@rynx-ai/server 0.1.11-beta.37 → 0.1.11-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/control-web/assets/{abnfDiagram-VRR7QNED-CmU_MmlR.js → abnfDiagram-VRR7QNED-D_NL89dn.js} +1 -1
- package/dist/control-web/assets/architecture-TIHT7OUA-C9wU1KtW.js +1 -0
- package/dist/control-web/assets/{architectureDiagram-ZJ3FMSHR-OecV-i7M.js → architectureDiagram-ZJ3FMSHR-CV0rxVH6.js} +1 -1
- package/dist/control-web/assets/{blockDiagram-677ZJIJ3-DOxDUxjd.js → blockDiagram-677ZJIJ3-Cc7nrkZh.js} +1 -1
- package/dist/control-web/assets/{c4Diagram-LMCZKHZV-D557d6cD.js → c4Diagram-LMCZKHZV-BPRU9m-F.js} +1 -1
- package/dist/control-web/assets/channel-BFm2_j8K.js +1 -0
- package/dist/control-web/assets/{chunk-32BRIVSS-BfXRqSpF.js → chunk-32BRIVSS-Bbq3O54m.js} +1 -1
- package/dist/control-web/assets/{chunk-52WLFC77-BeKggk68.js → chunk-52WLFC77-sD4al-Ob.js} +1 -1
- package/dist/control-web/assets/{chunk-C7G6YPKG-D0W6xHti.js → chunk-C7G6YPKG-DqHaDS1O.js} +1 -1
- package/dist/control-web/assets/{chunk-EX3LRPZG-D-s3PHl_.js → chunk-EX3LRPZG-36GNQ5wp.js} +1 -1
- package/dist/control-web/assets/{chunk-HOUHSVGY-Cz-4R9wb.js → chunk-HOUHSVGY-DeZ63q1j.js} +1 -1
- package/dist/control-web/assets/{chunk-ICXQ74PX-Jh1cDG2d.js → chunk-ICXQ74PX-D2yF6lD_.js} +1 -1
- package/dist/control-web/assets/{chunk-MOJQB5TN-Bne3Czi6.js → chunk-MOJQB5TN-CdaKyBz5.js} +1 -1
- package/dist/control-web/assets/{chunk-OGEWGWER-B3ysgOD5.js → chunk-OGEWGWER-eOXC7kiH.js} +1 -1
- package/dist/control-web/assets/{chunk-PUDLZKDR-CcXYtnKN.js → chunk-PUDLZKDR-6w0LILL_.js} +1 -1
- package/dist/control-web/assets/{chunk-Q4XR5HBZ-puXEgeqv.js → chunk-Q4XR5HBZ-CXgD5TGL.js} +1 -1
- package/dist/control-web/assets/{chunk-V7JOEXUC-C3tvTxnz.js → chunk-V7JOEXUC-BfoZ78b6.js} +1 -1
- package/dist/control-web/assets/{chunk-VR4S4FIN-DW_38atK.js → chunk-VR4S4FIN-BW2gCEMQ.js} +1 -1
- package/dist/control-web/assets/{chunk-WYO6CB5R-Bbp0lWuA.js → chunk-WYO6CB5R-CHn7hulw.js} +3 -3
- package/dist/control-web/assets/{chunk-ZGVPDNZ5-EJHunJJc.js → chunk-ZGVPDNZ5-CmFP0-fr.js} +1 -1
- package/dist/control-web/assets/classDiagram-OUVF2IWQ-CUe_bETB.js +1 -0
- package/dist/control-web/assets/classDiagram-v2-EOCWNBFH-CUe_bETB.js +1 -0
- package/dist/control-web/assets/{cynefin-VYW2F7L2-BaT-TB_Y.js → cynefin-VYW2F7L2-NaLr7Qlq.js} +1 -1
- package/dist/control-web/assets/{cynefinDiagram-TSTJHNR4-sW0lbfzR.js → cynefinDiagram-TSTJHNR4-C90wpjAI.js} +1 -1
- package/dist/control-web/assets/{dagre-VKFMJZFB-DszFEQ50.js → dagre-VKFMJZFB-BxrPFWTb.js} +1 -1
- package/dist/control-web/assets/{diagram-FQU43EPY-BPueVs2y.js → diagram-FQU43EPY-VIQINsvz.js} +1 -1
- package/dist/control-web/assets/{diagram-G47NLZAW-BSgnrddi.js → diagram-G47NLZAW-DFeAfYXn.js} +1 -1
- package/dist/control-web/assets/{diagram-NH7WQ7WH-1WyXWZVF.js → diagram-NH7WQ7WH-ATzdppDd.js} +1 -1
- package/dist/control-web/assets/{diagram-OA4YK3LP--O72jADz.js → diagram-OA4YK3LP-DJZpWmbl.js} +1 -1
- package/dist/control-web/assets/{diagram-WEI45ONY-B2QpDXZ9.js → diagram-WEI45ONY-CqDHcW3g.js} +1 -1
- package/dist/control-web/assets/{dist-Dv-qw3vC.js → dist-Dx9YWgcW.js} +1 -1
- package/dist/control-web/assets/{ebnfDiagram-CCIWWBDH-DSs-ystO.js → ebnfDiagram-CCIWWBDH-DnP6dHND.js} +1 -1
- package/dist/control-web/assets/{erDiagram-Q63AITRT-Dd6hMu35.js → erDiagram-Q63AITRT-Bo8bFqrZ.js} +1 -1
- package/dist/control-web/assets/eventmodeling-45OFAUF4-DTN8wqsu.js +1 -0
- package/dist/control-web/assets/flowDiagram-23GEKE2U-BwjqRyvd.js +1 -0
- package/dist/control-web/assets/{ganttDiagram-NO4QXBWP-COHCKhqO.js → ganttDiagram-NO4QXBWP-kxQaBTzd.js} +1 -1
- package/dist/control-web/assets/{gitGraph-TEB2WS4Q-CysYOV0u.js → gitGraph-TEB2WS4Q-a646NnuJ.js} +1 -1
- package/dist/control-web/assets/{gitGraphDiagram-IHSO6WYX-RDxV8G1J.js → gitGraphDiagram-IHSO6WYX-BBe0q0At.js} +1 -1
- package/dist/control-web/assets/{highlighted-body-OFNGDK62-D0q5eseS.js → highlighted-body-OFNGDK62-DVCHy9oI.js} +1 -1
- package/dist/control-web/assets/{index-CfRLpoTC.js → index-D7URT6K_.js} +23 -23
- package/dist/control-web/assets/{info-DKCQHKI2-C8E_rmu3.js → info-DKCQHKI2-Cp_JrY-b.js} +1 -1
- package/dist/control-web/assets/{infoDiagram-FWYZ7A6U-BmH8cm18.js → infoDiagram-FWYZ7A6U-CAm-h4F_.js} +1 -1
- package/dist/control-web/assets/{ishikawaDiagram-FXEZZL3T-DR1Vhzx7.js → ishikawaDiagram-FXEZZL3T-O17pqcWr.js} +1 -1
- package/dist/control-web/assets/{journeyDiagram-5HDEW3XC-C7gr8G1Z.js → journeyDiagram-5HDEW3XC-DQ-JuSoR.js} +1 -1
- package/dist/control-web/assets/{kanban-definition-HUTT4EX6-Cg_3ELUy.js → kanban-definition-HUTT4EX6-Cgv3kPbm.js} +1 -1
- package/dist/control-web/assets/katex-CyHG4N6b.js +1 -0
- package/dist/control-web/assets/{line-Dt86r9Z9.js → line-DUsXzGJZ.js} +1 -1
- package/dist/control-web/assets/{markdown-streamdown-OYO-HVz6.js → markdown-streamdown-4N4AcNp5.js} +8 -8
- package/dist/control-web/assets/mermaid-GHXKKRXX-BElZGKGd.js +1 -0
- package/dist/control-web/assets/{mermaid-parser.core-pxV_1Fef.js → mermaid-parser.core-VMln12Kd.js} +3 -3
- package/dist/control-web/assets/{mindmap-definition-LN4V7U3C-CBevDwDF.js → mindmap-definition-LN4V7U3C-Bn0lH-UM.js} +1 -1
- package/dist/control-web/assets/{packet-7NZHBO7P-A9sKZzEL.js → packet-7NZHBO7P-Zw8iJ8lo.js} +1 -1
- package/dist/control-web/assets/{pegDiagram-2B236MQR-BTIvrl_V.js → pegDiagram-2B236MQR-CtF7vVs_.js} +1 -1
- package/dist/control-web/assets/{pie-RZYD4A2V-DUzb4QBE.js → pie-RZYD4A2V-su_3QGU2.js} +1 -1
- package/dist/control-web/assets/{pieDiagram-ENE6RG2P-CzmJJofh.js → pieDiagram-ENE6RG2P-BkMUBLE1.js} +1 -1
- package/dist/control-web/assets/{quadrantDiagram-ABIIQ3AL-D6bXvpAG.js → quadrantDiagram-ABIIQ3AL-ba-VaqMe.js} +1 -1
- package/dist/control-web/assets/{radar-I7S5WNFK-BV54nFux.js → radar-I7S5WNFK-Dat0rqem.js} +1 -1
- package/dist/control-web/assets/{railroad-3IZDKUUU-B2cY_UXv.js → railroad-3IZDKUUU-Dh2-s8r8.js} +1 -1
- package/dist/control-web/assets/railroad-abnf-AHOZXSZD-CNUwq0JR.js +1 -0
- package/dist/control-web/assets/railroad-ebnf-EBAXGLYW-RHr0duea.js +1 -0
- package/dist/control-web/assets/railroad-peg-LSFZ7HO6-CVBWS2eU.js +1 -0
- package/dist/control-web/assets/{railroadDiagram-RFXS5EU6-D_fo16vD.js → railroadDiagram-RFXS5EU6-BiJX3SY-.js} +1 -1
- package/dist/control-web/assets/{requirementDiagram-TGXJPOKE-D2yP7TUp.js → requirementDiagram-TGXJPOKE-CFfakCzs.js} +1 -1
- package/dist/control-web/assets/{sankeyDiagram-HTMAVEWB-By_qJ9BM.js → sankeyDiagram-HTMAVEWB-jgDi0God.js} +1 -1
- package/dist/control-web/assets/{sequenceDiagram-DBY2YBRQ-DgX1K1l4.js → sequenceDiagram-DBY2YBRQ-DBfyyb0N.js} +1 -1
- package/dist/control-web/assets/{stateDiagram-2N3HPSRC-CeUgjm3D.js → stateDiagram-2N3HPSRC-Dwb_ncVi.js} +1 -1
- package/dist/control-web/assets/stateDiagram-v2-6OUMAXLB-DI0opaA1.js +1 -0
- package/dist/control-web/assets/{swimlanes-5IMT3BWC-CTlZZmMW.js → swimlanes-5IMT3BWC-DW0LuiIV.js} +1 -1
- package/dist/control-web/assets/swimlanesDiagram-G3AALYLV-DDTVjcOR.js +8 -0
- package/dist/control-web/assets/{timeline-definition-FHXFAJF6-Cq3seh59.js → timeline-definition-FHXFAJF6-DeX4B_B8.js} +1 -1
- package/dist/control-web/assets/{treeView-QDETBFTQ-Cumz-G5q.js → treeView-QDETBFTQ-D1UXtICj.js} +1 -1
- package/dist/control-web/assets/{treemap-6X3UGDF4-Bq5v5pf6.js → treemap-6X3UGDF4-CrppzjZH.js} +1 -1
- package/dist/control-web/assets/{vennDiagram-L72KCM5P-Bx9PN1Pw.js → vennDiagram-L72KCM5P-BYpf-7VR.js} +1 -1
- package/dist/control-web/assets/{wardley-OPB4EBWU-DDRYn_rw.js → wardley-OPB4EBWU-B9rA0UsV.js} +1 -1
- package/dist/control-web/assets/{wardleyDiagram-EHGQE667-DOHp80dH.js → wardleyDiagram-EHGQE667-BdvAUa5F.js} +1 -1
- package/dist/control-web/assets/{xychartDiagram-FW5EYKEG-kaZ1Sn-e.js → xychartDiagram-FW5EYKEG-BaEV3pGm.js} +1 -1
- package/dist/control-web/index.html +1 -1
- package/dist/machine-session-service.d.ts +7 -1
- package/dist/machine-session-service.js +12 -1
- package/dist/remote-runtime-session-projection.js +6 -0
- package/dist/server.d.ts +17 -3
- package/dist/server.js +155 -32
- package/dist/session-pending-inputs.d.ts +2 -0
- package/dist/session-pending-inputs.js +6 -3
- package/dist/session-runtime-index.d.ts +1 -0
- package/dist/session-runtime-index.js +28 -2
- package/package.json +7 -7
- package/dist/control-web/assets/architecture-TIHT7OUA-BA6n-Dzl.js +0 -1
- package/dist/control-web/assets/channel-CvSP6WIQ.js +0 -1
- package/dist/control-web/assets/classDiagram-OUVF2IWQ-CbpSOtxx.js +0 -1
- package/dist/control-web/assets/classDiagram-v2-EOCWNBFH-CbpSOtxx.js +0 -1
- package/dist/control-web/assets/eventmodeling-45OFAUF4-B4JspsqG.js +0 -1
- package/dist/control-web/assets/flowDiagram-23GEKE2U-Ium-zrch.js +0 -1
- package/dist/control-web/assets/katex-BSYj5LXs.js +0 -1
- package/dist/control-web/assets/mermaid-GHXKKRXX-BybKptJt.js +0 -1
- package/dist/control-web/assets/railroad-abnf-AHOZXSZD-C6gyeMKO.js +0 -1
- package/dist/control-web/assets/railroad-ebnf-EBAXGLYW-CTnsShXg.js +0 -1
- package/dist/control-web/assets/railroad-peg-LSFZ7HO6-NgilCakK.js +0 -1
- package/dist/control-web/assets/stateDiagram-v2-6OUMAXLB-CsJT1Rvc.js +0 -1
- package/dist/control-web/assets/swimlanesDiagram-G3AALYLV-CzaTMmXS.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-streamdown-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-streamdown-4N4AcNp5.js","assets/rolldown-runtime-hePW80VL.js","assets/lib-BZ_F5vVH.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-B6xuSHsQ.js","assets/chunk-WYO6CB5R-CHn7hulw.js","assets/chunk-ICXQ74PX-D2yF6lD_.js","assets/dist-v5Q1xZ2K.js","assets/chunk-HOUHSVGY-DeZ63q1j.js","assets/chunk-Q4XR5HBZ-CXgD5TGL.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-eOXC7kiH.js","assets/chunk-C7G6YPKG-DqHaDS1O.js","assets/chunk-ZGVPDNZ5-CmFP0-fr.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-52WLFC77-sD4al-Ob.js","assets/line-DUsXzGJZ.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/markdown-streamdown-DEcVZfaU.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var I=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},L={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.7`})),r=t(((e,t)=>{t.exports=n()})),i=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),a=t(((e,t)=>{t.exports=i()})),o=t((e=>{var t=r();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(n(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return s(e,t,null,r)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.7`})),s=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=o()})),c=t((e=>{var t=a(),n=r(),i=s();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(o(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return f(i),e;if(a===r)return f(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=a;break}if(c===r){s=!0,r=i,n=a;break}c=c.sibling}if(!s){for(c=a.child;c;){if(c===n){s=!0,n=a,r=i;break}if(c===r){s=!0,r=a,n=i;break}c=c.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function P(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?P(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return P(e(t))}catch{}}return null}var F=Array.isArray,I=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee={pending:!1,data:null,method:null,action:null},te=[],ne=-1;function re(e){return{current:e}}function R(e){0>ne||(e.current=te[ne],te[ne]=null,ne--)}function ie(e,t){ne++,te[ne]=e.current,e.current=t}var ae=re(null),oe=re(null),se=re(null),ce=re(null);function le(e,t){switch(ie(se,t),ie(oe,e),ie(ae,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Kd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Kd(t),e=qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}R(ae),ie(ae,e)}function ue(){R(ae),R(oe),R(se)}function de(e){e.memoizedState!==null&&ie(ce,e);var t=ae.current,n=qd(t,e.type);t!==n&&(ie(oe,e),ie(ae,n))}function fe(e){oe.current===e&&(R(ae),R(oe)),ce.current===e&&(R(ce),rp._currentValue=ee)}var pe,me;function he(e){if(pe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);pe=t&&t[1]||``,me=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+pe+e+me}var ge=!1;function _e(e,t){if(!e||ge)return``;ge=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -52,20 +52,20 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
|
|
|
52
52
|
`},us=0,ds=[];function fs(e){var t=u.useRef([]),n=u.useRef([0,0]),r=u.useRef(),i=u.useState(us++)[0],a=u.useState(Po)[0],o=u.useRef(e);u.useEffect(function(){o.current=e},[e]),u.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=lo([e.lockRef.current],(e.shards||[]).map(ss),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=u.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=as(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Qo(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Qo(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return is(h,t,e,h===`h`?s:c,!0)},[]),c=u.useCallback(function(e){var n=e;if(!(!ds.length||ds[ds.length-1]!==a)){var r=`deltaY`in n?os(n):as(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&cs(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(ss).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=u.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ps(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),d=u.useCallback(function(e){n.current=as(e),r.current=void 0},[]),f=u.useCallback(function(t){l(t.type,os(t),t.target,s(t,e.lockRef.current))},[]),p=u.useCallback(function(t){l(t.type,as(t),t.target,s(t,e.lockRef.current))},[]);u.useEffect(function(){return ds.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener(`wheel`,c,qo),document.addEventListener(`touchmove`,c,qo),document.addEventListener(`touchstart`,d,qo),function(){ds=ds.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,qo),document.removeEventListener(`touchmove`,c,qo),document.removeEventListener(`touchstart`,d,qo)}},[]);var m=e.removeScrollBar,h=e.inert;return u.createElement(u.Fragment,null,h?u.createElement(a,{styles:ls(i)}):null,m?u.createElement(Wo,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ps(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var ms=wo(To,fs),hs=u.forwardRef(function(e,t){return u.createElement(Do,G({},e,{ref:t,sideCar:ms}))});hs.classNames=Do.classNames;var gs=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},_s=new WeakMap,vs=new WeakMap,ys={},bs=0,xs=function(e){return e&&(e.host||xs(e.parentNode))},Ss=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=xs(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Cs=function(e,t,n,r){var i=Ss(t,Array.isArray(e)?e:[e]);ys[n]||(ys[n]=new WeakMap);var a=ys[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(_s.get(e)||0)+1,l=(a.get(e)||0)+1;_s.set(e,c),a.set(e,l),o.push(e),c===1&&i&&vs.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),bs++,function(){o.forEach(function(e){var t=_s.get(e)-1,i=a.get(e)-1;_s.set(e,t),a.set(e,i),t||(vs.has(e)||e.removeAttribute(r),vs.delete(e)),i||e.removeAttribute(n)}),bs--,bs||(_s=new WeakMap,_s=new WeakMap,vs=new WeakMap,ys={})}},ws=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||gs(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Cs(r,i,n,`aria-hidden`)):function(){return null}},Ts=`Dialog`,[Es,Ds]=Wi(Ts),[Os,ks]=Es(Ts),As=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=u.useRef(null),c=u.useRef(null),[l,d]=ea({prop:r,defaultProp:i??!1,onChange:a,caller:Ts});return(0,H.jsx)(Os,{scope:t,triggerRef:s,contentRef:c,contentId:Qi(),titleId:Qi(),descriptionId:Qi(),open:l,onOpenChange:d,onOpenToggle:u.useCallback(()=>d(e=>!e),[d]),modal:o,children:n})};As.displayName=Ts;var js=`DialogTrigger`,Ms=u.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ks(js,n),a=Ji(t,i.triggerRef);return(0,H.jsx)(W.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Qs(i.open),...r,ref:a,onClick:U(e.onClick,i.onOpenToggle)})});Ms.displayName=js;var Ns=`DialogPortal`,[Ps,Fs]=Es(Ns,{forceMount:void 0}),Is=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=ks(Ns,t);return(0,H.jsx)(Ps,{scope:t,forceMount:n,children:u.Children.map(r,e=>(0,H.jsx)(Qa,{present:n||a.open,children:(0,H.jsx)(Xa,{asChild:!0,container:i,children:e})}))})};Is.displayName=Ns;var Ls=`DialogOverlay`,Rs=u.forwardRef((e,t)=>{let n=Fs(Ls,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ks(Ls,e.__scopeDialog);return a.modal?(0,H.jsx)(Qa,{present:r||a.open,children:(0,H.jsx)(Bs,{...i,ref:t})}):null});Rs.displayName=Ls;var zs=ra(`DialogOverlay.RemoveScroll`),Bs=u.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ks(Ls,n),a=Ji(t,Da());return(0,H.jsx)(hs,{as:zs,allowPinchZoom:!0,shards:[i.contentRef],children:(0,H.jsx)(W.div,{"data-state":Qs(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})}),Vs=`DialogContent`,Hs=u.forwardRef((e,t)=>{let n=Fs(Vs,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ks(Vs,e.__scopeDialog);return(0,H.jsx)(Qa,{present:r||a.open,children:a.modal?(0,H.jsx)(Us,{...i,ref:t}):(0,H.jsx)(Ws,{...i,ref:t})})});Hs.displayName=Vs;var Us=u.forwardRef((e,t)=>{let n=ks(Vs,e.__scopeDialog),r=u.useRef(null),i=Ji(t,n.contentRef,r);return u.useEffect(()=>{let e=r.current;if(e)return ws(e)},[]),(0,H.jsx)(Gs,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:U(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:U(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:U(e.onFocusOutside,e=>e.preventDefault())})}),Ws=u.forwardRef((e,t)=>{let n=ks(Vs,e.__scopeDialog),r=u.useRef(!1),i=u.useRef(!1);return(0,H.jsx)(Gs,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Gs=u.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=ks(Vs,n);return oo(),(0,H.jsx)(H.Fragment,{children:(0,H.jsx)(La,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,H.jsx)(wa,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":Qs(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),Ks=`DialogTitle`,qs=u.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ks(Ks,n);return(0,H.jsx)(W.h2,{id:i.titleId,...r,ref:t})});qs.displayName=Ks;var Js=`DialogDescription`,Ys=u.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ks(Js,n);return(0,H.jsx)(W.p,{id:i.descriptionId,...r,ref:t})});Ys.displayName=Js;var Xs=`DialogClose`,Zs=u.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ks(Xs,n);return(0,H.jsx)(W.button,{type:`button`,...r,ref:t,onClick:U(e.onClick,()=>i.onOpenChange(!1))})});Zs.displayName=Xs;function Qs(e){return e?`open`:`closed`}var $s=`AlertDialog`,[ec,tc]=Wi($s,[Ds]),nc=Ds(),rc=e=>{let{__scopeAlertDialog:t,...n}=e,r=nc(t);return(0,H.jsx)(As,{...r,...n,modal:!0})};rc.displayName=$s;var ic=`AlertDialogTrigger`,ac=u.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=nc(n);return(0,H.jsx)(Ms,{...i,...r,ref:t})});ac.displayName=ic;var oc=`AlertDialogPortal`,sc=e=>{let{__scopeAlertDialog:t,...n}=e,r=nc(t);return(0,H.jsx)(Is,{...r,...n})};sc.displayName=oc;var cc=`AlertDialogOverlay`,lc=u.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=nc(n);return(0,H.jsx)(Rs,{...i,...r,ref:t})});lc.displayName=cc;var uc=`AlertDialogContent`,[dc,fc]=ec(uc),pc=u.forwardRef((e,t)=>{let{__scopeAlertDialog:n,children:r,...i}=e,a=nc(n),o=Ji(t,u.useRef(null)),s=u.useRef(null);return(0,H.jsx)(dc,{scope:n,cancelRef:s,children:(0,H.jsx)(Hs,{role:`alertdialog`,...a,...i,ref:o,onOpenAutoFocus:U(i.onOpenAutoFocus,e=>{e.preventDefault(),s.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})});pc.displayName=uc;var mc=`AlertDialogTitle`,hc=u.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=nc(n);return(0,H.jsx)(qs,{...i,...r,ref:t})});hc.displayName=mc;var gc=`AlertDialogDescription`,_c=u.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=nc(n);return(0,H.jsx)(Ys,{...i,...r,ref:t})});_c.displayName=gc;var vc=`AlertDialogAction`,yc=u.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=nc(n);return(0,H.jsx)(Zs,{...i,...r,ref:t})});yc.displayName=vc;var bc=`AlertDialogCancel`,xc=u.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=fc(bc,n),a=nc(n),o=Ji(t,i);return(0,H.jsx)(Zs,{...a,...r,ref:o})});xc.displayName=bc;var Sc=rc,Cc=ac,wc=sc,Tc=lc,Ec=pc,Dc=yc,Oc=xc,kc=hc,Ac=_c;function jc(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=jc(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Mc(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=jc(e))&&(r&&(r+=` `),r+=t);return r}var Nc=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Pc=(e,t)=>({classGroupId:e,validator:t}),Fc=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Ic=`-`,Lc=[],Rc=`arbitrary..`,zc=e=>{let t=Hc(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return Vc(e);let n=e.split(Ic);return Bc(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?Nc(i,t):t:i||Lc}return n[e]||Lc}}},Bc=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=Bc(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(Ic):e.slice(t).join(Ic),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},Vc=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?Rc+r:void 0})(),Hc=e=>{let{theme:t,classGroups:n}=e;return Uc(n,t)},Uc=(e,t)=>{let n=Fc();for(let r in e){let i=e[r];Wc(i,n,r,t)}return n},Wc=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Gc(i,t,n,r)}},Gc=(e,t,n,r)=>{if(typeof e==`string`){Kc(e,t,n);return}if(typeof e==`function`){qc(e,t,n,r);return}Jc(e,t,n,r)},Kc=(e,t,n)=>{let r=e===``?t:Yc(t,e);r.classGroupId=n},qc=(e,t,n,r)=>{if(Xc(e)){Wc(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Pc(n,e))},Jc=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Wc(o,Yc(t,a),n,r)}},Yc=(e,t)=>{let n=e,r=t.split(Ic),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=Fc(),n.nextPart.set(t,i)),n=i}return n},Xc=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,Zc=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Qc=`!`,$c=`:`,el=[],tl=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),nl=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===$c){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Qc)?(c=s.slice(0,-1),l=!0):s.startsWith(Qc)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return tl(t,l,c,u)};if(t){let e=t+$c,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):tl(el,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},rl=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},il=e=>({cache:Zc(e.cacheSize),parseClassName:nl(e),sortModifiers:rl(e),postfixLookupClassGroupIds:al(e),...zc(e)}),al=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},ol=/\s+/,sl=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(ol),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+Qc:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},cl=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=ll(n))&&(i&&(i+=` `),i+=r);return i},ll=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=ll(e[r]))&&(n&&(n+=` `),n+=t);return n},ul=(e,...t)=>{let n,r,i,a,o=o=>(n=il(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=sl(e,n);return i(e,a),a};return a=o,(...e)=>a(cl(...e))},dl=[],fl=e=>{let t=t=>t[e]||dl;return t.isThemeGetter=!0,t},pl=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ml=/^\((?:(\w[\w-]*):)?(.+)\)$/i,hl=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,gl=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_l=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,vl=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,yl=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,bl=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,xl=e=>hl.test(e),Sl=e=>!!e&&!Number.isNaN(Number(e)),Cl=e=>!!e&&Number.isInteger(Number(e)),wl=e=>e.endsWith(`%`)&&Sl(e.slice(0,-1)),Tl=e=>gl.test(e),El=()=>!0,Dl=e=>_l.test(e)&&!vl.test(e),Ol=()=>!1,kl=e=>yl.test(e),Al=e=>bl.test(e),jl=e=>!K(e)&&!q(e),Ml=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),Nl=e=>Jl(e,Ql,Ol),K=e=>pl.test(e),Pl=e=>Jl(e,$l,Dl),Fl=e=>Jl(e,eu,Sl),Il=e=>Jl(e,nu,El),Ll=e=>Jl(e,tu,Ol),Rl=e=>Jl(e,Xl,Ol),zl=e=>Jl(e,Zl,Al),Bl=e=>Jl(e,ru,kl),q=e=>ml.test(e),Vl=e=>Yl(e,$l),Hl=e=>Yl(e,tu),Ul=e=>Yl(e,Xl),Wl=e=>Yl(e,Ql),Gl=e=>Yl(e,Zl),Kl=e=>Yl(e,ru,!0),ql=e=>Yl(e,nu,!0),Jl=(e,t,n)=>{let r=pl.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Yl=(e,t,n=!1)=>{let r=ml.exec(e);return r?r[1]?t(r[1]):n:!1},Xl=e=>e===`position`||e===`percentage`,Zl=e=>e===`image`||e===`url`,Ql=e=>e===`length`||e===`size`||e===`bg-size`,$l=e=>e===`length`,eu=e=>e===`number`,tu=e=>e===`family-name`,nu=e=>e===`number`||e===`weight`,ru=e=>e===`shadow`,iu=ul(()=>{let e=fl(`color`),t=fl(`font`),n=fl(`text`),r=fl(`font-weight`),i=fl(`tracking`),a=fl(`leading`),o=fl(`breakpoint`),s=fl(`container`),c=fl(`spacing`),l=fl(`radius`),u=fl(`shadow`),d=fl(`inset-shadow`),f=fl(`text-shadow`),p=fl(`drop-shadow`),m=fl(`blur`),h=fl(`perspective`),g=fl(`aspect`),_=fl(`ease`),v=fl(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),q,K],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[q,K,c],T=()=>[xl,`full`,`auto`,...w()],E=()=>[Cl,`none`,`subgrid`,q,K],D=()=>[`auto`,{span:[`full`,Cl,q,K]},Cl,q,K],O=()=>[Cl,`auto`,q,K],k=()=>[`auto`,`min`,`max`,`fr`,q,K],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[xl,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[xl,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],F=()=>[xl,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],I=()=>[e,q,K],L=()=>[...b(),Ul,Rl,{position:[q,K]}],ee=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],te=()=>[`auto`,`cover`,`contain`,Wl,Nl,{size:[q,K]}],ne=()=>[wl,Vl,Pl],re=()=>[``,`none`,`full`,l,q,K],R=()=>[``,Sl,Vl,Pl],ie=()=>[`solid`,`dashed`,`dotted`,`double`],ae=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],oe=()=>[Sl,wl,Ul,Rl],se=()=>[``,`none`,m,q,K],ce=()=>[`none`,Sl,q,K],le=()=>[`none`,Sl,q,K],ue=()=>[Sl,q,K],de=()=>[xl,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[Tl],breakpoint:[Tl],color:[El],container:[Tl],"drop-shadow":[Tl],ease:[`in`,`out`,`in-out`],font:[jl],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[Tl],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[Tl],shadow:[Tl],spacing:[`px`,Sl],text:[Tl],"text-shadow":[Tl],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,xl,K,q,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,q,K]}],"container-named":[Ml],columns:[{columns:[Sl,K,q,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[Cl,`auto`,q,K]}],basis:[{basis:[xl,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[Sl,xl,`auto`,`initial`,`none`,K]}],grow:[{grow:[``,Sl,q,K]}],shrink:[{shrink:[``,Sl,q,K]}],order:[{order:[Cl,`first`,`last`,`none`,q,K]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...P()]}],"min-inline-size":[{"min-inline":[`auto`,...P()]}],"max-inline-size":[{"max-inline":[`none`,...P()]}],"block-size":[{block:[`auto`,...F()]}],"min-block-size":[{"min-block":[`auto`,...F()]}],"max-block-size":[{"max-block":[`none`,...F()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,Vl,Pl]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,ql,Il]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,wl,K]}],"font-family":[{font:[Hl,Ll,t]}],"font-features":[{"font-features":[K]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,q,K]}],"line-clamp":[{"line-clamp":[Sl,`none`,q,Fl]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,q,K]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,q,K]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...ie(),`wavy`]}],"text-decoration-thickness":[{decoration:[Sl,`from-font`,`auto`,q,Pl]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[Sl,`auto`,q,K]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[Cl,q,K]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,q,K]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,q,K]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:L()}],"bg-repeat":[{bg:ee()}],"bg-size":[{bg:te()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},Cl,q,K],radial:[``,q,K],conic:[Cl,q,K]},Gl,zl]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:ne()}],"gradient-via-pos":[{via:ne()}],"gradient-to-pos":[{to:ne()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:re()}],"rounded-s":[{"rounded-s":re()}],"rounded-e":[{"rounded-e":re()}],"rounded-t":[{"rounded-t":re()}],"rounded-r":[{"rounded-r":re()}],"rounded-b":[{"rounded-b":re()}],"rounded-l":[{"rounded-l":re()}],"rounded-ss":[{"rounded-ss":re()}],"rounded-se":[{"rounded-se":re()}],"rounded-ee":[{"rounded-ee":re()}],"rounded-es":[{"rounded-es":re()}],"rounded-tl":[{"rounded-tl":re()}],"rounded-tr":[{"rounded-tr":re()}],"rounded-br":[{"rounded-br":re()}],"rounded-bl":[{"rounded-bl":re()}],"border-w":[{border:R()}],"border-w-x":[{"border-x":R()}],"border-w-y":[{"border-y":R()}],"border-w-s":[{"border-s":R()}],"border-w-e":[{"border-e":R()}],"border-w-bs":[{"border-bs":R()}],"border-w-be":[{"border-be":R()}],"border-w-t":[{"border-t":R()}],"border-w-r":[{"border-r":R()}],"border-w-b":[{"border-b":R()}],"border-w-l":[{"border-l":R()}],"divide-x":[{"divide-x":R()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":R()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...ie(),`hidden`,`none`]}],"divide-style":[{divide:[...ie(),`hidden`,`none`]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...ie(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[Sl,q,K]}],"outline-w":[{outline:[``,Sl,Vl,Pl]}],"outline-color":[{outline:I()}],shadow:[{shadow:[``,`none`,u,Kl,Bl]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":[`none`,d,Kl,Bl]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:R()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[Sl,Pl]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":R()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":[`none`,f,Kl,Bl]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[Sl,q,K]}],"mix-blend":[{"mix-blend":[...ae(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ae()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[Sl]}],"mask-image-linear-from-pos":[{"mask-linear-from":oe()}],"mask-image-linear-to-pos":[{"mask-linear-to":oe()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":oe()}],"mask-image-t-to-pos":[{"mask-t-to":oe()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":oe()}],"mask-image-r-to-pos":[{"mask-r-to":oe()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":oe()}],"mask-image-b-to-pos":[{"mask-b-to":oe()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":oe()}],"mask-image-l-to-pos":[{"mask-l-to":oe()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":oe()}],"mask-image-x-to-pos":[{"mask-x-to":oe()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":oe()}],"mask-image-y-to-pos":[{"mask-y-to":oe()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[q,K]}],"mask-image-radial-from-pos":[{"mask-radial-from":oe()}],"mask-image-radial-to-pos":[{"mask-radial-to":oe()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[Sl]}],"mask-image-conic-from-pos":[{"mask-conic-from":oe()}],"mask-image-conic-to-pos":[{"mask-conic-to":oe()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:L()}],"mask-repeat":[{mask:ee()}],"mask-size":[{mask:te()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,q,K]}],filter:[{filter:[``,`none`,q,K]}],blur:[{blur:se()}],brightness:[{brightness:[Sl,q,K]}],contrast:[{contrast:[Sl,q,K]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Kl,Bl]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:[``,Sl,q,K]}],"hue-rotate":[{"hue-rotate":[Sl,q,K]}],invert:[{invert:[``,Sl,q,K]}],saturate:[{saturate:[Sl,q,K]}],sepia:[{sepia:[``,Sl,q,K]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,q,K]}],"backdrop-blur":[{"backdrop-blur":se()}],"backdrop-brightness":[{"backdrop-brightness":[Sl,q,K]}],"backdrop-contrast":[{"backdrop-contrast":[Sl,q,K]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,Sl,q,K]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Sl,q,K]}],"backdrop-invert":[{"backdrop-invert":[``,Sl,q,K]}],"backdrop-opacity":[{"backdrop-opacity":[Sl,q,K]}],"backdrop-saturate":[{"backdrop-saturate":[Sl,q,K]}],"backdrop-sepia":[{"backdrop-sepia":[``,Sl,q,K]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,q,K]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[Sl,`initial`,q,K]}],ease:[{ease:[`linear`,`initial`,_,q,K]}],delay:[{delay:[Sl,q,K]}],animate:[{animate:[`none`,v,q,K]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,q,K]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ce()}],"rotate-x":[{"rotate-x":ce()}],"rotate-y":[{"rotate-y":ce()}],"rotate-z":[{"rotate-z":ce()}],scale:[{scale:le()}],"scale-x":[{"scale-x":le()}],"scale-y":[{"scale-y":le()}],"scale-z":[{"scale-z":le()}],"scale-3d":[`scale-3d`],skew:[{skew:ue()}],"skew-x":[{"skew-x":ue()}],"skew-y":[{"skew-y":ue()}],transform:[{transform:[q,K,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:de()}],"translate-x":[{"translate-x":de()}],"translate-y":[{"translate-y":de()}],"translate-z":[{"translate-z":de()}],"translate-none":[`translate-none`],zoom:[{zoom:[Cl,q,K]}],accent:[{accent:I()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:I()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,q,K]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,q,K]}],fill:[{fill:[`none`,...I()]}],"stroke-w":[{stroke:[Sl,Vl,Pl,Fl]}],stroke:[{stroke:[`none`,...I()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function au(...e){return iu(Mc(e))}var ou=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,su=Mc,cu=(e,t)=>n=>{if(t?.variants==null)return su(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=ou(t)||ou(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return su(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},lu=cu(`group/button inline-flex shrink-0 items-center justify-center whitespace-nowrap rounded-lg border border-transparent bg-clip-padding text-sm font-medium transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/80`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)]`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}}),J=u.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},a)=>(0,H.jsx)(r?ia:`button`,{ref:a,"data-slot":`button`,"data-variant":t??`default`,"data-size":n??`default`,className:au(lu({variant:t,size:n,className:e})),...i}));J.displayName=`Button`;function uu(e){return(0,H.jsx)(Sc,{"data-slot":`alert-dialog`,...e})}var du=u.forwardRef((e,t)=>(0,H.jsx)(Cc,{ref:t,"data-slot":`alert-dialog-trigger`,...e}));du.displayName=Cc.displayName;function fu(e){return(0,H.jsx)(wc,{"data-slot":`alert-dialog-portal`,...e})}var pu=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Tc,{ref:n,"data-slot":`alert-dialog-overlay`,className:au(`fixed inset-0 z-50 bg-black/10 duration-100 supports-[backdrop-filter]:backdrop-blur-xs data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0`,e),...t}));pu.displayName=Tc.displayName;var mu=u.forwardRef(({className:e,size:t=`default`,...n},r)=>(0,H.jsxs)(fu,{children:[(0,H.jsx)(pu,{}),(0,H.jsx)(Ec,{ref:r,"data-slot":`alert-dialog-content`,"data-size":t,className:au(`group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-[calc(100%-2rem)] min-w-0 -translate-x-1/2 -translate-y-1/2 grid-cols-1 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 [&>*]:min-w-0`,e),...n})]}));mu.displayName=Ec.displayName;function hu({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:au(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function gu({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:au(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function _u({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`alert-dialog-media`,className:au(`mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6`,e),...t})}var vu=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(kc,{ref:n,"data-slot":`alert-dialog-title`,className:au(`text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t}));vu.displayName=kc.displayName;var yu=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Ac,{ref:n,"data-slot":`alert-dialog-description`,className:au(`text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t}));yu.displayName=Ac.displayName;var bu=u.forwardRef(({className:e,variant:t=`default`,size:n=`default`,...r},i)=>(0,H.jsx)(J,{variant:t,size:n,asChild:!0,children:(0,H.jsx)(Dc,{ref:i,"data-slot":`alert-dialog-action`,className:au(e),...r})}));bu.displayName=Dc.displayName;var xu=u.forwardRef(({className:e,variant:t=`outline`,size:n=`default`,...r},i)=>(0,H.jsx)(J,{variant:t,size:n,asChild:!0,children:(0,H.jsx)(Oc,{ref:i,"data-slot":`alert-dialog-cancel`,className:au(e),...r})}));xu.displayName=Oc.displayName;function Su(e){return(0,H.jsx)(As,{"data-slot":`dialog`,...e})}var Cu=u.forwardRef((e,t)=>(0,H.jsx)(Ms,{ref:t,"data-slot":`dialog-trigger`,...e}));Cu.displayName=Ms.displayName;function wu(e){return(0,H.jsx)(Is,{"data-slot":`dialog-portal`,...e})}var Tu=u.forwardRef((e,t)=>(0,H.jsx)(Zs,{ref:t,"data-slot":`dialog-close`,...e}));Tu.displayName=Zs.displayName;var Eu=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Rs,{ref:n,"data-slot":`dialog-overlay`,className:au(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-[backdrop-filter]:backdrop-blur-xs data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0`,e),...t}));Eu.displayName=Rs.displayName;var Du=u.forwardRef(({className:e,children:t,showCloseButton:n=!0,...r},i)=>(0,H.jsxs)(wu,{children:[(0,H.jsx)(Eu,{}),(0,H.jsxs)(Hs,{ref:i,"data-slot":`dialog-content`,className:au(`fixed top-1/2 left-1/2 z-50 grid w-full min-w-0 max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 grid-cols-1 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 [&>*]:min-w-0`,e),...r,children:[t,n&&(0,H.jsx)(Zs,{"data-slot":`dialog-close`,asChild:!0,children:(0,H.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-2`,children:[(0,H.jsx)(di,{"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]}));Du.displayName=Hs.displayName;function Ou({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`dialog-header`,className:au(`flex flex-col gap-2`,e),...t})}function ku({className:e,showCloseButton:t=!1,children:n,...r}){return(0,H.jsxs)(`div`,{"data-slot":`dialog-footer`,className:au(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,H.jsx)(Zs,{asChild:!0,children:(0,H.jsx)(J,{variant:`outline`,children:`Close`})})]})}var Au=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(qs,{ref:n,"data-slot":`dialog-title`,className:au(`text-base leading-none font-medium`,e),...t}));Au.displayName=qs.displayName;var ju=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Ys,{ref:n,"data-slot":`dialog-description`,className:au(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t}));ju.displayName=Ys.displayName;function Mu(e){let t=e+`CollectionProvider`,[n,r]=Wi(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=u.useRef(null),a=u.useRef(new Map).current;return(0,H.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=ra(s),l=u.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Ji(t,a(s,n).collectionRef);return(0,H.jsx)(c,{ref:i,children:r})});l.displayName=s;let d=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=ra(d),m=u.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=u.useRef(null),s=Ji(t,o),c=a(d,n);return u.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,H.jsx)(p,{[f]:``,ref:s,children:r})});m.displayName=d;function h(t){let n=a(e+`CollectionConsumer`,t);return u.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:m},h,r]}var Nu=u.createContext(void 0);function Pu(e){let t=u.useContext(Nu);return e||t||`ltr`}var Fu=[`top`,`right`,`bottom`,`left`],Iu=Math.min,Lu=Math.max,Ru=Math.round,zu=Math.floor,Bu=e=>({x:e,y:e}),Vu={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Hu(e,t,n){return Lu(e,Iu(t,n))}function Uu(e,t){return typeof e==`function`?e(t):e}function Wu(e){return e.split(`-`)[0]}function Gu(e){return e.split(`-`)[1]}function Ku(e){return e===`x`?`y`:`x`}function qu(e){return e===`y`?`height`:`width`}function Ju(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Yu(e){return Ku(Ju(e))}function Xu(e,t,n){n===void 0&&(n=!1);let r=Gu(e),i=Yu(e),a=qu(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=ad(o)),[o,ad(o)]}function Zu(e){let t=ad(e);return[Qu(e),t,Qu(t)]}function Qu(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var $u=[`left`,`right`],ed=[`right`,`left`],td=[`top`,`bottom`],nd=[`bottom`,`top`];function rd(e,t,n){switch(e){case`top`:case`bottom`:return n?t?ed:$u:t?$u:ed;case`left`:case`right`:return t?td:nd;default:return[]}}function id(e,t,n,r){let i=Gu(e),a=rd(Wu(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Qu)))),a}function ad(e){let t=Wu(e);return Vu[t]+e.slice(t.length)}function od(e){return{top:0,right:0,bottom:0,left:0,...e}}function sd(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:od(e)}function cd(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ld(e,t,n){let{reference:r,floating:i}=e,a=Ju(t),o=Yu(t),s=qu(o),c=Wu(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Gu(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1)}return p}async function ud(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Uu(t,e),p=sd(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=cd(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=cd(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var dd=50,fd=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:ud},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ld(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<dd&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ld(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},pd=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Uu(e,t)||{};if(l==null)return{};let d=sd(u),f={x:n,y:r},p=Yu(i),m=qu(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Iu(d[_],T),D=Iu(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=Hu(O,A,k),M=!c.arrow&&Gu(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),md=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Uu(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Wu(r),_=Ju(o),v=Wu(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[ad(o)]:Zu(o)),x=p!==`none`;!d&&x&&b.push(...id(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Xu(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Ju(t)||T.every(e=>Ju(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Ju(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function hd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function gd(e){return Fu.some(t=>e[t]>=0)}var _d=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Uu(e,t);switch(i){case`referenceHidden`:{let e=hd(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:gd(e)}}}case`escaped`:{let e=hd(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:gd(e)}}}default:return{}}}}},vd=new Set([`left`,`top`]);async function yd(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Wu(n),s=Gu(n),c=Ju(n)===`y`,l=vd.has(o)?-1:1,u=a&&c?-1:1,d=Uu(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var bd=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await yd(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},xd=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Uu(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Ju(Wu(i)),p=Ku(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=Hu(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=Hu(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},Sd=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Uu(e,t),u={x:n,y:r},d=Ju(i),f=Ku(d),p=u[f],m=u[d],h=Uu(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=vd.has(Wu(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Cd=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=Uu(e,t),u=await o.detectOverflow(t,l),d=Wu(i),f=Gu(i),p=Ju(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=Iu(h-u[g],v),x=Iu(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=Lu(u.left,0),t=Lu(u.right,0),n=Lu(u.top,0),r=Lu(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:Lu(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:Lu(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function wd(){return typeof window<`u`}function Td(e){return Od(e)?(e.nodeName||``).toLowerCase():`#document`}function Ed(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Dd(e){return((Od(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Od(e){return wd()?e instanceof Node||e instanceof Ed(e).Node:!1}function kd(e){return wd()?e instanceof Element||e instanceof Ed(e).Element:!1}function Ad(e){return wd()?e instanceof HTMLElement||e instanceof Ed(e).HTMLElement:!1}function jd(e){return!wd()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Ed(e).ShadowRoot}function Md(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Ud(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Nd(e){return/^(table|td|th)$/.test(Td(e))}function Pd(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Fd=/transform|translate|scale|rotate|perspective|filter/,Id=/paint|layout|strict|content/,Ld=e=>!!e&&e!==`none`,Rd;function zd(e){let t=kd(e)?Ud(e):e;return Ld(t.transform)||Ld(t.translate)||Ld(t.scale)||Ld(t.rotate)||Ld(t.perspective)||!Vd()&&(Ld(t.backdropFilter)||Ld(t.filter))||Fd.test(t.willChange||``)||Id.test(t.contain||``)}function Bd(e){let t=Gd(e);for(;Ad(t)&&!Hd(t);){if(zd(t))return t;if(Pd(t))return null;t=Gd(t)}return null}function Vd(){return Rd??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Rd}function Hd(e){return/^(html|body|#document)$/.test(Td(e))}function Ud(e){return Ed(e).getComputedStyle(e)}function Wd(e){return kd(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Gd(e){if(Td(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||jd(e)&&e.host||Dd(e);return jd(t)?t.host:t}function Kd(e){let t=Gd(e);return Hd(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ad(t)&&Md(t)?t:Kd(t)}function qd(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Kd(e),i=r===e.ownerDocument?.body,a=Ed(r);if(i){let e=Jd(a);return t.concat(a,a.visualViewport||[],Md(r)?r:[],e&&n?qd(e):[])}return t.concat(r,qd(r,[],n))}function Jd(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Yd(e){let t=Ud(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Ad(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Ru(n)!==a||Ru(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Xd(e){return kd(e)?e:e.contextElement}function Zd(e){let t=Xd(e);if(!Ad(t))return Bu(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Yd(t),o=(a?Ru(n.width):n.width)/r,s=(a?Ru(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Qd=Bu(0);function $d(e){let t=Ed(e);return!Vd()||!t.visualViewport?Qd:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ef(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ed(e)?!1:t}function tf(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Xd(e),o=Bu(1);t&&(r?kd(r)&&(o=Zd(r)):o=Zd(e));let s=ef(a,n,r)?$d(a):Bu(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=Ed(a),t=r&&kd(r)?Ed(r):r,n=e,i=Jd(n);for(;i&&r&&t!==n;){let e=Zd(i),t=i.getBoundingClientRect(),r=Ud(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Ed(i),i=Jd(n)}}return cd({width:u,height:d,x:c,y:l})}function nf(e,t){let n=Wd(e).scrollLeft;return t?t.left+n:tf(Dd(e)).left+n}function rf(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-nf(e,n),y:n.top+t.scrollTop}}function af(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Dd(r),s=t?Pd(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Bu(1),u=Bu(0),d=Ad(r);if((d||!d&&!a)&&((Td(r)!==`body`||Md(o))&&(c=Wd(r)),d)){let e=tf(r);l=Zd(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?rf(o,c):Bu(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function of(e){return Array.from(e.getClientRects())}function sf(e){let t=Dd(e),n=Wd(e),r=e.ownerDocument.body,i=Lu(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Lu(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+nf(e),s=-n.scrollTop;return Ud(r).direction===`rtl`&&(o+=Lu(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var cf=25;function lf(e,t){let n=Ed(e),r=Dd(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Vd();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=nf(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=cf&&(a-=o)}else l<=cf&&(a+=l);return{width:a,height:o,x:s,y:c}}function uf(e,t){let n=tf(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Ad(e)?Zd(e):Bu(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function df(e,t,n){let r;if(t===`viewport`)r=lf(e,n);else if(t===`document`)r=sf(Dd(e));else if(kd(t))r=uf(t,n);else{let n=$d(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return cd(r)}function ff(e,t){let n=Gd(e);return n===t||!kd(n)||Hd(n)?!1:Ud(n).position===`fixed`||ff(n,t)}function pf(e,t){let n=t.get(e);if(n)return n;let r=qd(e,[],!1).filter(e=>kd(e)&&Td(e)!==`body`),i=null,a=Ud(e).position===`fixed`,o=a?Gd(e):e;for(;kd(o)&&!Hd(o);){let t=Ud(o),n=zd(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||Md(o)&&!n&&ff(e,o))?r=r.filter(e=>e!==o):i=t,o=Gd(o)}return t.set(e,r),r}function mf(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Pd(t)?[]:pf(t,this._c):[].concat(n),r],o=df(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=df(t,a[e],i);s=Lu(n.top,s),c=Iu(n.right,c),l=Iu(n.bottom,l),u=Lu(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function hf(e){let{width:t,height:n}=Yd(e);return{width:t,height:n}}function gf(e,t,n){let r=Ad(t),i=Dd(t),a=n===`fixed`,o=tf(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Bu(0);function l(){c.x=nf(i)}if(r||!r&&!a){if((Td(t)!==`body`||Md(i))&&(s=Wd(t)),r){let e=tf(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l()}a&&!r&&i&&l();let u=i&&!r&&!a?rf(i,s):Bu(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function _f(e){return Ud(e).position===`static`}function vf(e,t){if(!Ad(e)||Ud(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Dd(e)===n&&(n=n.ownerDocument.body),n}function yf(e,t){let n=Ed(e);if(Pd(e))return n;if(!Ad(e)){let t=Gd(e);for(;t&&!Hd(t);){if(kd(t)&&!_f(t))return t;t=Gd(t)}return n}let r=vf(e,t);for(;r&&Nd(r)&&_f(r);)r=vf(r,t);return r&&Hd(r)&&_f(r)&&!zd(r)?n:r||Bd(e)||n}var bf=async function(e){let t=this.getOffsetParent||yf,n=this.getDimensions,r=await n(e.floating);return{reference:gf(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function xf(e){return Ud(e).direction===`rtl`}var Sf={convertOffsetParentRelativeRectToViewportRelativeRect:af,getDocumentElement:Dd,getClippingRect:mf,getOffsetParent:yf,getElementRects:bf,getClientRects:of,getDimensions:hf,getScale:Zd,isElement:kd,isRTL:xf};function Cf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function wf(e,t){let n=null,r,i=Dd(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=zu(d),h=zu(i.clientWidth-(u+f)),g=zu(i.clientHeight-(d+p)),_=zu(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Lu(0,Iu(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Cf(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function Tf(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Xd(e),u=i||a?[...l?qd(l):[],...t?qd(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?wf(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?tf(e):null;c&&g();function g(){let t=tf(e);h&&!Cf(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Ef=bd,Df=xd,Of=md,kf=Cd,Af=_d,jf=pd,Mf=Sd,Nf=(e,t,n)=>{let r=new Map,i={platform:Sf,...n},a={...i.platform,_c:r};return fd(e,t,{...i,platform:a})},Pf=typeof document<`u`?u.useLayoutEffect:function(){};function Ff(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Ff(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Ff(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function If(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Lf(e,t){let n=If(e);return Math.round(t*n)/n}function Rf(e){let t=u.useRef(e);return Pf(()=>{t.current=e}),t}function zf(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[f,p]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=u.useState(r);Ff(m,r)||h(r);let[g,_]=u.useState(null),[v,y]=u.useState(null),b=u.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=u.useCallback(e=>{e!==T.current&&(T.current=e,y(e))},[]),S=a||g,C=o||v,w=u.useRef(null),T=u.useRef(null),E=u.useRef(f),D=c!=null,O=Rf(c),k=Rf(i),A=Rf(l),j=u.useCallback(()=>{if(!w.current||!T.current)return;let e={placement:t,strategy:n,middleware:m};k.current&&(e.platform=k.current),Nf(w.current,T.current,e).then(e=>{let t={...e,isPositioned:A.current!==!1};M.current&&!Ff(E.current,t)&&(E.current=t,d.flushSync(()=>{p(t)}))})},[m,t,n,k,A]);Pf(()=>{l===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,p(e=>({...e,isPositioned:!1})))},[l]);let M=u.useRef(!1);Pf(()=>(M.current=!0,()=>{M.current=!1}),[]),Pf(()=>{if(S&&(w.current=S),C&&(T.current=C),S&&C){if(O.current)return O.current(S,C,j);j()}},[S,C,j,O,D]);let N=u.useMemo(()=>({reference:w,floating:T,setReference:b,setFloating:x}),[b,x]),P=u.useMemo(()=>({reference:S,floating:C}),[S,C]),F=u.useMemo(()=>{let e={position:n,left:0,top:0};if(!P.floating)return e;let t=Lf(P.floating,f.x),r=Lf(P.floating,f.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...If(P.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,P.floating,f.x,f.y]);return u.useMemo(()=>({...f,update:j,refs:N,elements:P,floatingStyles:F}),[f,j,N,P,F])}var Bf=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:jf({element:r.current,padding:i}).fn(n):r?jf({element:r,padding:i}).fn(n):{}}}},Vf=(e,t)=>{let n=Ef(e);return{name:n.name,fn:n.fn,options:[e,t]}},Hf=(e,t)=>{let n=Df(e);return{name:n.name,fn:n.fn,options:[e,t]}},Uf=(e,t)=>({fn:Mf(e).fn,options:[e,t]}),Wf=(e,t)=>{let n=Of(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gf=(e,t)=>{let n=kf(e);return{name:n.name,fn:n.fn,options:[e,t]}},Kf=(e,t)=>{let n=Af(e);return{name:n.name,fn:n.fn,options:[e,t]}},qf=(e,t)=>{let n=Bf(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jf=`Arrow`,Yf=u.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,H.jsx)(W.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,H.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Yf.displayName=Jf;var Xf=Yf;function Zf(e){let[t,n]=u.useState(void 0);return Yi(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}var Qf=`Popper`,[$f,ep]=Wi(Qf),[tp,np]=$f(Qf),rp=e=>{let{__scopePopper:t,children:n}=e,[r,i]=u.useState(null),[a,o]=u.useState(void 0);return(0,H.jsx)(tp,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};rp.displayName=Qf;var ip=`PopperAnchor`,ap=u.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=np(ip,n),o=u.useRef(null),s=a.onAnchorChange,c=Ji(t,u.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=u.useRef(null);u.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let d=a.placementState&&hp(a.placementState),f=d?.[0],p=d?.[1];return r?null:(0,H.jsx)(W.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...i,ref:c})});ap.displayName=ip;var op=`PopperContent`,[sp,cp]=$f(op),lp=u.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:d=0,sticky:f=`partial`,hideWhenDetached:p=!1,updatePositionStrategy:m=`optimized`,onPlaced:h,...g}=e,_=np(op,n),[v,y]=u.useState(null),b=Ji(t,y),[x,S]=u.useState(null),C=Zf(x),w=C?.width??0,T=C?.height??0,E=r+(a===`center`?``:`-`+a),D=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},O=Array.isArray(l)?l:[l],k=O.length>0,A={padding:D,boundary:O.filter(pp),altBoundary:k},{refs:j,floatingStyles:M,placement:N,isPositioned:P,middlewareData:F}=zf({strategy:`fixed`,placement:E,whileElementsMounted:(...e)=>Tf(...e,{animationFrame:m===`always`}),elements:{reference:_.anchor},middleware:[Vf({mainAxis:i+T,alignmentAxis:o}),c&&Hf({mainAxis:!0,crossAxis:!1,limiter:f===`partial`?Uf():void 0,...A}),c&&Wf({...A}),Gf({...A,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),x&&qf({element:x,padding:s}),mp({arrowWidth:w,arrowHeight:T}),p&&Kf({strategy:`referenceHidden`,...A,boundary:k?A.boundary:void 0})]}),I=_.setPlacementState;Yi(()=>(I(N),()=>{I(void 0)}),[N,I]);let[L,ee]=hp(N),te=_a(h);Yi(()=>{P&&te?.()},[P,te]);let ne=F.arrow?.x,re=F.arrow?.y,R=F.arrow?.centerOffset!==0,[ie,ae]=u.useState();return Yi(()=>{v&&ae(window.getComputedStyle(v).zIndex)},[v]),(0,H.jsx)(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:P?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ie,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(` `),...F.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,H.jsx)(sp,{scope:n,placedSide:L,placedAlign:ee,onArrowChange:S,arrowX:ne,arrowY:re,shouldHideArrow:R,children:(0,H.jsx)(W.div,{"data-side":L,"data-align":ee,...g,ref:b,style:{...g.style,animation:P?void 0:`none`}})})})});lp.displayName=op;var up=`PopperArrow`,dp={top:`bottom`,right:`left`,bottom:`top`,left:`right`},fp=u.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=cp(up,n),a=dp[i.placedSide];return(0,H.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,H.jsx)(Xf,{...r,ref:t,style:{...r.style,display:`block`}})})});fp.displayName=up;function pp(e){return e!==null}var mp=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=hp(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function hp(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var gp=rp,_p=ap,vp=lp,yp=fp,bp=!1;function xp(){let[e,t]=u.useState(bp);return u.useEffect(()=>{bp||(bp=!0,t(!0))},[]),e}var Sp=u.useSyncExternalStore;function Cp(){return()=>{}}function wp(){return Sp(Cp,()=>!0,()=>!1)}var Tp=typeof Sp==`function`?wp:xp,Ep=`rovingFocusGroup.onEntryFocus`,Dp={bubbles:!1,cancelable:!0},Op=`RovingFocusGroup`,[kp,Ap,jp]=Mu(Op),[Mp,Np]=Wi(Op,[jp]),[Pp,Fp]=Mp(Op),Ip=u.forwardRef((e,t)=>(0,H.jsx)(kp.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,H.jsx)(kp.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,H.jsx)(Lp,{...e,ref:t})})}));Ip.displayName=Op;var Lp=u.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:d=!1,...f}=e,p=u.useRef(null),m=Ji(t,p),h=Pu(a),[g,_]=ea({prop:o,defaultProp:s??null,onChange:c,caller:Op}),[v,y]=u.useState(!1),b=_a(l),x=Ap(n),S=u.useRef(!1),[C,w]=u.useState(0);return u.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(Ep,b),()=>e.removeEventListener(Ep,b)},[b]),(0,H.jsx)(Pp,{scope:n,orientation:r,dir:h,loop:i,currentTabStopId:g,onItemFocus:u.useCallback(e=>_(e),[_]),onItemShiftTab:u.useCallback(()=>y(!0),[]),onFocusableItemAdd:u.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:u.useCallback(()=>w(e=>e-1),[]),children:(0,H.jsx)(W.div,{tabIndex:v||C===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:`none`,...e.style},onMouseDown:U(e.onMouseDown,()=>{S.current=!0}),onFocus:U(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!v){let t=new CustomEvent(Ep,Dp);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);Up([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),d)}}S.current=!1}),onBlur:U(e.onBlur,()=>y(!1))})})}),Rp=`RovingFocusGroupItem`,zp=u.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Qi(),l=a||c,d=Fp(Rp,n),f=d.currentTabStopId===l,p=Ap(n),{onFocusableItemAdd:m,onFocusableItemRemove:h,currentTabStopId:g}=d,_=Tp();return Yi(()=>{if(!(!_||!r))return m(),()=>h()},[_,r,m,h]),u.useEffect(()=>{if(!(_||!r))return m(),()=>h()},[_,r,m,h]),(0,H.jsx)(kp.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,H.jsx)(W.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...s,ref:t,onMouseDown:U(e.onMouseDown,e=>{r?d.onItemFocus(l):e.preventDefault()}),onFocus:U(e.onFocus,()=>d.onItemFocus(l)),onKeyDown:U(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){d.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Hp(e,d.orientation,d.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=d.loop?Wp(n,r+1):n.slice(r+1)}setTimeout(()=>Up(n))}}),children:typeof o==`function`?o({isCurrentTabStop:f,hasTabStop:g!=null}):o})})});zp.displayName=Rp;var Bp={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Vp(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Hp(e,t,n){let r=Vp(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Bp[r]}function Up(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Wp(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Gp=Ip,Kp=zp,qp=[`Enter`,` `],Jp=[`ArrowDown`,`PageUp`,`Home`],Yp=[`ArrowUp`,`PageDown`,`End`],Xp=[...Jp,...Yp],Zp={ltr:[...qp,`ArrowRight`],rtl:[...qp,`ArrowLeft`]},Qp={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},$p=`Menu`,[em,tm,nm]=Mu($p),[rm,im]=Wi($p,[nm,ep,Np]),am=ep(),om=Np(),[sm,cm]=rm($p),[lm,um]=rm($p),dm=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=am(t),[c,l]=u.useState(null),d=u.useRef(!1),f=_a(a),p=Pu(i);return u.useEffect(()=>{let e=()=>{d.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>d.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),u.useEffect(()=>{if(!n)return;let e=()=>f(!1);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,f]),(0,H.jsx)(gp,{...s,children:(0,H.jsx)(sm,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:l,children:(0,H.jsx)(lm,{scope:t,onClose:u.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:o,children:r})})})};dm.displayName=$p;var fm=`MenuAnchor`,pm=u.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=am(n);return(0,H.jsx)(_p,{...i,...r,ref:t})});pm.displayName=fm;var mm=`MenuPortal`,[hm,gm]=rm(mm,{forceMount:void 0}),_m=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=cm(mm,t);return(0,H.jsx)(hm,{scope:t,forceMount:n,children:(0,H.jsx)(Qa,{present:n||a.open,children:(0,H.jsx)(Xa,{asChild:!0,container:i,children:r})})})};_m.displayName=mm;var vm=`MenuContent`,[ym,bm]=rm(vm),xm=u.forwardRef((e,t)=>{let n=gm(vm,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=cm(vm,e.__scopeMenu),o=um(vm,e.__scopeMenu);return(0,H.jsx)(em.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(Qa,{present:r||a.open,children:(0,H.jsx)(em.Slot,{scope:e.__scopeMenu,children:o.modal?(0,H.jsx)(Sm,{...i,ref:t}):(0,H.jsx)(Cm,{...i,ref:t})})})})}),Sm=u.forwardRef((e,t)=>{let n=cm(vm,e.__scopeMenu),r=u.useRef(null),i=Ji(t,r);return u.useEffect(()=>{let e=r.current;if(e)return ws(e)},[]),(0,H.jsx)(Tm,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:U(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Cm=u.forwardRef((e,t)=>{let n=cm(vm,e.__scopeMenu);return(0,H.jsx)(Tm,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),wm=ra(`MenuContent.ScrollLock`),Tm=u.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=cm(vm,n),v=um(vm,n),y=am(n),b=om(n),x=tm(n),[S,C]=u.useState(null),w=u.useRef(null),T=Ji(t,w,_.onContentChange),E=u.useRef(0),D=u.useRef(``),O=u.useRef(0),k=u.useRef(null),A=u.useRef(`right`),j=u.useRef(0),M=h?hs:u.Fragment,N=h?{as:wm,allowPinchZoom:!0}:void 0,P=e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=lh(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};u.useEffect(()=>()=>window.clearTimeout(E.current),[]),oo();let F=u.useCallback(e=>A.current===k.current?.side&&dh(e,k.current?.area),[]);return(0,H.jsx)(ym,{scope:n,searchRef:D,onItemEnter:u.useCallback(e=>{F(e)&&e.preventDefault()},[F]),onItemLeave:u.useCallback(e=>{F(e)||(w.current?.focus(),C(null))},[F]),onTriggerLeave:u.useCallback(e=>{F(e)&&e.preventDefault()},[F]),pointerGraceTimerRef:O,onPointerGraceIntentChange:u.useCallback(e=>{k.current=e},[]),children:(0,H.jsx)(M,{...N,children:(0,H.jsx)(La,{asChild:!0,trapped:i,onMountAutoFocus:U(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,H.jsx)(wa,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:(0,H.jsx)(Gp,{asChild:!0,...b,dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:U(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,H.jsx)(vp,{role:`menu`,"aria-orientation":`vertical`,"data-state":ih(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...g,ref:T,style:{outline:`none`,...g.style},onKeyDown:U(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&P(e.key));let i=w.current;if(e.target!==i||!Xp.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);Yp.includes(e.key)&&a.reverse(),sh(a)}),onBlur:U(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:U(e.onPointerMove,fh(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})});xm.displayName=vm;var Em=`MenuGroup`,Dm=u.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(W.div,{role:`group`,...r,ref:t})});Dm.displayName=Em;var Om=`MenuLabel`,km=u.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(W.div,{...r,ref:t})});km.displayName=Om;var Am=`MenuItem`,jm=`menu.itemSelect`,Mm=u.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=u.useRef(null),o=um(Am,e.__scopeMenu),s=bm(Am,e.__scopeMenu),c=Ji(t,a),l=u.useRef(!1),d=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(jm,{bubbles:!0,cancelable:!0});e.addEventListener(jm,e=>r?.(e),{once:!0}),ga(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,H.jsx)(Nm,{...i,ref:c,disabled:n,onClick:U(e.onClick,d),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:U(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:U(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&qp.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});Mm.displayName=Am;var Nm=u.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=bm(Am,n),s=om(n),c=u.useRef(null),l=Ji(t,c),[d,f]=u.useState(!1),[p,m]=u.useState(``);return u.useEffect(()=>{let e=c.current;e&&m((e.textContent??``).trim())},[a.children]),(0,H.jsx)(em.ItemSlot,{scope:n,disabled:r,textValue:i??p,children:(0,H.jsx)(Kp,{asChild:!0,...s,focusable:!r,children:(0,H.jsx)(W.div,{role:`menuitem`,"data-highlighted":d?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:U(e.onPointerMove,fh(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:U(e.onPointerLeave,fh(e=>o.onItemLeave(e))),onFocus:U(e.onFocus,()=>f(!0)),onBlur:U(e.onBlur,()=>f(!1))})})})}),Pm=`MenuCheckboxItem`,Fm=u.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,H.jsx)(Um,{scope:e.__scopeMenu,checked:n,children:(0,H.jsx)(Mm,{role:`menuitemcheckbox`,"aria-checked":ah(n)?`mixed`:n,...i,ref:t,"data-state":oh(n),onSelect:U(i.onSelect,()=>r?.(ah(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Fm.displayName=Pm;var Im=`MenuRadioGroup`,[Lm,Rm]=rm(Im,{value:void 0,onValueChange:()=>{}}),zm=u.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=_a(r);return(0,H.jsx)(Lm,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,H.jsx)(Dm,{...i,ref:t})})});zm.displayName=Im;var Bm=`MenuRadioItem`,Vm=u.forwardRef((e,t)=>{let{value:n,...r}=e,i=Rm(Bm,e.__scopeMenu),a=n===i.value;return(0,H.jsx)(Um,{scope:e.__scopeMenu,checked:a,children:(0,H.jsx)(Mm,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":oh(a),onSelect:U(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Vm.displayName=Bm;var Hm=`MenuItemIndicator`,[Um,Wm]=rm(Hm,{checked:!1}),Gm=u.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Wm(Hm,n);return(0,H.jsx)(Qa,{present:r||ah(a.checked)||a.checked===!0,children:(0,H.jsx)(W.span,{...i,ref:t,"data-state":oh(a.checked)})})});Gm.displayName=Hm;var Km=`MenuSeparator`,qm=u.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(W.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});qm.displayName=Km;var Jm=`MenuArrow`,Ym=u.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=am(n);return(0,H.jsx)(yp,{...i,...r,ref:t})});Ym.displayName=Jm;var Xm=`MenuSub`,[Zm,Qm]=rm(Xm),$m=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=cm(Xm,t),o=am(t),[s,c]=u.useState(null),[l,d]=u.useState(null),f=_a(i);return u.useEffect(()=>(a.open===!1&&f(!1),()=>f(!1)),[a.open,f]),(0,H.jsx)(gp,{...o,children:(0,H.jsx)(sm,{scope:t,open:r,onOpenChange:f,content:l,onContentChange:d,children:(0,H.jsx)(Zm,{scope:t,contentId:Qi(),triggerId:Qi(),trigger:s,onTriggerChange:c,children:n})})})};$m.displayName=Xm;var eh=`MenuSubTrigger`,th=u.forwardRef((e,t)=>{let n=cm(eh,e.__scopeMenu),r=um(eh,e.__scopeMenu),i=Qm(eh,e.__scopeMenu),a=bm(eh,e.__scopeMenu),o=u.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},d=u.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);u.useEffect(()=>d,[d]),u.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let f=Ji(t,i.onTriggerChange);return(0,H.jsx)(pm,{asChild:!0,...l,children:(0,H.jsx)(Nm,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":ih(n.open),...e,ref:f,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:U(e.onPointerMove,fh(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:U(e.onPointerLeave,fh(e=>{d();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:U(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||(a.searchRef.current===``||t.key!==` `)&&Zp[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});th.displayName=eh;var nh=`MenuSubContent`,rh=u.forwardRef((e,t)=>{let n=gm(vm,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=cm(vm,e.__scopeMenu),s=um(vm,e.__scopeMenu),c=Qm(nh,e.__scopeMenu),l=u.useRef(null),d=Ji(t,l);return(0,H.jsx)(em.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(Qa,{present:r||o.open,children:(0,H.jsx)(em.Slot,{scope:e.__scopeMenu,children:(0,H.jsx)(Tm,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:d,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:U(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:U(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:U(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Qp[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});rh.displayName=nh;function ih(e){return e?`open`:`closed`}function ah(e){return e===`indeterminate`}function oh(e){return ah(e)?`indeterminate`:e?`checked`:`unchecked`}function sh(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ch(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function lh(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ch(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function uh(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function dh(e,t){return t?uh({x:e.clientX,y:e.clientY},t):!1}function fh(e){return t=>t.pointerType===`mouse`?e(t):void 0}var ph=dm,mh=pm,hh=_m,gh=xm,_h=Dm,vh=km,yh=Mm,bh=Fm,xh=zm,Sh=Vm,Ch=Gm,wh=qm,Th=Ym,Eh=$m,Dh=th,Oh=rh,kh=`DropdownMenu`,[Ah,jh]=Wi(kh,[im]),Mh=im(),[Nh,Ph]=Ah(kh),Fh=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Mh(t),l=u.useRef(null),[d,f]=ea({prop:i,defaultProp:a??!1,onChange:o,caller:kh});return(0,H.jsx)(Nh,{scope:t,triggerId:Qi(),triggerRef:l,contentId:Qi(),open:d,onOpenChange:f,onOpenToggle:u.useCallback(()=>f(e=>!e),[f]),modal:s,children:(0,H.jsx)(ph,{...c,open:d,onOpenChange:f,dir:r,modal:s,children:n})})};Fh.displayName=kh;var Ih=`DropdownMenuTrigger`,Lh=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Ph(Ih,n),o=Mh(n),s=Ji(t,a.triggerRef);return(0,H.jsx)(mh,{asChild:!0,...o,children:(0,H.jsx)(W.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:U(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:U(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});Lh.displayName=Ih;var Rh=`DropdownMenuPortal`,zh=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Mh(t);return(0,H.jsx)(hh,{...r,...n})};zh.displayName=Rh;var Bh=`DropdownMenuContent`,Vh=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Ph(Bh,n),a=Mh(n),o=u.useRef(!1);return(0,H.jsx)(gh,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:U(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:U(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Vh.displayName=Bh;var Hh=`DropdownMenuGroup`,Uh=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Mh(n);return(0,H.jsx)(_h,{...i,...r,ref:t})});Uh.displayName=Hh;var Wh=`DropdownMenuLabel`,Gh=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Mh(n);return(0,H.jsx)(vh,{...i,...r,ref:t})});Gh.displayName=Wh;var Kh=`DropdownMenuItem`,qh=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Mh(n);return(0,H.jsx)(yh,{...i,...r,ref:t})});qh.displayName=Kh;var Jh=`DropdownMenuCheckboxItem`,Yh=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Mh(n);return(0,H.jsx)(bh,{...i,...r,ref:t})});Yh.displayName=Jh;var Xh=`DropdownMenuRadioGroup`,Zh=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Mh(n);return(0,H.jsx)(xh,{...i,...r,ref:t})});Zh.displayName=Xh;var Qh=`DropdownMenuRadioItem`,$h=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Mh(n);return(0,H.jsx)(Sh,{...i,...r,ref:t})});$h.displayName=Qh;var eg=`DropdownMenuItemIndicator`,tg=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Mh(n);return(0,H.jsx)(Ch,{...i,...r,ref:t})});tg.displayName=eg;var ng=`DropdownMenuSeparator`,rg=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Mh(n);return(0,H.jsx)(wh,{...i,...r,ref:t})});rg.displayName=ng;var ig=`DropdownMenuArrow`,ag=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Mh(n);return(0,H.jsx)(Th,{...i,...r,ref:t})});ag.displayName=ig;var og=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=Mh(t),[s,c]=ea({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,H.jsx)(Eh,{...o,open:s,onOpenChange:c,children:n})},sg=`DropdownMenuSubTrigger`,cg=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Mh(n);return(0,H.jsx)(Dh,{...i,...r,ref:t})});cg.displayName=sg;var lg=`DropdownMenuSubContent`,ug=u.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Mh(n);return(0,H.jsx)(Oh,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});ug.displayName=lg;var dg=Fh,fg=Lh,pg=zh,mg=Vh,hg=Gh,gg=qh,_g=rg,vg=og,yg=cg,bg=ug;function xg(e){return(0,H.jsx)(dg,{"data-slot":`dropdown-menu`,...e})}var Sg=u.forwardRef((e,t)=>(0,H.jsx)(fg,{ref:t,"data-slot":`dropdown-menu-trigger`,...e}));Sg.displayName=fg.displayName;var Cg=u.forwardRef(({className:e,sideOffset:t=4,collisionPadding:n=8,...r},i)=>(0,H.jsx)(pg,{children:(0,H.jsx)(mg,{ref:i,"data-slot":`dropdown-menu-content`,sideOffset:t,collisionPadding:n,className:au(`cn-menu-translucent z-50 min-w-36 origin-[var(--radix-dropdown-menu-content-transform-origin)] overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r})}));Cg.displayName=mg.displayName;var wg=u.forwardRef(({className:e,variant:t=`default`,...n},r)=>(0,H.jsx)(gg,{ref:r,"data-slot":`dropdown-menu-item`,"data-variant":t,className:au(`relative flex cursor-default items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,t===`destructive`&&`text-destructive focus:bg-destructive/10 focus:text-destructive dark:focus:bg-destructive/20`,e),...n}));wg.displayName=gg.displayName;var Tg=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(hg,{ref:n,"data-slot":`dropdown-menu-label`,className:au(`px-2 py-1.5 text-xs font-medium text-muted-foreground`,e),...t}));Tg.displayName=hg.displayName;var Eg=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(_g,{ref:n,"data-slot":`dropdown-menu-separator`,className:au(`-mx-1 my-1 h-px bg-border`,e),...t}));Eg.displayName=_g.displayName;function Dg(e){return(0,H.jsx)(vg,{"data-slot":`dropdown-menu-sub`,...e})}var Og=u.forwardRef(({className:e,children:t,...n},r)=>(0,H.jsxs)(yg,{ref:r,"data-slot":`dropdown-menu-sub-trigger`,className:au(`flex cursor-default select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-hidden focus:bg-accent data-[state=open]:bg-accent data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[t,(0,H.jsx)(`span`,{className:`ml-auto text-muted-foreground`,"aria-hidden":`true`,children:`›`})]}));Og.displayName=yg.displayName;var kg=u.forwardRef(({className:e,sideOffset:t=6,collisionPadding:n=8,...r},i)=>(0,H.jsx)(pg,{children:(0,H.jsx)(bg,{ref:i,"data-slot":`dropdown-menu-sub-content`,sideOffset:t,collisionPadding:n,className:au(`cn-menu-translucent z-50 min-w-48 overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r})}));kg.displayName=bg.displayName;var Ag=u.forwardRef(({className:e,type:t,...n},r)=>(0,H.jsx)(`input`,{ref:r,type:t,"data-slot":`input`,className:au(`h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n}));Ag.displayName=`Input`;function jg({className:e,...t}){return(0,H.jsx)(`textarea`,{"data-slot":`textarea`,className:au(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function Mg({idPrefix:e,fields:t,activeFieldId:n,answers:r,otherValues:i,otherSelections:a,errors:o={},disabled:s=!1,onNavigate:c,onAnswerChange:l,onOtherValueChange:d,onOtherSelectionChange:f}){let p=u.useRef(null),m=u.useRef(void 0),h=u.useRef(void 0),g=t.findIndex(e=>e.id===n),_=g>=0?g:0,v=t[_],y=v?o[v.id]:void 0,b=v?r[v.id]:void 0;if(u.useEffect(()=>{if(!v)return;let e=m.current!==void 0&&m.current!==v.id,t=!!y&&h.current!==y;if(m.current=v.id,h.current=y,!e&&!t)return;let n=p.current;(n?.querySelector(`input[aria-invalid="true"]:not([disabled]), textarea[aria-invalid="true"]:not([disabled])`)??n?.querySelector(`input:checked:not([disabled])`)??n?.querySelector(`input:not([disabled]), textarea:not([disabled])`))?.focus()},[y,v]),!v)return null;let x=`${e}-field-${_}`,S=v.description?`${x}-description`:void 0,C=y?`${x}-error`:void 0,w=[S,C].filter(Boolean).join(` `)||void 0;return(0,H.jsxs)(`div`,{className:`grid gap-3`,children:[t.length>1&&(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{"aria-live":`polite`,className:`font-mono text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:[`Question `,_+1,` of `,t.length]}),(0,H.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:v.required?`Required`:`Optional`})]}),(0,H.jsx)(`div`,{role:`progressbar`,"aria-label":`Question progress`,"aria-valuemin":1,"aria-valuemax":t.length,"aria-valuenow":_+1,className:`h-1 overflow-hidden rounded-full bg-muted`,children:(0,H.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${(_+1)/t.length*100}%`}})})]}),(0,H.jsx)(`div`,{ref:p,children:v.type===`text`?(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsxs)(`label`,{htmlFor:x,className:`text-xs font-medium text-foreground`,children:[v.label,v.required&&(0,H.jsx)(Fg,{})]}),v.description&&(0,H.jsx)(`p`,{id:S,className:`text-[11px] leading-relaxed text-muted-foreground`,children:v.description}),v.multiline&&!v.secret?(0,H.jsx)(jg,{id:x,value:typeof b==`string`?b:``,disabled:s,placeholder:v.placeholder,"aria-invalid":y?!0:void 0,"aria-describedby":w,required:v.required,onChange:e=>l(v.id,e.target.value)}):(0,H.jsx)(Ag,{id:x,type:v.secret?`password`:`text`,autoComplete:`off`,value:typeof b==`string`?b:``,disabled:s,placeholder:v.placeholder,"aria-invalid":y?!0:void 0,"aria-describedby":w,required:v.required,onChange:e=>l(v.id,e.target.value)}),(0,H.jsx)(Pg,{id:C,error:y})]}):(0,H.jsxs)(`fieldset`,{disabled:s,role:v.multiple?void 0:`radiogroup`,"aria-required":!v.multiple&&v.required?!0:void 0,"aria-invalid":y?!0:void 0,"aria-describedby":w,className:`grid gap-1.5`,children:[(0,H.jsxs)(`legend`,{className:`text-xs font-medium text-foreground`,children:[v.label,v.required&&(0,H.jsx)(Fg,{})]}),v.description&&(0,H.jsx)(`p`,{id:S,className:`text-[11px] leading-relaxed text-muted-foreground`,children:v.description}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[v.options.map((e,t)=>{let n=`${x}-option-${t}`,r=v.multiple?Array.isArray(b)&&b.includes(e.value):a[v.id]!==!0&&b===e.value;return(0,H.jsx)(Ng,{id:n,name:v.multiple?void 0:x,type:v.multiple?`checkbox`:`radio`,checked:r,label:e.label,description:e.description,onChange:t=>{if(v.multiple){let n=Array.isArray(b)?b:[];l(v.id,t?[...n.filter(t=>t!==e.value),e.value]:n.filter(t=>t!==e.value))}else l(v.id,e.value),f(v.id,!1)}},e.value)}),v.allowOther&&(0,H.jsxs)(`div`,{className:`grid gap-1.5 rounded-lg border border-border bg-background/60 px-2.5 py-2 has-[:checked]:border-primary/50 has-[:checked]:bg-primary/5`,children:[(0,H.jsx)(Ng,{id:`${x}-other`,name:v.multiple?void 0:x,type:v.multiple?`checkbox`:`radio`,checked:a[v.id]===!0,label:`Other`,embedded:!0,onChange:e=>{f(v.id,e),e&&!v.multiple&&l(v.id,``)}}),(0,H.jsx)(Ag,{value:i[v.id]??``,disabled:s||a[v.id]!==!0,"aria-label":`Other answer for ${v.label}`,"aria-invalid":y?!0:void 0,"aria-describedby":w,placeholder:`Enter another answer`,onChange:e=>d(v.id,e.target.value)})]}),!v.required&&!v.multiple&&(a[v.id]===!0||typeof b==`string`&&b.length>0)&&(0,H.jsx)(J,{type:`button`,size:`xs`,variant:`ghost`,className:`justify-self-start text-muted-foreground`,onClick:()=>{l(v.id,``),f(v.id,!1)},children:`Clear selection`})]}),(0,H.jsx)(Pg,{id:C,error:y})]})}),t.length>1&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t border-border/70 pt-2`,children:[(0,H.jsxs)(J,{type:`button`,size:`xs`,variant:`ghost`,disabled:s||_===0,onClick:()=>c(t[_-1].id),children:[(0,H.jsx)(In,{}),`Previous`]}),(0,H.jsxs)(J,{type:`button`,size:`xs`,variant:`outline`,disabled:s||_===t.length-1,onClick:()=>c(t[_+1].id),children:[`Next`,(0,H.jsx)(Ln,{})]})]})]})}function Ng({id:e,name:t,type:n,checked:r,label:i,description:a,embedded:o=!1,onChange:s}){return(0,H.jsxs)(`label`,{htmlFor:e,className:au(`flex cursor-pointer items-start gap-2 text-xs text-foreground`,!o&&`rounded-lg border border-border bg-background/60 px-2.5 py-2 transition-colors hover:bg-muted/60 has-[:checked]:border-primary/50 has-[:checked]:bg-primary/5`),children:[(0,H.jsxs)(`span`,{className:`relative mt-0.5 size-4 shrink-0`,children:[(0,H.jsx)(`input`,{id:e,type:n,name:t,checked:r,className:`peer size-4 appearance-none rounded-sm border border-input bg-background outline-none transition-colors checked:border-primary checked:bg-primary focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-60`,onChange:e=>s(e.target.checked)}),(0,H.jsx)(Pn,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 size-4 stroke-[3] text-primary-foreground opacity-0 peer-checked:opacity-100`})]}),(0,H.jsxs)(`span`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`block`,children:i}),a&&(0,H.jsx)(`span`,{className:`mt-0.5 block text-[11px] leading-relaxed text-muted-foreground`,children:a})]})]})}function Pg({id:e,error:t}){return t?(0,H.jsx)(`p`,{id:e,role:`alert`,className:`text-[11px] text-destructive`,children:t}):null}function Fg(){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`ml-0.5 text-destructive`,children:`*`}),(0,H.jsx)(`span`,{className:`sr-only`,children:` (required)`})]})}function Ig({className:e,size:t=`default`,...n}){return(0,H.jsxs)(`div`,{"data-slot":`native-select-wrapper`,"data-size":t,className:au(`group/native-select relative w-fit has-[select:disabled]:opacity-50`,e),children:[(0,H.jsx)(`select`,{"data-slot":`native-select`,"data-size":t,className:`h-8 w-full min-w-0 appearance-none rounded-lg border border-input bg-transparent py-1 pr-8 pl-2.5 text-sm transition-colors outline-none select-none selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[size=sm]:py-0.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,...n}),(0,H.jsx)(Fn,{"aria-hidden":`true`,"data-slot":`native-select-icon`,className:`pointer-events-none absolute top-1/2 right-2.5 size-4 -translate-y-1/2 text-muted-foreground select-none`})]})}var Lg=Object.defineProperty,Rg=(e,t)=>Lg(e,`name`,{value:t,configurable:!0});function zg(e,t){return u.useReducer((e,n)=>t[e][n]??e,e)}Rg(zg,`useStateMachine`);var Bg=Rg(e=>{let{present:t,children:n}=e,r=Vg(t),i=typeof n==`function`?n({present:r.isPresent}):u.Children.only(n),a=Ug(r.ref,Gg(i));return typeof n==`function`||r.isPresent?u.cloneElement(i,{ref:a}):null},`Presence`);function Vg(e){let[t,n]=u.useState(),r=u.useRef(null),i=u.useRef(e),a=u.useRef(`none`),o=u.useRef(void 0),[s,c]=zg(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return u.useEffect(()=>{s===`mounted`?(a.current=o.current??Wg(r.current),o.current=void 0):a.current=`none`},[s]),Yi(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=Wg(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),Yi(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=Rg(a=>{let o=Wg(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=Rg(e=>{e.target===t&&(a.current=Wg(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:u.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=Wg(t)}else r.current=null;n(e)},[])}}Rg(Vg,`usePresence`);function Hg(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Rg(Hg,`setRef`);function Ug(...e){let t=u.useRef(e);return t.current=e,u.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Hg(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Hg(n[e],null)}}},[])}Rg(Ug,`useStableComposedRefs`);function Wg(e){return e?.animationName||`none`}Rg(Wg,`getAnimationName`);function Gg(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Rg(Gg,`getElementRef`);function Kg(e,[t,n]){return Math.min(n,Math.max(t,e))}var qg=Object.defineProperty,Jg=(e,t)=>qg(e,`name`,{value:t,configurable:!0}),Yg=!!(typeof window<`u`&&window.document&&window.document.createElement);function Xg(e,t,{checkForDefaultPrevented:n=!0}={}){return Jg(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}Jg(Xg,`composeEventHandlers`);function Zg(e){if(!Yg)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}Jg(Zg,`getOwnerWindow`);function Qg(e){if(!Yg)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}Jg(Qg,`getOwnerDocument`);function $g(e,t=!1){let{activeElement:n}=Qg(e);if(!n?.nodeName)return null;if(e_(n)&&n.contentDocument)return $g(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=Qg(n).getElementById(e);if(t)return t}}return n}Jg($g,`getActiveElement`);function e_(e){return e.tagName===`IFRAME`}Jg(e_,`isFrame`);var t_=Object.defineProperty,n_=(e,t)=>t_(e,`name`,{value:t,configurable:!0});function r_(e,t){return u.useReducer((e,n)=>t[e][n]??e,e)}n_(r_,`useStateMachine`);var i_=`ScrollArea`,[a_,o_]=Wi(i_),[s_,c_]=a_(i_),l_=u.forwardRef(n_(function(e,t){let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=u.useState(null),[l,d]=u.useState(null),[f,p]=u.useState(null),[m,h]=u.useState(null),[g,_]=u.useState(null),[v,y]=u.useState(0),[b,x]=u.useState(0),[S,C]=u.useState(!1),[w,T]=u.useState(!1),E=Ji(t,c),D=Pu(i);return(0,H.jsx)(s_,{scope:n,type:r,dir:D,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:d,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:h,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:g,onScrollbarYChange:_,scrollbarYEnabled:w,onScrollbarYEnabledChange:T,onCornerWidthChange:y,onCornerHeightChange:x,children:(0,H.jsx)(W.div,{dir:D,...o,ref:E,style:{position:`relative`,"--radix-scroll-area-corner-width":v+`px`,"--radix-scroll-area-corner-height":b+`px`,...e.style}})})},`ScrollArea`)),u_=`ScrollAreaViewport`,d_=u.forwardRef(n_(function(e,t){let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=c_(u_,n),s=Ji(t,u.useRef(null),o.onViewportChange);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(f_,{nonce:i}),(0,H.jsx)(W.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,H.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})},`ScrollAreaViewport`)),f_=u.memo(n_(function({nonce:e}){return(0,H.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:e})},`ScrollAreaViewportStyle`),(e,t)=>e.nonce===t.nonce),p_=`ScrollAreaScrollbar`,m_=u.forwardRef(n_(function(e,t){let{forceMount:n,...r}=e,i=c_(p_,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return u.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,H.jsx)(h_,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,H.jsx)(g_,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,H.jsx)(__,{...r,ref:t,forceMount:n}):i.type===`always`?(0,H.jsx)(v_,{...r,ref:t,"data-state":`visible`}):null},`ScrollAreaScrollbar`)),h_=u.forwardRef(n_(function(e,t){let{forceMount:n,...r}=e,i=c_(p_,e.__scopeScrollArea),[a,o]=u.useState(!1);return u.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=n_(()=>{window.clearTimeout(t),o(!0)},`handlePointerEnter`),r=n_(()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)},`handlePointerLeave`);return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,H.jsx)(Bg,{present:n||a,children:(0,H.jsx)(__,{"data-state":a?`visible`:`hidden`,...r,ref:t})})},`ScrollAreaScrollbarHover`)),g_=u.forwardRef(n_(function(e,t){let{forceMount:n,...r}=e,i=c_(p_,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=R_(()=>c(`SCROLL_END`),100),[s,c]=r_(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return u.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),u.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=n_(()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r},`handleScroll`);return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,H.jsx)(Bg,{present:n||s!==`hidden`,children:(0,H.jsx)(v_,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:Xg(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:Xg(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})},`ScrollAreaScrollbarScroll`)),__=u.forwardRef(n_(function(e,t){let n=c_(p_,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=u.useState(!1),s=e.orientation===`horizontal`,c=R_(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return z_(n.viewport,c),z_(n.content,c),(0,H.jsx)(Bg,{present:r||a,children:(0,H.jsx)(v_,{"data-state":a?`visible`:`hidden`,...i,ref:t})})},`ScrollAreaScrollbarAuto`)),v_=u.forwardRef(n_(function(e,t){let{orientation:n=`vertical`,...r}=e,i=c_(p_,e.__scopeScrollArea),a=u.useRef(null),o=u.useRef(0),[s,c]=u.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=j_(s.viewport,s.content),d={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:n_(e=>a.current=e,`onThumbChange`),onThumbPointerUp:n_(()=>o.current=0,`onThumbPointerUp`),onThumbPointerDown:n_(e=>o.current=e,`onThumbPointerDown`)};function f(e,t){return N_(e,o.current,s,t)}return n_(f,`getScrollPosition`),n===`horizontal`?(0,H.jsx)(y_,{...d,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=P_(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=f(e,i.dir))}}):n===`vertical`?(0,H.jsx)(b_,{...d,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=P_(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=f(e))}}):null},`ScrollAreaScrollbarVisible`)),y_=u.forwardRef(n_(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=c_(p_,e.__scopeScrollArea),[o,s]=u.useState(),c=u.useRef(null),l=Ji(t,c,a.onScrollbarXChange);return u.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,H.jsx)(C_,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":M_(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),I_(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:A_(o.paddingLeft),paddingEnd:A_(o.paddingRight)}})}})},`ScrollAreaScrollbarX`)),b_=u.forwardRef(n_(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=c_(p_,e.__scopeScrollArea),[o,s]=u.useState(),c=u.useRef(null),l=Ji(t,c,a.onScrollbarYChange);return u.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,H.jsx)(C_,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":M_(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),I_(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:A_(o.paddingTop),paddingEnd:A_(o.paddingBottom)}})}})},`ScrollAreaScrollbarY`)),[x_,S_]=a_(p_),C_=u.forwardRef(n_(function(e,t){let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:d,onResize:f,...p}=e,m=c_(p_,n),[h,g]=u.useState(null),_=Ji(t,g),v=u.useRef(null),y=u.useRef(``),b=m.viewport,x=r.content-r.viewport,S=_a(d),C=_a(c),w=R_(f,10);function T(e){if(v.current){let t=e.clientX-v.current.left,n=e.clientY-v.current.top;l({x:t,y:n})}}return n_(T,`handleDragScroll`),u.useEffect(()=>{let e=n_(e=>{let t=e.target;h?.contains(t)&&S(e,x)},`handleWheel`);return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[b,h,x,S]),u.useEffect(C,[r,C]),z_(h,w),z_(m.content,w),(0,H.jsx)(x_,{scope:n,scrollbar:h,hasThumb:i,onThumbChange:_a(a),onThumbPointerUp:_a(o),onThumbPositionChange:C,onThumbPointerDown:_a(s),children:(0,H.jsx)(W.div,{...p,ref:_,style:{position:`absolute`,...p.style},onPointerDown:Xg(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),v.current=h.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,m.viewport&&(m.viewport.style.scrollBehavior=`auto`),T(e))}),onPointerMove:Xg(e.onPointerMove,T),onPointerUp:Xg(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=y.current,m.viewport&&(m.viewport.style.scrollBehavior=``),v.current=null})})})},`ScrollAreaScrollbarImpl`)),w_=`ScrollAreaThumb`,T_=u.forwardRef(n_(function(e,t){let{forceMount:n,...r}=e,i=S_(w_,e.__scopeScrollArea);return(0,H.jsx)(Bg,{present:n||i.hasThumb,children:(0,H.jsx)(E_,{ref:t,...r})})},`ScrollAreaThumb`)),E_=u.forwardRef(n_(function(e,t){let{__scopeScrollArea:n,style:r,...i}=e,a=c_(w_,n),o=S_(w_,n),{onThumbPositionChange:s}=o,c=Ji(t,o.onThumbChange),l=u.useRef(void 0),d=R_(()=>{l.current&&=(l.current(),void 0)},100);return u.useEffect(()=>{let e=a.viewport;if(e){let t=n_(()=>{if(d(),!l.current){let t=L_(e,s);l.current=t,s()}},`handleScroll`);return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,d,s]),(0,H.jsx)(W.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:Xg(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:Xg(e.onPointerUp,o.onThumbPointerUp)})},`ScrollAreaThumbImpl`)),D_=`ScrollAreaCorner`,O_=u.forwardRef(n_(function(e,t){let n=c_(D_,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,H.jsx)(k_,{...e,ref:t}):null},`ScrollAreaCorner`)),k_=u.forwardRef(n_(function(e,t){let{__scopeScrollArea:n,...r}=e,i=c_(D_,n),[a,o]=u.useState(0),[s,c]=u.useState(0),l=!!(a&&s),{onCornerWidthChange:d,onCornerHeightChange:f}=i;return z_(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),z_(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),u.useEffect(()=>()=>{d(0),f(0)},[d,f]),l?(0,H.jsx)(W.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null},`ScrollAreaCornerImpl`));function A_(e){return e?parseInt(e,10):0}n_(A_,`toInt`);function j_(e,t){let n=e/t;return isNaN(n)?0:n}n_(j_,`getThumbRatio`);function M_(e){let t=j_(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}n_(M_,`getThumbSize`);function N_(e,t,n,r=`ltr`){let i=M_(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return F_([c,l],d)(e)}n_(N_,`getScrollPositionFromPointer`);function P_(e,t,n=`ltr`){let r=M_(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=Kg(e,n===`ltr`?[0,o]:[o*-1,0]);return F_([0,o],[0,s])(c)}n_(P_,`getThumbOffsetFromScroll`);function F_(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}n_(F_,`linearScale`);function I_(e,t){return e>0&&e<t}n_(I_,`isScrollingWithinScrollbarBounds`);var L_=n_((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return n_((function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)}),`loop`)(),()=>window.cancelAnimationFrame(r)},`addUnlinkedScrollListener`);function R_(e,t){let n=_a(e),r=u.useRef(0);return u.useEffect(()=>()=>window.clearTimeout(r.current),[]),u.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}n_(R_,`useDebounceCallback`);function z_(e,t){let n=_a(t);Yi(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}n_(z_,`useResizeObserver`);var B_=l_,V_=d_,H_=O_,U_=u.forwardRef(({className:e,children:t,viewportClassName:n,viewportRef:r,viewportProps:i,scrollbars:a=`vertical`,type:o=`auto`,...s},c)=>(0,H.jsxs)(B_,{ref:c,"data-slot":`scroll-area`,type:o,className:au(`relative overflow-hidden`,e),...s,children:[(0,H.jsx)(V_,{ref:r,"data-slot":`scroll-area-viewport`,className:au(`size-full rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:ring-2 focus-visible:ring-[var(--ring)]/45`,a===`vertical`&&`[&>div]:!block [&>div]:min-w-0 [&>div]:w-full`,n),...i,children:t}),a!==`horizontal`&&(0,H.jsx)(W_,{orientation:`vertical`}),a!==`vertical`&&(0,H.jsx)(W_,{orientation:`horizontal`}),(0,H.jsx)(H_,{"data-slot":`scroll-area-corner`})]}));U_.displayName=B_.displayName;var W_=u.forwardRef(({className:e,orientation:t=`vertical`,style:n,...r},i)=>(0,H.jsx)(m_,{ref:i,"data-slot":`scroll-area-scrollbar`,orientation:t,className:au(`group flex touch-none select-none p-px transition-colors`,t===`vertical`&&`h-full w-2`,t===`horizontal`&&`h-2 flex-col`,e),style:{...t===`vertical`?{right:2}:{bottom:2},...n},...r,children:(0,H.jsx)(T_,{"data-slot":`scroll-area-thumb`,className:au(`relative flex-1 rounded-full bg-[var(--scrollbar-thumb)] transition-colors group-hover:bg-[var(--scrollbar-thumb-hover)] active:bg-[var(--scrollbar-thumb-active)]`,t===`vertical`?`min-h-8 w-full`:`h-full min-w-8`)})}));W_.displayName=m_.displayName;function G_(e){let t=u.useRef({value:e,previous:e});return u.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var K_=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),q_=`VisuallyHidden`,J_=u.forwardRef((e,t)=>(0,H.jsx)(W.span,{...e,ref:t,style:{...K_,...e.style}}));J_.displayName=q_;var Y_=[` `,`Enter`,`ArrowUp`,`ArrowDown`],X_=[` `,`Enter`],Z_=`Select`,[Q_,$_,ev]=Mu(Z_),[tv,nv]=Wi(Z_,[ev,ep]),rv=ep(),[iv,av]=tv(Z_),[ov,sv]=tv(Z_),cv=`SelectProvider`;function lv(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:d,autoComplete:f,disabled:p,required:m,form:h,internal_do_not_use_render:g}=e,_=rv(t),[v,y]=u.useState(null),[b,x]=u.useState(null),[S,C]=u.useState(!1),w=Pu(l),[T,E]=ea({prop:r,defaultProp:i??!1,onChange:a,caller:Z_}),[D,O]=ea({prop:o,defaultProp:s,onChange:c,caller:Z_}),k=u.useRef(null),A=u.useRef(D);u.useEffect(()=>{let e=h?v?.ownerDocument.getElementById(h):v?.form;if(e instanceof HTMLFormElement){let t=()=>O(A.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,v,O]);let j=!v||!!h||!!v.closest(`form`),[M,N]=u.useState(new Set),P=Qi(),F=Array.from(M).map(e=>e.props.value).join(`;`),I=u.useCallback(e=>{N(t=>new Set(t).add(e))},[]),L=u.useCallback(e=>{N(t=>{let n=new Set(t);return n.delete(e),n})},[]),ee={required:m,trigger:v,onTriggerChange:y,valueNode:b,onValueNodeChange:x,valueNodeHasChildren:S,onValueNodeHasChildrenChange:C,contentId:P,value:D,onValueChange:O,open:T,onOpenChange:E,dir:w,triggerPointerDownPosRef:k,disabled:p,name:d,autoComplete:f,form:h,nativeOptions:M,nativeSelectKey:F,isFormControl:j};return(0,H.jsx)(gp,{..._,children:(0,H.jsx)(iv,{scope:t,...ee,children:(0,H.jsx)(Q_.Provider,{scope:t,children:(0,H.jsx)(ov,{scope:t,onNativeOptionAdd:I,onNativeOptionRemove:L,children:ly(g)?g(ee):n})})})})}lv.displayName=cv;var uv=e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,H.jsx)(lv,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,H.jsxs)(H.Fragment,{children:[n,e?(0,H.jsx)(cy,{__scopeSelect:t}):null]})})};uv.displayName=Z_;var dv=`SelectTrigger`,fv=u.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=rv(n),o=av(dv,n),s=o.disabled||r,c=Ji(t,o.onTriggerChange),l=$_(n),d=u.useRef(`touch`),[f,p,m]=dy(e=>{let t=l().filter(e=>!e.disabled),n=fy(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),h=e=>{s||(o.onOpenChange(!0),m()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,H.jsx)(_p,{asChild:!0,...a,children:(0,H.jsx)(W.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":uy(o.value)?``:void 0,...i,ref:c,onClick:U(i.onClick,e=>{e.currentTarget.focus(),d.current!==`mouse`&&h(e)}),onPointerDown:U(i.onPointerDown,e=>{d.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:U(i.onKeyDown,e=>{let t=f.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&p(e.key),!(t&&e.key===` `)&&Y_.includes(e.key)&&(h(),e.preventDefault())})})})});fv.displayName=dv;var pv=`SelectValue`,mv=u.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=av(pv,n),{onValueNodeHasChildrenChange:l}=c,d=a!==void 0,f=Ji(t,c.onValueNodeChange);Yi(()=>{l(d)},[l,d]);let p=uy(c.value);return(0,H.jsx)(W.span,{...s,asChild:!p&&s.asChild,ref:f,style:{pointerEvents:`none`},children:(0,H.jsx)(u.Fragment,{children:p?o:a},p?`placeholder`:`value`)})});mv.displayName=pv;var hv=`SelectIcon`,gv=u.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,H.jsx)(W.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});gv.displayName=hv;var _v=`SelectPortal`,[vv,yv]=tv(_v,{forceMount:void 0}),bv=e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,H.jsx)(vv,{scope:e.__scopeSelect,forceMount:n,children:(0,H.jsx)(Xa,{asChild:!0,...r})})};bv.displayName=_v;var xv=`SelectContent`,Sv=u.forwardRef((e,t)=>{let n=yv(xv,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=av(xv,e.__scopeSelect),[o,s]=u.useState();return Yi(()=>{s(new DocumentFragment)},[]),(0,H.jsx)(Qa,{present:r||a.open,children:({present:e})=>e?(0,H.jsx)(kv,{...i,ref:t}):(0,H.jsx)(Cv,{...i,fragment:o})})});Sv.displayName=xv;var Cv=u.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,fragment:i}=e;return i?d.createPortal((0,H.jsx)(Tv,{scope:n,children:(0,H.jsx)(Q_.Slot,{scope:n,children:(0,H.jsx)(`div`,{ref:t,children:r})})}),i):null});Cv.displayName=`SelectContentFragment`;var wv=10,[Tv,Ev]=tv(xv),Dv=`SelectContentImpl`,Ov=ra(`SelectContent.RemoveScroll`),kv=u.forwardRef((e,t)=>{let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_,...v}=e,y=av(xv,n),[b,x]=u.useState(null),[S,C]=u.useState(null),w=Ji(t,x),[T,E]=u.useState(null),[D,O]=u.useState(null),k=$_(n),[A,j]=u.useState(!1),M=u.useRef(!1);u.useEffect(()=>{if(b)return ws(b)},[b]),oo();let N=u.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,S]),P=u.useCallback(()=>N([T,b]),[N,T,b]);u.useEffect(()=>{A&&P()},[A,P]);let{onOpenChange:F,triggerPointerDownPosRef:I}=y;u.useEffect(()=>{if(b){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(I.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(I.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(b)||F(!1),document.removeEventListener(`pointermove`,t),I.current=null};return I.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[b,F,I]),u.useEffect(()=>{let e=()=>F(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[F]);let[L,ee]=dy(e=>{let t=k().filter(e=>!e.disabled),n=fy(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),te=u.useCallback((e,t,n)=>{let r=!M.current&&!n;(y.value!==void 0&&y.value===t||r)&&(E(e),r&&(M.current=!0))},[y.value]),ne=u.useCallback(()=>b?.focus(),[b]),re=u.useCallback((e,t,n)=>{let r=!M.current&&!n;(y.value!==void 0&&y.value===t||r)&&O(e)},[y.value]),R=r===`popper`?Nv:jv,ie=R===Nv?{side:s,sideOffset:c,align:l,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_}:{};return(0,H.jsx)(Tv,{scope:n,content:b,viewport:S,onViewportChange:C,itemRefCallback:te,selectedItem:T,onItemLeave:ne,itemTextRefCallback:re,focusSelectedItem:P,selectedItemText:D,position:r,isPositioned:A,searchRef:L,children:(0,H.jsx)(hs,{as:Ov,allowPinchZoom:!0,children:(0,H.jsx)(La,{asChild:!0,trapped:y.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:U(i,e=>{y.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,H.jsx)(wa,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:(0,H.jsx)(R,{role:`listbox`,id:y.contentId,"data-state":y.open?`open`:`closed`,dir:y.dir,onContextMenu:e=>e.preventDefault(),...v,...ie,onPlaced:()=>j(!0),ref:w,style:{display:`flex`,flexDirection:`column`,outline:`none`,...v.style},onKeyDown:U(v.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ee(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>N(t)),e.preventDefault()}})})})})})})});kv.displayName=Dv;var Av=`SelectItemAlignedPosition`,jv=u.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=av(xv,n),o=Ev(xv,n),[s,c]=u.useState(null),[l,d]=u.useState(null),f=Ji(t,d),p=$_(n),m=u.useRef(!1),h=u.useRef(!0),{viewport:g,selectedItem:_,selectedItemText:v,focusSelectedItem:y}=o,b=u.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&g&&_&&v){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-wv,d=Kg(a,[wv,Math.max(wv,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-wv,d=Kg(a,[wv,Math.max(wv,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=p(),c=window.innerHeight-wv*2,u=g.scrollHeight,d=window.getComputedStyle(l),f=parseInt(d.borderTopWidth,10),h=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=f+h+u+b+y,S=Math.min(_.offsetHeight*5,x),C=window.getComputedStyle(g),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-wv,D=c-E,O=_.offsetHeight/2,k=_.offsetTop+O,A=f+h+k,j=x-A;if(A<=E){let e=o.length>0&&_===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-g.offsetTop-g.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&_===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,f+g.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,g.scrollTop=A-E+g.offsetTop}s.style.margin=`${wv}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,s,l,g,_,v,a.dir,r]);Yi(()=>b(),[b]);let[x,S]=u.useState();Yi(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]);let C=u.useCallback(e=>{e&&h.current===!0&&(b(),y?.(),h.current=!1)},[b,y]);return(0,H.jsx)(Pv,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:m,onScrollButtonChange:C,children:(0,H.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,H.jsx)(W.div,{...i,ref:f,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});jv.displayName=Av;var Mv=`SelectPopperPosition`,Nv=u.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=wv,...a}=e,o=rv(n);return(0,H.jsx)(vp,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Nv.displayName=Mv;var[Pv,Fv]=tv(xv,{}),Iv=`SelectViewport`,Lv=u.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Ev(Iv,n),o=Fv(Iv,n),s=Ji(t,a.onViewportChange),c=u.useRef(0);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,H.jsx)(Q_.Slot,{scope:n,children:(0,H.jsx)(W.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:U(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-wv*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Lv.displayName=Iv;var Rv=`SelectGroup`,[zv,Bv]=tv(Rv),Vv=u.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Qi();return(0,H.jsx)(zv,{scope:n,id:i,children:(0,H.jsx)(W.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Vv.displayName=Rv;var Hv=`SelectLabel`,Uv=u.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Bv(Hv,n);return(0,H.jsx)(W.div,{id:i.id,...r,ref:t})});Uv.displayName=Hv;var Wv=`SelectItem`,[Gv,Kv]=tv(Wv),qv=u.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=av(Wv,n),c=Ev(Wv,n),l=s.value===r,[d,f]=u.useState(a??``),[p,m]=u.useState(!1),h=Ji(t,_a(e=>c.itemRefCallback?.(e,r,i))),g=Qi(),_=u.useRef(`touch`),v=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};return(0,H.jsx)(Gv,{scope:n,value:r,disabled:i,textId:g,isSelected:l,onItemTextChange:u.useCallback(e=>{f(t=>t||(e?.textContent??``).trim())},[]),children:(0,H.jsx)(Q_.ItemSlot,{scope:n,value:r,disabled:i,textValue:d,children:(0,H.jsx)(W.div,{role:`option`,"aria-labelledby":g,"data-highlighted":p?``:void 0,"aria-selected":l&&p,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:h,onFocus:U(o.onFocus,()=>m(!0)),onBlur:U(o.onBlur,()=>m(!1)),onClick:U(o.onClick,()=>{_.current!==`mouse`&&v()}),onPointerUp:U(o.onPointerUp,()=>{_.current===`mouse`&&v()}),onPointerDown:U(o.onPointerDown,e=>{_.current=e.pointerType}),onPointerMove:U(o.onPointerMove,e=>{_.current=e.pointerType,i?c.onItemLeave?.():_.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:U(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:U(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&(X_.includes(e.key)&&v(),e.key===` `&&e.preventDefault())})})})})});qv.displayName=Wv;var Jv=`SelectItemText`,Yv=u.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=av(Jv,n),s=Ev(Jv,n),c=Kv(Jv,n),l=sv(Jv,n),[f,p]=u.useState(null),m=_a(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),h=Ji(t,p,c.onItemTextChange,m),g=f?.textContent,_=u.useMemo(()=>(0,H.jsx)(`option`,{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:v,onNativeOptionRemove:y}=l;return Yi(()=>(v(_),()=>y(_)),[v,y,_]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(W.span,{id:c.textId,...a,ref:h}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!uy(o.value)?d.createPortal(a.children,o.valueNode):null]})});Yv.displayName=Jv;var Xv=`SelectItemIndicator`,Zv=u.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Kv(Xv,n).isSelected?(0,H.jsx)(W.span,{"aria-hidden":!0,...r,ref:t}):null});Zv.displayName=Xv;var Qv=`SelectScrollUpButton`,$v=u.forwardRef((e,t)=>{let n=Ev(Qv,e.__scopeSelect),r=Fv(Qv,e.__scopeSelect),[i,a]=u.useState(!1),o=Ji(t,r.onScrollButtonChange);return Yi(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,H.jsx)(ny,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});$v.displayName=Qv;var ey=`SelectScrollDownButton`,ty=u.forwardRef((e,t)=>{let n=Ev(ey,e.__scopeSelect),r=Fv(ey,e.__scopeSelect),[i,a]=u.useState(!1),o=Ji(t,r.onScrollButtonChange);return Yi(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,H.jsx)(ny,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});ty.displayName=ey;var ny=u.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Ev(`SelectScrollButton`,n),o=u.useRef(null),s=$_(n),c=u.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return u.useEffect(()=>()=>c(),[c]),Yi(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,H.jsx)(W.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:U(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:U(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:U(i.onPointerLeave,()=>{c()})})}),ry=`SelectSeparator`,iy=u.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,H.jsx)(W.div,{"aria-hidden":!0,...r,ref:t})});iy.displayName=ry;var ay=`SelectArrow`,oy=u.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=rv(n);return Ev(ay,n).position===`popper`?(0,H.jsx)(yp,{...i,...r,ref:t}):null});oy.displayName=ay;var sy=`SelectBubbleInput`,cy=u.forwardRef(({__scopeSelect:e,...t},n)=>{let r=av(sy,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=u.useRef(null),h=Ji(n,m),g=i??``,_=G_(g),v=Array.from(f).some(e=>(e.props.value??``)===``);return u.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(_!==g&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,g),e.dispatchEvent(t)}},[_,g]),(0,H.jsxs)(W.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:d,onChange:e=>a(e.target.value),...t,style:{...K_,...t.style},ref:h,defaultValue:g,children:[uy(i)&&!v?(0,H.jsx)(`option`,{value:``}):null,Array.from(f)]},p)});cy.displayName=sy;function ly(e){return typeof e==`function`}function uy(e){return e===``||e===void 0}function dy(e){let t=_a(e),n=u.useRef(``),r=u.useRef(0),i=u.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=u.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return u.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function fy(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=py(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function py(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function my(e){return(0,H.jsx)(uv,{"data-slot":`select`,...e})}var hy=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Vv,{ref:n,"data-slot":`select-group`,className:au(`scroll-my-1 p-1`,e),...t}));hy.displayName=Vv.displayName;var gy=u.forwardRef((e,t)=>(0,H.jsx)(mv,{ref:t,"data-slot":`select-value`,...e}));gy.displayName=mv.displayName;var _y=u.forwardRef(({className:e,size:t=`default`,children:n,...r},i)=>(0,H.jsxs)(fv,{ref:i,"data-slot":`select-trigger`,"data-size":t,className:au(`flex w-full min-w-0 items-center justify-between gap-1.5 whitespace-nowrap rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&>span]:min-w-0 [&>span]:truncate [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,H.jsx)(gv,{asChild:!0,children:(0,H.jsx)(Fn,{"aria-hidden":`true`,className:`pointer-events-none size-4 shrink-0 text-muted-foreground`})})]}));_y.displayName=fv.displayName;var vy=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)($v,{ref:n,"data-slot":`select-scroll-up-button`,className:au(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,H.jsx)(Rn,{"aria-hidden":`true`})}));vy.displayName=$v.displayName;var yy=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(ty,{ref:n,"data-slot":`select-scroll-down-button`,className:au(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,H.jsx)(Fn,{"aria-hidden":`true`})}));yy.displayName=ty.displayName;var by=u.forwardRef(({className:e,children:t,position:n=`popper`,align:r=`center`,sideOffset:i=4,collisionPadding:a=8,...o},s)=>(0,H.jsx)(bv,{children:(0,H.jsxs)(Sv,{ref:s,"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,position:n,align:r,sideOffset:i,collisionPadding:a,className:au(`cn-menu-translucent relative z-50 max-h-[var(--radix-select-content-available-height)] min-w-36 origin-[var(--radix-select-content-transform-origin)] overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`w-[var(--radix-select-trigger-width)] data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),...o,children:[(0,H.jsx)(vy,{}),(0,H.jsx)(Lv,{"data-position":n,className:au(`p-1`,n===`popper`&&`min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,H.jsx)(yy,{})]})}));by.displayName=Sv.displayName;var xy=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Uv,{ref:n,"data-slot":`select-label`,className:au(`px-1.5 py-1 text-xs text-muted-foreground`,e),...t}));xy.displayName=Uv.displayName;var Sy=u.forwardRef(({className:e,children:t,...n},r)=>(0,H.jsxs)(qv,{ref:r,"data-slot":`select-item`,className:au(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[(0,H.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,H.jsx)(Zv,{children:(0,H.jsx)(Pn,{"aria-hidden":`true`,className:`pointer-events-none`})})}),(0,H.jsx)(Yv,{children:t})]}));Sy.displayName=qv.displayName;var Cy=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(iy,{ref:n,"data-slot":`select-separator`,className:au(`pointer-events-none -mx-1 my-1 h-px bg-border`,e),...t}));Cy.displayName=iy.displayName;var wy=Object.defineProperty,Ty=(e,t)=>wy(e,`name`,{value:t,configurable:!0}),Ey=!!(typeof window<`u`&&window.document&&window.document.createElement);function Dy(e,t,{checkForDefaultPrevented:n=!0}={}){return Ty(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}Ty(Dy,`composeEventHandlers`);function Oy(e){if(!Ey)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}Ty(Oy,`getOwnerWindow`);function ky(e){if(!Ey)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}Ty(ky,`getOwnerDocument`);function Ay(e,t=!1){let{activeElement:n}=ky(e);if(!n?.nodeName)return null;if(jy(n)&&n.contentDocument)return Ay(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=ky(n).getElementById(e);if(t)return t}}return n}Ty(Ay,`getActiveElement`);function jy(e){return e.tagName===`IFRAME`}Ty(jy,`isFrame`);var My=Object.defineProperty,Ny=(e,t)=>My(e,`name`,{value:t,configurable:!0});function Py(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Ny(Py,`setRef`);function Fy(...e){return t=>{let n=!1,r=e.map(e=>{let r=Py(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Py(e[t],null)}}}}Ny(Fy,`composeRefs`);function Iy(...e){return u.useCallback(Fy(...e),e)}Ny(Iy,`useComposedRefs`);var Ly=Object.defineProperty,Ry=(e,t)=>Ly(e,`name`,{value:t,configurable:!0});function zy(e,t){let n=u.createContext(t);n.displayName=e+`Context`;let r=Ry(e=>{let{children:t,...r}=e,i=u.useMemo(()=>r,Object.values(r));return(0,H.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=u.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return Ry(i,`useContext`),[r,i]}Ry(zy,`createContext`);function By(e,t=[]){let n=[];function r(t,r){let i=u.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=Ry(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=u.useMemo(()=>o,Object.values(o));return(0,H.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,d=u.useContext(l);if(d)return d;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return Ry(s,`useContext`),[o,s]}Ry(r,`createContext`);let i=Ry(()=>{let t=n.map(e=>u.createContext(e));return Ry(function(n){let r=n?.[e]||t;return u.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,Vy(i,...t)]}Ry(By,`createContextScope`);function Vy(...e){let t=e[0];if(e.length===1)return t;let n=Ry(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return Ry(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return u.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}Ry(Vy,`composeContextScopes`);var Hy=globalThis?.document?u.useLayoutEffect:()=>{},Uy=Object.defineProperty,Wy=(e,t)=>Uy(e,`name`,{value:t,configurable:!0}),Gy=u.useEffectEvent,Ky=u.useInsertionEffect;function qy(e){if(typeof Gy==`function`)return Gy(e);let t=u.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof Ky==`function`?Ky(()=>{t.current=e}):Hy(()=>{t.current=e}),u.useMemo(()=>((...e)=>t.current?.(...e)),[])}Wy(qy,`useEffectEvent`);var Jy=Object.defineProperty,Yy=(e,t)=>Jy(e,`name`,{value:t,configurable:!0}),Xy=u.useInsertionEffect||Hy;function Zy({prop:e,defaultProp:t,onChange:n=Yy(()=>{},`onChange`),caller:r}){let[i,a,o]=Qy({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,u.useCallback(t=>{if(s){let n=$y(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}Yy(Zy,`useControllableState`);function Qy({defaultProp:e,onChange:t}){let[n,r]=u.useState(e),i=u.useRef(n),a=u.useRef(t);return Xy(()=>{a.current=t},[t]),u.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}Yy(Qy,`useUncontrolledState`);function $y(e){return typeof e==`function`}Yy($y,`isFunction`);var eb=Symbol(`RADIX:SYNC_STATE`);function tb(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=qy(o),d=[{...n,state:a}];r&&d.push(r);let[f,p]=u.useReducer((t,n)=>{if(n.type===eb)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...d),m=f.state,h=u.useRef(m);u.useEffect(()=>{h.current!==m&&(h.current=m,c||l(m))},[m,h,c]);let g=u.useMemo(()=>i===void 0?f:{...f,state:i},[f,i]);return u.useEffect(()=>{c&&!Object.is(i,f.state)&&p({type:eb,state:i})},[i,f.state,c]),[g,p]}Yy(tb,`useControllableStateReducer`);var nb=Object.defineProperty,rb=(e,t)=>nb(e,`name`,{value:t,configurable:!0});function ib(e){let[t,n]=u.useState(void 0);return Hy(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}rb(ib,`useSize`);var ab=Object.defineProperty,ob=(e,t)=>ab(e,`name`,{value:t,configurable:!0}),sb=ob(((e,t)=>{let n={...t};for(let r in t){let i=e[r],a=t[r];if(/^on[A-Z]/.test(r)){if(i&&a){let e=typeof i==`function`,t=typeof a==`function`;n[r]=(...n)=>{let r=t?a(...n):void 0;return e&&i(...n),r}}else i&&(n[r]=i)}else r===`style`?n[r]={...typeof i==`object`?i:null,...typeof a==`object`?a:null}:r===`className`?n[r]=[i,a].filter(Boolean).join(` `):r===`aria-describedby`&&(n[r]=cb(a,i))}return{...e,...n}}),`mergeProps`);function cb(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}ob(cb,`concatAriaDescribedby`);var lb=u.createContext(sb);lb.displayName=`SlotContext`;function ub(e){let t=u.forwardRef((t,n)=>{let r=u.useContext(lb),{children:i,mergeProps:a=r,...o}=t,s=null,c=!1,l=[];_b(i)&&typeof xb==`function`&&(i=xb(i._payload)),u.Children.forEach(i,e=>{if(hb(e)){c=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;_b(n)&&typeof xb==`function`&&(n=xb(n._payload)),s=pb(t,n),l.push(s?.props?.children)}else l.push(e)}),s?s=u.cloneElement(s,void 0,l):!c&&u.Children.count(i)===1&&u.isValidElement(i)&&(s=i);let d=s?mb(s):void 0,f=Iy(n,d);if(!s){if(i||i===0)throw Error(c?bb(e):yb(e));return i}let p=a(o,s.props??{});return s.type!==u.Fragment&&(p.ref=n?f:d),u.cloneElement(s,p)});return t.displayName=`${e}.Slot`,t}ob(ub,`createSlot`);var db=Symbol.for(`radix.slottable`);function fb(e){let t=ob(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=db,t}ob(fb,`createSlottable`);var pb=ob((e,t)=>{if(`child`in e.props){let t=e.props.child;return u.isValidElement(t)?u.cloneElement(t,void 0,e.props.children(t.props.children)):null}return u.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function mb(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}ob(mb,`getElementRef`);function hb(e){return u.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===db}ob(hb,`isSlottable`);var gb=Symbol.for(`react.lazy`);function _b(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===gb&&`_payload`in e&&vb(e._payload)}ob(_b,`isLazyComponent`);function vb(e){return typeof e==`object`&&!!e&&`then`in e}ob(vb,`isPromiseLike`);var yb=ob(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),bb=ob(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),xb=u.use,Sb=Object.defineProperty,Cb=(e,t)=>Sb(e,`name`,{value:t,configurable:!0}),wb=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=ub(`Primitive.${t}`),r=u.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,H.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Tb(e,t){e&&d.flushSync(()=>e.dispatchEvent(t))}Cb(Tb,`dispatchDiscreteCustomEvent`);var Eb=Object.defineProperty,Db=(e,t)=>Eb(e,`name`,{value:t,configurable:!0}),Ob=`Switch`,[kb,Ab]=By(Ob),[jb,Mb]=kb(Ob);function Nb(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:d=`on`,internal_do_not_use_render:f}=e,[p,m]=Zy({prop:n,defaultProp:i??!1,onChange:c,caller:Ob}),[h,g]=u.useState(null),[_,v]=u.useState(null),y=u.useRef(!1),[b,x]=u.useReducer(e=>e+1,0),S={checked:p,setChecked:m,disabled:a,control:h,setControl:g,name:s,form:o,value:d,hasConsumerStoppedPropagationRef:y,userInteractionCount:b,onUserInteraction:x,required:l,defaultChecked:i,isFormControl:!h||!!o||!!h.closest(`form`),bubbleInput:_,setBubbleInput:v};return(0,H.jsx)(jb,{scope:t,...S,children:Vb(f)?f(S):r})}Db(Nb,`SwitchProvider`);var Pb=`SwitchTrigger`,Fb=u.forwardRef(Db(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:d,setChecked:f,hasConsumerStoppedPropagationRef:p,onUserInteraction:m,isFormControl:h,bubbleInput:g}=Mb(Pb,e),_=Iy(r,d),v=u.useRef(c);return u.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=Db(()=>f(v.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,f]),(0,H.jsx)(wb.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":Hb(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:_,onClick:Dy(t,e=>{m(),f(e=>!e),g&&h&&(p.current=e.isPropagationStopped(),p.current||e.stopPropagation())})})},`SwitchTrigger`)),Ib=u.forwardRef(Db(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,H.jsx)(Nb,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Fb,{...d,ref:t,__scopeSwitch:n}),e&&(0,H.jsx)(Bb,{__scopeSwitch:n})]})})},`Switch`)),Lb=`SwitchThumb`,Rb=u.forwardRef(Db(function(e,t){let{__scopeSwitch:n,...r}=e,i=Mb(Lb,n);return(0,H.jsx)(wb.span,{"data-state":Hb(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})},`SwitchThumb`)),zb=`SwitchBubbleInput`,Bb=u.forwardRef(Db(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:d,name:f,value:p,form:m,bubbleInput:h,setBubbleInput:g}=Mb(zb,e),_=Iy(r,g),v=ib(i),y=u.useRef(!1),b=u.useRef(s),x=u.useRef(o);u.useEffect(()=>{let e=h;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==x.current;x.current=o;let i=b.current!==s;b.current=s;let c=!(r&&a.current);if(i&&n){y.current=!r;let t=new Event(`click`,{bubbles:c});n.call(e,s),e.dispatchEvent(t),y.current=!1}},[h,s,a,o]);let S=u.useRef(s);return(0,H.jsx)(wb.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??S.current,required:l,disabled:d,name:f,value:p,form:m,...n,tabIndex:-1,ref:_,onClick:Dy(t,e=>{y.current&&e.stopPropagation()}),style:{...n.style,...v,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function Vb(e){return typeof e==`function`}Db(Vb,`isFunction`);function Hb(e){return e?`checked`:`unchecked`}Db(Hb,`getState`);var Ub=u.forwardRef(({className:e,size:t=`default`,...n},r)=>(0,H.jsx)(Ib,{ref:r,"data-slot":`switch`,"data-size":t,className:au(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent outline-none transition-all after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 dark:data-[state=unchecked]:bg-input/80`,e),...n,children:(0,H.jsx)(Rb,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-[state=checked]:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-[state=checked]:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-[state=unchecked]:translate-x-0 group-data-[size=sm]/switch:data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground`})}));Ub.displayName=Ib.displayName;var Wb=`Tabs`,[Gb,Kb]=Wi(Wb,[Np]),qb=Np(),[Jb,Yb]=Gb(Wb),Xb=u.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Pu(s),[d,f]=ea({prop:r,onChange:i,defaultProp:a??``,caller:Wb});return(0,H.jsx)(Jb,{scope:n,baseId:Qi(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,H.jsx)(W.div,{dir:u,"data-orientation":o,...l,ref:t})})});Xb.displayName=Wb;var Zb=`TabsList`,Qb=u.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Yb(Zb,n),o=qb(n);return(0,H.jsx)(Gp,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,H.jsx)(W.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Qb.displayName=Zb;var $b=`TabsTrigger`,ex=u.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Yb($b,n),s=qb(n),c=rx(o.baseId,r),l=ix(o.baseId,r),u=r===o.value;return(0,H.jsx)(Kp,{asChild:!0,...s,focusable:!i,active:u,children:(0,H.jsx)(W.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:U(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:U(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:U(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});ex.displayName=$b;var tx=`TabsContent`,nx=u.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Yb(tx,n),c=rx(s.baseId,r),l=ix(s.baseId,r),d=r===s.value,f=u.useRef(d);return u.useEffect(()=>{let e=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,H.jsx)(Qa,{present:i||d,children:({present:n})=>(0,H.jsx)(W.div,{"data-state":d?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:f.current?`0s`:void 0},children:n&&a})})});nx.displayName=tx;function rx(e,t){return`${e}-trigger-${t}`}function ix(e,t){return`${e}-content-${t}`}var ax=Xb,ox=Qb,sx=ex,cx=nx;function lx(e){return(0,H.jsx)(ax,{"data-slot":`tabs`,...e})}var ux=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(ox,{ref:n,"data-slot":`tabs-list`,className:au(`inline-flex h-9 items-center gap-1 rounded-lg bg-muted p-1 text-muted-foreground`,e),...t}));ux.displayName=`TabsList`;var dx=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(sx,{ref:n,"data-slot":`tabs-trigger`,className:au(`inline-flex h-7 items-center justify-center whitespace-nowrap rounded-md border border-transparent px-3 text-sm font-medium transition-all outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:border-border data-[state=active]:bg-background data-[state=active]:text-foreground`,e),...t}));dx.displayName=`TabsTrigger`;var fx=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(cx,{ref:n,"data-slot":`tabs-content`,className:au(`mt-4 outline-none`,e),...t}));fx.displayName=`TabsContent`;var px={sessions:`/sessions`,emulator:`/settings/emulator`,overview:`/settings/overview`,runtimes:`/settings/runtimes`,providers:`/settings/providers`,projects:`/settings/projects`,agents:`/settings/agents`,skills:`/settings/skills`,plugins:`/settings/plugins`,localRuntime:`/settings/local-runtime`,computerUse:`/settings/computer-use`},mx=`/settings`,hx=px.overview,gx=`/runtimes/:runtimeSelector/sessions`,_x=`/runtimes/:runtimeSelector/sessions/:sessionId`,vx=`!invalid-runtime-owner`,yx=/^[A-Za-z0-9][A-Za-z0-9._~-]{0,255}$/,bx={emulator:`/emulator`,overview:`/overview`,runtimes:`/runtimes`,providers:`/providers`,projects:`/projects`,agents:`/agents`,skills:`/skills`,plugins:`/plugins`},xx={"/settings/updates":`${px.overview}#software-update`,"/settings/daemon":`${px.localRuntime}#runtime`,"/settings/command":`${px.localRuntime}#terminal-command`,"/settings/computer":`${px.computerUse}#permissions`,"/settings/inspection":`${px.computerUse}#chrome-inspection`},Sx=[`localRuntime`,`computerUse`];function Cx(e){return Sx.includes(e)}function wx(e,t){return!Cx(e)||t}function Tx(e){let t=e.length>1?e.replace(/\/+$/,``):e;return Dx(t)||t===px.sessions||t.startsWith(`${px.sessions}/`)?`sessions`:Object.entries(px).find(([,e])=>e===t)?.[0]??`sessions`}function Ex(e,t=!0){let n=Tx(e);return n===`sessions`||!wx(n,t)?null:n}function Dx(e){let t=/^\/runtimes\/([^/]+)\/sessions(?:\/[^/]+)?\/?$/.exec(e);if(!t)return null;try{return kx(decodeURIComponent(t[1]))}catch{return vx}}function Ox(e){let t=new URLSearchParams(e).getAll(`runtime`);return t.length===0?null:t.length===1?kx(t[0]):vx}function kx(e){return yx.test(e)?e:vx}function Ax(e,t){return`/runtimes/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}`}function jx(e){return`/runtimes/${encodeURIComponent(e)}/sessions`}function Mx(e,t){let n=e?.returnTo;return typeof n==`string`&&n.startsWith(`/`)&&!n.startsWith(`//`)&&n!==`/settings`&&!n.startsWith(`/settings/`)?n:t}var Nx=`/api/plugins/install-preparations`,Px=`/api/plugin-marketplaces`,Fx=/^[A-Za-z0-9_-]{32,128}$/;function Ix(e){if(!Fx.test(e))throw Error(`invalid plugin preparation token`);return`${Nx}/${encodeURIComponent(e)}`}function Lx(e){return`${Ix(e)}/commit`}function Rx(){return typeof window>`u`?void 0:window.rynxSessionPortal}function zx(e){let t=Rx(),n=t?.portalId;if(!n)return e;let r=new URL(e,`http://session-portal.local`);return r.searchParams.set(`portal`,n),t.embedOrigin&&r.searchParams.set(`embed_origin`,t.embedOrigin),`${r.pathname}${r.search}${r.hash}`}function Bx(e){let t=new Headers(e),n=Rx(),r=n?.portalId;return r&&t.set(`x-rynx-session-portal`,r),n?.secret&&t.set(`x-rynx-session-portal-secret`,n.secret),t}function Vx(e){let t=Rx(),n=t?.portalId;n&&e.set(`portal`,n),t?.secret&&e.set(`portal_secret`,t.secret)}var Hx=class extends Error{status;code;outcome;constructor(e,t,n,r){super(e),this.name=`ApiRequestError`,this.status=t,this.code=n,this.outcome=r}};function Ux(e){return e instanceof Hx&&(e.outcome===`not_started`||[400,403,404,409,413].includes(e.status))}var Wx=`/api/runtimes/capability`,Gx=`x-rynx-runtime-capability`,Kx;async function qx(e,t,n){let r=location.protocol===`https:`?`wss`:`ws`,i=await Qx(n.refreshCapability),a=new URLSearchParams({capability:i,role:n.role??`owner`,cols:String(n.cols),rows:String(n.rows)});return Vx(a),`${r}://${location.host}/api/runtimes/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/terminal?${a.toString()}`}function Jx(e){let t=location.protocol===`https:`?`wss`:`ws`,n=new URLSearchParams;e&&n.set(`device`,e);let r=n.toString();return`${t}://${location.host}/api/emulator/touch${r?`?${r}`:``}`}async function Yx(e,t,n,r){let i=r?`${sS(r,e)}/interactions/${encodeURIComponent(t)}/resolve`:`/api/sessions/${encodeURIComponent(e)}/interactions/${encodeURIComponent(t)}/resolve`,a={method:`POST`,body:JSON.stringify({resolution:n})};return(r?await $x(i,a):await Xx(i,a)).disposition}async function Xx(e,t={}){return Zx(e,{},t)}async function Zx(e,t,n={}){let r=Bx(n.headers);n.body&&!r.has(`content-type`)&&r.set(`content-type`,`application/json`);let i=await fetch(e,{...n,headers:r});if(!i.ok){let e=`${i.status}`,t,n;try{let r=await i.json();typeof r.error==`string`&&(t=r.error,e=r.error),typeof r.code==`string`&&(t=r.code),(r.outcome===`not_started`||r.outcome===`unknown`)&&(n=r.outcome)}catch{}throw new Hx(e,i.status,t,n)}let a=await i.text();return a?JSON.parse(a):t}async function Qx(e=!1){return e&&(Kx=void 0),Kx||=Xx(Wx,{cache:`no-store`}).then(({capability:e})=>{if(typeof e!=`string`||!/^[A-Za-z0-9_-]{43}$/.test(e))throw Error(`invalid Runtime Web capability`);return e}).catch(e=>{throw Kx=void 0,e}),Kx}async function $x(e,t){let n=async n=>{let r=Bx(t.headers);return r.set(Gx,n),Xx(e,{...t,headers:r})},r=await Qx();try{return await n(r)}catch(e){if(!(e instanceof Error)||e.message!==`invalid_runtime_capability`)throw e;return Kx=void 0,n(await Qx())}}async function eS(e,t={}){let n=Bx(t.headers),r=await fetch(e,{...t,headers:n});if(!r.ok){let e=`${r.status}`;try{let t=await r.json();t.error&&(e=t.error)}catch{}throw Error(e)}return r.blob()}async function tS(e,t,n,r){let i=Bx({"content-type":`application/json`});await rS(await fetch(e,{method:`POST`,headers:i,body:t===void 0?void 0:JSON.stringify(t),signal:r}),n)}async function nS(e,t,n){await rS(await fetch(e,{signal:n,headers:Bx()}),t)}async function rS(e,t){if(!e.ok||!e.body){let t=`${e.status}`,n,r;try{let i=await e.json();i.error&&(n=i.error,t=i.error),i.code&&(n=i.code),(i.outcome===`not_started`||i.outcome===`unknown`)&&(r=i.outcome)}catch{}throw new Hx(t,e.status,n,r)}let n=e.body.getReader(),r=new TextDecoder,i=``;for(;;){let{done:e,value:a}=await n.read();if(e)break;i+=r.decode(a,{stream:!0});let o;for(;(o=i.indexOf(`
|
|
53
53
|
|
|
54
54
|
`))!==-1;){let e=i.slice(0,o);i=i.slice(o+2);let n=iS(e);n&&t(n)}}}function iS(e){let t=`message`,n=``;for(let r of e.split(`
|
|
55
|
-
`))r.startsWith(`event:`)?t=r.slice(6).trim():r.startsWith(`data:`)&&(n+=r.slice(5).trim());if(!t&&!n)return null;let r={};try{n&&(r=JSON.parse(n))}catch{}return{event:t,data:r}}function aS(e,t){return e?`/api/runtimes/${encodeURIComponent(e)}/emulator/${t}`:`/api/emulator/${t}`}function oS(e,t,n){let r=aS(e,t);return e?$x(r,n):Xx(r,n)}function sS(e,t,n){let r=`/api/runtimes/${encodeURIComponent(e)}/sessions`;if(t===void 0)return r;let i=`${r}/${encodeURIComponent(t)}`;return n?`${i}/${n}`:i}function cS(e,t){let n=`/api/runtimes/${encodeURIComponent(e)}/projects`;return t===void 0?n:`${n}/${encodeURIComponent(t)}`}function lS(e,t,...n){let r=`${sS(e,t)}/browser`;return n.length===0?r:`${r}/${n.map(e=>encodeURIComponent(e)).join(`/`)}`}function uS(e,t,n){let r=`${sS(e,t)}/emulator`;return n?`${r}/${n}`:r}function dS(e,t,n){let r=new URLSearchParams({bindingId:n});return zx(`${sS(e,t)}/emulator/frame?${r.toString()}`)}function fS(e,t,n,r,i){return $x(lS(e,t,`pages`,r,i),{method:`POST`,body:JSON.stringify({browserGeneration:n})})}function pS(e,t,n){return e?sS(e,t,n):`/api/sessions/${encodeURIComponent(t)}/${n}`}var Y={meta:()=>Xx(`/api/meta`),listRuntimeShareAddresses:()=>Xx(`/api/runtime-server/share-addresses`,{cache:`no-store`}).then(e=>e.addresses),shareRuntime:e=>$x(`/api/runtime-server/share`,{method:`POST`,body:JSON.stringify(e)}),listRuntimeAccess:()=>Xx(`/api/runtime-server/access`).then(e=>e.clients),revokeRuntimeAccess:e=>$x(`/api/runtime-server/access/${encodeURIComponent(e)}`,{method:`DELETE`}),deleteRevokedRuntimeAccess:e=>$x(`/api/runtime-server/access/${encodeURIComponent(e)}/record`,{method:`DELETE`}),listRuntimes:()=>Xx(`/api/runtimes`).then(e=>e.runtimes),listProviderClis:e=>Xx(`/api/runtimes/${encodeURIComponent(e)}/provider-clis`,{cache:`no-store`}),startProviderCliOperation:(e,t,n)=>$x(`/api/runtimes/${encodeURIComponent(e)}/provider-clis/${encodeURIComponent(t)}/${n}`,{method:`POST`,body:JSON.stringify({})}),getProviderCliJob:(e,t)=>Xx(`/api/runtimes/${encodeURIComponent(e)}/provider-clis/jobs/${encodeURIComponent(t)}`,{cache:`no-store`}).then(e=>e.job),pairRuntime:e=>$x(`/api/runtimes/pair`,{method:`POST`,body:JSON.stringify(e)}),testRuntime:e=>$x(`/api/runtimes/${encodeURIComponent(e)}/test`,{method:`POST`,body:JSON.stringify({})}),forgetRuntime:e=>$x(`/api/runtimes/${encodeURIComponent(e)}`,{method:`DELETE`}),getRuntimeBrowserState:(e,t)=>Zx(lS(e,t),null),getRuntimeBrowserRequestHeaders:(e,t)=>$x(lS(e,t,`request-headers`),{cache:`no-store`}),updateRuntimeBrowserRequestHeaders:(e,t)=>$x(lS(e,t.sessionId,`request-headers`),{method:`PUT`,body:JSON.stringify({expectedRevision:t.expectedRevision,enabled:t.enabled,headers:t.headers})}),openRuntimeBrowser:(e,t,n)=>$x(lS(e,t,`open`),{method:`POST`,body:JSON.stringify(n===void 0?{}:{url:n})}),closeRuntimeBrowser:(e,t,n)=>$x(lS(e,t,`close`),{method:`POST`,body:JSON.stringify({browserGeneration:n})}),createRuntimeBrowserPage:(e,t,n,r)=>$x(lS(e,t,`pages`),{method:`POST`,body:JSON.stringify({browserGeneration:n,...r===void 0?{}:{url:r}})}),closeRuntimeBrowserPage:(e,t,n,r)=>fS(e,t,n,r,`close`),activateRuntimeBrowserPage:(e,t,n,r)=>fS(e,t,n,r,`activate`),navigateRuntimeBrowserPage:(e,t,n,r,i)=>$x(lS(e,t,`pages`,r,`navigate`),{method:`POST`,body:JSON.stringify({browserGeneration:n,url:i})}),backRuntimeBrowserPage:(e,t,n,r)=>fS(e,t,n,r,`back`),forwardRuntimeBrowserPage:(e,t,n,r)=>fS(e,t,n,r,`forward`),reloadRuntimeBrowserPage:(e,t,n,r)=>fS(e,t,n,r,`reload`),getSessionEmulator:(e,t)=>Xx(uS(e,t)).then(e=>e.binding),listSessionEmulatorDevices:(e,t)=>Xx(uS(e,t,`devices`)).then(e=>e.devices),attachSessionEmulator:(e,t,n)=>$x(uS(e,t,`attach`),{method:`POST`,body:JSON.stringify({device:n})}),detachSessionEmulator:(e,t,n)=>$x(uS(e,t,`detach`),{method:`POST`,body:JSON.stringify({bindingId:n})}),tapSessionEmulator:(e,t,n,r,i)=>$x(uS(e,t,`tap`),{method:`POST`,body:JSON.stringify({bindingId:n,x:r,y:i})}),gestureSessionEmulator:(e,t,n,r)=>$x(uS(e,t,`gesture`),{method:`POST`,body:JSON.stringify({bindingId:n,points:r})}),buttonSessionEmulator:(e,t,n,r)=>$x(uS(e,t,`button`),{method:`POST`,body:JSON.stringify({bindingId:n,name:r})}),sessionEmulatorFrameBlob:(e,t,n,r)=>eS(dS(e,t,n),{signal:r,cache:`no-store`}),listPlugins:()=>Xx(`/api/plugins`).then(e=>e.plugins),listPluginMarketplaces:()=>Xx(Px,{cache:`no-store`}).then(e=>e.marketplaces),addPluginMarketplace:e=>$x(Px,{method:`POST`,headers:{"x-rynx-console":`1`},body:JSON.stringify(e)}),refreshPluginMarketplace:e=>$x(`${Px}/${encodeURIComponent(e)}/refresh`,{method:`POST`,headers:{"x-rynx-console":`1`},body:`{}`}),removePluginMarketplace:e=>$x(`${Px}/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{"x-rynx-console":`1`}}),preparePluginInstallation:(e,t)=>$x(Nx,{method:`POST`,headers:{"x-rynx-console":`1`},body:JSON.stringify(e),signal:t}),commitPluginInstallation:(e,t,n)=>$x(Lx(e),{method:`POST`,headers:{"x-rynx-console":`1`},body:JSON.stringify(t),signal:n}),cancelPluginInstallation:e=>$x(Ix(e),{method:`DELETE`,headers:{"x-rynx-console":`1`}}),setPluginEnabled:(e,t)=>$x(`/api/plugins/${encodeURIComponent(e)}/${t?`enable`:`disable`}`,{method:`POST`,headers:{"x-rynx-console":`1`},body:`{}`}).then(e=>e.plugin),pluginSettingsUi:(e,t)=>Xx(`/api/plugins/${encodeURIComponent(e)}/settings-ui`,{cache:`no-store`,signal:t}),pluginSettingsCall:(e,t,n,r,i)=>$x(`/api/plugins/${encodeURIComponent(e)}/settings`,{method:`POST`,headers:{"x-rynx-console":`1`},body:JSON.stringify({generation:t,method:n,params:r}),signal:i}).then(e=>e.result),emulatorDevices:e=>Xx(aS(e,`devices`)).then(e=>e.devices),activeEmulator:e=>Xx(aS(e,`active`)).then(e=>e.active),attachEmulator:(e,t)=>oS(t,`attach`,{method:`POST`,body:JSON.stringify({device:e})}),tapEmulator:(e,t,n,r)=>oS(r,`tap`,{method:`POST`,body:JSON.stringify({x:e,y:t,device:n})}),gestureEmulator:(e,t,n)=>oS(n,`gesture`,{method:`POST`,body:JSON.stringify({points:e,device:t})}),buttonEmulator:(e,t,n)=>oS(n,`button`,{method:`POST`,body:JSON.stringify({name:e,device:t})}),shutdownEmulator:(e,t)=>oS(t,`shutdown`,{method:`POST`,body:JSON.stringify({device:e})}),emulatorVideoStreamUrl:e=>`/api/emulator/video${e?`?device=${encodeURIComponent(e)}`:``}`,emulatorFrameBlob:e=>eS(`/api/emulator/frame${e?`?device=${encodeURIComponent(e)}`:``}`),screenshotEmulator:(e,t)=>Xx(`/api/emulator/screenshot`,{method:`POST`,body:JSON.stringify({device:e,out:t})}),emulatorScreenshotBlob:e=>eS(`/api/emulator/screenshot-file?file=${encodeURIComponent(e)}`),listAgents:()=>Xx(`/api/agents`).then(e=>e.agents),getAgent:e=>Xx(`/api/agents/${encodeURIComponent(e)}`),listAgentRuntimeOptions:(e=!1)=>Xx(`/api/agents/runtime-options${e?`?refresh=1`:``}`,{cache:`no-store`}).then(e=>e.runtimes),createAgent:e=>Xx(`/api/agents`,{method:`POST`,body:JSON.stringify(e)}),updateAgent:(e,t)=>Xx(`/api/agents/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(t)}),deleteAgent:e=>Xx(`/api/agents/${encodeURIComponent(e)}`,{method:`DELETE`}),listProjects:e=>Xx(cS(e),{cache:`no-store`}).then(e=>e.projects),createProject:(e,t)=>$x(cS(e),{method:`POST`,body:JSON.stringify(t)}).then(e=>e.project),updateProject:(e,t,n)=>$x(cS(e,t),{method:`PUT`,body:JSON.stringify(n)}).then(e=>e.project),deleteProject:(e,t)=>$x(cS(e,t),{method:`DELETE`}),listSkills:()=>Xx(`/api/skills`).then(e=>e.skills),getSkill:e=>Xx(`/api/skills/${encodeURIComponent(e)}`),readSkillFile:(e,t)=>Xx(`/api/skills/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`),installSkill:e=>Xx(`/api/skills`,{method:`POST`,body:JSON.stringify(e)}).then(e=>e.skills),scanLocalSkills:e=>Xx(`/api/skills/local-scan`,{method:`POST`,body:JSON.stringify({runtime:e})}).then(e=>e.candidates),importLocalSkills:(e,t)=>Xx(`/api/skills/local-import`,{method:`POST`,body:JSON.stringify({runtime:e,keys:t})}).then(e=>e.results),importSkillArchive:(e,t)=>Xx(`/api/skills/import-archive`,{method:`POST`,body:JSON.stringify({filename:e,contentBase64:t})}).then(e=>e.results),deleteSkill:e=>Xx(`/api/skills/${encodeURIComponent(e)}`,{method:`DELETE`}),listSessions:e=>Xx(e?sS(e):`/api/sessions`).then(e=>e.sessions),listSessionAgentOptions:e=>Xx(`${sS(e)}/agent-options`).then(e=>e.agents),listSessionLaunchOptions:e=>Xx(`${sS(e)}/launch-options`),getSessionExecutionSettings:(e,t)=>Xx(sS(e,t,`execution`),{cache:`no-store`}),updateSessionExecutionSettings:(e,t,n)=>$x(sS(e,t,`execution`),{method:`PUT`,body:JSON.stringify(n)}),createSession:(e,t)=>{let n=t?sS(t):`/api/sessions`,r={method:`POST`,body:JSON.stringify(e)};return t?$x(n,r):Xx(n,r)},forkSession:(e,t,n)=>$x(sS(e,t,`fork`),{method:`POST`,body:JSON.stringify(n)}),sendSessionMessage:(e,t,n,r,i)=>i?$x(sS(i,e,`messages`),{method:`POST`,body:JSON.stringify(typeof t==`string`?{message:t}:t),signal:r}):tS(`/api/sessions/${encodeURIComponent(e)}/messages`,typeof t==`string`?{message:t}:t,n,r),getSessionResourcePolicy:(e,t)=>Xx(`${sS(e,t,`resources`)}/policy`,{cache:`no-store`}),uploadSessionResource:(e,t,n,r,i,a)=>$x(sS(e,t,`resources`),{method:`POST`,body:n,signal:a,headers:{"content-type":n.type||`application/octet-stream`,"x-rynx-resource-type":i,"x-rynx-upload-id":r,"x-rynx-filename":encodeURIComponent(n.name)}}).then(e=>e.resource),deleteSessionResource:(e,t,n)=>$x(`${sS(e,t,`resources`)}/${encodeURIComponent(n)}`,{method:`DELETE`}),sessionResourceContentUrl:(e,t,n)=>zx(`${sS(e,t,`resources`)}/${encodeURIComponent(n.resourceId)}/content`),sessionItemFileContentUrl:(e,t,n,r)=>zx(`${sS(e,t,`items`)}/${encodeURIComponent(n)}/files/${r}/content`),sessionWorkspaceFileContentUrl:(e,t,n)=>zx(`${sS(e,t)}/workspace/files/content?${new URLSearchParams({path:n}).toString()}`),enqueueSessionMessage:(e,t,n)=>$x(sS(e,t,`messages/queue`),{method:`POST`,body:JSON.stringify({message:n})}),startSessionTerminal:(e,t)=>$x(sS(e,t,`terminal/start`),{method:`POST`,body:`{}`}),streamSession:(e,t,n,r)=>nS(pS(r,e,`stream`),t,n),getSessionHistory:e=>Xx(`/api/sessions/${encodeURIComponent(e)}/history`).then(e=>e.items),getSessionSnapshot:(e,t,n)=>Xx(pS(n,e,`snapshot`),{signal:t}),getSessionSnapshotPage:(e,t,n,r)=>{let i=new URLSearchParams;t!==void 0&&i.set(`afterId`,t);let a=i.size>0?`?${i.toString()}`:``;return Xx(`${pS(r,e,`snapshot-page`)}${a}`,{signal:n})},closeSession:(e,t)=>{let n=t?sS(t,e):`/api/sessions/${encodeURIComponent(e)}`,r={method:`DELETE`};return t?$x(n,r):Xx(n,r)},interruptSession:(e,t)=>{let n=pS(t,e,`interrupt`),r={method:`POST`};return t?$x(n,r):Xx(n,r)}},mS=`rynx.control.runtime-target.v1`,hS={selector:`local`,daemonId:`local`,displayName:`This device`,binding:`local`};function gS(e){if(!e)return`local`;try{return e.getItem(`rynx.control.runtime-target.v1`)?.trim()||`local`}catch{return`local`}}function _S(e,t){if(e)try{e.setItem(mS,t)}catch{}}function vS(e){let t=new Map;for(let n of e)!n.selector||t.has(n.selector)||t.set(n.selector,n);return t.has(`local`)||t.set(`local`,hS),[...t.values()].sort((e,t)=>e.selector===`local`?-1:t.selector===`local`?1:e.displayName.localeCompare(t.displayName))}var yS=(0,u.createContext)(null);function bS({children:e}){let t=Rx(),n=$e(),r=nt(),i=Dx(n.pathname)??(n.pathname===px.sessions?Ox(n.search):null),[a,o]=(0,u.useState)(()=>gS(typeof window>`u`?void 0:window.localStorage)),s=i??a,[c,l]=(0,u.useState)([hS]),d=(0,u.useCallback)(e=>{l(vS(e))},[]),f=(0,u.useCallback)(async()=>{if(t){d([hS]);return}try{d(await Y.listRuntimes())}catch(e){V.error(`Failed to load Runtimes: ${e.message}`)}},[t,d]);(0,u.useEffect)(()=>{f()},[f]),(0,u.useEffect)(()=>{!i||i===`!invalid-runtime-owner`||(o(i),_S(typeof window>`u`?void 0:window.localStorage,i))},[i]);let p=(0,u.useCallback)(e=>{let t=e.trim();t&&(o(t),_S(typeof window>`u`?void 0:window.localStorage,t),(n.pathname===px.sessions||n.pathname.startsWith(`${px.sessions}/`)||Dx(n.pathname)!==null)&&i!==t&&r(zx(jx(t))))},[n.pathname,r,i]),m=(0,u.useMemo)(()=>{let e=c.find(e=>e.selector===s)??(s===`!invalid-runtime-owner`?{selector:s,daemonId:s,displayName:`Invalid Runtime URL`,binding:`direct`}:{selector:s,daemonId:s,displayName:`${s} (unavailable)`,binding:s===`local`?`local`:`direct`}),t=s!==`local`;return{runtimes:c,runtimeSelector:s,runtimeRoute:t?s:void 0,selectedRuntime:e,isRemoteRuntime:t,selectRuntime:p,refreshRuntimes:f,updateRuntimes:d}},[f,s,c,p,d]);return(0,H.jsx)(yS.Provider,{value:m,children:e})}function xS(){let e=(0,u.useContext)(yS);if(!e)throw Error(`useRuntimeTarget must be used inside RuntimeTargetProvider`);return e}var SS=`!add-runtime`;function CS(){let e=$e(),t=nt(),{runtimes:n,runtimeSelector:r,selectedRuntime:i,selectRuntime:a}=xS(),o=n.some(e=>e.selector===r)?n:[...n,i];return(0,H.jsx)(`div`,{className:`ml-auto w-44 max-w-full sm:w-60`,children:(0,H.jsxs)(my,{value:r,onValueChange:n=>{if(n===SS){t(px.runtimes,{state:{returnTo:`${e.pathname}${e.search}${e.hash}`}});return}a(n)},children:[(0,H.jsxs)(_y,{className:`h-10 w-full min-w-0 gap-1.5 border-0 bg-transparent px-2 font-mono text-[10px] shadow-none hover:bg-[var(--accent)] focus-visible:ring-2 sm:h-7`,"aria-label":`Active Runtime`,children:[(0,H.jsx)(`span`,{className:`hidden shrink-0 uppercase tracking-[0.12em] text-[var(--muted-foreground)] sm:inline`,children:`Runtime ·`}),(0,H.jsx)(gy,{placeholder:`Select Runtime`})]}),(0,H.jsxs)(by,{align:`end`,children:[o.map(e=>{let t=e.binding===`local`?hr:Wr;return(0,H.jsx)(Sy,{value:e.selector,children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(t,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.displayName})]})},e.selector)}),(0,H.jsx)(Cy,{}),(0,H.jsx)(Sy,{value:SS,children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(Ir,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{children:`Add Runtime…`})]})})]})]})})}function wS(){return typeof window>`u`?null:window.rynxDesktopIntegration??null}function TS(e){return e.globalCli.state===`foreign`||e.globalCli.state===`unwritable`}function ES(e,t){return!e.runtime.ready||!e.builtinSkill.ready?!1:e.globalCli.state===`installed`&&!e.globalCli.canInstall||e.globalCli.state===`development`||TS(e)&&t}var DS=(0,u.createContext)({status:null,operation:null,error:null,checkForUpdates:async()=>null,installUpdate:async()=>null});function OS({children:e}){let t=wS(),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(!t)return;let e=!0,n=t.onAppUpdateStatus(t=>{e&&(r(t),t.error||s(null))});return t.getAppUpdateStatus().then(t=>{e&&r(t)}).catch(t=>{e&&s(AS(t))}),()=>{e=!1,n()}},[t]);let c=(0,u.useCallback)(async()=>{if(!t)return null;a(`check`),s(null);try{let e=await t.checkForAppUpdates();return r(e),e}catch(e){return s(AS(e)),null}finally{a(null)}},[t]),l=(0,u.useCallback)(async()=>{if(!t)return null;a(`install`),s(null);try{let e=await t.installAppUpdate();return r(e),e}catch(e){return s(AS(e)),null}finally{a(null)}},[t]),d=(0,u.useMemo)(()=>({status:n,operation:i,error:o,checkForUpdates:c,installUpdate:l}),[c,o,l,i,n]);return(0,H.jsx)(DS.Provider,{value:d,children:e})}function kS(){return(0,u.useContext)(DS)}function AS(e){return e instanceof Error?e.message:String(e)}function jS(){let{status:e,operation:t,error:n,installUpdate:r}=kS();if(!e?.availableVersion||e.phase!==`downloading`&&e.phase!==`ready`&&e.phase!==`installing`)return null;let i=t===`install`||e.phase===`installing`,a=e.phase===`ready`&&!i,o=n??e.error;return(0,H.jsxs)(`div`,{className:`group/update relative flex shrink-0 items-center`,children:[(0,H.jsxs)(J,{variant:`ghost`,size:`icon-xs`,className:`relative text-[var(--primary)] hover:text-[var(--primary)]`,"aria-label":`Rynx ${e.availableVersion} update available`,"aria-haspopup":`dialog`,children:[e.phase===`downloading`||i?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Bn,{}),(0,H.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 rounded-full bg-[var(--primary)] ring-2 ring-[var(--background)]`,"aria-hidden":`true`})]}),(0,H.jsx)(`div`,{role:`dialog`,"aria-label":`Rynx update`,className:`invisible absolute bottom-full right-0 z-50 w-72 translate-y-1 pb-2 opacity-0 transition-[opacity,transform,visibility] duration-150 group-hover/update:visible group-hover/update:translate-y-0 group-hover/update:opacity-100 group-focus-within/update:visible group-focus-within/update:translate-y-0 group-focus-within/update:opacity-100`,children:(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--border)] bg-[var(--popover)] p-3 font-sans text-[var(--popover-foreground)] shadow-xl`,children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/12 text-[var(--primary)]`,children:a?(0,H.jsx)(Bn,{className:`size-4`}):e.phase===`downloading`?(0,H.jsx)(Yn,{className:`size-4`}):(0,H.jsx)(B,{className:`size-4 animate-spin`})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-xs font-semibold text-[var(--foreground)]`,children:a?`Update ready`:i?`Preparing update`:`Downloading update`}),(0,H.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-4 text-[var(--muted-foreground)]`,children:a?`${e.appName} ${e.availableVersion} is ready to install.`:i?`Rynx will restart when the local Runtime is safe to stop.`:`${e.appName} ${e.availableVersion} is downloading in the background.`})]})]}),a&&(0,H.jsxs)(J,{size:`sm`,className:`mt-3 w-full`,onClick:()=>void r(),children:[(0,H.jsx)(Bn,{}),`Restart to update`]}),o&&(0,H.jsx)(`p`,{className:`mt-2 text-[10px] leading-4 text-[var(--destructive)]`,children:o})]})})]})}function X(...e){return iu(Mc(e))}function MS({children:e,theme:t,onToggleTheme:n}){let r=$e(),i=Rx(),{runtimeSelector:a}=xS(),o=Tx(r.pathname),s=r.pathname===`/settings`||r.pathname.startsWith(`/settings/`),c=Mx(r.state,jx(a)),l=s?c:hx,u=s?void 0:{returnTo:`${r.pathname}${r.search}${r.hash}`};return(0,H.jsxs)(`div`,{className:`grid h-dvh min-h-0 grid-rows-[minmax(0,1fr)_2.5rem] overflow-hidden bg-[var(--background)] sm:grid-rows-[minmax(0,1fr)_2rem]`,children:[(0,H.jsx)(`main`,{className:`min-h-0 overflow-hidden focus:outline-none`,children:e}),(0,H.jsxs)(`footer`,{className:`app-no-drag flex min-w-0 items-center gap-3 border-t border-[var(--border)] bg-[var(--muted)]/24 px-2 font-mono text-[10px] text-[var(--muted-foreground)] sm:px-3`,children:[(0,H.jsx)(`span`,{className:`hidden truncate uppercase tracking-[0.12em] min-[480px]:block`,children:s?o===`emulator`?`Emulator · local device`:`Settings · local configuration`:`Session workbench`}),(0,H.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-1.5`,children:[i?(0,H.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 px-1`,children:[(0,H.jsx)(`span`,{className:`text-[var(--foreground)]`,children:`Rynx Sessions`}),i.access===`read_only`&&(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`· read only`})]}):s?(0,H.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 px-1`,children:[(0,H.jsx)(`span`,{className:`text-[var(--foreground)]`,children:`Control Plane`}),(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,H.jsx)(`span`,{children:`This device`})]}):(0,H.jsx)(CS,{}),(0,H.jsx)(`span`,{className:`h-3.5 w-px bg-[var(--border)]`,"aria-hidden":`true`}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[!i&&(0,H.jsx)(jS,{}),(0,H.jsx)(J,{variant:`ghost`,size:`icon-xs`,className:`shrink-0`,onClick:n,"aria-label":t===`dark`?`Use light mode`:`Use dark mode`,title:t===`dark`?`Light mode`:`Dark mode`,children:t===`dark`?(0,H.jsx)(ai,{}):(0,H.jsx)(wr,{})}),!i&&(0,H.jsx)(J,{asChild:!0,variant:`ghost`,size:`icon-xs`,className:X(`shrink-0`,s&&`text-[var(--primary)]`),children:(0,H.jsx)(hn,{to:l,state:u,"aria-label":s?`Back to app`:`Settings`,title:s?`Back to app`:`Settings`,children:(0,H.jsx)(Kr,{})})})]})]})]})]})}var NS=`/assets/rynx-wordmark-LL1QRYHD.png`;function PS({bridge:e,children:t}){let[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(`refresh`),[c,l]=(0,u.useState)(!1),d=(0,u.useCallback)(async(t=!1)=>{s(`refresh`),a(null);try{let n=await e.getStatus(t);ES(n,!1)?r(await e.completeOnboarding()):r(n)}catch(e){a(e.message)}finally{s(null)}},[e]);(0,u.useEffect)(()=>{e.initialOnboardingCompleted||d()},[e.initialOnboardingCompleted,d]);let f=n?ES(n,c):!1;async function p(){let t=n?.globalCli.path;if(t){s(`install`),a(null);try{let n=await e.installCli(t);l(!1),ES(n,!1)?r(await e.completeOnboarding()):r(n)}catch(t){a(t.message);try{r(await e.getStatus(!0))}catch{}}finally{s(null)}}}async function m(){s(`runtime`),a(null);try{r(await e.restartDaemon())}catch(e){a(e.message)}finally{s(null)}}async function h(){if(!(!n||!f)){s(`complete`),a(null);try{r(await e.completeOnboarding())}catch(e){a(e.message)}finally{s(null)}}}if(e.initialOnboardingCompleted||n?.onboardingCompleted)return t;let g=!!(n?.runtime.ready&&n?.builtinSkill.ready);return(0,H.jsxs)(`div`,{className:`grid h-dvh min-h-0 overflow-hidden bg-[var(--background)] md:grid-cols-[15rem_minmax(0,1fr)]`,children:[(0,H.jsxs)(`aside`,{className:`app-drag-region desktop-macos-titlebar-inset shrink-0 border-b border-[var(--border)] bg-[var(--muted)]/18 p-4 md:border-r md:border-b-0 md:p-5`,children:[(0,H.jsx)(`img`,{src:NS,alt:`rynx`,className:`h-5 w-auto dark:brightness-0 dark:invert`}),(0,H.jsxs)(`div`,{className:`app-no-drag mt-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,H.jsx)(`p`,{className:`label-caps text-[10px] text-[var(--primary)]`,children:`Setup`}),(0,H.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--muted-foreground)]`,children:`1/1`})]}),(0,H.jsx)(`ol`,{className:`mt-3`,"aria-label":`Setup steps`,children:(0,H.jsxs)(`li`,{"aria-current":`step`,className:`flex items-center gap-2 rounded-lg bg-[var(--muted)] px-3 py-2.5 text-sm font-medium text-[var(--foreground)] ring-1 ring-inset ring-[var(--border)]`,children:[(0,H.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center rounded-full bg-[var(--primary)] text-[10px] font-semibold text-[var(--primary-foreground)]`,children:`1`}),(0,H.jsx)(`span`,{className:`truncate`,children:`Terminal command`})]})})]})]}),(0,H.jsxs)(`main`,{className:`app-no-drag relative min-h-0 overflow-auto`,children:[(0,H.jsx)(`div`,{className:`desktop-macos-home-titlebar`,"aria-hidden":`true`}),(0,H.jsx)(`div`,{className:`grid min-h-full place-items-center px-5 py-12 sm:px-8 md:px-12`,children:(0,H.jsxs)(`section`,{className:`w-full max-w-xl`,"aria-labelledby":`onboarding-command-title`,children:[(0,H.jsx)(FS,{titleId:`onboarding-command-title`,title:`Set up the Terminal command`,description:`Install one small command so Rynx is available from any Terminal.`}),(0,H.jsx)(`div`,{className:`mt-7 rounded-lg border border-[var(--border)] bg-[var(--card)] p-5 shadow-sm`,"aria-busy":o!==null,children:n?g?(0,H.jsx)(IS,{status:n,pending:o,acknowledged:c,onAcknowledgedChange:l,onInstall:()=>void p(),onRefresh:()=>void d(!0),onContinue:()=>void h()}):(0,H.jsx)(LS,{status:n,pending:o,onRetry:()=>void m()}):(0,H.jsxs)(`div`,{className:`flex min-h-40 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[o===`refresh`&&(0,H.jsx)(B,{className:`size-4 animate-spin`}),o===`refresh`?`Getting Rynx ready…`:`Setup status is unavailable.`]})}),i&&(0,H.jsxs)(`div`,{role:`alert`,className:`mt-5 flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_35%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_7%,var(--background))] p-3 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(zn,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]})]})})]})]})}function FS({titleId:e,title:t,description:n}){return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{id:e,className:`text-2xl font-semibold tracking-tight`,children:t}),(0,H.jsx)(`p`,{className:`mt-2 max-w-lg text-sm leading-6 text-[var(--muted-foreground)]`,children:n})]})}function IS({status:e,pending:t,acknowledged:n,onAcknowledgedChange:r,onInstall:i,onRefresh:a,onContinue:o}){let s=e.globalCli.state===`installed`,c=e.globalCli.state===`development`,l=s&&!e.globalCli.canInstall,u=TS(e),d=ES(e,n);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{className:l?`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--success)]/12 text-[var(--success)]`:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:l?(0,H.jsx)(Pn,{className:`size-4`}):(0,H.jsx)(qn,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium`,children:`Terminal command`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:RS(e)})]})]}),u&&(0,H.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 rounded-lg border border-[color-mix(in_srgb,var(--warning)_35%,var(--border))] bg-[color-mix(in_srgb,var(--warning)_7%,var(--background))] p-3 text-xs`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),className:`mt-0.5 size-4 shrink-0 accent-[var(--primary)]`}),(0,H.jsxs)(`span`,{children:[`Continue without Terminal access. I'll resolve the`,` `,(0,H.jsx)(`code`,{className:`font-mono`,children:`rynx`}),` command later.`]})]}),(0,H.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2`,children:[e.globalCli.canInstall&&(0,H.jsxs)(J,{disabled:t!==null,onClick:i,children:[t===`install`&&(0,H.jsx)(B,{className:`animate-spin`}),`Install command`]}),(l||c||u)&&(0,H.jsxs)(J,{disabled:t!==null||!d,onClick:o,children:[`Continue`,(0,H.jsx)(jn,{})]}),(0,H.jsxs)(J,{variant:`outline`,disabled:t!==null,onClick:a,children:[(0,H.jsx)(zr,{className:t===`refresh`?`animate-spin`:``}),`Check again`]})]})]})}function LS({status:e,pending:t,onRetry:n}){return(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--warning)]/12 text-[var(--warning)]`,children:(0,H.jsx)(zn,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium`,children:e.builtinSkill.ready?`Rynx couldn’t finish starting`:`Rynx needs to be reinstalled`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:e.builtinSkill.ready?`Try again to continue.`:`A required app component is unavailable. Reinstall Rynx, then open it again.`}),e.builtinSkill.ready&&(0,H.jsxs)(J,{className:`mt-4`,variant:`outline`,disabled:t!==null,onClick:n,children:[t===`runtime`&&(0,H.jsx)(B,{className:`animate-spin`}),`Try again`]})]})]})}function RS(e){switch(e.globalCli.state){case`installed`:return e.globalCli.canInstall?`Install the rynx command to use Rynx from Terminal.`:`Rynx is ready to use from Terminal.`;case`missing`:return`Install the rynx command to use Rynx from Terminal.`;case`stale`:return`An older rynx command was found. Repair it to continue.`;case`foreign`:return`Another command named rynx already exists. Resolve it later in Settings.`;case`development`:return`Terminal command registration is disabled in development builds.`;case`unwritable`:return`Rynx could not install the command automatically. Resolve it later in Settings.`;case`error`:return`Rynx could not check the command. Check again before continuing.`}}function zS({bridge:e}){let[t,n]=(0,u.useState)(null),[r,i]=(0,u.useState)(!1),[a,o]=(0,u.useState)(null),s=(0,u.useRef)(!1),c=(0,u.useRef)(0),l=(0,u.useCallback)(e=>{e.requestId<=c.current||(c.current=e.requestId,n(e),i(!1),o(null),s.current=!1)},[]);(0,u.useEffect)(()=>{let t=!0,n=e.onQuitPrompt(e=>{t&&l(e)});return e.getPendingQuitPrompt().then(e=>{t&&e&&l(e)}).catch(()=>{}),()=>{t=!1,n()}},[l,e]);let d=(0,u.useCallback)(async()=>{if(!(!t||r||s.current)){s.current=!0;try{let r=await e.respondToQuit(t.requestId,`cancel`);if(r.outcome===`failed`){o(r.message);return}if(r.outcome===`quitting`){i(!0);return}r.outcome===`cancelled`&&(n(null),o(null))}catch{o(`Rynx couldn’t dismiss the quit request. Try again.`)}finally{s.current=!1}}},[e,t,r]),f=(0,u.useCallback)(async()=>{if(!(!t||t.kind!==`active-work`||s.current)){s.current=!0,i(!0),o(null);try{let r=await e.respondToQuit(t.requestId,`force`);r.outcome===`failed`?(o(r.message),i(!1)):r.outcome===`cancelled`&&(n(null),i(!1))}catch{o(`Rynx couldn’t stop the running work. Try again.`),i(!1)}finally{s.current=!1}}},[e,t]),p=t?.kind===`active-work`;return(0,H.jsx)(uu,{open:t!==null,onOpenChange:e=>{e||d()},children:(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsx)(_u,{className:`bg-destructive/10 text-destructive`,children:(0,H.jsx)(ci,{"aria-hidden":`true`})}),(0,H.jsx)(vu,{children:p?`Quit Rynx?`:`Rynx couldn’t quit`}),(0,H.jsx)(yu,{children:p?`Work is still running. Quitting now will stop it and close the open workspace.`:`Rynx couldn’t stop its local service safely. Keep the app open and try again.`})]}),a&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{disabled:r,children:p?`Keep working`:`Close`}),p&&(0,H.jsx)(J,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>void f(),children:r?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(B,{className:`animate-spin motion-reduce:animate-none`}),`Quitting…`]}):`Quit anyway`})]})]})})}var BS=[{label:`General`,items:[{id:`overview`,label:`Overview`,icon:gr},{id:`projects`,label:`Projects`,icon:ir}]},{label:`Connections`,items:[{id:`localRuntime`,label:`Local Runtime`,icon:qn},{id:`runtimes`,label:`Runtimes`,icon:Wr}]},{label:`AI Capabilities`,items:[{id:`providers`,label:`Providers`,icon:ti},{id:`agents`,label:`Agents`,icon:Mn},{id:`skills`,label:`Skills`,icon:ei}]},{label:`Integrations`,items:[{id:`computerUse`,label:`Computer Use`,icon:Cr},{id:`emulator`,label:`Emulator`,icon:$r},{id:`plugins`,label:`Plugins`,icon:Rr}]}];function VS({activeView:e,desktopIntegrationAvailable:t,children:n}){let r=nt(),i=$e(),{runtimeSelector:a}=xS(),o=Mx(i.state,jx(a)),s={returnTo:o},c=BS.map(e=>({...e,items:e.items.filter(({id:e})=>wx(e,t))})).filter(e=>e.items.length>0),l=c.flatMap(e=>e.items);return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-[var(--background)] md:grid md:grid-cols-[14rem_minmax(0,1fr)]`,children:[(0,H.jsxs)(`aside`,{className:`hidden min-h-0 flex-col border-r border-[var(--border)] bg-[var(--muted)]/18 md:flex`,children:[(0,H.jsxs)(`div`,{className:`app-drag-region desktop-macos-titlebar-inset border-b border-[var(--border)] p-2.5`,children:[(0,H.jsx)(`div`,{className:`mb-2 flex h-7 items-center px-0.5`,children:(0,H.jsxs)(hn,{to:o,className:`app-no-drag flex w-fit items-center gap-2`,"aria-label":`Rynx`,children:[(0,H.jsx)(`img`,{src:NS,alt:`rynx`,className:`h-5 w-auto dark:brightness-0 dark:invert`}),(0,H.jsx)(`span`,{className:`label-caps text-[8px] text-[var(--muted-foreground)]`,children:`control`})]})}),(0,H.jsx)(J,{asChild:!0,variant:`ghost`,size:`sm`,className:`app-no-drag w-full justify-start gap-2 px-2`,children:(0,H.jsxs)(hn,{to:o,children:[(0,H.jsx)(An,{className:`size-3.5`}),`Back to app`]})})]}),(0,H.jsx)(U_,{className:`min-h-0 flex-1`,children:(0,H.jsx)(`nav`,{className:`space-y-4 p-3`,"aria-label":`Settings`,children:c.map(t=>(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`label-caps mb-1 px-2 text-[9px] text-[var(--muted-foreground)]`,children:t.label}),(0,H.jsx)(`div`,{className:`grid gap-0.5`,children:t.items.map(({id:t,label:n,icon:r})=>(0,H.jsxs)(hn,{to:px[t],state:s,"aria-current":e===t?`page`:void 0,className:X(`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,e===t?`bg-[var(--primary)]/10 text-[var(--primary)]`:`text-[var(--muted-foreground)] hover:bg-[var(--accent)] hover:text-[var(--accent-foreground)]`),children:[(0,H.jsx)(r,{className:`size-3.5 shrink-0`}),n]},t))})]},t.label))})})]}),(0,H.jsxs)(`div`,{className:`app-drag-region flex h-14 shrink-0 items-center gap-2 border-b border-[var(--border)] bg-[var(--muted)]/18 px-3 md:hidden`,children:[(0,H.jsx)(hn,{to:o,className:`app-no-drag shrink-0`,"aria-label":`Rynx`,children:(0,H.jsx)(`img`,{src:NS,alt:`rynx`,className:`h-5 w-auto dark:brightness-0 dark:invert`})}),(0,H.jsx)(J,{asChild:!0,variant:`ghost`,size:`sm`,className:`app-no-drag shrink-0 gap-1.5 px-2`,children:(0,H.jsxs)(hn,{to:o,children:[(0,H.jsx)(An,{className:`size-3.5`}),`Back`]})}),(0,H.jsx)(Ig,{"aria-label":`Settings page`,value:e,className:`ml-auto min-w-0 flex-1`,onChange:e=>r(px[e.target.value],{state:s}),children:l.map(({id:e,label:t})=>(0,H.jsx)(`option`,{value:e,children:t},e))})]}),e===`emulator`?(0,H.jsx)(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:n}):(0,H.jsx)(U_,{className:`min-h-0 flex-1`,children:(0,H.jsx)(`section`,{className:`p-4 sm:p-6`,children:n})})]})}var HS=`Label`,US=u.forwardRef((e,t)=>(0,H.jsx)(W.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));US.displayName=HS;var WS=US,GS=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(WS,{ref:n,className:X(`text-xs font-medium text-[var(--muted-foreground)]`,e),...t}));GS.displayName=`Label`;function KS({onInstalled:e,triggerLabel:t=`Install skill`,triggerVariant:n=`default`}){let[r,i]=(0,u.useState)(!1),[a,o]=(0,u.useState)(``),[s,c]=(0,u.useState)(``),[l,d]=(0,u.useState)(``),[f,p]=(0,u.useState)(!1);function m(){o(``),c(``),d(``)}let h=(()=>{let e=a.trim();return!e||!s.trim()?e:`${e}#${s.trim()}`})(),g=!!s.trim()&&a.includes(`#`);async function _(){let t=h;if(t){if(g){V.error(`Source already pins a ref with '#' — clear one of the two.`);return}p(!0);try{let n=await Y.installSkill({tool:`skills-cli`,source:t,...l.trim()?{skill:l.trim()}:{}});V.success(`Installed ${l.trim()||t}`),e(n),m(),i(!1)}catch(e){V.error(`Install failed: ${e.message}`)}finally{p(!1)}}}let v=[`npx skills add`,h||`<source>`,l.trim()&&`--skill ${l.trim()}`].filter(Boolean).join(` `);return(0,H.jsxs)(Su,{open:r,onOpenChange:e=>{i(e),e||m()},children:[(0,H.jsx)(Cu,{asChild:!0,children:(0,H.jsxs)(J,{size:`sm`,variant:n,children:[(0,H.jsx)(Ir,{}),` `,t]})}),(0,H.jsxs)(Du,{children:[(0,H.jsxs)(Ou,{children:[(0,H.jsx)(Au,{children:`Install a skill`}),(0,H.jsxs)(ju,{children:[`From the open skills ecosystem (skills.sh). Runs `,(0,H.jsx)(`code`,{children:`npx skills add`}),` into the global catalog (`,(0,H.jsx)(`code`,{children:`~/.rynx/skills`}),`).`]})]}),(0,H.jsxs)(`div`,{className:`grid gap-3`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsxs)(GS,{children:[`Source `,(0,H.jsx)(`span`,{className:`text-[var(--destructive)]`,children:`*`})]}),(0,H.jsx)(Ag,{value:a,autoFocus:!0,placeholder:`vercel-labs/skills or https://github.com/owner/repo`,onChange:e=>o(e.target.value)}),(0,H.jsxs)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:[`A repo (`,(0,H.jsx)(`code`,{children:`owner/repo`}),`), a git URL, or a namespace.`]})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{children:`Skill`}),(0,H.jsx)(Ag,{value:l,placeholder:`find-skills`,onChange:e=>d(e.target.value)}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Optional — when a repo ships several.`})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{children:`Branch`}),(0,H.jsx)(Ag,{value:s,placeholder:`main`,onChange:e=>c(e.target.value)}),(0,H.jsxs)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:[`Optional — a git ref, sent as `,(0,H.jsx)(`code`,{children:`#<branch>`}),`.`]})]})]}),(0,H.jsx)(`pre`,{className:`overflow-x-auto rounded-md border border-[var(--border)] bg-[var(--muted)]/40 p-2.5 font-mono text-xs text-[var(--muted-foreground)]`,children:v})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(J,{variant:`outline`,onClick:()=>i(!1),children:`Cancel`}),(0,H.jsx)(J,{onClick:_,disabled:f||!a.trim(),children:f?`Installing…`:`Install`})]})]})]})}var qS=[`codex`,`traex`,`claude`],JS=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`,`ultra`],YS=[`read-only`,`workspace-write`,`danger-full-access`],XS=[`never`,`on-failure`,`on-request`,`untrusted`],ZS=[`acceptEdits`,`auto`,`bypassPermissions`,`manual`,`dontAsk`,`plan`];function QS({value:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsx)(aC,{label:`Display name`,help:`Shown in the UI; the id (left) is the directory name.`,children:(0,H.jsx)(Ag,{value:e.name??``,placeholder:`My agent`,onChange:n=>t({...e,name:n.target.value})})}),(0,H.jsx)(aC,{label:`Description`,children:(0,H.jsx)(Ag,{value:e.description??``,placeholder:`What this agent does`,onChange:n=>t({...e,description:n.target.value})})}),(0,H.jsx)(aC,{label:`Instructions`,help:`Inline system prompt, or a path to a .md under the agent dir.`,children:(0,H.jsx)(jg,{value:e.instructions??``,className:`min-h-[14rem]`,placeholder:`You are a helpful agent.`,onChange:n=>t({...e,instructions:n.target.value})})})]})}function $S({value:e,onChange:t}){let n=e.executor??{},r=n.retry??{},[i,a]=(0,u.useState)(null);(0,u.useEffect)(()=>{let e=!1;return Y.listAgentRuntimeOptions().then(t=>!e&&a(t)).catch(t=>{e||(a([]),V.error(`Load runtime options failed: ${t.message}`))}),()=>{e=!0}},[]);let o=r=>t({...e,executor:{...n,...r}}),s=i=>t({...e,executor:{...n,retry:{...r,...i}}}),c=i?.find(e=>e.id===(n.runtime??`codex`)),l=c?.models??[],d=l.find(e=>e.id===n.model)?.reasoningOptions.map(e=>e.value)??JS;return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(aC,{label:`Runtime`,children:[(0,H.jsx)(sC,{value:n.runtime,options:i?.length?i.map(e=>e.id):qS,required:!0,onChange:e=>{if(!e)return;let t=i?.find(t=>t.id===e),n=t?.models.find(e=>e.isDefault)??t?.models[0];o({runtime:e,model:n?.id,reasoningEffort:n?.defaultReasoningEffort})}}),c&&!c.available&&(0,H.jsxs)(`p`,{className:`text-xs text-[var(--warning)]`,children:[c.name,` is not installed on this machine.`]})]}),(0,H.jsx)(aC,{label:`Reasoning effort`,children:(0,H.jsx)(sC,{value:n.reasoningEffort,options:d.length>0?d:JS,onChange:e=>o({reasoningEffort:e})})})]}),(0,H.jsx)(aC,{label:`Model`,help:`Blank inherits the runtime default.`,children:l.length>0?(0,H.jsxs)(my,{value:n.model??``,onValueChange:e=>o({model:e,reasoningEffort:void 0}),children:[(0,H.jsx)(_y,{children:(0,H.jsx)(gy,{placeholder:`runtime default`})}),(0,H.jsxs)(by,{children:[n.model&&!l.some(e=>e.id===n.model)&&(0,H.jsxs)(Sy,{value:n.model,children:[n.model,` · custom`]}),l.map(e=>(0,H.jsxs)(Sy,{value:e.id,children:[e.label,e.isDefault?` · default`:``]},e.id))]})]}):(0,H.jsx)(Ag,{value:n.model??``,placeholder:`runtime default`,onChange:e=>o({model:e.target.value||void 0})})}),(0,H.jsx)(`div`,{className:`label-caps pt-1 text-xs text-[var(--muted-foreground)]`,children:`Execution budget`}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsx)(aC,{label:`Timeout (s)`,help:`End-to-end wall-clock cap.`,children:(0,H.jsx)(cC,{value:n.timeout,onChange:e=>o({timeout:e})})}),(0,H.jsx)(aC,{label:`Max iterations`,help:`claude only (→ --max-turns).`,children:(0,H.jsx)(cC,{value:n.maxIterations,onChange:e=>o({maxIterations:e})})}),(0,H.jsx)(aC,{label:`Context window`,help:`codex/traex token budget.`,children:(0,H.jsx)(cC,{value:n.contextWindow,onChange:e=>o({contextWindow:e})})}),(0,H.jsx)(aC,{label:`Retry: max retries`,children:(0,H.jsx)(cC,{value:r.maxRetries,onChange:e=>s({maxRetries:e})})}),(0,H.jsx)(aC,{label:`Retry: timeout/req (s)`,children:(0,H.jsx)(cC,{value:r.timeoutPerRequestSeconds,onChange:e=>s({timeoutPerRequestSeconds:e})})})]})]})}function eC({value:e,onChange:t}){let n=e.osEnv??{},r=r=>t({...e,osEnv:{...n,...r}}),i=e.executor?.runtime??`codex`;return(0,H.jsx)(`div`,{className:`grid gap-4`,children:(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[i===`claude`?(0,H.jsx)(aC,{label:`Permission mode`,help:`Claude's approval axis (--permission-mode).`,children:(0,H.jsx)(sC,{value:n.permissionMode,options:ZS,onChange:e=>r({permissionMode:e})})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(aC,{label:`Sandbox`,children:(0,H.jsx)(sC,{value:n.sandbox,options:YS,onChange:e=>r({sandbox:e})})}),(0,H.jsx)(aC,{label:`Approval policy`,help:`Codex's approval axis.`,children:(0,H.jsx)(sC,{value:n.approvalPolicy,options:XS,onChange:e=>r({approvalPolicy:e})})})]}),(0,H.jsx)(aC,{label:`Full auto`,children:(0,H.jsxs)(`label`,{className:`flex h-8 items-center gap-2 text-sm`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`size-4`,checked:!!n.fullAuto,onChange:e=>r({fullAuto:e.target.checked||void 0})}),(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:`enable`})]})})]})})}function tC({value:e,onChange:t}){let n=e.tools??{},r=r=>t({...e,tools:{...n,...r}});return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsx)(aC,{label:`Allowed tools`,help:`claude only; codex/traex ignore.`,children:(0,H.jsx)(lC,{items:n.allowed??[],placeholder:`ToolName`,onChange:e=>r({allowed:e})})}),(0,H.jsx)(aC,{label:`Disallowed tools`,children:(0,H.jsx)(lC,{items:n.disallowed??[],placeholder:`ToolName`,onChange:e=>r({disallowed:e})})}),(0,H.jsx)(aC,{label:`MCP servers`,help:`HTTP transport only.`,children:(0,H.jsx)(uC,{rows:n.mcp??[],onChange:e=>r({mcp:e})})})]})}function nC({value:e,onChange:t}){let n=e.skills??[],[r,i]=(0,u.useState)(null);(0,u.useEffect)(()=>{Y.listSkills().then(i).catch(e=>{i([]),V.error(`Load skills failed: ${e.message}`)})},[]);let a=new Set(n.map(e=>e.name)),o=r=>{r.ref&&t({...e,skills:[...n,{...r.ref}]})},s=r=>t({...e,skills:n.filter(e=>e.name!==r)}),c=new Set((r??[]).map(e=>e.name)),l=n.map(e=>e.name).filter(e=>!c.has(e));return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsx)(aC,{label:`Skills`,help:`Empty = no skills (hermetic). Each selection copies the skill's install recipe into the spec, so the agent installs its own skills wherever it runs.`,children:r===null?(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Loading…`}):r.length===0&&l.length===0?(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`No skills installed yet — install one below.`}):(0,H.jsxs)(`div`,{className:`grid gap-0.5 rounded-md border border-[var(--border)] p-1.5`,children:[r.map(e=>(0,H.jsxs)(`label`,{className:`flex items-start gap-2 rounded-sm p-1.5 `+(e.ref?`cursor-pointer hover:bg-[var(--muted)]/50`:`opacity-60`),children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0`,disabled:!e.ref,checked:a.has(e.name),onChange:t=>t.target.checked?o(e):s(e.name)}),(0,H.jsxs)(`span`,{className:`grid`,children:[(0,H.jsxs)(`span`,{className:`font-mono text-sm`,children:[e.name,!e.ref&&(0,H.jsx)(`span`,{className:`ml-1 text-xs text-[var(--warning)]`,children:`(no install recipe — reinstall to make selectable)`})]}),(0,H.jsx)(`span`,{className:`line-clamp-2 text-xs text-[var(--muted-foreground)]`,children:e.description})]})]},e.name)),l.map(e=>(0,H.jsxs)(`label`,{className:`flex items-center gap-2 rounded-sm p-1.5`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`size-4 shrink-0`,checked:!0,onChange:()=>s(e)}),(0,H.jsxs)(`span`,{className:`font-mono text-sm`,children:[e,` `,(0,H.jsx)(`span`,{className:`text-xs text-[var(--muted-foreground)]`,children:`(declared in the spec; installs at run time)`})]})]},e))]})}),(0,H.jsx)(`div`,{children:(0,H.jsx)(KS,{onInstalled:i,triggerVariant:`outline`})})]})}function rC(e){let{skills:t,...n}=e,r=iC(n)??{};return Array.isArray(t)&&t.length>0&&(r.skills=t),r}function iC(e){if(Array.isArray(e)){let t=e.map(iC).filter(e=>e!==void 0);return t.length>0?t:void 0}if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e)){let e=iC(r);e!==void 0&&(t[n]=e)}return Object.keys(t).length>0?t:void 0}if(typeof e==`string`){let t=e.trim();return t===``?void 0:t}return e}function aC({label:e,help:t,children:n}){return(0,H.jsxs)(`div`,{className:`grid content-start gap-1.5`,children:[(0,H.jsx)(GS,{children:e}),n,t&&(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:t})]})}var oC=`__default__`;function sC({value:e,options:t,onChange:n,disabled:r,required:i}){return(0,H.jsxs)(my,{value:e??(i?t[0]:oC),disabled:r,onValueChange:e=>n(e===oC?void 0:e),children:[(0,H.jsx)(_y,{children:(0,H.jsx)(gy,{})}),(0,H.jsxs)(by,{children:[!i&&(0,H.jsx)(Sy,{value:oC,children:(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:`Unset`})}),t.map(e=>(0,H.jsx)(Sy,{value:e,children:e},e))]})]})}function cC({value:e,onChange:t}){return(0,H.jsx)(Ag,{type:`number`,value:e??``,onChange:e=>{let n=e.target.value;t(n===``?void 0:Number(n))}})}function lC({items:e,placeholder:t,onChange:n}){let r=(t,r)=>n(e.map((e,n)=>n===t?r:e)),i=t=>n(e.filter((e,n)=>n!==t));return(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[e.map((e,n)=>(0,H.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,H.jsx)(Ag,{value:e,placeholder:t,onChange:e=>r(n,e.target.value)}),(0,H.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>i(n),children:(0,H.jsx)(di,{})})]},n)),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,className:`justify-self-start`,onClick:()=>n([...e,``]),children:[(0,H.jsx)(Ir,{}),` Add`]})]})}function uC({rows:e,onChange:t}){let n=(0,u.useRef)(0),[r,i]=(0,u.useState)(()=>e.map(()=>n.current++)),a=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),o=n=>{t(e.filter((e,t)=>t!==n)),i(r.filter((e,t)=>t!==n))};return(0,H.jsxs)(`div`,{className:`grid gap-2`,children:[e.map((e,t)=>(0,H.jsxs)(`div`,{className:`grid gap-2 rounded-md border border-[var(--border)] p-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(Ag,{className:`w-1/3`,value:e.name??``,placeholder:`name`,onChange:e=>a(t,{name:e.target.value})}),(0,H.jsx)(`span`,{className:`label-caps rounded bg-[var(--muted)] px-1.5 py-1 text-[10px] text-[var(--muted-foreground)]`,children:`HTTP`}),(0,H.jsx)(Ag,{value:e.url??``,placeholder:`https://server/mcp`,onChange:e=>a(t,{url:e.target.value})}),(0,H.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>o(t),children:(0,H.jsx)(di,{})})]}),(0,H.jsx)(dC,{headers:e.headers??{},onChange:e=>a(t,{headers:e})})]},r[t]??t)),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,className:`justify-self-start`,onClick:()=>{t([...e,{name:``,url:``}]),i([...r,n.current++])},children:[(0,H.jsx)(Ir,{}),` Add MCP server`]})]})}function dC({headers:e,onChange:t}){let[n,r]=(0,u.useState)(()=>Object.entries(e).map(([e,t])=>({k:e,v:t})));function i(e){r(e);let n={};for(let{k:t,v:r}of e){let e=t.trim();e&&(n[e]=r)}t(Object.keys(n).length>0?n:void 0)}let a=(e,t)=>i(n.map((n,r)=>r===e?{...n,...t}:n)),o=e=>i(n.filter((t,n)=>n!==e));return(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[n.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,H.jsx)(Ag,{className:`w-1/3 font-mono text-xs`,value:e.k,placeholder:`Header`,onChange:e=>a(t,{k:e.target.value})}),(0,H.jsx)(Ag,{className:`font-mono text-xs`,value:e.v,placeholder:`value`,onChange:e=>a(t,{v:e.target.value})}),(0,H.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>o(t),children:(0,H.jsx)(di,{})})]},t)),(0,H.jsxs)(J,{variant:`ghost`,size:`sm`,className:`justify-self-start text-[var(--muted-foreground)]`,onClick:()=>i([...n,{k:``,v:``}]),children:[(0,H.jsx)(Ir,{}),` Add header`]})]})}function fC({className:e,...t}){return(0,H.jsx)(`div`,{className:X(`glass rounded-xl border border-[var(--border)] text-[var(--card-foreground)]`,e),...t})}function pC({className:e,...t}){return(0,H.jsx)(`div`,{className:X(`flex items-center justify-between gap-3 px-5 py-4 border-b border-[var(--border)]`,e),...t})}function mC({className:e,...t}){return(0,H.jsx)(`h3`,{className:X(`text-sm font-semibold tracking-tight`,e),...t})}function hC({className:e,...t}){return(0,H.jsx)(`div`,{className:X(`p-5`,e),...t})}var gC=/^[a-z0-9][a-z0-9-]{0,63}$/,_C=[{id:`identity`,label:`Identity`,blurb:`Name, description, and system instructions.`},{id:`model`,label:`Model & Budget`,blurb:`Runtime, model, reasoning effort, and execution limits.`},{id:`environment`,label:`Environment`,blurb:`Sandbox and per-runtime approval behavior.`},{id:`tools`,label:`Tools & MCP`,blurb:`Allowed/disallowed tools and MCP servers.`},{id:`skills`,label:`Skills`,blurb:`Which skills this agent can use.`},{id:`review`,label:`Review`,blurb:`Confirm and save.`}];function vC({initial:e,onClose:t,onSaved:n}){let r=e.id===``,[i,a]=(0,u.useState)(e.id),[o,s]=(0,u.useState)(e.spec),[c,l]=(0,u.useState)(`identity`),[d,f]=(0,u.useState)(`form`),[p,m]=(0,u.useState)(()=>JSON.stringify(e.spec,null,2)),[h,g]=(0,u.useState)(!1);function _(e){if(e!==d){if(e===`json`)m(JSON.stringify(o,null,2)),f(`json`);else try{s(JSON.parse(p)),f(`form`)}catch(e){V.error(`Invalid JSON: ${e.message}`)}}}async function v(){let t=i.trim();if(r&&!gC.test(t))return l(`identity`),V.error(t?`Invalid agent id — use lowercase letters, digits, or hyphens`:`Agent id is required`);let a;if(d===`json`)try{a=JSON.parse(p)}catch(e){return V.error(`Invalid JSON: ${e.message}`)}else a=o;g(!0);try{r?await Y.createAgent({...rC(a),id:i.trim()}):await Y.updateAgent(e.id,rC(a)),V.success(`Agent "${i}" saved`),await n()}catch(e){V.error(`Save failed: ${e.message}`)}finally{g(!1)}}return(0,H.jsxs)(`div`,{className:`grid gap-5`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex w-fit items-center gap-1 text-xs text-[var(--muted-foreground)] hover:text-[var(--foreground)]`,children:[(0,H.jsx)(An,{className:`size-3.5`}),` Agents`]}),(0,H.jsx)(`h1`,{className:`text-xl font-semibold`,children:r?`New agent`:`Edit "${e.id}"`})]}),(0,H.jsx)(`div`,{className:`inline-flex rounded-md border border-[var(--border)] p-0.5`,children:[`form`,`json`].map(e=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>_(e),className:X(`rounded-sm px-3 py-1 text-sm capitalize transition-colors`,d===e?`bg-[var(--primary)] text-[var(--primary-foreground)]`:`text-[var(--muted-foreground)] hover:text-[var(--foreground)]`),children:e},e))})]}),d===`json`?(0,H.jsx)(jg,{value:p,onChange:e=>m(e.target.value),className:`min-h-[28rem] font-mono text-xs`}):(0,H.jsxs)(`div`,{className:`grid grid-cols-[12rem_1fr] gap-6`,children:[(0,H.jsx)(`nav`,{className:`sticky top-6 grid h-fit gap-0.5`,children:_C.map(e=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>l(e.id),className:X(`rounded-md px-3 py-2 text-left text-sm transition-colors`,c===e.id?`bg-[var(--muted)] font-medium text-[var(--foreground)]`:`text-[var(--muted-foreground)] hover:bg-[var(--muted)]/50`),children:e.label},e.id))}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`mb-4`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold`,children:yC(c).label}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:yC(c).blurb})]}),(0,H.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] p-5`,children:[c===`identity`&&(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsxs)(GS,{children:[`Agent ID `,(0,H.jsx)(`span`,{className:`text-[var(--destructive)]`,children:`*`})]}),(0,H.jsx)(Ag,{value:i,disabled:!r,onChange:e=>a(e.target.value),placeholder:`polly`,"aria-invalid":r&&i.trim()!==``&&!gC.test(i.trim())}),r&&i.trim()!==``&&!gC.test(i.trim())?(0,H.jsx)(`p`,{className:`text-xs text-[var(--destructive)]`,children:`Use 1–64 lowercase letters, digits, or hyphens, starting with a letter or digit.`}):(0,H.jsxs)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:[`The config directory name. References (`,(0,H.jsx)(`code`,{children:`/agent <id>`}),`, bindings) use it; it can't change after creation.`]})]}),(0,H.jsx)(QS,{value:o,onChange:s})]}),c===`model`&&(0,H.jsx)($S,{value:o,onChange:s}),c===`environment`&&(0,H.jsx)(eC,{value:o,onChange:s}),c===`tools`&&(0,H.jsx)(tC,{value:o,onChange:s}),c===`skills`&&(0,H.jsx)(nC,{value:o,onChange:s}),c===`review`&&(0,H.jsx)(bC,{id:i,spec:o})]})]})]}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-[var(--border)] pt-4`,children:[(0,H.jsx)(J,{variant:`outline`,onClick:t,children:`Cancel`}),(0,H.jsx)(J,{onClick:v,disabled:h,children:h?`Saving…`:`Save`})]})]})}function yC(e){return _C.find(t=>t.id===e)??_C[0]}function bC({id:e,spec:t}){let n=rC(t),r=[[`Agent ID`,e||`—`],[`Display name`,t.name?.trim()||`—`],[`Runtime`,t.executor?.runtime??`default`],[`Model`,t.executor?.model?.trim()||`runtime default`],[`Skills`,xC(t.skills)],[`MCP servers`,String(t.tools?.mcp?.filter(e=>e.url?.trim()).length??0)]];return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsx)(`dl`,{className:`grid grid-cols-[10rem_1fr] gap-x-4 gap-y-2 text-sm`,children:r.map(([e,t])=>(0,H.jsxs)(`div`,{className:`contents`,children:[(0,H.jsx)(`dt`,{className:`text-[var(--muted-foreground)]`,children:e}),(0,H.jsx)(`dd`,{className:`font-medium`,children:t})]},e))}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{children:`Resulting spec`}),(0,H.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded-md border border-[var(--border)] bg-[var(--muted)]/40 p-3 font-mono text-xs`,children:JSON.stringify({id:e||void 0,...n},null,2)})]})]})}function xC(e){return e?.length?`${e.length} declared`:`None`}var SC=/^[a-z0-9][a-z0-9-]{0,63}$/;function CC({agents:e,onChange:t}){let[n,r]=(0,u.useState)(e[0]?.id??``),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(null),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)([]),[h,g]=(0,u.useState)([]),[_,v]=(0,u.useState)(!1);(0,u.useEffect)(()=>{n&&e.some(e=>e.id===n)||r(e[0]?.id??``)},[e,n]),(0,u.useEffect)(()=>{if(!n){a(null);return}let e=!1;return s(!0),Y.getAgent(n).then(t=>{e||a(t)}).catch(t=>!e&&V.error(`Load agent failed: ${t.message}`)).finally(()=>!e&&s(!1)),()=>{e=!0}},[n]);async function y(e=!1){v(!0);try{let[t,n]=await Promise.all([Y.listAgentRuntimeOptions(e),Y.listSkills()]);m(t),g(n)}catch(e){V.error(`Load local options failed: ${e.message}`)}finally{v(!1)}}async function b(e){try{let t=await Y.getAgent(e);delete t.id,l({id:e,spec:t})}catch(e){V.error(`Load failed: ${e.message}`)}}if(c)return(0,H.jsx)(vC,{initial:c,onClose:()=>l(null),onSaved:async()=>{let e=c.id;l(null),await t(),r(e),a(await Y.getAgent(e))}});let x=new Set(e.map(e=>e.runtime).filter(Boolean)),S=e.reduce((e,t)=>e+(t.skillCount??0),0);return(0,H.jsxs)(`div`,{className:`grid gap-5`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Agents`}),(0,H.jsxs)(`p`,{className:`mt-1 text-sm text-[var(--muted-foreground)]`,children:[`Local Agent profiles discovered from `,(0,H.jsx)(`code`,{children:`~/.rynx/agents`}),`.`]})]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(J,{variant:`outline`,onClick:()=>void t(),children:[(0,H.jsx)(zr,{}),` Refresh`]}),(0,H.jsxs)(J,{onClick:()=>{f(!0),y()},children:[(0,H.jsx)(Ir,{}),` New agent`]})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,H.jsx)(DC,{label:`agents`,value:e.length,detail:`Local registered profiles`}),(0,H.jsx)(DC,{label:`runtimes`,value:x.size,detail:`Runtimes currently used`}),(0,H.jsx)(DC,{label:`skill bindings`,value:S,detail:`Explicit Skill references`})]}),(0,H.jsxs)(`div`,{className:`grid min-h-[620px] gap-4 lg:grid-cols-[320px_minmax(0,1fr)]`,children:[(0,H.jsxs)(fC,{className:`overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--border)] px-4 py-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Agent list`}),(0,H.jsx)(`span`,{className:`text-xs text-[var(--muted-foreground)]`,children:e.length})]}),(0,H.jsxs)(`div`,{className:`grid gap-2 p-2`,children:[e.length===0&&(0,H.jsx)(`div`,{className:`rounded-lg border border-dashed border-[var(--border)] px-4 py-6 text-sm text-[var(--muted-foreground)]`,children:`No local Agents registered yet.`}),e.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:X(`flex w-full items-start gap-3 rounded-lg border px-3 py-3 text-left transition-colors`,n===e.id?`border-[var(--primary)] bg-[var(--primary)]/10`:`border-[var(--border)] hover:bg-[var(--muted)]/45`),children:[(0,H.jsx)(`span`,{className:`mt-0.5 grid size-9 shrink-0 place-items-center rounded-md bg-violet-500/10 text-violet-600`,children:(0,H.jsx)(Mn,{className:`size-4`})}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:e.name??e.id}),n===e.id&&(0,H.jsx)(Ln,{className:`size-4 shrink-0 text-[var(--primary)]`})]}),e.description&&(0,H.jsx)(`span`,{className:`mt-1 block line-clamp-2 text-xs text-[var(--muted-foreground)]`,children:e.description}),(0,H.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-1.5 text-[10px] text-[var(--muted-foreground)]`,children:[(0,H.jsx)(`span`,{className:`rounded bg-[var(--muted)] px-1.5 py-1`,children:e.runtime??`default runtime`}),(0,H.jsxs)(`span`,{className:`rounded bg-[var(--muted)] px-1.5 py-1`,children:[e.skillCount??0,` skills`]})]})]})]},e.id))]})]}),(0,H.jsx)(wC,{id:n,detail:i,loading:o,onEdit:()=>void b(n),onDeleted:t})]}),(0,H.jsx)(TC,{open:d,onOpenChange:f,runtimes:p,skills:h,loading:_,onRefresh:()=>y(!0),onCreated:async e=>{f(!1),await t(),r(e)}})]})}function wC({id:e,detail:t,loading:n,onEdit:r,onDeleted:i}){if(!e)return(0,H.jsx)(fC,{className:`p-6 text-sm text-[var(--muted-foreground)]`,children:`Select an Agent to inspect its configuration.`});if(n||!t)return(0,H.jsx)(fC,{className:`p-6 text-sm text-[var(--muted-foreground)]`,children:`Loading Agent configuration…`});let a=t.skills??[];return(0,H.jsxs)(fC,{className:`overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-[var(--border)] px-5 py-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`text-lg font-semibold`,children:t.name??e}),(0,H.jsx)(`code`,{className:`text-[10px] text-[var(--muted-foreground)]`,children:e})]}),t.description&&(0,H.jsx)(`p`,{className:`mt-1 text-sm text-[var(--muted-foreground)]`,children:t.description})]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(J,{variant:`outline`,size:`sm`,onClick:r,children:[(0,H.jsx)(Pr,{}),` Edit configuration`]}),(0,H.jsx)(EC,{id:e,onChange:i})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-6 p-5`,children:[(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,H.jsx)(OC,{label:`Runtime`,value:t.executor?.runtime??`default`}),(0,H.jsx)(OC,{label:`Model`,value:t.executor?.model??`runtime default`}),(0,H.jsx)(OC,{label:`Reasoning`,value:t.executor?.reasoningEffort??`runtime default`})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:`instructions`}),(0,H.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap rounded-lg border border-[var(--border)] bg-[var(--muted)]/25 p-4 text-sm leading-6`,children:t.instructions||`No inline instructions.`})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:`skills`}),(0,H.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:a.length===0?(0,H.jsx)(`span`,{className:`text-sm text-[var(--muted-foreground)]`,children:`No Skills bound.`}):a.map(e=>(0,H.jsx)(`span`,{className:`rounded-md bg-[var(--muted)] px-2 py-1 font-mono text-xs`,children:e.name},e.name))})]})]})]})}function TC({open:e,onOpenChange:t,runtimes:n,skills:r,loading:i,onRefresh:a,onCreated:o}){let[s,c]=(0,u.useState)(``),[l,d]=(0,u.useState)(``),[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(``),[g,_]=(0,u.useState)(`You are a helpful agent.`),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(new Set),[E,D]=(0,u.useState)(!1),O=n.filter(e=>e.available),k=n.find(e=>e.id===v),A=k?.models.find(e=>e.id===b);(0,u.useEffect)(()=>{if(!e||v)return;let t=O[0];if(!t)return;let n=t.models.find(e=>e.isDefault)??t.models[0];y(t.id),x(n?.id??``),C(n?.defaultReasoningEffort??``)},[O,e,v,n]);function j(){c(``),d(``),p(!1),h(``),_(`You are a helpful agent.`),y(``),x(``),C(``),T(new Set)}function M(e){let t=n.find(t=>t.id===e),r=t?.models.find(e=>e.isDefault)??t?.models[0];y(e),x(r?.id??``),C(r?.defaultReasoningEffort??``)}async function N(){let e=l.trim();if(!SC.test(e)||!s.trim()||!g.trim()||!v)return;let t=r.filter(e=>w.has(e.name)&&e.ref).map(e=>({...e.ref}));D(!0);try{await Y.createAgent({id:e,name:s.trim(),...m.trim()?{description:m.trim()}:{},instructions:g.trim(),executor:{runtime:v,...b?{model:b}:{},...S?{reasoningEffort:S}:{},timeout:1800,retry:{maxRetries:2}},osEnv:{sandbox:`danger-full-access`,approvalPolicy:`never`},...t.length?{skills:t}:{}}),V.success(`Agent "${s.trim()}" created`),j(),await o(e)}catch(e){V.error(`Create Agent failed: ${e.message}`)}finally{D(!1)}}let P=!!(SC.test(l.trim())&&s.trim()&&g.trim()&&v);return(0,H.jsx)(Su,{open:e,onOpenChange:e=>{t(e),e||j()},children:(0,H.jsxs)(Du,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,H.jsx)(Ou,{children:(0,H.jsx)(Au,{children:`Create local Agent`})}),(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(kC,{label:`Name`,children:(0,H.jsx)(Ag,{value:s,autoFocus:!0,onChange:e=>{let t=e.target.value;c(t),f||d(AC(t))}})}),(0,H.jsx)(kC,{label:`Agent ID`,children:(0,H.jsx)(Ag,{value:l,onChange:e=>{p(!0),d(e.target.value)},"aria-invalid":!!l&&!SC.test(l)})})]}),(0,H.jsx)(kC,{label:`Description`,children:(0,H.jsx)(Ag,{value:m,onChange:e=>h(e.target.value)})}),(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,H.jsx)(kC,{label:`Runtime`,children:(0,H.jsxs)(my,{value:v,onValueChange:M,disabled:i||n.length===0,children:[(0,H.jsx)(_y,{children:(0,H.jsx)(gy,{placeholder:`No runtime found`})}),(0,H.jsx)(by,{children:n.map(e=>(0,H.jsxs)(Sy,{value:e.id,disabled:!e.available,children:[e.name,e.available?``:` · missing`]},e.id))})]})}),(0,H.jsx)(kC,{label:`Model`,children:(0,H.jsxs)(my,{value:b,onValueChange:e=>{x(e),C(k?.models.find(t=>t.id===e)?.defaultReasoningEffort??``)},disabled:!k||k.models.length===0,children:[(0,H.jsx)(_y,{children:(0,H.jsx)(gy,{placeholder:`Runtime default`})}),(0,H.jsx)(by,{children:k?.models.map(e=>(0,H.jsxs)(Sy,{value:e.id,children:[e.label,e.isDefault?` · default`:``]},e.id))})]})}),(0,H.jsx)(kC,{label:`Reasoning`,children:(0,H.jsxs)(my,{value:S||`__default__`,onValueChange:e=>C(e===`__default__`?``:e),children:[(0,H.jsx)(_y,{children:(0,H.jsx)(gy,{})}),(0,H.jsxs)(by,{children:[(0,H.jsx)(Sy,{value:`__default__`,children:`Runtime default`}),A?.reasoningOptions.map(e=>(0,H.jsx)(Sy,{value:e.value,children:e.label},e.value))]})]})})]}),O.length===0&&!i&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-dashed border-[var(--border)] px-3 py-2 text-xs text-[var(--muted-foreground)]`,children:[`No local coding runtime was discovered.`,(0,H.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>void a(),children:[(0,H.jsx)(zr,{}),` Scan`]})]}),(0,H.jsx)(kC,{label:`Instructions`,children:(0,H.jsx)(jg,{className:`min-h-32`,value:g,onChange:e=>_(e.target.value)})}),(0,H.jsxs)(`fieldset`,{className:`rounded-lg border border-[var(--border)] p-3`,children:[(0,H.jsx)(`legend`,{className:`label-caps px-1 text-[10px] text-[var(--muted-foreground)]`,children:`skills · optional`}),(0,H.jsxs)(`div`,{className:`grid max-h-40 gap-1 overflow-y-auto`,children:[r.filter(e=>e.ref).length===0&&(0,H.jsx)(`div`,{className:`py-2 text-xs text-[var(--muted-foreground)]`,children:`No selectable local Skills.`}),r.filter(e=>e.ref).map(e=>(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md px-2 py-2 hover:bg-[var(--muted)]/50`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4`,checked:w.has(e.name),onChange:()=>T(t=>{let n=new Set(t);return n.has(e.name)?n.delete(e.name):n.add(e.name),n})}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`span`,{className:`block font-mono text-sm`,children:e.name}),(0,H.jsx)(`span`,{className:`line-clamp-1 text-xs text-[var(--muted-foreground)]`,children:e.description})]})]},e.name))]})]})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,H.jsx)(J,{disabled:!P||E,onClick:()=>void N(),children:E?`Creating…`:`Create`})]})]})})}function EC({id:e,onChange:t}){return(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsx)(J,{variant:`ghost`,size:`sm`,className:`text-[var(--destructive)]`,children:(0,H.jsx)(si,{})})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[`Delete Agent "`,e,`"?`]}),(0,H.jsx)(yu,{children:`Removes its local config directory. Existing Session snapshots are unaffected.`})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:async()=>{try{await Y.deleteAgent(e),V.success(`Agent "${e}" deleted`),await t()}catch(e){V.error(`Delete failed: ${e.message}`)}},children:`Delete`})]})]})]})}function DC({label:e,value:t,detail:n}){return(0,H.jsxs)(fC,{className:`p-4`,children:[(0,H.jsx)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:e}),(0,H.jsx)(`div`,{className:`mt-2 text-2xl font-semibold`,children:t}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:n})]})}function OC({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] bg-[var(--muted)]/20 px-3 py-2`,children:[(0,H.jsx)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:e}),(0,H.jsx)(`div`,{className:`mt-1 truncate text-sm`,children:t})]})}function kC({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{children:e}),t]})}function AC(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,64)}var jC=cu(`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium`,{variants:{variant:{default:`border-transparent bg-[var(--secondary)] text-[var(--secondary-foreground)]`,success:`border-transparent bg-[var(--success)]/15 text-[var(--success)]`,warning:`border-transparent bg-[var(--warning)]/15 text-[var(--warning)]`,destructive:`border-transparent bg-[var(--destructive)]/15 text-[var(--destructive)]`,outline:`text-[var(--muted-foreground)]`}},defaultVariants:{variant:`default`}});function MC({className:e,variant:t,...n}){return(0,H.jsx)(`span`,{className:X(jC({variant:t}),e),...n})}async function NC(e,t){if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),`clipboard`}catch{}if(!t||typeof document>`u`)return`unavailable`;t.focus({preventScroll:!0}),t.select(),t.setSelectionRange(0,e.length);try{if(typeof document.execCommand==`function`&&document.execCommand(`copy`))return`selection`}catch{}return`selected`}var PC=`127.0.0.1:9333`;function FC({embedded:e=!1}={}){let t=wS(),n=(0,u.useRef)(null),[r,i]=(0,u.useState)(null),[a,o]=(0,u.useState)(null),[s,c]=(0,u.useState)(`load`),l=(0,u.useCallback)(async()=>{if(!t){c(null),o(`Chrome inspection is available only in the Rynx app.`);return}c(`load`),o(null);try{i(await t.getChromeInspectionStatus())}catch(e){o(e.message)}finally{c(null)}},[t]);(0,u.useEffect)(()=>{l()},[l]);async function d(e){if(t){c(`save`),o(null);try{i(await t.configureChromeInspection(e))}catch(e){let t=e.message;o(t),V.error(`Could not update Chrome inspection: ${t}`)}finally{c(null)}}}async function f(){let e=await NC(PC,n.current);e===`clipboard`||e===`selection`?V.success(`Address copied`):e===`selected`?V.info(`Address selected — copy it manually`):V.error(`Copy is unavailable`)}let p=r?.settings,m=s!==null;return(0,H.jsxs)(`div`,{id:e?`chrome-inspection`:void 0,className:e?`grid scroll-mt-6 gap-5`:`grid max-w-3xl gap-5`,children:[!e&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Chrome inspection`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Inspect Rynx-managed browser pages with Chrome DevTools.`})]}),(0,H.jsxs)(fC,{"aria-busy":s!==null,children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(mC,{children:`DevTools discovery`}),r&&(0,H.jsx)(IC,{status:r})]}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Chrome connects to one local address and discovers the browsers you choose.`})]}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:m,onClick:()=>void l(),children:[(0,H.jsx)(zr,{className:s===`load`?`animate-spin`:``}),`Check`]})]}),(0,H.jsxs)(hC,{className:`grid gap-5`,children:[r&&p?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(LC,{title:`Enable Chrome inspection`,description:`Make the selected browser pages available to Chrome DevTools.`,children:(0,H.jsx)(Ub,{"aria-label":`Enable Chrome inspection`,checked:p.enabled,disabled:m,onCheckedChange:e=>void d({...p,enabled:e})})}),(0,H.jsx)(`div`,{className:`h-px bg-[var(--border)]`}),(0,H.jsxs)(`div`,{className:`grid gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:`Browsers to include`}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--muted-foreground)]`,children:`Only selected browser pages appear in Chrome.`})]}),(0,H.jsx)(RC,{title:`This device`,detail:`Browser pages managed by Rynx on this device`,checked:p.includeLocal,disabled:m||!p.enabled,onChange:e=>void d({...p,includeLocal:e})}),r.remotes.map(e=>(0,H.jsx)(RC,{title:e.displayName,detail:BC(e.status),badge:e.status,checked:p.remoteDaemonIds.includes(e.daemonId),disabled:m||!p.enabled||e.status===`incompatible`,onChange:t=>void d({...p,remoteDaemonIds:t?[...p.remoteDaemonIds,e.daemonId]:p.remoteDaemonIds.filter(t=>t!==e.daemonId)})},e.daemonId))]}),(0,H.jsx)(`div`,{className:`h-px bg-[var(--border)]`}),(0,H.jsxs)(`div`,{className:`grid gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:`Connect Chrome once`}),(0,H.jsxs)(`p`,{className:`mt-0.5 text-xs leading-5 text-[var(--muted-foreground)]`,children:[`Open `,(0,H.jsx)(`span`,{className:`font-mono`,children:`chrome://inspect`}),`, choose`,` `,(0,H.jsx)(`strong`,{children:`Configure…`}),`, then add this address.`]})]}),(0,H.jsxs)(`div`,{className:`flex max-w-sm gap-2`,children:[(0,H.jsx)(Ag,{ref:n,value:PC,readOnly:!0,"aria-label":`Chrome inspection address`,className:`font-mono`}),(0,H.jsxs)(J,{variant:`outline`,onClick:()=>void f(),"aria-label":`Copy Chrome inspection address`,children:[(0,H.jsx)(Jn,{}),`Copy`]})]})]}),r.runtime.state===`error`&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--warning)_35%,var(--border))] bg-[color-mix(in_srgb,var(--warning)_8%,var(--background))] p-3 text-xs text-[var(--warning)]`,children:[(0,H.jsx)(ci,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`font-medium`,children:`Chrome inspection could not start`}),(0,H.jsx)(`div`,{className:`mt-0.5 text-[var(--foreground)]`,children:r.runtime.error})]})]}),(0,H.jsxs)(`div`,{role:`note`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_30%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_6%,var(--background))] p-3 text-xs leading-5`,children:[(0,H.jsx)(ci,{className:`mt-0.5 size-4 shrink-0 text-[var(--destructive)]`}),(0,H.jsx)(`span`,{children:`Any process on this device can use this address to fully control every browser exposed here. Enable it only while you need DevTools.`})]})]}):(0,H.jsxs)(`div`,{className:`flex min-h-40 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[s===`load`&&(0,H.jsx)(B,{className:`size-4 animate-spin`}),s===`load`?`Loading Chrome inspection…`:`Chrome inspection settings are unavailable.`]}),a&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_35%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_7%,var(--background))] p-3 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(ci,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{children:a})]})]})]})]})}function IC({status:e}){return e.runtime.state===`listening`?(0,H.jsxs)(MC,{variant:`success`,children:[(0,H.jsx)(Pn,{className:`size-3`}),`Listening`]}):e.runtime.state===`error`?(0,H.jsx)(MC,{variant:`warning`,children:`Needs attention`}):(0,H.jsx)(MC,{variant:`outline`,children:`Off`})}function LC({title:e,description:t,children:n}){return(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:e}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--muted-foreground)]`,children:t})]}),n]})}function RC({title:e,detail:t,badge:n,checked:r,disabled:i,onChange:a}){return(0,H.jsxs)(`label`,{className:X(`flex items-center gap-3 rounded-lg border border-[var(--border)] px-3 py-2.5`,i&&`opacity-55`),children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:r,disabled:i,onChange:e=>a(e.target.checked),className:`size-4 accent-[var(--primary)]`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium`,children:[e,n&&(0,H.jsx)(MC,{variant:n===`ready`?`success`:n===`offline`?`warning`:`outline`,children:zC(n)})]}),(0,H.jsx)(`span`,{className:`block text-xs text-[var(--muted-foreground)]`,children:t})]})]})}function zC(e){return e===`ready`?`Ready`:e===`offline`?`Offline`:`Incompatible`}function BC(e){return e===`ready`?`Available now`:e===`offline`?`Currently unavailable`:`Update this Runtime before selecting it`}function VC({embedded:e=!1}={}){let t=wS(),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(`refresh`),c=(0,u.useCallback)(async()=>{if(t){s(`refresh`),a(null);try{r(await t.getStatus())}catch(e){a(e.message)}finally{s(null)}}},[t]);(0,u.useEffect)(()=>{c()},[c]);async function l(e){if(t){s(`permission`),a(null);try{await t.openSystemSettings(e),V.message(`After granting access, return to Rynx and click Check again.`)}catch(e){let t=e.message;a(t),V.error(`Could not open System Settings: ${t}`)}finally{s(null)}}}return(0,H.jsxs)(`div`,{id:e?`permissions`:void 0,className:e?`grid scroll-mt-6 gap-5`:`grid max-w-3xl gap-5`,children:[!e&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Computer integration`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Review the macOS permissions for the separate Computer Use integration. Browser and Emulator automation stay in the bundled rynx-cli Skill.`})]}),(0,H.jsxs)(fC,{"aria-busy":o!==null,children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`macOS permissions`}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`This page checks readiness only. Permissions remain under your control in System Settings.`})]}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o!==null,onClick:()=>void c(),children:[(0,H.jsx)(zr,{className:o===`refresh`?`animate-spin`:``}),`Check`]})]}),(0,H.jsxs)(hC,{className:`grid gap-3`,children:[n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(HC,{icon:(0,H.jsx)(Vr,{className:`size-4`}),ready:n.permissions.accessibility===`granted`,title:`Accessibility`,description:UC(n.permissions.accessibility,`Granted and ready for a Computer Use provider.`),action:n.permissions.accessibility===`granted`?void 0:(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o!==null,onClick:()=>void l(`accessibility`),children:[(0,H.jsx)(er,{}),`Open Settings`]})}),(0,H.jsx)(HC,{icon:(0,H.jsx)(Sr,{className:`size-4`}),ready:n.permissions.screenRecording===`granted`,title:`Screen Recording`,description:UC(n.permissions.screenRecording,`Granted and ready for a Computer Use provider.`),action:n.permissions.screenRecording===`granted`?void 0:(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o!==null,onClick:()=>void l(`screen-recording`),children:[(0,H.jsx)(er,{}),`Open Settings`]})})]}):(0,H.jsxs)(`div`,{className:`flex min-h-40 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[o===`refresh`&&(0,H.jsx)(B,{className:`size-4 animate-spin`}),o===`refresh`?`Checking integrations…`:`Integration status is unavailable.`]}),i&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_35%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_7%,var(--background))] p-3 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(zn,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]})]})]})]})}function HC({icon:e,ready:t,title:n,description:r,action:i}){return(0,H.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-[var(--border)] p-4 sm:grid-cols-[auto_minmax(0,1fr)_auto] sm:items-center`,children:[(0,H.jsx)(`span`,{className:t?`grid size-9 place-items-center rounded-lg bg-[var(--success)]/12 text-[var(--success)]`:`grid size-9 place-items-center rounded-lg bg-[var(--warning)]/12 text-[var(--warning)]`,children:t?(0,H.jsx)(Pn,{className:`size-4`}):e}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium`,children:n}),(0,H.jsx)(MC,{variant:t?`success`:`warning`,children:t?`Ready`:`Needs access`})]}),(0,H.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-[var(--muted-foreground)]`,children:r})]}),i&&(0,H.jsx)(`div`,{className:`sm:justify-self-end`,children:i})]})}function UC(e,t){switch(e){case`granted`:return t;case`not-granted`:return`Not granted. Open System Settings to allow access.`;case`unknown`:return`Rynx could not determine this permission. Open System Settings to verify it.`}}function WC(){return(0,H.jsxs)(`div`,{className:`grid max-w-3xl gap-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Computer Use`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Configure macOS permissions and Chrome DevTools access for computer automation.`})]}),(0,H.jsx)(VC,{embedded:!0}),(0,H.jsx)(FC,{embedded:!0})]})}var GC=700,KC=250,qC=33333,JC=new Uint8Array([0,0,0,1]);function YC(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function XC(e,t){for(let n=t;n<=e.length-3;n+=1)if(e[n]===0&&e[n+1]===0){if(e[n+2]===1)return{index:n,length:3};if(n<=e.length-4&&e[n+2]===0&&e[n+3]===1)return{index:n,length:4}}return null}function ZC(e,t){let n=YC(e,t),r=XC(n,0);if(!r)return{nals:[],pending:n.slice(Math.max(0,n.length-4))};let i=[],a=r.index,o=r.index+r.length,s=XC(n,o);for(;s;)s.index>o&&i.push(n.slice(o,s.index)),a=s.index,o=s.index+s.length,s=XC(n,o);return{nals:i,pending:n.slice(a)}}function QC(e){return e[0]&31}function $C(e){if(QC(e)!==7||e.length<4)return null;let t=e=>e.toString(16).padStart(2,`0`).toUpperCase();return`avc1.${t(e[1])}${t(e[2])}${t(e[3])}`}function ew(e){let t=e.reduce((e,t)=>e+JC.length+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(JC,r),r+=JC.length,n.set(t,r),r+=t.length;return n}function tw(e){let t=QC(e);return t===1||t===5}function nw(e){return e.some(e=>QC(e)===5)}function rw(e,t,n,r){(e.width!==n||e.height!==r)&&(e.width=n,e.height=r);let i=e.getContext(`2d`);i&&i.drawImage(t,0,0,n,r)}function iw(e,t){return new Promise((n,r)=>{if(t.aborted){r(t.reason);return}let i=window.setTimeout(n,e);t.addEventListener(`abort`,()=>{window.clearTimeout(i),r(t.reason)},{once:!0})})}function aw(e){return e instanceof Error?e.message:String(e)}function ow(e){return e instanceof DOMException&&e.name===`AbortError`}function sw({device:e,alt:t,mediaRef:n,onFrameSize:r}){let i=(0,u.useRef)(null),a=(0,u.useRef)(!1),o=(0,u.useRef)(!1),s=(0,u.useRef)(null),[c,l]=(0,u.useState)(`video`),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(`Loading preview...`),h=(0,u.useCallback)(e=>{i.current=e,n?.(e)},[n]),g=(0,u.useCallback)(()=>{a.current||(a.current=!0,f(!0),m(``))},[]),_=(0,u.useCallback)((e,t)=>{let n=s.current;(n?.width!==e||n.height!==t)&&(s.current={width:e,height:t},r?.(e,t))},[r]);return(0,u.useEffect)(()=>{a.current=!1,o.current=!1,s.current=null,f(!1),m(`Loading preview...`),l(`video`)},[e]),(0,u.useEffect)(()=>{if(c!==`video`||a.current)return;let t=!1;return(async()=>{try{let n=await Y.emulatorFrameBlob(e);if(t||a.current)return;let r=await createImageBitmap(n);try{let e=i.current;e&&!a.current&&(rw(e,r,r.width,r.height),_(r.width,r.height),g())}finally{r.close()}}catch{}})(),()=>{t=!0}},[e,g,c,_]),(0,u.useEffect)(()=>{if(c!==`video`)return;if(!(`VideoDecoder`in window)||!(`EncodedVideoChunk`in window)){m(`Video decoder unavailable`),l(`fallback`);return}let t=new AbortController,n=e=>{let t=i.current;try{if(t){let n=e.displayWidth||e.codedWidth,r=e.displayHeight||e.codedHeight;rw(t,e,n,r),_(n,r),o.current=!0,g()}}finally{e.close()}};return(async()=>{for(;!t.signal.aborted;){let r=null,i=null,a=new Uint8Array,s=[],c=!1,u=0,d=`avc1.42E01F`,f=async()=>{if(r)return r;let e={codec:d,optimizeForLatency:!0,avc:{format:`annexb`}};if(!(await VideoDecoder.isConfigSupported(e)).supported)throw Error(`Unsupported Android video codec: ${d}`);return r=new VideoDecoder({output:n,error:e=>{m(e.message)}}),r.configure(e),r},p=async()=>{if(!c){s=[];return}let e=await f(),t=nw(s),n=ew(s),r=u;u+=qC,s=[],c=!1,!(e.decodeQueueSize>2&&!t)&&e.decode(new EncodedVideoChunk({type:t?`key`:`delta`,timestamp:r,duration:qC,data:n}))},h=async e=>{let t=$C(e);t&&(d=t),(QC(e)===9||tw(e))&&c&&await p(),s.push(e),tw(e)&&(c=!0)};try{let n=await fetch(Y.emulatorVideoStreamUrl(e),{cache:`no-store`,signal:t.signal});if(!n.ok||!n.body)throw Error(`Android video stream failed: ${n.status}`);for(i=n.body.getReader();;){let{done:e,value:t}=await i.read();if(e)break;let n=ZC(a,t);a=n.pending;for(let e of n.nals)await h(e)}let o=ZC(a,JC);for(let e of o.nals)await h(e);await p(),r?.state===`configured`&&await r.flush()}catch(e){if(t.signal.aborted||ow(e))break;if(m(aw(e)),!o.current){l(`fallback`);break}}finally{try{i?.releaseLock()}catch{}r?.state!==`closed`&&r?.close()}t.signal.aborted||await iw(KC,t.signal).catch(()=>{})}})(),()=>{t.abort()}},[e,g,c,_]),(0,u.useEffect)(()=>{if(c!==`fallback`)return;let t=!1,n,r=async()=>{try{let n=await Y.emulatorFrameBlob(e);if(t)return;let r=await createImageBitmap(n);try{let e=i.current;e&&(rw(e,r,r.width,r.height),_(r.width,r.height),g())}finally{r.close()}}catch(e){t||m(aw(e))}finally{t||(n=window.setTimeout(r,GC))}};return r(),()=>{t=!0,n&&window.clearTimeout(n)}},[e,g,c,_]),(0,H.jsxs)(`div`,{className:`relative h-full w-full`,children:[(0,H.jsx)(`canvas`,{ref:h,"aria-label":t,width:720,height:1520,className:`pointer-events-none h-full w-full select-none object-contain`}),!d&&(0,H.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center px-5 text-center text-sm text-zinc-400`,children:p})]})}var cw=8,lw=.012,uw=1500,dw=35,fw=260,pw=40,mw=3,hw=5e3,gw=750;function _w(e){return[e.backend,e.isDefault?`default`:void 0,e.detail].filter(Boolean).join(` · `)}function vw(e,t,n){return Math.max(t,Math.min(n,e))}function yw(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function bw(e){let t=e.getBoundingClientRect();if(t.width<=0||t.height<=0)return null;let n=`naturalWidth`in e?e.naturalWidth||t.width:e.width||t.width,r=`naturalHeight`in e?e.naturalHeight||t.height:e.height||t.height;if(n<=0||r<=0)return t;let i=n/r;if(t.width/t.height>i){let e=t.height*i;return new DOMRect(t.left+(t.width-e)/2,t.top,e,t.height)}let a=t.width/i;return new DOMRect(t.left,t.top+(t.height-a)/2,t.width,a)}function xw(e,t,n){if(!e)return null;let r=bw(e);if(!r)return null;let i=(t.clientX-r.left)/r.width,a=(t.clientY-r.top)/r.height;return!n&&(i<0||i>1||a<0||a>1)?null:{x:vw(i,0,1),y:vw(a,0,1)}}function Sw(e){return new Promise(t=>setTimeout(t,e))}function Cw(e){let t=new TextEncoder().encode(JSON.stringify(e)),n=new Uint8Array(1+t.length);return n[0]=mw,n.set(t,1),n.buffer}function ww(){let[e,t]=(0,u.useState)([]),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(!0),[o,s]=(0,u.useState)(null),[c,l]=(0,u.useState)(null),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(null),[h,g]=(0,u.useState)(null),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(0),x=(0,u.useRef)(null),S=(0,u.useRef)(null),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)(null),E=(0,u.useRef)(null),D=(0,u.useCallback)(async()=>{a(!0);try{let[e,n]=await Promise.all([Y.emulatorDevices(),Y.activeEmulator()]);t(e),r(n)}catch(e){V.error(`Failed to load emulator: ${e.message}`)}finally{a(!1)}},[]);(0,u.useEffect)(()=>{D()},[D]),(0,u.useEffect)(()=>()=>{C.current!==null&&window.clearTimeout(C.current),S.current!==null&&window.clearTimeout(S.current)},[]),(0,u.useEffect)(()=>()=>{let e=w.current?.socket;w.current=null,e&&e.readyState!==WebSocket.CLOSED&&e.close()},[n?.wsUrl]),(0,u.useEffect)(()=>{if(n?.backend!==`android`){let e=T.current?.socket;T.current=null,e&&e.readyState!==WebSocket.CLOSED&&e.close();return}return R(n.deviceUdid).catch(()=>{}),()=>{let e=T.current?.socket;T.current=null,e&&e.readyState!==WebSocket.CLOSED&&e.close()}},[n?.backend,n?.deviceUdid]);let O=n?.streamUrl??null,k=O&&y>0?`${O}${O.includes(`?`)?`&`:`?`}rynx_preview_retry=${y}`:O,A=n?.backend===`android`&&!n.streamUrl,j=!!(O||A),M=h===null?void 0:{aspectRatio:h,width:`min(100%, calc(100cqh * ${h}))`},N=(0,u.useCallback)((e,t)=>{if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0)return;let n=e/t;g(e=>e!==null&&Math.abs(e-n)<1e-4?e:n)},[]),P=(0,u.useCallback)(()=>{S.current!==null&&(window.clearTimeout(S.current),S.current=null)},[]),F=(0,u.useCallback)((e,t)=>{P(),N(e,t),v(!0)},[P,N]),I=(0,u.useCallback)(()=>{v(!1),S.current===null&&(S.current=window.setTimeout(()=>{S.current=null,b(e=>e+1)},gw))},[]);(0,u.useEffect)(()=>{if(P(),g(null),v(!1),b(0),!O)return;let e=()=>{let e=x.current;e instanceof HTMLImageElement&&e.naturalWidth>0&&e.naturalHeight>0&&F(e.naturalWidth,e.naturalHeight)};e();let t=window.setInterval(e,500);return()=>window.clearInterval(t)},[P,n?.attachedAt,n?.deviceUdid,F,O]),(0,u.useEffect)(()=>{if(!O||_)return;let e=window.setTimeout(I,hw);return()=>window.clearTimeout(e)},[y,_,O,I]);async function L(e){if(n){m(`home`);try{await Y.buttonEmulator(e,n.deviceUdid)}catch(t){V.error(`${e===`appswitch`?`App switcher`:`Home`} failed: ${t.message}`)}finally{m(null)}}}function ee(){if(!(!n||p)){if(C.current!==null){window.clearTimeout(C.current),C.current=null,L(`appswitch`);return}C.current=window.setTimeout(()=>{C.current=null,L(`home`)},fw)}}async function te(e,t){let i=n?.deviceUdid===e;C.current!==null&&(window.clearTimeout(C.current),C.current=null),l(e),i&&m(`shutdown`);try{await Y.shutdownEmulator(e),i&&r(null),V.success(`Shutdown ${t}`),D()}catch(e){V.error(`Shutdown failed: ${e.message}`)}finally{l(null),i&&m(null)}}async function ne(e){s(e.id);try{let t=await Y.attachEmulator(e.id);r(t),V.success(`Attached ${t.deviceName??t.deviceUdid}`),D()}catch(e){V.error(`Attach failed: ${e.message}`)}finally{s(null)}}function re(e){let t=w.current;if(t?.url===e){if(t.socket?.readyState===WebSocket.OPEN)return Promise.resolve(t.socket);if(t.connecting)return t.connecting}else t?.socket&&t.socket.readyState!==WebSocket.CLOSED&&t.socket.close();let n={url:e,socket:null,connecting:null},r=new Promise((t,r)=>{let i=new WebSocket(e),a=window.setTimeout(()=>{i.close(),r(Error(`Timed out connecting to emulator gesture stream.`))},1500),o=()=>window.clearTimeout(a);i.binaryType=`arraybuffer`,i.addEventListener(`open`,()=>{o(),n.socket=i,n.connecting=null,t(i)},{once:!0}),i.addEventListener(`error`,()=>{o(),n.connecting=null,r(Error(`Failed to connect to emulator gesture stream.`))},{once:!0}),i.addEventListener(`close`,()=>{w.current?.socket===i&&(w.current=null)})});return n.connecting=r,w.current=n,r}function R(e){let t=T.current;if(t?.device===e){if(t.socket?.readyState===WebSocket.OPEN)return Promise.resolve(t.socket);if(t.connecting)return t.connecting}else t?.socket&&t.socket.readyState!==WebSocket.CLOSED&&t.socket.close();let n={device:e,socket:null,connecting:null},r=new Promise((t,r)=>{let i=new WebSocket(Jx(e)),a=!1,o=window.setTimeout(()=>{a||(a=!0,i.close(),r(Error(`Timed out connecting to Android touch stream.`)))},uw),s=()=>window.clearTimeout(o);i.addEventListener(`message`,e=>{if(!a&&typeof e.data==`string`)try{let o=JSON.parse(e.data);o.t===`opened`?(a=!0,s(),n.socket=i,n.connecting=null,t(i)):o.t===`error`&&(a=!0,s(),n.connecting=null,r(Error(o.message??`Android touch stream failed.`)))}catch{}}),i.addEventListener(`error`,()=>{a||(a=!0,s(),n.connecting=null,r(Error(`Failed to connect to Android touch stream.`)))},{once:!0}),i.addEventListener(`close`,()=>{s(),n.connecting=null,a||(a=!0,r(Error(`Android touch stream closed before it was ready.`))),T.current?.socket===i&&(T.current=null)})});return n.connecting=r,T.current=n,r}async function ie(e,t){if(e.backend===`android`){if(e.liveFailed)return!1;try{return(await R(e.device)).send(JSON.stringify(t)),e.sentLiveFrames+=1,!0}catch(t){return e.liveFailed=!0,e.sentLiveFrames>0&&V.error(`Android touch stream failed: ${t.message}`),!1}}if(!e.wsUrl||e.liveFailed)return!1;try{return(await re(e.wsUrl)).send(Cw(t)),e.sentLiveFrames+=1,!0}catch(t){return e.liveFailed=!0,e.sentLiveFrames>0&&V.error(`Gesture stream failed: ${t.message}`),!1}}function ae(e,t){Y.gestureEmulator([{type:`begin`,x:e.x,y:e.y}],t).catch(e=>{V.error(`Tap failed: ${e.message}`)})}function oe(e,t){Y.gestureEmulator(e,t).catch(e=>{V.error(`Gesture failed: ${e.message}`)})}function se(e){if(!n||!j||!e.isPrimary||e.pointerType===`mouse`&&e.button!==0)return;let t=xw(x.current,e,!1);t&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),E.current={backend:n.backend,pointerId:e.pointerId,device:n.deviceUdid,wsUrl:n.backend===`ios`?n.wsUrl:void 0,startClientX:e.clientX,startClientY:e.clientY,lastPoint:t,moved:!1,liveFailed:!1,sentLiveFrames:0,points:[{type:`begin`,x:t.x,y:t.y}]},ie(E.current,{type:`begin`,x:t.x,y:t.y}),f(!0))}function ce(e){let t=E.current;if(!t||t.pointerId!==e.pointerId)return;let n=xw(x.current,e,!0);if(!n)return;e.preventDefault();let r=Math.hypot(e.clientX-t.startClientX,e.clientY-t.startClientY)>cw,i=yw(n,t.lastPoint)>lw;if(t.lastPoint=n,r&&(i||!t.moved)){t.moved=!0;let e={type:`move`,x:n.x,y:n.y};t.points.push(e),ie(t,e)}}async function le(e){let t=E.current;if(!t||t.pointerId!==e.pointerId)return;e.preventDefault();let n=xw(x.current,e,!0)??t.lastPoint,r=Math.hypot(e.clientX-t.startClientX,e.clientY-t.startClientY)>cw;E.current=null,f(!1);try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let i={type:`end`,x:n.x,y:n.y};if((t.backend===`android`||t.wsUrl)&&!t.liveFailed&&(!t.moved&&!r&&await Sw(t.backend===`android`?dw:pw),await ie(t,i)||t.sentLiveFrames>0))return;if(!t.moved&&!r){ae(n,t.device);return}let a=[...t.points],o=a[a.length-1];o&&yw(o,n)<=.001?a[a.length-1]=i:a.push(i),oe(a,t.device)}function ue(e){let t=E.current;!t||t.pointerId!==e.pointerId||(E.current=null,f(!1),(t.backend===`android`||t.wsUrl)&&!t.liveFailed&&ie(t,{type:`end`,x:t.lastPoint.x,y:t.lastPoint.y}))}return(0,H.jsxs)(`div`,{className:`grid h-full min-h-0 gap-3 p-3 sm:p-4 lg:grid-cols-[minmax(0,360px)_minmax(360px,1fr)]`,children:[(0,H.jsxs)(fC,{className:`flex h-full min-h-0 flex-col overflow-hidden p-0`,children:[(0,H.jsxs)(pC,{className:`px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(mC,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Cr,{className:`size-4`}),`Preview`]}),(0,H.jsx)(`div`,{className:`label-caps mt-1 truncate text-[10px] text-[var(--muted-foreground)]`,children:n?`This device · ${n.backend} · ${n.deviceName??n.deviceUdid}`:`This device · not attached`})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,H.jsx)(J,{variant:`outline`,size:`icon`,className:`size-8`,onClick:ee,disabled:!n||p!==null,"aria-label":`Home or app switcher`,title:`Home · double-click for app switcher`,children:(0,H.jsx)(dr,{className:X(p===`home`&&`animate-pulse`)})}),(0,H.jsx)(J,{variant:`outline`,size:`icon`,className:`size-8`,onClick:()=>{n&&te(n.deviceUdid,n.deviceName??n.deviceUdid)},disabled:!n||p!==null||c!==null,"aria-label":`Shutdown emulator`,title:`Shutdown`,children:(0,H.jsx)(Lr,{className:X(p===`shutdown`&&`animate-pulse`)})}),(0,H.jsx)(J,{variant:`outline`,size:`icon`,className:`size-8`,onClick:()=>void D(),disabled:i,"aria-label":`Refresh emulator`,title:`Refresh`,children:(0,H.jsx)(zr,{className:X(i&&`animate-spin`)})})]})]}),(0,H.jsxs)(hC,{className:`relative grid min-h-0 flex-1 place-items-center p-2 sm:p-3`,style:{containerType:`size`},"aria-busy":j&&!_,children:[j?(0,H.jsx)(`div`,{className:X(`relative grid touch-none select-none place-items-center overflow-hidden bg-black`,_?`max-h-full max-w-full rounded-md border border-[var(--border)] shadow-sm`:`pointer-events-none absolute inset-0`,_&&(d?`cursor-grabbing`:`cursor-crosshair`)),style:_?M:void 0,onPointerDown:se,onPointerMove:ce,onPointerUp:le,onPointerCancel:ue,children:O?(0,H.jsx)(`img`,{ref:e=>{x.current=e},src:k??void 0,alt:n?.deviceName??n?.deviceUdid,className:`pointer-events-none absolute inset-0 h-full w-full select-none object-contain`,onLoad:e=>{F(e.currentTarget.naturalWidth,e.currentTarget.naturalHeight)},onError:I,draggable:!1},`${n?.deviceUdid}:${n?.attachedAt}:${y}`):n&&A?(0,H.jsx)(sw,{device:n.deviceUdid,alt:n.deviceName??n.deviceUdid,mediaRef:e=>{x.current=e},onFrameSize:F},n.deviceUdid):null}):(0,H.jsx)(`div`,{className:`grid h-full w-full place-items-center px-6 text-center text-sm text-[var(--muted-foreground)]`,children:n?`${n.backend} preview unavailable`:`No active emulator`}),j&&!_&&(0,H.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 grid place-items-center bg-[var(--background)] text-[var(--muted-foreground)]`,role:`status`,"aria-live":`polite`,children:(0,H.jsxs)(`div`,{className:`grid place-items-center gap-2 text-xs`,children:[(0,H.jsx)(zr,{className:`size-4 animate-spin text-[var(--primary)]`}),(0,H.jsx)(`span`,{children:`Loading preview…`})]})})]})]}),(0,H.jsxs)(fC,{className:`flex h-full min-h-0 flex-col overflow-hidden p-0`,children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(mC,{className:`flex items-center gap-2`,children:[(0,H.jsx)($r,{className:`size-4`}),`Devices`]}),(0,H.jsx)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:e.length})]}),(0,H.jsx)(hC,{className:`min-h-0 flex-1 p-0`,children:e.length===0?(0,H.jsx)(`div`,{className:`px-5 py-8 text-sm text-[var(--muted-foreground)]`,children:i?`Loading...`:`No devices`}):(0,H.jsx)(U_,{className:`h-full min-h-0`,children:(0,H.jsx)(`ul`,{className:`grid grid-cols-1 content-start gap-2 p-3 sm:grid-cols-2 2xl:grid-cols-3`,children:e.map(e=>{let t=n?.deviceUdid===e.id,r=o===e.id,i=c===e.id;return(0,H.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-[var(--border)] bg-[var(--background)] px-3 py-2.5`,children:[(0,H.jsx)($r,{className:`size-4 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,H.jsxs)(MC,{variant:e.state===`booted`?`success`:e.state===`shutdown`?`outline`:`warning`,className:`h-5 shrink-0 gap-1 px-2 py-0 font-mono text-[9px] uppercase`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`,"aria-hidden":`true`}),e.state]})]}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[10px] uppercase text-[var(--muted-foreground)]`,title:_w(e),children:_w(e)})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsx)(J,{size:`xs`,variant:t?`outline`:`default`,onClick:()=>void ne(e),disabled:r||c!==null,children:r?`Attaching…`:t?`Reattach`:`Attach`}),e.state===`booted`&&(0,H.jsx)(J,{size:`icon-xs`,variant:`destructive`,onClick:()=>void te(e.id,e.name),disabled:o!==null||c!==null,"aria-label":`Shutdown ${e.name}`,title:`Shutdown ${e.name}`,children:(0,H.jsx)(Lr,{className:X(i&&`animate-pulse`)})})]})]},`${e.backend}:${e.id}`)})})})})]})]})}function Tw({embedded:e=!1}={}){let t=wS(),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(!1),c=(0,u.useCallback)(async()=>{if(t){s(!0),a(null);try{r(await t.getStatus())}catch(e){a(e.message)}finally{s(!1)}}},[t]);(0,u.useEffect)(()=>{c()},[c]);async function l(e){if(!(!t||e===n?.runtime.lifecycleMode)){s(!0),a(null);try{r(await t.setDaemonLifecycleMode(e)),V.success(e===`resident`?`Runtime will stay available after Rynx quits`:`Runtime will now follow the Rynx app lifecycle`)}catch(e){let t=e.message;a(t),V.error(`Could not change Runtime mode: ${t}`)}finally{s(!1)}}}async function d(){if(t){s(!0),a(null);try{r(await t.restartDaemon()),V.success(`Local Runtime restarted`)}catch(e){let t=e.message;a(t),V.error(`Could not restart Runtime: ${t}`)}finally{s(!1)}}}return(0,H.jsxs)(`div`,{id:e?`runtime`:void 0,className:e?`grid scroll-mt-6 gap-5`:`grid max-w-3xl gap-5`,children:[!e&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Daemon`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Choose whether the local Runtime follows the Desktop app or stays available in the background.`})]}),(0,H.jsxs)(fC,{"aria-busy":o,children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`Runtime lifecycle`}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`This setting applies to the Runtime bundled with Rynx.`})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o,onClick:()=>void c(),children:[(0,H.jsx)(zr,{className:o?`animate-spin`:``}),`Check`]}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o,onClick:()=>void d(),children:[(0,H.jsx)(zr,{}),`Restart`]})]})]}),(0,H.jsxs)(hC,{className:`grid gap-5`,children:[n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-[var(--border)] p-4`,children:[(0,H.jsx)(`span`,{className:n.runtime.ready?`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--success)]/12 text-[var(--success)]`:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--warning)]/12 text-[var(--warning)]`,children:(0,H.jsx)(Wr,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:`Runtime status`}),(0,H.jsx)(MC,{variant:n.runtime.ready?`success`:`warning`,children:Ew(n.runtime.state)}),(0,H.jsx)(MC,{variant:`outline`,children:n.runtime.managedBy===`app`?`Managed by app`:n.runtime.managedBy===`external`?`External`:`Not managed`})]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:n.runtime.detail??Dw(n)})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-2`,children:[(0,H.jsx)(GS,{htmlFor:`daemon-lifecycle-mode`,children:`Lifecycle`}),(0,H.jsxs)(Ig,{id:`daemon-lifecycle-mode`,value:n.runtime.lifecycleMode,disabled:o,className:`max-w-sm`,onChange:e=>void l(e.target.value),children:[(0,H.jsx)(`option`,{value:`follow-app`,children:`Follow Rynx app`}),(0,H.jsx)(`option`,{value:`resident`,children:`Stay available in background`})]}),(0,H.jsx)(`p`,{className:`max-w-2xl text-xs leading-5 text-[var(--muted-foreground)]`,children:n.runtime.lifecycleMode===`follow-app`?`The Runtime and its embedded Browser Host start with Rynx and stop when the app fully quits. Closing a window does not quit the app.`:`The Runtime and its embedded Browser Host keep running when the app quits, so Terminals, agents, and Session browsers remain available.`})]})]}):(0,H.jsxs)(`div`,{className:`flex min-h-32 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[o&&(0,H.jsx)(B,{className:`size-4 animate-spin`}),o?`Checking Runtime…`:`Runtime status is unavailable.`]}),i&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_35%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_7%,var(--background))] p-3 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(zn,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]})]})]})]})}function Ew(e){switch(e){case`starting`:return`Starting`;case`running`:return`Running`;case`stopped`:return`Stopped`;case`busy`:return`Busy`;case`error`:return`Error`}}function Dw(e){let t=[e.runtime.version?`Version ${e.runtime.version}`:null,e.runtime.pid?`PID ${e.runtime.pid}`:null].filter(Boolean);return t.length>0?t.join(` · `):`No additional Runtime details.`}function Ow({embedded:e=!1}={}){let t=wS(),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(`refresh`),c=(0,u.useCallback)(async(e=!1)=>{if(t){s(`refresh`),a(null);try{r(await t.getStatus(e))}catch(e){a(e.message)}finally{s(null)}}},[t]);(0,u.useEffect)(()=>{c()},[c]);async function l(e){if(t){s(`install`),a(null);try{r(await t.installCli(e)),V.success(`Terminal command installed`)}catch(e){let n=e.message;a(n),V.error(`Could not install the Terminal command: ${n}`);try{r(await t.getStatus(!0))}catch{}}finally{s(null)}}}async function d(e){if(t){s(`remove`),a(null);try{r(await t.removeCli(e)),V.success(`Terminal command removed`)}catch(e){let n=e.message;a(n),V.error(`Could not remove the Terminal command: ${n}`);try{r(await t.getStatus(!0))}catch{}}finally{s(null)}}}let f=n?.globalCli,p=f?.state===`installed`,m=f?.state===`development`,h=f?.state===`installed`&&f.canInstall&&!!(f.path&&f.target&&f.path!==f.target);return(0,H.jsxs)(`div`,{id:e?`terminal-command`:void 0,className:e?`grid scroll-mt-6 gap-5`:`grid max-w-3xl gap-5`,children:[!e&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Terminal command`}),(0,H.jsxs)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:[`Install or remove the `,(0,H.jsx)(`code`,{className:`font-mono`,children:`rynx`}),` command used in Terminal.`]})]}),(0,H.jsxs)(fC,{"aria-busy":o!==null,children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`Shell access`}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Removing the command does not uninstall Rynx or delete its data.`})]}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o!==null,onClick:()=>void c(!0),children:[(0,H.jsx)(zr,{className:o===`refresh`?`animate-spin`:``}),`Check`]})]}),(0,H.jsxs)(hC,{className:`grid gap-3`,children:[f?(0,H.jsxs)(`div`,{className:`grid gap-4 rounded-lg border border-[var(--border)] p-4 sm:grid-cols-[auto_minmax(0,1fr)_auto] sm:items-center`,children:[(0,H.jsx)(`span`,{className:p?`grid size-10 place-items-center rounded-lg bg-[var(--success)]/12 text-[var(--success)]`:m?`grid size-10 place-items-center rounded-lg bg-[var(--muted)] text-[var(--muted-foreground)]`:`grid size-10 place-items-center rounded-lg bg-[var(--warning)]/12 text-[var(--warning)]`,children:p?(0,H.jsx)(Pn,{className:`size-5`}):(0,H.jsx)(qn,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`font-mono text-sm font-medium`,children:`rynx`}),(0,H.jsx)(MC,{variant:p?`success`:m?`outline`:`warning`,children:kw(f.state)})]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:Aw(f)}),f.path&&(0,H.jsx)(`code`,{className:`mt-1 block break-all font-mono text-[11px] text-[var(--muted-foreground)]`,children:f.path}),h&&f.target&&(0,H.jsxs)(`p`,{className:`mt-1 break-all text-[11px] text-[var(--muted-foreground)]`,children:[`Recommended: `,(0,H.jsx)(`code`,{className:`font-mono`,children:f.target})]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2 sm:justify-self-end`,children:[f.canInstall&&(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o!==null,onClick:()=>f.path&&void l(f.path),children:[o===`install`&&(0,H.jsx)(B,{className:`animate-spin`}),h?`Move command`:f.state===`stale`?`Repair command`:`Install command`]}),f.canRemove&&(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o!==null,children:[(0,H.jsx)(si,{}),`Remove command`]})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsx)(vu,{children:`Remove the Terminal command?`}),(0,H.jsx)(yu,{children:`This removes only the shell command link that points to this Rynx app. The app, Runtime, settings, and workspace data remain installed.`})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>f.path&&void d(f.path),children:`Remove command`})]})]})]})]})]}):(0,H.jsxs)(`div`,{className:`flex min-h-32 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[o===`refresh`&&(0,H.jsx)(B,{className:`size-4 animate-spin`}),o===`refresh`?`Checking command…`:`Command status is unavailable.`]}),i&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_35%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_7%,var(--background))] p-3 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(zn,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]})]})]})]})}function kw(e){switch(e){case`installed`:return`Installed`;case`missing`:return`Not installed`;case`stale`:return`Needs repair`;case`foreign`:return`Managed externally`;case`development`:return`Development build`;case`unwritable`:case`error`:return`Unavailable`}}function Aw(e){switch(e.state){case`installed`:return e.canInstall?`The command is ready. You can move it to the recommended location.`:`The command is ready to use from Terminal.`;case`missing`:return`Install the command to use Rynx from Terminal.`;case`stale`:return`Update the command registration to use this Rynx app.`;case`foreign`:return`Another program owns the active command. Rynx will not replace or remove it.`;case`development`:return`Global Terminal command registration is disabled in development builds. Install a packaged Rynx app to manage the rynx command.`;case`unwritable`:return`Rynx could not find a supported location for the command.`;case`error`:return`Rynx could not check the command.`}}function jw(){return(0,H.jsxs)(`div`,{className:`grid max-w-3xl gap-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Local Runtime`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Manage the Runtime bundled with Rynx and its Terminal command.`})]}),(0,H.jsx)(Tw,{embedded:!0}),(0,H.jsx)(Ow,{embedded:!0})]})}function Mw(){let{status:e,operation:t,error:n,checkForUpdates:r,installUpdate:i}=kS(),a=t!==null||e?.phase===`checking`||e?.phase===`downloading`||e?.phase===`installing`,o=n??e?.error;async function s(){let e=await r();e&&(e.error?V.error(`Could not check for updates: ${e.error}`):e.phase===`idle`?V.success(`${e.appName} is up to date`):e.availableVersion&&V.message(`Rynx ${e.availableVersion} is available`))}return(0,H.jsxs)(fC,{id:`software-update`,className:`scroll-mt-6`,"aria-busy":a,children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`Software update`}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Review the installed Desktop version and check GitHub Releases for updates.`})]}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:a||!e?.supported,onClick:()=>void s(),children:[(0,H.jsx)(zr,{className:t===`check`||e?.phase===`checking`?`animate-spin`:``}),`Check for updates`]})]}),(0,H.jsxs)(hC,{className:`grid gap-4`,children:[e?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-[var(--border)] p-4`,children:[(0,H.jsx)(`span`,{className:Pw(e),children:(0,H.jsx)(Nw,{status:e})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:e.appName}),(0,H.jsxs)(MC,{variant:`outline`,children:[`Version `,e.currentVersion]}),(0,H.jsx)(MC,{variant:e.channel===`preview`?`warning`:`default`,children:Iw(e.channel)})]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:Fw(e)}),e.lastCheckedAt&&(0,H.jsxs)(`p`,{className:`mt-1 text-[10px] text-[var(--muted-foreground)]`,children:[`Last checked `,Lw(e.lastCheckedAt)]})]}),e.phase===`ready`&&(0,H.jsxs)(J,{size:`sm`,disabled:t===`install`,onClick:()=>void i(),children:[t===`install`?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Bn,{}),`Restart to update`]})]}),!e.supported&&(0,H.jsx)(`div`,{className:`rounded-lg border border-[var(--border)] bg-[var(--muted)]/30 p-3 text-xs leading-5 text-[var(--muted-foreground)]`,children:`Automatic updates are available in signed release builds. Local development builds display their version here but do not contact the release feed.`})]}):(0,H.jsxs)(`div`,{className:`flex min-h-32 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),`Loading version information…`]}),o&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_35%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_7%,var(--background))] p-3 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(zn,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{children:o})]})]})]})}function Nw({status:e}){return e.phase===`checking`||e.phase===`installing`?(0,H.jsx)(B,{className:`size-5 animate-spin`}):e.phase===`downloading`?(0,H.jsx)(Yn,{className:`size-5`}):e.phase===`ready`?(0,H.jsx)(Bn,{className:`size-5`}):(0,H.jsx)(Vn,{className:`size-5`})}function Pw(e){return e.phase===`downloading`||e.phase===`ready`||e.phase===`installing`?`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/12 text-[var(--primary)]`:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--success)]/12 text-[var(--success)]`}function Fw(e){if(!e.supported)return`This local build does not check for automatic updates.`;switch(e.phase){case`disabled`:return`Automatic updates are disabled for this build.`;case`idle`:return e.error?`The last update check did not complete.`:e.lastCheckedAt?`This version is up to date.`:`Ready to check for updates.`;case`checking`:return`Checking GitHub Releases for a newer version…`;case`downloading`:return`Rynx ${e.availableVersion??``} is downloading in the background.`;case`ready`:return`Rynx ${e.availableVersion??``} is ready. Restart to finish the update.`;case`installing`:return`Preparing the Runtime and restarting Rynx safely…`}}function Iw(e){switch(e){case`local`:return`Local build`;case`preview`:return`Preview channel`;case`stable`:return`Stable channel`}}function Lw(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function Rw({plugins:e,agents:t,desktopIntegrationAvailable:n}){let r=nt(),i=e=>r(px[e]),a=e.filter(e=>e.enabled).length,o=e.filter(e=>e.runtimeState===`running`).length;return(0,H.jsxs)(`div`,{className:`grid gap-5`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Overview`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Plugins own integrations and their settings; agents define task behavior.`})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,H.jsx)(zw,{icon:Rr,label:`Plugins`,value:e.length,sub:`${a} enabled · ${o} healthy`,onClick:()=>i(`plugins`)}),(0,H.jsx)(zw,{icon:Mn,label:`Agents`,value:t.length,sub:t.length===1?`1 defined`:`${t.length} defined`,onClick:()=>i(`agents`)})]}),(0,H.jsxs)(fC,{children:[(0,H.jsxs)(pC,{children:[(0,H.jsx)(mC,{children:`Plugins`}),(0,H.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>i(`plugins`),children:`Manage`})]}),(0,H.jsx)(hC,{className:`p-0`,children:e.length===0?(0,H.jsxs)(`div`,{className:`px-5 py-10 text-center text-sm text-[var(--muted-foreground)]`,children:[`No plugins installed. Add one from a Market or a Git repository with the Rynx CLI.`,(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(J,{size:`sm`,onClick:()=>i(`plugins`),children:`View plugins`})})]}):(0,H.jsx)(`ul`,{className:`divide-y divide-[var(--border)]`,children:e.map(e=>(0,H.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-5 py-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.pluginId}),(0,H.jsxs)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:[e.id,` · v`,e.version]})]}),(0,H.jsx)(`span`,{className:`rounded-full border border-[var(--border)] px-2 py-0.5 font-mono text-[10px] text-[var(--muted-foreground)]`,children:e.enabled?e.runtimeState:`disabled`})]},e.id))})})]}),n&&(0,H.jsx)(Mw,{})]})}function zw({icon:e,label:t,value:n,sub:r,onClick:i}){return(0,H.jsx)(fC,{children:(0,H.jsxs)(`button`,{onClick:i,className:`flex w-full items-start gap-4 rounded-xl p-5 text-left transition-colors hover:bg-[var(--muted)]/40`,children:[(0,H.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(e,{className:`size-5`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-3xl font-semibold leading-none tabular-nums`,children:n}),(0,H.jsx)(`div`,{className:`label-caps mt-1.5 text-[11px] text-[var(--muted-foreground)]`,children:t}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:r})]})]})})}function Bw({description:e=`You're about to visit an external website. Review the complete destination before continuing.`,onConfirm:t,onOpenChange:n,open:r,url:i}){let[a,o]=(0,u.useState)(!1);(0,u.useEffect)(()=>{r||o(!1)},[r]);let s=async()=>{try{await navigator.clipboard.writeText(i),o(!0)}catch{}};return(0,H.jsx)(uu,{open:r,onOpenChange:n,children:(0,H.jsxs)(mu,{className:`sm:max-w-xl`,children:[(0,H.jsxs)(hu,{children:[(0,H.jsx)(_u,{children:(0,H.jsx)(er,{})}),(0,H.jsx)(vu,{children:`Open external link?`}),(0,H.jsx)(yu,{children:e})]}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`code`,{className:`block max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-lg border border-[var(--border)] bg-[var(--muted)]/40 py-3 pr-11 pl-3 font-mono text-xs leading-relaxed text-[var(--foreground)]`,children:i}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-2`,"aria-label":a?`Link copied`:`Copy link`,title:a?`Link copied`:`Copy link`,onClick:()=>void s(),children:a?(0,H.jsx)(Pn,{}):(0,H.jsx)(Jn,{})})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{onClick:t,children:`Open link`})]})]})})}function Vw(e){let t=Hw(e)?e.url:void 0;if(typeof t!=`string`||!t.trim())throw Error(`external URL is required`);let n;try{n=new URL(t)}catch{throw Error(`external URL is invalid`)}if(n.protocol!==`https:`)throw Error(`only HTTPS links may be opened`);if(n.username||n.password)throw Error(`external URLs must not contain credentials`);return n.href}function Hw(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Uw=1048576,Ww=16,Gw=3e4,Kw=2e3,qw=/^[A-Za-z][A-Za-z0-9._:-]{0,127}$/;function Jw({plugins:e,theme:t,onChange:n}){let[r,i]=(0,u.useState)(),[a,o]=(0,u.useState)(),[s,c]=(0,u.useState)(`discover`),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(),[m,h]=(0,u.useState)(!0),[g,_]=(0,u.useState)(!1),[v,y]=(0,u.useState)(),[b,x]=(0,u.useState)(),[S,C]=(0,u.useState)(),[w,T]=(0,u.useState)(!1),E=(0,u.useRef)(0),D=(0,u.useRef)(!1),O=(0,u.useRef)(!1),k=e.find(e=>e.id===r),A=(0,u.useCallback)(async()=>{let e=++E.current;h(!0);try{let t=await Y.listPluginMarketplaces();if(e!==E.current)return!0;let r=D.current;return D.current=!1,d(t),p(void 0),r&&n(),!0}catch(t){return e!==E.current||(D.current=!0,p(t.message),!1)}finally{e===E.current&&h(!1)}},[n]);(0,u.useEffect)(()=>{let e=!1,t,n=async()=>{!await A()&&!e&&(t=window.setTimeout(()=>void n(),Kw))};return n(),()=>{e=!0,t!==void 0&&window.clearTimeout(t),E.current+=1}},[A]),(0,u.useEffect)(()=>{r&&!k&&i(void 0)},[k,r]);let j=async e=>{o(e.id);try{await Y.setPluginEnabled(e.id,!e.enabled),await n()}catch(t){V.error(`Failed to ${e.enabled?`disable`:`enable`} plugin: ${t.message}`)}finally{o(void 0)}},M=async e=>{x(e);try{C(await Y.preparePluginInstallation({operation:`install`,marketplacePlugin:e}))}catch(t){V.error(`Could not prepare ${e}: ${t.message}`)}finally{x(void 0)}},N=async e=>{x(e);try{let t=await Y.preparePluginInstallation({operation:`update`,pluginId:e});if(t.unchanged){await Y.cancelPluginInstallation(t.token).catch(()=>!1),V.info(`${e} is already up to date.`);return}C(t)}catch(t){V.error(`Could not prepare update for ${e}: ${t.message}`)}finally{x(void 0)}},P=()=>{let e=S;C(void 0),e&&Y.cancelPluginInstallation(e.token).catch(()=>!1)},F=async()=>{if(!S)return;let e=!!S.existing;T(!0);try{let t=await Y.commitPluginInstallation(S.token,{overwrite:!!S.existing,expectedDigest:S.artifact.digest});C(void 0),V.success(`${e?`Updated`:`Installed`} ${t.plugin.id} v${t.plugin.version}.`+(e?` No Rynx restart required.`:``)),await n(),c(`installed`)}catch(t){C(void 0),V.error(`${e?`Update`:`Installation`} failed: ${t.message}`)}finally{T(!1)}},I=async e=>{if(!O.current){O.current=!0,y(e.id);try{await Y.refreshPluginMarketplace(e.id),await Promise.all([A(),n()]),V.success(`Refreshed ${e.id}`)}catch(e){V.error(`Market refresh failed: ${e.message}`)}finally{O.current=!1,y(void 0)}}},L=async e=>{if(!O.current){O.current=!0,y(e.id);try{await Y.removePluginMarketplace(e.id),await A(),V.success(`Removed ${e.id}`)}catch(e){V.error(`Market removal failed: ${e.message}`)}finally{O.current=!1,y(void 0)}}};return k?.hasSettingsUi?(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,H.jsxs)(J,{variant:`outline`,size:`sm`,className:`shrink-0`,onClick:()=>i(void 0),children:[(0,H.jsx)(An,{}),`Plugins`]}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsxs)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:[k.pluginId,` settings`]}),(0,H.jsx)(aT,{plugin:k})]}),(0,H.jsxs)(`div`,{className:`truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:[`Sandboxed plugin UI · `,k.id,` · v`,k.version]})]})]}),(0,H.jsx)(fC,{className:`overflow-hidden`,children:(0,H.jsx)(hC,{className:`p-0`,children:(0,H.jsx)(oT,{plugin:k,theme:t,onChange:n})})})]}):(0,H.jsxs)(`div`,{className:`grid gap-5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Plugins`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Discover plugins from trusted Markets, then review their source and executable entries before installation.`})]}),(0,H.jsxs)(J,{size:`sm`,className:`shrink-0`,onClick:()=>_(!0),children:[(0,H.jsx)(Ir,{}),`Add Market`]})]}),(0,H.jsxs)(lx,{value:s,onValueChange:c,children:[(0,H.jsxs)(ux,{"aria-label":`Plugin management views`,children:[(0,H.jsxs)(dx,{value:`discover`,className:`gap-1.5 leading-none`,children:[`Discover`,(0,H.jsx)(`span`,{className:`text-xs font-normal leading-none tabular-nums`,children:l?.reduce((e,t)=>e+t.plugins.length,0)??0})]}),(0,H.jsxs)(dx,{value:`installed`,className:`gap-1.5 leading-none`,children:[`Installed`,(0,H.jsx)(`span`,{className:`text-xs font-normal leading-none tabular-nums`,children:e.length})]}),(0,H.jsxs)(dx,{value:`markets`,className:`gap-1.5 leading-none`,children:[`Markets`,(0,H.jsx)(`span`,{className:`text-xs font-normal leading-none tabular-nums`,children:l?.length??0})]})]}),(0,H.jsx)(fx,{value:`discover`,children:l===null&&f?(0,H.jsx)(rT,{error:f,retrying:m,onRetry:()=>void A()}):(0,H.jsx)(Yw,{markets:l,installed:e,preparingId:b,onAddMarket:()=>_(!0),onInstall:e=>void M(e)})}),(0,H.jsx)(fx,{value:`installed`,children:(0,H.jsx)(Xw,{plugins:e,mutatingId:a,preparingId:b,onBrowse:()=>c(`discover`),onConfigure:i,onUpdate:e=>void N(e),onChangeEnabled:e=>void j(e)})}),(0,H.jsx)(fx,{value:`markets`,children:l===null&&f?(0,H.jsx)(rT,{error:f,retrying:m,onRetry:()=>void A()}):(0,H.jsx)(Zw,{markets:l,mutatingId:v,onAdd:()=>_(!0),onRefresh:e=>void I(e),onRemove:e=>void L(e)})})]}),(0,H.jsx)(Qw,{open:g,onOpenChange:_,onAdded:async e=>{await A(),c(`discover`),V.success(`Added ${e.id}`)}}),(0,H.jsx)($w,{preparation:S,committing:w,onCancel:P,onCommit:()=>void F()})]})}function Yw({markets:e,installed:t,preparingId:n,onAddMarket:r,onInstall:i}){let[a,o]=(0,u.useState)(``),s=new Set(t.map(e=>e.id)),c=(e??[]).flatMap(e=>e.plugins.map(t=>({id:`${t.id}@${e.id}`,pluginId:t.id,market:e}))),l=a.trim().toLowerCase(),d=l?c.filter(({id:e})=>e.includes(l)):c;return e===null?(0,H.jsx)(nT,{label:`Loading plugin catalogs…`}):e.length===0?(0,H.jsx)(tT,{icon:ii,title:`Add a Market to discover plugins`,description:`A Market is a Git or local catalog. Adding it downloads metadata only and never installs plugin code.`,action:(0,H.jsxs)(J,{size:`sm`,onClick:r,children:[(0,H.jsx)(Ir,{}),` Add Market`]})}):(0,H.jsxs)(fC,{children:[(0,H.jsxs)(pC,{className:`flex-col items-stretch gap-3 sm:flex-row sm:items-center`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`Available plugins`}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Catalog entries stay inert until you review and install one.`})]}),(0,H.jsxs)(`div`,{className:`relative w-full sm:w-64`,children:[(0,H.jsx)(Hr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-[var(--muted-foreground)]`}),(0,H.jsx)(Ag,{"aria-label":`Search available plugins`,className:`pl-8`,value:a,placeholder:`Search plugins or Markets`,onChange:e=>o(e.target.value)})]})]}),(0,H.jsx)(hC,{className:`p-0`,children:d.length===0?(0,H.jsxs)(`div`,{className:`px-5 py-10 text-center text-sm text-[var(--muted-foreground)]`,children:[`No catalog entries match “`,a.trim(),`”.`]}):(0,H.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:d.map(({id:e,pluginId:t,market:r})=>{let a=s.has(e),o=n===e;return(0,H.jsxs)(`article`,{className:`flex flex-col gap-3 px-5 py-4 transition-colors hover:bg-[var(--muted)]/35 sm:flex-row sm:items-center`,children:[(0,H.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(Rr,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`strong`,{className:`text-sm`,children:t}),(0,H.jsx)(MC,{variant:`outline`,className:`font-mono`,children:r.id})]}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:e})]}),(0,H.jsx)(J,{size:`sm`,variant:a?`outline`:`default`,disabled:a||!!n,onClick:()=>i(e),children:a?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Pn,{}),` Installed`]}):o?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(B,{className:`animate-spin`}),` Preparing…`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Yn,{}),` Install`]})})]},e)})})})]})}function Xw({plugins:e,mutatingId:t,preparingId:n,onBrowse:r,onConfigure:i,onUpdate:a,onChangeEnabled:o}){return e.length===0?(0,H.jsx)(tT,{icon:Or,title:`No plugins installed`,description:`Browse your registered Markets and review a plugin before installing it.`,action:(0,H.jsxs)(J,{size:`sm`,onClick:r,children:[(0,H.jsx)(Or,{}),` Browse plugins`]})}):(0,H.jsx)(`div`,{className:`grid gap-3`,children:e.map(e=>(0,H.jsx)(fC,{children:(0,H.jsxs)(hC,{className:`flex flex-col gap-4 sm:flex-row sm:items-center`,children:[(0,H.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(Rr,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`strong`,{className:`text-sm`,children:e.pluginId}),(0,H.jsx)(aT,{plugin:e}),(0,H.jsx)(MC,{variant:`outline`,children:e.marketplaceId})]}),(0,H.jsxs)(`div`,{className:`mt-1 truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:[`v`,e.version]}),e.runtimeError&&(0,H.jsxs)(`div`,{className:`mt-2 flex items-start gap-1.5 text-xs text-[var(--danger)]`,children:[(0,H.jsx)(ci,{className:`mt-0.5 size-3.5 shrink-0`}),e.runtimeError]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[e.hasSettingsUi&&(0,H.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>i(e.id),children:[(0,H.jsx)(Gr,{}),`Configure`]}),e.updateState!==`current`&&(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:!!n||t!==void 0,onClick:()=>a(e.id),children:[(0,H.jsx)(zr,{className:n===e.id?`animate-spin`:``}),n===e.id?`Checking…`:e.updateState===`available`?`Update`:`Check for updates`]}),(0,H.jsx)(Ub,{"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.pluginId}`,checked:e.enabled,disabled:t===e.id,onCheckedChange:()=>o(e)})]})]})},e.id))})}function Zw({markets:e,mutatingId:t,onAdd:n,onRefresh:r,onRemove:i}){return e===null?(0,H.jsx)(nT,{label:`Loading Markets…`}):e.length===0?(0,H.jsx)(tT,{icon:ii,title:`No Markets registered`,description:`Add a trusted Git repository or local catalog to make its plugins discoverable.`,action:(0,H.jsxs)(J,{size:`sm`,onClick:n,children:[(0,H.jsx)(Ir,{}),` Add Market`]})}):(0,H.jsxs)(fC,{children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`Registered Markets`}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Built-in Markets update with Rynx. User-added Markets can be refreshed independently.`})]}),(0,H.jsxs)(J,{size:`sm`,variant:`outline`,onClick:n,children:[(0,H.jsx)(Ir,{}),` Add Market`]})]}),(0,H.jsx)(hC,{className:`p-0`,children:(0,H.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:e.map(e=>(0,H.jsxs)(`article`,{className:`flex flex-col gap-3 px-5 py-4 sm:flex-row sm:items-center`,children:[(0,H.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(ii,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`strong`,{className:`font-mono text-sm`,children:e.id}),(0,H.jsx)(MC,{variant:`outline`,children:e.builtIn?`Built-in`:e.source}),(0,H.jsxs)(MC,{variant:`default`,children:[e.plugins.length,` plugins`]})]}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:e.builtIn?`Managed by Rynx · updated ${new Date(e.refreshedAt).toLocaleString()}`:`${e.id} · ${iT(e.resolvedRevision)} · refreshed ${new Date(e.refreshedAt).toLocaleString()}`})]}),!e.builtIn&&(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,H.jsxs)(J,{size:`sm`,variant:`outline`,disabled:t!==void 0,onClick:()=>r(e),children:[(0,H.jsx)(zr,{className:t===e.id?`animate-spin`:``}),`Refresh`]}),(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsx)(J,{size:`icon-sm`,variant:`ghost`,disabled:t!==void 0,"aria-label":`Remove ${e.id}`,children:(0,H.jsx)(si,{})})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsx)(vu,{children:`Remove this Market?`}),(0,H.jsxs)(yu,{children:[e.id,` will disappear from Discover. A Market with installed plugins cannot be removed until those plugins are uninstalled.`]})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>i(e),children:`Remove Market`})]})]})]})]})]},e.id))})})]})}function Qw({open:e,onOpenChange:t,onAdded:n}){let[r,i]=(0,u.useState)(``),[a,o]=(0,u.useState)(!1),s=()=>{i(``),t(!1)},c=async()=>{if(r.trim()){o(!0);try{let e=await Y.addPluginMarketplace({source:r.trim()});s(),await n(e)}catch(e){V.error(`Could not add Market: ${e.message}`)}finally{o(!1)}}};return(0,H.jsx)(Su,{open:e,onOpenChange:e=>{a||(e?t(!0):s())},children:(0,H.jsxs)(Du,{className:`sm:max-w-lg`,showCloseButton:!a,children:[(0,H.jsxs)(Ou,{children:[(0,H.jsx)(Au,{children:`Add a Market`}),(0,H.jsxs)(ju,{children:[`Register a Git repository or local directory containing`,` `,(0,H.jsx)(`code`,{children:`.rynx-plugin/marketplace.json`}),`. This reads the catalog only.`]})]}),(0,H.jsx)(`div`,{className:`grid gap-4`,children:(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`market-source`,children:`Source`}),(0,H.jsx)(Ag,{id:`market-source`,autoFocus:!0,value:r,placeholder:`owner/repo or https://github.com/owner/repo`,onChange:e=>i(e.target.value)}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`GitHub shorthand, a credential-free Git URL, or an absolute local path.`})]})}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(J,{variant:`outline`,disabled:a,onClick:s,children:`Cancel`}),(0,H.jsxs)(J,{disabled:a||!r.trim(),onClick:()=>void c(),children:[a?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(ii,{}),a?`Adding…`:`Add Market`]})]})]})})}function $w({preparation:e,committing:t,onCancel:n,onCommit:r}){let i=e?.artifact;return(0,H.jsx)(Su,{open:!!e,onOpenChange:e=>{!e&&!t&&n()},children:(0,H.jsx)(Du,{className:`max-h-[calc(100dvh-2rem)] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 overflow-hidden p-0 sm:max-w-2xl`,children:e&&i&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(Ou,{className:`px-5 pb-4 pr-12 pt-5`,children:[(0,H.jsxs)(Au,{children:[`Review `,e.existing?`plugin update`:`plugin installation`]}),(0,H.jsx)(ju,{children:`Rynx inspected an immutable package snapshot. Confirm its source and executable entries before the active installation changes.`})]}),(0,H.jsx)(U_,{className:`min-h-0`,children:(0,H.jsxs)(`div`,{className:`grid gap-3 px-5 pb-5`,children:[(0,H.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-[var(--border)] bg-[var(--muted)]/25 p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`strong`,{children:i.pluginId}),(0,H.jsx)(MC,{variant:`outline`,children:i.marketplaceId}),(0,H.jsxs)(MC,{variant:`default`,children:[`v`,i.version]})]}),(0,H.jsx)(`div`,{className:`font-mono text-[10px] text-[var(--muted-foreground)]`,children:i.id}),(0,H.jsx)(`div`,{className:`break-all font-mono text-[10px] leading-relaxed text-[var(--muted-foreground)]`,children:i.digest}),(0,H.jsxs)(`dl`,{className:`grid gap-2 border-t border-[var(--border)] pt-3 text-xs`,children:[(0,H.jsx)(eT,{label:`Source`,children:i.resolvedSource.type===`git`?i.resolvedSource.repository:`Local directory (path hidden)`}),(0,H.jsx)(eT,{label:`Subdirectory`,children:i.resolvedSource.subdirectory}),i.resolvedSource.type===`git`&&(0,H.jsx)(eT,{label:`Commit`,children:i.resolvedSource.commit})]}),(i.runtimeEntry||i.settingsBackgroundEntry||i.commandsEntry||i.settingsUiEntry||i.skillDirectory)&&(0,H.jsxs)(`div`,{className:`grid gap-2 border-t border-[var(--border)] pt-3`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium`,children:`Included components`}),(0,H.jsxs)(`dl`,{className:`grid gap-2 text-xs`,children:[i.runtimeEntry&&(0,H.jsx)(eT,{label:i.runtimeEntry.type===`module`?`Runtime module`:`Runtime process`,children:i.runtimeEntry.type===`module`?i.runtimeEntry.entry:[i.runtimeEntry.command,...i.runtimeEntry.args].join(` `)}),i.commandsEntry&&(0,H.jsx)(eT,{label:`Commands`,children:i.commandsEntry}),i.settingsUiEntry&&(0,H.jsx)(eT,{label:`Settings UI`,children:i.settingsUiEntry}),i.settingsBackgroundEntry&&(0,H.jsx)(eT,{label:i.settingsBackgroundEntry.type===`module`?`Settings background`:`Settings process`,children:i.settingsBackgroundEntry.type===`module`?i.settingsBackgroundEntry.entry:[i.settingsBackgroundEntry.command,...i.settingsBackgroundEntry.args].join(` `)}),i.skillDirectory&&(0,H.jsx)(eT,{label:`Skills`,children:i.skillDirectory})]})]})]}),e.existing&&(0,H.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--warning)]/35 bg-[var(--warning)]/10 p-3 text-xs`,children:[(0,H.jsx)(ci,{className:`mt-0.5 size-4 shrink-0 text-[var(--warning)]`}),`This replaces `,e.existing.id,` v`,e.existing.version,`. Its enabled state and plugin-owned data are retained.`]})]})}),(0,H.jsxs)(ku,{className:`mx-0 mb-0 rounded-none rounded-b-xl px-5 py-3`,children:[(0,H.jsx)(J,{variant:`outline`,disabled:t,onClick:n,children:`Cancel`}),(0,H.jsxs)(J,{disabled:t,onClick:r,children:[t?(0,H.jsx)(B,{className:`animate-spin`}):e.existing?(0,H.jsx)(zr,{}):(0,H.jsx)(Yn,{}),t?e.existing?`Updating…`:`Installing…`:e.existing?`Update plugin`:`Install plugin`]})]})]})})})}function eT({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`grid gap-0.5 sm:grid-cols-[7rem_minmax(0,1fr)] sm:gap-3`,children:[(0,H.jsx)(`dt`,{className:`text-[var(--muted-foreground)]`,children:e}),(0,H.jsx)(`dd`,{className:`min-w-0`,children:(0,H.jsx)(`code`,{className:`break-all text-[11px]`,children:t})})]})}function tT({icon:e,title:t,description:n,action:r}){return(0,H.jsx)(fC,{children:(0,H.jsxs)(hC,{className:`grid justify-items-center gap-3 py-12 text-center`,children:[(0,H.jsx)(`span`,{className:`grid size-11 place-items-center rounded-xl bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(e,{className:`size-5`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:t}),(0,H.jsx)(`p`,{className:`mt-1 max-w-md text-xs text-[var(--muted-foreground)]`,children:n})]}),r]})})}function nT({label:e}){return(0,H.jsx)(fC,{children:(0,H.jsxs)(hC,{className:`flex items-center justify-center gap-2 py-12 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),e]})})}function rT({error:e,retrying:t,onRetry:n}){return(0,H.jsx)(fC,{role:`alert`,children:(0,H.jsxs)(hC,{className:`grid justify-items-center gap-3 py-12 text-center`,children:[(0,H.jsx)(`span`,{className:`grid size-11 place-items-center rounded-xl bg-[var(--danger)]/10 text-[var(--danger)]`,children:(0,H.jsx)(ci,{className:`size-5`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:`Rynx Runtime is unavailable`}),(0,H.jsx)(`p`,{className:`mt-1 max-w-md text-xs text-[var(--muted-foreground)]`,children:`Plugin catalogs could not be loaded. Rynx will retry automatically.`}),(0,H.jsx)(`p`,{className:`mt-2 max-w-md break-all font-mono text-[10px] text-[var(--danger)]`,children:e})]}),(0,H.jsxs)(J,{size:`sm`,variant:`outline`,disabled:t,onClick:n,children:[(0,H.jsx)(zr,{className:t?`animate-spin`:``}),t?`Retrying…`:`Retry now`]})]})})}function iT(e){return e===`local`||e.length<=12?e:e.slice(0,12)}function aT({plugin:e}){if(!e.enabled)return null;let t=e.runtimeState,n=t===`absent`?`Unavailable`:t.charAt(0).toUpperCase()+t.slice(1);return(0,H.jsx)(`span`,{className:X(`rounded-full border border-[var(--border)] px-2 py-0.5 font-mono text-[10px]`,t===`running`&&`text-[var(--success)]`,(t===`failed`||t===`degraded`)&&`text-[var(--danger)]`,(t===`stopped`||t===`absent`)&&`text-[var(--muted-foreground)]`),children:n})}function oT({plugin:e,theme:t,onChange:n}){let r=(0,u.useRef)(null),i=(0,u.useRef)(()=>void 0),a=(0,u.useRef)(null),o=(0,u.useRef)(void 0),s=(0,u.useRef)(void 0),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(),[p,m]=(0,u.useState)(),h=(0,u.useCallback)((e,t)=>{let n=Vw(e);return s.current?Promise.reject(Error(`another external link confirmation is already open`)):new Promise((e,r)=>{let i=!1,a,o=()=>{t.removeEventListener(`abort`,c),s.current===a&&(s.current=void 0,m(void 0))},c=()=>{i||(i=!0,o(),r(Error(`external link request was cancelled`)))};a={url:n,settle(t){i||(i=!0,o(),t&&window.open(n,`_blank`,`noopener,noreferrer`),e({opened:t}))}},s.current=a,m(a),t.aborted?c():t.addEventListener(`abort`,c,{once:!0})})},[]);(0,u.useEffect)(()=>{let t=new AbortController;return i.current(),o.current=void 0,l(void 0),f(void 0),Y.pluginSettingsUi(e.id,t.signal).then(l).catch(e=>{t.signal.aborted||f(e.message)}),()=>{t.abort(),i.current()}},[e.id,e.updatedAt]),(0,u.useEffect)(()=>{a.current?.postMessage(sT(t))},[t]);let g=(0,u.useCallback)(()=>{if(i.current(),!c||!r.current?.contentWindow)return;let o=new MessageChannel,s=new Set,l=new Set,u=!0,d=0,f=e=>{if(!u)return;let t=uT(e);o.port1.postMessage(t)};o.port1.onmessage=t=>{let r=lT(t.data);if(!r.ok){f({id:r.id,error:r.error});return}if(l.has(r.id)){f({id:r.id,error:`duplicate request id`});return}if(d>=Ww){f({id:r.id,error:`too many requests in flight`});return}l.add(r.id),d+=1;let i=new AbortController;s.add(i);let a=window.setTimeout(()=>i.abort(),Gw);cT(e.id,c.generation,h,r.method,r.params,i.signal).then(e=>{f({id:r.id,result:e}),r.method!==`host.openExternal`&&n()}).catch(e=>{f({id:r.id,error:i.signal.aborted?`request timed out`:e.message})}).finally(()=>{window.clearTimeout(a),s.delete(i),l.delete(r.id),--d})},o.port1.onmessageerror=()=>{f({id:null,error:`invalid plugin UI message`})},o.port1.start(),a.current=o.port1,r.current.contentWindow.postMessage({type:`rynx-plugin-connect`,pluginId:e.id,appearance:{colorScheme:t}},`*`,[o.port2]),i.current=()=>{if(u){u=!1;for(let e of s)e.abort();s.clear(),l.clear(),a.current===o.port1&&(a.current=null),o.port1.close(),o.port2.close()}}},[c,n,e.id,h,t]),_=(0,u.useCallback)(()=>{if(c){if(o.current===c.generation){i.current();return}o.current=c.generation,g()}},[g,c]);return d?(0,H.jsx)(`div`,{className:`p-5 text-sm text-[var(--danger)]`,children:d}):c?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`iframe`,{ref:r,title:`${e.pluginId} settings`,className:`h-[calc(100dvh-10rem)] min-h-[28rem] max-h-[64rem] w-full border-0 bg-[var(--background)]`,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,srcDoc:c.html,onLoad:_}),(0,H.jsx)(Bw,{open:!!p,url:p?.url??``,onOpenChange:e=>{e||p?.settle(!1)},description:(0,H.jsxs)(H.Fragment,{children:[`The `,e.pluginId,` plugin wants to open this address in a new browser tab. Review the complete destination before continuing.`]}),onConfirm:()=>p?.settle(!0)})]}):(0,H.jsx)(`div`,{className:`p-5 text-sm text-[var(--muted-foreground)]`,children:`Loading plugin UI…`})}function sT(e){return{type:`rynx-host-appearance`,appearance:{colorScheme:e}}}async function cT(e,t,n,r,i,a){if(r===`host.openExternal`)return n(i,a);if(r.startsWith(`host.`))throw Error(`unknown Rynx host settings method "${r}"`);return Y.pluginSettingsCall(e,t,r,i,a)}function lT(e){let t;try{t=dT(e)}catch{return{ok:!1,id:null,error:`request is not serializable`}}if(t>Uw)return{ok:!1,id:null,error:`request exceeds 1 MiB`};if(typeof e!=`object`||!e||Array.isArray(e))return{ok:!1,id:null,error:`request must be an object`};let n=e,r=typeof n.id==`string`||typeof n.id==`number`&&Number.isSafeInteger(n.id)?n.id:null;return r===null||typeof n.method!=`string`||!qw.test(n.method)?{ok:!1,id:r,error:`request id or method is invalid`}:{ok:!0,id:r,method:n.method,params:n.params}}function uT(e){try{return dT(e)<=Uw?e:{id:fT(e),error:`response exceeds 1 MiB`}}catch{return{id:fT(e),error:`response is not serializable`}}}function dT(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength}function fT(e){if(typeof e!=`object`||!e)return null;let t=e.id;return typeof t==`string`||typeof t==`number`?t:null}function pT(e){let t=[...new Set(e.directories.map(e=>e.trim()).filter(Boolean))],n=e.primary.trim();return{name:e.name.trim()||mT(n),directories:t,primary:n}}function mT(e){let t=e.trim().replace(/[\\/]+$/,``);if(!t||/^[A-Za-z]:$/.test(t))return``;let n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return t.slice(n+1)}var hT={name:``,directories:[],primary:``},gT=`local`;function _T(){let e=$e(),[t,n]=(0,u.useState)([]),[r,i]=(0,u.useState)(!0),[a,o]=(0,u.useState)(),[s,c]=(0,u.useState)(()=>e.state?.createProject===!0?`new`:null),l=(0,u.useRef)(0);async function d(e=!1){let t=++l.current;e&&i(!0);try{let e=await Y.listProjects(gT);if(t!==l.current)return;n(e),o(void 0)}catch(e){if(t!==l.current)return;n([]),o(`Could not load projects: ${e.message}`)}finally{t===l.current&&i(!1)}}return(0,u.useEffect)(()=>(n([]),o(void 0),i(!0),d(),()=>{l.current+=1}),[]),(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(fC,{children:[(0,H.jsxs)(pC,{className:`flex-wrap`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(mC,{children:[`Projects`,` `,(0,H.jsx)(`span`,{className:`ml-1 text-[var(--muted-foreground)]`,children:t.length})]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:`Reusable source directories stored on This device.`})]}),(0,H.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-2 sm:flex-none`,children:(0,H.jsxs)(J,{size:`sm`,onClick:()=>c(`new`),children:[(0,H.jsx)(Ir,{}),` New project`]})})]}),(0,H.jsx)(hC,{className:`p-0`,children:r?(0,H.jsxs)(`div`,{className:`flex min-h-36 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,role:`status`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),` Loading projects…`]}):a?(0,H.jsxs)(`div`,{className:`grid min-h-36 place-items-center gap-3 px-5 py-8 text-center`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`Projects are unavailable`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:a})]}),(0,H.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>void d(!0),children:`Retry`})]}):t.length===0?(0,H.jsx)(`div`,{className:`grid min-h-44 place-items-center px-5 py-8 text-center`,children:(0,H.jsxs)(`div`,{className:`max-w-sm`,children:[(0,H.jsx)(`span`,{className:`mx-auto flex size-10 items-center justify-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(ar,{className:`size-5`})}),(0,H.jsx)(`p`,{className:`mt-3 text-sm font-medium`,children:`No projects on this device`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:`Save one or more directories so a new Session can start in the same workspace.`}),(0,H.jsxs)(J,{className:`mt-4`,size:`sm`,onClick:()=>c(`new`),children:[(0,H.jsx)(Ir,{}),` New project`]})]})}):(0,H.jsx)(`ul`,{className:`divide-y divide-[var(--border)]`,children:t.map(e=>(0,H.jsx)(vT,{project:e,onEdit:()=>c(e),onDeleted:()=>void d()},e.id))})})]}),(0,H.jsx)(yT,{open:s!==null,project:s===`new`?void 0:s??void 0,onOpenChange:e=>{e||c(null)},onSaved:async()=>{c(null),await d()}},s===`new`?`new`:s?.id??`closed`)]})}function vT({project:e,onEdit:t,onDeleted:n}){let[r,i]=(0,u.useState)(!1);async function a(){i(!0);try{await Y.deleteProject(gT,e.id),V.success(`Project "${e.name}" removed`),n()}catch(e){V.error(`Delete failed: ${e.message}`)}finally{i(!1)}}return(0,H.jsxs)(`li`,{className:`grid gap-3 px-5 py-4 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(sr,{className:`size-4 shrink-0 text-[var(--primary)]`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,H.jsxs)(`span`,{className:`rounded-md bg-[var(--muted)] px-1.5 py-0.5 font-mono text-[9px] text-[var(--muted-foreground)]`,children:[e.directories.length,` `,e.directories.length===1?`folder`:`folders`]})]}),(0,H.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-1.5 pl-6 font-mono text-[10px] text-[var(--muted-foreground)]`,children:[(0,H.jsx)(ri,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`truncate`,title:e.primary,children:e.primary})]})]}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-1.5`,children:[(0,H.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:t,children:[(0,H.jsx)(Pr,{}),` Edit`]}),(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsx)(J,{variant:`ghost`,size:`icon-sm`,className:`text-[var(--destructive)]`,"aria-label":`Delete ${e.name}`,disabled:r,children:r?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(si,{})})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[`Remove project “`,e.name,`”?`]}),(0,H.jsx)(yu,{children:`This removes only the saved project. It does not delete any directories or affect existing Sessions.`})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>void a(),children:`Remove project`})]})]})]})]})]})}function yT({open:e,project:t,onOpenChange:n,onSaved:r}){let i=wS(),a=!!i?.chooseDirectory,[o,s]=(0,u.useState)(()=>t?{name:t.name,directories:[...t.directories],primary:t.primary}:{...hT}),[c,l]=(0,u.useState)(!1),[d,f]=(0,u.useState)(!1),p=(0,u.useMemo)(()=>bT(o),[o]);function m(){s(e=>({...e,directories:[...e.directories,``]}))}async function h(){let e=await i?.chooseDirectory?.();e&&s(t=>t.directories.includes(e)?t:{...t,directories:[...t.directories,e],primary:t.primary||e})}function g(e,t){s(n=>{let r=n.directories[e]??``,i=n.directories.map((n,r)=>r===e?t:n),a=n.primary;return a===r&&(a=t),!a&&t&&(a=t),{...n,directories:i,primary:a}})}function _(e){s(t=>{let n=t.directories[e],r=t.directories.filter((t,n)=>n!==e);return{...t,directories:r,primary:t.primary===n?r.find(Boolean)??``:t.primary}})}async function v(){if(f(!0),p)return;let e=pT(o);l(!0);try{t?(await Y.updateProject(gT,t.id,e),V.success(`Project "${e.name}" updated`)):(await Y.createProject(gT,e),V.success(`Project "${e.name}" created`)),await r()}catch(e){V.error(`Save failed: ${e.message}`)}finally{l(!1)}}return(0,H.jsx)(Su,{open:e,onOpenChange:n,children:(0,H.jsxs)(Du,{className:`sm:max-w-2xl`,children:[(0,H.jsxs)(Ou,{children:[(0,H.jsx)(Au,{children:t?`Edit project`:`Create project`}),(0,H.jsx)(ju,{children:`These paths belong to This device. The Primary directory becomes the Session working directory; every listed directory is available to the Session.`})]}),(0,H.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),v()},children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`project-name`,children:`Name`}),(0,H.jsx)(Ag,{id:`project-name`,value:o.name,onChange:e=>s(t=>({...t,name:e.target.value})),placeholder:`Defaults to Primary folder name`,maxLength:128,autoFocus:!0})]}),(0,H.jsxs)(`div`,{className:`grid gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(GS,{children:`Source directories`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:`Choose local folders or enter absolute paths.`})]}),(0,H.jsxs)(`div`,{className:`flex gap-1.5`,children:[a&&(0,H.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void h(),children:[(0,H.jsx)(ar,{}),` Choose folder`]}),(0,H.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:m,children:[(0,H.jsx)(Ir,{}),` `,a?`Enter path`:`Add path`]})]})]}),(0,H.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-[var(--border)]`,children:o.directories.length===0?(0,H.jsxs)(`button`,{type:`button`,className:`flex min-h-24 w-full items-center justify-center gap-2 text-sm text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)]`,onClick:a?()=>void h():m,children:[(0,H.jsx)(ar,{className:`size-4`}),a?`Choose a source folder`:`Add an absolute directory path`]}):(0,H.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:o.directories.map((e,t)=>{let n=e!==``&&e===o.primary;return(0,H.jsxs)(`div`,{className:`grid gap-2 p-2.5 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,H.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,H.jsx)(sr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-[var(--muted-foreground)]`}),(0,H.jsx)(Ag,{value:e,onChange:e=>g(t,e.target.value),placeholder:`/Users/name/Workspace/project`,className:`pl-8 font-mono text-xs`,"aria-label":`Source directory ${t+1}`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,H.jsxs)(J,{type:`button`,variant:n?`secondary`:`ghost`,size:`sm`,className:X(n&&`text-[var(--primary)]`),disabled:!e.trim(),onClick:()=>s(t=>({...t,primary:e})),children:[n?(0,H.jsx)(Pn,{}):(0,H.jsx)(ri,{}),n?`Primary`:`Make primary`]}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Remove source directory ${t+1}`,onClick:()=>_(t),children:(0,H.jsx)(di,{})})]})]},t)})})}),d&&p&&(0,H.jsx)(`p`,{className:`text-xs text-[var(--destructive)]`,role:`alert`,children:p})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,H.jsxs)(J,{type:`submit`,disabled:c,children:[c?(0,H.jsx)(B,{className:`animate-spin`}):null,t?`Save changes`:`Create project`]})]})]})]})})}function bT(e){let t=pT(e);if(!t.name)return`Enter a project name.`;if(t.directories.length===0)return`Add at least one source directory.`;if(t.directories.some(e=>!xT(e)))return`Every source directory must be an absolute path.`;if(!t.primary||!t.directories.includes(t.primary))return`Choose one listed directory as Primary.`}function xT(e){return e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}var ST={codex:{src:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAGcklEQVR42s2YbayXZR3HP9efc3g4wEEcgiKSIuQENCnEkUo5ZeUxS4eVtnzR1gpdTzO1CNfDirlc9aJMrfmi1Zo2K2wtQsk0TM6gLWxATUklFQNFoIOcwznA+fSi7023twcQa617++9/77qvh9/j9/f9XfB/9pTXM0ktQCmlDKonAvOBWUAnsBv4C7CmlLI9c1uAzW1KKf7HEucA1AnqEnW9+pK6V92v9qkvZvwW9fgj7NVSh1V7HpOFqkWlFNXZwNeBLqAfWAlsBF4BjgPmARcAB4FfAo/EeqcB+4CtwHpgdSmlX21l78E3YqEp6kr/9SxXL81Yh9oejTvVT6l7PPzznHqPellt72HN89oOI0RbYmAUcD3wLuBe4HOllGcbcztiobnAGGAb8DiwGdgOjIyl5gBXA+eqk4CfAL1q64iWip/b8j5bfVn9q3p6XSt1hHq+ert6IFb4nfrxBP6r3K/OU7+j7lN3qNdUMXXUAM77OPUmdVBdFgFa+Z+mfjZuUN2cgJ5cWz9cHTHEGV9OIqxT5xzOdTQ2eqv6LXWb2pO4aY+mXeqaCLJd/Z46q+5udZK6SH2/Or4K4ig0Sr0v62/Nnm2Hc1W7ekMEqZ5d6twsHKmuyvgKdUHNJdXvktqcgbwvbEDItfn2sHpC0zvUNFim9kage9Q/JXPelu+jY+rd6hV1U6tnqz/IN9Un1A15f1n9fuADdYb6uPqUOu81AmXgg1m4O+Y+TX1QfaUmUIfaHWC8MGOnqF9UN6r9EeJG9Uz1DPXz6gsR7KnE5cxYeJfaNZSFxqu/zaIlMf3ECLSnIdC6WPCqxEh3A2/uUMfU9h6rzle/28jGreom9YKES6nj0PnA2cA64L6g84QhkHxYkHoscAMwExgHLAf6gEuBK4EO9X7gwVLKHqBb3Qw8DFwLvDf7PQ8MpEb+u/6ptwUflsYKJS5bFQudm3mdsZrRtlu9Tj0p6P0JdW2+P5MUn1vPInWq+pmai7+R2GzVXXZvNvlIbezUHN6jnhUhO5MZAwG5aUNk6zT1rhxmYmpxFKzjXJf6fDDpw9V4q/Ffh/BWXNoC2kId9qUU9AA/K6U8HVxpVRhTSnka+CnwJNALvAm4E7gDWBilhpdSVgBLs/9i9bi6IM+lUp+stteYQD/QASxKTB2I0AUYGY33l1IGU4/2Z6wdmAg8ASwGHgUWhgl8NDFWgDXAauDNwCV1gbqBncBFwKmZ/BKwKoIuSeBenYJ74Cjkzli3L0X5CuCrGXsPMDEW/1uoyvEhfYcEeijVeQHw9pp77gYuB34TvnMXcAbwYiwj0F65DGivrbXm7p1x49643PChgWTaMGDqIYFKKbvi50FgmdpVShkopfQAD8Ts10ejDmAGcJU6rZTSV7mslNKXQF8UgrYPGBWLH4wgBxr09rXxGw1HJwX7k5KfVqc2iuZc9SvqlmTQ2qT6lKT+dYGCCgAfUDuz/pxk7OqUjhKIWRrIuW2oWnZeDUdU7w8aT6gTMvXK1K2/qzvVH6s/z5qd6mPh3KvVsbVa16M+Wqtp03PejjqTrKp1S70wcL5V/X0OOJhyML/aPGvGZLz+rEkdXJTysk4d3RBotTo5Zy7JuoeqtG92Fl3R8NfqLPXmFERTIJekYJ6ZIrkh5t4QgjYl+yxIAe5uCLQnAk2PlXenoH/gcK3OeYH89TXKOivIuyOCbQy1qLjS3epZdeJeO2xtVWgj0D/UP4favBCq87V62DQFOkF9JHB+TePbRaEM/XHjr9R31glazTorIvAqdWTG3xJrVM+2kMH2VwnTyKISWmm0GNGgn+PU96mXp3GsE7RZobPba/HUVVFU9eJYaLv6TXWOOvxIXLrqJuaof4g5bxliXnujek9O/Gyu9V83qqc3GoMvpWG4SR03VGMxpFD5fSgx06d+Oy1Macw9Sf1YyFZFR25PazSioeQ09cm4bHbNI62jNYrm94tA/BeATwIXA+vVZ4K+JwLTgXPy/iPgh7lw6D3Up5dyUD0ldWwGcCuwJYL6ulrpRlxcllh6dojWeDD/e4LqndG6PeA5Je3T8sxbWcHCMV/H1C8DYv4FaYVPBkYAW8KJ3pHi2wY8Fgq8Ky31bODdmb8CuLmUsql+iXHM1zCJp9YR5oxPLfpjsqc3VzR7A4zr03VMOGoAv5ELqyHWDqYhmBQ+MzPXMz3AJqC7lLKtIvD/lQur//XzT+4u16KSSLsQAAAAAElFTkSuQmCC`,monochrome:!0},claude:{src:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAEYElEQVR4nMVXW4hVVRjedrMii+6FRRRFUQ9iVNAFKipoKAeC1vrXGTUkSn0xGpyz/nVmHjpRYJQvZQ+R0EOXhyQksQsVKFo9WBORdc6sf59RiWlUyCmly5SWJ/69195n7T3nOo31w2Lm/Ovyf+v7b2sHQQcZXbnyVCoVrpsYFGcE/4eQgdcJoU6oDo2PqMubrakOL7uUNGwkLW6ZU+PVtQNXxMbjYTU83x4kfDenALaX7zqFEI54IH6ulMVZMwAgTLr5z+cUAAtp+ZTPQqjVE4En9XL5JEI4FjGE8FqQkxDVUIhqNERYFcxGamv65ocIoQdib12Ik5N5Wlu4IAVnoOjvJVTDqfsQfuO1bY2NG3E1aVkaQ3VbBgTKJZlYQLksnSuJ6xsA5L2pcQOP+XsIYcoH3lRIw2du8V+Mvh4E85I5i/BRaggh5PiI9FrenejHSg+dH4EqijsJ4WjGdaiGOtIdImzKoDawdbcZONe76bGUBSMfjUGr5Y7i76N1eullhHAwaxw2+ZdpKVXOZ4RtOer2WK1uciy84un3VcritMTPoZFbOF4I1a7c/mqzzGkpdY5qLUv+bQnhTzJq0AH8xbvZKkJ4yf1+mlC+nDP+aw0LNwSzETJwc6jh2+yB8j1r5Iue7muL8JZz186c8Xpo1Irg30htTd98i+qZXED97f1/nBB+yBt2pfvtZmfuK684vWbU4lp56dndAzFqMSHsbm5o5uCc52Dcg+KcUBfuCzWMuACnOMOidYfTBlcZFOftLy85sxMbhLDOO6DlCBF+4uDLseUPPuPd6GAaEQsJ4Q83Mc11PfK9gZ0c2YTqDfa7Raldyq3rlglvHOCUJqPKhNBndf+CzO0oimD4wlE06W7Qq5FM6kXtGeGR0Axc1bWvm9HOhYhrOB9ULQ5cw/7sYJzpHSOEHYRyM/ueBzcqi/IFaxSSUdCxLOeFHyOhgTdd5LcDMMW1gTtgh3j5JCnnbYX9ZQ08Swi/JxFOBjZEf1seLjdzlYz3Fu6P9sd1Ytpbd5gzpaVhpohQPh4FUCO6t9eKcCMhVBJDbUB8nA+2OJPEHXxu0mOaitXi2lxNP2KNXM1l2iK843Tb0pZrYEOSctyULMJXMWA1une4cHHQi1gjV2fo1fB+8hi1Gp50+h85fUMtn4vXqHsI1avZHpGyM26HxJVdGa8HwbxGE1KHOO9TYCV5uyvJx0NUD7COiwmv5YZTK4kLXQDGgTgiFvIj1v2e7LopWa0eZmp96uIuKPc7RtYnekI5EencU4vzvtGI5JZIF7tpOr7QLJ7to/xhgupTx8oujm7WV4riEmfsqP/YIC0/zD/dCGGRK3IHegZgG+33oO/LsAgPumifmFEvGpV0anxo+UUxs/0LmN2ejFMUXGlzWZSZi+s6G/lyBmiUMmVBq/6eb50IFxEuq7WSuDXICSF84FJwa34umtewngx8w608OBFCydeQho0nxEDQCQDfkGu9l6r/PYhOXzpdyD/VGsqNWs3dHgAAAABJRU5ErkJggg==`,monochrome:!1},traex:{src:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAF9SURBVHgB7Zm9SsNQFMf/EYWiVB2KKGLBScHFN9BJurmoa0dn9QGqD1CdHbtWFzd10jfQQdBJqIgKGYw4VCR+nGD0ptqmsSectD0/CKXpbXJ+3HvOyYfVP5B+RxvTgzZHBaRRAWlUQBoVkEYFpOkNGzC0MgtJnPJZw99DBcZ2FiFJmIDmgDSdn8S1PB9d4aFwiDgY2cwhnZuK9J/IAq5TxevNI+Lg7amKqGgO/DrgYIplTNPnAyN9E8OYPF5FZmOu7hgKPrufZ+svkXOgHhR8di/vfWbW5719dvE0MMYPPjUz6m3E3doBWoFlBszgfUjCnAkzeB+6TGl1JuJNYuOJk/W1ccMiQGW1slwKlFe7eAJ7+2cJuZ8lsrJUwsvF/fc+us5JxBIiTIna4H1MCY7gCbYkJij464Xdhg3Jl3D/0bT+gj0HmummXMET2omlCc2By/GtwHeq3dO3BSQFXULSdN8dGdV6p3yOpGDpOzJhVEAaFZBGBaRRAWlUQJoPEeV5RYlN/QYAAAAASUVORK5CYII=`,monochrome:!1}},CT=`local`,wT={starting:`Starting…`,installing:`Installing…`,updating:`Updating…`,verifying:`Verifying installation…`,complete:`Complete`};function TT(){let[e,t]=(0,u.useState)(null),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(!1),[o,s]=(0,u.useState)({}),c=(0,u.useRef)(0),l=(0,u.useCallback)(async(e=!1)=>{let n=++c.current;e&&a(!0),r(null);try{let e=await Y.listProviderClis(CT);n===c.current&&t(e)}catch(e){n===c.current&&(t(null),r(e instanceof Error?e.message:String(e)))}finally{n===c.current&&a(!1)}},[]);(0,u.useEffect)(()=>{l()},[l]);let d=async(e,t)=>{try{let n=(await Y.startProviderCliOperation(CT,e,t)).job;for(s(t=>({...t,[e]:n}));n.state===`running`;)await PT(750),n=await Y.getProviderCliJob(CT,n.id),s(t=>({...t,[e]:n}));n.state===`succeeded`?(V.success(`${NT(e)} ${t} completed`),await l(),s(t=>{let n={...t};return delete n[e],n})):V.error(n.error??`${NT(e)} ${t} failed`)}catch(t){V.error(t.message),s(t=>{let n={...t};return delete n[e],n})}};return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Providers`}),(0,H.jsx)(`p`,{className:`mt-1 max-w-2xl text-xs text-[var(--muted-foreground)]`,children:`Inspect and manage the coding-agent providers installed on this device.`})]}),(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:i,onClick:()=>void l(!0),children:[(0,H.jsx)(zr,{className:i?`animate-spin`:``}),`Refresh`]})})]}),n&&(0,H.jsxs)(`div`,{className:`rounded-lg border border-[var(--destructive)]/35 bg-[var(--destructive)]/8 px-4 py-3 text-sm`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-[var(--destructive)]`,children:[(0,H.jsx)(ci,{className:`size-4`}),` Could not inspect Providers`]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:n}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,className:`mt-3`,onClick:()=>void l(!0),children:[(0,H.jsx)(zr,{}),` Retry`]})]}),e===null&&!n?(0,H.jsx)(`div`,{className:`grid gap-3`,"aria-label":`Loading Providers`,children:[0,1,2].map(e=>(0,H.jsx)(DT,{},e))}):(0,H.jsx)(`div`,{className:`grid gap-3`,children:e?.providerClis.map(t=>(0,H.jsx)(ET,{provider:t,job:o[t.id],readOnly:e.management===`read_only`,onOperation:d},t.id))})]})}function ET({provider:e,job:t,readOnly:n,onOperation:r}){let i=e.availability===`installed`?e.updateState===`available`&&e.canUpdate?`update`:void 0:e.canInstall?`install`:void 0,a=t?.state===`running`;return(0,H.jsx)(fC,{className:`min-w-0`,children:(0,H.jsxs)(hC,{className:`grid gap-3 p-4 text-xs`,children:[(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-[12rem_minmax(14rem,1.5fr)_minmax(8rem,0.65fr)_minmax(13rem,0.9fr)_11rem] xl:items-center`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 md:col-span-2 xl:col-span-1`,children:[(0,H.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--background)]`,children:(0,H.jsx)(`img`,{src:ST[e.id].src,alt:``,"aria-hidden":`true`,className:X(`size-full object-cover`,ST[e.id].monochrome&&`brightness-0 dark:invert`)})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(mC,{children:e.name}),(0,H.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-[var(--muted-foreground)]`,children:e.binary})]})]}),(0,H.jsx)(kT,{icon:yr,label:`Executable`,value:e.executablePath??`Not found on Runtime PATH`,mono:!0}),(0,H.jsx)(kT,{icon:zr,label:`Version`,value:jT(e),mono:!0,noWrap:!0}),(0,H.jsx)(kT,{icon:mr,label:`Authentication`,value:MT(e)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 md:col-span-2 xl:col-span-1 xl:justify-end`,children:[(0,H.jsx)(OT,{provider:e}),!n&&i&&(0,H.jsx)(AT,{provider:e,operation:i,disabled:a,onConfirm:()=>r(e.id,i)})]})]}),e.error&&(0,H.jsx)(`p`,{className:`rounded-md bg-[var(--destructive)]/8 px-2.5 py-2 text-[11px] text-[var(--destructive)]`,children:e.error}),t&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-[var(--muted)]/45 px-2.5 py-2 text-[11px]`,children:[a?(0,H.jsx)(zr,{className:`size-3.5 animate-spin text-[var(--primary)]`}):t.state===`succeeded`?(0,H.jsx)(Vn,{className:`size-3.5 text-[var(--success)]`}):(0,H.jsx)(ci,{className:`size-3.5 text-[var(--destructive)]`}),(0,H.jsx)(`span`,{children:t.error??wT[t.stage]})]})]})})}function DT(){return(0,H.jsxs)(`div`,{"aria-hidden":`true`,className:`grid animate-pulse gap-4 rounded-xl border border-[var(--border)] p-4 md:grid-cols-2 xl:grid-cols-[12rem_minmax(14rem,1.5fr)_minmax(8rem,0.65fr)_minmax(13rem,0.9fr)_11rem] xl:items-center`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3 md:col-span-2 xl:col-span-1`,children:[(0,H.jsx)(`div`,{className:`size-9 rounded-lg bg-[var(--muted)]`}),(0,H.jsxs)(`div`,{className:`grid gap-2`,children:[(0,H.jsx)(`div`,{className:`h-3.5 w-20 rounded bg-[var(--muted)]`}),(0,H.jsx)(`div`,{className:`h-2.5 w-12 rounded bg-[var(--muted)]`})]})]}),[`w-full`,`w-24`,`w-32`].map((e,t)=>(0,H.jsxs)(`div`,{className:`grid gap-2`,children:[(0,H.jsx)(`div`,{className:`h-2.5 w-16 rounded bg-[var(--muted)]`}),(0,H.jsx)(`div`,{className:`h-3 rounded bg-[var(--muted)] ${e}`})]},t)),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 md:col-span-2 xl:col-span-1 xl:justify-end`,children:[(0,H.jsx)(`div`,{className:`h-5 w-24 rounded-full bg-[var(--muted)]`}),(0,H.jsx)(`div`,{className:`h-8 w-24 rounded-md bg-[var(--muted)]`})]})]})}function OT({provider:e}){return e.availability===`missing`?(0,H.jsx)(MC,{variant:`warning`,children:`Not installed`}):e.availability===`broken`?(0,H.jsx)(MC,{variant:`destructive`,children:`Unavailable`}):e.updateState===`available`?(0,H.jsx)(MC,{variant:`warning`,children:`New version`}):(0,H.jsx)(MC,{variant:`success`,children:`Installed`})}function kT({icon:e,label:t,value:n,mono:r=!1,noWrap:i=!1}){return(0,H.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] gap-x-2`,children:[(0,H.jsx)(e,{className:`mt-0.5 size-3.5 text-[var(--muted-foreground)]`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-[var(--muted-foreground)]`,children:t}),(0,H.jsx)(`div`,{className:X(`mt-0.5`,r&&`font-mono text-[11px]`,r&&!i&&`break-all`,i&&`whitespace-nowrap`),children:n})]})]})}function AT({provider:e,operation:t,disabled:n,onConfirm:r}){let i=t===`install`?`Install`:`Update`;return(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsxs)(J,{size:`sm`,className:`w-full sm:w-auto`,disabled:n,children:[n?(0,H.jsx)(zr,{className:`animate-spin`}):(0,H.jsx)(Yn,{}),n?`Working…`:i]})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[i,` `,e.name,`?`]}),(0,H.jsxs)(yu,{children:[`Rynx will run `,e.name,`'s official `,t,` mechanism on this Runtime. The daemon will verify the executable and version when it finishes.`]})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{onClick:()=>void r(),children:i})]})]})]})}function jT(e){return e.currentVersion?e.latestVersion?e.updateState===`available`?`${e.currentVersion} → ${e.latestVersion}`:`${e.currentVersion} · latest`:`${e.currentVersion} · latest unknown`:e.availability===`missing`?`—`:`Unknown`}function MT(e){let t=e.authMode?` · ${e.authMode}`:``;return e.authState===`ready`?`Authenticated${t}`:e.authState===`required`?`Sign-in required${t}`:`Unknown${t}`}function NT(e){return e===`codex`?`Codex`:e===`claude`?`Claude Code`:`Traex`}function PT(e){return new Promise(t=>window.setTimeout(t,e))}function FT(e,t){if(e instanceof Hx)switch(e.code){case`offer_expired`:return`This Share Link has expired. Generate a new link on the remote Host and try again.`;case`offer_rejected`:return`The remote Host rejected this Share Link. It may already have been used, expired, or revoked. Generate a new link and use it once.`;case`invalid_offer`:return`This is not a valid Rynx Share Link. Copy and paste the complete link from the remote Host.`}return`${t} failed: ${e instanceof Error?e.message:String(e)}`}function IT(){let{runtimeSelector:e,selectRuntime:t,updateRuntimes:n}=xS(),[r,i]=(0,u.useState)(null),[a,o]=(0,u.useState)(!1),[s,c]=(0,u.useState)(null),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)({}),[m,h]=(0,u.useState)({});async function g(){try{let e=await Y.listRuntimes();i(e),n(e)}catch(e){i([]),V.error(`Failed to load Runtimes: ${e.message}`)}}(0,u.useEffect)(()=>{g()},[]);async function _(e){d(e.selector);try{let t=await Y.testRuntime(e.selector);p(n=>({...n,[e.selector]:t})),h(t=>{let n={...t};return delete n[e.selector],n}),V.success(`${e.displayName} is reachable`)}catch(t){p(t=>{let n={...t};return delete n[e.selector],n});let n={code:t instanceof Hx?t.code:void 0,message:t.message};h(t=>({...t,[e.selector]:n})),V.error(n.code===`authentication_failed`?`Authorization is no longer valid. Generate a new Share Link on the remote host, then reauthorize this Runtime.`:`Connection test failed: ${n.message}`)}finally{d(null)}}async function v(n){try{await Y.forgetRuntime(n.daemonId),p(e=>{let t={...e};return delete t[n.selector],t}),h(e=>{let t={...e};return delete t[n.selector],t}),V.success(`Forgot ${n.displayName}`),e===n.selector&&t(`local`),await g()}catch(e){V.error(`Forget failed: ${e.message}`)}}return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsx)(RT,{}),(0,H.jsxs)(fC,{children:[(0,H.jsxs)(pC,{className:`items-start`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsxs)(mC,{children:[`Runtimes`,` `,(0,H.jsx)(`span`,{className:`ml-1 text-[var(--muted-foreground)]`,children:r?.length??0})]}),(0,H.jsx)(`p`,{className:`max-w-2xl text-xs text-[var(--muted-foreground)]`,children:`Pair this Control Plane with remote Rynx daemons. Client keys stay in the local backend and never enter the browser.`})]}),(0,H.jsxs)(J,{size:`sm`,onClick:()=>o(!0),children:[(0,H.jsx)(Ir,{}),` Add Runtime`]})]}),(0,H.jsx)(hC,{className:`p-0`,children:(0,H.jsxs)(`div`,{className:`divide-y divide-[var(--border)]`,children:[r===null&&(0,H.jsx)(`div`,{className:`px-5 py-10 text-center text-sm text-[var(--muted-foreground)]`,children:`Loading Runtimes…`}),r?.map(e=>{let t=f[e.selector],n=m[e.selector]?.code===`authentication_failed`;return(0,H.jsxs)(`article`,{className:`grid gap-3 px-5 py-4 transition-colors hover:bg-[var(--muted)]/35 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,H.jsx)(`div`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:e.binding===`local`?(0,H.jsx)(hr,{className:`size-4`}):(0,H.jsx)(Wr,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`font-medium`,children:e.displayName}),(0,H.jsx)(MC,{variant:e.binding===`local`?`default`:`outline`,children:e.binding}),t&&(0,H.jsxs)(MC,{variant:`success`,children:[(0,H.jsx)(Vn,{className:`mr-1 size-3`}),` reachable`]}),n&&(0,H.jsxs)(MC,{variant:`warning`,children:[(0,H.jsx)(Xr,{className:`size-3`}),` authorization required`]})]}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-[var(--muted-foreground)]`,children:e.daemonId}),e.endpoint&&(0,H.jsx)(`div`,{className:`mt-1 truncate text-xs text-[var(--muted-foreground)]`,children:e.endpoint}),e.identityKeyFingerprint&&(0,H.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5 truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:[(0,H.jsx)(Yr,{className:`size-3 shrink-0`}),e.identityKeyFingerprint]}),t&&(0,H.jsxs)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:[`Instance `,t.status.daemonInstanceId]})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[e.binding===`direct`&&(0,H.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>c(e),children:[(0,H.jsx)(Yr,{}),`Reauthorize`]}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:l===e.selector,onClick:()=>void _(e),children:[(0,H.jsx)(zr,{className:l===e.selector?`animate-spin`:``}),`Test`]}),e.binding===`direct`&&(0,H.jsx)(JT,{target:e,onForget:()=>v(e)})]})]},e.selector)})]})})]}),(0,H.jsx)(`div`,{className:`rounded-lg border border-[var(--border)] bg-[var(--muted)]/30 px-4 py-3 text-xs text-[var(--muted-foreground)]`,children:`Sessions, terminals, and Session-scoped resources follow the selected Runtime. The standalone Emulator manager in Settings controls This device only. A remote failure never falls back to this device.`}),(0,H.jsx)(qT,{open:a,onOpenChange:o,onAdded:async e=>{p(t=>({...t,[e.target.selector]:e})),await g()}}),(0,H.jsx)(qT,{open:s!==null,target:s,onOpenChange:e=>{e||c(null)},onAdded:async e=>{p(t=>({...t,[e.target.selector]:e})),h(t=>{let n={...t};return delete n[e.target.selector],n}),await g()}})]})}var LT=`__rynx_custom_share_address__`;function RT(){let[e,t]=(0,u.useState)(null),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(!1),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(null),x=(0,u.useRef)(null),[S,C]=(0,u.useState)(null),[w,T]=(0,u.useState)(null),[E,D]=(0,u.useState)(!1),[O,k]=(0,u.useState)(null),[A,j]=(0,u.useState)(null),M=(0,u.useCallback)(async(e=!1)=>{D(!0);try{C(await Y.listRuntimeAccess()),T(null),e&&V.success(`Shared access refreshed`)}catch(t){let n=t.message;T(n),e&&V.error(`Failed to refresh shared access: ${n}`)}finally{D(!1)}},[]),N=(0,u.useCallback)(async(e=!1)=>{s(!0);try{let n=await Y.listRuntimeShareAddresses();t(n),a(null),r(e=>e?.kind===`custom`||e&&n.some(t=>t.address===e.address)?e:n[0]?{kind:`detected`,address:n[0].address}:null),e&&V.success(`Network addresses refreshed`)}catch(n){let r=n.message;t(e=>e??[]),a(r),e&&V.error(`Failed to refresh network addresses: ${r}`)}finally{s(!1)}},[]);(0,u.useEffect)(()=>{M(),N()},[M,N]);let P=n?.address??``,F=h.trim(),I=y&&y.address===P.trim()&&y.clientLabel===F?y.code:``;function L(t){if(t===LT){f(n?.kind===`custom`?n.address:``),m(!1),l(!0);return}t!==VT(n)&&e?.some(e=>e.address===t)&&r({kind:`detected`,address:t})}function ee(){let e=d.trim();if(!HT(e)){m(!0);return}r({kind:`custom`,address:e}),l(!1),m(!1)}async function te(){let e=P.trim();if(!e){V.error(`Choose an address that the other device can reach`);return}v(!0);try{let t=await Y.shareRuntime({address:e,...F?{clientLabel:F}:{}});b({code:t.pairingCode,address:e,clientLabel:F}),V.success(`Pairing link generated`),await M()}catch(e){V.error(`Failed to generate pairing link: ${e.message}`)}finally{v(!1)}}async function ne(){if(!I)return;let e=await NC(I,x.current);e===`clipboard`||e===`selection`?V.success(`Pairing link copied`):e===`selected`?V.info(`Pairing link selected — press Ctrl+C or ⌘C to copy`):V.error(`Copy is unavailable — select the pairing link and copy it manually`)}async function re(e){k(e.grantId);try{let t=await Y.revokeRuntimeAccess(e.grantId);V.success(`Revoked ${GT(e)}${t.closedConnections>0?` and closed ${t.closedConnections} active connection${t.closedConnections===1?``:`s`}`:``}`),await M()}catch(e){V.error(`Revoke failed: ${e.message}`)}finally{k(null)}}async function R(e){j(e.grantId);try{await Y.deleteRevokedRuntimeAccess(e.grantId),V.success(`Removed revoked access record for ${GT(e)}`),await M()}catch(e){V.error(`Remove failed: ${e.message}`)}finally{j(null)}}let ie=S?.filter(e=>e.revokedAt===null).length??0;return(0,H.jsxs)(fC,{children:[(0,H.jsx)(pC,{className:`items-start`,children:(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,H.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(qr,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`Share this device`}),(0,H.jsx)(`p`,{className:`max-w-2xl text-xs text-[var(--muted-foreground)]`,children:`Generate a revocable pairing link so another Rynx Control Plane can connect to this Runtime. Use a LAN, Tailscale, or tunnel address reachable from that device.`})]})]})}),(0,H.jsxs)(hC,{className:`grid gap-6`,children:[(0,H.jsxs)(`form`,{className:`grid gap-3`,onSubmit:e=>{e.preventDefault(),te()},children:[(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] md:items-end`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`runtime-share-address`,children:`Connection address`}),(0,H.jsxs)(`div`,{className:`flex min-w-0 gap-1.5`,children:[(0,H.jsxs)(my,{value:n?.kind===`custom`?VT(n):n?.address,onValueChange:L,disabled:e===null,children:[(0,H.jsx)(_y,{id:`runtime-share-address`,className:`min-w-0 flex-1`,"aria-describedby":`runtime-share-address-help`,children:(0,H.jsx)(gy,{placeholder:e===null?`Detecting addresses…`:`No address detected`,children:n?.kind===`custom`?n.address:n?BT(e??[],n.address):void 0})}),(0,H.jsxs)(by,{align:`start`,children:[n?.kind===`custom`&&(0,H.jsxs)(Sy,{value:VT(n),children:[`Custom (`,n.address,`)`]}),e?.map(e=>(0,H.jsx)(Sy,{value:e.address,children:zT(e)},e.address)),(n?.kind===`custom`||!!e?.length)&&(0,H.jsx)(Cy,{}),(0,H.jsx)(Sy,{value:LT,children:`Enter custom address…`})]})]}),(0,H.jsx)(J,{type:`button`,variant:`outline`,size:`icon`,disabled:o,"aria-label":`Refresh network addresses`,title:`Refresh network addresses`,onClick:()=>void N(!0),children:(0,H.jsx)(zr,{className:o?`animate-spin`:``})})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`runtime-share-label`,children:`Client label`}),(0,H.jsx)(Ag,{id:`runtime-share-label`,value:h,onChange:e=>g(e.target.value),placeholder:`Alice’s laptop (optional)`,maxLength:128})]}),(0,H.jsxs)(J,{type:`submit`,disabled:_||!n,children:[_?(0,H.jsx)(zr,{className:`animate-spin`}):(0,H.jsx)(_r,{}),`Generate Link`]})]}),(0,H.jsx)(`p`,{id:`runtime-share-address-help`,className:i?`text-xs text-[var(--destructive)]`:`text-xs text-[var(--muted-foreground)]`,role:i?`alert`:void 0,children:i?`Could not refresh network addresses: ${i}`:n?.kind===`custom`?`Using a custom host or ws(s) endpoint. Make sure the other device can reach it.`:e?.length?`Detected from this device. Tailnet addresses are listed first.`:e===null?`Looking for reachable IPv4 interfaces on this device…`:`No reachable IPv4 interface was found. Check the Runtime listener or enter a custom address.`}),I&&(0,H.jsxs)(`div`,{className:`grid gap-1.5 rounded-lg border border-[var(--border)] bg-[var(--muted)]/30 p-3`,children:[(0,H.jsx)(GS,{htmlFor:`runtime-pairing-code`,children:`Pairing link`}),(0,H.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,H.jsx)(Ag,{id:`runtime-pairing-code`,ref:x,value:I,readOnly:!0,className:`font-mono text-xs`,spellCheck:!1}),(0,H.jsxs)(J,{type:`button`,variant:`outline`,onClick:()=>void ne(),children:[(0,H.jsx)(Jn,{}),` Copy`]})]}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Treat this link as a credential. After it is used, the client appears below and can be revoked.`})]})]}),(0,H.jsxs)(`section`,{className:`grid gap-3 border-t border-[var(--border)] pt-4`,"aria-labelledby":`runtime-access-title`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`h2`,{id:`runtime-access-title`,className:`text-sm font-medium`,children:[`Shared access `,(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:ie})]}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--muted-foreground)]`,children:`Active clients can reconnect until their grant is revoked.`})]}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:E,"aria-label":`Refresh shared access`,onClick:()=>void M(!0),children:(0,H.jsx)(zr,{className:E?`animate-spin`:``})})]}),S===null&&!w&&(0,H.jsx)(`div`,{className:`py-4 text-center text-xs text-[var(--muted-foreground)]`,role:`status`,children:`Loading shared access…`}),w&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-[var(--destructive)]/30 bg-[var(--destructive)]/5 px-3 py-2`,children:[(0,H.jsxs)(`p`,{className:`text-xs text-[var(--destructive)]`,role:`alert`,children:[`Could not load shared access: `,w]}),(0,H.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void M(),children:`Retry`})]}),S?.length===0&&!w&&(0,H.jsx)(`div`,{className:`rounded-lg border border-dashed border-[var(--border)] px-4 py-6 text-center text-xs text-[var(--muted-foreground)]`,children:`No shared Runtime access yet.`}),S&&S.length>0&&(0,H.jsx)(`ul`,{className:`divide-y divide-[var(--border)] overflow-hidden rounded-lg border border-[var(--border)]`,children:S.map(e=>(0,H.jsxs)(`li`,{className:`grid gap-3 px-3 py-3 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:GT(e)}),(0,H.jsxs)(MC,{variant:e.revokedAt?`destructive`:`success`,children:[e.revokedAt?(0,H.jsx)(Xr,{className:`size-3`}):(0,H.jsx)(Yr,{className:`size-3`}),e.revokedAt?`revoked`:`active`]})]}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:e.grantId}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:e.lastUsedAt?`Last used ${KT(e.lastUsedAt)}`:`Created ${KT(e.createdAt)} · never connected`})]}),e.revokedAt?(0,H.jsx)(WT,{client:e,disabled:A===e.grantId,onRemove:()=>R(e)}):(0,H.jsx)(UT,{client:e,disabled:O===e.grantId,onRevoke:()=>re(e)})]},e.grantId))})]})]}),(0,H.jsx)(Su,{open:c,onOpenChange:e=>{l(e),e||m(!1)},children:(0,H.jsxs)(Du,{className:`sm:max-w-md`,children:[(0,H.jsxs)(Ou,{children:[(0,H.jsx)(Au,{children:`Enter custom address`}),(0,H.jsx)(ju,{children:`Use a DNS name, custom port, reverse proxy, or tunnel when the detected interfaces are not the route the other device should dial.`})]}),(0,H.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),ee()},children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`runtime-custom-share-address`,children:`Host or WebSocket URL`}),(0,H.jsx)(Ag,{id:`runtime-custom-share-address`,value:d,onChange:e=>{f(e.target.value),e.target.value.trim()&&m(!1)},placeholder:`runtime.example.com or wss://runtime.example.com`,maxLength:2048,"aria-invalid":p,"aria-describedby":`runtime-custom-share-address-help`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,autoFocus:!0}),(0,H.jsx)(`p`,{id:`runtime-custom-share-address-help`,className:p?`text-xs text-[var(--destructive)]`:`text-xs text-[var(--muted-foreground)]`,children:p?`Enter a host or a complete ws:// or wss:// URL without spaces.`:`Rynx adds the listener port for a host and supplies the Runtime path.`})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(Tu,{asChild:!0,children:(0,H.jsx)(J,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,H.jsx)(J,{type:`submit`,disabled:!d.trim(),children:`Use Address`})]})]})]})})]})}function zT(e){return`${e.interfaceName} (${e.address})`}function BT(e,t){let n=e.find(e=>e.address===t);return n?zT(n):t}function VT(e){return e?.kind===`custom`?`__rynx_custom_share_address_current__:${e.address}`:void 0}function HT(e){return e.length>0&&e.length<=2048&&!/[\s\u0000-\u001f\u007f]/.test(e)}function UT({client:e,disabled:t,onRevoke:n}){return(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsxs)(J,{type:`button`,variant:`destructive`,size:`sm`,disabled:t,children:[t?(0,H.jsx)(zr,{className:`animate-spin`}):(0,H.jsx)(Xr,{}),`Revoke`]})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[`Revoke access for “`,GT(e),`”?`]}),(0,H.jsx)(yu,{children:`This client will no longer be able to reconnect. Any active Runtime connections using this grant are closed immediately.`})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>void n(),children:`Revoke Access`})]})]})]})}function WT({client:e,disabled:t,onRemove:n}){return(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:t,children:[t?(0,H.jsx)(zr,{className:`animate-spin`}):(0,H.jsx)(si,{}),`Remove Record`]})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[`Remove revoked record for “`,GT(e),`”?`]}),(0,H.jsx)(yu,{children:`This removes the revoked authorization record from this Host. It does not restore access or delete the credential stored on the client device.`})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>void n(),children:`Remove Record`})]})]})]})}function GT(e){return e.clientLabel??e.clientId}function KT(e){let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():e}function qT({open:e,target:t=null,onOpenChange:n,onAdded:r}){let[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(!1),d=t!==null;(0,u.useEffect)(()=>{e&&(a(t?.displayName??``),s(``))},[e,t]);async function f(){let e=o.trim();if(e){l(!0);try{let o=await Y.pairRuntime({offer:e,...i.trim()?{displayName:i.trim()}:{},...t?{replaceExisting:!0,expectedDaemonId:t.daemonId}:{}});V.success(d?`Reauthorized ${o.target.displayName}`:`Paired ${o.target.displayName}`),await r(o),a(``),s(``),n(!1)}catch(e){V.error(FT(e,d?`Reauthorization`:`Pairing`))}finally{l(!1)}}}return(0,H.jsx)(Su,{open:e,onOpenChange:n,children:(0,H.jsxs)(Du,{className:`sm:max-w-lg`,children:[(0,H.jsxs)(Ou,{children:[(0,H.jsx)(Au,{children:d?`Reauthorize Runtime`:`Add Runtime`}),(0,H.jsx)(ju,{children:d?`Generate a fresh Share Link on the remote Host and paste it here. The old local credential is replaced only after the new connection is authenticated.`:`On the remote host, share the Runtime and paste its pairing link here. The local backend keeps the resulting client credential out of the browser.`})]}),(0,H.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),f()},children:[(0,H.jsxs)(`div`,{className:`grid gap-3`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`runtime-name`,children:`Display name`}),(0,H.jsx)(Ag,{id:`runtime-name`,value:i,onChange:e=>a(e.target.value),placeholder:`Remote lab`,maxLength:128})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`runtime-offer`,children:`Pairing link`}),(0,H.jsx)(Ag,{id:`runtime-offer`,value:o,onChange:e=>s(e.target.value),placeholder:`rynx://pair?code=...`,className:`font-mono text-xs`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1}),(0,H.jsxs)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:[`Generate one from`,` `,(0,H.jsx)(`span`,{className:`font-medium text-[var(--foreground)]`,children:`Share this device`}),` on the remote Control Plane.`]})]})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(Tu,{asChild:!0,children:(0,H.jsx)(J,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,H.jsxs)(J,{type:`submit`,disabled:c||!o.trim(),children:[c?(0,H.jsx)(zr,{className:`animate-spin`}):(0,H.jsx)(Yr,{}),d?`Reauthorize`:`Add Runtime`]})]})]})]})})}function JT({target:e,onForget:t}){return(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsxs)(J,{variant:`ghost`,size:`sm`,className:`text-[var(--destructive)]`,children:[(0,H.jsx)(si,{}),(0,H.jsxs)(`span`,{className:`sr-only`,children:[`Forget `,e.displayName]})]})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[`Forget “`,e.displayName,`”?`]}),(0,H.jsxs)(yu,{children:[`Removes this route and its protected client credential from the local Control Plane. The remote grant remains until an operator runs `,(0,H.jsx)(`code`,{children:`rynx runtime clients revoke`}),`on that daemon.`]})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>void t(),children:`Forget Runtime`})]})]})]})}function YT(e,t){return t===`install`||e?.phase===`installing`}var XT=`rynx.control.session-launch-selection.v2`,ZT=`default`;function QT(e){return`${e.kind}:${e.id}`}function $T(e){return e===`provider:claude`?{kind:`provider`,id:`claude`}:e===`provider:codex`?{kind:`provider`,id:`codex`}:e===`provider:traex`?{kind:`provider`,id:`traex`}:e.startsWith(`agent:`)&&e.length>6?{kind:`agent`,id:e.slice(6)}:null}function eE(e,t){return e.kind===`provider`?t.providers.some(t=>t.id===e.id):t.agents.some(t=>t.id===e.id)}function tE(e,t){let n=t?$T(t):null;if(n&&eE(n,e)&&(n.kind===`agent`&&e.agents.some(e=>e.id===n.id&&e.ready)||n.kind===`provider`&&e.providers.some(e=>e.id===n.id&&e.ready)))return n;for(let t of[`claude`,`codex`,`traex`])if(e.providers.some(e=>e.id===t&&e.ready))return{kind:`provider`,id:t};let r=e.providers.find(e=>e.ready);if(r)return{kind:`provider`,id:r.id};let i=e.agents.find(e=>e.ready);return i?{kind:`agent`,id:i.id}:e.providers[0]?{kind:`provider`,id:e.providers[0].id}:e.agents[0]?{kind:`agent`,id:e.agents[0].id}:null}function nE(e,t){if(!t)return null;try{return t.getItem(iE(e))}catch{return null}}function rE(e,t,n){if(t)try{t.setItem(iE(e),QT(n))}catch{}}function iE(e){return`${XT}:${encodeURIComponent(e)}`}function aE(e,t,n,r){let i=n?{projectId:n}:{},a=r?.permissionPreset&&r.permissionPreset!=="default"?{permissionPreset:r.permissionPreset}:{};return e.kind===`provider`?{provider:e.id,title:t,...i,...r?.model?{model:r.model}:{},...r?.reasoningEffort?{reasoningEffort:r.reasoningEffort}:{},...a}:{agent:e.id,title:t,...i,...a}}function oE(e,t,n=ZT){if(!e||e.kind!==`provider`)return{permissionPreset:n};let r=t.providers.find(t=>t.id===e.id),i=r?.models?.find(e=>e.isDefault)??r?.models?.[0],a=i?.defaultReasoningEffort&&i.reasoningOptions.some(e=>e.value===i.defaultReasoningEffort)?i.defaultReasoningEffort:i?.reasoningOptions.find(e=>e.value===`medium`)?.value??i?.reasoningOptions[0]?.value;return{permissionPreset:n,...i?{model:i.id}:{},...a?{reasoningEffort:a}:{}}}function sE(e){let t=e.replace(/\s+/g,` `).trim(),n=Array.from(t);return n.length<=64?t:`${n.slice(0,61).join(``).trimEnd()}…`}function cE(e){return{providers:[],agents:e.map(e=>({...e,ready:!0,readiness:`unverified`}))}}function lE(e){return e.readiness===`unverified`?`unverified`:e.ready?`ready`:`needs_setup`}function uE(e){return e===`claude`?`Claude Code`:e===`traex`?`Traex`:`Codex`}function dE(e,t){if(!e)return null;if(e.kind===`provider`)return t.providers.find(t=>t.id===e.id)??null;let n=t.agents.find(t=>t.id===e.id);return n?{name:n.name??n.id,ready:n.ready,...n.reason?{reason:n.reason}:{},...n.readiness?{readiness:n.readiness}:{}}:null}var fE=ax,pE=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(ox,{ref:n,className:X(`inline-flex h-9 items-center gap-1 rounded-lg bg-[var(--muted)] p-1 text-[var(--muted-foreground)]`,e),...t}));pE.displayName=`TabsList`;var mE=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(sx,{ref:n,className:X(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium transition-all focus-visible:outline-none data-[state=active]:bg-[var(--background)] data-[state=active]:text-[var(--foreground)] data-[state=active]:shadow-sm`,e),...t}));mE.displayName=`TabsTrigger`;var hE=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(cx,{ref:n,className:X(`mt-4 focus-visible:outline-none`,e),...t}));hE.displayName=`TabsContent`;function gE(){return{items:[],byId:{},callIndex:{},interactionIndex:{},pendingOutputs:{},pendingInteractionResolutions:{},childStates:{},turns:{},runStatus:`idle`,backgroundTaskCount:0,waitingForInteraction:!1,todos:[],historyLoaded:!1}}function _E(e,t){return e===`startup`&&t!==void 0&&(/^Starting MCP servers?:/i.test(t)||/^MCP startup /i.test(t))}function vE(e){return e.filter(e=>`text`in e).map(e=>e.text).join(``)}function yE(e){let t=e.data.content.flatMap((e,t)=>`text`in e?[t]:[]);return t.length===1&&e.truncations?.some(({field:e})=>e===`data.content[${t[0]}].text`)===!0}function bE(e){return e.flatMap((e,t)=>e.type===`input_image`?[{...e,partIndex:t}]:[])}function xE(e){return e.flatMap((e,t)=>e.type===`input_file`?[{...e,partIndex:t}]:[])}function SE(e){let t=e.slice();for(let e=1;e<t.length;e+=1){let n=t[e],r=t[e-1];n.type!==`reasoning`||n.data.model!==`traex`||r.type!==`message`||r.data.role!==`assistant`||r.data.model!==`traex`||r.responseId!==n.responseId||n.createdAt<r.createdAt||n.createdAt-r.createdAt>500||(t[e]=r,t[e-1]=n)}return t}function CE(e){return{...e,items:e.items.slice(),byId:{...e.byId},callIndex:{...e.callIndex},interactionIndex:{...e.interactionIndex},pendingOutputs:{...e.pendingOutputs},pendingInteractionResolutions:{...e.pendingInteractionResolutions},childStates:{...e.childStates},turns:{...e.turns}}}function wE(e,t,n){e.items[t]=n}function TE(e,t){let n=e.items.length;return e.items.push(t),n}function EE(e,t){let n=gE();for(let e of SE(t))UE(n,e);for(let t of e.items){if(t.kind!==`message`||t.role!==`user`||!t.optimistic)continue;let e={...t,images:t.images.slice()};n.byId[e.id]=TE(n,e)}return n}function DE(e,t,n){if(!n)return;let r=e.turns[t];e.turns[t]=r?{...r,model:r.model??n}:{status:`completed`,model:n}}function OE(e){let t=0;for(let n of e)n.kind===`interaction`&&n.status===`pending`&&(t+=1),n.kind===`tool`&&n.children&&(t+=OE(n.children));return t}function kE(e){e.waitingForInteraction=OE(e.items)>0||Object.values(e.childStates).some(e=>e.waitingForInteraction)}function AE(e){let t={...e,status:`pending`};return delete t.resolution,delete t.reason,delete t.resolvedAt,t}function jE(e,t){return e.map(e=>e.kind===`interaction`?t.has(e.id)?AE(e):e.status===`pending`?{...e,status:`inactive`}:e:e.kind===`tool`&&e.children?{...e,children:jE(e.children,t)}:e)}function ME(e,t=new Set){for(let n of e)n.kind===`interaction`&&t.add(n.id),n.kind===`tool`&&n.children&&ME(n.children,t);return t}function NE(e,t){let n=new Set(t.pendingInteractions.map(({interaction:e})=>e.interactionId));for(let[t,r]of Object.entries(e.childStates)){let i=CE(r);i.items=jE(i.items,n),kE(i),e.childStates[t]=i;let a=e.callIndex[t];if(a!==void 0){let t=e.items[a];wE(e,a,{...t,children:i.items})}}e.items=jE(e.items,n);let r=ME(e.items);for(let t of Object.values(e.childStates))ME(t.items,r);for(let{responseId:n,interaction:i}of t.pendingInteractions){if(r.has(i.interactionId))continue;let t={kind:`interaction`,id:i.interactionId,responseId:n,request:i,status:`pending`};e.interactionIndex[i.interactionId]=TE(e,t),r.add(i.interactionId)}let i=new Set(t.activeResponseIds);for(let[t,n]of Object.entries(e.turns))i.has(t)||n.status===`running`&&(e.turns[t]={...n,status:`completed`},WE(e,t));GE(e,i);for(let t of i)e.turns[t]={...e.turns[t],status:`running`};e.runStatus=t.status,e.statusKind=t.statusKind,e.backgroundTaskCount=t.backgroundTaskCount??0,e.waitingForInteraction=n.size>0}function PE(e,t){return{...e,status:t.status,...t.resolution?{resolution:t.resolution}:{},...t.reason?{reason:t.reason}:{},resolvedAt:t.resolvedAt}}function FE(e,t,n,r){let i=e.byId[t];if(i!==void 0)return i;let a=TE(e,r());return e.byId[t]=a,a}function IE(e,t){e.items.splice(t,1);for(let n of[e.byId,e.callIndex,e.interactionIndex])for(let[e,r]of Object.entries(n))r===t?delete n[e]:r>t&&(n[e]=r-1)}function LE(e,t){if(t){let n=e.byId[t];if(n!==void 0&&e.items[n]?.kind===`message`&&e.items[n].role===`user`&&e.items[n].optimistic)return n}return e.items.findIndex(e=>e.kind===`message`&&e.role===`user`&&e.optimistic)}function RE(e,t,n){let r={kind:`message`,id:t,responseId:t,role:`user`,text:vE(n),images:bE(n),files:xE(n),streaming:!1,optimistic:!0,pendingContent:n.map(e=>({...e}))},i=e.byId[t];if(i!==void 0){e.items[i]?.kind===`message`&&e.items[i].optimistic&&wE(e,i,r);return}e.byId[t]=TE(e,r)}function zE(e,t,n){let r=e.byId[t];if(r===void 0||e.items[r]?.kind!==`message`||!e.items[r].optimistic)return!1;let i=e.byId[n];if(i!==void 0&&i!==r)return IE(e,r),!0;let a=e.items[r];return delete e.byId[t],wE(e,r,{...a,id:n,responseId:n}),e.byId[n]=r,!0}function BE(e){let t=e=>{if(Array.isArray(e))return e.map(t);if(typeof e==`object`&&e){let n=e;return Object.fromEntries(Object.keys(n).sort().map(e=>[e,t(n[e])]))}return e};return JSON.stringify(t(e))}function VE(e,t,n=!1){let r=new Set(t.map(e=>e.pendingId));for(let n of t){if(e.byId[n.pendingId]===void 0){let t=BE(n.content),i=e.items.find(e=>e.kind===`message`&&e.role===`user`&&e.optimistic===!0&&!r.has(e.id)&&e.pendingContent!==void 0&&BE(e.pendingContent)===t);i&&zE(e,i.id,n.pendingId)}RE(e,n.pendingId,n.content)}if(n)for(let t=e.items.length-1;t>=0;--t){let n=e.items[t];n?.kind===`message`&&n.role===`user`&&n.optimistic&&!r.has(n.id)&&IE(e,t)}}function HE(e,t,n){let r=CE(e.childStates[t]??gE());UE(r,{...n,parentToolCallId:void 0}),kE(r),e.childStates[t]=r;let i=e.callIndex[t];if(i!==void 0){let t=e.items[i];wE(e,i,{...t,children:r.items})}}function UE(e,t,n,r=!1){if(t.parentToolCallId){HE(e,t.parentToolCallId,t);return}switch(t.type){case`message`:{DE(e,t.responseId,t.data.model);let i={kind:`message`,id:t.id,responseId:t.responseId,role:t.data.role,text:vE(t.data.content),images:bE(t.data.content),files:xE(t.data.content),model:t.data.model,isMeta:t.data.isMeta,interrupted:t.data.interrupted,streaming:!1,...yE(t)?{textPrefixTruncated:!0}:{}},a=e.byId[t.id];if(a!==void 0){if(wE(e,a,i),r&&t.data.role===`user`){let t=LE(e,n);t!==-1&&t!==a&&IE(e,t)}return}if(r&&t.data.role===`user`){let r=LE(e,n);if(r!==-1){let n=e.items[r];delete e.byId[n.id],wE(e,r,i),e.byId[t.id]=r;return}}e.byId[t.id]=TE(e,i);return}case`reasoning`:{DE(e,t.responseId,t.data.model);let n={kind:`reasoning`,id:t.id,responseId:t.responseId,summary:t.data.summary.map(e=>e.text),model:t.data.model,streaming:!1},r=e.byId[t.id];r===void 0?e.byId[t.id]=TE(e,n):wE(e,r,n);return}case`function_call`:{let n=t.data.callId,r=e.pendingOutputs[n],i=e.childStates[n]?.items,a={kind:`tool`,id:n,responseId:t.responseId,name:t.data.name,arguments:t.data.arguments,status:r?r.status??`completed`:t.status,output:r?.output,exitCode:r?.exitCode,generatedImage:r?.generatedImage,generatedImageItemId:r?.generatedImageItemId,...i&&i.length?{children:i}:{}};r&&delete e.pendingOutputs[n];let o=e.callIndex[n];o===void 0?e.callIndex[n]=TE(e,a):wE(e,o,a);return}case`function_call_output`:{let n=t.data.callId,r=e.callIndex[n];if(r===void 0){e.pendingOutputs[n]={output:t.data.output,status:t.data.status,exitCode:t.data.exitCode,generatedImage:t.data.generatedImage,generatedImageItemId:t.id};return}let i=e.items[r];wE(e,r,{...i,output:t.data.output,status:t.data.status??`completed`,exitCode:t.data.exitCode,generatedImage:t.data.generatedImage,generatedImageItemId:t.id});return}case`terminal_command`:{let n={kind:`terminal_command`,id:t.id,responseId:t.responseId,command:t.data.command,...t.data.stdout?{stdout:t.data.stdout}:{},...t.data.stderr?{stderr:t.data.stderr}:{}},r=e.byId[t.id];r===void 0?e.byId[t.id]=TE(e,n):wE(e,r,n);return}case`interaction_request`:{let n=t.data.interaction,r=n.interactionId,i=e.interactionIndex[r],a=e.pendingInteractionResolutions[r],o=i===void 0?void 0:e.items[i],s={kind:`interaction`,id:r,responseId:t.responseId,request:n,status:o?.status??`pending`,...o?.resolution?{resolution:o.resolution}:{},...o?.reason?{reason:o.reason}:{},...o?.resolvedAt===void 0?{}:{resolvedAt:o.resolvedAt}};a&&(s=PE(s,a),delete e.pendingInteractionResolutions[r]),i===void 0?e.interactionIndex[r]=TE(e,s):wE(e,i,s),e.byId[t.id]=e.interactionIndex[r];return}case`interaction_resolution`:{let n=t.data,r=e.interactionIndex[n.interactionId];if(r===void 0){e.pendingInteractionResolutions[n.interactionId]={...n,responseId:t.responseId,itemId:t.id};return}let i=e.items[r];wE(e,r,PE(i,n)),e.byId[t.id]=r;return}case`error`:{let n={kind:`error`,id:t.id,responseId:t.responseId,source:t.data.source,code:t.data.code,message:t.data.message},r=e.byId[t.id];r===void 0?e.byId[t.id]=TE(e,n):wE(e,r,n);return}}}function WE(e,t){let n=e=>e===t;KE(e,n),e.items=JE(e.items,t);for(let[r,i]of Object.entries(e.childStates)){let a=CE(i);KE(a,n),a.items=JE(a.items,t),kE(a),e.childStates[r]=a;let o=e.callIndex[r];if(o!==void 0){let t=e.items[o];wE(e,o,{...t,children:a.items})}}}function GE(e,t){let n=e=>!t.has(e);KE(e,n);for(let[t,r]of Object.entries(e.childStates)){let i=CE(r);KE(i,n),kE(i),e.childStates[t]=i;let a=e.callIndex[t];if(a!==void 0){let t=e.items[a];wE(e,a,{...t,children:i.items})}}}function KE(e,t){for(let n=e.items.length-1;n>=0;--n){let r=e.items[n];r?.kind===`message`&&t(r.responseId)&&r.role===`assistant`&&r.liveDraft===!0&&IE(e,n)}}function qE(e,t){let n=e.items.filter(e=>e.kind===`message`&&e.responseId===t&&e.role===`assistant`&&e.liveDraft!==!0);if(n.length!==0)for(let r=e.items.length-1;r>=0;--r){let i=e.items[r];i?.kind===`message`&&i.responseId===t&&i.role===`assistant`&&i.liveDraft===!0&&n.some(e=>e.text===i.text||e.textPrefixTruncated===!0&&e.text.length>0&&i.text.startsWith(e.text))&&IE(e,r)}}function JE(e,t){return e.map(e=>{let n=e.kind===`tool`&&e.children?{...e,children:JE(e.children,t)}:e;return n.responseId===t?n.kind===`tool`&&n.status===`in_progress`?{...n,status:`incomplete`}:(n.kind===`message`||n.kind===`reasoning`)&&n.streaming?{...n,streaming:!1}:n.kind===`interaction`&&n.status===`pending`?{...n,status:`inactive`,reason:`Turn ended before this interaction was resolved`}:n:n})}function YE(e){return Object.values(e.turns).some(e=>e.status===`running`)}function XE(e){e.note=void 0,e.statusKind=void 0}function ZE(e,t){switch(t.type){case`session.status`:e.runStatus=t.status,t.runtimeSessionId&&(e.runtimeSessionId=t.runtimeSessionId),e.note=t.note,e.statusKind=t.statusKind,t.backgroundTaskCount===void 0?(t.status===`running`||t.status===`failed`)&&(e.backgroundTaskCount=0):e.backgroundTaskCount=t.backgroundTaskCount;return;case`session.collaboration_mode`:e.collaborationMode=t.mode;return;case`response.created`:e.turns[t.responseId]={status:`running`,model:t.model},e.runStatus=`running`,e.backgroundTaskCount=0,XE(e);return;case`response.output_text.delta`:{XE(e);let n=e.byId[t.itemId],r=n===void 0?void 0:e.items[n];if(t.discard===!0){n!==void 0&&r?.kind===`message`&&r.role===`assistant`&&r.responseId===t.responseId&&r.liveDraft===!0&&IE(e,n);return}let i=e.turns[t.responseId]?.status;if(i===`completed`||i===`failed`||i===`cancelled`||r?.kind===`message`&&r.role===`assistant`&&r.liveDraft!==!0)return;let a=FE(e,t.itemId,t.responseId,()=>({kind:`message`,id:t.itemId,responseId:t.responseId,role:`assistant`,text:``,images:[],files:[],streaming:!0,liveDraft:!0})),o=e.items[a];e.items[a]={...o,text:o.text+t.delta,streaming:!0},t.final&&qE(e,t.responseId);return}case`response.reasoning_summary_text.delta`:{XE(e);let n=FE(e,t.itemId,t.responseId,()=>({kind:`reasoning`,id:t.itemId,responseId:t.responseId,summary:[],streaming:!0})),r=e.items[n],i=r.summary.slice();i[t.summaryIndex]=(i[t.summaryIndex]??``)+t.delta,e.items[n]={...r,summary:i,streaming:!0};return}case`response.function_call_output.delta`:{XE(e);let n=e.callIndex[t.callId];if(n===void 0){let n=e.pendingOutputs[t.callId]??{output:``};e.pendingOutputs[t.callId]={...n,output:(n.output??``)+t.delta};return}let r=e.items[n];e.items[n]={...r,output:(r.output??``)+t.delta};return}case`session.interaction.requested`:{XE(e),UE(e,t.item);let n=e.interactionIndex[t.interaction.interactionId];if(n!==void 0){let t=e.items[n];(t.status===`pending`||t.status===`inactive`)&&wE(e,n,AE(t))}return}case`session.interaction.resolved`:case`session.interaction.cancelled`:XE(e),UE(e,t.item);return;case`session.interrupted`:{XE(e);let n=e.turns[t.responseId];e.turns[t.responseId]={...n,status:`cancelled`};let r=!1;for(let n=e.items.length-1;n>=0;--n){let i=e.items[n];if(i?.kind===`message`&&i.role===`assistant`&&i.responseId===t.responseId){e.items[n]={...i,interrupted:!0,streaming:!1,liveDraft:!1},r=!0;break}}if(!r){let n=`interrupted_${t.responseId}`;e.byId[n]===void 0&&(e.byId[n]=TE(e,{kind:`error`,id:n,responseId:t.responseId,source:`execution`,code:`response_stopped`,message:`Response stopped`}))}WE(e,t.responseId),e.runStatus=YE(e)?`running`:`idle`;return}case`response.output_item.done`:{XE(e);let n=t.item;if(n.type===`message`&&n.data.role===`assistant`&&e.turns[t.responseId]?.status===`cancelled`){let r=e.byId[`interrupted_${t.responseId}`];r!==void 0&&IE(e,r),n={...n,data:{...n.data,interrupted:!0}}}UE(e,n);return}case`response.completed`:{XE(e);let n=e.turns[t.responseId];e.turns[t.responseId]={...n,status:n?.status===`cancelled`?`cancelled`:`completed`,usage:t.usage},WE(e,t.responseId),!YE(e)&&e.runStatus!==`failed`&&(e.runStatus=`idle`);return}case`response.failed`:{XE(e);let n=e.turns[t.responseId];e.turns[t.responseId]={...n,status:`failed`},e.items.some(e=>e.kind===`error`&&e.responseId===t.responseId&&e.code===t.error.code)||TE(e,{kind:`error`,id:`failed_${t.responseId}_${t.error.code}`,responseId:t.responseId,source:t.error.source,code:t.error.code,message:t.error.message}),WE(e,t.responseId),e.runStatus=YE(e)?`running`:`idle`;return}case`session.input.consumed`:XE(e),UE(e,t.item,t.clearedPendingId,!0);return;case`session.todos`:e.todos=t.todos;return;case`session.rotated`:TE(e,{kind:`divider`,id:`rotate_${t.newSessionId}`,responseId:`rotate_${t.newSessionId}`,label:t.kind===`fork`?`forked to a new session`:`context cleared — new session`,newSessionId:t.newSessionId,rotateKind:t.kind}),e.runStatus=`idle`,e.backgroundTaskCount=0,XE(e);return}}function QE(e,t){switch(t.kind){case`reset`:return gE();case`snapshot`:{let n=EE(e,t.items);return VE(n,t.pendingInputs??[]),NE(n,t.runtime),n.historyLoaded=!0,n}case`reconcile_snapshot`:{let n=CE(e);for(let e of SE(t.items))UE(n,e);return VE(n,t.pendingInputs??[],t.pruneMissingPending),NE(n,t.runtime),n.historyLoaded=!0,n.error=void 0,n}case`history`:{let n=EE(e,t.items);return kE(n),n.historyLoaded=!0,n}case`reconcile_history`:{let n=CE(e);for(let e of SE(t.items))UE(n,e);return kE(n),n.historyLoaded=!0,n.error=void 0,n}case`event`:{let n=CE(e);return ZE(n,t.event),kE(n),n}case`optimistic_user`:{let n=CE(e);return RE(n,t.id,[...t.attachments??[],...t.text?[{type:`input_text`,text:t.text}]:[]]),n}case`discard_optimistic_user`:{let n=e.byId[t.id];if(n===void 0||e.items[n]?.kind!==`message`||!e.items[n].optimistic)return e;let r=CE(e);return IE(r,n),r}case`stream_error`:{let n=CE(e);return n.error=t.message,n}case`stream_done`:return e}}function $E(e){let t;for(let n of e.items){let r=e.turns[n.responseId];r&&(t=r)}return t}function eD(e){let t=!1,n=e.map(e=>e.kind===`error`?e.code===`codex_error`&&e.message===`Codex turn was interrupted`||e.code===`traex_error`&&e.message===`Traex turn was interrupted`?(t=!0,{...e,code:`response_stopped`,message:`Response stopped`}):e.code===`codex_error`&&e.message===`Codex turn failed`||e.code===`traex_error`&&e.message===`Traex turn failed`||e.code===`claude_error`&&e.message===`claude turn failed`?(t=!0,{...e,code:`agent_error`,message:`Agent turn failed`}):e:e);return t?n:e}var tD=`browser:`,nD=`emulator:`;function rD(e){return e?e===`browser`?{type:`browser`,pageId:null}:e.startsWith(tD)?{type:`browser`,pageId:e.slice(8).trim()||null}:e===`emulator`?{type:`emulator`,bindingId:null}:e.startsWith(nD)?{type:`emulator`,bindingId:e.slice(9).trim()||null}:null:null}function iD(e){return e?`${tD}${e}`:`browser`}function aD(e){return e?`${nD}${e}`:`emulator`}function oD(e,t){let n=new Set(t),r=new Set,i=[];for(let t of e)!n.has(t)||r.has(t)||(r.add(t),i.push(t));for(let e of t)r.has(e)||(r.add(e),i.push(e));return i}function sD(e,t){let n=Math.max(0,Math.max(0,e)-420);return Math.min(n,Math.max(Math.min(360,n),t))}function cD(e,t,n){return!e||e.pages.length===0?null:t&&e.pages.some(e=>e.pageId===t)?t:n&&e.pages.some(e=>e.pageId===n)?n:e.activePageId&&e.pages.some(t=>t.pageId===e.activePageId)?e.activePageId:e.pages[0]?.pageId??null}function lD(e,t){return!e||!t?.activePageId||e.includes(t.activePageId)?null:t.pages.some(e=>e.pageId===t.activePageId)?t.activePageId:null}var uD=/^[A-Za-z0-9][A-Za-z0-9._~-]*$/,dD=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,fD=/^[\x20-\x7e]*$/,pD=new Set([`accept-encoding`,`authorization`,`connection`,`content-length`,`cookie`,`host`,`keep-alive`,`origin`,`proxy-authenticate`,`proxy-authorization`,`proxy-connection`,`referer`,`set-cookie`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`user-agent`]);function mD(e){let t=gD(e,[`sessionId`,`expectedRevision`,`enabled`,`headers`],`browser.request-headers.set params`);return{sessionId:vD(t.sessionId,`browser.request-headers.set sessionId`),expectedRevision:vD(t.expectedRevision,`browser.request-headers.set expectedRevision`),...hD(t,`browser.request-headers.set params`)}}function hD(e,t){let n=bD(e.enabled,`${t} enabled`);if(!Array.isArray(e.headers))throw xD(`${t} headers must be an array`);if(e.headers.length>32)throw xD(`${t} headers exceeds 32 entries`);let r=new Set,i={enabled:n,headers:e.headers.map((e,n)=>{let i=gD(e,[`name`,`value`],`${t} headers[${n}]`),a=yD(i.name,`${t} headers[${n}] name`,128);if(!dD.test(a))throw xD(`${t} headers[${n}] name is not an HTTP header token`);let o=a.toLowerCase();if(pD.has(o)||o.startsWith(`proxy-`)||o.startsWith(`sec-`))throw xD(`${t} headers[${n}] name is controlled by the Browser`);if(r.has(o))throw xD(`${t} headers contains duplicate names`);if(r.add(o),typeof i.value!=`string`)throw xD(`${t} headers[${n}] value must be a string`);if(i.value.length>8192)throw xD(`${t} headers[${n}] value is too long`);if(!fD.test(i.value))throw xD(`${t} headers[${n}] value must be printable ASCII`);return{name:a,value:i.value}})};if(new TextEncoder().encode(JSON.stringify(i)).byteLength>24576)throw xD(`${t} exceeds its serialized byte limit`);return i}function gD(e,t,n){let r=_D(e,n),i=new Set(t);for(let e of Object.keys(r))if(!i.has(e))throw xD(`${n} contains unknown field ${e}`);return r}function _D(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw xD(`${t} must be an object`);return e}function vD(e,t){let n=yD(e,t,512);if(!uD.test(n))throw xD(`${t} must be an opaque ASCII token`);return n}function yD(e,t,n){if(typeof e!=`string`||e.length===0||e.length>n)throw xD(`${t} must be a non-empty string of at most ${n} characters`);return e}function bD(e,t){if(typeof e!=`boolean`)throw xD(`${t} must be a boolean`);return e}function xD(e){return TypeError(`Invalid Runtime Browser protocol: ${e}`)}var SD=5242880,CD=20971520,wD=8192,TD=4e7,ED=[`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/svg+xml`];function DD(){return{enabled:!0,mediaTypes:[...ED],maxImagesPerMessage:4,maxImageBytes:SD,maxMessageBytes:CD,maxImageSide:wD,maxImagePixels:TD}}var OD={fields:64,optionsPerField:128,actions:16,routingSkeletonBytes:36864};new TextEncoder;var kD=16384;OD.fields,OD.optionsPerField,OD.actions,new TextEncoder;function AD(e,t){let n=new Map;for(let e of t)e.type===`interaction_request`&&n.set(e.data.interaction.interactionId,e);return{status:e.status,...e.statusKind===void 0?{}:{statusKind:e.statusKind},...e.backgroundTaskCount===void 0?{}:{backgroundTaskCount:e.backgroundTaskCount},activeResponseIds:[...e.activeResponseIds],pendingInteractions:e.pendingInteractions.flatMap(e=>{let t=n.get(e.interactionId);return!t||t.responseId!==e.responseId?[]:[{responseId:e.responseId,interaction:t.data.interaction}]})}}4*Math.ceil(kD/3),new Set(Object.keys({"status.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:null},"provider.cli.status.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.provider-cli.status.v1`},"project.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.project.manage.v1`},"project.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.project.manage.v1`},"project.create":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.project.manage.v1`},"project.update":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.project.manage.v1`},"project.delete":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.project.manage.v1`},"emulator.devices.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.active.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.attach":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.tap":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.type":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.button":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.rotate":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.launch":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.gesture":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.kill":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.shutdown":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"session.emulator.state.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.devices.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.attach":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.detach":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.tap":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.type":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.button":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.rotate":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.launch":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.gesture":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.list.v1`},"session.agentOptions.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.agent-options.v1`},"session.launchOptions.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.launch-options.v2`},"session.execution.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.execution-settings.v1`},"session.execution.update":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.execution-settings.v1`},"session.create":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.create.v1`},"session.fork":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.fork.v1`},"session.message.send":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.message.v1`},"session.resource.policy.get":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.resource.upload.begin":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.resource.upload.chunk":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.resource.upload.commit":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.resource.get":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.resource.read":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.resource.delete":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.file.get":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.files.v1`},"session.file.read":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.files.v1`},"session.workspace.file.get":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.workspace-files.v1`},"session.workspace.file.read":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.workspace-files.v1`},"session.message.enqueue":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.message-queue.v1`},"session.terminal.start":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.terminal-start.v1`},"session.delete":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.delete.v1`},"session.snapshot.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.snapshot.v1`},"session.interrupt":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.interrupt.v1`},"session.interaction.resolve":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.interaction.v1`},"browser.state.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.request-headers.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.request-headers.v1`},"browser.request-headers.set":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.request-headers.v1`},"browser.open":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.close":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.create":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.close":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.activate":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.navigate":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.back":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.forward":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.reload":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`}})),new TextEncoder;var jD=0;function MD(e){let t=globalThis.crypto;if(typeof t?.randomUUID==`function`)return`${e}_${t.randomUUID()}`;if(typeof t?.getRandomValues==`function`){let n=t.getRandomValues(new Uint8Array(16));return`${e}_${Array.from(n,e=>e.toString(16).padStart(2,`0`)).join(``)}`}return jD=jD+1>>>0,`${e}_${Date.now().toString(36)}_${jD.toString(36)}`}var ND=256,PD=4194304;function FD(e,t,n,r){return e||(n?t:r)}function ID(e){return e.type===`response.created`||e.type===`session.input.consumed`}function LD(e,t,n){return n&&e!==null&&t===e}function RD(e,t){return e&&t}function zD(e){let t=Object.entries(e);for(let e=t.length-1;e>=0;--e){let n=t[e];if(n?.[1].status===`running`)return n[0]}}function BD(e,{runtimeSelector:t,allowSend:n=!0}={}){let[r,i]=(0,u.useReducer)(QE,void 0,gE),[a,o]=(0,u.useState)(!1),[s,c]=(0,u.useState)(!1),l=(0,u.useRef)(null),d=(0,u.useRef)(0),f=(0,u.useRef)(null),p=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(i({kind:`reset`}),f.current=null,p.current=null,o(!1),c(!1),!e)return;let n=new AbortController,r=!1,a=!0,s;return(async()=>{let l=500;for(;!n.signal.aborted;){let u=new AbortController,d=()=>u.abort();n.signal.addEventListener(`abort`,d,{once:!0});let m=!1,h=!1,g=!1,_={events:[],utf8Bytes:0},v,y,b=new Promise((e,t)=>{v=e,y=t}),x=Y.streamSession(e,e=>{if(!(r||u.signal.aborted)){if(e.event===`ready`){let t=HD(s,e.data);s=t.daemonInstanceId,t.changed&&(a=!0,i({kind:`reset`}),c(!1)),v()}else if(e.event===`event`){let t=e.data,n=f.current;n!==null&&ID(t)&&(p.current=n,LD(f.current,p.current,m)&&(f.current=null,p.current=null,o(!1))),m?i({kind:`event`,event:t}):VD(_,t)||(g=!0,u.abort())}else e.event===`error`&&i({kind:`stream_error`,message:String(e.data.message??`stream error`)})}},u.signal,t).then(()=>(y(Error(`session stream closed before ready`)),{error:void 0})).catch(e=>(y(e),{error:e}));try{await b,l=500;let o=500,s,c=0,d=[],f=[];for(;;){let l=new AbortController,p=()=>l.abort();u.signal.addEventListener(`abort`,p,{once:!0}),u.signal.aborted&&l.abort();let m=t?Y.getSessionSnapshotPage(e,s,l.signal,t).then(e=>({kind:`snapshot_page`,page:e})).catch(e=>({kind:`snapshot_error`,error:e})):Y.getSessionSnapshot(e,l.signal).then(e=>({kind:`snapshot`,snapshot:e})).catch(e=>({kind:`snapshot_error`,error:e})),_=await Promise.race([m,x.then(()=>({kind:`stream_ended`}))]);if(u.signal.removeEventListener(`abort`,p),_.kind===`stream_ended`){l.abort();break}if(r||n.signal.aborted)return;if(g)break;if(_.kind===`snapshot_page`){let{page:t}=_;if(t.sessionId!==e||t.hasMore&&(!t.nextAfterId||t.nextAfterId===s)){i({kind:`stream_error`,message:`Session snapshot page did not advance`}),u.abort();break}if(d.push(...t.items),f=t.pendingInputs??[],i({kind:a&&c===0?`history`:`reconcile_history`,items:t.items}),c+=1,o=500,t.hasMore){s=t.nextAfterId;continue}i({kind:`reconcile_snapshot`,items:[],pendingInputs:f,pruneMissingPending:!a,runtime:AD(t.runtime,d)}),h=!0,a=!1;break}if(_.kind===`snapshot`){let{snapshot:e}=_;i({kind:a?`snapshot`:`reconcile_snapshot`,items:e.items,pendingInputs:e.pendingInputs??[],...a?{}:{pruneMissingPending:!0},runtime:e.runtime}),h=!0,a=!1;break}let{error:v}=_;i({kind:`stream_error`,message:v instanceof Error?v.message:String(v)});let y=await Promise.race([x.then(()=>`stream_ended`),UD(o,n.signal).then(()=>`retry`)]);if(n.signal.aborted)return;if(y===`stream_ended`)break;o=Math.min(o*2,8e3)}}catch(e){!r&&!n.signal.aborted&&!g&&i({kind:`stream_error`,message:e instanceof Error?e.message:String(e)})}finally{if(g||(m=!0),!r&&!n.signal.aborted&&!g){for(let e of _.events.splice(0))i({kind:`event`,event:e});_.utf8Bytes=0,h&&(c(!0),LD(f.current,p.current,!0)&&(f.current=null,p.current=null,o(!1)))}}let S=await x;if(r||c(!1),n.signal.removeEventListener(`abort`,d),u.abort(),n.signal.aborted)return;S.error,await UD(l,n.signal),l=Math.min(l*2,8e3)}})(),()=>{r=!0,n.abort()}},[t,e]);let m=(0,u.useCallback)(async r=>{if(!e||!n)return;let a=typeof r==`string`?r:r.text,s=typeof r==`string`?[]:r.attachments,c=typeof r==`string`?MD(`msg`):r.clientMessageId??MD(`msg`),u=new AbortController,m=++d.current;l.current=u,f.current=m,p.current=null,o(!0);let h=c;i({kind:`optimistic_user`,id:h,text:a,attachments:s});try{await Y.sendSessionMessage(e,{content:[...s,...a?[{type:`input_text`,text:a}]:[]],clientMessageId:c},()=>{},u.signal,t)}catch(e){throw u.signal.aborted||(Ux(e)&&i({kind:`discard_optimistic_user`,id:h}),i({kind:`stream_error`,message:e.message})),f.current===m&&(f.current=null,p.current=null,o(!1)),e}finally{l.current===u&&(l.current=null)}},[n,t,e]),h=(0,u.useCallback)(async()=>{if(l.current?.abort(),f.current=null,p.current=null,o(!1),!e)return;let n=zD(r.turns);n&&i({kind:`event`,event:{type:`session.interrupted`,sessionId:e,responseId:n}});try{await Y.interruptSession(e,t)}catch{}},[t,e,r.turns]);return(0,u.useEffect)(()=>{if(!a)return;if(RD(s,r.runStatus===`running`||r.waitingForInteraction)){f.current=null,p.current=null,o(!1);return}let e=f.current,t=window.setTimeout(()=>{f.current===e&&(f.current=null,p.current=null,o(!1))},15e3);return()=>window.clearTimeout(t)},[s,a,r.runStatus,r.waitingForInteraction]),{state:r,pendingSend:a,current:s,send:m,stop:h}}function VD(e,t,n={}){let r=n.events??ND,i=n.utf8Bytes??PD,a;try{a=new TextEncoder().encode(JSON.stringify(t)).byteLength}catch{return!1}return e.events.length>=r||a>i||e.utf8Bytes+a>i?!1:(e.events.push(t),e.utf8Bytes+=a,!0)}function HD(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t.daemonInstanceId:void 0;return typeof n!=`string`||n.length===0?{daemonInstanceId:e,changed:!1}:{daemonInstanceId:n,changed:e!==void 0&&e!==n}}function UD(e,t){return t.aborted?Promise.resolve():new Promise(n=>{let r=window.setTimeout(i,e);t.addEventListener(`abort`,i,{once:!0});function i(){window.clearTimeout(r),t.removeEventListener(`abort`,i),n()}})}var WD=4096,GD=4096,KD=512,qD=1024,JD=new Uint8Array([82,66,83,70]),YD=38,XD=1,ZD=2,QD=new TextEncoder,$D=new TextDecoder(`utf-8`,{fatal:!0});function eO(e){let t=nO(e);switch(t.type){case`browser.surface.ready`:{iO(t,[`type`,`subscriptionId`,`browserGeneration`,`viewportRevision`,`sourceWidth`,`sourceHeight`,`deviceScaleFactor`,`format`,`grantedRole`],`Browser Surface ready frame`);let e=dO(t.sourceWidth,`sourceWidth`),n=dO(t.sourceHeight,`sourceHeight`);return fO(e,n),{type:`browser.surface.ready`,subscriptionId:aO(t.subscriptionId,`subscriptionId`),browserGeneration:sO(t.browserGeneration,`browserGeneration`),viewportRevision:cO(t.viewportRevision,`viewportRevision`),sourceWidth:e,sourceHeight:n,deviceScaleFactor:uO(t.deviceScaleFactor,.25,8,`deviceScaleFactor`),format:pO(t.format),grantedRole:mO(t.grantedRole,[`view`,`control`],`grantedRole`)}}case`browser.surface.driver.changed`:{iO(t,[`type`,`subscriptionId`,`browserGeneration`,`driver`,`driverSubscriptionId`],`driver changed frame`,!0);let e=mO(t.driver,[`none`,`desktop`,`stream`],`driver`),n=t.driverSubscriptionId===void 0?void 0:aO(t.driverSubscriptionId,`driverSubscriptionId`);if(e===`stream`!=(n!==void 0))throw gO(`driverSubscriptionId is required only when driver is stream`);return{type:`browser.surface.driver.changed`,subscriptionId:aO(t.subscriptionId,`subscriptionId`),browserGeneration:sO(t.browserGeneration,`browserGeneration`),driver:e,...n===void 0?{}:{driverSubscriptionId:n}}}case`browser.surface.closed`:{iO(t,[`type`,`subscriptionId`,`reason`,`message`],`Browser Surface closed frame`,!0);let e=t.message===void 0?void 0:oO(t.message,`message`,qD);return{type:`browser.surface.closed`,subscriptionId:aO(t.subscriptionId,`subscriptionId`),reason:mO(t.reason,[`browser_closed`,`page_closed`,`generation_changed`,`replaced`,`cancelled`,`unauthorized`,`unsupported`,`capacity`,`idle_timeout`,`protocol_error`,`internal_error`],`reason`),...e===void 0?{}:{message:e}}}default:throw gO(`unknown Browser Surface server frame type`)}}function tO(e){if(!(e instanceof Uint8Array)||e.byteLength<39||e.byteLength>4194854)throw gO(`Browser Surface image frame has an invalid byte length`);for(let t=0;t<JD.length;t+=1)if(e[t]!==JD[t])throw gO(`Browser Surface image frame has invalid magic`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint8(4)!==1||t.getUint16(6,!1)!==0)throw gO(`Browser Surface image frame header is unsupported`);let n=t.getUint8(5),r=n===XD?`jpeg`:n===ZD?`png`:void 0;if(r===void 0)throw gO(`Browser Surface image frame format is unsupported`);let i=t.getUint16(32,!1),a=t.getUint32(34,!1);if(i===0||i>KD||a===0||a>4194304||YD+i+a!==e.byteLength)throw gO(`Browser Surface image frame lengths are invalid`);let o;try{o=$D.decode(e.subarray(YD,YD+i))}catch{throw gO(`subscriptionId must be valid UTF-8`)}o=aO(o,`subscriptionId`);let s=hO(t.getBigUint64(8,!1),`frameSequence`),c=t.getUint32(16,!1),l=hO(t.getBigUint64(20,!1),`timestampMilliseconds`),u=dO(t.getUint16(28,!1),`width`),d=dO(t.getUint16(30,!1),`height`);return fO(u,d),{subscriptionId:o,frameSequence:s,viewportRevision:c,timestampMilliseconds:l,width:u,height:d,format:r,encodedBytes:new Uint8Array(e.subarray(YD+i))}}function nO(e){let t=e;if(typeof e==`string`){if(QD.encode(e).byteLength>32768)throw gO(`Browser Surface control frame exceeds its byte limit`);try{t=JSON.parse(e)}catch{throw gO(`Browser Surface control frame must be valid JSON`)}}let n=rO(t,`Browser Surface control frame`),r;try{r=JSON.stringify(n)}catch{throw gO(`Browser Surface control frame must be serializable`)}if(QD.encode(r).byteLength>32768)throw gO(`Browser Surface control frame exceeds its byte limit`);return n}function rO(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw gO(`${t} must be an object`);return e}function iO(e,t,n,r=!1){let i=Object.keys(e),a=r?t.length-1:t.length;if(i.length<a||i.length>t.length||i.some(e=>!t.includes(e))||t.slice(0,a).some(t=>!Object.hasOwn(e,t)))throw gO(`${n} contains unknown or missing fields`)}function aO(e,t){if(typeof e!=`string`||e.length===0||QD.encode(e).byteLength>KD||!/^[\x21-\x7e]+$/.test(e))throw gO(`${t} must be a bounded opaque identifier`);return e}function oO(e,t,n){if(typeof e!=`string`||e.includes(`\0`)||QD.encode(e).byteLength>n)throw gO(`${t} exceeds its text byte limit`);return e}function sO(e,t){if(!Number.isSafeInteger(e)||e<1)throw gO(`${t} must be a positive safe integer`);return e}function cO(e,t){if(!Number.isSafeInteger(e)||e<0)throw gO(`${t} must be a nonnegative safe integer`);return e}function lO(e,t,n,r){if(!Number.isInteger(e)||e<t||e>n)throw gO(`${r} must be an integer from ${t} to ${n}`);return e}function uO(e,t,n,r){if(typeof e!=`number`||!Number.isFinite(e)||e<t||e>n)throw gO(`${r} must be a finite number from ${t} to ${n}`);return e}function dO(e,t){return lO(e,1,t.toLowerCase().includes(`height`)?GD:WD,t)}function fO(e,t){if(e*t>8847360)throw gO(`Browser Surface viewport exceeds its maximum pixels`)}function pO(e){return mO(e,[`jpeg`,`png`],`format`)}function mO(e,t,n){if(typeof e!=`string`||!t.includes(e))throw gO(`${n} is unsupported`);return e}function hO(e,t){if(e>BigInt(2**53-1))throw gO(`${t} exceeds a safe integer`);return Number(e)}function gO(e){return TypeError(`Invalid Runtime Browser Surface: ${e}`)}var _O=1e4,vO=16,yO=1,bO=[500,1e3,2e3,4e3,8e3,15e3];function xO(e){return bO[Math.max(0,Math.min(Math.trunc(e),bO.length-1))]}function SO(e){return e===1e3||e===1001||e===1006||e===1012||e===4408}function CO(e){return e===`browser_closed`||e===`generation_changed`||e===`cancelled`||e===`capacity`||e===`idle_timeout`||e===`internal_error`}function wO(e){let t=e.trim();if(t)return/^[A-Za-z][A-Za-z\d+.-]*:/.test(t)?t:`https://${t}`}function TO(e){return!(e instanceof Error)||!e.message?`Browser operation failed`:e.message===`failed_precondition`?"Browser Host is unavailable. On a headless Runtime, run `rynx browser install` on that host.":e.message.replaceAll(`_`,` `)}function EO(e,t,n){return n&&e===`local`&&t.executionBackend===`embedded-electron`&&t.capabilities.includes(`desktop-direct-view`)}function DO(e,t,n){return!n||e!==`local`?!1:t.status===`unavailable`||t.status===`ready`&&t.executionBackend===`headless-chromium`}function OO(e,t,n){return n&&e===`local`&&t.status===`ready`&&t.executionBackend===`embedded-electron`&&!t.capabilities.includes(`desktop-direct-view`)}async function kO(e,t){let n=e.pages.findIndex(t=>t.pageId===e.activePageId);await t.close(e.browserGeneration);let r=await t.open(e.pages[0]?.url);t.onProgress?.(r);for(let n of e.pages.slice(1))r=await t.createPage(r.browserGeneration,n.url),t.onProgress?.(r);let i=n>=0?r.pages[n]:void 0;return i&&r.activePageId!==i.pageId&&(r=await t.activatePage(r.browserGeneration,i.pageId),t.onProgress?.(r)),r}function AO({scrollLeft:e,viewportWidth:t,contentWidth:n,availableWidth:r=t}){let i=Math.max(0,n-t),a=n-r>yO;return{hasOverflow:a,canScrollLeft:a&&e>yO,canScrollRight:a&&e<i-yO}}function jO(e){return Math.max(120,e*.75)}function MO({scrollLeft:e,viewportWidth:t,tabLeft:n,tabWidth:r,inset:i=4}){let a=e,o=e+t,s=Math.max(0,n-i),c=n+r+i;return s<a?s-a:c>o?c-o:0}function NO(e,t,n,r){return{deltaX:PO(e+n),deltaY:PO(t+r)}}function PO(e){return Number.isFinite(e)?Math.max(-1e4,Math.min(_O,e)):0}function FO(e){if(!e)return[];let t=new TextEncoder,n=[],r=``,i=0;for(let a of e){let e=t.encode(a).byteLength;if(i+e>4096){if(n.push(r),n.length>=vO)throw RangeError(`Browser text input is too large`);r=``,i=0}r+=a,i+=e}return r&&n.push(r),n}function IO(e,t){if(t.type===`pointerdown`){let n=LO(t.button);return n&&e.set(t.pointerId,n),n}let n=e.get(t.pointerId);return e.delete(t.pointerId),n??LO(t.button)}function LO(e){if(e===0)return`left`;if(e===1)return`middle`;if(e===2)return`right`;if(e===3)return`back`;if(e===4)return`forward`}var RO=1,zO=2;function BO({runtimeSelector:e,sessionId:t,browserGeneration:n,pageId:r,toolbarHost:i,readOnly:a=!1}){let o=(0,u.useRef)(null),s=(0,u.useRef)(null),c=(0,u.useRef)(void 0),l=(0,u.useRef)(void 0),f=(0,u.useRef)(0),p=(0,u.useRef)(0),m=(0,u.useRef)(0),h=(0,u.useRef)(0),g=(0,u.useRef)(void 0),_=(0,u.useRef)(!1),v=(0,u.useRef)(!1),y=(0,u.useRef)(!1),b=(0,u.useRef)(void 0),x=(0,u.useRef)(void 0),S=(0,u.useRef)(void 0),C=(0,u.useRef)(new Map),[w,T]=(0,u.useState)(`connecting`),[E,D]=(0,u.useState)(),[O,k]=(0,u.useState)(),[A,j]=(0,u.useState)(`none`),[M,N]=(0,u.useState)(),[P,F]=(0,u.useState)(!1),[I,L]=(0,u.useState)(!1),ee=A===`stream`&&M===O?.subscriptionId,te=(0,u.useCallback)(()=>{S.current!==void 0&&(window.cancelAnimationFrame(S.current),S.current=void 0),b.current=void 0,x.current=void 0,C.current.clear()},[]),ne=(0,u.useCallback)(()=>{g.current!==void 0&&(window.clearTimeout(g.current),g.current=void 0)},[]),re=(0,u.useCallback)(async({refreshCapability:i=!1,preserveFrame:s=!1}={})=>{ne();let u=++m.current;c.current?.close(1e3,`Browser Surface reconnecting`),c.current=void 0,l.current=void 0,f.current=0,p.current=0,y.current=!1,v.current=!1,te(),T(`connecting`),D(void 0),k(void 0),j(`none`),N(void 0),L(!1),s||(_.current=!1,F(!1));let d=e=>{if(m.current!==u)return;D(e),T(`connecting`);let t=xO(h.current++);g.current=window.setTimeout(()=>{g.current=void 0,re({preserveFrame:!0})},t)};try{let s=await Qx(i);if(m.current!==u)return;let p=new WebSocket(UO({runtimeSelector:e,sessionId:t,pageId:r,browserGeneration:n,capability:s,readOnly:a}));p.binaryType=`arraybuffer`,c.current=p;let g=i,b=!1;p.onmessage=e=>{if(m.current!==u||c.current!==p)return;if(typeof e.data==`string`){try{let t=JSON.parse(e.data);if(t&&typeof t==`object`&&`type`in t&&t.type===`error`){let e=`message`in t&&typeof t.message==`string`?t.message:`Browser Surface failed`;D(e);return}let n=eO(t);if(n.type===`browser.surface.ready`){l.current=n,f.current=n.viewportRevision,ne(),k(n),T(`ready`);return}if(n.type===`browser.surface.driver.changed`){let e=n.driver===`stream`&&n.driverSubscriptionId===l.current?.subscriptionId;y.current=e,e||te(),j(n.driver),N(n.driverSubscriptionId);return}y.current=!1,te();let r=n.message??qO(n.reason);b=!0,CO(n.reason)?(d(r),p.close(1e3,`recovering Browser Surface`)):(D(r),T(`closed`))}catch{b=!0,D(`Browser Surface sent an invalid control frame`),T(`closed`),p.close(4400,`invalid Browser Surface control`)}return}if(!(e.data instanceof ArrayBuffer)){D(`Browser Surface sent an invalid image frame`),p.close(4400,`invalid Browser Surface image`);return}let t=()=>m.current===u&&c.current===p;VO(e.data,p,o.current,l.current,t).then(e=>{e===void 0||!t()||(f.current=e,_.current=!0,v.current=!0,h.current=0,F(!0),L(!0))}).catch(()=>{t()&&(b=!0,D(`Browser preview could not be decoded`),T(`closed`),p.close(4400,`Browser Surface image decode failed`))})},p.onclose=e=>{if(m.current===u&&c.current===p&&(c.current=void 0,y.current=!1,te(),!b)){if((e.code===4403||e.code===1006)&&!g){g=!0,re({refreshCapability:!0,preserveFrame:!0});return}if(SO(e.code)){d(JO(e.code));return}T(`closed`),D(t=>t??JO(e.code))}},p.onerror=()=>{c.current===p&&D(`Browser preview transport failed`)}}catch(e){if(m.current!==u)return;d(e instanceof Error?e.message:`Browser preview could not connect`)}},[e,t,r,n,a,te,ne]);(0,u.useEffect)(()=>(re(),()=>{m.current+=1,ne(),te(),c.current?.close(1e3,`Browser Surface view unmounted`),c.current=void 0}),[re,te,ne]);let R=(0,u.useCallback)(()=>{h.current=0,re({preserveFrame:!0})},[re]),ie=(0,u.useCallback)(e=>{let t=c.current;return!t||t.readyState!==WebSocket.OPEN?!1:(t.send(JSON.stringify(e)),!0)},[]),ae=(0,u.useCallback)(()=>{let e=l.current;!e||!v.current||(ie({type:`browser.surface.driver.take`,subscriptionId:e.subscriptionId,browserGeneration:e.browserGeneration,viewportRevision:f.current}),s.current?.focus())},[ie]),oe=(0,u.useCallback)(()=>{let e=l.current;e&&(te(),s.current&&(s.current.value=``),ie({type:`browser.surface.driver.release`,subscriptionId:e.subscriptionId,browserGeneration:e.browserGeneration}))},[ie,te]),se=(0,u.useCallback)(e=>{let t=l.current;return!t||!v.current||!y.current?!1:ie({type:`browser.surface.input`,subscriptionId:t.subscriptionId,browserGeneration:t.browserGeneration,viewportRevision:f.current,inputSequence:p.current++,event:e})},[ie]),ce=(0,u.useCallback)(e=>{let t;try{t=FO(e)}catch{return D(`Text input is limited to 64 KiB at a time.`),!1}let n=!1;for(let e of t){if(!se({type:`text.insert`,text:e}))return n;n=!0}return n},[se]),le=(0,u.useCallback)(()=>{S.current!==void 0&&(window.cancelAnimationFrame(S.current),S.current=void 0);let e=b.current,t=x.current;b.current=void 0,x.current=void 0,y.current&&(e&&se({...e}),t&&se({...t}))},[se]),ue=(0,u.useCallback)(()=>{S.current===void 0&&(S.current=window.requestAnimationFrame(le))},[le]);(0,u.useEffect)(()=>{y.current=ee,ee||(te(),s.current&&(s.current.value=``,s.current.blur()))},[ee,te]);let de=(0,u.useCallback)(e=>{if(!ee)return;let t=WO(e.currentTarget,e.clientX,e.clientY);if(!t)return;if(e.type===`pointermove`){b.current={type:`pointer.move`,...t,modifiers:GO(e)},ue(),e.preventDefault();return}le(),e.type===`pointerdown`&&(s.current?.focus(),e.currentTarget.setPointerCapture(e.pointerId));let n=e.type===`pointerdown`?`pointer.down`:`pointer.up`,r=IO(C.current,e);if(!r)return;let i={type:n,...t,button:r,modifiers:GO(e)};se(i)&&e.preventDefault()},[ee,se,le,ue]),fe=(0,u.useCallback)(e=>{if(!ee)return;let t=WO(e.currentTarget,e.clientX,e.clientY);if(!t)return;let n=e.deltaMode===RO?16:e.deltaMode===zO?Math.max(1,e.currentTarget.clientHeight):1,r=x.current,i=NO(r?.deltaX??0,r?.deltaY??0,e.deltaX*n,e.deltaY*n);x.current={type:`wheel`,...t,...i,modifiers:GO(e)},ue(),e.preventDefault()},[ee,ue]),pe=(0,u.useCallback)(e=>{if(e.nativeEvent.isComposing||e.key===`Process`||e.key===`Dead`)return;le();let t=se({type:e.type===`keydown`?`key.down`:`key.up`,key:e.key,code:e.code,repeat:e.repeat,modifiers:GO(e)}),n=HO({type:e.type,key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,isComposing:e.nativeEvent.isComposing}),r=n!==void 0&&ce(n);(t||r)&&e.preventDefault()},[se,ce,le]),me=(0,u.useCallback)(e=>{le();let t=e.clipboardData.getData(`text/plain`);t&&ce(t)&&e.preventDefault()},[ce,le]),he=(0,u.useCallback)(e=>{let t=e.data||e.currentTarget.value;e.currentTarget.value=``,t&&ce(t)},[ce]);return(0,H.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-[#111318]`,children:[(0,H.jsx)(`canvas`,{ref:o,className:`max-h-full max-w-full outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--ring)]`,"aria-label":ee?`Interactive browser preview`:`Browser preview`,tabIndex:-1,onPointerMove:de,onPointerDown:de,onPointerUp:de,onPointerCancel:de,onWheel:fe}),(0,H.jsx)(`textarea`,{ref:s,"aria-label":`Browser keyboard input`,className:`pointer-events-none absolute left-0 top-0 size-px resize-none opacity-0`,tabIndex:ee?0:-1,autoComplete:`off`,spellCheck:!1,onKeyDown:pe,onKeyUp:pe,onPaste:me,onCompositionEnd:he}),w===`connecting`&&(0,H.jsx)(KO,{preserveFrame:P,icon:(0,H.jsx)(B,{className:`size-5 animate-spin`}),label:P?`Reconnecting preview…`:`Connecting preview…`}),w===`ready`&&!I&&(0,H.jsx)(KO,{icon:(0,H.jsx)(B,{className:`size-5 animate-spin`}),label:`Waiting for first frame…`}),w===`closed`&&(0,H.jsx)(`div`,{className:`absolute inset-0 grid place-items-center bg-[#111318]/90 px-6 text-center`,children:(0,H.jsxs)(`div`,{className:`max-w-sm`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-white`,children:`Preview disconnected`}),(0,H.jsx)(`p`,{role:`alert`,className:`mt-1 text-xs leading-5 text-white/60`,children:E??`The Browser Surface ended.`})]})}),i&&(0,d.createPortal)((0,H.jsx)(`div`,{className:`flex items-center`,children:w===`closed`?(0,H.jsx)(J,{size:`icon-sm`,variant:`outline`,className:`size-8`,"aria-label":`Reconnect browser preview`,title:`Reconnect browser preview`,onClick:R,children:(0,H.jsx)(zr,{className:`size-4`})}):w!==`ready`||!I?(0,H.jsx)(J,{size:`icon-sm`,variant:`outline`,className:`size-8`,"aria-label":_.current?`Reconnecting browser preview`:`Connecting browser preview`,title:_.current?`Reconnecting browser preview`:`Connecting browser preview`,disabled:!0,children:(0,H.jsx)(B,{className:`size-4 animate-spin`})}):a?(0,H.jsx)(J,{size:`icon-sm`,variant:`outline`,className:`size-8`,"aria-label":`Browser preview is read only`,title:`Browser preview is read only`,disabled:!0,children:(0,H.jsx)(Tr,{className:`size-4`})}):ee?(0,H.jsx)(J,{size:`icon-sm`,variant:`outline`,className:`size-8`,"aria-label":`Release browser control`,title:`Release browser control`,onClick:oe,children:(0,H.jsx)(Tr,{className:`size-4`})}):(0,H.jsx)(J,{size:`icon-sm`,className:`size-8`,"aria-label":`Take browser control`,title:`Take browser control`,onClick:ae,children:(0,H.jsx)(Er,{className:`size-4`})})}),i),(0,H.jsx)(`p`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:E??(ee?`Browser control active`:`Browser preview ${w}`)})]})}async function VO(e,t,n,r,i){let a=tO(new Uint8Array(e));if(!r||a.subscriptionId!==r.subscriptionId||a.format!==r.format)throw Error(`Browser Surface image does not match the active subscription`);let o=await createImageBitmap(new Blob([a.encodedBytes],{type:a.format===`jpeg`?`image/jpeg`:`image/png`}));try{if(!i()||!n||t.readyState!==WebSocket.OPEN)return;n.width=a.width,n.height=a.height;let e=n.getContext(`2d`,{alpha:!1});if(!e)throw Error(`Browser preview canvas is unavailable`);return e.drawImage(o,0,0,a.width,a.height),t.send(JSON.stringify({type:`browser.surface.frame.ack`,subscriptionId:r.subscriptionId,frameSequence:a.frameSequence})),a.viewportRevision}finally{o.close()}}function HO(e){if(!(e.type!==`keydown`||e.isComposing||e.key===`Process`||e.key===`Dead`||e.altKey||e.ctrlKey||e.metaKey||Array.from(e.key).length!==1))return e.key}function UO(e){let t=location.protocol===`https:`?`wss`:`ws`,n=new URLSearchParams({generation:String(e.browserGeneration),role:e.readOnly?`view`:`control`,format:`jpeg`,quality:`75`,maximumFrameRate:`15`,capability:e.capability});return Vx(n),`${t}://${location.host}/api/runtimes/${encodeURIComponent(e.runtimeSelector)}/sessions/${encodeURIComponent(e.sessionId)}/browser/pages/${encodeURIComponent(e.pageId)}/surface?${n.toString()}`}function WO(e,t,n){let r=e.getBoundingClientRect();if(!(r.width<=0||r.height<=0||e.width<=0||e.height<=0))return{x:Math.max(0,Math.min(e.width,(t-r.left)*e.width/r.width)),y:Math.max(0,Math.min(e.height,(n-r.top)*e.height/r.height))}}function GO(e){let t=[];return e.altKey&&t.push(`alt`),e.ctrlKey&&t.push(`control`),e.metaKey&&t.push(`meta`),e.shiftKey&&t.push(`shift`),t}function KO({icon:e,label:t,preserveFrame:n=!1}){return(0,H.jsx)(`div`,{className:n?`absolute inset-0 grid place-items-center bg-[#111318]/55 text-white`:`absolute inset-0 grid place-items-center bg-[#111318] text-white/70`,children:(0,H.jsxs)(`div`,{role:`status`,className:`flex flex-col items-center gap-3 text-sm`,children:[e,t]})})}function qO(e){return e===`replaced`?`This preview was opened somewhere else.`:e===`generation_changed`?`The Browser was restarted.`:e===`page_closed`?`This Browser page was closed.`:e===`idle_timeout`?`The Browser preview timed out.`:e===`unauthorized`?`Browser preview authorization expired.`:`The Browser preview ended.`}function JO(e){return e===4403?`Browser preview authorization failed.`:e===4406?`The selected Runtime cannot provide this Browser preview.`:e===4408?`The Browser preview client was too slow.`:e===1012?`The selected Runtime disconnected.`:`The Browser preview connection closed.`}var YO=400;function XO({runtimeSelector:e,sessionId:t,browserGeneration:n,pageId:r}){let i=(0,u.useRef)(null),[a,o]=(0,u.useState)(0),[s,c]=(0,u.useState)(`mounting`),[l,d]=(0,u.useState)(`unavailable`),[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(),g=(0,u.useMemo)(()=>({runtimeSelector:e,sessionId:t,browserGeneration:n,pageId:r}),[e,t,n,r]);(0,u.useEffect)(()=>{let e=window.rynxDesktopBrowser,t=i.current;if(!e||!t){c(`unavailable`);return}let n=!1,r=0,a,o=QO(g),s=async()=>{if(n)return;let r=ZO(t.getBoundingClientRect());if(!r){e.park(g);return}try{let t=await e.mount(g,r);if(n)return;if(t===`mounted`){c(`mounted`),a!==void 0&&window.clearTimeout(a),a=void 0;return}}catch{}n||(c(`mounting`),a=window.setTimeout(()=>void s(),YO))},l=()=>{window.cancelAnimationFrame(r),r=window.requestAnimationFrame(()=>void s())},u=new ResizeObserver(l);u.observe(t),window.addEventListener(`resize`,l),window.addEventListener(`scroll`,l,!0);let f=e.onState(e=>{if(QO(e.resource)===o){if(e.state===`closed`){c(`unavailable`);return}l()}}),m=e.onDriver(e=>{QO(e.resource)===o&&(d(e.driver),e.driver===`desktop`&&(p(!1),h(void 0)))});return d(e.getDriver(g)),c(`mounting`),l(),()=>{n=!0,u.disconnect(),f(),m(),window.removeEventListener(`resize`,l),window.removeEventListener(`scroll`,l,!0),window.cancelAnimationFrame(r),a!==void 0&&window.clearTimeout(a),e.park(g)}},[g,a]);let _=async()=>{let e=window.rynxDesktopBrowser;if(!(!e||f)){p(!0),h(void 0);try{if(await e.takeBack(g)!==`taken`)throw Error(`The remote controller is no longer available.`)}catch(e){p(!1),h(e instanceof Error?e.message:`Could not take back browser control.`)}}};return(0,H.jsxs)(`div`,{ref:i,className:`relative flex min-h-0 flex-1 overflow-hidden bg-white`,"aria-label":`Embedded session browser page`,children:[s!==`mounted`&&(0,H.jsx)(`div`,{className:`absolute inset-0 z-0 grid place-items-center bg-[var(--muted)]/20 p-4 text-center`,children:s===`mounting`?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),`Attaching the local browser…`]}):(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`The local desktop browser is unavailable.`}),(0,H.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>o(e=>e+1),children:[(0,H.jsx)(zr,{}),`Retry`]})]})}),s===`mounted`&&l===`stream`&&(0,H.jsx)(`div`,{className:`absolute inset-0 z-20 grid place-items-center bg-black/45 p-4 text-center backdrop-blur-[1px]`,children:(0,H.jsxs)(`div`,{className:`max-w-sm rounded-lg border border-white/20 bg-[var(--card)] p-4 shadow-lg`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-[var(--foreground)]`,children:`Controlled from a remote viewer`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:`Local mouse and keyboard input are paused to prevent two controllers from acting at once.`}),(0,H.jsxs)(J,{className:`mt-3`,size:`sm`,disabled:f,onClick:()=>void _(),children:[f?(0,H.jsx)(B,{className:`animate-spin`}):null,`Take back control`]}),m?(0,H.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-[var(--destructive)]`,children:m}):null]})})]})}function ZO(e){let t=Math.max(0,Math.ceil(e.left)),n=Math.max(0,Math.ceil(e.top)),r=Math.min(window.innerWidth,Math.floor(e.right)),i=Math.min(window.innerHeight,Math.floor(e.bottom));return r<=t||i<=n?null:{x:t,y:n,width:r-t,height:i-n}}function QO(e){return JSON.stringify([e.runtimeSelector,e.sessionId,e.browserGeneration,e.pageId])}var $O=`size-11 sm:size-8`;function ek({sessionId:e,runtimeSelector:t,pageId:n,browserResource:r,readOnly:i=!1}){let{browser:a,loading:o,pendingAction:s,error:c,disabled:l,load:d,openBrowser:f,closeBrowser:p,recreateForDesktop:m,navigatePage:h,backPage:g,forwardPage:_,reloadPage:v}=r,y=(0,u.useMemo)(()=>a?.pages.find(e=>e.pageId===n),[a,n]),b=a!==null&&EO(t,a,window.rynxDesktopBrowser!==void 0),x=a!==null&&a.sessionId===e&&DO(t,a,window.rynxDesktopBrowser!==void 0),S=a!==null&&a.sessionId===e&&OO(t,a,window.rynxDesktopBrowser!==void 0),C=(0,u.useRef)(null),[w,T]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let n=`${t}\n${e}`;i||!x||C.current===n||(C.current=n,m())},[x,i,m,t,e]),o&&a===null?(0,H.jsx)(ik,{label:`Loading browser…`}):a===null?i?(0,H.jsx)(ak,{label:`Browser is not running for this Session.`}):(0,H.jsx)(tk,{error:c,pending:s!==null,onOpen:e=>void f(e),onRetry:()=>void d(!0)}):(0,H.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-[var(--card)]`,"aria-label":`Session browser page`,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 border-b border-[var(--border)] px-2 py-2 sm:flex-nowrap sm:px-3`,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,H.jsx)(rk,{label:`Go back`,disabled:l||!y?.canGoBack,onClick:()=>y&&void g(y.pageId),children:(0,H.jsx)(An,{})}),(0,H.jsx)(rk,{label:`Go forward`,disabled:l||!y?.canGoForward,onClick:()=>y&&void _(y.pageId),children:(0,H.jsx)(jn,{})}),(0,H.jsx)(rk,{label:`Reload page`,disabled:l||!y,onClick:()=>y&&void v(y.pageId),children:(0,H.jsx)(Br,{className:y?.loading?`animate-spin`:void 0})})]}),y?(0,H.jsx)(nk,{page:y,disabled:l,onNavigate:e=>void h(y.pageId,e)},`${y.pageId}\n${y.url}`):(0,H.jsx)(`div`,{className:`h-11 min-w-0 flex-1 rounded-lg border border-[var(--border)] bg-[var(--muted)]/30 sm:h-8`}),!b&&(0,H.jsx)(`div`,{ref:T,className:`flex shrink-0 items-center`}),!i&&S&&(0,H.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:s!==null,onClick:()=>void m(),children:`Open in app`}),!i&&(0,H.jsx)(rk,{label:`Stop browser`,disabled:s!==null,onClick:()=>void p(),children:(0,H.jsx)(Lr,{})})]}),(0,H.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[x?(0,H.jsx)(ik,{label:`Opening in Desktop…`}):a.status===`ready`&&y?b?(0,H.jsx)(XO,{runtimeSelector:t,sessionId:e,browserGeneration:a.browserGeneration,pageId:y.pageId}):(0,H.jsx)(BO,{runtimeSelector:t,sessionId:e,browserGeneration:a.browserGeneration,pageId:y.pageId,readOnly:i,toolbarHost:w}):a.status===`ready`?(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-[var(--muted-foreground)]`,children:`No browser page is open.`}):a.status===`unavailable`&&i?(0,H.jsx)(ak,{label:`Browser is unavailable.`}):a.status===`unavailable`?(0,H.jsx)(ok,{error:c,pending:s!==null,onRestart:()=>void f()}):(0,H.jsx)(ik,{label:a.status===`closing`?`Closing browser…`:`Starting browser…`}),c&&a.status!==`unavailable`&&(0,H.jsx)(`div`,{role:`alert`,className:`absolute bottom-3 left-1/2 max-w-[calc(100%-1.5rem)] -translate-x-1/2 rounded-md border border-[var(--destructive)]/30 bg-[var(--card)] px-3 py-2 text-xs text-[var(--destructive)] shadow-sm`,children:c})]}),(0,H.jsx)(`p`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:s??c??(a.status===`ready`?`Browser ready`:`Browser ${a.status}`)})]})}function tk({error:e,pending:t,onOpen:n,onRetry:r}){let[i,a]=(0,u.useState)(``);return(0,H.jsx)(U_,{className:`min-h-0 flex-1 bg-[var(--muted)]/20`,children:(0,H.jsx)(`main`,{className:`flex min-h-full items-center justify-center p-4 sm:p-6`,children:(0,H.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n(wO(i))},className:`w-full max-w-xl rounded-lg border border-[var(--border)] bg-[var(--card)] p-4 shadow-sm sm:p-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(Xn,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h3`,{className:`text-base font-semibold`,children:`Open a browser for this session`}),(0,H.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-[var(--muted-foreground)]`,children:`The browser runs on the selected Runtime, beside the agent using it.`})]})]}),(0,H.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2 sm:flex-row`,children:[(0,H.jsx)(Ag,{value:i,onChange:e=>a(e.target.value),"aria-label":`Initial browser address`,placeholder:`https://example.com (optional)`,className:`h-11 flex-1 sm:h-9`,disabled:t,autoFocus:!0}),(0,H.jsxs)(J,{type:`submit`,className:`h-11 sm:h-9`,disabled:t,children:[t?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Xn,{}),t?`Opening…`:`Open browser`]})]}),e&&(0,H.jsxs)(`div`,{role:`alert`,className:`mt-3 flex items-center justify-between gap-3 rounded-md bg-[var(--destructive)]/10 px-3 py-2 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(`span`,{children:e}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:`Retry`})]}),(0,H.jsx)(`p`,{className:`sr-only`,"aria-live":`polite`,children:t?`Starting browser`:``})]})})})}function nk({page:e,disabled:t,onNavigate:n}){let[r,i]=(0,u.useState)(e.url);return(0,H.jsx)(`form`,{onSubmit:e=>{e.preventDefault();let t=wO(r);t&&n(t)},className:`order-last flex min-w-full flex-1 sm:order-none sm:min-w-0`,children:(0,H.jsx)(Ag,{value:r,onChange:e=>i(e.target.value),"aria-label":`Browser address`,className:`h-11 rounded-lg bg-[var(--muted)]/35 font-mono text-xs sm:h-8`,disabled:t,spellCheck:!1})})}function rk({label:e,disabled:t,onClick:n,children:r}){return(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:$O,"aria-label":e,title:e,disabled:t,onClick:n,children:r})}function ik({label:e}){return(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 bg-[var(--muted)]/20 text-sm text-[var(--muted-foreground)]`,"aria-live":`polite`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),e]})}function ak({label:e}){return(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-[var(--muted)]/20 text-sm text-[var(--muted-foreground)]`,"aria-live":`polite`,children:e})}function ok({error:e,pending:t,onRestart:n}){return(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4 text-center`,role:`status`,children:[(0,H.jsx)(zr,{className:`size-5 text-[var(--muted-foreground)]`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`Browser is unavailable`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:e??`The selected Runtime cannot provide this browser right now.`})]}),(0,H.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:t,onClick:n,children:[t&&(0,H.jsx)(B,{className:`animate-spin`}),t?`Restarting…`:`Restart browser`]})]})}function sk({open:e,onClose:t,runtimeSelector:n,sessionId:r}){let[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)([]),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(!e)return;let t=!1;return f(!0),g(null),Y.getRuntimeBrowserRequestHeaders(n,r).then(e=>{t||(a(e.revision),s(e.enabled),l(e.headers.map(e=>({...e}))))}).catch(e=>{t||g(ck(e))}).finally(()=>{t||f(!1)}),()=>{t=!0}},[e,n,r]);let _=(e,t,n)=>{l(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},v=async()=>{if(!(i===null||p)){m(!0),g(null);try{let e=mD({sessionId:r,expectedRevision:i,enabled:o,headers:c}),s=await Y.updateRuntimeBrowserRequestHeaders(n,e);a(s.revision),V.success(`Browser request headers updated`),t()}catch(e){if(e instanceof Hx&&e.status===409)try{let e=await Y.getRuntimeBrowserRequestHeaders(n,r);a(e.revision),g(`These settings changed elsewhere. Your draft was preserved; review it and Save again to replace the latest version.`)}catch(e){g(ck(e))}else g(ck(e))}finally{m(!1)}}};return(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold`,children:`Browser request headers`}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-[var(--muted-foreground)]`,children:`Apply request headers to all requests, including subresources, from every Browser page in this Session. Changes affect existing and future pages.`})]}),d?(0,H.jsxs)(`div`,{className:`flex min-h-44 items-center justify-center text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`mr-2 size-4 animate-spin`}),` Loading settings…`]}):(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-lg border border-[var(--border)] p-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:`Enable request headers`}),(0,H.jsx)(`div`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Turning this off keeps the rows below without sending them.`})]}),(0,H.jsx)(Ub,{checked:o,onCheckedChange:s,disabled:i===null||p,"aria-label":`Enable Browser request headers`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)_2rem] gap-2 px-1 text-xs font-medium text-[var(--muted-foreground)]`,children:[(0,H.jsx)(`span`,{children:`Name`}),(0,H.jsx)(`span`,{children:`Value`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Actions`})]}),c.length===0&&(0,H.jsx)(`div`,{className:`rounded-lg border border-dashed border-[var(--border)] px-3 py-6 text-center text-sm text-[var(--muted-foreground)]`,children:`No request headers configured.`}),c.map((e,t)=>(0,H.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)_2rem] gap-2`,children:[(0,H.jsx)(Ag,{value:e.name,onChange:e=>_(t,`name`,e.target.value),placeholder:`X-Example`,disabled:p,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,"aria-label":`Header ${t+1} name`}),(0,H.jsx)(Ag,{value:e.value,onChange:e=>_(t,`value`,e.target.value),placeholder:`value`,disabled:p,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,"aria-label":`Header ${t+1} value`}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:p,onClick:()=>l(e=>e.filter((e,n)=>n!==t)),"aria-label":`Remove header ${t+1}`,title:`Remove header`,children:(0,H.jsx)(si,{})})]},t)),(0,H.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:p||c.length>=32,onClick:()=>l(e=>[...e,{name:``,value:``}]),children:[(0,H.jsx)(Ir,{}),` Add header`]}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Values are sent to every origin requested by the Session Browser. Treat them as sensitive and avoid unrelated third-party pages while enabled.`})]}),h&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--destructive)]`,children:h})]}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-[var(--border)] pt-4`,children:[(0,H.jsx)(J,{type:`button`,variant:`outline`,onClick:t,disabled:p,children:`Cancel`}),(0,H.jsxs)(J,{type:`button`,onClick:()=>void v(),disabled:i===null||d||p,children:[p&&(0,H.jsx)(B,{className:`animate-spin`}),` Save`]})]})]})}function ck(e){return e instanceof Error?e.message:`Browser settings are unavailable`}var lk=[{id:`browser-request-headers`,label:`Browser headers`,icon:Xn}];function uk({open:e,onOpenChange:t,runtimeSelector:n,sessionId:r}){let[i,a]=(0,u.useState)(`browser-request-headers`);return(0,H.jsx)(Su,{open:e,onOpenChange:t,children:(0,H.jsxs)(Du,{className:`max-h-[calc(100dvh-2rem)] gap-0 overflow-hidden p-0 sm:max-w-5xl`,children:[(0,H.jsxs)(Ou,{className:`border-b border-[var(--border)] p-5 pr-12`,children:[(0,H.jsx)(Au,{children:`Session settings`}),(0,H.jsx)(ju,{children:`Manage shared behavior for this Session.`})]}),(0,H.jsxs)(`div`,{className:`grid min-h-0 grid-cols-1 sm:grid-cols-[13rem_minmax(0,1fr)]`,children:[(0,H.jsx)(`nav`,{"aria-label":`Session settings sections`,className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--muted)]/30 p-2 sm:flex-col sm:border-r sm:border-b-0`,children:lk.map(e=>{let t=e.icon,n=i===e.id;return(0,H.jsxs)(`button`,{type:`button`,"aria-current":n?`page`:void 0,onClick:()=>a(e.id),className:`flex shrink-0 items-center gap-2 rounded-md px-3 py-2 text-left text-sm font-medium sm:w-full `+(n?`bg-[var(--accent)] text-[var(--accent-foreground)]`:`text-[var(--muted-foreground)] hover:bg-[var(--accent)]/60 hover:text-[var(--foreground)]`),children:[(0,H.jsx)(t,{className:`size-4`}),(0,H.jsx)(`span`,{children:e.label})]},e.id)})}),(0,H.jsx)(`div`,{className:`min-h-0 overflow-y-auto p-5`,children:i===`browser-request-headers`&&(0,H.jsx)(sk,{open:e,onClose:()=>t(!1),runtimeSelector:n,sessionId:r})})]})]})})}function dk(e,t,n,r){return n===r?t:e}function fk(e,t){return e.key!==t.key||t.streamCurrent===!0&&e.streamCurrent!==!0}function pk(e){return e?e.tool===`skills-cli`?{source:e.source}:{source:e.command}:{}}var mk=DD(),hk={...mk,enabled:!1};function gk({policy:e,upload:t,deleteResource:n,onChange:r}){let[i,a]=(0,u.useState)([]),o=(0,u.useRef)([]),s=(0,u.useRef)(new Map),c=(0,u.useCallback)(e=>{a(t=>{let n=e(t);return o.current=n,n})},[]);(0,u.useEffect)(()=>()=>{for(let e of s.current.values())e.abort();for(let e of o.current)e.previewUrl&&URL.revokeObjectURL(e.previewUrl)},[]);let l=(0,u.useCallback)(i=>{if(!e.enabled||i.length===0)return;r?.();let a=o.current.filter(e=>e.type===`input_image`).length;for(let r of i){let i=r.type.startsWith(`image/`)?`input_image`:`input_file`,l=MD(`attachment`),u=MD(`upl`),d=i===`input_image`?URL.createObjectURL(r):void 0,f;if(i===`input_image`?(a+=1,a>e.maxImagesPerMessage?f=`Attach up to ${e.maxImagesPerMessage} images`:e.mediaTypes.includes(r.type)?(r.size<=0||r.size>e.maxImageBytes)&&(f=`Image must be smaller than ${yk(e.maxImageBytes)}`):f=`Unsupported image type`):(r.size<=0||!Number.isSafeInteger(r.size))&&(f=`File is empty or too large for this browser`),f){c(e=>[...e,{id:l,file:r,clientUploadId:u,type:i,previewUrl:d,state:`failed`,error:f}]);continue}let p={id:l,file:r,clientUploadId:u,type:i,previewUrl:d,state:t?`uploading`:`ready`};if(c(e=>[...e,p]),!t)continue;let m=new AbortController;s.current.set(l,m),t(r,u,i,m.signal).then(e=>{if(s.current.delete(l),!o.current.some(e=>e.id===l)){n?.(e).catch(()=>void 0);return}c(t=>t.map(t=>t.id===l?{...t,state:`ready`,resource:e}:t))}).catch(e=>{s.current.delete(l),!m.signal.aborted&&c(t=>t.map(t=>t.id===l?{...t,state:`failed`,error:e instanceof Error?e.message:`Upload failed`}:t))})}},[n,r,e,c,t]);return{items:i,addFiles:l,onPaste:(0,u.useCallback)(e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length!==0&&(e.preventDefault(),l(t))},[l]),remove:(0,u.useCallback)(e=>{r?.(),s.current.get(e.id)?.abort(),s.current.delete(e.id),c(t=>t.filter(t=>t.id!==e.id)),e.previewUrl&&URL.revokeObjectURL(e.previewUrl),e.resource&&n?.(e.resource).catch(()=>void 0)},[n,r,c]),clear:(0,u.useCallback)(()=>{for(let e of s.current.values())e.abort();s.current.clear();for(let e of o.current)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);o.current=[],a([])},[]),hasPending:i.some(e=>e.state===`uploading`),hasFailed:i.some(e=>e.state===`failed`),readyResources:i.flatMap(e=>e.state===`ready`&&e.resource?[e.resource]:[]),readyUploads:i.flatMap(e=>e.state===`ready`?[{file:e.file,clientUploadId:e.clientUploadId,type:e.type}]:[])}}function _k({items:e,disabled:t,onRemove:n,className:r}){return e.length===0?null:(0,H.jsx)(`div`,{className:X(`flex gap-2 overflow-x-auto px-2 pb-2`,r),"aria-label":`Attachments`,children:e.map(e=>(0,H.jsxs)(`div`,{className:X(`group relative h-20 shrink-0 overflow-hidden rounded-md border border-[var(--border)] bg-[var(--muted)]`,e.type===`input_image`?`w-20`:`w-52`),title:e.error??e.file.name,children:[e.previewUrl?(0,H.jsx)(`img`,{src:e.previewUrl,alt:e.file.name,className:`size-full object-cover`}):(0,H.jsxs)(`div`,{className:`flex size-full items-center gap-2 px-3 pr-8`,children:[(0,H.jsx)(nr,{className:`size-5 shrink-0 text-[var(--primary)]`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-xs font-medium`,children:e.file.name}),(0,H.jsx)(`div`,{className:`text-[10px] text-[var(--muted-foreground)]`,children:bk(e.file.size)})]})]}),e.state===`uploading`&&(0,H.jsx)(`div`,{className:`absolute inset-0 grid place-items-center bg-black/45 text-white`,children:(0,H.jsx)(B,{className:`size-5 animate-spin`})}),e.state===`failed`&&(0,H.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 bg-[var(--destructive)] px-1 py-0.5 text-center text-[9px] text-white`,children:`Upload failed`}),(0,H.jsx)(`button`,{type:`button`,className:`absolute right-1 top-1 grid size-5 place-items-center rounded-full bg-black/65 text-white opacity-90 transition-opacity hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-45`,"aria-label":`Remove ${e.file.name}`,disabled:t,onClick:()=>n(e),children:(0,H.jsx)(di,{className:`size-3`})})]},e.id))})}function vk({policy:e,disabled:t,onFiles:n,className:r}){let i=(0,u.useRef)(null);function a(e){n(Array.from(e.target.files??[])),e.target.value=``}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`input`,{ref:i,type:`file`,multiple:!0,className:`hidden`,onChange:a}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:X(`size-8 shrink-0`,r),disabled:t||!e.enabled,"aria-label":`Attach files`,title:`Attach images or files`,onClick:()=>i.current?.click(),children:e.enabled?(0,H.jsx)(Nr,{}):(0,H.jsx)(pr,{})})]})}function yk(e){return`${Math.round(e/1048576)} MB`}function bk(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}var xk=200;function Sk({initialDraft:e,model:t,running:n,collaborationMode:r,streamCurrent:i,disabled:a,sessionId:o,runtimeSelector:s,onSend:c,onStop:l}){let[d,f]=(0,u.useState)(e??``),[p,m]=(0,u.useState)(hk),[h,g]=(0,u.useState)(!1),_=(0,u.useRef)(null),v=(0,u.useRef)(!1),y=(0,u.useRef)(void 0),b=(0,u.useRef)(0),x=(0,u.useRef)(!1),S=gk({policy:p,upload:(e,t,n,r)=>Y.uploadSessionResource(s,o,e,t,n,r),deleteResource:e=>Y.deleteSessionResource(s,o,e.resourceId),onChange:()=>{y.current=void 0}});(0,u.useEffect)(()=>{let e=!1;return Y.getSessionResourcePolicy(s,o).then(t=>{e||m(t)}).catch(()=>{e||m(hk)}),()=>{e=!0}},[s,o]),(0,u.useEffect)(()=>{e!==void 0&&f(t=>t||e)},[e]),(0,u.useLayoutEffect)(()=>{let e=_.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight;e.style.height=`${Math.min(t,xk)}px`,e.style.overflowY=t>xk?`auto`:`hidden`},[d]);async function C(){if(x.current)return;let e=d,t=b.current,n=d.trim(),r=S.readyResources;if(!n&&r.length===0||S.hasPending||S.hasFailed)return;let i=r.length>0?y.current??MD(`msg`):void 0;i&&(y.current=i),x.current=!0,g(!0),f(``);try{await c({text:n,attachments:r,clientMessageId:i}),S.clear(),y.current=void 0}catch(n){V.error(`Could not send message: ${n instanceof Error?n.message:`unknown error`}`),Ux(n)?f(n=>dk(n,e,b.current,t)):(S.clear(),y.current=void 0)}finally{x.current=!1,g(!1)}}let w=!a&&!h&&!S.hasPending&&!S.hasFailed&&(!!d.trim()||S.items.length>0);return(0,H.jsx)(`div`,{className:`px-4 pb-3 pt-1`,children:(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl rounded-xl border border-[var(--border)] bg-[var(--card)] p-2 shadow-[var(--shadow-sm)] transition-[border-color,box-shadow] focus-within:border-[color-mix(in_srgb,var(--primary)_55%,var(--border))] focus-within:shadow-[0_0_0_3px_color-mix(in_srgb,var(--primary)_9%,transparent),var(--shadow-sm)]`,children:[(0,H.jsx)(_k,{items:S.items,disabled:h,onRemove:S.remove}),(0,H.jsx)(`textarea`,{ref:_,value:d,rows:1,placeholder:`Message… (Enter to send · Shift+Enter for newline)`,disabled:a,onChange:e=>{b.current+=1,y.current=void 0,f(e.target.value)},onPaste:e=>{h||S.onPaste(e)},onCompositionStart:()=>{v.current=!0},onCompositionEnd:()=>{v.current=!1},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!v.current&&!e.nativeEvent.isComposing&&e.keyCode!==229&&(e.preventDefault(),w&&C())},className:X(`block min-h-[52px] w-full resize-none overflow-hidden border-0 bg-transparent px-2 py-1.5`,`text-sm leading-relaxed placeholder:text-[var(--muted-foreground)]`,`focus-visible:outline-none`,`disabled:cursor-not-allowed disabled:opacity-50`),style:{maxHeight:xk}}),(0,H.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2 pt-1`,children:[(0,H.jsx)(vk,{policy:p,disabled:a||h,onFiles:S.addFiles}),(0,H.jsx)(Ck,{fallbackModel:t,running:n,collaborationMode:r,streamCurrent:i,sessionId:o,runtimeSelector:s}),n?(0,H.jsxs)(J,{variant:`outline`,className:`ml-auto h-8 shrink-0`,onClick:l,title:`Stop the running turn`,children:[(0,H.jsx)(ni,{}),` Stop`]}):(0,H.jsxs)(J,{className:`ml-auto h-8 shrink-0`,onClick:C,disabled:!w,children:[(0,H.jsx)(Ur,{}),` Send`]})]})]})})}function Ck({fallbackModel:e,running:t,collaborationMode:n,streamCurrent:r,sessionId:i,runtimeSelector:a}){let[o,s]=(0,u.useState)(null),[c,l]=(0,u.useState)([]),[d,f]=(0,u.useState)(!0),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(!1),_=(0,u.useRef)({key:null,streamCurrent:void 0});(0,u.useEffect)(()=>{let e=`${a}\0${i}`,t=_.current,n={key:e,streamCurrent:r};if(_.current=n,!fk(t,n))return;let o=!1,c=t.key!==e;return c&&(f(!0),s(null),l([])),Promise.all([Y.getSessionExecutionSettings(a,i),Y.listSessionLaunchOptions(a)]).then(([e,t])=>{o||(s(e),l(t.providers.find(t=>t.id===e.provider)?.models??[]))}).catch(()=>{}).finally(()=>{!o&&c&&f(!1)}),()=>{o=!0}},[a,i,r]),(0,u.useEffect)(()=>{n&&s(e=>e&&{...e,collaborationMode:n})},[n]);let v=c.find(e=>e.id===o?.model),y=v?.reasoningOptions.find(e=>e.value===o?.reasoningEffort),b=v?`${v.label}${y?` / ${y.label}`:``}`:o?.model??e,x=t||p||d||!o||c.length===0;async function S(e,n){if(!(p||t)){m(!0);try{let t=await Y.updateSessionExecutionSettings(a,i,{model:e,reasoningEffort:n});s(t)}catch(e){V.error(`Could not change model: ${e instanceof Error?e.message:`unknown error`}`)}finally{m(!1)}}}async function C(){if(!o||h)return;let e=o,t=o.collaborationMode===`plan`?`default`:`plan`;g(!0),s({...o,collaborationMode:t});try{let e=await Y.updateSessionExecutionSettings(a,i,{model:o.model,reasoningEffort:o.reasoningEffort,collaborationMode:t});s(e)}catch(n){s(e);let r=t===`plan`?`enter`:`exit`;V.error(`Could not ${r} Plan mode: ${n instanceof Error?n.message:`unknown error`}`)}finally{g(!1)}}let w=o?.provider===`codex`||o?.provider===`traex`,T=o?.collaborationMode===`plan`,E=T?`Exit Plan mode`:`Enter Plan mode`,D=w?(0,H.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,className:X(`h-7 shrink-0 gap-1 px-2 text-[11px] font-medium`,T?`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)] text-[var(--primary)] hover:bg-[color-mix(in_srgb,var(--primary)_14%,transparent)]`:`text-[var(--muted-foreground)] hover:text-[var(--foreground)]`),"aria-label":E,"aria-pressed":T,"data-testid":`session-plan-mode-toggle`,"data-active":T?`true`:void 0,title:E,disabled:h,onClick:()=>void C(),children:[h?(0,H.jsx)(B,{className:`size-3 animate-spin`}):(0,H.jsx)(nr,{className:`size-3`,strokeWidth:1.8}),(0,H.jsx)(`span`,{children:`Plan`})]}):null;return!b&&!D?null:c.length===0||!o?(0,H.jsxs)(H.Fragment,{children:[b?(0,H.jsx)(`span`,{className:`min-w-0 max-w-52 truncate px-2 font-mono text-[10px] text-[var(--muted-foreground)]`,children:b}):null,D]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(xg,{children:[(0,H.jsx)(Sg,{asChild:!0,children:(0,H.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,disabled:x,className:`h-7 min-w-0 max-w-52 justify-start gap-1.5 px-2 font-normal text-[11px] text-[var(--muted-foreground)]`,"aria-label":`Model and thinking effort`,title:t?`Model settings can be changed after the current turn finishes`:`Change model and thinking effort for the next turn`,children:[p?(0,H.jsx)(B,{className:`size-3 animate-spin`}):null,(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:b}),(0,H.jsx)(Fn,{className:`size-3 shrink-0 opacity-55`})]})}),(0,H.jsxs)(Cg,{align:`start`,className:`min-w-56`,children:[(0,H.jsx)(Tg,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:`Model → Thinking effort`}),c.map(e=>{let t=o.model===e.id;return e.reasoningOptions.length===0?(0,H.jsxs)(wg,{onSelect:()=>void S(e.id,null),children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),t&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]},e.id):(0,H.jsxs)(Dg,{children:[(0,H.jsxs)(Og,{children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),t&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]}),(0,H.jsxs)(kg,{children:[(0,H.jsx)(Tg,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:`Thinking effort`}),e.reasoningOptions.map(n=>{let r=t&&o.reasoningEffort===n.value;return(0,H.jsxs)(wg,{onSelect:()=>void S(e.id,n.value),children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.label}),r&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]},n.value)})]})]},e.id)})]})]}),D]})}var wk=24,Tk={hasOverflow:!1,canScrollLeft:!1,canScrollRight:!1};function Ek({pages:e,order:t,selectedPageId:n,selectionDisabled:r,mutationDisabled:i,createDisabled:a,createPending:o,emulatorAttached:s,emulator:c,onSelectPage:l,onClosePage:d,onCreatePage:f,onSelectEmulator:p,onCloseEmulator:m,onAddEmulator:h,headerLeadingAction:g,settingsAction:_,leadingAction:v,trailingAction:y}){let b=(0,u.useRef)(null),x=(0,u.useRef)(null),S=(0,u.useRef)(null),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)(null),[E,D]=(0,u.useState)(Tk),O=t.flatMap(t=>{if(t===aD())return c?[{type:`emulator`,key:t,emulator:c}]:[];let n=e.find(e=>iD(e.pageId)===t);return n?[{type:`browser`,key:t,page:n}]:[]}),k=O.map(e=>e.key).join(`
|
|
56
|
-
`),A=O.length,j=(0,u.useCallback)(()=>{let e=b.current,t=x.current,n=S.current;if(!(!e||!t||!n))return AO({scrollLeft:t.scrollLeft,viewportWidth:t.clientWidth,contentWidth:n.scrollWidth,availableWidth:e.clientWidth})},[]),M=(0,u.useCallback)(()=>{let e=j();e&&D(t=>kk(t,e)?t:e)},[j]),N=(0,u.useCallback)(()=>{w.current===null&&(w.current=window.requestAnimationFrame(()=>{w.current=null,M()}))},[M]),P=(0,u.useCallback)(e=>{let t=x.current,n=C.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=MO({scrollLeft:t.scrollLeft,viewportWidth:t.clientWidth,tabLeft:t.scrollLeft+i.left-r.left,tabWidth:i.width,inset:wk});a!==0&&t.scrollBy({left:a,behavior:e})},[]),F=(0,u.useCallback)(e=>{let t=x.current;if(!t)return;let n=jO(t.clientWidth);t.scrollBy({left:e===`left`?-n:n,behavior:Ok()})},[]);(0,u.useEffect)(()=>()=>{w.current!==null&&window.cancelAnimationFrame(w.current)},[]),(0,u.useLayoutEffect)(()=>{let e=b.current,t=x.current,n=S.current;if(!e||!t||!n)return;let r=()=>{let e=t.clientWidth,n=T.current===null||Math.abs(e-T.current)>1;T.current=e,N(),n&&P(`auto`)},i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(r);return i?.observe(e),i?.observe(t),i?.observe(n),window.addEventListener(`resize`,r),M(),()=>{i?.disconnect(),window.removeEventListener(`resize`,r)}},[P,N,M]),(0,u.useEffect)(()=>{let e=x.current;if(!e)return;let t=t=>{if(t.ctrlKey||t.deltaY===0||Math.abs(t.deltaY)<=Math.abs(t.deltaX))return;let n=j();(t.deltaY<0?n?.canScrollLeft:n?.canScrollRight)&&(t.preventDefault(),e.scrollLeft+=t.deltaY,N())};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[j,N]),(0,u.useLayoutEffect)(()=>{P(Ok()),N()},[k,P,N,E.hasOverflow,n]);function I(e,t){let n;if(e.key===`ArrowLeft`?n=(t-1+A)%A:e.key===`ArrowRight`?n=(t+1)%A:e.key===`Home`?n=0:e.key===`End`&&(n=A-1),n===void 0||n===t)return;e.preventDefault();let r=S.current?.querySelectorAll(`[role="tab"]`).item(n);r?.focus(),r?.click()}return(0,H.jsxs)(`div`,{className:`desktop-macos-titlebar-header app-drag-region flex h-12 shrink-0 items-end gap-1 border-b border-[var(--border)] bg-[var(--muted)]/30 pl-2 pr-3 pt-1 sm:pr-4`,children:[g&&(0,H.jsx)(`div`,{className:`mb-1 flex h-8 shrink-0 items-center`,children:g}),(0,H.jsxs)(`div`,{ref:b,className:`flex min-w-0 flex-1 items-end gap-1`,children:[E.hasOverflow&&(0,H.jsx)(Dk,{direction:`left`,disabled:!E.canScrollLeft,onClick:()=>F(`left`)}),(0,H.jsx)(`div`,{ref:x,className:`min-w-0 flex-1 overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,style:Ak(E),onScroll:N,children:(0,H.jsx)(`div`,{ref:S,className:`flex w-max items-end gap-1`,role:`tablist`,"aria-label":`Session resources`,children:O.map((e,t)=>{if(e.type===`emulator`){let n=e.emulator;return(0,H.jsxs)(`div`,{ref:n.selected?C:void 0,role:`presentation`,className:n.selected?`group flex h-8 w-44 shrink-0 items-center rounded-t-md border border-b-[var(--card)] border-[var(--border)] bg-[var(--card)] px-2`:`group flex h-8 w-44 shrink-0 items-center rounded-t-md border border-transparent px-2 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]`,children:[(0,H.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n.selected,"aria-label":n.label,title:n.label,tabIndex:n.selected?0:-1,onClick:p,onKeyDown:e=>I(e,t),className:`flex min-w-0 flex-1 items-center gap-2 text-left text-xs outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[n.busy?(0,H.jsx)(B,{className:`size-3 shrink-0 animate-spin`}):(0,H.jsx)($r,{className:`size-3 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:n.label})]}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Close emulator tab`,title:`Close emulator tab`,onClick:m,className:`ml-1`,children:(0,H.jsx)(di,{className:`size-3`})})]},e.key)}let a=e.page,o=a.pageId===n,s=a.title||a.url||`New page`;return(0,H.jsxs)(`div`,{ref:o?C:void 0,role:`presentation`,className:o?`group flex h-8 w-44 shrink-0 items-center rounded-t-md border border-b-[var(--card)] border-[var(--border)] bg-[var(--card)] px-2`:`group flex h-8 w-44 shrink-0 items-center rounded-t-md border border-transparent px-2 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]`,children:[(0,H.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":o,"aria-label":s,title:s,tabIndex:o?0:-1,disabled:r,onClick:()=>l(a.pageId),onKeyDown:e=>I(e,t),className:`flex min-w-0 flex-1 items-center gap-2 text-left text-xs outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[a.loading?(0,H.jsx)(B,{className:`size-3 shrink-0 animate-spin`}):(0,H.jsx)(Xn,{className:`size-3 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:s})]}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Close ${s}`,title:`Close ${s}`,disabled:i,onClick:()=>d(a.pageId),className:`ml-1`,children:(0,H.jsx)(di,{className:`size-3`})})]},e.key)})})}),E.hasOverflow&&(0,H.jsx)(Dk,{direction:`right`,disabled:!E.canScrollRight,onClick:()=>F(`right`)})]}),(0,H.jsxs)(xg,{children:[(0,H.jsx)(Sg,{asChild:!0,children:(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mb-1 size-8`,"aria-label":`Add Session resource`,title:`Add Session resource`,children:(0,H.jsx)(Ir,{})})}),(0,H.jsxs)(Cg,{align:`end`,children:[(0,H.jsxs)(wg,{disabled:a,"aria-busy":o,onSelect:f,children:[o?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Xn,{}),o?`Creating browser tab…`:`New browser tab`]}),(0,H.jsxs)(wg,{onSelect:h,children:[(0,H.jsx)($r,{}),c||s?`Show emulator`:`Attach emulator`]})]})]}),_&&(0,H.jsx)(`div`,{className:`mb-1 shrink-0`,children:_}),v&&(0,H.jsx)(`div`,{className:`mb-1 shrink-0`,children:v}),y&&(0,H.jsx)(`div`,{className:`mb-1 ml-0.5 shrink-0`,children:y})]})}function Dk({direction:e,disabled:t,onClick:n}){let r=e===`left`?In:Ln;return(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mb-1 size-7`,"aria-label":`Scroll resource tabs ${e}`,title:`Scroll resource tabs ${e}`,disabled:t,onClick:n,children:(0,H.jsx)(r,{})})}function Ok(){return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}function kk(e,t){return e.hasOverflow===t.hasOverflow&&e.canScrollLeft===t.canScrollLeft&&e.canScrollRight===t.canScrollRight}function Ak(e){let t=`${wk}px`,n;return e.canScrollLeft&&e.canScrollRight?n=`linear-gradient(to right, transparent, #000 ${t}, #000 calc(100% - ${t}), transparent)`:e.canScrollLeft?n=`linear-gradient(to right, transparent, #000 ${t}, #000 100%)`:e.canScrollRight&&(n=`linear-gradient(to right, #000 0, #000 calc(100% - ${t}), transparent)`),n?{WebkitMaskImage:n,maskImage:n}:void 0}var jk=8,Mk=4e3;function Nk({sessionId:e,runtimeSelector:t,controller:n,readOnly:r=!1}){return n.binding?(0,H.jsx)(Fk,{sessionId:e,runtimeSelector:t,binding:n.binding,controller:n,readOnly:r}):r?(0,H.jsx)(Rk,{icon:(0,H.jsx)(xr,{className:`size-5`}),label:`No Emulator is attached.`}):(0,H.jsx)(Pk,{controller:n})}function Pk({controller:e}){let[t,n]=(0,u.useState)(null),r=async t=>{n(t);try{await e.attach(t)}catch(e){V.error(`Could not attach Emulator: ${e.message}`)}finally{n(null)}};return(0,H.jsx)(U_,{className:`min-h-0 flex-1`,children:(0,H.jsx)(`div`,{className:`p-4 sm:p-5`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,H.jsxs)(`div`,{className:`mb-4 flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Attach an Emulator`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:`Only devices available to this Session are shown. Attaching does not affect another Session.`})]}),(0,H.jsx)(J,{variant:`ghost`,size:`icon-sm`,onClick:()=>void e.reloadDevices(),title:`Refresh devices`,"aria-label":`Refresh devices`,children:(0,H.jsx)(zr,{className:X(`size-4`,e.devicesLoading&&`animate-spin`)})})]}),e.error&&(0,H.jsx)(`div`,{className:`mb-3 rounded-md border border-[var(--destructive)]/30 bg-[var(--destructive)]/5 px-3 py-2 text-xs text-[var(--destructive)]`,children:e.error.message}),e.devicesLoading&&e.devices.length===0?(0,H.jsx)(`div`,{className:`grid min-h-40 place-items-center`,"aria-live":`polite`,children:(0,H.jsx)(Rk,{icon:(0,H.jsx)(B,{className:`size-5 animate-spin`}),label:`Loading devices…`})}):e.devices.length===0?(0,H.jsxs)(`div`,{className:`rounded-md border border-dashed border-[var(--border)] px-5 py-10 text-center`,children:[(0,H.jsx)(xr,{className:`mx-auto mb-3 size-6 text-[var(--muted-foreground)]`}),(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`No Emulator is available`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:`Boot a simulator on this Runtime, or release one from another Session.`})]}):(0,H.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:e.devices.map(n=>(0,H.jsxs)(`button`,{type:`button`,disabled:e.mutating,onClick:()=>void r(n.id),className:`group flex min-h-20 items-center gap-3 rounded-md border border-[var(--border)] bg-[var(--card)] p-3 text-left transition-colors hover:border-[var(--primary)]/50 hover:bg-[var(--primary)]/[0.03] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] disabled:opacity-60`,children:[(0,H.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-md bg-[var(--primary)]/10 text-[var(--primary)]`,children:t===n.id?(0,H.jsx)(B,{className:`size-4 animate-spin`}):(0,H.jsx)(xr,{className:`size-4`})}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:n.name}),(0,H.jsxs)(`span`,{className:`mt-1 flex items-center gap-2`,children:[(0,H.jsx)(Lk,{state:n.state}),(0,H.jsx)(`span`,{className:`font-mono text-[9px] uppercase text-[var(--muted-foreground)]`,children:n.backend})]})]})]},`${n.backend}:${n.id}`))})]})})})}function Fk({sessionId:e,runtimeSelector:t,binding:n,controller:r,readOnly:i}){let[a,o]=(0,u.useState)(null),[s,c]=(0,u.useState)(!1),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(null),m=(0,u.useRef)(null),h=(0,u.useRef)(null),g=(0,u.useRef)(null),_=(0,u.useRef)(null),v=(0,u.useRef)(null);(0,u.useEffect)(()=>{o(null),c(!1),p(null),d(null);let r=!1,i,a,s=0,l=0,u=!1,f=null,m,g=`png`,_=()=>{a!==void 0&&window.clearTimeout(a),a=void 0,d(null)},v=(e,t=!1)=>{if(a!==void 0&&window.clearTimeout(a),t||f===null){d(e);return}a=window.setTimeout(()=>{a=void 0,r||d(e)},Mk)},y=e=>{if(r)return;let t=URL.createObjectURL(e),n=f;f=t,o(t),_(),s=0,u=!1,n&&window.setTimeout(()=>URL.revokeObjectURL(n),1e3)},b=(e,t=!1)=>{if(r)return;i!==void 0&&window.clearTimeout(i);let n=t?0:Math.min(8e3,500*2**s++);i=window.setTimeout(()=>void e(t),n)},x=async(i=!1)=>{let a=++l;try{let o=await Qx(i);if(r||a!==l)return;let s=new WebSocket(Ik({runtimeSelector:t,sessionId:e,bindingId:n.bindingId,maximumFrameRate:n.backend===`ios`?30:5,capability:o}));m=s,s.binaryType=`arraybuffer`,s.onmessage=e=>{if(r||a!==l||m!==s)return;if(typeof e.data==`string`){try{let t=JSON.parse(e.data);if(t.type!==`emulator.surface.ready`||typeof t.surfaceId!=`string`||t.format!==`png`&&t.format!==`jpeg`)throw Error(`invalid Emulator Surface ready frame`);g=t.format,h.current={socket:s,surfaceId:t.surfaceId,inputSequence:0}}catch{s.close(4400,`invalid Emulator Surface ready frame`)}return}let t=e.data instanceof ArrayBuffer||e.data instanceof Blob?e.data:null,n=g===`jpeg`?`image/jpeg`:`image/png`;(t instanceof Blob||t)&&y(new Blob([t],{type:n}))},s.onclose=e=>{if(r||a!==l||m!==s)return;h.current?.socket===s&&(h.current=null);let t=Error(e.code===4406?`emulator_surface_upgrade_required`:e.reason||`Remote Emulator Surface disconnected`);v(t,e.code===4406),e.code!==4406&&((e.code===4403||e.code===1006)&&!u?(u=!0,b(x,!0)):b(x))},s.onerror=()=>void 0}catch(e){if(r||a!==l)return;v(e instanceof Error?e:Error(String(e))),b(x)}};return x(),()=>{r=!0,l+=1,h.current=null,m?.close(1e3,`Session Emulator pane closed`),i!==void 0&&window.clearTimeout(i),a!==void 0&&window.clearTimeout(a),f&&URL.revokeObjectURL(f)}},[n.backend,n.bindingId,t,e]);let y=(0,u.useCallback)((e,t,n)=>{let r=h.current;if(!r||r.socket.readyState!==WebSocket.OPEN||n!==void 0&&r.surfaceId!==n)return!1;try{return r.socket.send(JSON.stringify({type:`emulator.surface.touch`,surfaceId:r.surfaceId,inputSequence:r.inputSequence++,phase:e,...t})),!0}catch{return!1}},[]),b=(0,u.useCallback)(()=>{_.current!==null&&window.cancelAnimationFrame(_.current),_.current=null;let e=g.current;g.current=null,e&&y(`move`,e,e.surfaceId)},[y]),x=(0,u.useCallback)(e=>{let t=m.current;if(!t)return null;let n=t.getBoundingClientRect();return n.width<=0||n.height<=0?null:{x:Math.max(0,Math.min(1,(e.clientX-n.left)/n.width)),y:Math.max(0,Math.min(1,(e.clientY-n.top)/n.height))}},[]),S=e=>{if(r.mutating)return;let t=x(e.nativeEvent);if(!t)return;e.currentTarget.setPointerCapture(e.pointerId);let n=h.current?.surfaceId??null,i=n!==null&&y(`begin`,t,n);v.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,lastPoint:t,points:[{type:`begin`,...t}],live:i,surfaceId:i?n:null}},C=e=>{let t=v.current;if(!t||t.pointerId!==e.pointerId)return;let n=x(e.nativeEvent);n&&t.live?(t.lastPoint=n,g.current=t.surfaceId?{...n,surfaceId:t.surfaceId}:null,_.current===null&&(_.current=window.requestAnimationFrame(()=>b()))):n&&t.points.length<255&&(t.lastPoint=n,t.points.push({type:`move`,...n}))},w=e=>{let t=v.current;if(v.current=null,!t||t.pointerId!==e.pointerId)return;let n=x(e.nativeEvent);if(n){if(t.live){b(),t.surfaceId&&y(`end`,n,t.surfaceId);return}(Math.hypot(e.clientX-t.startX,e.clientY-t.startY)>jk?r.gesture([...t.points,{type:`end`,...n}]):r.tap(n.x,n.y)).catch(e=>V.error(`Emulator input failed: ${e.message}`))}},T=async()=>{try{await r.detach()}catch(e){V.error(`Could not detach Emulator: ${e.message}`)}};return(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-[var(--background)]`,children:[(0,H.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between gap-3 border-b border-[var(--border)] px-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-xs font-medium`,children:n.deviceName??n.deviceId}),(0,H.jsx)(Lk,{state:n.deviceState}),!n.available&&(0,H.jsx)(MC,{variant:`outline`,children:`Unavailable`}),l&&a&&(0,H.jsxs)(MC,{variant:`outline`,className:`gap-1 border-[var(--warning)]/30 font-mono text-[8px] uppercase text-[var(--warning)]`,children:[(0,H.jsx)(B,{className:`size-2.5 animate-spin`}),`Reconnecting`]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsx)(J,{variant:`ghost`,size:`icon-sm`,disabled:!n.available||r.mutating,title:`Home`,"aria-label":`Home`,onClick:()=>void r.button(`home`).catch(e=>V.error(`Home failed: ${e.message}`)),children:(0,H.jsx)(dr,{})}),(0,H.jsxs)(J,{variant:`ghost`,size:`sm`,disabled:r.mutating,title:`Detach from this session`,onClick:()=>void T(),children:[r.mutating?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(li,{}),`Detach`]})]})]}),(0,H.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3`,children:[!s&&!l&&(0,H.jsx)(`div`,{className:`absolute inset-0 z-10 grid place-items-center bg-[var(--background)]`,children:(0,H.jsx)(Rk,{icon:(0,H.jsx)(B,{className:`size-5 animate-spin`}),label:`Connecting to Emulator…`})}),l&&!a&&(0,H.jsxs)(`div`,{className:`max-w-sm text-center`,children:[(0,H.jsx)(xr,{className:`mx-auto mb-3 size-7 text-[var(--muted-foreground)]`}),(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:t===`local`?`Preview is unavailable`:`Remote Emulator Surface is unavailable`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:l.message===`emulator_surface_upgrade_required`?`Upgrade the selected Runtime daemon to a version with Emulator Surface support.`:l.message})]}),a&&(0,H.jsx)(`img`,{ref:m,src:a,alt:n.deviceName??n.deviceId,draggable:!1,onLoad:e=>{p({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight}),c(!0)},onPointerDown:i?void 0:S,onPointerMove:i?void 0:C,onPointerUp:i?void 0:w,onPointerCancel:i?void 0:()=>{let e=v.current;v.current=null,e?.live&&(b(),e.surfaceId&&y(`end`,e.lastPoint,e.surfaceId))},className:`max-h-full max-w-full touch-none select-none rounded-md bg-black object-contain shadow-[var(--shadow-md)]`,style:f?{aspectRatio:`${f.width} / ${f.height}`}:void 0})]})]})}function Ik(e){let t=location.protocol===`https:`?`wss`:`ws`,n=new URLSearchParams({bindingId:e.bindingId,maximumFrameRate:String(e.maximumFrameRate),capability:e.capability});return Vx(n),`${t}://${location.host}/api/runtimes/${encodeURIComponent(e.runtimeSelector)}/sessions/${encodeURIComponent(e.sessionId)}/emulator/surface?${n.toString()}`}function Lk({state:e}){return(0,H.jsxs)(MC,{variant:`outline`,className:X(`gap-1 px-1.5 py-0 font-mono text-[8px] uppercase`,e===`booted`&&`border-[var(--success)]/30 text-[var(--success)]`,e===`shutdown`&&`text-[var(--muted-foreground)]`),children:[(0,H.jsx)(`span`,{className:X(`size-1 rounded-full bg-current`,e===`booted`&&`animate-pulse`)}),e]})}function Rk({icon:e,label:t}){return(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-2 text-[var(--muted-foreground)]`,children:[e,(0,H.jsx)(`span`,{className:`text-xs`,children:t})]})}var zk=`Collapsible`,[Bk,Vk]=Wi(zk),[Hk,Uk]=Bk(zk),Wk=u.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=ea({prop:r,defaultProp:i??!1,onChange:o,caller:zk});return(0,H.jsx)(Hk,{scope:n,disabled:a,contentId:Qi(),open:c,onOpenToggle:u.useCallback(()=>l(e=>!e),[l]),children:(0,H.jsx)(W.div,{"data-state":Xk(c),"data-disabled":a?``:void 0,...s,ref:t})})});Wk.displayName=zk;var Gk=`CollapsibleTrigger`,Kk=u.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=Uk(Gk,n);return(0,H.jsx)(W.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":Xk(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:U(e.onClick,i.onOpenToggle)})});Kk.displayName=Gk;var qk=`CollapsibleContent`,Jk=u.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Uk(qk,e.__scopeCollapsible);return(0,H.jsx)(Qa,{present:n||i.open,children:({present:e})=>(0,H.jsx)(Yk,{...r,ref:t,present:e})})});Jk.displayName=qk;var Yk=u.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=Uk(qk,n),[s,c]=u.useState(r),l=u.useRef(null),d=Ji(t,l),f=u.useRef(0),p=f.current,m=u.useRef(0),h=m.current,g=o.open||s,_=u.useRef(g),v=u.useRef(void 0);return u.useEffect(()=>{let e=requestAnimationFrame(()=>_.current=!1);return()=>cancelAnimationFrame(e)},[]),Yi(()=>{let e=l.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();f.current=t.height,m.current=t.width,_.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),c(r)}},[o.open,r]),(0,H.jsx)(W.div,{"data-state":Xk(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!g,...a,ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":h?`${h}px`:void 0,...e.style},children:g&&i})});function Xk(e){return e?`open`:`closed`}var Zk=Wk,Qk=Kk,$k=Jk,eA=Zk,tA=Qk,nA=$k;function rA({status:e}){return e===`completed`?(0,H.jsx)(Pn,{className:`size-3 shrink-0 text-[var(--success)]`}):e===`in_progress`?(0,H.jsx)(B,{className:`size-3 shrink-0 animate-spin text-[var(--primary)]`}):(0,H.jsx)(Kn,{className:`size-3 shrink-0 text-[var(--muted-foreground)]`})}function iA({todos:e}){let[t,n]=(0,u.useState)(!0);if(e.length===0)return null;let r=e.filter(e=>e.status===`completed`).length;return(0,H.jsxs)(eA,{open:t,onOpenChange:n,className:`mx-auto mt-2 w-[calc(100%-2rem)] max-w-3xl rounded-md border border-[var(--border)] bg-[var(--muted)]/30`,children:[(0,H.jsxs)(tA,{className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs`,children:[(0,H.jsx)(Ln,{className:X(`size-3 shrink-0 text-[var(--muted-foreground)] transition-transform`,t&&`rotate-90`)}),(0,H.jsx)(`span`,{className:`label-caps text-[var(--muted-foreground)]`,children:`Tasks`}),(0,H.jsxs)(`span`,{className:`font-mono text-[var(--muted-foreground)]`,children:[r,`/`,e.length]})]}),(0,H.jsx)(nA,{className:`overflow-hidden px-3 pb-2`,children:(0,H.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,H.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,H.jsx)(rA,{status:e.status}),(0,H.jsx)(`span`,{className:X(`truncate`,e.status===`completed`&&`text-[var(--muted-foreground)] line-through`),children:e.subject})]},e.id))})})]})}function aA({open:e,src:t,alt:n,onOpenChange:r}){return(0,H.jsx)(Su,{open:e,onOpenChange:r,children:(0,H.jsxs)(Du,{showCloseButton:!1,"aria-describedby":void 0,className:`inset-0 left-0 top-0 h-dvh max-h-none w-screen max-w-none translate-x-0 translate-y-0 place-items-center gap-0 rounded-none bg-black/80 p-4 text-white ring-0 sm:max-w-none`,onClick:()=>r(!1),children:[(0,H.jsx)(Au,{className:`sr-only`,children:n}),(0,H.jsxs)(`div`,{className:`absolute right-4 top-4 z-10 flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,H.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`grid size-9 place-items-center rounded-full bg-black/60 text-white transition-colors hover:bg-black/75 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white`,"aria-label":`Open original image`,children:(0,H.jsx)(er,{className:`size-4`})}),(0,H.jsx)(Tu,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:`grid size-9 place-items-center rounded-full bg-black/60 text-white transition-colors hover:bg-black/75 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white`,"aria-label":`Close image preview`,children:(0,H.jsx)(di,{className:`size-5`})})})]}),(0,H.jsx)(`img`,{src:t,alt:n,className:`block h-auto max-h-[calc(100dvh-2rem)] min-h-0 w-auto max-w-[calc(100vw-2rem)] min-w-0 rounded-md object-contain shadow-2xl`,onClick:e=>e.stopPropagation()})]})})}function oA(e,t,n){let[r,i]=(0,u.useState)(e),a=(0,u.useRef)(0),o=(0,u.useRef)(0),s=(0,u.useRef)(e);return s.current=e,(0,u.useEffect)(()=>{if(!n){window.clearTimeout(o.current),o.current=0,a.current=0,i(e);return}if(Object.is(r,e))return;let c=Date.now()-a.current;if(a.current===0||c>=t){window.clearTimeout(o.current),o.current=0,a.current=Date.now(),i(e);return}o.current===0&&(o.current=window.setTimeout(()=>{o.current=0,a.current=Date.now(),i(s.current)},t-c))},[n,t,r,e]),(0,u.useEffect)(()=>()=>{window.clearTimeout(o.current)},[]),n?r:e}var sA=/^\$(?:\{[A-Z_][A-Z0-9_]*\}|[A-Z_][A-Z0-9_]+(?![A-Za-z0-9_]))/,cA=/^ {0,3}(`{3,}|~{3,})/;function lA(e){let t=``,n=``,r=0,i=!1;for(let a=0;a<e.length;a+=1){let o=e[a],s=a===0||e[a-1]===`
|
|
57
|
-
`;if(!r&&s){let r=e.slice(a).match(
|
|
58
|
-
`)||n.includes(`\r`)||n.includes(`?`)||n.includes(`#`)||dA.test(n)||n.startsWith(`//`))return null;if(n.startsWith(`/`)||t)return n;let r=n.indexOf(`/`);return r>0&&!/\s/.test(n.slice(0,r))?n:null}var pA=`data-rynx-workspace-image`,mA=`/__rynx_workspace_image__`,hA=(0,u.lazy)(()=>g(()=>import(`./markdown-streamdown-OYO-HVz6.js`).then(e=>({default:e.MarkdownStreamdown})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]))),gA=100,_A=5e4,vA=5e3,yA=2e5,bA=X(`min-w-0 wrap-anywhere text-sm leading-relaxed`,`[&_p]:my-1.5 [&_ul]:my-1.5 [&_ol]:my-1.5 [&_li]:my-0.5`,`[&_pre]:my-2 [&_pre]:rounded-md [&_pre]:text-xs`,`[&_code]:font-mono [&_h1]:mt-3 [&_h2]:mt-3 [&_h3]:mt-2`,`[&_a]:text-[var(--primary)] [&_a]:underline [&_a]:underline-offset-2`);function xA(e){let t=0,n=0;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);i===32||i>=9&&i<=13?n=0:(n+=1,n>t&&(t=n))}return t}function SA(e){return e.length>_A||xA(e)>vA}function CA({text:e,className:t}){let n=e.length>yA,r=n?e.slice(0,yA):e;return(0,H.jsxs)(`div`,{className:X(`whitespace-pre-wrap break-all font-mono text-sm`,t),children:[r,n&&(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:`\n… [${e.length-yA} more characters not shown]`})]})}var wA=(0,u.createContext)(null),TA=`wrap-anywhere font-medium text-[var(--primary)] underline`;function EA(e){let t=(0,u.useContext)(wA),n=(0,u.useMemo)(()=>t&&e?Y.sessionWorkspaceFileContentUrl(t.runtimeSelector,t.sessionId,e):null,[e,t]),[r,i]=(0,u.useState)(null);return(0,u.useEffect)(()=>{if(i(null),!n)return;let e=new AbortController;return fetch(n,{method:`HEAD`,signal:e.signal}).then(e=>{e.ok&&i(n)}).catch(()=>void 0),()=>e.abort()},[n]),r}function DA({href:e,children:t,className:n,title:r,node:i,...a}){let o=typeof e==`string`?fA(e,!0):null,s=EA(o),[c,l]=(0,u.useState)(!1);return o?s?(0,H.jsx)(`a`,{...a,href:s,target:`_blank`,rel:`noreferrer`,title:r??o,"data-streamdown":`link`,className:X(TA,`decoration-dotted underline-offset-2`,n),children:t}):(0,H.jsx)(`span`,{title:r??o,children:t}):e?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,className:X(`wrap-anywhere appearance-none text-left font-medium text-[var(--primary)] underline`,n),"data-streamdown":`link`,onClick:()=>l(!0),children:t}),(0,H.jsx)(Bw,{open:c,url:e,onOpenChange:l,onConfirm:()=>window.open(e,`_blank`,`noreferrer`)})]}):(0,H.jsx)(`span`,{className:n,children:t})}function OA({children:e,className:t,node:n,...r}){let i=EA(fA(typeof e==`string`?e:``,!1));if(!i)return(0,H.jsx)(`code`,{...r,className:X(`rounded bg-[var(--muted)] px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,children:e});let a=()=>window.open(i,`_blank`,`noreferrer`);return(0,H.jsx)(`code`,{...r,role:`link`,tabIndex:0,className:X(`cursor-pointer font-mono underline decoration-dotted underline-offset-2 transition-colors hover:text-[var(--foreground)]`,t),"data-streamdown":`inline-code`,onClick:a,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},children:e})}function kA({src:e,alt:t=``,className:n,node:r,...i}){let a=i[pA],o=typeof a==`string`?fA(a,!0):null,s=EA(o),[c,l]=(0,u.useState)(!1),[d,f]=(0,u.useState)(!1);if((0,u.useEffect)(()=>f(!1),[s]),!o||!s)return(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:t||`Image unavailable`});if(d)return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[var(--muted-foreground)]`,children:[(0,H.jsx)(fr,{className:`size-4`,"aria-hidden":`true`}),t||`Image unavailable`]});let p={...i};return delete p[pA],(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,className:`group my-2 block max-w-full overflow-hidden rounded-md text-left focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ring)]`,"aria-label":`Open ${t||`image`}`,onClick:()=>l(!0),children:(0,H.jsx)(`img`,{...p,src:s,alt:t,loading:`lazy`,className:X(`block h-auto max-h-80 max-w-full rounded-md object-contain transition-opacity group-hover:opacity-90`,n),onError:()=>f(!0)})}),(0,H.jsx)(aA,{open:c,src:s,alt:t||`Markdown image`,onOpenChange:l})]})}var AA={a:DA,inlineCode:OA,img:kA};function jA({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,H.jsx)(Bw,{open:e,url:r,onOpenChange:e=>{e||t()},onConfirm:n})}function MA({children:e,className:t,workspaceFiles:n,breaks:r=!1,streaming:i=!1}){let a=(0,u.useMemo)(()=>n?{runtimeSelector:n.runtimeSelector,sessionId:n.sessionId}:null,[n?.runtimeSelector,n?.sessionId]),o=(0,u.useMemo)(()=>SA(e),[e]),s=oA((0,u.useMemo)(()=>o?e:lA(e),[e,o]),gA,i);return o?(0,H.jsx)(CA,{text:e,className:t}):(0,H.jsx)(u.Suspense,{fallback:(0,H.jsx)(`div`,{className:X(`whitespace-pre-wrap break-words text-sm`,t),children:s}),children:(0,H.jsx)(wA.Provider,{value:a,children:(0,H.jsx)(hA,{breaks:r,shikiTheme:[`github-light`,`github-dark`],linkSafety:{enabled:!0,renderModal:jA},components:AA,className:X(bA,t),children:s})})})}function NA(e,t,n={},r={},i=!0){let a={},o={};for(let s of e){if(s.type===`text`){let e=typeof t[s.id]==`string`?t[s.id]:``;i&&s.required&&!e.trim()?o[s.id]=`${s.label} is required`:e.length>0&&(a[s.id]=e);continue}let e=new Set(s.options.map(e=>e.value)),c=s.allowOther===!0&&r[s.id]===!0,l=c?(n[s.id]??``).trim():``;if(s.multiple){let e=Array.isArray(t[s.id])?t[s.id]:[],n=s.options.map(e=>e.value).filter(t=>e.includes(t));l&&!n.includes(l)&&n.push(l),i&&c&&!l?o[s.id]=`${s.label}: enter a value for Other`:i&&s.required&&n.length===0?o[s.id]=`${s.label} is required`:n.length>0&&(a[s.id]=n);continue}let u=typeof t[s.id]==`string`?t[s.id]:``,d=c?l:e.has(u)?u:``;i&&c&&!l?o[s.id]=`${s.label}: enter a value for Other`:i&&s.required&&!d?o[s.id]=`${s.label} is required`:d&&(a[s.id]=d)}return Object.keys(o).length>0?{ok:!1,errors:o}:{ok:!0,answers:a}}function PA({sessionId:e,item:t,canResolve:n=!0}){let{runtimeSelector:r}=xS(),i=(0,u.useId)().replaceAll(`:`,``),[a,o]=(0,u.useState)({}),[s,c]=(0,u.useState)({}),[l,d]=(0,u.useState)({}),[f,p]=(0,u.useState)({}),[m,h]=(0,u.useState)(()=>t.request.fields[0]?.id),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(),b=t.status===`pending`;function x(e){p(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})}function S(e,t){o(n=>({...n,[e]:t})),x(e)}function C(e,t){d(n=>({...n,[e]:t})),x(e)}function w(e){let n=t.request.fields,r=Math.max(n.findIndex(e=>e.id===m),0),i=n.findIndex(t=>t.id===e);if(!(i<0)){if(i>r){let e=n[r];if(e){let t=NA([e],a,s,l);if(!t.ok){p(e=>({...e,...t.errors}));return}x(e.id)}}h(e)}}async function T(i){if(!n)return;let o=NA(t.request.fields,a,s,l,i.requiresAnswers);if(!o.ok){p(o.errors);let e=t.request.fields.find(e=>o.errors[e.id]);e&&h(e.id);return}p({}),_(void 0),y(i.id);try{await Yx(e,t.id,{actionId:i.id,...Object.keys(o.answers).length>0?{answers:o.answers}:{}},r)}catch(e){y(void 0),_(e instanceof Error?e.message:String(e))}}let E=t.request.kind===`permission`?Jr:t.request.kind===`form`?vr:Hn,D=Math.max(t.request.fields.findIndex(e=>e.id===m),0),O=t.request.fields.length===0||D===t.request.fields.length-1,k=t.request.actions.filter(e=>!e.requiresAnswers||O),A=t.request.context?.toolName===`ExitPlanMode`&&!!t.request.context.summary;return(0,H.jsxs)(`section`,{"aria-labelledby":`${i}-title`,"aria-busy":v!==void 0,className:X(`min-w-0 max-w-full overflow-hidden rounded-lg border p-3 text-xs shadow-sm`,t.request.kind===`permission`?`border-[var(--warning)]/40 bg-[var(--warning)]/5`:`border-[var(--primary)]/30 bg-[var(--primary)]/5`),children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(E,{"aria-hidden":`true`,className:X(`mt-0.5 size-4 shrink-0`,t.request.kind===`permission`?`text-[var(--warning)]`:`text-[var(--primary)]`)}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{id:`${i}-title`,className:`font-medium text-[var(--foreground)]`,children:t.request.title}),t.request.description&&(0,H.jsx)(`p`,{className:`mt-1 leading-relaxed text-[var(--muted-foreground)]`,children:t.request.description})]})]}),(0,H.jsx)(IA,{item:t}),b&&!n?(0,H.jsx)(`div`,{role:`status`,className:`mt-3 text-[var(--muted-foreground)]`,children:`Pending interaction · resolve it on the owning Runtime.`}):b?(0,H.jsxs)(`div`,{className:`mt-3 grid min-w-0 gap-3`,children:[A?(0,H.jsx)(FA,{plan:t.request.context.summary,actions:t.request.actions,feedback:typeof a.feedback==`string`?a.feedback:``,busyActionId:v,onFeedback:e=>S(`feedback`,e),onSubmit:e=>void T(e)}):(0,H.jsx)(Mg,{idPrefix:i,fields:t.request.fields,activeFieldId:m,answers:a,otherValues:s,otherSelections:l,errors:f,disabled:v!==void 0,onNavigate:w,onAnswerChange:S,onOtherSelectionChange:C,onOtherValueChange:(e,t)=>{c(n=>({...n,[e]:t})),x(e)}}),g&&(0,H.jsxs)(`p`,{role:`alert`,className:`text-[var(--destructive)]`,children:[`Could not submit: `,g]}),!A&&(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[k.map(e=>(0,H.jsxs)(J,{type:`button`,size:`sm`,variant:zA(e),className:`h-auto max-w-full whitespace-normal break-words py-1.5 text-left`,disabled:v!==void 0,title:e.description,"aria-label":e.description?`${e.label}. ${e.description}`:void 0,onClick:()=>void T(e),children:[v===e.id&&(0,H.jsx)(B,{"aria-hidden":`true`,className:`animate-spin`}),e.label]},e.id)),v&&(0,H.jsxs)(`span`,{role:`status`,className:`text-[var(--muted-foreground)]`,children:[`Submitting `,t.request.actions.find(e=>e.id===v)?.label,`…`]})]})]}):(0,H.jsx)(RA,{item:t})]})}function FA({plan:e,actions:t,feedback:n,busyActionId:r,onFeedback:i,onSubmit:a}){let[o,s]=(0,u.useState)(!1),c=e=>t.find(t=>t.id===e),l=e=>{let t=c(e);t&&a(t)};return(0,H.jsxs)(`div`,{className:`grid min-w-0 gap-3`,"data-testid":`exit-plan-mode-review`,children:[(0,H.jsx)(`p`,{className:`text-[var(--muted-foreground)]`,children:`Claude finished planning and wants to proceed.`}),(0,H.jsx)(`div`,{className:`rounded-md border bg-[var(--background)]/60 p-3`,children:(0,H.jsx)(MA,{className:`[&>:first-child]:mt-0 [&>:last-child]:mb-0`,children:e})}),o?(0,H.jsxs)(`div`,{className:`grid gap-2`,"data-testid":`exit-plan-mode-feedback`,children:[(0,H.jsx)(jg,{autoFocus:!0,className:`min-h-20 text-xs`,placeholder:`What should change about the plan? (optional)`,value:n,disabled:r!==void 0,onChange:e=>i(e.target.value)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsxs)(J,{size:`sm`,disabled:r!==void 0,onClick:()=>l(`deny_feedback`),children:[r===`deny_feedback`?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(di,{}),`Reject plan`]}),(0,H.jsx)(J,{size:`sm`,variant:`ghost`,disabled:r!==void 0,onClick:()=>s(!1),children:`Cancel`})]})]}):(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsxs)(J,{size:`sm`,disabled:r!==void 0,onClick:()=>l(`allow_auto`),children:[r===`allow_auto`?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(fi,{}),`Yes, and use auto mode`]}),(0,H.jsxs)(J,{size:`sm`,variant:`outline`,disabled:r!==void 0,onClick:()=>l(`allow_manual`),children:[r===`allow_manual`?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Pn,{}),`Yes, manually approve edits`]}),(0,H.jsxs)(J,{size:`sm`,variant:`outline`,disabled:r!==void 0,onClick:()=>s(!0),children:[(0,H.jsx)(di,{}),` Reject with feedback`]})]})]})}function IA({item:e}){let t=e.request.context;return!t||t.toolName===`ExitPlanMode`?null:(0,H.jsxs)(`div`,{className:`mt-3 grid min-w-0 gap-1.5`,children:[t.summary&&(0,H.jsx)(`p`,{className:`break-words leading-relaxed text-[var(--muted-foreground)]`,children:t.summary}),t.toolName&&(0,H.jsxs)(`div`,{className:`font-mono text-[10px] text-[var(--muted-foreground)]`,children:[`tool · `,t.toolName]}),t.command&&(0,H.jsx)(LA,{value:t.command}),t.cwd&&(0,H.jsx)(`div`,{className:`min-w-0 whitespace-pre-wrap break-all font-mono text-[10px] text-[var(--muted-foreground)]`,children:t.cwd}),t.diff&&(0,H.jsx)(LA,{value:t.diff,tall:!0})]})}function LA({value:e,tall:t=!1}){return(0,H.jsx)(`pre`,{className:X(`min-w-0 max-w-full overflow-auto whitespace-pre-wrap [overflow-wrap:anywhere] rounded-md bg-[var(--muted)] p-2 font-mono text-[11px] leading-relaxed`,t?`max-h-56`:`max-h-32`),children:(0,H.jsx)(`code`,{className:`block min-w-0`,children:e})})}function RA({item:e}){if(e.status!==`resolved`){let t=e.status===`expired`?`Expired`:e.status===`inactive`?`No longer active`:`Cancelled`;return(0,H.jsxs)(`div`,{role:`status`,className:`mt-3 text-[var(--muted-foreground)]`,children:[t,e.reason?` · ${e.reason}`:``]})}let t=e.request.actions.find(t=>t.id===e.resolution?.actionId),n=e.request.fields.flatMap(t=>{let n=e.resolution?.answers?.[t.id];if(n===void 0)return[];let r=t.type===`text`&&t.secret?`••••••••`:Array.isArray(n)?n.join(`, `):n;return[{id:t.id,label:t.label,value:r}]});return(0,H.jsxs)(`div`,{"aria-live":`polite`,className:`mt-3 grid gap-1.5 text-[var(--muted-foreground)]`,children:[(0,H.jsxs)(`div`,{children:[`Resolved · `,t?.label??e.resolution?.actionId??`answered`]}),n.map(e=>(0,H.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-2 text-[11px]`,children:[(0,H.jsx)(`span`,{children:e.label}),(0,H.jsx)(`span`,{className:`break-words text-[var(--foreground)]`,children:e.value})]},e.id))]})}function zA(e){return e.style===`primary`?`default`:e.style===`danger`?`destructive`:`outline`}function BA({item:e}){let t=e.rotateKind===`fork`?cr:Qn;return(0,H.jsxs)(`div`,{className:`my-2 flex items-center gap-2 text-[10px] text-[var(--muted-foreground)]`,children:[(0,H.jsx)(`div`,{className:`h-px flex-1 bg-[var(--border)]`}),(0,H.jsx)(t,{className:`size-3 shrink-0 text-[var(--primary)]`}),(0,H.jsx)(`span`,{className:`label-caps`,children:e.label}),(0,H.jsx)(`span`,{className:`font-mono opacity-70`,children:e.newSessionId.slice(0,12)}),(0,H.jsx)(`div`,{className:`h-px flex-1 bg-[var(--border)]`})]})}function VA({item:e}){return e.code===`response_stopped`?(0,H.jsxs)(`div`,{className:`my-1 flex items-center gap-2 px-1 py-1 text-xs text-[var(--muted-foreground)]`,children:[(0,H.jsx)(Wn,{className:`size-3.5 shrink-0`}),(0,H.jsx)(`span`,{children:`Response stopped`})]}):(0,H.jsxs)(`div`,{className:`my-1 flex gap-2 rounded-md border border-[var(--destructive)]/40 bg-[var(--destructive)]/5 px-3 py-2 text-sm`,children:[(0,H.jsx)(ci,{className:`size-4 shrink-0 text-[var(--destructive)]`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`label-caps text-[10px] text-[var(--destructive)]`,children:[e.source,` error · `,e.code]}),(0,H.jsx)(`div`,{className:`mt-0.5 whitespace-pre-wrap break-words text-[var(--foreground)]/80`,children:e.message})]})]})}function HA({item:e,sessionId:t,runtimeSelector:n}){let[r,i]=(0,u.useState)(null),[a,o]=(0,u.useState)(()=>new Set),[s,c]=(0,u.useState)({}),l=e.images??[],d=e.files??[],f=l.find(e=>UA(e)===r);return e.role===`user`?(0,H.jsx)(`div`,{className:`flex justify-end`,children:(0,H.jsxs)(`div`,{className:`max-w-[85%] rounded-md rounded-br-sm bg-[var(--primary)]/10 p-2 text-sm dark:bg-[var(--primary)]/25 dark:ring-1 dark:ring-inset dark:ring-[var(--primary)]/35`,children:[l.length>0&&(0,H.jsx)(`div`,{className:`grid gap-1.5 ${l.length===1?`grid-cols-1`:`grid-cols-2`}`,children:l.map(r=>{let l=UA(r),u=KA(WA(n,t,e.id,r),s[l]??0),d=a.has(l);return(0,H.jsx)(`button`,{type:`button`,className:`group relative size-28 overflow-hidden rounded-md border border-black/10 bg-[var(--muted)] text-[var(--muted-foreground)] sm:size-36`,onClick:()=>{d?(o(e=>{let t=new Set(e);return t.delete(l),t}),c(e=>({...e,[l]:(e[l]??0)+1}))):i(l)},"aria-label":`${d?`Retry`:`Open`} ${r.filename??`attached image`}`,children:d?(0,H.jsxs)(`span`,{className:`flex size-full items-center justify-center gap-2 px-3 text-xs`,children:[(0,H.jsx)(fr,{className:`size-4`}),`Image unavailable`]}):(0,H.jsx)(`img`,{src:u,alt:r.filename??`Attached image`,loading:`lazy`,className:`size-full object-cover transition-transform group-hover:scale-[1.02]`,onError:()=>o(e=>new Set(e).add(l))})},l)})}),d.length>0&&(0,H.jsx)(`div`,{className:l.length>0?`mt-2 space-y-1.5`:`space-y-1.5`,children:d.map(r=>(0,H.jsxs)(`a`,{href:WA(n,t,e.id,r),target:`_blank`,rel:`noreferrer`,className:`flex min-w-0 items-center gap-2 rounded-md border border-black/10 bg-[var(--card)]/80 px-2.5 py-2 text-left text-[var(--foreground)] transition-colors hover:bg-[var(--card)]`,children:[(0,H.jsx)(nr,{className:`size-4 shrink-0 text-[var(--primary)]`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block truncate text-xs font-medium`,children:r.filename??`Attached file`}),(0,H.jsxs)(`span`,{className:`block truncate text-[10px] text-[var(--muted-foreground)]`,children:[r.mediaType,r.byteLength?` · ${GA(r.byteLength)}`:``]})]}),(0,H.jsx)(er,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`})]},UA(r)))}),e.text&&(0,H.jsx)(MA,{breaks:!0,className:`px-1 [&>:first-child]:mt-0 [&>:last-child]:mb-0 ${l.length||d.length?`pt-2`:``}`,workspaceFiles:{runtimeSelector:n,sessionId:t},children:e.text}),f&&(0,H.jsx)(aA,{open:!0,src:WA(n,t,e.id,f),alt:f.filename??`Attached image`,onOpenChange:e=>{e||i(null)}})]})}):(0,H.jsx)(`div`,{className:`flex justify-start`,children:(0,H.jsxs)(`div`,{className:`flex min-w-0 max-w-[90%] flex-col items-start`,children:[(0,H.jsxs)(`div`,{className:`rounded-md rounded-bl-sm bg-[var(--muted)] px-3.5 py-2.5`,children:[e.text&&(0,H.jsx)(MA,{className:`[&>:first-child]:mt-0 [&>:last-child]:mb-0`,streaming:e.streaming,workspaceFiles:{runtimeSelector:n,sessionId:t},children:e.text}),e.streaming&&(0,H.jsx)(`span`,{className:`ml-0.5 inline-block h-4 w-[3px] translate-y-0.5 animate-pulse rounded-full bg-[var(--primary)] align-middle`})]}),e.interrupted&&(0,H.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 px-1 text-xs text-[var(--muted-foreground)]`,"data-testid":`assistant-interrupted-indicator`,children:[(0,H.jsx)(Wn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:`Response stopped`})]})]})})}function UA(e){return`resourceId`in e&&e.resourceId?`resource:${e.resourceId}`:`path:${e.partIndex}`}function WA(e,t,n,r){return`resourceId`in r&&r.resourceId?Y.sessionResourceContentUrl(e,t,r):Y.sessionItemFileContentUrl(e,t,n,r.partIndex)}function GA(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function KA(e,t){return t===0?e:`${e}${e.includes(`?`)?`&`:`?`}retry=${t}`}function qA({item:e}){let t=e.summary.filter(Boolean).join(`
|
|
55
|
+
`))r.startsWith(`event:`)?t=r.slice(6).trim():r.startsWith(`data:`)&&(n+=r.slice(5).trim());if(!t&&!n)return null;let r={};try{n&&(r=JSON.parse(n))}catch{}return{event:t,data:r}}function aS(e,t){return e?`/api/runtimes/${encodeURIComponent(e)}/emulator/${t}`:`/api/emulator/${t}`}function oS(e,t,n){let r=aS(e,t);return e?$x(r,n):Xx(r,n)}function sS(e,t,n){let r=`/api/runtimes/${encodeURIComponent(e)}/sessions`;if(t===void 0)return r;let i=`${r}/${encodeURIComponent(t)}`;return n?`${i}/${n}`:i}function cS(e,t){let n=`/api/runtimes/${encodeURIComponent(e)}/projects`;return t===void 0?n:`${n}/${encodeURIComponent(t)}`}function lS(e,t,...n){let r=`${sS(e,t)}/browser`;return n.length===0?r:`${r}/${n.map(e=>encodeURIComponent(e)).join(`/`)}`}function uS(e,t,n){let r=`${sS(e,t)}/emulator`;return n?`${r}/${n}`:r}function dS(e,t,n){let r=new URLSearchParams({bindingId:n});return zx(`${sS(e,t)}/emulator/frame?${r.toString()}`)}function fS(e,t,n,r,i){return $x(lS(e,t,`pages`,r,i),{method:`POST`,body:JSON.stringify({browserGeneration:n})})}function pS(e,t,n){return e?sS(e,t,n):`/api/sessions/${encodeURIComponent(t)}/${n}`}var Y={meta:()=>Xx(`/api/meta`),listRuntimeShareAddresses:()=>Xx(`/api/runtime-server/share-addresses`,{cache:`no-store`}).then(e=>e.addresses),shareRuntime:e=>$x(`/api/runtime-server/share`,{method:`POST`,body:JSON.stringify(e)}),listRuntimeAccess:()=>Xx(`/api/runtime-server/access`).then(e=>e.clients),revokeRuntimeAccess:e=>$x(`/api/runtime-server/access/${encodeURIComponent(e)}`,{method:`DELETE`}),deleteRevokedRuntimeAccess:e=>$x(`/api/runtime-server/access/${encodeURIComponent(e)}/record`,{method:`DELETE`}),listRuntimes:()=>Xx(`/api/runtimes`).then(e=>e.runtimes),listProviderClis:e=>Xx(`/api/runtimes/${encodeURIComponent(e)}/provider-clis`,{cache:`no-store`}),startProviderCliOperation:(e,t,n)=>$x(`/api/runtimes/${encodeURIComponent(e)}/provider-clis/${encodeURIComponent(t)}/${n}`,{method:`POST`,body:JSON.stringify({})}),getProviderCliJob:(e,t)=>Xx(`/api/runtimes/${encodeURIComponent(e)}/provider-clis/jobs/${encodeURIComponent(t)}`,{cache:`no-store`}).then(e=>e.job),pairRuntime:e=>$x(`/api/runtimes/pair`,{method:`POST`,body:JSON.stringify(e)}),testRuntime:e=>$x(`/api/runtimes/${encodeURIComponent(e)}/test`,{method:`POST`,body:JSON.stringify({})}),forgetRuntime:e=>$x(`/api/runtimes/${encodeURIComponent(e)}`,{method:`DELETE`}),getRuntimeBrowserState:(e,t)=>Zx(lS(e,t),null),getRuntimeBrowserRequestHeaders:(e,t)=>$x(lS(e,t,`request-headers`),{cache:`no-store`}),updateRuntimeBrowserRequestHeaders:(e,t)=>$x(lS(e,t.sessionId,`request-headers`),{method:`PUT`,body:JSON.stringify({expectedRevision:t.expectedRevision,enabled:t.enabled,headers:t.headers})}),openRuntimeBrowser:(e,t,n)=>$x(lS(e,t,`open`),{method:`POST`,body:JSON.stringify(n===void 0?{}:{url:n})}),closeRuntimeBrowser:(e,t,n)=>$x(lS(e,t,`close`),{method:`POST`,body:JSON.stringify({browserGeneration:n})}),createRuntimeBrowserPage:(e,t,n,r)=>$x(lS(e,t,`pages`),{method:`POST`,body:JSON.stringify({browserGeneration:n,...r===void 0?{}:{url:r}})}),closeRuntimeBrowserPage:(e,t,n,r)=>fS(e,t,n,r,`close`),activateRuntimeBrowserPage:(e,t,n,r)=>fS(e,t,n,r,`activate`),navigateRuntimeBrowserPage:(e,t,n,r,i)=>$x(lS(e,t,`pages`,r,`navigate`),{method:`POST`,body:JSON.stringify({browserGeneration:n,url:i})}),backRuntimeBrowserPage:(e,t,n,r)=>fS(e,t,n,r,`back`),forwardRuntimeBrowserPage:(e,t,n,r)=>fS(e,t,n,r,`forward`),reloadRuntimeBrowserPage:(e,t,n,r)=>fS(e,t,n,r,`reload`),getSessionEmulator:(e,t)=>Xx(uS(e,t)).then(e=>e.binding),listSessionEmulatorDevices:(e,t)=>Xx(uS(e,t,`devices`)).then(e=>e.devices),attachSessionEmulator:(e,t,n)=>$x(uS(e,t,`attach`),{method:`POST`,body:JSON.stringify({device:n})}),detachSessionEmulator:(e,t,n)=>$x(uS(e,t,`detach`),{method:`POST`,body:JSON.stringify({bindingId:n})}),tapSessionEmulator:(e,t,n,r,i)=>$x(uS(e,t,`tap`),{method:`POST`,body:JSON.stringify({bindingId:n,x:r,y:i})}),gestureSessionEmulator:(e,t,n,r)=>$x(uS(e,t,`gesture`),{method:`POST`,body:JSON.stringify({bindingId:n,points:r})}),buttonSessionEmulator:(e,t,n,r)=>$x(uS(e,t,`button`),{method:`POST`,body:JSON.stringify({bindingId:n,name:r})}),sessionEmulatorFrameBlob:(e,t,n,r)=>eS(dS(e,t,n),{signal:r,cache:`no-store`}),listPlugins:()=>Xx(`/api/plugins`).then(e=>e.plugins),listPluginMarketplaces:()=>Xx(Px,{cache:`no-store`}).then(e=>e.marketplaces),addPluginMarketplace:e=>$x(Px,{method:`POST`,headers:{"x-rynx-console":`1`},body:JSON.stringify(e)}),refreshPluginMarketplace:e=>$x(`${Px}/${encodeURIComponent(e)}/refresh`,{method:`POST`,headers:{"x-rynx-console":`1`},body:`{}`}),removePluginMarketplace:e=>$x(`${Px}/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{"x-rynx-console":`1`}}),preparePluginInstallation:(e,t)=>$x(Nx,{method:`POST`,headers:{"x-rynx-console":`1`},body:JSON.stringify(e),signal:t}),commitPluginInstallation:(e,t,n)=>$x(Lx(e),{method:`POST`,headers:{"x-rynx-console":`1`},body:JSON.stringify(t),signal:n}),cancelPluginInstallation:e=>$x(Ix(e),{method:`DELETE`,headers:{"x-rynx-console":`1`}}),setPluginEnabled:(e,t)=>$x(`/api/plugins/${encodeURIComponent(e)}/${t?`enable`:`disable`}`,{method:`POST`,headers:{"x-rynx-console":`1`},body:`{}`}).then(e=>e.plugin),pluginSettingsUi:(e,t)=>Xx(`/api/plugins/${encodeURIComponent(e)}/settings-ui`,{cache:`no-store`,signal:t}),pluginSettingsCall:(e,t,n,r,i)=>$x(`/api/plugins/${encodeURIComponent(e)}/settings`,{method:`POST`,headers:{"x-rynx-console":`1`},body:JSON.stringify({generation:t,method:n,params:r}),signal:i}).then(e=>e.result),emulatorDevices:e=>Xx(aS(e,`devices`)).then(e=>e.devices),activeEmulator:e=>Xx(aS(e,`active`)).then(e=>e.active),attachEmulator:(e,t)=>oS(t,`attach`,{method:`POST`,body:JSON.stringify({device:e})}),tapEmulator:(e,t,n,r)=>oS(r,`tap`,{method:`POST`,body:JSON.stringify({x:e,y:t,device:n})}),gestureEmulator:(e,t,n)=>oS(n,`gesture`,{method:`POST`,body:JSON.stringify({points:e,device:t})}),buttonEmulator:(e,t,n)=>oS(n,`button`,{method:`POST`,body:JSON.stringify({name:e,device:t})}),shutdownEmulator:(e,t)=>oS(t,`shutdown`,{method:`POST`,body:JSON.stringify({device:e})}),emulatorVideoStreamUrl:e=>`/api/emulator/video${e?`?device=${encodeURIComponent(e)}`:``}`,emulatorFrameBlob:e=>eS(`/api/emulator/frame${e?`?device=${encodeURIComponent(e)}`:``}`),screenshotEmulator:(e,t)=>Xx(`/api/emulator/screenshot`,{method:`POST`,body:JSON.stringify({device:e,out:t})}),emulatorScreenshotBlob:e=>eS(`/api/emulator/screenshot-file?file=${encodeURIComponent(e)}`),listAgents:()=>Xx(`/api/agents`).then(e=>e.agents),getAgent:e=>Xx(`/api/agents/${encodeURIComponent(e)}`),listAgentRuntimeOptions:(e=!1)=>Xx(`/api/agents/runtime-options${e?`?refresh=1`:``}`,{cache:`no-store`}).then(e=>e.runtimes),createAgent:e=>Xx(`/api/agents`,{method:`POST`,body:JSON.stringify(e)}),updateAgent:(e,t)=>Xx(`/api/agents/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(t)}),deleteAgent:e=>Xx(`/api/agents/${encodeURIComponent(e)}`,{method:`DELETE`}),listProjects:e=>Xx(cS(e),{cache:`no-store`}).then(e=>e.projects),createProject:(e,t)=>$x(cS(e),{method:`POST`,body:JSON.stringify(t)}).then(e=>e.project),updateProject:(e,t,n)=>$x(cS(e,t),{method:`PUT`,body:JSON.stringify(n)}).then(e=>e.project),deleteProject:(e,t)=>$x(cS(e,t),{method:`DELETE`}),listSkills:()=>Xx(`/api/skills`).then(e=>e.skills),getSkill:e=>Xx(`/api/skills/${encodeURIComponent(e)}`),readSkillFile:(e,t)=>Xx(`/api/skills/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`),installSkill:e=>Xx(`/api/skills`,{method:`POST`,body:JSON.stringify(e)}).then(e=>e.skills),scanLocalSkills:e=>Xx(`/api/skills/local-scan`,{method:`POST`,body:JSON.stringify({runtime:e})}).then(e=>e.candidates),importLocalSkills:(e,t)=>Xx(`/api/skills/local-import`,{method:`POST`,body:JSON.stringify({runtime:e,keys:t})}).then(e=>e.results),importSkillArchive:(e,t)=>Xx(`/api/skills/import-archive`,{method:`POST`,body:JSON.stringify({filename:e,contentBase64:t})}).then(e=>e.results),deleteSkill:e=>Xx(`/api/skills/${encodeURIComponent(e)}`,{method:`DELETE`}),listSessions:e=>Xx(e?sS(e):`/api/sessions`).then(e=>e.sessions),listSessionAgentOptions:e=>Xx(`${sS(e)}/agent-options`).then(e=>e.agents),listSessionLaunchOptions:e=>Xx(`${sS(e)}/launch-options`),getSessionExecutionSettings:(e,t)=>Xx(sS(e,t,`execution`),{cache:`no-store`}),updateSessionExecutionSettings:(e,t,n)=>$x(sS(e,t,`execution`),{method:`PUT`,body:JSON.stringify(n)}),createSession:(e,t)=>{let n=t?sS(t):`/api/sessions`,r={method:`POST`,body:JSON.stringify(e)};return t?$x(n,r):Xx(n,r)},forkSession:(e,t,n)=>$x(sS(e,t,`fork`),{method:`POST`,body:JSON.stringify(n)}),sendSessionMessage:(e,t,n,r,i)=>i?$x(sS(i,e,`messages`),{method:`POST`,body:JSON.stringify(typeof t==`string`?{message:t}:t),signal:r}):tS(`/api/sessions/${encodeURIComponent(e)}/messages`,typeof t==`string`?{message:t}:t,n,r),getSessionResourcePolicy:(e,t)=>Xx(`${sS(e,t,`resources`)}/policy`,{cache:`no-store`}),uploadSessionResource:(e,t,n,r,i,a)=>$x(sS(e,t,`resources`),{method:`POST`,body:n,signal:a,headers:{"content-type":n.type||`application/octet-stream`,"x-rynx-resource-type":i,"x-rynx-upload-id":r,"x-rynx-filename":encodeURIComponent(n.name)}}).then(e=>e.resource),deleteSessionResource:(e,t,n)=>$x(`${sS(e,t,`resources`)}/${encodeURIComponent(n)}`,{method:`DELETE`}),sessionResourceContentUrl:(e,t,n)=>zx(`${sS(e,t,`resources`)}/${encodeURIComponent(n.resourceId)}/content`),sessionItemFileContentUrl:(e,t,n,r)=>zx(`${sS(e,t,`items`)}/${encodeURIComponent(n)}/files/${r}/content`),sessionWorkspaceFileContentUrl:(e,t,n)=>zx(`${sS(e,t)}/workspace/files/content?${new URLSearchParams({path:n}).toString()}`),enqueueSessionMessage:(e,t,n)=>$x(sS(e,t,`messages/queue`),{method:`POST`,body:JSON.stringify({message:n})}),startSessionTerminal:(e,t)=>$x(sS(e,t,`terminal/start`),{method:`POST`,body:`{}`}),streamSession:(e,t,n,r)=>nS(pS(r,e,`stream`),t,n),getSessionHistory:e=>Xx(`/api/sessions/${encodeURIComponent(e)}/history`).then(e=>e.items),getSessionSnapshot:(e,t,n)=>Xx(pS(n,e,`snapshot`),{signal:t}),getSessionSnapshotPage:(e,t,n,r)=>{let i=new URLSearchParams;t!==void 0&&i.set(`afterId`,t);let a=i.size>0?`?${i.toString()}`:``;return Xx(`${pS(r,e,`snapshot-page`)}${a}`,{signal:n})},closeSession:(e,t)=>{let n=t?sS(t,e):`/api/sessions/${encodeURIComponent(e)}`,r={method:`DELETE`};return t?$x(n,r):Xx(n,r)},interruptSession:(e,t)=>{let n=pS(t,e,`interrupt`),r={method:`POST`};return t?$x(n,r):Xx(n,r)}},mS=`rynx.control.runtime-target.v1`,hS={selector:`local`,daemonId:`local`,displayName:`This device`,binding:`local`};function gS(e){if(!e)return`local`;try{return e.getItem(`rynx.control.runtime-target.v1`)?.trim()||`local`}catch{return`local`}}function _S(e,t){if(e)try{e.setItem(mS,t)}catch{}}function vS(e){let t=new Map;for(let n of e)!n.selector||t.has(n.selector)||t.set(n.selector,n);return t.has(`local`)||t.set(`local`,hS),[...t.values()].sort((e,t)=>e.selector===`local`?-1:t.selector===`local`?1:e.displayName.localeCompare(t.displayName))}var yS=(0,u.createContext)(null);function bS({children:e}){let t=Rx(),n=$e(),r=nt(),i=Dx(n.pathname)??(n.pathname===px.sessions?Ox(n.search):null),[a,o]=(0,u.useState)(()=>gS(typeof window>`u`?void 0:window.localStorage)),s=i??a,[c,l]=(0,u.useState)([hS]),d=(0,u.useCallback)(e=>{l(vS(e))},[]),f=(0,u.useCallback)(async()=>{if(t){d([hS]);return}try{d(await Y.listRuntimes())}catch(e){V.error(`Failed to load Runtimes: ${e.message}`)}},[t,d]);(0,u.useEffect)(()=>{f()},[f]),(0,u.useEffect)(()=>{!i||i===`!invalid-runtime-owner`||(o(i),_S(typeof window>`u`?void 0:window.localStorage,i))},[i]);let p=(0,u.useCallback)(e=>{let t=e.trim();t&&(o(t),_S(typeof window>`u`?void 0:window.localStorage,t),(n.pathname===px.sessions||n.pathname.startsWith(`${px.sessions}/`)||Dx(n.pathname)!==null)&&i!==t&&r(zx(jx(t))))},[n.pathname,r,i]),m=(0,u.useMemo)(()=>{let e=c.find(e=>e.selector===s)??(s===`!invalid-runtime-owner`?{selector:s,daemonId:s,displayName:`Invalid Runtime URL`,binding:`direct`}:{selector:s,daemonId:s,displayName:`${s} (unavailable)`,binding:s===`local`?`local`:`direct`}),t=s!==`local`;return{runtimes:c,runtimeSelector:s,runtimeRoute:t?s:void 0,selectedRuntime:e,isRemoteRuntime:t,selectRuntime:p,refreshRuntimes:f,updateRuntimes:d}},[f,s,c,p,d]);return(0,H.jsx)(yS.Provider,{value:m,children:e})}function xS(){let e=(0,u.useContext)(yS);if(!e)throw Error(`useRuntimeTarget must be used inside RuntimeTargetProvider`);return e}var SS=`!add-runtime`;function CS(){let e=$e(),t=nt(),{runtimes:n,runtimeSelector:r,selectedRuntime:i,selectRuntime:a}=xS(),o=n.some(e=>e.selector===r)?n:[...n,i];return(0,H.jsx)(`div`,{className:`ml-auto w-44 max-w-full sm:w-60`,children:(0,H.jsxs)(my,{value:r,onValueChange:n=>{if(n===SS){t(px.runtimes,{state:{returnTo:`${e.pathname}${e.search}${e.hash}`}});return}a(n)},children:[(0,H.jsxs)(_y,{className:`h-10 w-full min-w-0 gap-1.5 border-0 bg-transparent px-2 font-mono text-[10px] shadow-none hover:bg-[var(--accent)] focus-visible:ring-2 sm:h-7`,"aria-label":`Active Runtime`,children:[(0,H.jsx)(`span`,{className:`hidden shrink-0 uppercase tracking-[0.12em] text-[var(--muted-foreground)] sm:inline`,children:`Runtime ·`}),(0,H.jsx)(gy,{placeholder:`Select Runtime`})]}),(0,H.jsxs)(by,{align:`end`,children:[o.map(e=>{let t=e.binding===`local`?hr:Wr;return(0,H.jsx)(Sy,{value:e.selector,children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(t,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.displayName})]})},e.selector)}),(0,H.jsx)(Cy,{}),(0,H.jsx)(Sy,{value:SS,children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(Ir,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{children:`Add Runtime…`})]})})]})]})})}function wS(){return typeof window>`u`?null:window.rynxDesktopIntegration??null}function TS(e){return e.globalCli.state===`foreign`||e.globalCli.state===`unwritable`}function ES(e,t){return!e.runtime.ready||!e.builtinSkill.ready?!1:e.globalCli.state===`installed`&&!e.globalCli.canInstall||e.globalCli.state===`development`||TS(e)&&t}var DS=(0,u.createContext)({status:null,operation:null,error:null,checkForUpdates:async()=>null,installUpdate:async()=>null});function OS({children:e}){let t=wS(),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(!t)return;let e=!0,n=t.onAppUpdateStatus(t=>{e&&(r(t),t.error||s(null))});return t.getAppUpdateStatus().then(t=>{e&&r(t)}).catch(t=>{e&&s(AS(t))}),()=>{e=!1,n()}},[t]);let c=(0,u.useCallback)(async()=>{if(!t)return null;a(`check`),s(null);try{let e=await t.checkForAppUpdates();return r(e),e}catch(e){return s(AS(e)),null}finally{a(null)}},[t]),l=(0,u.useCallback)(async()=>{if(!t)return null;a(`install`),s(null);try{let e=await t.installAppUpdate();return r(e),e}catch(e){return s(AS(e)),null}finally{a(null)}},[t]),d=(0,u.useMemo)(()=>({status:n,operation:i,error:o,checkForUpdates:c,installUpdate:l}),[c,o,l,i,n]);return(0,H.jsx)(DS.Provider,{value:d,children:e})}function kS(){return(0,u.useContext)(DS)}function AS(e){return e instanceof Error?e.message:String(e)}function jS(){let{status:e,operation:t,error:n,installUpdate:r}=kS();if(!e?.availableVersion||e.phase!==`downloading`&&e.phase!==`ready`&&e.phase!==`installing`)return null;let i=t===`install`||e.phase===`installing`,a=e.phase===`ready`&&!i,o=n??e.error;return(0,H.jsxs)(`div`,{className:`group/update relative flex shrink-0 items-center`,children:[(0,H.jsxs)(J,{variant:`ghost`,size:`icon-xs`,className:`relative text-[var(--primary)] hover:text-[var(--primary)]`,"aria-label":`Rynx ${e.availableVersion} update available`,"aria-haspopup":`dialog`,children:[e.phase===`downloading`||i?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Bn,{}),(0,H.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 rounded-full bg-[var(--primary)] ring-2 ring-[var(--background)]`,"aria-hidden":`true`})]}),(0,H.jsx)(`div`,{role:`dialog`,"aria-label":`Rynx update`,className:`invisible absolute bottom-full right-0 z-50 w-72 translate-y-1 pb-2 opacity-0 transition-[opacity,transform,visibility] duration-150 group-hover/update:visible group-hover/update:translate-y-0 group-hover/update:opacity-100 group-focus-within/update:visible group-focus-within/update:translate-y-0 group-focus-within/update:opacity-100`,children:(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--border)] bg-[var(--popover)] p-3 font-sans text-[var(--popover-foreground)] shadow-xl`,children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/12 text-[var(--primary)]`,children:a?(0,H.jsx)(Bn,{className:`size-4`}):e.phase===`downloading`?(0,H.jsx)(Yn,{className:`size-4`}):(0,H.jsx)(B,{className:`size-4 animate-spin`})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-xs font-semibold text-[var(--foreground)]`,children:a?`Update ready`:i?`Preparing update`:`Downloading update`}),(0,H.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-4 text-[var(--muted-foreground)]`,children:a?`${e.appName} ${e.availableVersion} is ready to install.`:i?`Rynx will restart when the local Runtime is safe to stop.`:`${e.appName} ${e.availableVersion} is downloading in the background.`})]})]}),a&&(0,H.jsxs)(J,{size:`sm`,className:`mt-3 w-full`,onClick:()=>void r(),children:[(0,H.jsx)(Bn,{}),`Restart to update`]}),o&&(0,H.jsx)(`p`,{className:`mt-2 text-[10px] leading-4 text-[var(--destructive)]`,children:o})]})})]})}function X(...e){return iu(Mc(e))}function MS({children:e,theme:t,onToggleTheme:n}){let r=$e(),i=Rx(),{runtimeSelector:a}=xS(),o=Tx(r.pathname),s=r.pathname===`/settings`||r.pathname.startsWith(`/settings/`),c=Mx(r.state,jx(a)),l=s?c:hx,u=s?void 0:{returnTo:`${r.pathname}${r.search}${r.hash}`};return(0,H.jsxs)(`div`,{className:`grid h-dvh min-h-0 grid-rows-[minmax(0,1fr)_2.5rem] overflow-hidden bg-[var(--background)] sm:grid-rows-[minmax(0,1fr)_2rem]`,children:[(0,H.jsx)(`main`,{className:`min-h-0 overflow-hidden focus:outline-none`,children:e}),(0,H.jsxs)(`footer`,{className:`app-no-drag flex min-w-0 items-center gap-3 border-t border-[var(--border)] bg-[var(--muted)]/24 px-2 font-mono text-[10px] text-[var(--muted-foreground)] sm:px-3`,children:[(0,H.jsx)(`span`,{className:`hidden truncate uppercase tracking-[0.12em] min-[480px]:block`,children:s?o===`emulator`?`Emulator · local device`:`Settings · local configuration`:`Session workbench`}),(0,H.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-1.5`,children:[i?(0,H.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 px-1`,children:[(0,H.jsx)(`span`,{className:`text-[var(--foreground)]`,children:`Rynx Sessions`}),i.access===`read_only`&&(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`· read only`})]}):s?(0,H.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 px-1`,children:[(0,H.jsx)(`span`,{className:`text-[var(--foreground)]`,children:`Control Plane`}),(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,H.jsx)(`span`,{children:`This device`})]}):(0,H.jsx)(CS,{}),(0,H.jsx)(`span`,{className:`h-3.5 w-px bg-[var(--border)]`,"aria-hidden":`true`}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[!i&&(0,H.jsx)(jS,{}),(0,H.jsx)(J,{variant:`ghost`,size:`icon-xs`,className:`shrink-0`,onClick:n,"aria-label":t===`dark`?`Use light mode`:`Use dark mode`,title:t===`dark`?`Light mode`:`Dark mode`,children:t===`dark`?(0,H.jsx)(ai,{}):(0,H.jsx)(wr,{})}),!i&&(0,H.jsx)(J,{asChild:!0,variant:`ghost`,size:`icon-xs`,className:X(`shrink-0`,s&&`text-[var(--primary)]`),children:(0,H.jsx)(hn,{to:l,state:u,"aria-label":s?`Back to app`:`Settings`,title:s?`Back to app`:`Settings`,children:(0,H.jsx)(Kr,{})})})]})]})]})]})}var NS=`/assets/rynx-wordmark-LL1QRYHD.png`;function PS({bridge:e,children:t}){let[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(`refresh`),[c,l]=(0,u.useState)(!1),d=(0,u.useCallback)(async(t=!1)=>{s(`refresh`),a(null);try{let n=await e.getStatus(t);ES(n,!1)?r(await e.completeOnboarding()):r(n)}catch(e){a(e.message)}finally{s(null)}},[e]);(0,u.useEffect)(()=>{e.initialOnboardingCompleted||d()},[e.initialOnboardingCompleted,d]);let f=n?ES(n,c):!1;async function p(){let t=n?.globalCli.path;if(t){s(`install`),a(null);try{let n=await e.installCli(t);l(!1),ES(n,!1)?r(await e.completeOnboarding()):r(n)}catch(t){a(t.message);try{r(await e.getStatus(!0))}catch{}}finally{s(null)}}}async function m(){s(`runtime`),a(null);try{r(await e.restartDaemon())}catch(e){a(e.message)}finally{s(null)}}async function h(){if(!(!n||!f)){s(`complete`),a(null);try{r(await e.completeOnboarding())}catch(e){a(e.message)}finally{s(null)}}}if(e.initialOnboardingCompleted||n?.onboardingCompleted)return t;let g=!!(n?.runtime.ready&&n?.builtinSkill.ready);return(0,H.jsxs)(`div`,{className:`grid h-dvh min-h-0 overflow-hidden bg-[var(--background)] md:grid-cols-[15rem_minmax(0,1fr)]`,children:[(0,H.jsxs)(`aside`,{className:`app-drag-region desktop-macos-titlebar-inset shrink-0 border-b border-[var(--border)] bg-[var(--muted)]/18 p-4 md:border-r md:border-b-0 md:p-5`,children:[(0,H.jsx)(`img`,{src:NS,alt:`rynx`,className:`h-5 w-auto dark:brightness-0 dark:invert`}),(0,H.jsxs)(`div`,{className:`app-no-drag mt-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,H.jsx)(`p`,{className:`label-caps text-[10px] text-[var(--primary)]`,children:`Setup`}),(0,H.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--muted-foreground)]`,children:`1/1`})]}),(0,H.jsx)(`ol`,{className:`mt-3`,"aria-label":`Setup steps`,children:(0,H.jsxs)(`li`,{"aria-current":`step`,className:`flex items-center gap-2 rounded-lg bg-[var(--muted)] px-3 py-2.5 text-sm font-medium text-[var(--foreground)] ring-1 ring-inset ring-[var(--border)]`,children:[(0,H.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center rounded-full bg-[var(--primary)] text-[10px] font-semibold text-[var(--primary-foreground)]`,children:`1`}),(0,H.jsx)(`span`,{className:`truncate`,children:`Terminal command`})]})})]})]}),(0,H.jsxs)(`main`,{className:`app-no-drag relative min-h-0 overflow-auto`,children:[(0,H.jsx)(`div`,{className:`desktop-macos-home-titlebar`,"aria-hidden":`true`}),(0,H.jsx)(`div`,{className:`grid min-h-full place-items-center px-5 py-12 sm:px-8 md:px-12`,children:(0,H.jsxs)(`section`,{className:`w-full max-w-xl`,"aria-labelledby":`onboarding-command-title`,children:[(0,H.jsx)(FS,{titleId:`onboarding-command-title`,title:`Set up the Terminal command`,description:`Install one small command so Rynx is available from any Terminal.`}),(0,H.jsx)(`div`,{className:`mt-7 rounded-lg border border-[var(--border)] bg-[var(--card)] p-5 shadow-sm`,"aria-busy":o!==null,children:n?g?(0,H.jsx)(IS,{status:n,pending:o,acknowledged:c,onAcknowledgedChange:l,onInstall:()=>void p(),onRefresh:()=>void d(!0),onContinue:()=>void h()}):(0,H.jsx)(LS,{status:n,pending:o,onRetry:()=>void m()}):(0,H.jsxs)(`div`,{className:`flex min-h-40 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[o===`refresh`&&(0,H.jsx)(B,{className:`size-4 animate-spin`}),o===`refresh`?`Getting Rynx ready…`:`Setup status is unavailable.`]})}),i&&(0,H.jsxs)(`div`,{role:`alert`,className:`mt-5 flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_35%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_7%,var(--background))] p-3 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(zn,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]})]})})]})]})}function FS({titleId:e,title:t,description:n}){return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{id:e,className:`text-2xl font-semibold tracking-tight`,children:t}),(0,H.jsx)(`p`,{className:`mt-2 max-w-lg text-sm leading-6 text-[var(--muted-foreground)]`,children:n})]})}function IS({status:e,pending:t,acknowledged:n,onAcknowledgedChange:r,onInstall:i,onRefresh:a,onContinue:o}){let s=e.globalCli.state===`installed`,c=e.globalCli.state===`development`,l=s&&!e.globalCli.canInstall,u=TS(e),d=ES(e,n);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{className:l?`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--success)]/12 text-[var(--success)]`:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:l?(0,H.jsx)(Pn,{className:`size-4`}):(0,H.jsx)(qn,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium`,children:`Terminal command`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:RS(e)})]})]}),u&&(0,H.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 rounded-lg border border-[color-mix(in_srgb,var(--warning)_35%,var(--border))] bg-[color-mix(in_srgb,var(--warning)_7%,var(--background))] p-3 text-xs`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),className:`mt-0.5 size-4 shrink-0 accent-[var(--primary)]`}),(0,H.jsxs)(`span`,{children:[`Continue without Terminal access. I'll resolve the`,` `,(0,H.jsx)(`code`,{className:`font-mono`,children:`rynx`}),` command later.`]})]}),(0,H.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2`,children:[e.globalCli.canInstall&&(0,H.jsxs)(J,{disabled:t!==null,onClick:i,children:[t===`install`&&(0,H.jsx)(B,{className:`animate-spin`}),`Install command`]}),(l||c||u)&&(0,H.jsxs)(J,{disabled:t!==null||!d,onClick:o,children:[`Continue`,(0,H.jsx)(jn,{})]}),(0,H.jsxs)(J,{variant:`outline`,disabled:t!==null,onClick:a,children:[(0,H.jsx)(zr,{className:t===`refresh`?`animate-spin`:``}),`Check again`]})]})]})}function LS({status:e,pending:t,onRetry:n}){return(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--warning)]/12 text-[var(--warning)]`,children:(0,H.jsx)(zn,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium`,children:e.builtinSkill.ready?`Rynx couldn’t finish starting`:`Rynx needs to be reinstalled`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:e.builtinSkill.ready?`Try again to continue.`:`A required app component is unavailable. Reinstall Rynx, then open it again.`}),e.builtinSkill.ready&&(0,H.jsxs)(J,{className:`mt-4`,variant:`outline`,disabled:t!==null,onClick:n,children:[t===`runtime`&&(0,H.jsx)(B,{className:`animate-spin`}),`Try again`]})]})]})}function RS(e){switch(e.globalCli.state){case`installed`:return e.globalCli.canInstall?`Install the rynx command to use Rynx from Terminal.`:`Rynx is ready to use from Terminal.`;case`missing`:return`Install the rynx command to use Rynx from Terminal.`;case`stale`:return`An older rynx command was found. Repair it to continue.`;case`foreign`:return`Another command named rynx already exists. Resolve it later in Settings.`;case`development`:return`Terminal command registration is disabled in development builds.`;case`unwritable`:return`Rynx could not install the command automatically. Resolve it later in Settings.`;case`error`:return`Rynx could not check the command. Check again before continuing.`}}function zS({bridge:e}){let[t,n]=(0,u.useState)(null),[r,i]=(0,u.useState)(!1),[a,o]=(0,u.useState)(null),s=(0,u.useRef)(!1),c=(0,u.useRef)(0),l=(0,u.useCallback)(e=>{e.requestId<=c.current||(c.current=e.requestId,n(e),i(!1),o(null),s.current=!1)},[]);(0,u.useEffect)(()=>{let t=!0,n=e.onQuitPrompt(e=>{t&&l(e)});return e.getPendingQuitPrompt().then(e=>{t&&e&&l(e)}).catch(()=>{}),()=>{t=!1,n()}},[l,e]);let d=(0,u.useCallback)(async()=>{if(!(!t||r||s.current)){s.current=!0;try{let r=await e.respondToQuit(t.requestId,`cancel`);if(r.outcome===`failed`){o(r.message);return}if(r.outcome===`quitting`){i(!0);return}r.outcome===`cancelled`&&(n(null),o(null))}catch{o(`Rynx couldn’t dismiss the quit request. Try again.`)}finally{s.current=!1}}},[e,t,r]),f=(0,u.useCallback)(async()=>{if(!(!t||t.kind!==`active-work`||s.current)){s.current=!0,i(!0),o(null);try{let r=await e.respondToQuit(t.requestId,`force`);r.outcome===`failed`?(o(r.message),i(!1)):r.outcome===`cancelled`&&(n(null),i(!1))}catch{o(`Rynx couldn’t stop the running work. Try again.`),i(!1)}finally{s.current=!1}}},[e,t]),p=t?.kind===`active-work`;return(0,H.jsx)(uu,{open:t!==null,onOpenChange:e=>{e||d()},children:(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsx)(_u,{className:`bg-destructive/10 text-destructive`,children:(0,H.jsx)(ci,{"aria-hidden":`true`})}),(0,H.jsx)(vu,{children:p?`Quit Rynx?`:`Rynx couldn’t quit`}),(0,H.jsx)(yu,{children:p?`Work is still running. Quitting now will stop it and close the open workspace.`:`Rynx couldn’t stop its local service safely. Keep the app open and try again.`})]}),a&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{disabled:r,children:p?`Keep working`:`Close`}),p&&(0,H.jsx)(J,{type:`button`,variant:`destructive`,disabled:r,onClick:()=>void f(),children:r?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(B,{className:`animate-spin motion-reduce:animate-none`}),`Quitting…`]}):`Quit anyway`})]})]})})}var BS=[{label:`General`,items:[{id:`overview`,label:`Overview`,icon:gr},{id:`projects`,label:`Projects`,icon:ir}]},{label:`Connections`,items:[{id:`localRuntime`,label:`Local Runtime`,icon:qn},{id:`runtimes`,label:`Runtimes`,icon:Wr}]},{label:`AI Capabilities`,items:[{id:`providers`,label:`Providers`,icon:ti},{id:`agents`,label:`Agents`,icon:Mn},{id:`skills`,label:`Skills`,icon:ei}]},{label:`Integrations`,items:[{id:`computerUse`,label:`Computer Use`,icon:Cr},{id:`emulator`,label:`Emulator`,icon:$r},{id:`plugins`,label:`Plugins`,icon:Rr}]}];function VS({activeView:e,desktopIntegrationAvailable:t,children:n}){let r=nt(),i=$e(),{runtimeSelector:a}=xS(),o=Mx(i.state,jx(a)),s={returnTo:o},c=BS.map(e=>({...e,items:e.items.filter(({id:e})=>wx(e,t))})).filter(e=>e.items.length>0),l=c.flatMap(e=>e.items);return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-[var(--background)] md:grid md:grid-cols-[14rem_minmax(0,1fr)]`,children:[(0,H.jsxs)(`aside`,{className:`hidden min-h-0 flex-col border-r border-[var(--border)] bg-[var(--muted)]/18 md:flex`,children:[(0,H.jsxs)(`div`,{className:`app-drag-region desktop-macos-titlebar-inset border-b border-[var(--border)] p-2.5`,children:[(0,H.jsx)(`div`,{className:`mb-2 flex h-7 items-center px-0.5`,children:(0,H.jsxs)(hn,{to:o,className:`app-no-drag flex w-fit items-center gap-2`,"aria-label":`Rynx`,children:[(0,H.jsx)(`img`,{src:NS,alt:`rynx`,className:`h-5 w-auto dark:brightness-0 dark:invert`}),(0,H.jsx)(`span`,{className:`label-caps text-[8px] text-[var(--muted-foreground)]`,children:`control`})]})}),(0,H.jsx)(J,{asChild:!0,variant:`ghost`,size:`sm`,className:`app-no-drag w-full justify-start gap-2 px-2`,children:(0,H.jsxs)(hn,{to:o,children:[(0,H.jsx)(An,{className:`size-3.5`}),`Back to app`]})})]}),(0,H.jsx)(U_,{className:`min-h-0 flex-1`,children:(0,H.jsx)(`nav`,{className:`space-y-4 p-3`,"aria-label":`Settings`,children:c.map(t=>(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`label-caps mb-1 px-2 text-[9px] text-[var(--muted-foreground)]`,children:t.label}),(0,H.jsx)(`div`,{className:`grid gap-0.5`,children:t.items.map(({id:t,label:n,icon:r})=>(0,H.jsxs)(hn,{to:px[t],state:s,"aria-current":e===t?`page`:void 0,className:X(`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,e===t?`bg-[var(--primary)]/10 text-[var(--primary)]`:`text-[var(--muted-foreground)] hover:bg-[var(--accent)] hover:text-[var(--accent-foreground)]`),children:[(0,H.jsx)(r,{className:`size-3.5 shrink-0`}),n]},t))})]},t.label))})})]}),(0,H.jsxs)(`div`,{className:`app-drag-region flex h-14 shrink-0 items-center gap-2 border-b border-[var(--border)] bg-[var(--muted)]/18 px-3 md:hidden`,children:[(0,H.jsx)(hn,{to:o,className:`app-no-drag shrink-0`,"aria-label":`Rynx`,children:(0,H.jsx)(`img`,{src:NS,alt:`rynx`,className:`h-5 w-auto dark:brightness-0 dark:invert`})}),(0,H.jsx)(J,{asChild:!0,variant:`ghost`,size:`sm`,className:`app-no-drag shrink-0 gap-1.5 px-2`,children:(0,H.jsxs)(hn,{to:o,children:[(0,H.jsx)(An,{className:`size-3.5`}),`Back`]})}),(0,H.jsx)(Ig,{"aria-label":`Settings page`,value:e,className:`ml-auto min-w-0 flex-1`,onChange:e=>r(px[e.target.value],{state:s}),children:l.map(({id:e,label:t})=>(0,H.jsx)(`option`,{value:e,children:t},e))})]}),e===`emulator`?(0,H.jsx)(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:n}):(0,H.jsx)(U_,{className:`min-h-0 flex-1`,children:(0,H.jsx)(`section`,{className:`p-4 sm:p-6`,children:n})})]})}var HS=`Label`,US=u.forwardRef((e,t)=>(0,H.jsx)(W.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));US.displayName=HS;var WS=US,GS=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(WS,{ref:n,className:X(`text-xs font-medium text-[var(--muted-foreground)]`,e),...t}));GS.displayName=`Label`;function KS({onInstalled:e,triggerLabel:t=`Install skill`,triggerVariant:n=`default`}){let[r,i]=(0,u.useState)(!1),[a,o]=(0,u.useState)(``),[s,c]=(0,u.useState)(``),[l,d]=(0,u.useState)(``),[f,p]=(0,u.useState)(!1);function m(){o(``),c(``),d(``)}let h=(()=>{let e=a.trim();return!e||!s.trim()?e:`${e}#${s.trim()}`})(),g=!!s.trim()&&a.includes(`#`);async function _(){let t=h;if(t){if(g){V.error(`Source already pins a ref with '#' — clear one of the two.`);return}p(!0);try{let n=await Y.installSkill({tool:`skills-cli`,source:t,...l.trim()?{skill:l.trim()}:{}});V.success(`Installed ${l.trim()||t}`),e(n),m(),i(!1)}catch(e){V.error(`Install failed: ${e.message}`)}finally{p(!1)}}}let v=[`npx skills add`,h||`<source>`,l.trim()&&`--skill ${l.trim()}`].filter(Boolean).join(` `);return(0,H.jsxs)(Su,{open:r,onOpenChange:e=>{i(e),e||m()},children:[(0,H.jsx)(Cu,{asChild:!0,children:(0,H.jsxs)(J,{size:`sm`,variant:n,children:[(0,H.jsx)(Ir,{}),` `,t]})}),(0,H.jsxs)(Du,{children:[(0,H.jsxs)(Ou,{children:[(0,H.jsx)(Au,{children:`Install a skill`}),(0,H.jsxs)(ju,{children:[`From the open skills ecosystem (skills.sh). Runs `,(0,H.jsx)(`code`,{children:`npx skills add`}),` into the global catalog (`,(0,H.jsx)(`code`,{children:`~/.rynx/skills`}),`).`]})]}),(0,H.jsxs)(`div`,{className:`grid gap-3`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsxs)(GS,{children:[`Source `,(0,H.jsx)(`span`,{className:`text-[var(--destructive)]`,children:`*`})]}),(0,H.jsx)(Ag,{value:a,autoFocus:!0,placeholder:`vercel-labs/skills or https://github.com/owner/repo`,onChange:e=>o(e.target.value)}),(0,H.jsxs)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:[`A repo (`,(0,H.jsx)(`code`,{children:`owner/repo`}),`), a git URL, or a namespace.`]})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{children:`Skill`}),(0,H.jsx)(Ag,{value:l,placeholder:`find-skills`,onChange:e=>d(e.target.value)}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Optional — when a repo ships several.`})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{children:`Branch`}),(0,H.jsx)(Ag,{value:s,placeholder:`main`,onChange:e=>c(e.target.value)}),(0,H.jsxs)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:[`Optional — a git ref, sent as `,(0,H.jsx)(`code`,{children:`#<branch>`}),`.`]})]})]}),(0,H.jsx)(`pre`,{className:`overflow-x-auto rounded-md border border-[var(--border)] bg-[var(--muted)]/40 p-2.5 font-mono text-xs text-[var(--muted-foreground)]`,children:v})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(J,{variant:`outline`,onClick:()=>i(!1),children:`Cancel`}),(0,H.jsx)(J,{onClick:_,disabled:f||!a.trim(),children:f?`Installing…`:`Install`})]})]})]})}var qS=[`codex`,`traex`,`claude`],JS=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`,`ultra`],YS=[`read-only`,`workspace-write`,`danger-full-access`],XS=[`never`,`on-failure`,`on-request`,`untrusted`],ZS=[`acceptEdits`,`auto`,`bypassPermissions`,`manual`,`dontAsk`,`plan`];function QS({value:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsx)(aC,{label:`Display name`,help:`Shown in the UI; the id (left) is the directory name.`,children:(0,H.jsx)(Ag,{value:e.name??``,placeholder:`My agent`,onChange:n=>t({...e,name:n.target.value})})}),(0,H.jsx)(aC,{label:`Description`,children:(0,H.jsx)(Ag,{value:e.description??``,placeholder:`What this agent does`,onChange:n=>t({...e,description:n.target.value})})}),(0,H.jsx)(aC,{label:`Instructions`,help:`Inline system prompt, or a path to a .md under the agent dir.`,children:(0,H.jsx)(jg,{value:e.instructions??``,className:`min-h-[14rem]`,placeholder:`You are a helpful agent.`,onChange:n=>t({...e,instructions:n.target.value})})})]})}function $S({value:e,onChange:t}){let n=e.executor??{},r=n.retry??{},[i,a]=(0,u.useState)(null);(0,u.useEffect)(()=>{let e=!1;return Y.listAgentRuntimeOptions().then(t=>!e&&a(t)).catch(t=>{e||(a([]),V.error(`Load runtime options failed: ${t.message}`))}),()=>{e=!0}},[]);let o=r=>t({...e,executor:{...n,...r}}),s=i=>t({...e,executor:{...n,retry:{...r,...i}}}),c=i?.find(e=>e.id===(n.runtime??`codex`)),l=c?.models??[],d=l.find(e=>e.id===n.model)?.reasoningOptions.map(e=>e.value)??JS;return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(aC,{label:`Runtime`,children:[(0,H.jsx)(sC,{value:n.runtime,options:i?.length?i.map(e=>e.id):qS,required:!0,onChange:e=>{if(!e)return;let t=i?.find(t=>t.id===e),n=t?.models.find(e=>e.isDefault)??t?.models[0];o({runtime:e,model:n?.id,reasoningEffort:n?.defaultReasoningEffort})}}),c&&!c.available&&(0,H.jsxs)(`p`,{className:`text-xs text-[var(--warning)]`,children:[c.name,` is not installed on this machine.`]})]}),(0,H.jsx)(aC,{label:`Reasoning effort`,children:(0,H.jsx)(sC,{value:n.reasoningEffort,options:d.length>0?d:JS,onChange:e=>o({reasoningEffort:e})})})]}),(0,H.jsx)(aC,{label:`Model`,help:`Blank inherits the runtime default.`,children:l.length>0?(0,H.jsxs)(my,{value:n.model??``,onValueChange:e=>o({model:e,reasoningEffort:void 0}),children:[(0,H.jsx)(_y,{children:(0,H.jsx)(gy,{placeholder:`runtime default`})}),(0,H.jsxs)(by,{children:[n.model&&!l.some(e=>e.id===n.model)&&(0,H.jsxs)(Sy,{value:n.model,children:[n.model,` · custom`]}),l.map(e=>(0,H.jsxs)(Sy,{value:e.id,children:[e.label,e.isDefault?` · default`:``]},e.id))]})]}):(0,H.jsx)(Ag,{value:n.model??``,placeholder:`runtime default`,onChange:e=>o({model:e.target.value||void 0})})}),(0,H.jsx)(`div`,{className:`label-caps pt-1 text-xs text-[var(--muted-foreground)]`,children:`Execution budget`}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsx)(aC,{label:`Timeout (s)`,help:`End-to-end wall-clock cap.`,children:(0,H.jsx)(cC,{value:n.timeout,onChange:e=>o({timeout:e})})}),(0,H.jsx)(aC,{label:`Max iterations`,help:`claude only (→ --max-turns).`,children:(0,H.jsx)(cC,{value:n.maxIterations,onChange:e=>o({maxIterations:e})})}),(0,H.jsx)(aC,{label:`Context window`,help:`codex/traex token budget.`,children:(0,H.jsx)(cC,{value:n.contextWindow,onChange:e=>o({contextWindow:e})})}),(0,H.jsx)(aC,{label:`Retry: max retries`,children:(0,H.jsx)(cC,{value:r.maxRetries,onChange:e=>s({maxRetries:e})})}),(0,H.jsx)(aC,{label:`Retry: timeout/req (s)`,children:(0,H.jsx)(cC,{value:r.timeoutPerRequestSeconds,onChange:e=>s({timeoutPerRequestSeconds:e})})})]})]})}function eC({value:e,onChange:t}){let n=e.osEnv??{},r=r=>t({...e,osEnv:{...n,...r}}),i=e.executor?.runtime??`codex`;return(0,H.jsx)(`div`,{className:`grid gap-4`,children:(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[i===`claude`?(0,H.jsx)(aC,{label:`Permission mode`,help:`Claude's approval axis (--permission-mode).`,children:(0,H.jsx)(sC,{value:n.permissionMode,options:ZS,onChange:e=>r({permissionMode:e})})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(aC,{label:`Sandbox`,children:(0,H.jsx)(sC,{value:n.sandbox,options:YS,onChange:e=>r({sandbox:e})})}),(0,H.jsx)(aC,{label:`Approval policy`,help:`Codex's approval axis.`,children:(0,H.jsx)(sC,{value:n.approvalPolicy,options:XS,onChange:e=>r({approvalPolicy:e})})})]}),(0,H.jsx)(aC,{label:`Full auto`,children:(0,H.jsxs)(`label`,{className:`flex h-8 items-center gap-2 text-sm`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`size-4`,checked:!!n.fullAuto,onChange:e=>r({fullAuto:e.target.checked||void 0})}),(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:`enable`})]})})]})})}function tC({value:e,onChange:t}){let n=e.tools??{},r=r=>t({...e,tools:{...n,...r}});return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsx)(aC,{label:`Allowed tools`,help:`claude only; codex/traex ignore.`,children:(0,H.jsx)(lC,{items:n.allowed??[],placeholder:`ToolName`,onChange:e=>r({allowed:e})})}),(0,H.jsx)(aC,{label:`Disallowed tools`,children:(0,H.jsx)(lC,{items:n.disallowed??[],placeholder:`ToolName`,onChange:e=>r({disallowed:e})})}),(0,H.jsx)(aC,{label:`MCP servers`,help:`HTTP transport only.`,children:(0,H.jsx)(uC,{rows:n.mcp??[],onChange:e=>r({mcp:e})})})]})}function nC({value:e,onChange:t}){let n=e.skills??[],[r,i]=(0,u.useState)(null);(0,u.useEffect)(()=>{Y.listSkills().then(i).catch(e=>{i([]),V.error(`Load skills failed: ${e.message}`)})},[]);let a=new Set(n.map(e=>e.name)),o=r=>{r.ref&&t({...e,skills:[...n,{...r.ref}]})},s=r=>t({...e,skills:n.filter(e=>e.name!==r)}),c=new Set((r??[]).map(e=>e.name)),l=n.map(e=>e.name).filter(e=>!c.has(e));return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsx)(aC,{label:`Skills`,help:`Empty = no skills (hermetic). Each selection copies the skill's install recipe into the spec, so the agent installs its own skills wherever it runs.`,children:r===null?(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Loading…`}):r.length===0&&l.length===0?(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`No skills installed yet — install one below.`}):(0,H.jsxs)(`div`,{className:`grid gap-0.5 rounded-md border border-[var(--border)] p-1.5`,children:[r.map(e=>(0,H.jsxs)(`label`,{className:`flex items-start gap-2 rounded-sm p-1.5 `+(e.ref?`cursor-pointer hover:bg-[var(--muted)]/50`:`opacity-60`),children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0`,disabled:!e.ref,checked:a.has(e.name),onChange:t=>t.target.checked?o(e):s(e.name)}),(0,H.jsxs)(`span`,{className:`grid`,children:[(0,H.jsxs)(`span`,{className:`font-mono text-sm`,children:[e.name,!e.ref&&(0,H.jsx)(`span`,{className:`ml-1 text-xs text-[var(--warning)]`,children:`(no install recipe — reinstall to make selectable)`})]}),(0,H.jsx)(`span`,{className:`line-clamp-2 text-xs text-[var(--muted-foreground)]`,children:e.description})]})]},e.name)),l.map(e=>(0,H.jsxs)(`label`,{className:`flex items-center gap-2 rounded-sm p-1.5`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`size-4 shrink-0`,checked:!0,onChange:()=>s(e)}),(0,H.jsxs)(`span`,{className:`font-mono text-sm`,children:[e,` `,(0,H.jsx)(`span`,{className:`text-xs text-[var(--muted-foreground)]`,children:`(declared in the spec; installs at run time)`})]})]},e))]})}),(0,H.jsx)(`div`,{children:(0,H.jsx)(KS,{onInstalled:i,triggerVariant:`outline`})})]})}function rC(e){let{skills:t,...n}=e,r=iC(n)??{};return Array.isArray(t)&&t.length>0&&(r.skills=t),r}function iC(e){if(Array.isArray(e)){let t=e.map(iC).filter(e=>e!==void 0);return t.length>0?t:void 0}if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e)){let e=iC(r);e!==void 0&&(t[n]=e)}return Object.keys(t).length>0?t:void 0}if(typeof e==`string`){let t=e.trim();return t===``?void 0:t}return e}function aC({label:e,help:t,children:n}){return(0,H.jsxs)(`div`,{className:`grid content-start gap-1.5`,children:[(0,H.jsx)(GS,{children:e}),n,t&&(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:t})]})}var oC=`__default__`;function sC({value:e,options:t,onChange:n,disabled:r,required:i}){return(0,H.jsxs)(my,{value:e??(i?t[0]:oC),disabled:r,onValueChange:e=>n(e===oC?void 0:e),children:[(0,H.jsx)(_y,{children:(0,H.jsx)(gy,{})}),(0,H.jsxs)(by,{children:[!i&&(0,H.jsx)(Sy,{value:oC,children:(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:`Unset`})}),t.map(e=>(0,H.jsx)(Sy,{value:e,children:e},e))]})]})}function cC({value:e,onChange:t}){return(0,H.jsx)(Ag,{type:`number`,value:e??``,onChange:e=>{let n=e.target.value;t(n===``?void 0:Number(n))}})}function lC({items:e,placeholder:t,onChange:n}){let r=(t,r)=>n(e.map((e,n)=>n===t?r:e)),i=t=>n(e.filter((e,n)=>n!==t));return(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[e.map((e,n)=>(0,H.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,H.jsx)(Ag,{value:e,placeholder:t,onChange:e=>r(n,e.target.value)}),(0,H.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>i(n),children:(0,H.jsx)(di,{})})]},n)),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,className:`justify-self-start`,onClick:()=>n([...e,``]),children:[(0,H.jsx)(Ir,{}),` Add`]})]})}function uC({rows:e,onChange:t}){let n=(0,u.useRef)(0),[r,i]=(0,u.useState)(()=>e.map(()=>n.current++)),a=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),o=n=>{t(e.filter((e,t)=>t!==n)),i(r.filter((e,t)=>t!==n))};return(0,H.jsxs)(`div`,{className:`grid gap-2`,children:[e.map((e,t)=>(0,H.jsxs)(`div`,{className:`grid gap-2 rounded-md border border-[var(--border)] p-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(Ag,{className:`w-1/3`,value:e.name??``,placeholder:`name`,onChange:e=>a(t,{name:e.target.value})}),(0,H.jsx)(`span`,{className:`label-caps rounded bg-[var(--muted)] px-1.5 py-1 text-[10px] text-[var(--muted-foreground)]`,children:`HTTP`}),(0,H.jsx)(Ag,{value:e.url??``,placeholder:`https://server/mcp`,onChange:e=>a(t,{url:e.target.value})}),(0,H.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>o(t),children:(0,H.jsx)(di,{})})]}),(0,H.jsx)(dC,{headers:e.headers??{},onChange:e=>a(t,{headers:e})})]},r[t]??t)),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,className:`justify-self-start`,onClick:()=>{t([...e,{name:``,url:``}]),i([...r,n.current++])},children:[(0,H.jsx)(Ir,{}),` Add MCP server`]})]})}function dC({headers:e,onChange:t}){let[n,r]=(0,u.useState)(()=>Object.entries(e).map(([e,t])=>({k:e,v:t})));function i(e){r(e);let n={};for(let{k:t,v:r}of e){let e=t.trim();e&&(n[e]=r)}t(Object.keys(n).length>0?n:void 0)}let a=(e,t)=>i(n.map((n,r)=>r===e?{...n,...t}:n)),o=e=>i(n.filter((t,n)=>n!==e));return(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[n.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,H.jsx)(Ag,{className:`w-1/3 font-mono text-xs`,value:e.k,placeholder:`Header`,onChange:e=>a(t,{k:e.target.value})}),(0,H.jsx)(Ag,{className:`font-mono text-xs`,value:e.v,placeholder:`value`,onChange:e=>a(t,{v:e.target.value})}),(0,H.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>o(t),children:(0,H.jsx)(di,{})})]},t)),(0,H.jsxs)(J,{variant:`ghost`,size:`sm`,className:`justify-self-start text-[var(--muted-foreground)]`,onClick:()=>i([...n,{k:``,v:``}]),children:[(0,H.jsx)(Ir,{}),` Add header`]})]})}function fC({className:e,...t}){return(0,H.jsx)(`div`,{className:X(`glass rounded-xl border border-[var(--border)] text-[var(--card-foreground)]`,e),...t})}function pC({className:e,...t}){return(0,H.jsx)(`div`,{className:X(`flex items-center justify-between gap-3 px-5 py-4 border-b border-[var(--border)]`,e),...t})}function mC({className:e,...t}){return(0,H.jsx)(`h3`,{className:X(`text-sm font-semibold tracking-tight`,e),...t})}function hC({className:e,...t}){return(0,H.jsx)(`div`,{className:X(`p-5`,e),...t})}var gC=/^[a-z0-9][a-z0-9-]{0,63}$/,_C=[{id:`identity`,label:`Identity`,blurb:`Name, description, and system instructions.`},{id:`model`,label:`Model & Budget`,blurb:`Runtime, model, reasoning effort, and execution limits.`},{id:`environment`,label:`Environment`,blurb:`Sandbox and per-runtime approval behavior.`},{id:`tools`,label:`Tools & MCP`,blurb:`Allowed/disallowed tools and MCP servers.`},{id:`skills`,label:`Skills`,blurb:`Which skills this agent can use.`},{id:`review`,label:`Review`,blurb:`Confirm and save.`}];function vC({initial:e,onClose:t,onSaved:n}){let r=e.id===``,[i,a]=(0,u.useState)(e.id),[o,s]=(0,u.useState)(e.spec),[c,l]=(0,u.useState)(`identity`),[d,f]=(0,u.useState)(`form`),[p,m]=(0,u.useState)(()=>JSON.stringify(e.spec,null,2)),[h,g]=(0,u.useState)(!1);function _(e){if(e!==d){if(e===`json`)m(JSON.stringify(o,null,2)),f(`json`);else try{s(JSON.parse(p)),f(`form`)}catch(e){V.error(`Invalid JSON: ${e.message}`)}}}async function v(){let t=i.trim();if(r&&!gC.test(t))return l(`identity`),V.error(t?`Invalid agent id — use lowercase letters, digits, or hyphens`:`Agent id is required`);let a;if(d===`json`)try{a=JSON.parse(p)}catch(e){return V.error(`Invalid JSON: ${e.message}`)}else a=o;g(!0);try{r?await Y.createAgent({...rC(a),id:i.trim()}):await Y.updateAgent(e.id,rC(a)),V.success(`Agent "${i}" saved`),await n()}catch(e){V.error(`Save failed: ${e.message}`)}finally{g(!1)}}return(0,H.jsxs)(`div`,{className:`grid gap-5`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex w-fit items-center gap-1 text-xs text-[var(--muted-foreground)] hover:text-[var(--foreground)]`,children:[(0,H.jsx)(An,{className:`size-3.5`}),` Agents`]}),(0,H.jsx)(`h1`,{className:`text-xl font-semibold`,children:r?`New agent`:`Edit "${e.id}"`})]}),(0,H.jsx)(`div`,{className:`inline-flex rounded-md border border-[var(--border)] p-0.5`,children:[`form`,`json`].map(e=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>_(e),className:X(`rounded-sm px-3 py-1 text-sm capitalize transition-colors`,d===e?`bg-[var(--primary)] text-[var(--primary-foreground)]`:`text-[var(--muted-foreground)] hover:text-[var(--foreground)]`),children:e},e))})]}),d===`json`?(0,H.jsx)(jg,{value:p,onChange:e=>m(e.target.value),className:`min-h-[28rem] font-mono text-xs`}):(0,H.jsxs)(`div`,{className:`grid grid-cols-[12rem_1fr] gap-6`,children:[(0,H.jsx)(`nav`,{className:`sticky top-6 grid h-fit gap-0.5`,children:_C.map(e=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>l(e.id),className:X(`rounded-md px-3 py-2 text-left text-sm transition-colors`,c===e.id?`bg-[var(--muted)] font-medium text-[var(--foreground)]`:`text-[var(--muted-foreground)] hover:bg-[var(--muted)]/50`),children:e.label},e.id))}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`mb-4`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold`,children:yC(c).label}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:yC(c).blurb})]}),(0,H.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] p-5`,children:[c===`identity`&&(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsxs)(GS,{children:[`Agent ID `,(0,H.jsx)(`span`,{className:`text-[var(--destructive)]`,children:`*`})]}),(0,H.jsx)(Ag,{value:i,disabled:!r,onChange:e=>a(e.target.value),placeholder:`polly`,"aria-invalid":r&&i.trim()!==``&&!gC.test(i.trim())}),r&&i.trim()!==``&&!gC.test(i.trim())?(0,H.jsx)(`p`,{className:`text-xs text-[var(--destructive)]`,children:`Use 1–64 lowercase letters, digits, or hyphens, starting with a letter or digit.`}):(0,H.jsxs)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:[`The config directory name. References (`,(0,H.jsx)(`code`,{children:`/agent <id>`}),`, bindings) use it; it can't change after creation.`]})]}),(0,H.jsx)(QS,{value:o,onChange:s})]}),c===`model`&&(0,H.jsx)($S,{value:o,onChange:s}),c===`environment`&&(0,H.jsx)(eC,{value:o,onChange:s}),c===`tools`&&(0,H.jsx)(tC,{value:o,onChange:s}),c===`skills`&&(0,H.jsx)(nC,{value:o,onChange:s}),c===`review`&&(0,H.jsx)(bC,{id:i,spec:o})]})]})]}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-[var(--border)] pt-4`,children:[(0,H.jsx)(J,{variant:`outline`,onClick:t,children:`Cancel`}),(0,H.jsx)(J,{onClick:v,disabled:h,children:h?`Saving…`:`Save`})]})]})}function yC(e){return _C.find(t=>t.id===e)??_C[0]}function bC({id:e,spec:t}){let n=rC(t),r=[[`Agent ID`,e||`—`],[`Display name`,t.name?.trim()||`—`],[`Runtime`,t.executor?.runtime??`default`],[`Model`,t.executor?.model?.trim()||`runtime default`],[`Skills`,xC(t.skills)],[`MCP servers`,String(t.tools?.mcp?.filter(e=>e.url?.trim()).length??0)]];return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsx)(`dl`,{className:`grid grid-cols-[10rem_1fr] gap-x-4 gap-y-2 text-sm`,children:r.map(([e,t])=>(0,H.jsxs)(`div`,{className:`contents`,children:[(0,H.jsx)(`dt`,{className:`text-[var(--muted-foreground)]`,children:e}),(0,H.jsx)(`dd`,{className:`font-medium`,children:t})]},e))}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{children:`Resulting spec`}),(0,H.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded-md border border-[var(--border)] bg-[var(--muted)]/40 p-3 font-mono text-xs`,children:JSON.stringify({id:e||void 0,...n},null,2)})]})]})}function xC(e){return e?.length?`${e.length} declared`:`None`}var SC=/^[a-z0-9][a-z0-9-]{0,63}$/;function CC({agents:e,onChange:t}){let[n,r]=(0,u.useState)(e[0]?.id??``),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(null),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)([]),[h,g]=(0,u.useState)([]),[_,v]=(0,u.useState)(!1);(0,u.useEffect)(()=>{n&&e.some(e=>e.id===n)||r(e[0]?.id??``)},[e,n]),(0,u.useEffect)(()=>{if(!n){a(null);return}let e=!1;return s(!0),Y.getAgent(n).then(t=>{e||a(t)}).catch(t=>!e&&V.error(`Load agent failed: ${t.message}`)).finally(()=>!e&&s(!1)),()=>{e=!0}},[n]);async function y(e=!1){v(!0);try{let[t,n]=await Promise.all([Y.listAgentRuntimeOptions(e),Y.listSkills()]);m(t),g(n)}catch(e){V.error(`Load local options failed: ${e.message}`)}finally{v(!1)}}async function b(e){try{let t=await Y.getAgent(e);delete t.id,l({id:e,spec:t})}catch(e){V.error(`Load failed: ${e.message}`)}}if(c)return(0,H.jsx)(vC,{initial:c,onClose:()=>l(null),onSaved:async()=>{let e=c.id;l(null),await t(),r(e),a(await Y.getAgent(e))}});let x=new Set(e.map(e=>e.runtime).filter(Boolean)),S=e.reduce((e,t)=>e+(t.skillCount??0),0);return(0,H.jsxs)(`div`,{className:`grid gap-5`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Agents`}),(0,H.jsxs)(`p`,{className:`mt-1 text-sm text-[var(--muted-foreground)]`,children:[`Local Agent profiles discovered from `,(0,H.jsx)(`code`,{children:`~/.rynx/agents`}),`.`]})]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(J,{variant:`outline`,onClick:()=>void t(),children:[(0,H.jsx)(zr,{}),` Refresh`]}),(0,H.jsxs)(J,{onClick:()=>{f(!0),y()},children:[(0,H.jsx)(Ir,{}),` New agent`]})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,H.jsx)(DC,{label:`agents`,value:e.length,detail:`Local registered profiles`}),(0,H.jsx)(DC,{label:`runtimes`,value:x.size,detail:`Runtimes currently used`}),(0,H.jsx)(DC,{label:`skill bindings`,value:S,detail:`Explicit Skill references`})]}),(0,H.jsxs)(`div`,{className:`grid min-h-[620px] gap-4 lg:grid-cols-[320px_minmax(0,1fr)]`,children:[(0,H.jsxs)(fC,{className:`overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--border)] px-4 py-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Agent list`}),(0,H.jsx)(`span`,{className:`text-xs text-[var(--muted-foreground)]`,children:e.length})]}),(0,H.jsxs)(`div`,{className:`grid gap-2 p-2`,children:[e.length===0&&(0,H.jsx)(`div`,{className:`rounded-lg border border-dashed border-[var(--border)] px-4 py-6 text-sm text-[var(--muted-foreground)]`,children:`No local Agents registered yet.`}),e.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:X(`flex w-full items-start gap-3 rounded-lg border px-3 py-3 text-left transition-colors`,n===e.id?`border-[var(--primary)] bg-[var(--primary)]/10`:`border-[var(--border)] hover:bg-[var(--muted)]/45`),children:[(0,H.jsx)(`span`,{className:`mt-0.5 grid size-9 shrink-0 place-items-center rounded-md bg-violet-500/10 text-violet-600`,children:(0,H.jsx)(Mn,{className:`size-4`})}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:e.name??e.id}),n===e.id&&(0,H.jsx)(Ln,{className:`size-4 shrink-0 text-[var(--primary)]`})]}),e.description&&(0,H.jsx)(`span`,{className:`mt-1 block line-clamp-2 text-xs text-[var(--muted-foreground)]`,children:e.description}),(0,H.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-1.5 text-[10px] text-[var(--muted-foreground)]`,children:[(0,H.jsx)(`span`,{className:`rounded bg-[var(--muted)] px-1.5 py-1`,children:e.runtime??`default runtime`}),(0,H.jsxs)(`span`,{className:`rounded bg-[var(--muted)] px-1.5 py-1`,children:[e.skillCount??0,` skills`]})]})]})]},e.id))]})]}),(0,H.jsx)(wC,{id:n,detail:i,loading:o,onEdit:()=>void b(n),onDeleted:t})]}),(0,H.jsx)(TC,{open:d,onOpenChange:f,runtimes:p,skills:h,loading:_,onRefresh:()=>y(!0),onCreated:async e=>{f(!1),await t(),r(e)}})]})}function wC({id:e,detail:t,loading:n,onEdit:r,onDeleted:i}){if(!e)return(0,H.jsx)(fC,{className:`p-6 text-sm text-[var(--muted-foreground)]`,children:`Select an Agent to inspect its configuration.`});if(n||!t)return(0,H.jsx)(fC,{className:`p-6 text-sm text-[var(--muted-foreground)]`,children:`Loading Agent configuration…`});let a=t.skills??[];return(0,H.jsxs)(fC,{className:`overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-[var(--border)] px-5 py-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`text-lg font-semibold`,children:t.name??e}),(0,H.jsx)(`code`,{className:`text-[10px] text-[var(--muted-foreground)]`,children:e})]}),t.description&&(0,H.jsx)(`p`,{className:`mt-1 text-sm text-[var(--muted-foreground)]`,children:t.description})]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(J,{variant:`outline`,size:`sm`,onClick:r,children:[(0,H.jsx)(Pr,{}),` Edit configuration`]}),(0,H.jsx)(EC,{id:e,onChange:i})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-6 p-5`,children:[(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,H.jsx)(OC,{label:`Runtime`,value:t.executor?.runtime??`default`}),(0,H.jsx)(OC,{label:`Model`,value:t.executor?.model??`runtime default`}),(0,H.jsx)(OC,{label:`Reasoning`,value:t.executor?.reasoningEffort??`runtime default`})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:`instructions`}),(0,H.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap rounded-lg border border-[var(--border)] bg-[var(--muted)]/25 p-4 text-sm leading-6`,children:t.instructions||`No inline instructions.`})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:`skills`}),(0,H.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:a.length===0?(0,H.jsx)(`span`,{className:`text-sm text-[var(--muted-foreground)]`,children:`No Skills bound.`}):a.map(e=>(0,H.jsx)(`span`,{className:`rounded-md bg-[var(--muted)] px-2 py-1 font-mono text-xs`,children:e.name},e.name))})]})]})]})}function TC({open:e,onOpenChange:t,runtimes:n,skills:r,loading:i,onRefresh:a,onCreated:o}){let[s,c]=(0,u.useState)(``),[l,d]=(0,u.useState)(``),[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(``),[g,_]=(0,u.useState)(`You are a helpful agent.`),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(new Set),[E,D]=(0,u.useState)(!1),O=n.filter(e=>e.available),k=n.find(e=>e.id===v),A=k?.models.find(e=>e.id===b);(0,u.useEffect)(()=>{if(!e||v)return;let t=O[0];if(!t)return;let n=t.models.find(e=>e.isDefault)??t.models[0];y(t.id),x(n?.id??``),C(n?.defaultReasoningEffort??``)},[O,e,v,n]);function j(){c(``),d(``),p(!1),h(``),_(`You are a helpful agent.`),y(``),x(``),C(``),T(new Set)}function M(e){let t=n.find(t=>t.id===e),r=t?.models.find(e=>e.isDefault)??t?.models[0];y(e),x(r?.id??``),C(r?.defaultReasoningEffort??``)}async function N(){let e=l.trim();if(!SC.test(e)||!s.trim()||!g.trim()||!v)return;let t=r.filter(e=>w.has(e.name)&&e.ref).map(e=>({...e.ref}));D(!0);try{await Y.createAgent({id:e,name:s.trim(),...m.trim()?{description:m.trim()}:{},instructions:g.trim(),executor:{runtime:v,...b?{model:b}:{},...S?{reasoningEffort:S}:{},timeout:1800,retry:{maxRetries:2}},osEnv:{sandbox:`danger-full-access`,approvalPolicy:`never`},...t.length?{skills:t}:{}}),V.success(`Agent "${s.trim()}" created`),j(),await o(e)}catch(e){V.error(`Create Agent failed: ${e.message}`)}finally{D(!1)}}let P=!!(SC.test(l.trim())&&s.trim()&&g.trim()&&v);return(0,H.jsx)(Su,{open:e,onOpenChange:e=>{t(e),e||j()},children:(0,H.jsxs)(Du,{className:`max-h-[85vh] overflow-y-auto sm:max-w-2xl`,children:[(0,H.jsx)(Ou,{children:(0,H.jsx)(Au,{children:`Create local Agent`})}),(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(kC,{label:`Name`,children:(0,H.jsx)(Ag,{value:s,autoFocus:!0,onChange:e=>{let t=e.target.value;c(t),f||d(AC(t))}})}),(0,H.jsx)(kC,{label:`Agent ID`,children:(0,H.jsx)(Ag,{value:l,onChange:e=>{p(!0),d(e.target.value)},"aria-invalid":!!l&&!SC.test(l)})})]}),(0,H.jsx)(kC,{label:`Description`,children:(0,H.jsx)(Ag,{value:m,onChange:e=>h(e.target.value)})}),(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,H.jsx)(kC,{label:`Runtime`,children:(0,H.jsxs)(my,{value:v,onValueChange:M,disabled:i||n.length===0,children:[(0,H.jsx)(_y,{children:(0,H.jsx)(gy,{placeholder:`No runtime found`})}),(0,H.jsx)(by,{children:n.map(e=>(0,H.jsxs)(Sy,{value:e.id,disabled:!e.available,children:[e.name,e.available?``:` · missing`]},e.id))})]})}),(0,H.jsx)(kC,{label:`Model`,children:(0,H.jsxs)(my,{value:b,onValueChange:e=>{x(e),C(k?.models.find(t=>t.id===e)?.defaultReasoningEffort??``)},disabled:!k||k.models.length===0,children:[(0,H.jsx)(_y,{children:(0,H.jsx)(gy,{placeholder:`Runtime default`})}),(0,H.jsx)(by,{children:k?.models.map(e=>(0,H.jsxs)(Sy,{value:e.id,children:[e.label,e.isDefault?` · default`:``]},e.id))})]})}),(0,H.jsx)(kC,{label:`Reasoning`,children:(0,H.jsxs)(my,{value:S||`__default__`,onValueChange:e=>C(e===`__default__`?``:e),children:[(0,H.jsx)(_y,{children:(0,H.jsx)(gy,{})}),(0,H.jsxs)(by,{children:[(0,H.jsx)(Sy,{value:`__default__`,children:`Runtime default`}),A?.reasoningOptions.map(e=>(0,H.jsx)(Sy,{value:e.value,children:e.label},e.value))]})]})})]}),O.length===0&&!i&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-dashed border-[var(--border)] px-3 py-2 text-xs text-[var(--muted-foreground)]`,children:[`No local coding runtime was discovered.`,(0,H.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>void a(),children:[(0,H.jsx)(zr,{}),` Scan`]})]}),(0,H.jsx)(kC,{label:`Instructions`,children:(0,H.jsx)(jg,{className:`min-h-32`,value:g,onChange:e=>_(e.target.value)})}),(0,H.jsxs)(`fieldset`,{className:`rounded-lg border border-[var(--border)] p-3`,children:[(0,H.jsx)(`legend`,{className:`label-caps px-1 text-[10px] text-[var(--muted-foreground)]`,children:`skills · optional`}),(0,H.jsxs)(`div`,{className:`grid max-h-40 gap-1 overflow-y-auto`,children:[r.filter(e=>e.ref).length===0&&(0,H.jsx)(`div`,{className:`py-2 text-xs text-[var(--muted-foreground)]`,children:`No selectable local Skills.`}),r.filter(e=>e.ref).map(e=>(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md px-2 py-2 hover:bg-[var(--muted)]/50`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4`,checked:w.has(e.name),onChange:()=>T(t=>{let n=new Set(t);return n.has(e.name)?n.delete(e.name):n.add(e.name),n})}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`span`,{className:`block font-mono text-sm`,children:e.name}),(0,H.jsx)(`span`,{className:`line-clamp-1 text-xs text-[var(--muted-foreground)]`,children:e.description})]})]},e.name))]})]})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,H.jsx)(J,{disabled:!P||E,onClick:()=>void N(),children:E?`Creating…`:`Create`})]})]})})}function EC({id:e,onChange:t}){return(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsx)(J,{variant:`ghost`,size:`sm`,className:`text-[var(--destructive)]`,children:(0,H.jsx)(si,{})})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[`Delete Agent "`,e,`"?`]}),(0,H.jsx)(yu,{children:`Removes its local config directory. Existing Session snapshots are unaffected.`})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:async()=>{try{await Y.deleteAgent(e),V.success(`Agent "${e}" deleted`),await t()}catch(e){V.error(`Delete failed: ${e.message}`)}},children:`Delete`})]})]})]})}function DC({label:e,value:t,detail:n}){return(0,H.jsxs)(fC,{className:`p-4`,children:[(0,H.jsx)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:e}),(0,H.jsx)(`div`,{className:`mt-2 text-2xl font-semibold`,children:t}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:n})]})}function OC({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] bg-[var(--muted)]/20 px-3 py-2`,children:[(0,H.jsx)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:e}),(0,H.jsx)(`div`,{className:`mt-1 truncate text-sm`,children:t})]})}function kC({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{children:e}),t]})}function AC(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,64)}var jC=cu(`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium`,{variants:{variant:{default:`border-transparent bg-[var(--secondary)] text-[var(--secondary-foreground)]`,success:`border-transparent bg-[var(--success)]/15 text-[var(--success)]`,warning:`border-transparent bg-[var(--warning)]/15 text-[var(--warning)]`,destructive:`border-transparent bg-[var(--destructive)]/15 text-[var(--destructive)]`,outline:`text-[var(--muted-foreground)]`}},defaultVariants:{variant:`default`}});function MC({className:e,variant:t,...n}){return(0,H.jsx)(`span`,{className:X(jC({variant:t}),e),...n})}async function NC(e,t){if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),`clipboard`}catch{}if(!t||typeof document>`u`)return`unavailable`;t.focus({preventScroll:!0}),t.select(),t.setSelectionRange(0,e.length);try{if(typeof document.execCommand==`function`&&document.execCommand(`copy`))return`selection`}catch{}return`selected`}var PC=`127.0.0.1:9333`;function FC({embedded:e=!1}={}){let t=wS(),n=(0,u.useRef)(null),[r,i]=(0,u.useState)(null),[a,o]=(0,u.useState)(null),[s,c]=(0,u.useState)(`load`),l=(0,u.useCallback)(async()=>{if(!t){c(null),o(`Chrome inspection is available only in the Rynx app.`);return}c(`load`),o(null);try{i(await t.getChromeInspectionStatus())}catch(e){o(e.message)}finally{c(null)}},[t]);(0,u.useEffect)(()=>{l()},[l]);async function d(e){if(t){c(`save`),o(null);try{i(await t.configureChromeInspection(e))}catch(e){let t=e.message;o(t),V.error(`Could not update Chrome inspection: ${t}`)}finally{c(null)}}}async function f(){let e=await NC(PC,n.current);e===`clipboard`||e===`selection`?V.success(`Address copied`):e===`selected`?V.info(`Address selected — copy it manually`):V.error(`Copy is unavailable`)}let p=r?.settings,m=s!==null;return(0,H.jsxs)(`div`,{id:e?`chrome-inspection`:void 0,className:e?`grid scroll-mt-6 gap-5`:`grid max-w-3xl gap-5`,children:[!e&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Chrome inspection`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Inspect Rynx-managed browser pages with Chrome DevTools.`})]}),(0,H.jsxs)(fC,{"aria-busy":s!==null,children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(mC,{children:`DevTools discovery`}),r&&(0,H.jsx)(IC,{status:r})]}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Chrome connects to one local address and discovers the browsers you choose.`})]}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:m,onClick:()=>void l(),children:[(0,H.jsx)(zr,{className:s===`load`?`animate-spin`:``}),`Check`]})]}),(0,H.jsxs)(hC,{className:`grid gap-5`,children:[r&&p?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(LC,{title:`Enable Chrome inspection`,description:`Make the selected browser pages available to Chrome DevTools.`,children:(0,H.jsx)(Ub,{"aria-label":`Enable Chrome inspection`,checked:p.enabled,disabled:m,onCheckedChange:e=>void d({...p,enabled:e})})}),(0,H.jsx)(`div`,{className:`h-px bg-[var(--border)]`}),(0,H.jsxs)(`div`,{className:`grid gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:`Browsers to include`}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--muted-foreground)]`,children:`Only selected browser pages appear in Chrome.`})]}),(0,H.jsx)(RC,{title:`This device`,detail:`Browser pages managed by Rynx on this device`,checked:p.includeLocal,disabled:m||!p.enabled,onChange:e=>void d({...p,includeLocal:e})}),r.remotes.map(e=>(0,H.jsx)(RC,{title:e.displayName,detail:BC(e.status),badge:e.status,checked:p.remoteDaemonIds.includes(e.daemonId),disabled:m||!p.enabled||e.status===`incompatible`,onChange:t=>void d({...p,remoteDaemonIds:t?[...p.remoteDaemonIds,e.daemonId]:p.remoteDaemonIds.filter(t=>t!==e.daemonId)})},e.daemonId))]}),(0,H.jsx)(`div`,{className:`h-px bg-[var(--border)]`}),(0,H.jsxs)(`div`,{className:`grid gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:`Connect Chrome once`}),(0,H.jsxs)(`p`,{className:`mt-0.5 text-xs leading-5 text-[var(--muted-foreground)]`,children:[`Open `,(0,H.jsx)(`span`,{className:`font-mono`,children:`chrome://inspect`}),`, choose`,` `,(0,H.jsx)(`strong`,{children:`Configure…`}),`, then add this address.`]})]}),(0,H.jsxs)(`div`,{className:`flex max-w-sm gap-2`,children:[(0,H.jsx)(Ag,{ref:n,value:PC,readOnly:!0,"aria-label":`Chrome inspection address`,className:`font-mono`}),(0,H.jsxs)(J,{variant:`outline`,onClick:()=>void f(),"aria-label":`Copy Chrome inspection address`,children:[(0,H.jsx)(Jn,{}),`Copy`]})]})]}),r.runtime.state===`error`&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--warning)_35%,var(--border))] bg-[color-mix(in_srgb,var(--warning)_8%,var(--background))] p-3 text-xs text-[var(--warning)]`,children:[(0,H.jsx)(ci,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`font-medium`,children:`Chrome inspection could not start`}),(0,H.jsx)(`div`,{className:`mt-0.5 text-[var(--foreground)]`,children:r.runtime.error})]})]}),(0,H.jsxs)(`div`,{role:`note`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_30%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_6%,var(--background))] p-3 text-xs leading-5`,children:[(0,H.jsx)(ci,{className:`mt-0.5 size-4 shrink-0 text-[var(--destructive)]`}),(0,H.jsx)(`span`,{children:`Any process on this device can use this address to fully control every browser exposed here. Enable it only while you need DevTools.`})]})]}):(0,H.jsxs)(`div`,{className:`flex min-h-40 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[s===`load`&&(0,H.jsx)(B,{className:`size-4 animate-spin`}),s===`load`?`Loading Chrome inspection…`:`Chrome inspection settings are unavailable.`]}),a&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_35%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_7%,var(--background))] p-3 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(ci,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{children:a})]})]})]})]})}function IC({status:e}){return e.runtime.state===`listening`?(0,H.jsxs)(MC,{variant:`success`,children:[(0,H.jsx)(Pn,{className:`size-3`}),`Listening`]}):e.runtime.state===`error`?(0,H.jsx)(MC,{variant:`warning`,children:`Needs attention`}):(0,H.jsx)(MC,{variant:`outline`,children:`Off`})}function LC({title:e,description:t,children:n}){return(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:e}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--muted-foreground)]`,children:t})]}),n]})}function RC({title:e,detail:t,badge:n,checked:r,disabled:i,onChange:a}){return(0,H.jsxs)(`label`,{className:X(`flex items-center gap-3 rounded-lg border border-[var(--border)] px-3 py-2.5`,i&&`opacity-55`),children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:r,disabled:i,onChange:e=>a(e.target.checked),className:`size-4 accent-[var(--primary)]`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium`,children:[e,n&&(0,H.jsx)(MC,{variant:n===`ready`?`success`:n===`offline`?`warning`:`outline`,children:zC(n)})]}),(0,H.jsx)(`span`,{className:`block text-xs text-[var(--muted-foreground)]`,children:t})]})]})}function zC(e){return e===`ready`?`Ready`:e===`offline`?`Offline`:`Incompatible`}function BC(e){return e===`ready`?`Available now`:e===`offline`?`Currently unavailable`:`Update this Runtime before selecting it`}function VC({embedded:e=!1}={}){let t=wS(),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(`refresh`),c=(0,u.useCallback)(async()=>{if(t){s(`refresh`),a(null);try{r(await t.getStatus())}catch(e){a(e.message)}finally{s(null)}}},[t]);(0,u.useEffect)(()=>{c()},[c]);async function l(e){if(t){s(`permission`),a(null);try{await t.openSystemSettings(e),V.message(`After granting access, return to Rynx and click Check again.`)}catch(e){let t=e.message;a(t),V.error(`Could not open System Settings: ${t}`)}finally{s(null)}}}return(0,H.jsxs)(`div`,{id:e?`permissions`:void 0,className:e?`grid scroll-mt-6 gap-5`:`grid max-w-3xl gap-5`,children:[!e&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Computer integration`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Review the macOS permissions for the separate Computer Use integration. Browser and Emulator automation stay in the bundled rynx-cli Skill.`})]}),(0,H.jsxs)(fC,{"aria-busy":o!==null,children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`macOS permissions`}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`This page checks readiness only. Permissions remain under your control in System Settings.`})]}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o!==null,onClick:()=>void c(),children:[(0,H.jsx)(zr,{className:o===`refresh`?`animate-spin`:``}),`Check`]})]}),(0,H.jsxs)(hC,{className:`grid gap-3`,children:[n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(HC,{icon:(0,H.jsx)(Vr,{className:`size-4`}),ready:n.permissions.accessibility===`granted`,title:`Accessibility`,description:UC(n.permissions.accessibility,`Granted and ready for a Computer Use provider.`),action:n.permissions.accessibility===`granted`?void 0:(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o!==null,onClick:()=>void l(`accessibility`),children:[(0,H.jsx)(er,{}),`Open Settings`]})}),(0,H.jsx)(HC,{icon:(0,H.jsx)(Sr,{className:`size-4`}),ready:n.permissions.screenRecording===`granted`,title:`Screen Recording`,description:UC(n.permissions.screenRecording,`Granted and ready for a Computer Use provider.`),action:n.permissions.screenRecording===`granted`?void 0:(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o!==null,onClick:()=>void l(`screen-recording`),children:[(0,H.jsx)(er,{}),`Open Settings`]})})]}):(0,H.jsxs)(`div`,{className:`flex min-h-40 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[o===`refresh`&&(0,H.jsx)(B,{className:`size-4 animate-spin`}),o===`refresh`?`Checking integrations…`:`Integration status is unavailable.`]}),i&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_35%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_7%,var(--background))] p-3 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(zn,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]})]})]})]})}function HC({icon:e,ready:t,title:n,description:r,action:i}){return(0,H.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-[var(--border)] p-4 sm:grid-cols-[auto_minmax(0,1fr)_auto] sm:items-center`,children:[(0,H.jsx)(`span`,{className:t?`grid size-9 place-items-center rounded-lg bg-[var(--success)]/12 text-[var(--success)]`:`grid size-9 place-items-center rounded-lg bg-[var(--warning)]/12 text-[var(--warning)]`,children:t?(0,H.jsx)(Pn,{className:`size-4`}):e}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium`,children:n}),(0,H.jsx)(MC,{variant:t?`success`:`warning`,children:t?`Ready`:`Needs access`})]}),(0,H.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-[var(--muted-foreground)]`,children:r})]}),i&&(0,H.jsx)(`div`,{className:`sm:justify-self-end`,children:i})]})}function UC(e,t){switch(e){case`granted`:return t;case`not-granted`:return`Not granted. Open System Settings to allow access.`;case`unknown`:return`Rynx could not determine this permission. Open System Settings to verify it.`}}function WC(){return(0,H.jsxs)(`div`,{className:`grid max-w-3xl gap-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Computer Use`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Configure macOS permissions and Chrome DevTools access for computer automation.`})]}),(0,H.jsx)(VC,{embedded:!0}),(0,H.jsx)(FC,{embedded:!0})]})}var GC=700,KC=250,qC=33333,JC=new Uint8Array([0,0,0,1]);function YC(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function XC(e,t){for(let n=t;n<=e.length-3;n+=1)if(e[n]===0&&e[n+1]===0){if(e[n+2]===1)return{index:n,length:3};if(n<=e.length-4&&e[n+2]===0&&e[n+3]===1)return{index:n,length:4}}return null}function ZC(e,t){let n=YC(e,t),r=XC(n,0);if(!r)return{nals:[],pending:n.slice(Math.max(0,n.length-4))};let i=[],a=r.index,o=r.index+r.length,s=XC(n,o);for(;s;)s.index>o&&i.push(n.slice(o,s.index)),a=s.index,o=s.index+s.length,s=XC(n,o);return{nals:i,pending:n.slice(a)}}function QC(e){return e[0]&31}function $C(e){if(QC(e)!==7||e.length<4)return null;let t=e=>e.toString(16).padStart(2,`0`).toUpperCase();return`avc1.${t(e[1])}${t(e[2])}${t(e[3])}`}function ew(e){let t=e.reduce((e,t)=>e+JC.length+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(JC,r),r+=JC.length,n.set(t,r),r+=t.length;return n}function tw(e){let t=QC(e);return t===1||t===5}function nw(e){return e.some(e=>QC(e)===5)}function rw(e,t,n,r){(e.width!==n||e.height!==r)&&(e.width=n,e.height=r);let i=e.getContext(`2d`);i&&i.drawImage(t,0,0,n,r)}function iw(e,t){return new Promise((n,r)=>{if(t.aborted){r(t.reason);return}let i=window.setTimeout(n,e);t.addEventListener(`abort`,()=>{window.clearTimeout(i),r(t.reason)},{once:!0})})}function aw(e){return e instanceof Error?e.message:String(e)}function ow(e){return e instanceof DOMException&&e.name===`AbortError`}function sw({device:e,alt:t,mediaRef:n,onFrameSize:r}){let i=(0,u.useRef)(null),a=(0,u.useRef)(!1),o=(0,u.useRef)(!1),s=(0,u.useRef)(null),[c,l]=(0,u.useState)(`video`),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(`Loading preview...`),h=(0,u.useCallback)(e=>{i.current=e,n?.(e)},[n]),g=(0,u.useCallback)(()=>{a.current||(a.current=!0,f(!0),m(``))},[]),_=(0,u.useCallback)((e,t)=>{let n=s.current;(n?.width!==e||n.height!==t)&&(s.current={width:e,height:t},r?.(e,t))},[r]);return(0,u.useEffect)(()=>{a.current=!1,o.current=!1,s.current=null,f(!1),m(`Loading preview...`),l(`video`)},[e]),(0,u.useEffect)(()=>{if(c!==`video`||a.current)return;let t=!1;return(async()=>{try{let n=await Y.emulatorFrameBlob(e);if(t||a.current)return;let r=await createImageBitmap(n);try{let e=i.current;e&&!a.current&&(rw(e,r,r.width,r.height),_(r.width,r.height),g())}finally{r.close()}}catch{}})(),()=>{t=!0}},[e,g,c,_]),(0,u.useEffect)(()=>{if(c!==`video`)return;if(!(`VideoDecoder`in window)||!(`EncodedVideoChunk`in window)){m(`Video decoder unavailable`),l(`fallback`);return}let t=new AbortController,n=e=>{let t=i.current;try{if(t){let n=e.displayWidth||e.codedWidth,r=e.displayHeight||e.codedHeight;rw(t,e,n,r),_(n,r),o.current=!0,g()}}finally{e.close()}};return(async()=>{for(;!t.signal.aborted;){let r=null,i=null,a=new Uint8Array,s=[],c=!1,u=0,d=`avc1.42E01F`,f=async()=>{if(r)return r;let e={codec:d,optimizeForLatency:!0,avc:{format:`annexb`}};if(!(await VideoDecoder.isConfigSupported(e)).supported)throw Error(`Unsupported Android video codec: ${d}`);return r=new VideoDecoder({output:n,error:e=>{m(e.message)}}),r.configure(e),r},p=async()=>{if(!c){s=[];return}let e=await f(),t=nw(s),n=ew(s),r=u;u+=qC,s=[],c=!1,!(e.decodeQueueSize>2&&!t)&&e.decode(new EncodedVideoChunk({type:t?`key`:`delta`,timestamp:r,duration:qC,data:n}))},h=async e=>{let t=$C(e);t&&(d=t),(QC(e)===9||tw(e))&&c&&await p(),s.push(e),tw(e)&&(c=!0)};try{let n=await fetch(Y.emulatorVideoStreamUrl(e),{cache:`no-store`,signal:t.signal});if(!n.ok||!n.body)throw Error(`Android video stream failed: ${n.status}`);for(i=n.body.getReader();;){let{done:e,value:t}=await i.read();if(e)break;let n=ZC(a,t);a=n.pending;for(let e of n.nals)await h(e)}let o=ZC(a,JC);for(let e of o.nals)await h(e);await p(),r?.state===`configured`&&await r.flush()}catch(e){if(t.signal.aborted||ow(e))break;if(m(aw(e)),!o.current){l(`fallback`);break}}finally{try{i?.releaseLock()}catch{}r?.state!==`closed`&&r?.close()}t.signal.aborted||await iw(KC,t.signal).catch(()=>{})}})(),()=>{t.abort()}},[e,g,c,_]),(0,u.useEffect)(()=>{if(c!==`fallback`)return;let t=!1,n,r=async()=>{try{let n=await Y.emulatorFrameBlob(e);if(t)return;let r=await createImageBitmap(n);try{let e=i.current;e&&(rw(e,r,r.width,r.height),_(r.width,r.height),g())}finally{r.close()}}catch(e){t||m(aw(e))}finally{t||(n=window.setTimeout(r,GC))}};return r(),()=>{t=!0,n&&window.clearTimeout(n)}},[e,g,c,_]),(0,H.jsxs)(`div`,{className:`relative h-full w-full`,children:[(0,H.jsx)(`canvas`,{ref:h,"aria-label":t,width:720,height:1520,className:`pointer-events-none h-full w-full select-none object-contain`}),!d&&(0,H.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center px-5 text-center text-sm text-zinc-400`,children:p})]})}var cw=8,lw=.012,uw=1500,dw=35,fw=260,pw=40,mw=3,hw=5e3,gw=750;function _w(e){return[e.backend,e.isDefault?`default`:void 0,e.detail].filter(Boolean).join(` · `)}function vw(e,t,n){return Math.max(t,Math.min(n,e))}function yw(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function bw(e){let t=e.getBoundingClientRect();if(t.width<=0||t.height<=0)return null;let n=`naturalWidth`in e?e.naturalWidth||t.width:e.width||t.width,r=`naturalHeight`in e?e.naturalHeight||t.height:e.height||t.height;if(n<=0||r<=0)return t;let i=n/r;if(t.width/t.height>i){let e=t.height*i;return new DOMRect(t.left+(t.width-e)/2,t.top,e,t.height)}let a=t.width/i;return new DOMRect(t.left,t.top+(t.height-a)/2,t.width,a)}function xw(e,t,n){if(!e)return null;let r=bw(e);if(!r)return null;let i=(t.clientX-r.left)/r.width,a=(t.clientY-r.top)/r.height;return!n&&(i<0||i>1||a<0||a>1)?null:{x:vw(i,0,1),y:vw(a,0,1)}}function Sw(e){return new Promise(t=>setTimeout(t,e))}function Cw(e){let t=new TextEncoder().encode(JSON.stringify(e)),n=new Uint8Array(1+t.length);return n[0]=mw,n.set(t,1),n.buffer}function ww(){let[e,t]=(0,u.useState)([]),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(!0),[o,s]=(0,u.useState)(null),[c,l]=(0,u.useState)(null),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(null),[h,g]=(0,u.useState)(null),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(0),x=(0,u.useRef)(null),S=(0,u.useRef)(null),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)(null),E=(0,u.useRef)(null),D=(0,u.useCallback)(async()=>{a(!0);try{let[e,n]=await Promise.all([Y.emulatorDevices(),Y.activeEmulator()]);t(e),r(n)}catch(e){V.error(`Failed to load emulator: ${e.message}`)}finally{a(!1)}},[]);(0,u.useEffect)(()=>{D()},[D]),(0,u.useEffect)(()=>()=>{C.current!==null&&window.clearTimeout(C.current),S.current!==null&&window.clearTimeout(S.current)},[]),(0,u.useEffect)(()=>()=>{let e=w.current?.socket;w.current=null,e&&e.readyState!==WebSocket.CLOSED&&e.close()},[n?.wsUrl]),(0,u.useEffect)(()=>{if(n?.backend!==`android`){let e=T.current?.socket;T.current=null,e&&e.readyState!==WebSocket.CLOSED&&e.close();return}return R(n.deviceUdid).catch(()=>{}),()=>{let e=T.current?.socket;T.current=null,e&&e.readyState!==WebSocket.CLOSED&&e.close()}},[n?.backend,n?.deviceUdid]);let O=n?.streamUrl??null,k=O&&y>0?`${O}${O.includes(`?`)?`&`:`?`}rynx_preview_retry=${y}`:O,A=n?.backend===`android`&&!n.streamUrl,j=!!(O||A),M=h===null?void 0:{aspectRatio:h,width:`min(100%, calc(100cqh * ${h}))`},N=(0,u.useCallback)((e,t)=>{if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0)return;let n=e/t;g(e=>e!==null&&Math.abs(e-n)<1e-4?e:n)},[]),P=(0,u.useCallback)(()=>{S.current!==null&&(window.clearTimeout(S.current),S.current=null)},[]),F=(0,u.useCallback)((e,t)=>{P(),N(e,t),v(!0)},[P,N]),I=(0,u.useCallback)(()=>{v(!1),S.current===null&&(S.current=window.setTimeout(()=>{S.current=null,b(e=>e+1)},gw))},[]);(0,u.useEffect)(()=>{if(P(),g(null),v(!1),b(0),!O)return;let e=()=>{let e=x.current;e instanceof HTMLImageElement&&e.naturalWidth>0&&e.naturalHeight>0&&F(e.naturalWidth,e.naturalHeight)};e();let t=window.setInterval(e,500);return()=>window.clearInterval(t)},[P,n?.attachedAt,n?.deviceUdid,F,O]),(0,u.useEffect)(()=>{if(!O||_)return;let e=window.setTimeout(I,hw);return()=>window.clearTimeout(e)},[y,_,O,I]);async function L(e){if(n){m(`home`);try{await Y.buttonEmulator(e,n.deviceUdid)}catch(t){V.error(`${e===`appswitch`?`App switcher`:`Home`} failed: ${t.message}`)}finally{m(null)}}}function ee(){if(!(!n||p)){if(C.current!==null){window.clearTimeout(C.current),C.current=null,L(`appswitch`);return}C.current=window.setTimeout(()=>{C.current=null,L(`home`)},fw)}}async function te(e,t){let i=n?.deviceUdid===e;C.current!==null&&(window.clearTimeout(C.current),C.current=null),l(e),i&&m(`shutdown`);try{await Y.shutdownEmulator(e),i&&r(null),V.success(`Shutdown ${t}`),D()}catch(e){V.error(`Shutdown failed: ${e.message}`)}finally{l(null),i&&m(null)}}async function ne(e){s(e.id);try{let t=await Y.attachEmulator(e.id);r(t),V.success(`Attached ${t.deviceName??t.deviceUdid}`),D()}catch(e){V.error(`Attach failed: ${e.message}`)}finally{s(null)}}function re(e){let t=w.current;if(t?.url===e){if(t.socket?.readyState===WebSocket.OPEN)return Promise.resolve(t.socket);if(t.connecting)return t.connecting}else t?.socket&&t.socket.readyState!==WebSocket.CLOSED&&t.socket.close();let n={url:e,socket:null,connecting:null},r=new Promise((t,r)=>{let i=new WebSocket(e),a=window.setTimeout(()=>{i.close(),r(Error(`Timed out connecting to emulator gesture stream.`))},1500),o=()=>window.clearTimeout(a);i.binaryType=`arraybuffer`,i.addEventListener(`open`,()=>{o(),n.socket=i,n.connecting=null,t(i)},{once:!0}),i.addEventListener(`error`,()=>{o(),n.connecting=null,r(Error(`Failed to connect to emulator gesture stream.`))},{once:!0}),i.addEventListener(`close`,()=>{w.current?.socket===i&&(w.current=null)})});return n.connecting=r,w.current=n,r}function R(e){let t=T.current;if(t?.device===e){if(t.socket?.readyState===WebSocket.OPEN)return Promise.resolve(t.socket);if(t.connecting)return t.connecting}else t?.socket&&t.socket.readyState!==WebSocket.CLOSED&&t.socket.close();let n={device:e,socket:null,connecting:null},r=new Promise((t,r)=>{let i=new WebSocket(Jx(e)),a=!1,o=window.setTimeout(()=>{a||(a=!0,i.close(),r(Error(`Timed out connecting to Android touch stream.`)))},uw),s=()=>window.clearTimeout(o);i.addEventListener(`message`,e=>{if(!a&&typeof e.data==`string`)try{let o=JSON.parse(e.data);o.t===`opened`?(a=!0,s(),n.socket=i,n.connecting=null,t(i)):o.t===`error`&&(a=!0,s(),n.connecting=null,r(Error(o.message??`Android touch stream failed.`)))}catch{}}),i.addEventListener(`error`,()=>{a||(a=!0,s(),n.connecting=null,r(Error(`Failed to connect to Android touch stream.`)))},{once:!0}),i.addEventListener(`close`,()=>{s(),n.connecting=null,a||(a=!0,r(Error(`Android touch stream closed before it was ready.`))),T.current?.socket===i&&(T.current=null)})});return n.connecting=r,T.current=n,r}async function ie(e,t){if(e.backend===`android`){if(e.liveFailed)return!1;try{return(await R(e.device)).send(JSON.stringify(t)),e.sentLiveFrames+=1,!0}catch(t){return e.liveFailed=!0,e.sentLiveFrames>0&&V.error(`Android touch stream failed: ${t.message}`),!1}}if(!e.wsUrl||e.liveFailed)return!1;try{return(await re(e.wsUrl)).send(Cw(t)),e.sentLiveFrames+=1,!0}catch(t){return e.liveFailed=!0,e.sentLiveFrames>0&&V.error(`Gesture stream failed: ${t.message}`),!1}}function ae(e,t){Y.gestureEmulator([{type:`begin`,x:e.x,y:e.y}],t).catch(e=>{V.error(`Tap failed: ${e.message}`)})}function oe(e,t){Y.gestureEmulator(e,t).catch(e=>{V.error(`Gesture failed: ${e.message}`)})}function se(e){if(!n||!j||!e.isPrimary||e.pointerType===`mouse`&&e.button!==0)return;let t=xw(x.current,e,!1);t&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),E.current={backend:n.backend,pointerId:e.pointerId,device:n.deviceUdid,wsUrl:n.backend===`ios`?n.wsUrl:void 0,startClientX:e.clientX,startClientY:e.clientY,lastPoint:t,moved:!1,liveFailed:!1,sentLiveFrames:0,points:[{type:`begin`,x:t.x,y:t.y}]},ie(E.current,{type:`begin`,x:t.x,y:t.y}),f(!0))}function ce(e){let t=E.current;if(!t||t.pointerId!==e.pointerId)return;let n=xw(x.current,e,!0);if(!n)return;e.preventDefault();let r=Math.hypot(e.clientX-t.startClientX,e.clientY-t.startClientY)>cw,i=yw(n,t.lastPoint)>lw;if(t.lastPoint=n,r&&(i||!t.moved)){t.moved=!0;let e={type:`move`,x:n.x,y:n.y};t.points.push(e),ie(t,e)}}async function le(e){let t=E.current;if(!t||t.pointerId!==e.pointerId)return;e.preventDefault();let n=xw(x.current,e,!0)??t.lastPoint,r=Math.hypot(e.clientX-t.startClientX,e.clientY-t.startClientY)>cw;E.current=null,f(!1);try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let i={type:`end`,x:n.x,y:n.y};if((t.backend===`android`||t.wsUrl)&&!t.liveFailed&&(!t.moved&&!r&&await Sw(t.backend===`android`?dw:pw),await ie(t,i)||t.sentLiveFrames>0))return;if(!t.moved&&!r){ae(n,t.device);return}let a=[...t.points],o=a[a.length-1];o&&yw(o,n)<=.001?a[a.length-1]=i:a.push(i),oe(a,t.device)}function ue(e){let t=E.current;!t||t.pointerId!==e.pointerId||(E.current=null,f(!1),(t.backend===`android`||t.wsUrl)&&!t.liveFailed&&ie(t,{type:`end`,x:t.lastPoint.x,y:t.lastPoint.y}))}return(0,H.jsxs)(`div`,{className:`grid h-full min-h-0 gap-3 p-3 sm:p-4 lg:grid-cols-[minmax(0,360px)_minmax(360px,1fr)]`,children:[(0,H.jsxs)(fC,{className:`flex h-full min-h-0 flex-col overflow-hidden p-0`,children:[(0,H.jsxs)(pC,{className:`px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(mC,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Cr,{className:`size-4`}),`Preview`]}),(0,H.jsx)(`div`,{className:`label-caps mt-1 truncate text-[10px] text-[var(--muted-foreground)]`,children:n?`This device · ${n.backend} · ${n.deviceName??n.deviceUdid}`:`This device · not attached`})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,H.jsx)(J,{variant:`outline`,size:`icon`,className:`size-8`,onClick:ee,disabled:!n||p!==null,"aria-label":`Home or app switcher`,title:`Home · double-click for app switcher`,children:(0,H.jsx)(dr,{className:X(p===`home`&&`animate-pulse`)})}),(0,H.jsx)(J,{variant:`outline`,size:`icon`,className:`size-8`,onClick:()=>{n&&te(n.deviceUdid,n.deviceName??n.deviceUdid)},disabled:!n||p!==null||c!==null,"aria-label":`Shutdown emulator`,title:`Shutdown`,children:(0,H.jsx)(Lr,{className:X(p===`shutdown`&&`animate-pulse`)})}),(0,H.jsx)(J,{variant:`outline`,size:`icon`,className:`size-8`,onClick:()=>void D(),disabled:i,"aria-label":`Refresh emulator`,title:`Refresh`,children:(0,H.jsx)(zr,{className:X(i&&`animate-spin`)})})]})]}),(0,H.jsxs)(hC,{className:`relative grid min-h-0 flex-1 place-items-center p-2 sm:p-3`,style:{containerType:`size`},"aria-busy":j&&!_,children:[j?(0,H.jsx)(`div`,{className:X(`relative grid touch-none select-none place-items-center overflow-hidden bg-black`,_?`max-h-full max-w-full rounded-md border border-[var(--border)] shadow-sm`:`pointer-events-none absolute inset-0`,_&&(d?`cursor-grabbing`:`cursor-crosshair`)),style:_?M:void 0,onPointerDown:se,onPointerMove:ce,onPointerUp:le,onPointerCancel:ue,children:O?(0,H.jsx)(`img`,{ref:e=>{x.current=e},src:k??void 0,alt:n?.deviceName??n?.deviceUdid,className:`pointer-events-none absolute inset-0 h-full w-full select-none object-contain`,onLoad:e=>{F(e.currentTarget.naturalWidth,e.currentTarget.naturalHeight)},onError:I,draggable:!1},`${n?.deviceUdid}:${n?.attachedAt}:${y}`):n&&A?(0,H.jsx)(sw,{device:n.deviceUdid,alt:n.deviceName??n.deviceUdid,mediaRef:e=>{x.current=e},onFrameSize:F},n.deviceUdid):null}):(0,H.jsx)(`div`,{className:`grid h-full w-full place-items-center px-6 text-center text-sm text-[var(--muted-foreground)]`,children:n?`${n.backend} preview unavailable`:`No active emulator`}),j&&!_&&(0,H.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 grid place-items-center bg-[var(--background)] text-[var(--muted-foreground)]`,role:`status`,"aria-live":`polite`,children:(0,H.jsxs)(`div`,{className:`grid place-items-center gap-2 text-xs`,children:[(0,H.jsx)(zr,{className:`size-4 animate-spin text-[var(--primary)]`}),(0,H.jsx)(`span`,{children:`Loading preview…`})]})})]})]}),(0,H.jsxs)(fC,{className:`flex h-full min-h-0 flex-col overflow-hidden p-0`,children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(mC,{className:`flex items-center gap-2`,children:[(0,H.jsx)($r,{className:`size-4`}),`Devices`]}),(0,H.jsx)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:e.length})]}),(0,H.jsx)(hC,{className:`min-h-0 flex-1 p-0`,children:e.length===0?(0,H.jsx)(`div`,{className:`px-5 py-8 text-sm text-[var(--muted-foreground)]`,children:i?`Loading...`:`No devices`}):(0,H.jsx)(U_,{className:`h-full min-h-0`,children:(0,H.jsx)(`ul`,{className:`grid grid-cols-1 content-start gap-2 p-3 sm:grid-cols-2 2xl:grid-cols-3`,children:e.map(e=>{let t=n?.deviceUdid===e.id,r=o===e.id,i=c===e.id;return(0,H.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-[var(--border)] bg-[var(--background)] px-3 py-2.5`,children:[(0,H.jsx)($r,{className:`size-4 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,H.jsxs)(MC,{variant:e.state===`booted`?`success`:e.state===`shutdown`?`outline`:`warning`,className:`h-5 shrink-0 gap-1 px-2 py-0 font-mono text-[9px] uppercase`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`,"aria-hidden":`true`}),e.state]})]}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[10px] uppercase text-[var(--muted-foreground)]`,title:_w(e),children:_w(e)})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsx)(J,{size:`xs`,variant:t?`outline`:`default`,onClick:()=>void ne(e),disabled:r||c!==null,children:r?`Attaching…`:t?`Reattach`:`Attach`}),e.state===`booted`&&(0,H.jsx)(J,{size:`icon-xs`,variant:`destructive`,onClick:()=>void te(e.id,e.name),disabled:o!==null||c!==null,"aria-label":`Shutdown ${e.name}`,title:`Shutdown ${e.name}`,children:(0,H.jsx)(Lr,{className:X(i&&`animate-pulse`)})})]})]},`${e.backend}:${e.id}`)})})})})]})]})}function Tw({embedded:e=!1}={}){let t=wS(),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(!1),c=(0,u.useCallback)(async()=>{if(t){s(!0),a(null);try{r(await t.getStatus())}catch(e){a(e.message)}finally{s(!1)}}},[t]);(0,u.useEffect)(()=>{c()},[c]);async function l(e){if(!(!t||e===n?.runtime.lifecycleMode)){s(!0),a(null);try{r(await t.setDaemonLifecycleMode(e)),V.success(e===`resident`?`Runtime will stay available after Rynx quits`:`Runtime will now follow the Rynx app lifecycle`)}catch(e){let t=e.message;a(t),V.error(`Could not change Runtime mode: ${t}`)}finally{s(!1)}}}async function d(){if(t){s(!0),a(null);try{r(await t.restartDaemon()),V.success(`Local Runtime restarted`)}catch(e){let t=e.message;a(t),V.error(`Could not restart Runtime: ${t}`)}finally{s(!1)}}}return(0,H.jsxs)(`div`,{id:e?`runtime`:void 0,className:e?`grid scroll-mt-6 gap-5`:`grid max-w-3xl gap-5`,children:[!e&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Daemon`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Choose whether the local Runtime follows the Desktop app or stays available in the background.`})]}),(0,H.jsxs)(fC,{"aria-busy":o,children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`Runtime lifecycle`}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`This setting applies to the Runtime bundled with Rynx.`})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o,onClick:()=>void c(),children:[(0,H.jsx)(zr,{className:o?`animate-spin`:``}),`Check`]}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o,onClick:()=>void d(),children:[(0,H.jsx)(zr,{}),`Restart`]})]})]}),(0,H.jsxs)(hC,{className:`grid gap-5`,children:[n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-[var(--border)] p-4`,children:[(0,H.jsx)(`span`,{className:n.runtime.ready?`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--success)]/12 text-[var(--success)]`:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--warning)]/12 text-[var(--warning)]`,children:(0,H.jsx)(Wr,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:`Runtime status`}),(0,H.jsx)(MC,{variant:n.runtime.ready?`success`:`warning`,children:Ew(n.runtime.state)}),(0,H.jsx)(MC,{variant:`outline`,children:n.runtime.managedBy===`app`?`Managed by app`:n.runtime.managedBy===`external`?`External`:`Not managed`})]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:n.runtime.detail??Dw(n)})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-2`,children:[(0,H.jsx)(GS,{htmlFor:`daemon-lifecycle-mode`,children:`Lifecycle`}),(0,H.jsxs)(Ig,{id:`daemon-lifecycle-mode`,value:n.runtime.lifecycleMode,disabled:o,className:`max-w-sm`,onChange:e=>void l(e.target.value),children:[(0,H.jsx)(`option`,{value:`follow-app`,children:`Follow Rynx app`}),(0,H.jsx)(`option`,{value:`resident`,children:`Stay available in background`})]}),(0,H.jsx)(`p`,{className:`max-w-2xl text-xs leading-5 text-[var(--muted-foreground)]`,children:n.runtime.lifecycleMode===`follow-app`?`The Runtime and its embedded Browser Host start with Rynx and stop when the app fully quits. Closing a window does not quit the app.`:`The Runtime and its embedded Browser Host keep running when the app quits, so Terminals, agents, and Session browsers remain available.`})]})]}):(0,H.jsxs)(`div`,{className:`flex min-h-32 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[o&&(0,H.jsx)(B,{className:`size-4 animate-spin`}),o?`Checking Runtime…`:`Runtime status is unavailable.`]}),i&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_35%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_7%,var(--background))] p-3 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(zn,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]})]})]})]})}function Ew(e){switch(e){case`starting`:return`Starting`;case`running`:return`Running`;case`stopped`:return`Stopped`;case`busy`:return`Busy`;case`error`:return`Error`}}function Dw(e){let t=[e.runtime.version?`Version ${e.runtime.version}`:null,e.runtime.pid?`PID ${e.runtime.pid}`:null].filter(Boolean);return t.length>0?t.join(` · `):`No additional Runtime details.`}function Ow({embedded:e=!1}={}){let t=wS(),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(`refresh`),c=(0,u.useCallback)(async(e=!1)=>{if(t){s(`refresh`),a(null);try{r(await t.getStatus(e))}catch(e){a(e.message)}finally{s(null)}}},[t]);(0,u.useEffect)(()=>{c()},[c]);async function l(e){if(t){s(`install`),a(null);try{r(await t.installCli(e)),V.success(`Terminal command installed`)}catch(e){let n=e.message;a(n),V.error(`Could not install the Terminal command: ${n}`);try{r(await t.getStatus(!0))}catch{}}finally{s(null)}}}async function d(e){if(t){s(`remove`),a(null);try{r(await t.removeCli(e)),V.success(`Terminal command removed`)}catch(e){let n=e.message;a(n),V.error(`Could not remove the Terminal command: ${n}`);try{r(await t.getStatus(!0))}catch{}}finally{s(null)}}}let f=n?.globalCli,p=f?.state===`installed`,m=f?.state===`development`,h=f?.state===`installed`&&f.canInstall&&!!(f.path&&f.target&&f.path!==f.target);return(0,H.jsxs)(`div`,{id:e?`terminal-command`:void 0,className:e?`grid scroll-mt-6 gap-5`:`grid max-w-3xl gap-5`,children:[!e&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Terminal command`}),(0,H.jsxs)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:[`Install or remove the `,(0,H.jsx)(`code`,{className:`font-mono`,children:`rynx`}),` command used in Terminal.`]})]}),(0,H.jsxs)(fC,{"aria-busy":o!==null,children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`Shell access`}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Removing the command does not uninstall Rynx or delete its data.`})]}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o!==null,onClick:()=>void c(!0),children:[(0,H.jsx)(zr,{className:o===`refresh`?`animate-spin`:``}),`Check`]})]}),(0,H.jsxs)(hC,{className:`grid gap-3`,children:[f?(0,H.jsxs)(`div`,{className:`grid gap-4 rounded-lg border border-[var(--border)] p-4 sm:grid-cols-[auto_minmax(0,1fr)_auto] sm:items-center`,children:[(0,H.jsx)(`span`,{className:p?`grid size-10 place-items-center rounded-lg bg-[var(--success)]/12 text-[var(--success)]`:m?`grid size-10 place-items-center rounded-lg bg-[var(--muted)] text-[var(--muted-foreground)]`:`grid size-10 place-items-center rounded-lg bg-[var(--warning)]/12 text-[var(--warning)]`,children:p?(0,H.jsx)(Pn,{className:`size-5`}):(0,H.jsx)(qn,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`font-mono text-sm font-medium`,children:`rynx`}),(0,H.jsx)(MC,{variant:p?`success`:m?`outline`:`warning`,children:kw(f.state)})]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:Aw(f)}),f.path&&(0,H.jsx)(`code`,{className:`mt-1 block break-all font-mono text-[11px] text-[var(--muted-foreground)]`,children:f.path}),h&&f.target&&(0,H.jsxs)(`p`,{className:`mt-1 break-all text-[11px] text-[var(--muted-foreground)]`,children:[`Recommended: `,(0,H.jsx)(`code`,{className:`font-mono`,children:f.target})]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2 sm:justify-self-end`,children:[f.canInstall&&(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o!==null,onClick:()=>f.path&&void l(f.path),children:[o===`install`&&(0,H.jsx)(B,{className:`animate-spin`}),h?`Move command`:f.state===`stale`?`Repair command`:`Install command`]}),f.canRemove&&(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:o!==null,children:[(0,H.jsx)(si,{}),`Remove command`]})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsx)(vu,{children:`Remove the Terminal command?`}),(0,H.jsx)(yu,{children:`This removes only the shell command link that points to this Rynx app. The app, Runtime, settings, and workspace data remain installed.`})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>f.path&&void d(f.path),children:`Remove command`})]})]})]})]})]}):(0,H.jsxs)(`div`,{className:`flex min-h-32 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[o===`refresh`&&(0,H.jsx)(B,{className:`size-4 animate-spin`}),o===`refresh`?`Checking command…`:`Command status is unavailable.`]}),i&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_35%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_7%,var(--background))] p-3 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(zn,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]})]})]})]})}function kw(e){switch(e){case`installed`:return`Installed`;case`missing`:return`Not installed`;case`stale`:return`Needs repair`;case`foreign`:return`Managed externally`;case`development`:return`Development build`;case`unwritable`:case`error`:return`Unavailable`}}function Aw(e){switch(e.state){case`installed`:return e.canInstall?`The command is ready. You can move it to the recommended location.`:`The command is ready to use from Terminal.`;case`missing`:return`Install the command to use Rynx from Terminal.`;case`stale`:return`Update the command registration to use this Rynx app.`;case`foreign`:return`Another program owns the active command. Rynx will not replace or remove it.`;case`development`:return`Global Terminal command registration is disabled in development builds. Install a packaged Rynx app to manage the rynx command.`;case`unwritable`:return`Rynx could not find a supported location for the command.`;case`error`:return`Rynx could not check the command.`}}function jw(){return(0,H.jsxs)(`div`,{className:`grid max-w-3xl gap-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Local Runtime`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Manage the Runtime bundled with Rynx and its Terminal command.`})]}),(0,H.jsx)(Tw,{embedded:!0}),(0,H.jsx)(Ow,{embedded:!0})]})}function Mw(){let{status:e,operation:t,error:n,checkForUpdates:r,installUpdate:i}=kS(),a=t!==null||e?.phase===`checking`||e?.phase===`downloading`||e?.phase===`installing`,o=n??e?.error;async function s(){let e=await r();e&&(e.error?V.error(`Could not check for updates: ${e.error}`):e.phase===`idle`?V.success(`${e.appName} is up to date`):e.availableVersion&&V.message(`Rynx ${e.availableVersion} is available`))}return(0,H.jsxs)(fC,{id:`software-update`,className:`scroll-mt-6`,"aria-busy":a,children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`Software update`}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Review the installed Desktop version and check GitHub Releases for updates.`})]}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:a||!e?.supported,onClick:()=>void s(),children:[(0,H.jsx)(zr,{className:t===`check`||e?.phase===`checking`?`animate-spin`:``}),`Check for updates`]})]}),(0,H.jsxs)(hC,{className:`grid gap-4`,children:[e?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-[var(--border)] p-4`,children:[(0,H.jsx)(`span`,{className:Pw(e),children:(0,H.jsx)(Nw,{status:e})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:e.appName}),(0,H.jsxs)(MC,{variant:`outline`,children:[`Version `,e.currentVersion]}),(0,H.jsx)(MC,{variant:e.channel===`preview`?`warning`:`default`,children:Iw(e.channel)})]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:Fw(e)}),e.lastCheckedAt&&(0,H.jsxs)(`p`,{className:`mt-1 text-[10px] text-[var(--muted-foreground)]`,children:[`Last checked `,Lw(e.lastCheckedAt)]})]}),e.phase===`ready`&&(0,H.jsxs)(J,{size:`sm`,disabled:t===`install`,onClick:()=>void i(),children:[t===`install`?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Bn,{}),`Restart to update`]})]}),!e.supported&&(0,H.jsx)(`div`,{className:`rounded-lg border border-[var(--border)] bg-[var(--muted)]/30 p-3 text-xs leading-5 text-[var(--muted-foreground)]`,children:`Automatic updates are available in signed release builds. Local development builds display their version here but do not contact the release feed.`})]}):(0,H.jsxs)(`div`,{className:`flex min-h-32 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),`Loading version information…`]}),o&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-lg border border-[color-mix(in_srgb,var(--destructive)_35%,var(--border))] bg-[color-mix(in_srgb,var(--destructive)_7%,var(--background))] p-3 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(zn,{className:`mt-0.5 size-4 shrink-0`}),(0,H.jsx)(`span`,{children:o})]})]})]})}function Nw({status:e}){return e.phase===`checking`||e.phase===`installing`?(0,H.jsx)(B,{className:`size-5 animate-spin`}):e.phase===`downloading`?(0,H.jsx)(Yn,{className:`size-5`}):e.phase===`ready`?(0,H.jsx)(Bn,{className:`size-5`}):(0,H.jsx)(Vn,{className:`size-5`})}function Pw(e){return e.phase===`downloading`||e.phase===`ready`||e.phase===`installing`?`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/12 text-[var(--primary)]`:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--success)]/12 text-[var(--success)]`}function Fw(e){if(!e.supported)return`This local build does not check for automatic updates.`;switch(e.phase){case`disabled`:return`Automatic updates are disabled for this build.`;case`idle`:return e.error?`The last update check did not complete.`:e.lastCheckedAt?`This version is up to date.`:`Ready to check for updates.`;case`checking`:return`Checking GitHub Releases for a newer version…`;case`downloading`:return`Rynx ${e.availableVersion??``} is downloading in the background.`;case`ready`:return`Rynx ${e.availableVersion??``} is ready. Restart to finish the update.`;case`installing`:return`Preparing the Runtime and restarting Rynx safely…`}}function Iw(e){switch(e){case`local`:return`Local build`;case`preview`:return`Preview channel`;case`stable`:return`Stable channel`}}function Lw(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function Rw({plugins:e,agents:t,desktopIntegrationAvailable:n}){let r=nt(),i=e=>r(px[e]),a=e.filter(e=>e.enabled).length,o=e.filter(e=>e.runtimeState===`running`).length;return(0,H.jsxs)(`div`,{className:`grid gap-5`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Overview`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Plugins own integrations and their settings; agents define task behavior.`})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,H.jsx)(zw,{icon:Rr,label:`Plugins`,value:e.length,sub:`${a} enabled · ${o} healthy`,onClick:()=>i(`plugins`)}),(0,H.jsx)(zw,{icon:Mn,label:`Agents`,value:t.length,sub:t.length===1?`1 defined`:`${t.length} defined`,onClick:()=>i(`agents`)})]}),(0,H.jsxs)(fC,{children:[(0,H.jsxs)(pC,{children:[(0,H.jsx)(mC,{children:`Plugins`}),(0,H.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>i(`plugins`),children:`Manage`})]}),(0,H.jsx)(hC,{className:`p-0`,children:e.length===0?(0,H.jsxs)(`div`,{className:`px-5 py-10 text-center text-sm text-[var(--muted-foreground)]`,children:[`No plugins installed. Add one from a Market or a Git repository with the Rynx CLI.`,(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(J,{size:`sm`,onClick:()=>i(`plugins`),children:`View plugins`})})]}):(0,H.jsx)(`ul`,{className:`divide-y divide-[var(--border)]`,children:e.map(e=>(0,H.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-5 py-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.pluginId}),(0,H.jsxs)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:[e.id,` · v`,e.version]})]}),(0,H.jsx)(`span`,{className:`rounded-full border border-[var(--border)] px-2 py-0.5 font-mono text-[10px] text-[var(--muted-foreground)]`,children:e.enabled?e.runtimeState:`disabled`})]},e.id))})})]}),n&&(0,H.jsx)(Mw,{})]})}function zw({icon:e,label:t,value:n,sub:r,onClick:i}){return(0,H.jsx)(fC,{children:(0,H.jsxs)(`button`,{onClick:i,className:`flex w-full items-start gap-4 rounded-xl p-5 text-left transition-colors hover:bg-[var(--muted)]/40`,children:[(0,H.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(e,{className:`size-5`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-3xl font-semibold leading-none tabular-nums`,children:n}),(0,H.jsx)(`div`,{className:`label-caps mt-1.5 text-[11px] text-[var(--muted-foreground)]`,children:t}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:r})]})]})})}function Bw({description:e=`You're about to visit an external website. Review the complete destination before continuing.`,onConfirm:t,onOpenChange:n,open:r,url:i}){let[a,o]=(0,u.useState)(!1);(0,u.useEffect)(()=>{r||o(!1)},[r]);let s=async()=>{try{await navigator.clipboard.writeText(i),o(!0)}catch{}};return(0,H.jsx)(uu,{open:r,onOpenChange:n,children:(0,H.jsxs)(mu,{className:`sm:max-w-xl`,children:[(0,H.jsxs)(hu,{children:[(0,H.jsx)(_u,{children:(0,H.jsx)(er,{})}),(0,H.jsx)(vu,{children:`Open external link?`}),(0,H.jsx)(yu,{children:e})]}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`code`,{className:`block max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-lg border border-[var(--border)] bg-[var(--muted)]/40 py-3 pr-11 pl-3 font-mono text-xs leading-relaxed text-[var(--foreground)]`,children:i}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-2`,"aria-label":a?`Link copied`:`Copy link`,title:a?`Link copied`:`Copy link`,onClick:()=>void s(),children:a?(0,H.jsx)(Pn,{}):(0,H.jsx)(Jn,{})})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{onClick:t,children:`Open link`})]})]})})}function Vw(e){let t=Hw(e)?e.url:void 0;if(typeof t!=`string`||!t.trim())throw Error(`external URL is required`);let n;try{n=new URL(t)}catch{throw Error(`external URL is invalid`)}if(n.protocol!==`https:`)throw Error(`only HTTPS links may be opened`);if(n.username||n.password)throw Error(`external URLs must not contain credentials`);return n.href}function Hw(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Uw=1048576,Ww=16,Gw=3e4,Kw=2e3,qw=/^[A-Za-z][A-Za-z0-9._:-]{0,127}$/;function Jw({plugins:e,theme:t,onChange:n}){let[r,i]=(0,u.useState)(),[a,o]=(0,u.useState)(),[s,c]=(0,u.useState)(`discover`),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(),[m,h]=(0,u.useState)(!0),[g,_]=(0,u.useState)(!1),[v,y]=(0,u.useState)(),[b,x]=(0,u.useState)(),[S,C]=(0,u.useState)(),[w,T]=(0,u.useState)(!1),E=(0,u.useRef)(0),D=(0,u.useRef)(!1),O=(0,u.useRef)(!1),k=e.find(e=>e.id===r),A=(0,u.useCallback)(async()=>{let e=++E.current;h(!0);try{let t=await Y.listPluginMarketplaces();if(e!==E.current)return!0;let r=D.current;return D.current=!1,d(t),p(void 0),r&&n(),!0}catch(t){return e!==E.current||(D.current=!0,p(t.message),!1)}finally{e===E.current&&h(!1)}},[n]);(0,u.useEffect)(()=>{let e=!1,t,n=async()=>{!await A()&&!e&&(t=window.setTimeout(()=>void n(),Kw))};return n(),()=>{e=!0,t!==void 0&&window.clearTimeout(t),E.current+=1}},[A]),(0,u.useEffect)(()=>{r&&!k&&i(void 0)},[k,r]);let j=async e=>{o(e.id);try{await Y.setPluginEnabled(e.id,!e.enabled),await n()}catch(t){V.error(`Failed to ${e.enabled?`disable`:`enable`} plugin: ${t.message}`)}finally{o(void 0)}},M=async e=>{x(e);try{C(await Y.preparePluginInstallation({operation:`install`,marketplacePlugin:e}))}catch(t){V.error(`Could not prepare ${e}: ${t.message}`)}finally{x(void 0)}},N=async e=>{x(e);try{let t=await Y.preparePluginInstallation({operation:`update`,pluginId:e});if(t.unchanged){await Y.cancelPluginInstallation(t.token).catch(()=>!1),V.info(`${e} is already up to date.`);return}C(t)}catch(t){V.error(`Could not prepare update for ${e}: ${t.message}`)}finally{x(void 0)}},P=()=>{let e=S;C(void 0),e&&Y.cancelPluginInstallation(e.token).catch(()=>!1)},F=async()=>{if(!S)return;let e=!!S.existing;T(!0);try{let t=await Y.commitPluginInstallation(S.token,{overwrite:!!S.existing,expectedDigest:S.artifact.digest});C(void 0),V.success(`${e?`Updated`:`Installed`} ${t.plugin.id} v${t.plugin.version}.`+(e?` No Rynx restart required.`:``)),await n(),c(`installed`)}catch(t){C(void 0),V.error(`${e?`Update`:`Installation`} failed: ${t.message}`)}finally{T(!1)}},I=async e=>{if(!O.current){O.current=!0,y(e.id);try{await Y.refreshPluginMarketplace(e.id),await Promise.all([A(),n()]),V.success(`Refreshed ${e.id}`)}catch(e){V.error(`Market refresh failed: ${e.message}`)}finally{O.current=!1,y(void 0)}}},L=async e=>{if(!O.current){O.current=!0,y(e.id);try{await Y.removePluginMarketplace(e.id),await A(),V.success(`Removed ${e.id}`)}catch(e){V.error(`Market removal failed: ${e.message}`)}finally{O.current=!1,y(void 0)}}};return k?.hasSettingsUi?(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,H.jsxs)(J,{variant:`outline`,size:`sm`,className:`shrink-0`,onClick:()=>i(void 0),children:[(0,H.jsx)(An,{}),`Plugins`]}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsxs)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:[k.pluginId,` settings`]}),(0,H.jsx)(aT,{plugin:k})]}),(0,H.jsxs)(`div`,{className:`truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:[`Sandboxed plugin UI · `,k.id,` · v`,k.version]})]})]}),(0,H.jsx)(fC,{className:`overflow-hidden`,children:(0,H.jsx)(hC,{className:`p-0`,children:(0,H.jsx)(oT,{plugin:k,theme:t,onChange:n})})})]}):(0,H.jsxs)(`div`,{className:`grid gap-5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Plugins`}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`Discover plugins from trusted Markets, then review their source and executable entries before installation.`})]}),(0,H.jsxs)(J,{size:`sm`,className:`shrink-0`,onClick:()=>_(!0),children:[(0,H.jsx)(Ir,{}),`Add Market`]})]}),(0,H.jsxs)(lx,{value:s,onValueChange:c,children:[(0,H.jsxs)(ux,{"aria-label":`Plugin management views`,children:[(0,H.jsxs)(dx,{value:`discover`,className:`gap-1.5 leading-none`,children:[`Discover`,(0,H.jsx)(`span`,{className:`text-xs font-normal leading-none tabular-nums`,children:l?.reduce((e,t)=>e+t.plugins.length,0)??0})]}),(0,H.jsxs)(dx,{value:`installed`,className:`gap-1.5 leading-none`,children:[`Installed`,(0,H.jsx)(`span`,{className:`text-xs font-normal leading-none tabular-nums`,children:e.length})]}),(0,H.jsxs)(dx,{value:`markets`,className:`gap-1.5 leading-none`,children:[`Markets`,(0,H.jsx)(`span`,{className:`text-xs font-normal leading-none tabular-nums`,children:l?.length??0})]})]}),(0,H.jsx)(fx,{value:`discover`,children:l===null&&f?(0,H.jsx)(rT,{error:f,retrying:m,onRetry:()=>void A()}):(0,H.jsx)(Yw,{markets:l,installed:e,preparingId:b,onAddMarket:()=>_(!0),onInstall:e=>void M(e)})}),(0,H.jsx)(fx,{value:`installed`,children:(0,H.jsx)(Xw,{plugins:e,mutatingId:a,preparingId:b,onBrowse:()=>c(`discover`),onConfigure:i,onUpdate:e=>void N(e),onChangeEnabled:e=>void j(e)})}),(0,H.jsx)(fx,{value:`markets`,children:l===null&&f?(0,H.jsx)(rT,{error:f,retrying:m,onRetry:()=>void A()}):(0,H.jsx)(Zw,{markets:l,mutatingId:v,onAdd:()=>_(!0),onRefresh:e=>void I(e),onRemove:e=>void L(e)})})]}),(0,H.jsx)(Qw,{open:g,onOpenChange:_,onAdded:async e=>{await A(),c(`discover`),V.success(`Added ${e.id}`)}}),(0,H.jsx)($w,{preparation:S,committing:w,onCancel:P,onCommit:()=>void F()})]})}function Yw({markets:e,installed:t,preparingId:n,onAddMarket:r,onInstall:i}){let[a,o]=(0,u.useState)(``),s=new Set(t.map(e=>e.id)),c=(e??[]).flatMap(e=>e.plugins.map(t=>({id:`${t.id}@${e.id}`,pluginId:t.id,market:e}))),l=a.trim().toLowerCase(),d=l?c.filter(({id:e})=>e.includes(l)):c;return e===null?(0,H.jsx)(nT,{label:`Loading plugin catalogs…`}):e.length===0?(0,H.jsx)(tT,{icon:ii,title:`Add a Market to discover plugins`,description:`A Market is a Git or local catalog. Adding it downloads metadata only and never installs plugin code.`,action:(0,H.jsxs)(J,{size:`sm`,onClick:r,children:[(0,H.jsx)(Ir,{}),` Add Market`]})}):(0,H.jsxs)(fC,{children:[(0,H.jsxs)(pC,{className:`flex-col items-stretch gap-3 sm:flex-row sm:items-center`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`Available plugins`}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Catalog entries stay inert until you review and install one.`})]}),(0,H.jsxs)(`div`,{className:`relative w-full sm:w-64`,children:[(0,H.jsx)(Hr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-[var(--muted-foreground)]`}),(0,H.jsx)(Ag,{"aria-label":`Search available plugins`,className:`pl-8`,value:a,placeholder:`Search plugins or Markets`,onChange:e=>o(e.target.value)})]})]}),(0,H.jsx)(hC,{className:`p-0`,children:d.length===0?(0,H.jsxs)(`div`,{className:`px-5 py-10 text-center text-sm text-[var(--muted-foreground)]`,children:[`No catalog entries match “`,a.trim(),`”.`]}):(0,H.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:d.map(({id:e,pluginId:t,market:r})=>{let a=s.has(e),o=n===e;return(0,H.jsxs)(`article`,{className:`flex flex-col gap-3 px-5 py-4 transition-colors hover:bg-[var(--muted)]/35 sm:flex-row sm:items-center`,children:[(0,H.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(Rr,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`strong`,{className:`text-sm`,children:t}),(0,H.jsx)(MC,{variant:`outline`,className:`font-mono`,children:r.id})]}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:e})]}),(0,H.jsx)(J,{size:`sm`,variant:a?`outline`:`default`,disabled:a||!!n,onClick:()=>i(e),children:a?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Pn,{}),` Installed`]}):o?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(B,{className:`animate-spin`}),` Preparing…`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Yn,{}),` Install`]})})]},e)})})})]})}function Xw({plugins:e,mutatingId:t,preparingId:n,onBrowse:r,onConfigure:i,onUpdate:a,onChangeEnabled:o}){return e.length===0?(0,H.jsx)(tT,{icon:Or,title:`No plugins installed`,description:`Browse your registered Markets and review a plugin before installing it.`,action:(0,H.jsxs)(J,{size:`sm`,onClick:r,children:[(0,H.jsx)(Or,{}),` Browse plugins`]})}):(0,H.jsx)(`div`,{className:`grid gap-3`,children:e.map(e=>(0,H.jsx)(fC,{children:(0,H.jsxs)(hC,{className:`flex flex-col gap-4 sm:flex-row sm:items-center`,children:[(0,H.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(Rr,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`strong`,{className:`text-sm`,children:e.pluginId}),(0,H.jsx)(aT,{plugin:e}),(0,H.jsx)(MC,{variant:`outline`,children:e.marketplaceId})]}),(0,H.jsxs)(`div`,{className:`mt-1 truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:[`v`,e.version]}),e.runtimeError&&(0,H.jsxs)(`div`,{className:`mt-2 flex items-start gap-1.5 text-xs text-[var(--danger)]`,children:[(0,H.jsx)(ci,{className:`mt-0.5 size-3.5 shrink-0`}),e.runtimeError]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[e.hasSettingsUi&&(0,H.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>i(e.id),children:[(0,H.jsx)(Gr,{}),`Configure`]}),e.updateState!==`current`&&(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:!!n||t!==void 0,onClick:()=>a(e.id),children:[(0,H.jsx)(zr,{className:n===e.id?`animate-spin`:``}),n===e.id?`Checking…`:e.updateState===`available`?`Update`:`Check for updates`]}),(0,H.jsx)(Ub,{"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.pluginId}`,checked:e.enabled,disabled:t===e.id,onCheckedChange:()=>o(e)})]})]})},e.id))})}function Zw({markets:e,mutatingId:t,onAdd:n,onRefresh:r,onRemove:i}){return e===null?(0,H.jsx)(nT,{label:`Loading Markets…`}):e.length===0?(0,H.jsx)(tT,{icon:ii,title:`No Markets registered`,description:`Add a trusted Git repository or local catalog to make its plugins discoverable.`,action:(0,H.jsxs)(J,{size:`sm`,onClick:n,children:[(0,H.jsx)(Ir,{}),` Add Market`]})}):(0,H.jsxs)(fC,{children:[(0,H.jsxs)(pC,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`Registered Markets`}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Built-in Markets update with Rynx. User-added Markets can be refreshed independently.`})]}),(0,H.jsxs)(J,{size:`sm`,variant:`outline`,onClick:n,children:[(0,H.jsx)(Ir,{}),` Add Market`]})]}),(0,H.jsx)(hC,{className:`p-0`,children:(0,H.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:e.map(e=>(0,H.jsxs)(`article`,{className:`flex flex-col gap-3 px-5 py-4 sm:flex-row sm:items-center`,children:[(0,H.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(ii,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`strong`,{className:`font-mono text-sm`,children:e.id}),(0,H.jsx)(MC,{variant:`outline`,children:e.builtIn?`Built-in`:e.source}),(0,H.jsxs)(MC,{variant:`default`,children:[e.plugins.length,` plugins`]})]}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:e.builtIn?`Managed by Rynx · updated ${new Date(e.refreshedAt).toLocaleString()}`:`${e.id} · ${iT(e.resolvedRevision)} · refreshed ${new Date(e.refreshedAt).toLocaleString()}`})]}),!e.builtIn&&(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,H.jsxs)(J,{size:`sm`,variant:`outline`,disabled:t!==void 0,onClick:()=>r(e),children:[(0,H.jsx)(zr,{className:t===e.id?`animate-spin`:``}),`Refresh`]}),(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsx)(J,{size:`icon-sm`,variant:`ghost`,disabled:t!==void 0,"aria-label":`Remove ${e.id}`,children:(0,H.jsx)(si,{})})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsx)(vu,{children:`Remove this Market?`}),(0,H.jsxs)(yu,{children:[e.id,` will disappear from Discover. A Market with installed plugins cannot be removed until those plugins are uninstalled.`]})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>i(e),children:`Remove Market`})]})]})]})]})]},e.id))})})]})}function Qw({open:e,onOpenChange:t,onAdded:n}){let[r,i]=(0,u.useState)(``),[a,o]=(0,u.useState)(!1),s=()=>{i(``),t(!1)},c=async()=>{if(r.trim()){o(!0);try{let e=await Y.addPluginMarketplace({source:r.trim()});s(),await n(e)}catch(e){V.error(`Could not add Market: ${e.message}`)}finally{o(!1)}}};return(0,H.jsx)(Su,{open:e,onOpenChange:e=>{a||(e?t(!0):s())},children:(0,H.jsxs)(Du,{className:`sm:max-w-lg`,showCloseButton:!a,children:[(0,H.jsxs)(Ou,{children:[(0,H.jsx)(Au,{children:`Add a Market`}),(0,H.jsxs)(ju,{children:[`Register a Git repository or local directory containing`,` `,(0,H.jsx)(`code`,{children:`.rynx-plugin/marketplace.json`}),`. This reads the catalog only.`]})]}),(0,H.jsx)(`div`,{className:`grid gap-4`,children:(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`market-source`,children:`Source`}),(0,H.jsx)(Ag,{id:`market-source`,autoFocus:!0,value:r,placeholder:`owner/repo or https://github.com/owner/repo`,onChange:e=>i(e.target.value)}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`GitHub shorthand, a credential-free Git URL, or an absolute local path.`})]})}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(J,{variant:`outline`,disabled:a,onClick:s,children:`Cancel`}),(0,H.jsxs)(J,{disabled:a||!r.trim(),onClick:()=>void c(),children:[a?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(ii,{}),a?`Adding…`:`Add Market`]})]})]})})}function $w({preparation:e,committing:t,onCancel:n,onCommit:r}){let i=e?.artifact;return(0,H.jsx)(Su,{open:!!e,onOpenChange:e=>{!e&&!t&&n()},children:(0,H.jsx)(Du,{className:`max-h-[calc(100dvh-2rem)] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 overflow-hidden p-0 sm:max-w-2xl`,children:e&&i&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(Ou,{className:`px-5 pb-4 pr-12 pt-5`,children:[(0,H.jsxs)(Au,{children:[`Review `,e.existing?`plugin update`:`plugin installation`]}),(0,H.jsx)(ju,{children:`Rynx inspected an immutable package snapshot. Confirm its source and executable entries before the active installation changes.`})]}),(0,H.jsx)(U_,{className:`min-h-0`,children:(0,H.jsxs)(`div`,{className:`grid gap-3 px-5 pb-5`,children:[(0,H.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-[var(--border)] bg-[var(--muted)]/25 p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`strong`,{children:i.pluginId}),(0,H.jsx)(MC,{variant:`outline`,children:i.marketplaceId}),(0,H.jsxs)(MC,{variant:`default`,children:[`v`,i.version]})]}),(0,H.jsx)(`div`,{className:`font-mono text-[10px] text-[var(--muted-foreground)]`,children:i.id}),(0,H.jsx)(`div`,{className:`break-all font-mono text-[10px] leading-relaxed text-[var(--muted-foreground)]`,children:i.digest}),(0,H.jsxs)(`dl`,{className:`grid gap-2 border-t border-[var(--border)] pt-3 text-xs`,children:[(0,H.jsx)(eT,{label:`Source`,children:i.resolvedSource.type===`git`?i.resolvedSource.repository:`Local directory (path hidden)`}),(0,H.jsx)(eT,{label:`Subdirectory`,children:i.resolvedSource.subdirectory}),i.resolvedSource.type===`git`&&(0,H.jsx)(eT,{label:`Commit`,children:i.resolvedSource.commit})]}),(i.runtimeEntry||i.settingsBackgroundEntry||i.commandsEntry||i.settingsUiEntry||i.skillDirectory)&&(0,H.jsxs)(`div`,{className:`grid gap-2 border-t border-[var(--border)] pt-3`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium`,children:`Included components`}),(0,H.jsxs)(`dl`,{className:`grid gap-2 text-xs`,children:[i.runtimeEntry&&(0,H.jsx)(eT,{label:i.runtimeEntry.type===`module`?`Runtime module`:`Runtime process`,children:i.runtimeEntry.type===`module`?i.runtimeEntry.entry:[i.runtimeEntry.command,...i.runtimeEntry.args].join(` `)}),i.commandsEntry&&(0,H.jsx)(eT,{label:`Commands`,children:i.commandsEntry}),i.settingsUiEntry&&(0,H.jsx)(eT,{label:`Settings UI`,children:i.settingsUiEntry}),i.settingsBackgroundEntry&&(0,H.jsx)(eT,{label:i.settingsBackgroundEntry.type===`module`?`Settings background`:`Settings process`,children:i.settingsBackgroundEntry.type===`module`?i.settingsBackgroundEntry.entry:[i.settingsBackgroundEntry.command,...i.settingsBackgroundEntry.args].join(` `)}),i.skillDirectory&&(0,H.jsx)(eT,{label:`Skills`,children:i.skillDirectory})]})]})]}),e.existing&&(0,H.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--warning)]/35 bg-[var(--warning)]/10 p-3 text-xs`,children:[(0,H.jsx)(ci,{className:`mt-0.5 size-4 shrink-0 text-[var(--warning)]`}),`This replaces `,e.existing.id,` v`,e.existing.version,`. Its enabled state and plugin-owned data are retained.`]})]})}),(0,H.jsxs)(ku,{className:`mx-0 mb-0 rounded-none rounded-b-xl px-5 py-3`,children:[(0,H.jsx)(J,{variant:`outline`,disabled:t,onClick:n,children:`Cancel`}),(0,H.jsxs)(J,{disabled:t,onClick:r,children:[t?(0,H.jsx)(B,{className:`animate-spin`}):e.existing?(0,H.jsx)(zr,{}):(0,H.jsx)(Yn,{}),t?e.existing?`Updating…`:`Installing…`:e.existing?`Update plugin`:`Install plugin`]})]})]})})})}function eT({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`grid gap-0.5 sm:grid-cols-[7rem_minmax(0,1fr)] sm:gap-3`,children:[(0,H.jsx)(`dt`,{className:`text-[var(--muted-foreground)]`,children:e}),(0,H.jsx)(`dd`,{className:`min-w-0`,children:(0,H.jsx)(`code`,{className:`break-all text-[11px]`,children:t})})]})}function tT({icon:e,title:t,description:n,action:r}){return(0,H.jsx)(fC,{children:(0,H.jsxs)(hC,{className:`grid justify-items-center gap-3 py-12 text-center`,children:[(0,H.jsx)(`span`,{className:`grid size-11 place-items-center rounded-xl bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(e,{className:`size-5`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:t}),(0,H.jsx)(`p`,{className:`mt-1 max-w-md text-xs text-[var(--muted-foreground)]`,children:n})]}),r]})})}function nT({label:e}){return(0,H.jsx)(fC,{children:(0,H.jsxs)(hC,{className:`flex items-center justify-center gap-2 py-12 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),e]})})}function rT({error:e,retrying:t,onRetry:n}){return(0,H.jsx)(fC,{role:`alert`,children:(0,H.jsxs)(hC,{className:`grid justify-items-center gap-3 py-12 text-center`,children:[(0,H.jsx)(`span`,{className:`grid size-11 place-items-center rounded-xl bg-[var(--danger)]/10 text-[var(--danger)]`,children:(0,H.jsx)(ci,{className:`size-5`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:`Rynx Runtime is unavailable`}),(0,H.jsx)(`p`,{className:`mt-1 max-w-md text-xs text-[var(--muted-foreground)]`,children:`Plugin catalogs could not be loaded. Rynx will retry automatically.`}),(0,H.jsx)(`p`,{className:`mt-2 max-w-md break-all font-mono text-[10px] text-[var(--danger)]`,children:e})]}),(0,H.jsxs)(J,{size:`sm`,variant:`outline`,disabled:t,onClick:n,children:[(0,H.jsx)(zr,{className:t?`animate-spin`:``}),t?`Retrying…`:`Retry now`]})]})})}function iT(e){return e===`local`||e.length<=12?e:e.slice(0,12)}function aT({plugin:e}){if(!e.enabled)return null;let t=e.runtimeState,n=t===`absent`?`Unavailable`:t.charAt(0).toUpperCase()+t.slice(1);return(0,H.jsx)(`span`,{className:X(`rounded-full border border-[var(--border)] px-2 py-0.5 font-mono text-[10px]`,t===`running`&&`text-[var(--success)]`,(t===`failed`||t===`degraded`)&&`text-[var(--danger)]`,(t===`stopped`||t===`absent`)&&`text-[var(--muted-foreground)]`),children:n})}function oT({plugin:e,theme:t,onChange:n}){let r=(0,u.useRef)(null),i=(0,u.useRef)(()=>void 0),a=(0,u.useRef)(null),o=(0,u.useRef)(void 0),s=(0,u.useRef)(void 0),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(),[p,m]=(0,u.useState)(),h=(0,u.useCallback)((e,t)=>{let n=Vw(e);return s.current?Promise.reject(Error(`another external link confirmation is already open`)):new Promise((e,r)=>{let i=!1,a,o=()=>{t.removeEventListener(`abort`,c),s.current===a&&(s.current=void 0,m(void 0))},c=()=>{i||(i=!0,o(),r(Error(`external link request was cancelled`)))};a={url:n,settle(t){i||(i=!0,o(),t&&window.open(n,`_blank`,`noopener,noreferrer`),e({opened:t}))}},s.current=a,m(a),t.aborted?c():t.addEventListener(`abort`,c,{once:!0})})},[]);(0,u.useEffect)(()=>{let t=new AbortController;return i.current(),o.current=void 0,l(void 0),f(void 0),Y.pluginSettingsUi(e.id,t.signal).then(l).catch(e=>{t.signal.aborted||f(e.message)}),()=>{t.abort(),i.current()}},[e.id,e.updatedAt]),(0,u.useEffect)(()=>{a.current?.postMessage(sT(t))},[t]);let g=(0,u.useCallback)(()=>{if(i.current(),!c||!r.current?.contentWindow)return;let o=new MessageChannel,s=new Set,l=new Set,u=!0,d=0,f=e=>{if(!u)return;let t=uT(e);o.port1.postMessage(t)};o.port1.onmessage=t=>{let r=lT(t.data);if(!r.ok){f({id:r.id,error:r.error});return}if(l.has(r.id)){f({id:r.id,error:`duplicate request id`});return}if(d>=Ww){f({id:r.id,error:`too many requests in flight`});return}l.add(r.id),d+=1;let i=new AbortController;s.add(i);let a=window.setTimeout(()=>i.abort(),Gw);cT(e.id,c.generation,h,r.method,r.params,i.signal).then(e=>{f({id:r.id,result:e}),r.method!==`host.openExternal`&&n()}).catch(e=>{f({id:r.id,error:i.signal.aborted?`request timed out`:e.message})}).finally(()=>{window.clearTimeout(a),s.delete(i),l.delete(r.id),--d})},o.port1.onmessageerror=()=>{f({id:null,error:`invalid plugin UI message`})},o.port1.start(),a.current=o.port1,r.current.contentWindow.postMessage({type:`rynx-plugin-connect`,pluginId:e.id,appearance:{colorScheme:t}},`*`,[o.port2]),i.current=()=>{if(u){u=!1;for(let e of s)e.abort();s.clear(),l.clear(),a.current===o.port1&&(a.current=null),o.port1.close(),o.port2.close()}}},[c,n,e.id,h,t]),_=(0,u.useCallback)(()=>{if(c){if(o.current===c.generation){i.current();return}o.current=c.generation,g()}},[g,c]);return d?(0,H.jsx)(`div`,{className:`p-5 text-sm text-[var(--danger)]`,children:d}):c?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`iframe`,{ref:r,title:`${e.pluginId} settings`,className:`h-[calc(100dvh-10rem)] min-h-[28rem] max-h-[64rem] w-full border-0 bg-[var(--background)]`,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,srcDoc:c.html,onLoad:_}),(0,H.jsx)(Bw,{open:!!p,url:p?.url??``,onOpenChange:e=>{e||p?.settle(!1)},description:(0,H.jsxs)(H.Fragment,{children:[`The `,e.pluginId,` plugin wants to open this address in a new browser tab. Review the complete destination before continuing.`]}),onConfirm:()=>p?.settle(!0)})]}):(0,H.jsx)(`div`,{className:`p-5 text-sm text-[var(--muted-foreground)]`,children:`Loading plugin UI…`})}function sT(e){return{type:`rynx-host-appearance`,appearance:{colorScheme:e}}}async function cT(e,t,n,r,i,a){if(r===`host.openExternal`)return n(i,a);if(r.startsWith(`host.`))throw Error(`unknown Rynx host settings method "${r}"`);return Y.pluginSettingsCall(e,t,r,i,a)}function lT(e){let t;try{t=dT(e)}catch{return{ok:!1,id:null,error:`request is not serializable`}}if(t>Uw)return{ok:!1,id:null,error:`request exceeds 1 MiB`};if(typeof e!=`object`||!e||Array.isArray(e))return{ok:!1,id:null,error:`request must be an object`};let n=e,r=typeof n.id==`string`||typeof n.id==`number`&&Number.isSafeInteger(n.id)?n.id:null;return r===null||typeof n.method!=`string`||!qw.test(n.method)?{ok:!1,id:r,error:`request id or method is invalid`}:{ok:!0,id:r,method:n.method,params:n.params}}function uT(e){try{return dT(e)<=Uw?e:{id:fT(e),error:`response exceeds 1 MiB`}}catch{return{id:fT(e),error:`response is not serializable`}}}function dT(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength}function fT(e){if(typeof e!=`object`||!e)return null;let t=e.id;return typeof t==`string`||typeof t==`number`?t:null}function pT(e){let t=[...new Set(e.directories.map(e=>e.trim()).filter(Boolean))],n=e.primary.trim();return{name:e.name.trim()||mT(n),directories:t,primary:n}}function mT(e){let t=e.trim().replace(/[\\/]+$/,``);if(!t||/^[A-Za-z]:$/.test(t))return``;let n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return t.slice(n+1)}var hT={name:``,directories:[],primary:``},gT=`local`;function _T(){let e=$e(),[t,n]=(0,u.useState)([]),[r,i]=(0,u.useState)(!0),[a,o]=(0,u.useState)(),[s,c]=(0,u.useState)(()=>e.state?.createProject===!0?`new`:null),l=(0,u.useRef)(0);async function d(e=!1){let t=++l.current;e&&i(!0);try{let e=await Y.listProjects(gT);if(t!==l.current)return;n(e),o(void 0)}catch(e){if(t!==l.current)return;n([]),o(`Could not load projects: ${e.message}`)}finally{t===l.current&&i(!1)}}return(0,u.useEffect)(()=>(n([]),o(void 0),i(!0),d(),()=>{l.current+=1}),[]),(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(fC,{children:[(0,H.jsxs)(pC,{className:`flex-wrap`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(mC,{children:[`Projects`,` `,(0,H.jsx)(`span`,{className:`ml-1 text-[var(--muted-foreground)]`,children:t.length})]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:`Reusable source directories stored on This device.`})]}),(0,H.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-2 sm:flex-none`,children:(0,H.jsxs)(J,{size:`sm`,onClick:()=>c(`new`),children:[(0,H.jsx)(Ir,{}),` New project`]})})]}),(0,H.jsx)(hC,{className:`p-0`,children:r?(0,H.jsxs)(`div`,{className:`flex min-h-36 items-center justify-center gap-2 text-sm text-[var(--muted-foreground)]`,role:`status`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),` Loading projects…`]}):a?(0,H.jsxs)(`div`,{className:`grid min-h-36 place-items-center gap-3 px-5 py-8 text-center`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`Projects are unavailable`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:a})]}),(0,H.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>void d(!0),children:`Retry`})]}):t.length===0?(0,H.jsx)(`div`,{className:`grid min-h-44 place-items-center px-5 py-8 text-center`,children:(0,H.jsxs)(`div`,{className:`max-w-sm`,children:[(0,H.jsx)(`span`,{className:`mx-auto flex size-10 items-center justify-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(ar,{className:`size-5`})}),(0,H.jsx)(`p`,{className:`mt-3 text-sm font-medium`,children:`No projects on this device`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:`Save one or more directories so a new Session can start in the same workspace.`}),(0,H.jsxs)(J,{className:`mt-4`,size:`sm`,onClick:()=>c(`new`),children:[(0,H.jsx)(Ir,{}),` New project`]})]})}):(0,H.jsx)(`ul`,{className:`divide-y divide-[var(--border)]`,children:t.map(e=>(0,H.jsx)(vT,{project:e,onEdit:()=>c(e),onDeleted:()=>void d()},e.id))})})]}),(0,H.jsx)(yT,{open:s!==null,project:s===`new`?void 0:s??void 0,onOpenChange:e=>{e||c(null)},onSaved:async()=>{c(null),await d()}},s===`new`?`new`:s?.id??`closed`)]})}function vT({project:e,onEdit:t,onDeleted:n}){let[r,i]=(0,u.useState)(!1);async function a(){i(!0);try{await Y.deleteProject(gT,e.id),V.success(`Project "${e.name}" removed`),n()}catch(e){V.error(`Delete failed: ${e.message}`)}finally{i(!1)}}return(0,H.jsxs)(`li`,{className:`grid gap-3 px-5 py-4 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(sr,{className:`size-4 shrink-0 text-[var(--primary)]`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,H.jsxs)(`span`,{className:`rounded-md bg-[var(--muted)] px-1.5 py-0.5 font-mono text-[9px] text-[var(--muted-foreground)]`,children:[e.directories.length,` `,e.directories.length===1?`folder`:`folders`]})]}),(0,H.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-1.5 pl-6 font-mono text-[10px] text-[var(--muted-foreground)]`,children:[(0,H.jsx)(ri,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`truncate`,title:e.primary,children:e.primary})]})]}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-1.5`,children:[(0,H.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:t,children:[(0,H.jsx)(Pr,{}),` Edit`]}),(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsx)(J,{variant:`ghost`,size:`icon-sm`,className:`text-[var(--destructive)]`,"aria-label":`Delete ${e.name}`,disabled:r,children:r?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(si,{})})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[`Remove project “`,e.name,`”?`]}),(0,H.jsx)(yu,{children:`This removes only the saved project. It does not delete any directories or affect existing Sessions.`})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>void a(),children:`Remove project`})]})]})]})]})]})}function yT({open:e,project:t,onOpenChange:n,onSaved:r}){let i=wS(),a=!!i?.chooseDirectory,[o,s]=(0,u.useState)(()=>t?{name:t.name,directories:[...t.directories],primary:t.primary}:{...hT}),[c,l]=(0,u.useState)(!1),[d,f]=(0,u.useState)(!1),p=(0,u.useMemo)(()=>bT(o),[o]);function m(){s(e=>({...e,directories:[...e.directories,``]}))}async function h(){let e=await i?.chooseDirectory?.();e&&s(t=>t.directories.includes(e)?t:{...t,directories:[...t.directories,e],primary:t.primary||e})}function g(e,t){s(n=>{let r=n.directories[e]??``,i=n.directories.map((n,r)=>r===e?t:n),a=n.primary;return a===r&&(a=t),!a&&t&&(a=t),{...n,directories:i,primary:a}})}function _(e){s(t=>{let n=t.directories[e],r=t.directories.filter((t,n)=>n!==e);return{...t,directories:r,primary:t.primary===n?r.find(Boolean)??``:t.primary}})}async function v(){if(f(!0),p)return;let e=pT(o);l(!0);try{t?(await Y.updateProject(gT,t.id,e),V.success(`Project "${e.name}" updated`)):(await Y.createProject(gT,e),V.success(`Project "${e.name}" created`)),await r()}catch(e){V.error(`Save failed: ${e.message}`)}finally{l(!1)}}return(0,H.jsx)(Su,{open:e,onOpenChange:n,children:(0,H.jsxs)(Du,{className:`sm:max-w-2xl`,children:[(0,H.jsxs)(Ou,{children:[(0,H.jsx)(Au,{children:t?`Edit project`:`Create project`}),(0,H.jsx)(ju,{children:`These paths belong to This device. The Primary directory becomes the Session working directory; every listed directory is available to the Session.`})]}),(0,H.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),v()},children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`project-name`,children:`Name`}),(0,H.jsx)(Ag,{id:`project-name`,value:o.name,onChange:e=>s(t=>({...t,name:e.target.value})),placeholder:`Defaults to Primary folder name`,maxLength:128,autoFocus:!0})]}),(0,H.jsxs)(`div`,{className:`grid gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(GS,{children:`Source directories`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:`Choose local folders or enter absolute paths.`})]}),(0,H.jsxs)(`div`,{className:`flex gap-1.5`,children:[a&&(0,H.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void h(),children:[(0,H.jsx)(ar,{}),` Choose folder`]}),(0,H.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:m,children:[(0,H.jsx)(Ir,{}),` `,a?`Enter path`:`Add path`]})]})]}),(0,H.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-[var(--border)]`,children:o.directories.length===0?(0,H.jsxs)(`button`,{type:`button`,className:`flex min-h-24 w-full items-center justify-center gap-2 text-sm text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)]`,onClick:a?()=>void h():m,children:[(0,H.jsx)(ar,{className:`size-4`}),a?`Choose a source folder`:`Add an absolute directory path`]}):(0,H.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:o.directories.map((e,t)=>{let n=e!==``&&e===o.primary;return(0,H.jsxs)(`div`,{className:`grid gap-2 p-2.5 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,H.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,H.jsx)(sr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-[var(--muted-foreground)]`}),(0,H.jsx)(Ag,{value:e,onChange:e=>g(t,e.target.value),placeholder:`/Users/name/Workspace/project`,className:`pl-8 font-mono text-xs`,"aria-label":`Source directory ${t+1}`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,H.jsxs)(J,{type:`button`,variant:n?`secondary`:`ghost`,size:`sm`,className:X(n&&`text-[var(--primary)]`),disabled:!e.trim(),onClick:()=>s(t=>({...t,primary:e})),children:[n?(0,H.jsx)(Pn,{}):(0,H.jsx)(ri,{}),n?`Primary`:`Make primary`]}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Remove source directory ${t+1}`,onClick:()=>_(t),children:(0,H.jsx)(di,{})})]})]},t)})})}),d&&p&&(0,H.jsx)(`p`,{className:`text-xs text-[var(--destructive)]`,role:`alert`,children:p})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,H.jsxs)(J,{type:`submit`,disabled:c,children:[c?(0,H.jsx)(B,{className:`animate-spin`}):null,t?`Save changes`:`Create project`]})]})]})]})})}function bT(e){let t=pT(e);if(!t.name)return`Enter a project name.`;if(t.directories.length===0)return`Add at least one source directory.`;if(t.directories.some(e=>!xT(e)))return`Every source directory must be an absolute path.`;if(!t.primary||!t.directories.includes(t.primary))return`Choose one listed directory as Primary.`}function xT(e){return e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}var ST={codex:{src:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAGcklEQVR42s2YbayXZR3HP9efc3g4wEEcgiKSIuQENCnEkUo5ZeUxS4eVtnzR1gpdTzO1CNfDirlc9aJMrfmi1Zo2K2wtQsk0TM6gLWxATUklFQNFoIOcwznA+fSi7023twcQa617++9/77qvh9/j9/f9XfB/9pTXM0ktQCmlDKonAvOBWUAnsBv4C7CmlLI9c1uAzW1KKf7HEucA1AnqEnW9+pK6V92v9qkvZvwW9fgj7NVSh1V7HpOFqkWlFNXZwNeBLqAfWAlsBF4BjgPmARcAB4FfAo/EeqcB+4CtwHpgdSmlX21l78E3YqEp6kr/9SxXL81Yh9oejTvVT6l7PPzznHqPellt72HN89oOI0RbYmAUcD3wLuBe4HOllGcbcztiobnAGGAb8DiwGdgOjIyl5gBXA+eqk4CfAL1q64iWip/b8j5bfVn9q3p6XSt1hHq+ert6IFb4nfrxBP6r3K/OU7+j7lN3qNdUMXXUAM77OPUmdVBdFgFa+Z+mfjZuUN2cgJ5cWz9cHTHEGV9OIqxT5xzOdTQ2eqv6LXWb2pO4aY+mXeqaCLJd/Z46q+5udZK6SH2/Or4K4ig0Sr0v62/Nnm2Hc1W7ekMEqZ5d6twsHKmuyvgKdUHNJdXvktqcgbwvbEDItfn2sHpC0zvUNFim9kage9Q/JXPelu+jY+rd6hV1U6tnqz/IN9Un1A15f1n9fuADdYb6uPqUOu81AmXgg1m4O+Y+TX1QfaUmUIfaHWC8MGOnqF9UN6r9EeJG9Uz1DPXz6gsR7KnE5cxYeJfaNZSFxqu/zaIlMf3ECLSnIdC6WPCqxEh3A2/uUMfU9h6rzle/28jGreom9YKES6nj0PnA2cA64L6g84QhkHxYkHoscAMwExgHLAf6gEuBK4EO9X7gwVLKHqBb3Qw8DFwLvDf7PQ8MpEb+u/6ptwUflsYKJS5bFQudm3mdsZrRtlu9Tj0p6P0JdW2+P5MUn1vPInWq+pmai7+R2GzVXXZvNvlIbezUHN6jnhUhO5MZAwG5aUNk6zT1rhxmYmpxFKzjXJf6fDDpw9V4q/Ffh/BWXNoC2kId9qUU9AA/K6U8HVxpVRhTSnka+CnwJNALvAm4E7gDWBilhpdSVgBLs/9i9bi6IM+lUp+stteYQD/QASxKTB2I0AUYGY33l1IGU4/2Z6wdmAg8ASwGHgUWhgl8NDFWgDXAauDNwCV1gbqBncBFwKmZ/BKwKoIuSeBenYJ74Cjkzli3L0X5CuCrGXsPMDEW/1uoyvEhfYcEeijVeQHw9pp77gYuB34TvnMXcAbwYiwj0F65DGivrbXm7p1x49643PChgWTaMGDqIYFKKbvi50FgmdpVShkopfQAD8Ts10ejDmAGcJU6rZTSV7mslNKXQF8UgrYPGBWLH4wgBxr09rXxGw1HJwX7k5KfVqc2iuZc9SvqlmTQ2qT6lKT+dYGCCgAfUDuz/pxk7OqUjhKIWRrIuW2oWnZeDUdU7w8aT6gTMvXK1K2/qzvVH6s/z5qd6mPh3KvVsbVa16M+Wqtp03PejjqTrKp1S70wcL5V/X0OOJhyML/aPGvGZLz+rEkdXJTysk4d3RBotTo5Zy7JuoeqtG92Fl3R8NfqLPXmFERTIJekYJ6ZIrkh5t4QgjYl+yxIAe5uCLQnAk2PlXenoH/gcK3OeYH89TXKOivIuyOCbQy1qLjS3epZdeJeO2xtVWgj0D/UP4favBCq87V62DQFOkF9JHB+TePbRaEM/XHjr9R31glazTorIvAqdWTG3xJrVM+2kMH2VwnTyKISWmm0GNGgn+PU96mXp3GsE7RZobPba/HUVVFU9eJYaLv6TXWOOvxIXLrqJuaof4g5bxliXnujek9O/Gyu9V83qqc3GoMvpWG4SR03VGMxpFD5fSgx06d+Oy1Macw9Sf1YyFZFR25PazSioeQ09cm4bHbNI62jNYrm94tA/BeATwIXA+vVZ4K+JwLTgXPy/iPgh7lw6D3Up5dyUD0ldWwGcCuwJYL6ulrpRlxcllh6dojWeDD/e4LqndG6PeA5Je3T8sxbWcHCMV/H1C8DYv4FaYVPBkYAW8KJ3pHi2wY8Fgq8Ky31bODdmb8CuLmUsql+iXHM1zCJp9YR5oxPLfpjsqc3VzR7A4zr03VMOGoAv5ELqyHWDqYhmBQ+MzPXMz3AJqC7lLKtIvD/lQur//XzT+4u16KSSLsQAAAAAElFTkSuQmCC`,monochrome:!0},claude:{src:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAEYElEQVR4nMVXW4hVVRjedrMii+6FRRRFUQ9iVNAFKipoKAeC1vrXGTUkSn0xGpyz/nVmHjpRYJQvZQ+R0EOXhyQksQsVKFo9WBORdc6sf59RiWlUyCmly5SWJ/69195n7T3nOo31w2Lm/Ovyf+v7b2sHQQcZXbnyVCoVrpsYFGcE/4eQgdcJoU6oDo2PqMubrakOL7uUNGwkLW6ZU+PVtQNXxMbjYTU83x4kfDenALaX7zqFEI54IH6ulMVZMwAgTLr5z+cUAAtp+ZTPQqjVE4En9XL5JEI4FjGE8FqQkxDVUIhqNERYFcxGamv65ocIoQdib12Ik5N5Wlu4IAVnoOjvJVTDqfsQfuO1bY2NG3E1aVkaQ3VbBgTKJZlYQLksnSuJ6xsA5L2pcQOP+XsIYcoH3lRIw2du8V+Mvh4E85I5i/BRaggh5PiI9FrenejHSg+dH4EqijsJ4WjGdaiGOtIdImzKoDawdbcZONe76bGUBSMfjUGr5Y7i76N1eullhHAwaxw2+ZdpKVXOZ4RtOer2WK1uciy84un3VcritMTPoZFbOF4I1a7c/mqzzGkpdY5qLUv+bQnhTzJq0AH8xbvZKkJ4yf1+mlC+nDP+aw0LNwSzETJwc6jh2+yB8j1r5Iue7muL8JZz186c8Xpo1Irg30htTd98i+qZXED97f1/nBB+yBt2pfvtZmfuK684vWbU4lp56dndAzFqMSHsbm5o5uCc52Dcg+KcUBfuCzWMuACnOMOidYfTBlcZFOftLy85sxMbhLDOO6DlCBF+4uDLseUPPuPd6GAaEQsJ4Q83Mc11PfK9gZ0c2YTqDfa7Raldyq3rlglvHOCUJqPKhNBndf+CzO0oimD4wlE06W7Qq5FM6kXtGeGR0Axc1bWvm9HOhYhrOB9ULQ5cw/7sYJzpHSOEHYRyM/ueBzcqi/IFaxSSUdCxLOeFHyOhgTdd5LcDMMW1gTtgh3j5JCnnbYX9ZQ08Swi/JxFOBjZEf1seLjdzlYz3Fu6P9sd1Ytpbd5gzpaVhpohQPh4FUCO6t9eKcCMhVBJDbUB8nA+2OJPEHXxu0mOaitXi2lxNP2KNXM1l2iK843Tb0pZrYEOSctyULMJXMWA1une4cHHQi1gjV2fo1fB+8hi1Gp50+h85fUMtn4vXqHsI1avZHpGyM26HxJVdGa8HwbxGE1KHOO9TYCV5uyvJx0NUD7COiwmv5YZTK4kLXQDGgTgiFvIj1v2e7LopWa0eZmp96uIuKPc7RtYnekI5EencU4vzvtGI5JZIF7tpOr7QLJ7to/xhgupTx8oujm7WV4riEmfsqP/YIC0/zD/dCGGRK3IHegZgG+33oO/LsAgPumifmFEvGpV0anxo+UUxs/0LmN2ejFMUXGlzWZSZi+s6G/lyBmiUMmVBq/6eb50IFxEuq7WSuDXICSF84FJwa34umtewngx8w608OBFCydeQho0nxEDQCQDfkGu9l6r/PYhOXzpdyD/VGsqNWs3dHgAAAABJRU5ErkJggg==`,monochrome:!1},traex:{src:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAF9SURBVHgB7Zm9SsNQFMf/EYWiVB2KKGLBScHFN9BJurmoa0dn9QGqD1CdHbtWFzd10jfQQdBJqIgKGYw4VCR+nGD0ptqmsSectD0/CKXpbXJ+3HvOyYfVP5B+RxvTgzZHBaRRAWlUQBoVkEYFpOkNGzC0MgtJnPJZw99DBcZ2FiFJmIDmgDSdn8S1PB9d4aFwiDgY2cwhnZuK9J/IAq5TxevNI+Lg7amKqGgO/DrgYIplTNPnAyN9E8OYPF5FZmOu7hgKPrufZ+svkXOgHhR8di/vfWbW5719dvE0MMYPPjUz6m3E3doBWoFlBszgfUjCnAkzeB+6TGl1JuJNYuOJk/W1ccMiQGW1slwKlFe7eAJ7+2cJuZ8lsrJUwsvF/fc+us5JxBIiTIna4H1MCY7gCbYkJij464Xdhg3Jl3D/0bT+gj0HmummXMET2omlCc2By/GtwHeq3dO3BSQFXULSdN8dGdV6p3yOpGDpOzJhVEAaFZBGBaRRAWlUQJoPEeV5RYlN/QYAAAAASUVORK5CYII=`,monochrome:!1}},CT=`local`,wT={starting:`Starting…`,installing:`Installing…`,updating:`Updating…`,verifying:`Verifying installation…`,complete:`Complete`};function TT(){let[e,t]=(0,u.useState)(null),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(!1),[o,s]=(0,u.useState)({}),c=(0,u.useRef)(0),l=(0,u.useCallback)(async(e=!1)=>{let n=++c.current;e&&a(!0),r(null);try{let e=await Y.listProviderClis(CT);n===c.current&&t(e)}catch(e){n===c.current&&(t(null),r(e instanceof Error?e.message:String(e)))}finally{n===c.current&&a(!1)}},[]);(0,u.useEffect)(()=>{l()},[l]);let d=async(e,t)=>{try{let n=(await Y.startProviderCliOperation(CT,e,t)).job;for(s(t=>({...t,[e]:n}));n.state===`running`;)await PT(750),n=await Y.getProviderCliJob(CT,n.id),s(t=>({...t,[e]:n}));n.state===`succeeded`?(V.success(`${NT(e)} ${t} completed`),await l(),s(t=>{let n={...t};return delete n[e],n})):V.error(n.error??`${NT(e)} ${t} failed`)}catch(t){V.error(t.message),s(t=>{let n={...t};return delete n[e],n})}};return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Providers`}),(0,H.jsx)(`p`,{className:`mt-1 max-w-2xl text-xs text-[var(--muted-foreground)]`,children:`Inspect and manage the coding-agent providers installed on this device.`})]}),(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:i,onClick:()=>void l(!0),children:[(0,H.jsx)(zr,{className:i?`animate-spin`:``}),`Refresh`]})})]}),n&&(0,H.jsxs)(`div`,{className:`rounded-lg border border-[var(--destructive)]/35 bg-[var(--destructive)]/8 px-4 py-3 text-sm`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-[var(--destructive)]`,children:[(0,H.jsx)(ci,{className:`size-4`}),` Could not inspect Providers`]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:n}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,className:`mt-3`,onClick:()=>void l(!0),children:[(0,H.jsx)(zr,{}),` Retry`]})]}),e===null&&!n?(0,H.jsx)(`div`,{className:`grid gap-3`,"aria-label":`Loading Providers`,children:[0,1,2].map(e=>(0,H.jsx)(DT,{},e))}):(0,H.jsx)(`div`,{className:`grid gap-3`,children:e?.providerClis.map(t=>(0,H.jsx)(ET,{provider:t,job:o[t.id],readOnly:e.management===`read_only`,onOperation:d},t.id))})]})}function ET({provider:e,job:t,readOnly:n,onOperation:r}){let i=e.availability===`installed`?e.updateState===`available`&&e.canUpdate?`update`:void 0:e.canInstall?`install`:void 0,a=t?.state===`running`;return(0,H.jsx)(fC,{className:`min-w-0`,children:(0,H.jsxs)(hC,{className:`grid gap-3 p-4 text-xs`,children:[(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-[12rem_minmax(14rem,1.5fr)_minmax(8rem,0.65fr)_minmax(13rem,0.9fr)_11rem] xl:items-center`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 md:col-span-2 xl:col-span-1`,children:[(0,H.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--background)]`,children:(0,H.jsx)(`img`,{src:ST[e.id].src,alt:``,"aria-hidden":`true`,className:X(`size-full object-cover`,ST[e.id].monochrome&&`brightness-0 dark:invert`)})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(mC,{children:e.name}),(0,H.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-[var(--muted-foreground)]`,children:e.binary})]})]}),(0,H.jsx)(kT,{icon:yr,label:`Executable`,value:e.executablePath??`Not found on Runtime PATH`,mono:!0}),(0,H.jsx)(kT,{icon:zr,label:`Version`,value:jT(e),mono:!0,noWrap:!0}),(0,H.jsx)(kT,{icon:mr,label:`Authentication`,value:MT(e)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 md:col-span-2 xl:col-span-1 xl:justify-end`,children:[(0,H.jsx)(OT,{provider:e}),!n&&i&&(0,H.jsx)(AT,{provider:e,operation:i,disabled:a,onConfirm:()=>r(e.id,i)})]})]}),e.error&&(0,H.jsx)(`p`,{className:`rounded-md bg-[var(--destructive)]/8 px-2.5 py-2 text-[11px] text-[var(--destructive)]`,children:e.error}),t&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-[var(--muted)]/45 px-2.5 py-2 text-[11px]`,children:[a?(0,H.jsx)(zr,{className:`size-3.5 animate-spin text-[var(--primary)]`}):t.state===`succeeded`?(0,H.jsx)(Vn,{className:`size-3.5 text-[var(--success)]`}):(0,H.jsx)(ci,{className:`size-3.5 text-[var(--destructive)]`}),(0,H.jsx)(`span`,{children:t.error??wT[t.stage]})]})]})})}function DT(){return(0,H.jsxs)(`div`,{"aria-hidden":`true`,className:`grid animate-pulse gap-4 rounded-xl border border-[var(--border)] p-4 md:grid-cols-2 xl:grid-cols-[12rem_minmax(14rem,1.5fr)_minmax(8rem,0.65fr)_minmax(13rem,0.9fr)_11rem] xl:items-center`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3 md:col-span-2 xl:col-span-1`,children:[(0,H.jsx)(`div`,{className:`size-9 rounded-lg bg-[var(--muted)]`}),(0,H.jsxs)(`div`,{className:`grid gap-2`,children:[(0,H.jsx)(`div`,{className:`h-3.5 w-20 rounded bg-[var(--muted)]`}),(0,H.jsx)(`div`,{className:`h-2.5 w-12 rounded bg-[var(--muted)]`})]})]}),[`w-full`,`w-24`,`w-32`].map((e,t)=>(0,H.jsxs)(`div`,{className:`grid gap-2`,children:[(0,H.jsx)(`div`,{className:`h-2.5 w-16 rounded bg-[var(--muted)]`}),(0,H.jsx)(`div`,{className:`h-3 rounded bg-[var(--muted)] ${e}`})]},t)),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 md:col-span-2 xl:col-span-1 xl:justify-end`,children:[(0,H.jsx)(`div`,{className:`h-5 w-24 rounded-full bg-[var(--muted)]`}),(0,H.jsx)(`div`,{className:`h-8 w-24 rounded-md bg-[var(--muted)]`})]})]})}function OT({provider:e}){return e.availability===`missing`?(0,H.jsx)(MC,{variant:`warning`,children:`Not installed`}):e.availability===`broken`?(0,H.jsx)(MC,{variant:`destructive`,children:`Unavailable`}):e.updateState===`available`?(0,H.jsx)(MC,{variant:`warning`,children:`New version`}):(0,H.jsx)(MC,{variant:`success`,children:`Installed`})}function kT({icon:e,label:t,value:n,mono:r=!1,noWrap:i=!1}){return(0,H.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] gap-x-2`,children:[(0,H.jsx)(e,{className:`mt-0.5 size-3.5 text-[var(--muted-foreground)]`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.12em] text-[var(--muted-foreground)]`,children:t}),(0,H.jsx)(`div`,{className:X(`mt-0.5`,r&&`font-mono text-[11px]`,r&&!i&&`break-all`,i&&`whitespace-nowrap`),children:n})]})]})}function AT({provider:e,operation:t,disabled:n,onConfirm:r}){let i=t===`install`?`Install`:`Update`;return(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsxs)(J,{size:`sm`,className:`w-full sm:w-auto`,disabled:n,children:[n?(0,H.jsx)(zr,{className:`animate-spin`}):(0,H.jsx)(Yn,{}),n?`Working…`:i]})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[i,` `,e.name,`?`]}),(0,H.jsxs)(yu,{children:[`Rynx will run `,e.name,`'s official `,t,` mechanism on this Runtime. The daemon will verify the executable and version when it finishes.`]})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{onClick:()=>void r(),children:i})]})]})]})}function jT(e){return e.currentVersion?e.latestVersion?e.updateState===`available`?`${e.currentVersion} → ${e.latestVersion}`:`${e.currentVersion} · latest`:`${e.currentVersion} · latest unknown`:e.availability===`missing`?`—`:`Unknown`}function MT(e){let t=e.authMode?` · ${e.authMode}`:``;return e.authState===`ready`?`Authenticated${t}`:e.authState===`required`?`Sign-in required${t}`:`Unknown${t}`}function NT(e){return e===`codex`?`Codex`:e===`claude`?`Claude Code`:`Traex`}function PT(e){return new Promise(t=>window.setTimeout(t,e))}function FT(e,t){if(e instanceof Hx)switch(e.code){case`offer_expired`:return`This Share Link has expired. Generate a new link on the remote Host and try again.`;case`offer_rejected`:return`The remote Host rejected this Share Link. It may already have been used, expired, or revoked. Generate a new link and use it once.`;case`invalid_offer`:return`This is not a valid Rynx Share Link. Copy and paste the complete link from the remote Host.`}return`${t} failed: ${e instanceof Error?e.message:String(e)}`}function IT(){let{runtimeSelector:e,selectRuntime:t,updateRuntimes:n}=xS(),[r,i]=(0,u.useState)(null),[a,o]=(0,u.useState)(!1),[s,c]=(0,u.useState)(null),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)({}),[m,h]=(0,u.useState)({});async function g(){try{let e=await Y.listRuntimes();i(e),n(e)}catch(e){i([]),V.error(`Failed to load Runtimes: ${e.message}`)}}(0,u.useEffect)(()=>{g()},[]);async function _(e){d(e.selector);try{let t=await Y.testRuntime(e.selector);p(n=>({...n,[e.selector]:t})),h(t=>{let n={...t};return delete n[e.selector],n}),V.success(`${e.displayName} is reachable`)}catch(t){p(t=>{let n={...t};return delete n[e.selector],n});let n={code:t instanceof Hx?t.code:void 0,message:t.message};h(t=>({...t,[e.selector]:n})),V.error(n.code===`authentication_failed`?`Authorization is no longer valid. Generate a new Share Link on the remote host, then reauthorize this Runtime.`:`Connection test failed: ${n.message}`)}finally{d(null)}}async function v(n){try{await Y.forgetRuntime(n.daemonId),p(e=>{let t={...e};return delete t[n.selector],t}),h(e=>{let t={...e};return delete t[n.selector],t}),V.success(`Forgot ${n.displayName}`),e===n.selector&&t(`local`),await g()}catch(e){V.error(`Forget failed: ${e.message}`)}}return(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsx)(RT,{}),(0,H.jsxs)(fC,{children:[(0,H.jsxs)(pC,{className:`items-start`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsxs)(mC,{children:[`Runtimes`,` `,(0,H.jsx)(`span`,{className:`ml-1 text-[var(--muted-foreground)]`,children:r?.length??0})]}),(0,H.jsx)(`p`,{className:`max-w-2xl text-xs text-[var(--muted-foreground)]`,children:`Pair this Control Plane with remote Rynx daemons. Client keys stay in the local backend and never enter the browser.`})]}),(0,H.jsxs)(J,{size:`sm`,onClick:()=>o(!0),children:[(0,H.jsx)(Ir,{}),` Add Runtime`]})]}),(0,H.jsx)(hC,{className:`p-0`,children:(0,H.jsxs)(`div`,{className:`divide-y divide-[var(--border)]`,children:[r===null&&(0,H.jsx)(`div`,{className:`px-5 py-10 text-center text-sm text-[var(--muted-foreground)]`,children:`Loading Runtimes…`}),r?.map(e=>{let t=f[e.selector],n=m[e.selector]?.code===`authentication_failed`;return(0,H.jsxs)(`article`,{className:`grid gap-3 px-5 py-4 transition-colors hover:bg-[var(--muted)]/35 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,H.jsx)(`div`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:e.binding===`local`?(0,H.jsx)(hr,{className:`size-4`}):(0,H.jsx)(Wr,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`font-medium`,children:e.displayName}),(0,H.jsx)(MC,{variant:e.binding===`local`?`default`:`outline`,children:e.binding}),t&&(0,H.jsxs)(MC,{variant:`success`,children:[(0,H.jsx)(Vn,{className:`mr-1 size-3`}),` reachable`]}),n&&(0,H.jsxs)(MC,{variant:`warning`,children:[(0,H.jsx)(Xr,{className:`size-3`}),` authorization required`]})]}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-[var(--muted-foreground)]`,children:e.daemonId}),e.endpoint&&(0,H.jsx)(`div`,{className:`mt-1 truncate text-xs text-[var(--muted-foreground)]`,children:e.endpoint}),e.identityKeyFingerprint&&(0,H.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5 truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:[(0,H.jsx)(Yr,{className:`size-3 shrink-0`}),e.identityKeyFingerprint]}),t&&(0,H.jsxs)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:[`Instance `,t.status.daemonInstanceId]})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[e.binding===`direct`&&(0,H.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>c(e),children:[(0,H.jsx)(Yr,{}),`Reauthorize`]}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:l===e.selector,onClick:()=>void _(e),children:[(0,H.jsx)(zr,{className:l===e.selector?`animate-spin`:``}),`Test`]}),e.binding===`direct`&&(0,H.jsx)(JT,{target:e,onForget:()=>v(e)})]})]},e.selector)})]})})]}),(0,H.jsx)(`div`,{className:`rounded-lg border border-[var(--border)] bg-[var(--muted)]/30 px-4 py-3 text-xs text-[var(--muted-foreground)]`,children:`Sessions, terminals, and Session-scoped resources follow the selected Runtime. The standalone Emulator manager in Settings controls This device only. A remote failure never falls back to this device.`}),(0,H.jsx)(qT,{open:a,onOpenChange:o,onAdded:async e=>{p(t=>({...t,[e.target.selector]:e})),await g()}}),(0,H.jsx)(qT,{open:s!==null,target:s,onOpenChange:e=>{e||c(null)},onAdded:async e=>{p(t=>({...t,[e.target.selector]:e})),h(t=>{let n={...t};return delete n[e.target.selector],n}),await g()}})]})}var LT=`__rynx_custom_share_address__`;function RT(){let[e,t]=(0,u.useState)(null),[n,r]=(0,u.useState)(null),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(!1),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(null),x=(0,u.useRef)(null),[S,C]=(0,u.useState)(null),[w,T]=(0,u.useState)(null),[E,D]=(0,u.useState)(!1),[O,k]=(0,u.useState)(null),[A,j]=(0,u.useState)(null),M=(0,u.useCallback)(async(e=!1)=>{D(!0);try{C(await Y.listRuntimeAccess()),T(null),e&&V.success(`Shared access refreshed`)}catch(t){let n=t.message;T(n),e&&V.error(`Failed to refresh shared access: ${n}`)}finally{D(!1)}},[]),N=(0,u.useCallback)(async(e=!1)=>{s(!0);try{let n=await Y.listRuntimeShareAddresses();t(n),a(null),r(e=>e?.kind===`custom`||e&&n.some(t=>t.address===e.address)?e:n[0]?{kind:`detected`,address:n[0].address}:null),e&&V.success(`Network addresses refreshed`)}catch(n){let r=n.message;t(e=>e??[]),a(r),e&&V.error(`Failed to refresh network addresses: ${r}`)}finally{s(!1)}},[]);(0,u.useEffect)(()=>{M(),N()},[M,N]);let P=n?.address??``,F=h.trim(),I=y&&y.address===P.trim()&&y.clientLabel===F?y.code:``;function L(t){if(t===LT){f(n?.kind===`custom`?n.address:``),m(!1),l(!0);return}t!==VT(n)&&e?.some(e=>e.address===t)&&r({kind:`detected`,address:t})}function ee(){let e=d.trim();if(!HT(e)){m(!0);return}r({kind:`custom`,address:e}),l(!1),m(!1)}async function te(){let e=P.trim();if(!e){V.error(`Choose an address that the other device can reach`);return}v(!0);try{let t=await Y.shareRuntime({address:e,...F?{clientLabel:F}:{}});b({code:t.pairingCode,address:e,clientLabel:F}),V.success(`Pairing link generated`),await M()}catch(e){V.error(`Failed to generate pairing link: ${e.message}`)}finally{v(!1)}}async function ne(){if(!I)return;let e=await NC(I,x.current);e===`clipboard`||e===`selection`?V.success(`Pairing link copied`):e===`selected`?V.info(`Pairing link selected — press Ctrl+C or ⌘C to copy`):V.error(`Copy is unavailable — select the pairing link and copy it manually`)}async function re(e){k(e.grantId);try{let t=await Y.revokeRuntimeAccess(e.grantId);V.success(`Revoked ${GT(e)}${t.closedConnections>0?` and closed ${t.closedConnections} active connection${t.closedConnections===1?``:`s`}`:``}`),await M()}catch(e){V.error(`Revoke failed: ${e.message}`)}finally{k(null)}}async function R(e){j(e.grantId);try{await Y.deleteRevokedRuntimeAccess(e.grantId),V.success(`Removed revoked access record for ${GT(e)}`),await M()}catch(e){V.error(`Remove failed: ${e.message}`)}finally{j(null)}}let ie=S?.filter(e=>e.revokedAt===null).length??0;return(0,H.jsxs)(fC,{children:[(0,H.jsx)(pC,{className:`items-start`,children:(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,H.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(qr,{className:`size-4`})}),(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(mC,{children:`Share this device`}),(0,H.jsx)(`p`,{className:`max-w-2xl text-xs text-[var(--muted-foreground)]`,children:`Generate a revocable pairing link so another Rynx Control Plane can connect to this Runtime. Use a LAN, Tailscale, or tunnel address reachable from that device.`})]})]})}),(0,H.jsxs)(hC,{className:`grid gap-6`,children:[(0,H.jsxs)(`form`,{className:`grid gap-3`,onSubmit:e=>{e.preventDefault(),te()},children:[(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] md:items-end`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`runtime-share-address`,children:`Connection address`}),(0,H.jsxs)(`div`,{className:`flex min-w-0 gap-1.5`,children:[(0,H.jsxs)(my,{value:n?.kind===`custom`?VT(n):n?.address,onValueChange:L,disabled:e===null,children:[(0,H.jsx)(_y,{id:`runtime-share-address`,className:`min-w-0 flex-1`,"aria-describedby":`runtime-share-address-help`,children:(0,H.jsx)(gy,{placeholder:e===null?`Detecting addresses…`:`No address detected`,children:n?.kind===`custom`?n.address:n?BT(e??[],n.address):void 0})}),(0,H.jsxs)(by,{align:`start`,children:[n?.kind===`custom`&&(0,H.jsxs)(Sy,{value:VT(n),children:[`Custom (`,n.address,`)`]}),e?.map(e=>(0,H.jsx)(Sy,{value:e.address,children:zT(e)},e.address)),(n?.kind===`custom`||!!e?.length)&&(0,H.jsx)(Cy,{}),(0,H.jsx)(Sy,{value:LT,children:`Enter custom address…`})]})]}),(0,H.jsx)(J,{type:`button`,variant:`outline`,size:`icon`,disabled:o,"aria-label":`Refresh network addresses`,title:`Refresh network addresses`,onClick:()=>void N(!0),children:(0,H.jsx)(zr,{className:o?`animate-spin`:``})})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`runtime-share-label`,children:`Client label`}),(0,H.jsx)(Ag,{id:`runtime-share-label`,value:h,onChange:e=>g(e.target.value),placeholder:`Alice’s laptop (optional)`,maxLength:128})]}),(0,H.jsxs)(J,{type:`submit`,disabled:_||!n,children:[_?(0,H.jsx)(zr,{className:`animate-spin`}):(0,H.jsx)(_r,{}),`Generate Link`]})]}),(0,H.jsx)(`p`,{id:`runtime-share-address-help`,className:i?`text-xs text-[var(--destructive)]`:`text-xs text-[var(--muted-foreground)]`,role:i?`alert`:void 0,children:i?`Could not refresh network addresses: ${i}`:n?.kind===`custom`?`Using a custom host or ws(s) endpoint. Make sure the other device can reach it.`:e?.length?`Detected from this device. Tailnet addresses are listed first.`:e===null?`Looking for reachable IPv4 interfaces on this device…`:`No reachable IPv4 interface was found. Check the Runtime listener or enter a custom address.`}),I&&(0,H.jsxs)(`div`,{className:`grid gap-1.5 rounded-lg border border-[var(--border)] bg-[var(--muted)]/30 p-3`,children:[(0,H.jsx)(GS,{htmlFor:`runtime-pairing-code`,children:`Pairing link`}),(0,H.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,H.jsx)(Ag,{id:`runtime-pairing-code`,ref:x,value:I,readOnly:!0,className:`font-mono text-xs`,spellCheck:!1}),(0,H.jsxs)(J,{type:`button`,variant:`outline`,onClick:()=>void ne(),children:[(0,H.jsx)(Jn,{}),` Copy`]})]}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Treat this link as a credential. After it is used, the client appears below and can be revoked.`})]})]}),(0,H.jsxs)(`section`,{className:`grid gap-3 border-t border-[var(--border)] pt-4`,"aria-labelledby":`runtime-access-title`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`h2`,{id:`runtime-access-title`,className:`text-sm font-medium`,children:[`Shared access `,(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:ie})]}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--muted-foreground)]`,children:`Active clients can reconnect until their grant is revoked.`})]}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:E,"aria-label":`Refresh shared access`,onClick:()=>void M(!0),children:(0,H.jsx)(zr,{className:E?`animate-spin`:``})})]}),S===null&&!w&&(0,H.jsx)(`div`,{className:`py-4 text-center text-xs text-[var(--muted-foreground)]`,role:`status`,children:`Loading shared access…`}),w&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-[var(--destructive)]/30 bg-[var(--destructive)]/5 px-3 py-2`,children:[(0,H.jsxs)(`p`,{className:`text-xs text-[var(--destructive)]`,role:`alert`,children:[`Could not load shared access: `,w]}),(0,H.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void M(),children:`Retry`})]}),S?.length===0&&!w&&(0,H.jsx)(`div`,{className:`rounded-lg border border-dashed border-[var(--border)] px-4 py-6 text-center text-xs text-[var(--muted-foreground)]`,children:`No shared Runtime access yet.`}),S&&S.length>0&&(0,H.jsx)(`ul`,{className:`divide-y divide-[var(--border)] overflow-hidden rounded-lg border border-[var(--border)]`,children:S.map(e=>(0,H.jsxs)(`li`,{className:`grid gap-3 px-3 py-3 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:GT(e)}),(0,H.jsxs)(MC,{variant:e.revokedAt?`destructive`:`success`,children:[e.revokedAt?(0,H.jsx)(Xr,{className:`size-3`}):(0,H.jsx)(Yr,{className:`size-3`}),e.revokedAt?`revoked`:`active`]})]}),(0,H.jsx)(`div`,{className:`mt-1 truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:e.grantId}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:e.lastUsedAt?`Last used ${KT(e.lastUsedAt)}`:`Created ${KT(e.createdAt)} · never connected`})]}),e.revokedAt?(0,H.jsx)(WT,{client:e,disabled:A===e.grantId,onRemove:()=>R(e)}):(0,H.jsx)(UT,{client:e,disabled:O===e.grantId,onRevoke:()=>re(e)})]},e.grantId))})]})]}),(0,H.jsx)(Su,{open:c,onOpenChange:e=>{l(e),e||m(!1)},children:(0,H.jsxs)(Du,{className:`sm:max-w-md`,children:[(0,H.jsxs)(Ou,{children:[(0,H.jsx)(Au,{children:`Enter custom address`}),(0,H.jsx)(ju,{children:`Use a DNS name, custom port, reverse proxy, or tunnel when the detected interfaces are not the route the other device should dial.`})]}),(0,H.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),ee()},children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`runtime-custom-share-address`,children:`Host or WebSocket URL`}),(0,H.jsx)(Ag,{id:`runtime-custom-share-address`,value:d,onChange:e=>{f(e.target.value),e.target.value.trim()&&m(!1)},placeholder:`runtime.example.com or wss://runtime.example.com`,maxLength:2048,"aria-invalid":p,"aria-describedby":`runtime-custom-share-address-help`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,autoFocus:!0}),(0,H.jsx)(`p`,{id:`runtime-custom-share-address-help`,className:p?`text-xs text-[var(--destructive)]`:`text-xs text-[var(--muted-foreground)]`,children:p?`Enter a host or a complete ws:// or wss:// URL without spaces.`:`Rynx adds the listener port for a host and supplies the Runtime path.`})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(Tu,{asChild:!0,children:(0,H.jsx)(J,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,H.jsx)(J,{type:`submit`,disabled:!d.trim(),children:`Use Address`})]})]})]})})]})}function zT(e){return`${e.interfaceName} (${e.address})`}function BT(e,t){let n=e.find(e=>e.address===t);return n?zT(n):t}function VT(e){return e?.kind===`custom`?`__rynx_custom_share_address_current__:${e.address}`:void 0}function HT(e){return e.length>0&&e.length<=2048&&!/[\s\u0000-\u001f\u007f]/.test(e)}function UT({client:e,disabled:t,onRevoke:n}){return(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsxs)(J,{type:`button`,variant:`destructive`,size:`sm`,disabled:t,children:[t?(0,H.jsx)(zr,{className:`animate-spin`}):(0,H.jsx)(Xr,{}),`Revoke`]})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[`Revoke access for “`,GT(e),`”?`]}),(0,H.jsx)(yu,{children:`This client will no longer be able to reconnect. Any active Runtime connections using this grant are closed immediately.`})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>void n(),children:`Revoke Access`})]})]})]})}function WT({client:e,disabled:t,onRemove:n}){return(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:t,children:[t?(0,H.jsx)(zr,{className:`animate-spin`}):(0,H.jsx)(si,{}),`Remove Record`]})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[`Remove revoked record for “`,GT(e),`”?`]}),(0,H.jsx)(yu,{children:`This removes the revoked authorization record from this Host. It does not restore access or delete the credential stored on the client device.`})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>void n(),children:`Remove Record`})]})]})]})}function GT(e){return e.clientLabel??e.clientId}function KT(e){let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():e}function qT({open:e,target:t=null,onOpenChange:n,onAdded:r}){let[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(!1),d=t!==null;(0,u.useEffect)(()=>{e&&(a(t?.displayName??``),s(``))},[e,t]);async function f(){let e=o.trim();if(e){l(!0);try{let o=await Y.pairRuntime({offer:e,...i.trim()?{displayName:i.trim()}:{},...t?{replaceExisting:!0,expectedDaemonId:t.daemonId}:{}});V.success(d?`Reauthorized ${o.target.displayName}`:`Paired ${o.target.displayName}`),await r(o),a(``),s(``),n(!1)}catch(e){V.error(FT(e,d?`Reauthorization`:`Pairing`))}finally{l(!1)}}}return(0,H.jsx)(Su,{open:e,onOpenChange:n,children:(0,H.jsxs)(Du,{className:`sm:max-w-lg`,children:[(0,H.jsxs)(Ou,{children:[(0,H.jsx)(Au,{children:d?`Reauthorize Runtime`:`Add Runtime`}),(0,H.jsx)(ju,{children:d?`Generate a fresh Share Link on the remote Host and paste it here. The old local credential is replaced only after the new connection is authenticated.`:`On the remote host, share the Runtime and paste its pairing link here. The local backend keeps the resulting client credential out of the browser.`})]}),(0,H.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),f()},children:[(0,H.jsxs)(`div`,{className:`grid gap-3`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`runtime-name`,children:`Display name`}),(0,H.jsx)(Ag,{id:`runtime-name`,value:i,onChange:e=>a(e.target.value),placeholder:`Remote lab`,maxLength:128})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(GS,{htmlFor:`runtime-offer`,children:`Pairing link`}),(0,H.jsx)(Ag,{id:`runtime-offer`,value:o,onChange:e=>s(e.target.value),placeholder:`rynx://pair?code=...`,className:`font-mono text-xs`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1}),(0,H.jsxs)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:[`Generate one from`,` `,(0,H.jsx)(`span`,{className:`font-medium text-[var(--foreground)]`,children:`Share this device`}),` on the remote Control Plane.`]})]})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(Tu,{asChild:!0,children:(0,H.jsx)(J,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,H.jsxs)(J,{type:`submit`,disabled:c||!o.trim(),children:[c?(0,H.jsx)(zr,{className:`animate-spin`}):(0,H.jsx)(Yr,{}),d?`Reauthorize`:`Add Runtime`]})]})]})]})})}function JT({target:e,onForget:t}){return(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsxs)(J,{variant:`ghost`,size:`sm`,className:`text-[var(--destructive)]`,children:[(0,H.jsx)(si,{}),(0,H.jsxs)(`span`,{className:`sr-only`,children:[`Forget `,e.displayName]})]})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[`Forget “`,e.displayName,`”?`]}),(0,H.jsxs)(yu,{children:[`Removes this route and its protected client credential from the local Control Plane. The remote grant remains until an operator runs `,(0,H.jsx)(`code`,{children:`rynx runtime clients revoke`}),`on that daemon.`]})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>void t(),children:`Forget Runtime`})]})]})]})}function YT(e,t){return t===`install`||e?.phase===`installing`}var XT=`rynx.control.session-launch-selection.v2`,ZT=`default`;function QT(e){return`${e.kind}:${e.id}`}function $T(e){return e===`provider:claude`?{kind:`provider`,id:`claude`}:e===`provider:codex`?{kind:`provider`,id:`codex`}:e===`provider:traex`?{kind:`provider`,id:`traex`}:e.startsWith(`agent:`)&&e.length>6?{kind:`agent`,id:e.slice(6)}:null}function eE(e,t){return e.kind===`provider`?t.providers.some(t=>t.id===e.id):t.agents.some(t=>t.id===e.id)}function tE(e,t){let n=t?$T(t):null;if(n&&eE(n,e)&&(n.kind===`agent`&&e.agents.some(e=>e.id===n.id&&e.ready)||n.kind===`provider`&&e.providers.some(e=>e.id===n.id&&e.ready)))return n;for(let t of[`claude`,`codex`,`traex`])if(e.providers.some(e=>e.id===t&&e.ready))return{kind:`provider`,id:t};let r=e.providers.find(e=>e.ready);if(r)return{kind:`provider`,id:r.id};let i=e.agents.find(e=>e.ready);return i?{kind:`agent`,id:i.id}:e.providers[0]?{kind:`provider`,id:e.providers[0].id}:e.agents[0]?{kind:`agent`,id:e.agents[0].id}:null}function nE(e,t){if(!t)return null;try{return t.getItem(iE(e))}catch{return null}}function rE(e,t,n){if(t)try{t.setItem(iE(e),QT(n))}catch{}}function iE(e){return`${XT}:${encodeURIComponent(e)}`}function aE(e,t,n,r){let i=n?{projectId:n}:{},a=r?.permissionPreset&&r.permissionPreset!=="default"?{permissionPreset:r.permissionPreset}:{};return e.kind===`provider`?{provider:e.id,title:t,...i,...r?.model?{model:r.model}:{},...r?.reasoningEffort?{reasoningEffort:r.reasoningEffort}:{},...a}:{agent:e.id,title:t,...i,...a}}function oE(e,t,n=ZT){if(!e||e.kind!==`provider`)return{permissionPreset:n};let r=t.providers.find(t=>t.id===e.id),i=r?.models?.find(e=>e.isDefault)??r?.models?.[0],a=i?.defaultReasoningEffort&&i.reasoningOptions.some(e=>e.value===i.defaultReasoningEffort)?i.defaultReasoningEffort:i?.reasoningOptions.find(e=>e.value===`medium`)?.value??i?.reasoningOptions[0]?.value;return{permissionPreset:n,...i?{model:i.id}:{},...a?{reasoningEffort:a}:{}}}function sE(e){let t=e.replace(/\s+/g,` `).trim(),n=Array.from(t);return n.length<=64?t:`${n.slice(0,61).join(``).trimEnd()}…`}function cE(e){return{providers:[],agents:e.map(e=>({...e,ready:!0,readiness:`unverified`}))}}function lE(e){return e.readiness===`unverified`?`unverified`:e.ready?`ready`:`needs_setup`}function uE(e){return e===`claude`?`Claude Code`:e===`traex`?`Traex`:`Codex`}function dE(e,t){if(!e)return null;if(e.kind===`provider`)return t.providers.find(t=>t.id===e.id)??null;let n=t.agents.find(t=>t.id===e.id);return n?{name:n.name??n.id,ready:n.ready,...n.reason?{reason:n.reason}:{},...n.readiness?{readiness:n.readiness}:{}}:null}var fE=ax,pE=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(ox,{ref:n,className:X(`inline-flex h-9 items-center gap-1 rounded-lg bg-[var(--muted)] p-1 text-[var(--muted-foreground)]`,e),...t}));pE.displayName=`TabsList`;var mE=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(sx,{ref:n,className:X(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium transition-all focus-visible:outline-none data-[state=active]:bg-[var(--background)] data-[state=active]:text-[var(--foreground)] data-[state=active]:shadow-sm`,e),...t}));mE.displayName=`TabsTrigger`;var hE=u.forwardRef(({className:e,...t},n)=>(0,H.jsx)(cx,{ref:n,className:X(`mt-4 focus-visible:outline-none`,e),...t}));hE.displayName=`TabsContent`;function gE(){return{items:[],byId:{},callIndex:{},interactionIndex:{},pendingOutputs:{},pendingInteractionResolutions:{},childStates:{},turns:{},runStatus:`idle`,backgroundTaskCount:0,waitingForInteraction:!1,todos:[],historyLoaded:!1}}function _E(e,t){return e===`startup`&&t!==void 0&&(/^Starting MCP servers?:/i.test(t)||/^MCP startup /i.test(t))}function vE(e){return e.filter(e=>`text`in e).map(e=>e.text).join(``)}function yE(e){let t=e.data.content.flatMap((e,t)=>`text`in e?[t]:[]);return t.length===1&&e.truncations?.some(({field:e})=>e===`data.content[${t[0]}].text`)===!0}function bE(e){return e.flatMap((e,t)=>e.type===`input_image`?[{...e,partIndex:t}]:[])}function xE(e){return e.flatMap((e,t)=>e.type===`input_file`?[{...e,partIndex:t}]:[])}function SE(e){let t=e.slice();for(let e=1;e<t.length;e+=1){let n=t[e],r=t[e-1];n.type!==`reasoning`||n.data.model!==`traex`||r.type!==`message`||r.data.role!==`assistant`||r.data.model!==`traex`||r.responseId!==n.responseId||n.createdAt<r.createdAt||n.createdAt-r.createdAt>500||(t[e]=r,t[e-1]=n)}return t}function CE(e){return{...e,items:e.items.slice(),byId:{...e.byId},callIndex:{...e.callIndex},interactionIndex:{...e.interactionIndex},pendingOutputs:{...e.pendingOutputs},pendingInteractionResolutions:{...e.pendingInteractionResolutions},childStates:{...e.childStates},turns:{...e.turns}}}function wE(e,t,n){e.items[t]=n}function TE(e,t){let n=e.items.length;return e.items.push(t),n}function EE(e,t){let n=gE();for(let e of SE(t))WE(n,e);for(let t of e.items){if(t.kind!==`message`||t.role!==`user`||!t.optimistic)continue;let e={...t,images:t.images.slice()};n.byId[e.id]=TE(n,e)}return n}function DE(e,t,n){if(!n)return;let r=e.turns[t];e.turns[t]=r?{...r,model:r.model??n}:{status:`completed`,model:n}}function OE(e){let t=0;for(let n of e)n.kind===`interaction`&&n.status===`pending`&&(t+=1),n.kind===`tool`&&n.children&&(t+=OE(n.children));return t}function kE(e){e.waitingForInteraction=OE(e.items)>0||Object.values(e.childStates).some(e=>e.waitingForInteraction)}function AE(e){let t={...e,status:`pending`};return delete t.resolution,delete t.reason,delete t.resolvedAt,t}function jE(e,t){return e.map(e=>e.kind===`interaction`?t.has(e.id)?AE(e):e.status===`pending`?{...e,status:`inactive`}:e:e.kind===`tool`&&e.children?{...e,children:jE(e.children,t)}:e)}function ME(e,t=new Set){for(let n of e)n.kind===`interaction`&&t.add(n.id),n.kind===`tool`&&n.children&&ME(n.children,t);return t}function NE(e,t){let n=new Set(t.pendingInteractions.map(({interaction:e})=>e.interactionId));for(let[t,r]of Object.entries(e.childStates)){let i=CE(r);i.items=jE(i.items,n),kE(i),e.childStates[t]=i;let a=e.callIndex[t];if(a!==void 0){let t=e.items[a];wE(e,a,{...t,children:i.items})}}e.items=jE(e.items,n);let r=ME(e.items);for(let t of Object.values(e.childStates))ME(t.items,r);for(let{responseId:n,interaction:i}of t.pendingInteractions){if(r.has(i.interactionId))continue;let t={kind:`interaction`,id:i.interactionId,responseId:n,request:i,status:`pending`};e.interactionIndex[i.interactionId]=TE(e,t),r.add(i.interactionId)}let i=new Set(t.activeResponseIds);for(let[t,n]of Object.entries(e.turns))i.has(t)||n.status===`running`&&(e.turns[t]={...n,status:`completed`},GE(e,t));KE(e,i);for(let t of i)e.turns[t]={...e.turns[t],status:`running`};e.runStatus=t.status,e.statusKind=t.statusKind,e.backgroundTaskCount=t.backgroundTaskCount??0,e.waitingForInteraction=n.size>0}function PE(e,t){return{...e,status:t.status,...t.resolution?{resolution:t.resolution}:{},...t.reason?{reason:t.reason}:{},resolvedAt:t.resolvedAt}}function FE(e,t,n,r){let i=e.byId[t];if(i!==void 0)return i;let a=TE(e,r());return e.byId[t]=a,a}function IE(e,t){e.items.splice(t,1);for(let n of[e.byId,e.callIndex,e.interactionIndex])for(let[e,r]of Object.entries(n))r===t?delete n[e]:r>t&&(n[e]=r-1)}function LE(e,t){for(let n=e.items.length-1;n>=0;--n){let r=e.items[n];r?.kind===`compaction`&&r.status===`in_progress`&&(t===void 0||r.responseId===t)&&IE(e,n)}}function RE(e,t){if(t){let n=e.byId[t];if(n!==void 0&&e.items[n]?.kind===`message`&&e.items[n].role===`user`&&e.items[n].optimistic)return n}return e.items.findIndex(e=>e.kind===`message`&&e.role===`user`&&e.optimistic)}function zE(e,t,n){let r={kind:`message`,id:t,responseId:t,role:`user`,text:vE(n),images:bE(n),files:xE(n),streaming:!1,optimistic:!0,pendingContent:n.map(e=>({...e}))},i=e.byId[t];if(i!==void 0){e.items[i]?.kind===`message`&&e.items[i].optimistic&&wE(e,i,r);return}e.byId[t]=TE(e,r)}function BE(e,t,n){let r=e.byId[t];if(r===void 0||e.items[r]?.kind!==`message`||!e.items[r].optimistic)return!1;let i=e.byId[n];if(i!==void 0&&i!==r)return IE(e,r),!0;let a=e.items[r];return delete e.byId[t],wE(e,r,{...a,id:n,responseId:n}),e.byId[n]=r,!0}function VE(e){let t=e=>{if(Array.isArray(e))return e.map(t);if(typeof e==`object`&&e){let n=e;return Object.fromEntries(Object.keys(n).sort().map(e=>[e,t(n[e])]))}return e};return JSON.stringify(t(e))}function HE(e,t,n=!1){let r=new Set(t.map(e=>e.pendingId));for(let n of t){if(e.byId[n.pendingId]===void 0){let t=VE(n.content),i=e.items.find(e=>e.kind===`message`&&e.role===`user`&&e.optimistic===!0&&!r.has(e.id)&&e.pendingContent!==void 0&&VE(e.pendingContent)===t);i&&BE(e,i.id,n.pendingId)}zE(e,n.pendingId,n.content)}if(n)for(let t=e.items.length-1;t>=0;--t){let n=e.items[t];n?.kind===`message`&&n.role===`user`&&n.optimistic&&!r.has(n.id)&&IE(e,t)}}function UE(e,t,n){let r=CE(e.childStates[t]??gE());WE(r,{...n,parentToolCallId:void 0}),kE(r),e.childStates[t]=r;let i=e.callIndex[t];if(i!==void 0){let t=e.items[i];wE(e,i,{...t,children:r.items})}}function WE(e,t,n,r=!1){if(t.parentToolCallId){UE(e,t.parentToolCallId,t);return}switch(t.type){case`message`:{DE(e,t.responseId,t.data.model);let i={kind:`message`,id:t.id,responseId:t.responseId,role:t.data.role,text:vE(t.data.content),images:bE(t.data.content),files:xE(t.data.content),model:t.data.model,isMeta:t.data.isMeta,interrupted:t.data.interrupted,streaming:!1,...yE(t)?{textPrefixTruncated:!0}:{}},a=e.byId[t.id];if(a!==void 0){if(wE(e,a,i),r&&t.data.role===`user`){let t=RE(e,n);t!==-1&&t!==a&&IE(e,t)}return}if(r&&t.data.role===`user`){let r=RE(e,n);if(r!==-1){let n=e.items[r];delete e.byId[n.id],wE(e,r,i),e.byId[t.id]=r;return}}e.byId[t.id]=TE(e,i);return}case`reasoning`:{DE(e,t.responseId,t.data.model);let n={kind:`reasoning`,id:t.id,responseId:t.responseId,summary:t.data.summary.map(e=>e.text),model:t.data.model,streaming:!1},r=e.byId[t.id];r===void 0?e.byId[t.id]=TE(e,n):wE(e,r,n);return}case`function_call`:{let n=t.data.callId,r=e.pendingOutputs[n],i=e.childStates[n]?.items,a={kind:`tool`,id:n,responseId:t.responseId,name:t.data.name,arguments:t.data.arguments,status:r?r.status??`completed`:t.status,output:r?.output,exitCode:r?.exitCode,generatedImage:r?.generatedImage,generatedImageItemId:r?.generatedImageItemId,...i&&i.length?{children:i}:{}};r&&delete e.pendingOutputs[n];let o=e.callIndex[n];o===void 0?e.callIndex[n]=TE(e,a):wE(e,o,a);return}case`function_call_output`:{let n=t.data.callId,r=e.callIndex[n];if(r===void 0){e.pendingOutputs[n]={output:t.data.output,status:t.data.status,exitCode:t.data.exitCode,generatedImage:t.data.generatedImage,generatedImageItemId:t.id};return}let i=e.items[r];wE(e,r,{...i,output:t.data.output,status:t.data.status??`completed`,exitCode:t.data.exitCode,generatedImage:t.data.generatedImage,generatedImageItemId:t.id});return}case`terminal_command`:{if(t.data.stdout!==void 0||t.data.stderr!==void 0)for(let n=e.items.length-1;n>=0;--n){let r=e.items[n];if(r?.kind===`terminal_command`&&r.responseId===t.responseId&&r.command===t.data.command&&r.stdout===void 0&&r.stderr===void 0){wE(e,n,{...r,...t.data.stdout===void 0?{}:{stdout:t.data.stdout},...t.data.stderr===void 0?{}:{stderr:t.data.stderr}}),e.byId[t.id]=n;return}}let n={kind:`terminal_command`,id:t.id,responseId:t.responseId,command:t.data.command,...t.data.stdout?{stdout:t.data.stdout}:{},...t.data.stderr?{stderr:t.data.stderr}:{}},r=e.byId[t.id];r===void 0?e.byId[t.id]=TE(e,n):wE(e,r,n);return}case`compaction`:{LE(e);let n={kind:`compaction`,id:t.id,responseId:t.responseId,status:`completed`,summary:t.data.summary,sequence:t.data.sequence},r=e.byId[t.id];r===void 0?e.byId[t.id]=TE(e,n):wE(e,r,n);return}case`interaction_request`:{let n=t.data.interaction,r=n.interactionId,i=e.interactionIndex[r],a=e.pendingInteractionResolutions[r],o=i===void 0?void 0:e.items[i],s={kind:`interaction`,id:r,responseId:t.responseId,request:n,status:o?.status??`pending`,...o?.resolution?{resolution:o.resolution}:{},...o?.reason?{reason:o.reason}:{},...o?.resolvedAt===void 0?{}:{resolvedAt:o.resolvedAt}};a&&(s=PE(s,a),delete e.pendingInteractionResolutions[r]),i===void 0?e.interactionIndex[r]=TE(e,s):wE(e,i,s),e.byId[t.id]=e.interactionIndex[r];return}case`interaction_resolution`:{let n=t.data,r=e.interactionIndex[n.interactionId];if(r===void 0){e.pendingInteractionResolutions[n.interactionId]={...n,responseId:t.responseId,itemId:t.id};return}let i=e.items[r];wE(e,r,PE(i,n)),e.byId[t.id]=r;return}case`error`:{let n={kind:`error`,id:t.id,responseId:t.responseId,source:t.data.source,code:t.data.code,message:t.data.message},r=e.byId[t.id];r===void 0?e.byId[t.id]=TE(e,n):wE(e,r,n);return}}}function GE(e,t){let n=e=>e===t;qE(e,n),e.items=YE(e.items,t);for(let[r,i]of Object.entries(e.childStates)){let a=CE(i);qE(a,n),a.items=YE(a.items,t),kE(a),e.childStates[r]=a;let o=e.callIndex[r];if(o!==void 0){let t=e.items[o];wE(e,o,{...t,children:a.items})}}}function KE(e,t){let n=e=>!t.has(e);qE(e,n);for(let[t,r]of Object.entries(e.childStates)){let i=CE(r);qE(i,n),kE(i),e.childStates[t]=i;let a=e.callIndex[t];if(a!==void 0){let t=e.items[a];wE(e,a,{...t,children:i.items})}}}function qE(e,t){for(let n=e.items.length-1;n>=0;--n){let r=e.items[n];r?.kind===`message`&&t(r.responseId)&&r.role===`assistant`&&r.liveDraft===!0&&IE(e,n)}}function JE(e,t){let n=e.items.filter(e=>e.kind===`message`&&e.responseId===t&&e.role===`assistant`&&e.liveDraft!==!0);if(n.length!==0)for(let r=e.items.length-1;r>=0;--r){let i=e.items[r];i?.kind===`message`&&i.responseId===t&&i.role===`assistant`&&i.liveDraft===!0&&n.some(e=>e.text===i.text||e.textPrefixTruncated===!0&&e.text.length>0&&i.text.startsWith(e.text))&&IE(e,r)}}function YE(e,t){return e.map(e=>{let n=e.kind===`tool`&&e.children?{...e,children:YE(e.children,t)}:e;return n.responseId===t?n.kind===`tool`&&n.status===`in_progress`?{...n,status:`incomplete`}:(n.kind===`message`||n.kind===`reasoning`)&&n.streaming?{...n,streaming:!1}:n.kind===`interaction`&&n.status===`pending`?{...n,status:`inactive`,reason:`Turn ended before this interaction was resolved`}:n:n})}function XE(e){return Object.values(e.turns).some(e=>e.status===`running`)}function ZE(e){e.note=void 0,e.statusKind=void 0}function QE(e,t){switch(t.type){case`session.status`:e.runStatus=t.status,t.runtimeSessionId&&(e.runtimeSessionId=t.runtimeSessionId),e.note=t.note,e.statusKind=t.statusKind,t.backgroundTaskCount===void 0?(t.status===`running`||t.status===`failed`)&&(e.backgroundTaskCount=0):e.backgroundTaskCount=t.backgroundTaskCount;return;case`session.collaboration_mode`:e.collaborationMode=t.mode;return;case`response.created`:e.turns[t.responseId]={status:`running`,model:t.model},e.runStatus=`running`,e.backgroundTaskCount=0,ZE(e);return;case`response.output_text.delta`:{ZE(e);let n=e.byId[t.itemId],r=n===void 0?void 0:e.items[n];if(t.discard===!0){n!==void 0&&r?.kind===`message`&&r.role===`assistant`&&r.responseId===t.responseId&&r.liveDraft===!0&&IE(e,n);return}let i=e.turns[t.responseId]?.status;if(i===`completed`||i===`failed`||i===`cancelled`||r?.kind===`message`&&r.role===`assistant`&&r.liveDraft!==!0)return;let a=FE(e,t.itemId,t.responseId,()=>({kind:`message`,id:t.itemId,responseId:t.responseId,role:`assistant`,text:``,images:[],files:[],streaming:!0,liveDraft:!0})),o=e.items[a];e.items[a]={...o,text:o.text+t.delta,streaming:!0},t.final&&JE(e,t.responseId);return}case`response.reasoning_summary_text.delta`:{ZE(e);let n=FE(e,t.itemId,t.responseId,()=>({kind:`reasoning`,id:t.itemId,responseId:t.responseId,summary:[],streaming:!0})),r=e.items[n],i=r.summary.slice();i[t.summaryIndex]=(i[t.summaryIndex]??``)+t.delta,e.items[n]={...r,summary:i,streaming:!0};return}case`response.function_call_output.delta`:{ZE(e);let n=e.callIndex[t.callId];if(n===void 0){let n=e.pendingOutputs[t.callId]??{output:``};e.pendingOutputs[t.callId]={...n,output:(n.output??``)+t.delta};return}let r=e.items[n];e.items[n]={...r,output:(r.output??``)+t.delta};return}case`session.interaction.requested`:{ZE(e),WE(e,t.item);let n=e.interactionIndex[t.interaction.interactionId];if(n!==void 0){let t=e.items[n];(t.status===`pending`||t.status===`inactive`)&&wE(e,n,AE(t))}return}case`session.interaction.resolved`:case`session.interaction.cancelled`:ZE(e),WE(e,t.item);return;case`session.interrupted`:{ZE(e);let n=e.turns[t.responseId];e.turns[t.responseId]={...n,status:`cancelled`};let r=!1;for(let n=e.items.length-1;n>=0;--n){let i=e.items[n];if(i?.kind===`message`&&i.role===`assistant`&&i.responseId===t.responseId){e.items[n]={...i,interrupted:!0,streaming:!1,liveDraft:!1},r=!0;break}}if(!r){let n=`interrupted_${t.responseId}`;e.byId[n]===void 0&&(e.byId[n]=TE(e,{kind:`error`,id:n,responseId:t.responseId,source:`execution`,code:`response_stopped`,message:`Response stopped`}))}GE(e,t.responseId),e.runStatus=XE(e)?`running`:`idle`;return}case`response.output_item.done`:{ZE(e);let n=t.item;if(n.type===`message`&&n.data.role===`assistant`&&e.turns[t.responseId]?.status===`cancelled`){let r=e.byId[`interrupted_${t.responseId}`];r!==void 0&&IE(e,r),n={...n,data:{...n.data,interrupted:!0}}}WE(e,n);return}case`response.completed`:{ZE(e);let n=e.turns[t.responseId];e.turns[t.responseId]={...n,status:n?.status===`cancelled`?`cancelled`:`completed`,usage:t.usage},GE(e,t.responseId),!XE(e)&&e.runStatus!==`failed`&&(e.runStatus=`idle`);return}case`response.failed`:{ZE(e);let n=e.turns[t.responseId];e.turns[t.responseId]={...n,status:`failed`},e.items.some(e=>e.kind===`error`&&e.responseId===t.responseId&&e.code===t.error.code)||TE(e,{kind:`error`,id:`failed_${t.responseId}_${t.error.code}`,responseId:t.responseId,source:t.error.source,code:t.error.code,message:t.error.message}),GE(e,t.responseId),e.runStatus=XE(e)?`running`:`idle`;return}case`session.input.consumed`:ZE(e),WE(e,t.item,t.clearedPendingId,!0);return;case`session.todos`:e.todos=t.todos;return;case`response.compaction.in_progress`:{let n=`compaction_loading_${t.responseId??t.sessionId}`;e.byId[n]===void 0&&(e.byId[n]=TE(e,{kind:`compaction`,id:n,responseId:t.responseId??n,status:`in_progress`}));return}case`response.compaction.completed`:case`response.compaction.failed`:LE(e);return;case`session.rotated`:for(let t=e.items.length-1;t>=0;--t){let n=e.items[t];n?.kind===`message`&&n.role===`user`&&n.optimistic&&IE(e,t)}TE(e,{kind:`divider`,id:`rotate_${t.newSessionId}`,responseId:`rotate_${t.newSessionId}`,label:t.kind===`fork`?`forked to a new session`:`context cleared — new session`,newSessionId:t.newSessionId,rotateKind:t.kind}),e.runStatus=`idle`,e.backgroundTaskCount=0,ZE(e);return}}function $E(e,t){switch(t.kind){case`reset`:return gE();case`snapshot`:{let n=EE(e,t.items);return HE(n,t.pendingInputs??[]),NE(n,t.runtime),n.historyLoaded=!0,n}case`reconcile_snapshot`:{let n=CE(e);for(let e of SE(t.items))WE(n,e);return HE(n,t.pendingInputs??[],t.pruneMissingPending),NE(n,t.runtime),n.historyLoaded=!0,n.error=void 0,n}case`history`:{let n=EE(e,t.items);return kE(n),n.historyLoaded=!0,n}case`reconcile_history`:{let n=CE(e);for(let e of SE(t.items))WE(n,e);return kE(n),n.historyLoaded=!0,n.error=void 0,n}case`event`:{let n=CE(e);return QE(n,t.event),kE(n),n}case`optimistic_user`:{let n=CE(e);return zE(n,t.id,[...t.attachments??[],...t.text?[{type:`input_text`,text:t.text}]:[]]),n}case`discard_optimistic_user`:{let n=e.byId[t.id];if(n===void 0||e.items[n]?.kind!==`message`||!e.items[n].optimistic)return e;let r=CE(e);return IE(r,n),r}case`stream_error`:{let n=CE(e);return n.error=t.message,n}case`stream_done`:return e}}function eD(e){let t;for(let n of e.items){let r=e.turns[n.responseId];r&&(t=r)}return t}function tD(e){let t=!1,n=e.map(e=>e.kind===`error`?e.code===`codex_error`&&e.message===`Codex turn was interrupted`||e.code===`traex_error`&&e.message===`Traex turn was interrupted`?(t=!0,{...e,code:`response_stopped`,message:`Response stopped`}):e.code===`codex_error`&&e.message===`Codex turn failed`||e.code===`traex_error`&&e.message===`Traex turn failed`||e.code===`claude_error`&&e.message===`claude turn failed`?(t=!0,{...e,code:`agent_error`,message:`Agent turn failed`}):e:e);return t?n:e}var nD=`browser:`,rD=`emulator:`;function iD(e){return e?e===`browser`?{type:`browser`,pageId:null}:e.startsWith(nD)?{type:`browser`,pageId:e.slice(8).trim()||null}:e===`emulator`?{type:`emulator`,bindingId:null}:e.startsWith(rD)?{type:`emulator`,bindingId:e.slice(9).trim()||null}:null:null}function aD(e){return e?`${nD}${e}`:`browser`}function oD(e){return e?`${rD}${e}`:`emulator`}function sD(e,t){let n=new Set(t),r=new Set,i=[];for(let t of e)!n.has(t)||r.has(t)||(r.add(t),i.push(t));for(let e of t)r.has(e)||(r.add(e),i.push(e));return i}function cD(e,t){let n=Math.max(0,Math.max(0,e)-420);return Math.min(n,Math.max(Math.min(360,n),t))}function lD(e,t,n){return!e||e.pages.length===0?null:t&&e.pages.some(e=>e.pageId===t)?t:n&&e.pages.some(e=>e.pageId===n)?n:e.activePageId&&e.pages.some(t=>t.pageId===e.activePageId)?e.activePageId:e.pages[0]?.pageId??null}function uD(e,t){return!e||!t?.activePageId||e.includes(t.activePageId)?null:t.pages.some(e=>e.pageId===t.activePageId)?t.activePageId:null}var dD=/^[A-Za-z0-9][A-Za-z0-9._~-]*$/,fD=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,pD=/^[\x20-\x7e]*$/,mD=new Set([`accept-encoding`,`authorization`,`connection`,`content-length`,`cookie`,`host`,`keep-alive`,`origin`,`proxy-authenticate`,`proxy-authorization`,`proxy-connection`,`referer`,`set-cookie`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`user-agent`]);function hD(e){let t=_D(e,[`sessionId`,`expectedRevision`,`enabled`,`headers`],`browser.request-headers.set params`);return{sessionId:yD(t.sessionId,`browser.request-headers.set sessionId`),expectedRevision:yD(t.expectedRevision,`browser.request-headers.set expectedRevision`),...gD(t,`browser.request-headers.set params`)}}function gD(e,t){let n=xD(e.enabled,`${t} enabled`);if(!Array.isArray(e.headers))throw SD(`${t} headers must be an array`);if(e.headers.length>32)throw SD(`${t} headers exceeds 32 entries`);let r=new Set,i={enabled:n,headers:e.headers.map((e,n)=>{let i=_D(e,[`name`,`value`],`${t} headers[${n}]`),a=bD(i.name,`${t} headers[${n}] name`,128);if(!fD.test(a))throw SD(`${t} headers[${n}] name is not an HTTP header token`);let o=a.toLowerCase();if(mD.has(o)||o.startsWith(`proxy-`)||o.startsWith(`sec-`))throw SD(`${t} headers[${n}] name is controlled by the Browser`);if(r.has(o))throw SD(`${t} headers contains duplicate names`);if(r.add(o),typeof i.value!=`string`)throw SD(`${t} headers[${n}] value must be a string`);if(i.value.length>8192)throw SD(`${t} headers[${n}] value is too long`);if(!pD.test(i.value))throw SD(`${t} headers[${n}] value must be printable ASCII`);return{name:a,value:i.value}})};if(new TextEncoder().encode(JSON.stringify(i)).byteLength>24576)throw SD(`${t} exceeds its serialized byte limit`);return i}function _D(e,t,n){let r=vD(e,n),i=new Set(t);for(let e of Object.keys(r))if(!i.has(e))throw SD(`${n} contains unknown field ${e}`);return r}function vD(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw SD(`${t} must be an object`);return e}function yD(e,t){let n=bD(e,t,512);if(!dD.test(n))throw SD(`${t} must be an opaque ASCII token`);return n}function bD(e,t,n){if(typeof e!=`string`||e.length===0||e.length>n)throw SD(`${t} must be a non-empty string of at most ${n} characters`);return e}function xD(e,t){if(typeof e!=`boolean`)throw SD(`${t} must be a boolean`);return e}function SD(e){return TypeError(`Invalid Runtime Browser protocol: ${e}`)}var CD=5242880,wD=20971520,TD=8192,ED=4e7,DD=[`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/svg+xml`];function OD(){return{enabled:!0,mediaTypes:[...DD],maxImagesPerMessage:4,maxImageBytes:CD,maxMessageBytes:wD,maxImageSide:TD,maxImagePixels:ED}}var kD={fields:64,optionsPerField:128,actions:16,routingSkeletonBytes:36864};new TextEncoder;var AD=16384;kD.fields,kD.optionsPerField,kD.actions,new TextEncoder;function jD(e,t){let n=new Map;for(let e of t)e.type===`interaction_request`&&n.set(e.data.interaction.interactionId,e);return{status:e.status,...e.statusKind===void 0?{}:{statusKind:e.statusKind},...e.backgroundTaskCount===void 0?{}:{backgroundTaskCount:e.backgroundTaskCount},activeResponseIds:[...e.activeResponseIds],pendingInteractions:e.pendingInteractions.flatMap(e=>{let t=n.get(e.interactionId);return!t||t.responseId!==e.responseId?[]:[{responseId:e.responseId,interaction:t.data.interaction}]})}}4*Math.ceil(AD/3),new Set(Object.keys({"status.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:null},"provider.cli.status.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.provider-cli.status.v1`},"project.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.project.manage.v1`},"project.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.project.manage.v1`},"project.create":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.project.manage.v1`},"project.update":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.project.manage.v1`},"project.delete":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.project.manage.v1`},"emulator.devices.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.active.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.attach":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.tap":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.type":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.button":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.rotate":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.launch":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.gesture":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.kill":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"emulator.shutdown":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.emulator.unary.v1`},"session.emulator.state.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.devices.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.attach":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.detach":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.tap":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.type":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.button":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.rotate":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.launch":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.emulator.gesture":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.emulator.v1`},"session.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.list.v1`},"session.agentOptions.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.agent-options.v1`},"session.launchOptions.list":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.launch-options.v2`},"session.execution.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.execution-settings.v1`},"session.execution.update":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.execution-settings.v1`},"session.create":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.create.v1`},"session.fork":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.fork.v1`},"session.message.send":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.message.v1`},"session.resource.policy.get":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.resource.upload.begin":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.resource.upload.chunk":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.resource.upload.commit":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.resource.get":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.resource.read":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.resource.delete":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.resources.v2`},"session.file.get":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.files.v1`},"session.file.read":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.files.v1`},"session.workspace.file.get":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.workspace-files.v1`},"session.workspace.file.read":{retryPolicy:`safe`,introducedCoreVersion:2,requiredSemanticCapability:`semantic.session.workspace-files.v1`},"session.message.enqueue":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.message-queue.v1`},"session.terminal.start":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.terminal-start.v1`},"session.delete":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.delete.v1`},"session.snapshot.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.snapshot.v1`},"session.interrupt":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.interrupt.v1`},"session.interaction.resolve":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.session.interaction.v1`},"browser.state.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.request-headers.get":{retryPolicy:`safe`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.request-headers.v1`},"browser.request-headers.set":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.request-headers.v1`},"browser.open":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.close":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.create":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.close":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.activate":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.navigate":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.back":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.forward":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`},"browser.page.reload":{retryPolicy:`never`,introducedCoreVersion:1,requiredSemanticCapability:`semantic.browser.v1`}})),new TextEncoder;var MD=0;function ND(e){let t=globalThis.crypto;if(typeof t?.randomUUID==`function`)return`${e}_${t.randomUUID()}`;if(typeof t?.getRandomValues==`function`){let n=t.getRandomValues(new Uint8Array(16));return`${e}_${Array.from(n,e=>e.toString(16).padStart(2,`0`)).join(``)}`}return MD=MD+1>>>0,`${e}_${Date.now().toString(36)}_${MD.toString(36)}`}var PD=256,FD=4194304;function ID(e,t,n,r){return e||(n?t:r)}function LD(e){return e.type===`response.created`||e.type===`session.input.consumed`}function RD(e,t,n){return n&&e!==null&&t===e}function zD(e,t){return e&&t}function BD(e){let t=Object.entries(e);for(let e=t.length-1;e>=0;--e){let n=t[e];if(n?.[1].status===`running`)return n[0]}}function VD(e,{runtimeSelector:t,allowSend:n=!0}={}){let[r,i]=(0,u.useReducer)($E,void 0,gE),[a,o]=(0,u.useState)(!1),[s,c]=(0,u.useState)(!1),l=(0,u.useRef)(null),d=(0,u.useRef)(0),f=(0,u.useRef)(null),p=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(i({kind:`reset`}),f.current=null,p.current=null,o(!1),c(!1),!e)return;let n=new AbortController,r=!1,a=!0,s;return(async()=>{let l=500;for(;!n.signal.aborted;){let u=new AbortController,d=()=>u.abort();n.signal.addEventListener(`abort`,d,{once:!0});let m=!1,h=!1,g=!1,_={events:[],utf8Bytes:0},v,y,b=new Promise((e,t)=>{v=e,y=t}),x=Y.streamSession(e,e=>{if(!(r||u.signal.aborted)){if(e.event===`ready`){let t=UD(s,e.data);s=t.daemonInstanceId,t.changed&&(a=!0,i({kind:`reset`}),c(!1)),v()}else if(e.event===`event`){let t=e.data,n=f.current;n!==null&&LD(t)&&(p.current=n,RD(f.current,p.current,m)&&(f.current=null,p.current=null,o(!1))),m?i({kind:`event`,event:t}):HD(_,t)||(g=!0,u.abort())}else e.event===`error`&&i({kind:`stream_error`,message:String(e.data.message??`stream error`)})}},u.signal,t).then(()=>(y(Error(`session stream closed before ready`)),{error:void 0})).catch(e=>(y(e),{error:e}));try{await b,l=500;let o=500,s,c=0,d=[],f=[];for(;;){let l=new AbortController,p=()=>l.abort();u.signal.addEventListener(`abort`,p,{once:!0}),u.signal.aborted&&l.abort();let m=t?Y.getSessionSnapshotPage(e,s,l.signal,t).then(e=>({kind:`snapshot_page`,page:e})).catch(e=>({kind:`snapshot_error`,error:e})):Y.getSessionSnapshot(e,l.signal).then(e=>({kind:`snapshot`,snapshot:e})).catch(e=>({kind:`snapshot_error`,error:e})),_=await Promise.race([m,x.then(()=>({kind:`stream_ended`}))]);if(u.signal.removeEventListener(`abort`,p),_.kind===`stream_ended`){l.abort();break}if(r||n.signal.aborted)return;if(g)break;if(_.kind===`snapshot_page`){let{page:t}=_;if(t.sessionId!==e||t.hasMore&&(!t.nextAfterId||t.nextAfterId===s)){i({kind:`stream_error`,message:`Session snapshot page did not advance`}),u.abort();break}if(d.push(...t.items),f=t.pendingInputs??[],i({kind:a&&c===0?`history`:`reconcile_history`,items:t.items}),c+=1,o=500,t.hasMore){s=t.nextAfterId;continue}i({kind:`reconcile_snapshot`,items:[],pendingInputs:f,pruneMissingPending:!a,runtime:jD(t.runtime,d)}),h=!0,a=!1;break}if(_.kind===`snapshot`){let{snapshot:e}=_;i({kind:a?`snapshot`:`reconcile_snapshot`,items:e.items,pendingInputs:e.pendingInputs??[],...a?{}:{pruneMissingPending:!0},runtime:e.runtime}),h=!0,a=!1;break}let{error:v}=_;i({kind:`stream_error`,message:v instanceof Error?v.message:String(v)});let y=await Promise.race([x.then(()=>`stream_ended`),WD(o,n.signal).then(()=>`retry`)]);if(n.signal.aborted)return;if(y===`stream_ended`)break;o=Math.min(o*2,8e3)}}catch(e){!r&&!n.signal.aborted&&!g&&i({kind:`stream_error`,message:e instanceof Error?e.message:String(e)})}finally{if(g||(m=!0),!r&&!n.signal.aborted&&!g){for(let e of _.events.splice(0))i({kind:`event`,event:e});_.utf8Bytes=0,h&&(c(!0),RD(f.current,p.current,!0)&&(f.current=null,p.current=null,o(!1)))}}let S=await x;if(r||c(!1),n.signal.removeEventListener(`abort`,d),u.abort(),n.signal.aborted)return;S.error,await WD(l,n.signal),l=Math.min(l*2,8e3)}})(),()=>{r=!0,n.abort()}},[t,e]);let m=(0,u.useCallback)(async r=>{if(!e||!n)return;let a=typeof r==`string`?r:r.text,s=typeof r==`string`?[]:r.attachments,c=typeof r==`string`?ND(`msg`):r.clientMessageId??ND(`msg`),u=new AbortController,m=++d.current;l.current=u,f.current=m,p.current=null,o(!0);let h=c;i({kind:`optimistic_user`,id:h,text:a,attachments:s});try{await Y.sendSessionMessage(e,{content:[...s,...a?[{type:`input_text`,text:a}]:[]],clientMessageId:c},()=>{},u.signal,t)}catch(e){throw u.signal.aborted||(Ux(e)&&i({kind:`discard_optimistic_user`,id:h}),i({kind:`stream_error`,message:e.message})),f.current===m&&(f.current=null,p.current=null,o(!1)),e}finally{l.current===u&&(l.current=null)}},[n,t,e]),h=(0,u.useCallback)(async()=>{if(l.current?.abort(),f.current=null,p.current=null,o(!1),!e)return;let n=BD(r.turns);n&&i({kind:`event`,event:{type:`session.interrupted`,sessionId:e,responseId:n}});try{await Y.interruptSession(e,t)}catch{}},[t,e,r.turns]);return(0,u.useEffect)(()=>{if(!a)return;if(zD(s,r.runStatus===`running`||r.waitingForInteraction)){f.current=null,p.current=null,o(!1);return}let e=f.current,t=window.setTimeout(()=>{f.current===e&&(f.current=null,p.current=null,o(!1))},15e3);return()=>window.clearTimeout(t)},[s,a,r.runStatus,r.waitingForInteraction]),{state:r,pendingSend:a,current:s,send:m,stop:h}}function HD(e,t,n={}){let r=n.events??PD,i=n.utf8Bytes??FD,a;try{a=new TextEncoder().encode(JSON.stringify(t)).byteLength}catch{return!1}return e.events.length>=r||a>i||e.utf8Bytes+a>i?!1:(e.events.push(t),e.utf8Bytes+=a,!0)}function UD(e,t){let n=t&&typeof t==`object`&&!Array.isArray(t)?t.daemonInstanceId:void 0;return typeof n!=`string`||n.length===0?{daemonInstanceId:e,changed:!1}:{daemonInstanceId:n,changed:e!==void 0&&e!==n}}function WD(e,t){return t.aborted?Promise.resolve():new Promise(n=>{let r=window.setTimeout(i,e);t.addEventListener(`abort`,i,{once:!0});function i(){window.clearTimeout(r),t.removeEventListener(`abort`,i),n()}})}var GD=4096,KD=4096,qD=512,JD=1024,YD=new Uint8Array([82,66,83,70]),XD=38,ZD=1,QD=2,$D=new TextEncoder,eO=new TextDecoder(`utf-8`,{fatal:!0});function tO(e){let t=rO(e);switch(t.type){case`browser.surface.ready`:{aO(t,[`type`,`subscriptionId`,`browserGeneration`,`viewportRevision`,`sourceWidth`,`sourceHeight`,`deviceScaleFactor`,`format`,`grantedRole`],`Browser Surface ready frame`);let e=fO(t.sourceWidth,`sourceWidth`),n=fO(t.sourceHeight,`sourceHeight`);return pO(e,n),{type:`browser.surface.ready`,subscriptionId:oO(t.subscriptionId,`subscriptionId`),browserGeneration:cO(t.browserGeneration,`browserGeneration`),viewportRevision:lO(t.viewportRevision,`viewportRevision`),sourceWidth:e,sourceHeight:n,deviceScaleFactor:dO(t.deviceScaleFactor,.25,8,`deviceScaleFactor`),format:mO(t.format),grantedRole:hO(t.grantedRole,[`view`,`control`],`grantedRole`)}}case`browser.surface.driver.changed`:{aO(t,[`type`,`subscriptionId`,`browserGeneration`,`driver`,`driverSubscriptionId`],`driver changed frame`,!0);let e=hO(t.driver,[`none`,`desktop`,`stream`],`driver`),n=t.driverSubscriptionId===void 0?void 0:oO(t.driverSubscriptionId,`driverSubscriptionId`);if(e===`stream`!=(n!==void 0))throw _O(`driverSubscriptionId is required only when driver is stream`);return{type:`browser.surface.driver.changed`,subscriptionId:oO(t.subscriptionId,`subscriptionId`),browserGeneration:cO(t.browserGeneration,`browserGeneration`),driver:e,...n===void 0?{}:{driverSubscriptionId:n}}}case`browser.surface.closed`:{aO(t,[`type`,`subscriptionId`,`reason`,`message`],`Browser Surface closed frame`,!0);let e=t.message===void 0?void 0:sO(t.message,`message`,JD);return{type:`browser.surface.closed`,subscriptionId:oO(t.subscriptionId,`subscriptionId`),reason:hO(t.reason,[`browser_closed`,`page_closed`,`generation_changed`,`replaced`,`cancelled`,`unauthorized`,`unsupported`,`capacity`,`idle_timeout`,`protocol_error`,`internal_error`],`reason`),...e===void 0?{}:{message:e}}}default:throw _O(`unknown Browser Surface server frame type`)}}function nO(e){if(!(e instanceof Uint8Array)||e.byteLength<39||e.byteLength>4194854)throw _O(`Browser Surface image frame has an invalid byte length`);for(let t=0;t<YD.length;t+=1)if(e[t]!==YD[t])throw _O(`Browser Surface image frame has invalid magic`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint8(4)!==1||t.getUint16(6,!1)!==0)throw _O(`Browser Surface image frame header is unsupported`);let n=t.getUint8(5),r=n===ZD?`jpeg`:n===QD?`png`:void 0;if(r===void 0)throw _O(`Browser Surface image frame format is unsupported`);let i=t.getUint16(32,!1),a=t.getUint32(34,!1);if(i===0||i>qD||a===0||a>4194304||XD+i+a!==e.byteLength)throw _O(`Browser Surface image frame lengths are invalid`);let o;try{o=eO.decode(e.subarray(XD,XD+i))}catch{throw _O(`subscriptionId must be valid UTF-8`)}o=oO(o,`subscriptionId`);let s=gO(t.getBigUint64(8,!1),`frameSequence`),c=t.getUint32(16,!1),l=gO(t.getBigUint64(20,!1),`timestampMilliseconds`),u=fO(t.getUint16(28,!1),`width`),d=fO(t.getUint16(30,!1),`height`);return pO(u,d),{subscriptionId:o,frameSequence:s,viewportRevision:c,timestampMilliseconds:l,width:u,height:d,format:r,encodedBytes:new Uint8Array(e.subarray(XD+i))}}function rO(e){let t=e;if(typeof e==`string`){if($D.encode(e).byteLength>32768)throw _O(`Browser Surface control frame exceeds its byte limit`);try{t=JSON.parse(e)}catch{throw _O(`Browser Surface control frame must be valid JSON`)}}let n=iO(t,`Browser Surface control frame`),r;try{r=JSON.stringify(n)}catch{throw _O(`Browser Surface control frame must be serializable`)}if($D.encode(r).byteLength>32768)throw _O(`Browser Surface control frame exceeds its byte limit`);return n}function iO(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw _O(`${t} must be an object`);return e}function aO(e,t,n,r=!1){let i=Object.keys(e),a=r?t.length-1:t.length;if(i.length<a||i.length>t.length||i.some(e=>!t.includes(e))||t.slice(0,a).some(t=>!Object.hasOwn(e,t)))throw _O(`${n} contains unknown or missing fields`)}function oO(e,t){if(typeof e!=`string`||e.length===0||$D.encode(e).byteLength>qD||!/^[\x21-\x7e]+$/.test(e))throw _O(`${t} must be a bounded opaque identifier`);return e}function sO(e,t,n){if(typeof e!=`string`||e.includes(`\0`)||$D.encode(e).byteLength>n)throw _O(`${t} exceeds its text byte limit`);return e}function cO(e,t){if(!Number.isSafeInteger(e)||e<1)throw _O(`${t} must be a positive safe integer`);return e}function lO(e,t){if(!Number.isSafeInteger(e)||e<0)throw _O(`${t} must be a nonnegative safe integer`);return e}function uO(e,t,n,r){if(!Number.isInteger(e)||e<t||e>n)throw _O(`${r} must be an integer from ${t} to ${n}`);return e}function dO(e,t,n,r){if(typeof e!=`number`||!Number.isFinite(e)||e<t||e>n)throw _O(`${r} must be a finite number from ${t} to ${n}`);return e}function fO(e,t){return uO(e,1,t.toLowerCase().includes(`height`)?KD:GD,t)}function pO(e,t){if(e*t>8847360)throw _O(`Browser Surface viewport exceeds its maximum pixels`)}function mO(e){return hO(e,[`jpeg`,`png`],`format`)}function hO(e,t,n){if(typeof e!=`string`||!t.includes(e))throw _O(`${n} is unsupported`);return e}function gO(e,t){if(e>BigInt(2**53-1))throw _O(`${t} exceeds a safe integer`);return Number(e)}function _O(e){return TypeError(`Invalid Runtime Browser Surface: ${e}`)}var vO=1e4,yO=16,bO=1,xO=[500,1e3,2e3,4e3,8e3,15e3];function SO(e){return xO[Math.max(0,Math.min(Math.trunc(e),xO.length-1))]}function CO(e){return e===1e3||e===1001||e===1006||e===1012||e===4408}function wO(e){return e===`browser_closed`||e===`generation_changed`||e===`cancelled`||e===`capacity`||e===`idle_timeout`||e===`internal_error`}function TO(e){let t=e.trim();if(t)return/^[A-Za-z][A-Za-z\d+.-]*:/.test(t)?t:`https://${t}`}function EO(e){return!(e instanceof Error)||!e.message?`Browser operation failed`:e.message===`failed_precondition`?"Browser Host is unavailable. On a headless Runtime, run `rynx browser install` on that host.":e.message.replaceAll(`_`,` `)}function DO(e,t,n){return n&&e===`local`&&t.executionBackend===`embedded-electron`&&t.capabilities.includes(`desktop-direct-view`)}function OO(e,t,n){return!n||e!==`local`?!1:t.status===`unavailable`||t.status===`ready`&&t.executionBackend===`headless-chromium`}function kO(e,t,n){return n&&e===`local`&&t.status===`ready`&&t.executionBackend===`embedded-electron`&&!t.capabilities.includes(`desktop-direct-view`)}async function AO(e,t){let n=e.pages.findIndex(t=>t.pageId===e.activePageId);await t.close(e.browserGeneration);let r=await t.open(e.pages[0]?.url);t.onProgress?.(r);for(let n of e.pages.slice(1))r=await t.createPage(r.browserGeneration,n.url),t.onProgress?.(r);let i=n>=0?r.pages[n]:void 0;return i&&r.activePageId!==i.pageId&&(r=await t.activatePage(r.browserGeneration,i.pageId),t.onProgress?.(r)),r}function jO({scrollLeft:e,viewportWidth:t,contentWidth:n,availableWidth:r=t}){let i=Math.max(0,n-t),a=n-r>bO;return{hasOverflow:a,canScrollLeft:a&&e>bO,canScrollRight:a&&e<i-bO}}function MO(e){return Math.max(120,e*.75)}function NO({scrollLeft:e,viewportWidth:t,tabLeft:n,tabWidth:r,inset:i=4}){let a=e,o=e+t,s=Math.max(0,n-i),c=n+r+i;return s<a?s-a:c>o?c-o:0}function PO(e,t,n,r){return{deltaX:FO(e+n),deltaY:FO(t+r)}}function FO(e){return Number.isFinite(e)?Math.max(-1e4,Math.min(vO,e)):0}function IO(e){if(!e)return[];let t=new TextEncoder,n=[],r=``,i=0;for(let a of e){let e=t.encode(a).byteLength;if(i+e>4096){if(n.push(r),n.length>=yO)throw RangeError(`Browser text input is too large`);r=``,i=0}r+=a,i+=e}return r&&n.push(r),n}function LO(e,t){if(t.type===`pointerdown`){let n=RO(t.button);return n&&e.set(t.pointerId,n),n}let n=e.get(t.pointerId);return e.delete(t.pointerId),n??RO(t.button)}function RO(e){if(e===0)return`left`;if(e===1)return`middle`;if(e===2)return`right`;if(e===3)return`back`;if(e===4)return`forward`}var zO=1,BO=2;function VO({runtimeSelector:e,sessionId:t,browserGeneration:n,pageId:r,toolbarHost:i,readOnly:a=!1}){let o=(0,u.useRef)(null),s=(0,u.useRef)(null),c=(0,u.useRef)(void 0),l=(0,u.useRef)(void 0),f=(0,u.useRef)(0),p=(0,u.useRef)(0),m=(0,u.useRef)(0),h=(0,u.useRef)(0),g=(0,u.useRef)(void 0),_=(0,u.useRef)(!1),v=(0,u.useRef)(!1),y=(0,u.useRef)(!1),b=(0,u.useRef)(void 0),x=(0,u.useRef)(void 0),S=(0,u.useRef)(void 0),C=(0,u.useRef)(new Map),[w,T]=(0,u.useState)(`connecting`),[E,D]=(0,u.useState)(),[O,k]=(0,u.useState)(),[A,j]=(0,u.useState)(`none`),[M,N]=(0,u.useState)(),[P,F]=(0,u.useState)(!1),[I,L]=(0,u.useState)(!1),ee=A===`stream`&&M===O?.subscriptionId,te=(0,u.useCallback)(()=>{S.current!==void 0&&(window.cancelAnimationFrame(S.current),S.current=void 0),b.current=void 0,x.current=void 0,C.current.clear()},[]),ne=(0,u.useCallback)(()=>{g.current!==void 0&&(window.clearTimeout(g.current),g.current=void 0)},[]),re=(0,u.useCallback)(async({refreshCapability:i=!1,preserveFrame:s=!1}={})=>{ne();let u=++m.current;c.current?.close(1e3,`Browser Surface reconnecting`),c.current=void 0,l.current=void 0,f.current=0,p.current=0,y.current=!1,v.current=!1,te(),T(`connecting`),D(void 0),k(void 0),j(`none`),N(void 0),L(!1),s||(_.current=!1,F(!1));let d=e=>{if(m.current!==u)return;D(e),T(`connecting`);let t=SO(h.current++);g.current=window.setTimeout(()=>{g.current=void 0,re({preserveFrame:!0})},t)};try{let s=await Qx(i);if(m.current!==u)return;let p=new WebSocket(WO({runtimeSelector:e,sessionId:t,pageId:r,browserGeneration:n,capability:s,readOnly:a}));p.binaryType=`arraybuffer`,c.current=p;let g=i,b=!1;p.onmessage=e=>{if(m.current!==u||c.current!==p)return;if(typeof e.data==`string`){try{let t=JSON.parse(e.data);if(t&&typeof t==`object`&&`type`in t&&t.type===`error`){let e=`message`in t&&typeof t.message==`string`?t.message:`Browser Surface failed`;D(e);return}let n=tO(t);if(n.type===`browser.surface.ready`){l.current=n,f.current=n.viewportRevision,ne(),k(n),T(`ready`);return}if(n.type===`browser.surface.driver.changed`){let e=n.driver===`stream`&&n.driverSubscriptionId===l.current?.subscriptionId;y.current=e,e||te(),j(n.driver),N(n.driverSubscriptionId);return}y.current=!1,te();let r=n.message??JO(n.reason);b=!0,wO(n.reason)?(d(r),p.close(1e3,`recovering Browser Surface`)):(D(r),T(`closed`))}catch{b=!0,D(`Browser Surface sent an invalid control frame`),T(`closed`),p.close(4400,`invalid Browser Surface control`)}return}if(!(e.data instanceof ArrayBuffer)){D(`Browser Surface sent an invalid image frame`),p.close(4400,`invalid Browser Surface image`);return}let t=()=>m.current===u&&c.current===p;HO(e.data,p,o.current,l.current,t).then(e=>{e===void 0||!t()||(f.current=e,_.current=!0,v.current=!0,h.current=0,F(!0),L(!0))}).catch(()=>{t()&&(b=!0,D(`Browser preview could not be decoded`),T(`closed`),p.close(4400,`Browser Surface image decode failed`))})},p.onclose=e=>{if(m.current===u&&c.current===p&&(c.current=void 0,y.current=!1,te(),!b)){if((e.code===4403||e.code===1006)&&!g){g=!0,re({refreshCapability:!0,preserveFrame:!0});return}if(CO(e.code)){d(YO(e.code));return}T(`closed`),D(t=>t??YO(e.code))}},p.onerror=()=>{c.current===p&&D(`Browser preview transport failed`)}}catch(e){if(m.current!==u)return;d(e instanceof Error?e.message:`Browser preview could not connect`)}},[e,t,r,n,a,te,ne]);(0,u.useEffect)(()=>(re(),()=>{m.current+=1,ne(),te(),c.current?.close(1e3,`Browser Surface view unmounted`),c.current=void 0}),[re,te,ne]);let R=(0,u.useCallback)(()=>{h.current=0,re({preserveFrame:!0})},[re]),ie=(0,u.useCallback)(e=>{let t=c.current;return!t||t.readyState!==WebSocket.OPEN?!1:(t.send(JSON.stringify(e)),!0)},[]),ae=(0,u.useCallback)(()=>{let e=l.current;!e||!v.current||(ie({type:`browser.surface.driver.take`,subscriptionId:e.subscriptionId,browserGeneration:e.browserGeneration,viewportRevision:f.current}),s.current?.focus())},[ie]),oe=(0,u.useCallback)(()=>{let e=l.current;e&&(te(),s.current&&(s.current.value=``),ie({type:`browser.surface.driver.release`,subscriptionId:e.subscriptionId,browserGeneration:e.browserGeneration}))},[ie,te]),se=(0,u.useCallback)(e=>{let t=l.current;return!t||!v.current||!y.current?!1:ie({type:`browser.surface.input`,subscriptionId:t.subscriptionId,browserGeneration:t.browserGeneration,viewportRevision:f.current,inputSequence:p.current++,event:e})},[ie]),ce=(0,u.useCallback)(e=>{let t;try{t=IO(e)}catch{return D(`Text input is limited to 64 KiB at a time.`),!1}let n=!1;for(let e of t){if(!se({type:`text.insert`,text:e}))return n;n=!0}return n},[se]),le=(0,u.useCallback)(()=>{S.current!==void 0&&(window.cancelAnimationFrame(S.current),S.current=void 0);let e=b.current,t=x.current;b.current=void 0,x.current=void 0,y.current&&(e&&se({...e}),t&&se({...t}))},[se]),ue=(0,u.useCallback)(()=>{S.current===void 0&&(S.current=window.requestAnimationFrame(le))},[le]);(0,u.useEffect)(()=>{y.current=ee,ee||(te(),s.current&&(s.current.value=``,s.current.blur()))},[ee,te]);let de=(0,u.useCallback)(e=>{if(!ee)return;let t=GO(e.currentTarget,e.clientX,e.clientY);if(!t)return;if(e.type===`pointermove`){b.current={type:`pointer.move`,...t,modifiers:KO(e)},ue(),e.preventDefault();return}le(),e.type===`pointerdown`&&(s.current?.focus(),e.currentTarget.setPointerCapture(e.pointerId));let n=e.type===`pointerdown`?`pointer.down`:`pointer.up`,r=LO(C.current,e);if(!r)return;let i={type:n,...t,button:r,modifiers:KO(e)};se(i)&&e.preventDefault()},[ee,se,le,ue]),fe=(0,u.useCallback)(e=>{if(!ee)return;let t=GO(e.currentTarget,e.clientX,e.clientY);if(!t)return;let n=e.deltaMode===zO?16:e.deltaMode===BO?Math.max(1,e.currentTarget.clientHeight):1,r=x.current,i=PO(r?.deltaX??0,r?.deltaY??0,e.deltaX*n,e.deltaY*n);x.current={type:`wheel`,...t,...i,modifiers:KO(e)},ue(),e.preventDefault()},[ee,ue]),pe=(0,u.useCallback)(e=>{if(e.nativeEvent.isComposing||e.key===`Process`||e.key===`Dead`)return;le();let t=se({type:e.type===`keydown`?`key.down`:`key.up`,key:e.key,code:e.code,repeat:e.repeat,modifiers:KO(e)}),n=UO({type:e.type,key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,isComposing:e.nativeEvent.isComposing}),r=n!==void 0&&ce(n);(t||r)&&e.preventDefault()},[se,ce,le]),me=(0,u.useCallback)(e=>{le();let t=e.clipboardData.getData(`text/plain`);t&&ce(t)&&e.preventDefault()},[ce,le]),he=(0,u.useCallback)(e=>{let t=e.data||e.currentTarget.value;e.currentTarget.value=``,t&&ce(t)},[ce]);return(0,H.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-[#111318]`,children:[(0,H.jsx)(`canvas`,{ref:o,className:`max-h-full max-w-full outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--ring)]`,"aria-label":ee?`Interactive browser preview`:`Browser preview`,tabIndex:-1,onPointerMove:de,onPointerDown:de,onPointerUp:de,onPointerCancel:de,onWheel:fe}),(0,H.jsx)(`textarea`,{ref:s,"aria-label":`Browser keyboard input`,className:`pointer-events-none absolute left-0 top-0 size-px resize-none opacity-0`,tabIndex:ee?0:-1,autoComplete:`off`,spellCheck:!1,onKeyDown:pe,onKeyUp:pe,onPaste:me,onCompositionEnd:he}),w===`connecting`&&(0,H.jsx)(qO,{preserveFrame:P,icon:(0,H.jsx)(B,{className:`size-5 animate-spin`}),label:P?`Reconnecting preview…`:`Connecting preview…`}),w===`ready`&&!I&&(0,H.jsx)(qO,{icon:(0,H.jsx)(B,{className:`size-5 animate-spin`}),label:`Waiting for first frame…`}),w===`closed`&&(0,H.jsx)(`div`,{className:`absolute inset-0 grid place-items-center bg-[#111318]/90 px-6 text-center`,children:(0,H.jsxs)(`div`,{className:`max-w-sm`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-white`,children:`Preview disconnected`}),(0,H.jsx)(`p`,{role:`alert`,className:`mt-1 text-xs leading-5 text-white/60`,children:E??`The Browser Surface ended.`})]})}),i&&(0,d.createPortal)((0,H.jsx)(`div`,{className:`flex items-center`,children:w===`closed`?(0,H.jsx)(J,{size:`icon-sm`,variant:`outline`,className:`size-8`,"aria-label":`Reconnect browser preview`,title:`Reconnect browser preview`,onClick:R,children:(0,H.jsx)(zr,{className:`size-4`})}):w!==`ready`||!I?(0,H.jsx)(J,{size:`icon-sm`,variant:`outline`,className:`size-8`,"aria-label":_.current?`Reconnecting browser preview`:`Connecting browser preview`,title:_.current?`Reconnecting browser preview`:`Connecting browser preview`,disabled:!0,children:(0,H.jsx)(B,{className:`size-4 animate-spin`})}):a?(0,H.jsx)(J,{size:`icon-sm`,variant:`outline`,className:`size-8`,"aria-label":`Browser preview is read only`,title:`Browser preview is read only`,disabled:!0,children:(0,H.jsx)(Tr,{className:`size-4`})}):ee?(0,H.jsx)(J,{size:`icon-sm`,variant:`outline`,className:`size-8`,"aria-label":`Release browser control`,title:`Release browser control`,onClick:oe,children:(0,H.jsx)(Tr,{className:`size-4`})}):(0,H.jsx)(J,{size:`icon-sm`,className:`size-8`,"aria-label":`Take browser control`,title:`Take browser control`,onClick:ae,children:(0,H.jsx)(Er,{className:`size-4`})})}),i),(0,H.jsx)(`p`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:E??(ee?`Browser control active`:`Browser preview ${w}`)})]})}async function HO(e,t,n,r,i){let a=nO(new Uint8Array(e));if(!r||a.subscriptionId!==r.subscriptionId||a.format!==r.format)throw Error(`Browser Surface image does not match the active subscription`);let o=await createImageBitmap(new Blob([a.encodedBytes],{type:a.format===`jpeg`?`image/jpeg`:`image/png`}));try{if(!i()||!n||t.readyState!==WebSocket.OPEN)return;n.width=a.width,n.height=a.height;let e=n.getContext(`2d`,{alpha:!1});if(!e)throw Error(`Browser preview canvas is unavailable`);return e.drawImage(o,0,0,a.width,a.height),t.send(JSON.stringify({type:`browser.surface.frame.ack`,subscriptionId:r.subscriptionId,frameSequence:a.frameSequence})),a.viewportRevision}finally{o.close()}}function UO(e){if(!(e.type!==`keydown`||e.isComposing||e.key===`Process`||e.key===`Dead`||e.altKey||e.ctrlKey||e.metaKey||Array.from(e.key).length!==1))return e.key}function WO(e){let t=location.protocol===`https:`?`wss`:`ws`,n=new URLSearchParams({generation:String(e.browserGeneration),role:e.readOnly?`view`:`control`,format:`jpeg`,quality:`75`,maximumFrameRate:`15`,capability:e.capability});return Vx(n),`${t}://${location.host}/api/runtimes/${encodeURIComponent(e.runtimeSelector)}/sessions/${encodeURIComponent(e.sessionId)}/browser/pages/${encodeURIComponent(e.pageId)}/surface?${n.toString()}`}function GO(e,t,n){let r=e.getBoundingClientRect();if(!(r.width<=0||r.height<=0||e.width<=0||e.height<=0))return{x:Math.max(0,Math.min(e.width,(t-r.left)*e.width/r.width)),y:Math.max(0,Math.min(e.height,(n-r.top)*e.height/r.height))}}function KO(e){let t=[];return e.altKey&&t.push(`alt`),e.ctrlKey&&t.push(`control`),e.metaKey&&t.push(`meta`),e.shiftKey&&t.push(`shift`),t}function qO({icon:e,label:t,preserveFrame:n=!1}){return(0,H.jsx)(`div`,{className:n?`absolute inset-0 grid place-items-center bg-[#111318]/55 text-white`:`absolute inset-0 grid place-items-center bg-[#111318] text-white/70`,children:(0,H.jsxs)(`div`,{role:`status`,className:`flex flex-col items-center gap-3 text-sm`,children:[e,t]})})}function JO(e){return e===`replaced`?`This preview was opened somewhere else.`:e===`generation_changed`?`The Browser was restarted.`:e===`page_closed`?`This Browser page was closed.`:e===`idle_timeout`?`The Browser preview timed out.`:e===`unauthorized`?`Browser preview authorization expired.`:`The Browser preview ended.`}function YO(e){return e===4403?`Browser preview authorization failed.`:e===4406?`The selected Runtime cannot provide this Browser preview.`:e===4408?`The Browser preview client was too slow.`:e===1012?`The selected Runtime disconnected.`:`The Browser preview connection closed.`}var XO=400;function ZO({runtimeSelector:e,sessionId:t,browserGeneration:n,pageId:r}){let i=(0,u.useRef)(null),[a,o]=(0,u.useState)(0),[s,c]=(0,u.useState)(`mounting`),[l,d]=(0,u.useState)(`unavailable`),[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(),g=(0,u.useMemo)(()=>({runtimeSelector:e,sessionId:t,browserGeneration:n,pageId:r}),[e,t,n,r]);(0,u.useEffect)(()=>{let e=window.rynxDesktopBrowser,t=i.current;if(!e||!t){c(`unavailable`);return}let n=!1,r=0,a,o=$O(g),s=async()=>{if(n)return;let r=QO(t.getBoundingClientRect());if(!r){e.park(g);return}try{let t=await e.mount(g,r);if(n)return;if(t===`mounted`){c(`mounted`),a!==void 0&&window.clearTimeout(a),a=void 0;return}}catch{}n||(c(`mounting`),a=window.setTimeout(()=>void s(),XO))},l=()=>{window.cancelAnimationFrame(r),r=window.requestAnimationFrame(()=>void s())},u=new ResizeObserver(l);u.observe(t),window.addEventListener(`resize`,l),window.addEventListener(`scroll`,l,!0);let f=e.onState(e=>{if($O(e.resource)===o){if(e.state===`closed`){c(`unavailable`);return}l()}}),m=e.onDriver(e=>{$O(e.resource)===o&&(d(e.driver),e.driver===`desktop`&&(p(!1),h(void 0)))});return d(e.getDriver(g)),c(`mounting`),l(),()=>{n=!0,u.disconnect(),f(),m(),window.removeEventListener(`resize`,l),window.removeEventListener(`scroll`,l,!0),window.cancelAnimationFrame(r),a!==void 0&&window.clearTimeout(a),e.park(g)}},[g,a]);let _=async()=>{let e=window.rynxDesktopBrowser;if(!(!e||f)){p(!0),h(void 0);try{if(await e.takeBack(g)!==`taken`)throw Error(`The remote controller is no longer available.`)}catch(e){p(!1),h(e instanceof Error?e.message:`Could not take back browser control.`)}}};return(0,H.jsxs)(`div`,{ref:i,className:`relative flex min-h-0 flex-1 overflow-hidden bg-white`,"aria-label":`Embedded session browser page`,children:[s!==`mounted`&&(0,H.jsx)(`div`,{className:`absolute inset-0 z-0 grid place-items-center bg-[var(--muted)]/20 p-4 text-center`,children:s===`mounting`?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),`Attaching the local browser…`]}):(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`p`,{className:`text-sm text-[var(--muted-foreground)]`,children:`The local desktop browser is unavailable.`}),(0,H.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>o(e=>e+1),children:[(0,H.jsx)(zr,{}),`Retry`]})]})}),s===`mounted`&&l===`stream`&&(0,H.jsx)(`div`,{className:`absolute inset-0 z-20 grid place-items-center bg-black/45 p-4 text-center backdrop-blur-[1px]`,children:(0,H.jsxs)(`div`,{className:`max-w-sm rounded-lg border border-white/20 bg-[var(--card)] p-4 shadow-lg`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-[var(--foreground)]`,children:`Controlled from a remote viewer`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:`Local mouse and keyboard input are paused to prevent two controllers from acting at once.`}),(0,H.jsxs)(J,{className:`mt-3`,size:`sm`,disabled:f,onClick:()=>void _(),children:[f?(0,H.jsx)(B,{className:`animate-spin`}):null,`Take back control`]}),m?(0,H.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-[var(--destructive)]`,children:m}):null]})})]})}function QO(e){let t=Math.max(0,Math.ceil(e.left)),n=Math.max(0,Math.ceil(e.top)),r=Math.min(window.innerWidth,Math.floor(e.right)),i=Math.min(window.innerHeight,Math.floor(e.bottom));return r<=t||i<=n?null:{x:t,y:n,width:r-t,height:i-n}}function $O(e){return JSON.stringify([e.runtimeSelector,e.sessionId,e.browserGeneration,e.pageId])}var ek=`size-11 sm:size-8`;function tk({sessionId:e,runtimeSelector:t,pageId:n,browserResource:r,readOnly:i=!1}){let{browser:a,loading:o,pendingAction:s,error:c,disabled:l,load:d,openBrowser:f,closeBrowser:p,recreateForDesktop:m,navigatePage:h,backPage:g,forwardPage:_,reloadPage:v}=r,y=(0,u.useMemo)(()=>a?.pages.find(e=>e.pageId===n),[a,n]),b=a!==null&&DO(t,a,window.rynxDesktopBrowser!==void 0),x=a!==null&&a.sessionId===e&&OO(t,a,window.rynxDesktopBrowser!==void 0),S=a!==null&&a.sessionId===e&&kO(t,a,window.rynxDesktopBrowser!==void 0),C=(0,u.useRef)(null),[w,T]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let n=`${t}\n${e}`;i||!x||C.current===n||(C.current=n,m())},[x,i,m,t,e]),o&&a===null?(0,H.jsx)(ak,{label:`Loading browser…`}):a===null?i?(0,H.jsx)(ok,{label:`Browser is not running for this Session.`}):(0,H.jsx)(nk,{error:c,pending:s!==null,onOpen:e=>void f(e),onRetry:()=>void d(!0)}):(0,H.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-[var(--card)]`,"aria-label":`Session browser page`,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 border-b border-[var(--border)] px-2 py-2 sm:flex-nowrap sm:px-3`,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,H.jsx)(ik,{label:`Go back`,disabled:l||!y?.canGoBack,onClick:()=>y&&void g(y.pageId),children:(0,H.jsx)(An,{})}),(0,H.jsx)(ik,{label:`Go forward`,disabled:l||!y?.canGoForward,onClick:()=>y&&void _(y.pageId),children:(0,H.jsx)(jn,{})}),(0,H.jsx)(ik,{label:`Reload page`,disabled:l||!y,onClick:()=>y&&void v(y.pageId),children:(0,H.jsx)(Br,{className:y?.loading?`animate-spin`:void 0})})]}),y?(0,H.jsx)(rk,{page:y,disabled:l,onNavigate:e=>void h(y.pageId,e)},`${y.pageId}\n${y.url}`):(0,H.jsx)(`div`,{className:`h-11 min-w-0 flex-1 rounded-lg border border-[var(--border)] bg-[var(--muted)]/30 sm:h-8`}),!b&&(0,H.jsx)(`div`,{ref:T,className:`flex shrink-0 items-center`}),!i&&S&&(0,H.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:s!==null,onClick:()=>void m(),children:`Open in app`}),!i&&(0,H.jsx)(ik,{label:`Stop browser`,disabled:s!==null,onClick:()=>void p(),children:(0,H.jsx)(Lr,{})})]}),(0,H.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[x?(0,H.jsx)(ak,{label:`Opening in Desktop…`}):a.status===`ready`&&y?b?(0,H.jsx)(ZO,{runtimeSelector:t,sessionId:e,browserGeneration:a.browserGeneration,pageId:y.pageId}):(0,H.jsx)(VO,{runtimeSelector:t,sessionId:e,browserGeneration:a.browserGeneration,pageId:y.pageId,readOnly:i,toolbarHost:w}):a.status===`ready`?(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-[var(--muted-foreground)]`,children:`No browser page is open.`}):a.status===`unavailable`&&i?(0,H.jsx)(ok,{label:`Browser is unavailable.`}):a.status===`unavailable`?(0,H.jsx)(sk,{error:c,pending:s!==null,onRestart:()=>void f()}):(0,H.jsx)(ak,{label:a.status===`closing`?`Closing browser…`:`Starting browser…`}),c&&a.status!==`unavailable`&&(0,H.jsx)(`div`,{role:`alert`,className:`absolute bottom-3 left-1/2 max-w-[calc(100%-1.5rem)] -translate-x-1/2 rounded-md border border-[var(--destructive)]/30 bg-[var(--card)] px-3 py-2 text-xs text-[var(--destructive)] shadow-sm`,children:c})]}),(0,H.jsx)(`p`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:s??c??(a.status===`ready`?`Browser ready`:`Browser ${a.status}`)})]})}function nk({error:e,pending:t,onOpen:n,onRetry:r}){let[i,a]=(0,u.useState)(``);return(0,H.jsx)(U_,{className:`min-h-0 flex-1 bg-[var(--muted)]/20`,children:(0,H.jsx)(`main`,{className:`flex min-h-full items-center justify-center p-4 sm:p-6`,children:(0,H.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n(TO(i))},className:`w-full max-w-xl rounded-lg border border-[var(--border)] bg-[var(--card)] p-4 shadow-sm sm:p-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-lg bg-[var(--primary)]/10 text-[var(--primary)]`,children:(0,H.jsx)(Xn,{className:`size-5`})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h3`,{className:`text-base font-semibold`,children:`Open a browser for this session`}),(0,H.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-[var(--muted-foreground)]`,children:`The browser runs on the selected Runtime, beside the agent using it.`})]})]}),(0,H.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2 sm:flex-row`,children:[(0,H.jsx)(Ag,{value:i,onChange:e=>a(e.target.value),"aria-label":`Initial browser address`,placeholder:`https://example.com (optional)`,className:`h-11 flex-1 sm:h-9`,disabled:t,autoFocus:!0}),(0,H.jsxs)(J,{type:`submit`,className:`h-11 sm:h-9`,disabled:t,children:[t?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Xn,{}),t?`Opening…`:`Open browser`]})]}),e&&(0,H.jsxs)(`div`,{role:`alert`,className:`mt-3 flex items-center justify-between gap-3 rounded-md bg-[var(--destructive)]/10 px-3 py-2 text-xs text-[var(--destructive)]`,children:[(0,H.jsx)(`span`,{children:e}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:`Retry`})]}),(0,H.jsx)(`p`,{className:`sr-only`,"aria-live":`polite`,children:t?`Starting browser`:``})]})})})}function rk({page:e,disabled:t,onNavigate:n}){let[r,i]=(0,u.useState)(e.url);return(0,H.jsx)(`form`,{onSubmit:e=>{e.preventDefault();let t=TO(r);t&&n(t)},className:`order-last flex min-w-full flex-1 sm:order-none sm:min-w-0`,children:(0,H.jsx)(Ag,{value:r,onChange:e=>i(e.target.value),"aria-label":`Browser address`,className:`h-11 rounded-lg bg-[var(--muted)]/35 font-mono text-xs sm:h-8`,disabled:t,spellCheck:!1})})}function ik({label:e,disabled:t,onClick:n,children:r}){return(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:ek,"aria-label":e,title:e,disabled:t,onClick:n,children:r})}function ak({label:e}){return(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 bg-[var(--muted)]/20 text-sm text-[var(--muted-foreground)]`,"aria-live":`polite`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),e]})}function ok({label:e}){return(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center bg-[var(--muted)]/20 text-sm text-[var(--muted-foreground)]`,"aria-live":`polite`,children:e})}function sk({error:e,pending:t,onRestart:n}){return(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4 text-center`,role:`status`,children:[(0,H.jsx)(zr,{className:`size-5 text-[var(--muted-foreground)]`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`Browser is unavailable`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:e??`The selected Runtime cannot provide this browser right now.`})]}),(0,H.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:t,onClick:n,children:[t&&(0,H.jsx)(B,{className:`animate-spin`}),t?`Restarting…`:`Restart browser`]})]})}function ck({open:e,onClose:t,runtimeSelector:n,sessionId:r}){let[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)([]),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(!e)return;let t=!1;return f(!0),g(null),Y.getRuntimeBrowserRequestHeaders(n,r).then(e=>{t||(a(e.revision),s(e.enabled),l(e.headers.map(e=>({...e}))))}).catch(e=>{t||g(lk(e))}).finally(()=>{t||f(!1)}),()=>{t=!0}},[e,n,r]);let _=(e,t,n)=>{l(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},v=async()=>{if(!(i===null||p)){m(!0),g(null);try{let e=hD({sessionId:r,expectedRevision:i,enabled:o,headers:c}),s=await Y.updateRuntimeBrowserRequestHeaders(n,e);a(s.revision),V.success(`Browser request headers updated`),t()}catch(e){if(e instanceof Hx&&e.status===409)try{let e=await Y.getRuntimeBrowserRequestHeaders(n,r);a(e.revision),g(`These settings changed elsewhere. Your draft was preserved; review it and Save again to replace the latest version.`)}catch(e){g(lk(e))}else g(lk(e))}finally{m(!1)}}};return(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold`,children:`Browser request headers`}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-[var(--muted-foreground)]`,children:`Apply request headers to all requests, including subresources, from every Browser page in this Session. Changes affect existing and future pages.`})]}),d?(0,H.jsxs)(`div`,{className:`flex min-h-44 items-center justify-center text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`mr-2 size-4 animate-spin`}),` Loading settings…`]}):(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-lg border border-[var(--border)] p-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium`,children:`Enable request headers`}),(0,H.jsx)(`div`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Turning this off keeps the rows below without sending them.`})]}),(0,H.jsx)(Ub,{checked:o,onCheckedChange:s,disabled:i===null||p,"aria-label":`Enable Browser request headers`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)_2rem] gap-2 px-1 text-xs font-medium text-[var(--muted-foreground)]`,children:[(0,H.jsx)(`span`,{children:`Name`}),(0,H.jsx)(`span`,{children:`Value`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Actions`})]}),c.length===0&&(0,H.jsx)(`div`,{className:`rounded-lg border border-dashed border-[var(--border)] px-3 py-6 text-center text-sm text-[var(--muted-foreground)]`,children:`No request headers configured.`}),c.map((e,t)=>(0,H.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)_2rem] gap-2`,children:[(0,H.jsx)(Ag,{value:e.name,onChange:e=>_(t,`name`,e.target.value),placeholder:`X-Example`,disabled:p,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,"aria-label":`Header ${t+1} name`}),(0,H.jsx)(Ag,{value:e.value,onChange:e=>_(t,`value`,e.target.value),placeholder:`value`,disabled:p,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,"aria-label":`Header ${t+1} value`}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:p,onClick:()=>l(e=>e.filter((e,n)=>n!==t)),"aria-label":`Remove header ${t+1}`,title:`Remove header`,children:(0,H.jsx)(si,{})})]},t)),(0,H.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:p||c.length>=32,onClick:()=>l(e=>[...e,{name:``,value:``}]),children:[(0,H.jsx)(Ir,{}),` Add header`]}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--muted-foreground)]`,children:`Values are sent to every origin requested by the Session Browser. Treat them as sensitive and avoid unrelated third-party pages while enabled.`})]}),h&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--destructive)]`,children:h})]}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-[var(--border)] pt-4`,children:[(0,H.jsx)(J,{type:`button`,variant:`outline`,onClick:t,disabled:p,children:`Cancel`}),(0,H.jsxs)(J,{type:`button`,onClick:()=>void v(),disabled:i===null||d||p,children:[p&&(0,H.jsx)(B,{className:`animate-spin`}),` Save`]})]})]})}function lk(e){return e instanceof Error?e.message:`Browser settings are unavailable`}var uk=[{id:`browser-request-headers`,label:`Browser headers`,icon:Xn}];function dk({open:e,onOpenChange:t,runtimeSelector:n,sessionId:r}){let[i,a]=(0,u.useState)(`browser-request-headers`);return(0,H.jsx)(Su,{open:e,onOpenChange:t,children:(0,H.jsxs)(Du,{className:`max-h-[calc(100dvh-2rem)] gap-0 overflow-hidden p-0 sm:max-w-5xl`,children:[(0,H.jsxs)(Ou,{className:`border-b border-[var(--border)] p-5 pr-12`,children:[(0,H.jsx)(Au,{children:`Session settings`}),(0,H.jsx)(ju,{children:`Manage shared behavior for this Session.`})]}),(0,H.jsxs)(`div`,{className:`grid min-h-0 grid-cols-1 sm:grid-cols-[13rem_minmax(0,1fr)]`,children:[(0,H.jsx)(`nav`,{"aria-label":`Session settings sections`,className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--muted)]/30 p-2 sm:flex-col sm:border-r sm:border-b-0`,children:uk.map(e=>{let t=e.icon,n=i===e.id;return(0,H.jsxs)(`button`,{type:`button`,"aria-current":n?`page`:void 0,onClick:()=>a(e.id),className:`flex shrink-0 items-center gap-2 rounded-md px-3 py-2 text-left text-sm font-medium sm:w-full `+(n?`bg-[var(--accent)] text-[var(--accent-foreground)]`:`text-[var(--muted-foreground)] hover:bg-[var(--accent)]/60 hover:text-[var(--foreground)]`),children:[(0,H.jsx)(t,{className:`size-4`}),(0,H.jsx)(`span`,{children:e.label})]},e.id)})}),(0,H.jsx)(`div`,{className:`min-h-0 overflow-y-auto p-5`,children:i===`browser-request-headers`&&(0,H.jsx)(ck,{open:e,onClose:()=>t(!1),runtimeSelector:n,sessionId:r})})]})]})})}function fk(e,t,n,r){return n===r?t:e}function pk(e,t){return e.key!==t.key||t.streamCurrent===!0&&e.streamCurrent!==!0}function mk(e){return e?e.tool===`skills-cli`?{source:e.source}:{source:e.command}:{}}var hk=OD(),gk={...hk,enabled:!1};function _k({policy:e,upload:t,deleteResource:n,onChange:r}){let[i,a]=(0,u.useState)([]),o=(0,u.useRef)([]),s=(0,u.useRef)(new Map),c=(0,u.useCallback)(e=>{a(t=>{let n=e(t);return o.current=n,n})},[]);(0,u.useEffect)(()=>()=>{for(let e of s.current.values())e.abort();for(let e of o.current)e.previewUrl&&URL.revokeObjectURL(e.previewUrl)},[]);let l=(0,u.useCallback)(i=>{if(!e.enabled||i.length===0)return;r?.();let a=o.current.filter(e=>e.type===`input_image`).length;for(let r of i){let i=r.type.startsWith(`image/`)?`input_image`:`input_file`,l=ND(`attachment`),u=ND(`upl`),d=i===`input_image`?URL.createObjectURL(r):void 0,f;if(i===`input_image`?(a+=1,a>e.maxImagesPerMessage?f=`Attach up to ${e.maxImagesPerMessage} images`:e.mediaTypes.includes(r.type)?(r.size<=0||r.size>e.maxImageBytes)&&(f=`Image must be smaller than ${bk(e.maxImageBytes)}`):f=`Unsupported image type`):(r.size<=0||!Number.isSafeInteger(r.size))&&(f=`File is empty or too large for this browser`),f){c(e=>[...e,{id:l,file:r,clientUploadId:u,type:i,previewUrl:d,state:`failed`,error:f}]);continue}let p={id:l,file:r,clientUploadId:u,type:i,previewUrl:d,state:t?`uploading`:`ready`};if(c(e=>[...e,p]),!t)continue;let m=new AbortController;s.current.set(l,m),t(r,u,i,m.signal).then(e=>{if(s.current.delete(l),!o.current.some(e=>e.id===l)){n?.(e).catch(()=>void 0);return}c(t=>t.map(t=>t.id===l?{...t,state:`ready`,resource:e}:t))}).catch(e=>{s.current.delete(l),!m.signal.aborted&&c(t=>t.map(t=>t.id===l?{...t,state:`failed`,error:e instanceof Error?e.message:`Upload failed`}:t))})}},[n,r,e,c,t]);return{items:i,addFiles:l,onPaste:(0,u.useCallback)(e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length!==0&&(e.preventDefault(),l(t))},[l]),remove:(0,u.useCallback)(e=>{r?.(),s.current.get(e.id)?.abort(),s.current.delete(e.id),c(t=>t.filter(t=>t.id!==e.id)),e.previewUrl&&URL.revokeObjectURL(e.previewUrl),e.resource&&n?.(e.resource).catch(()=>void 0)},[n,r,c]),clear:(0,u.useCallback)(()=>{for(let e of s.current.values())e.abort();s.current.clear();for(let e of o.current)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);o.current=[],a([])},[]),hasPending:i.some(e=>e.state===`uploading`),hasFailed:i.some(e=>e.state===`failed`),readyResources:i.flatMap(e=>e.state===`ready`&&e.resource?[e.resource]:[]),readyUploads:i.flatMap(e=>e.state===`ready`?[{file:e.file,clientUploadId:e.clientUploadId,type:e.type}]:[])}}function vk({items:e,disabled:t,onRemove:n,className:r}){return e.length===0?null:(0,H.jsx)(`div`,{className:X(`flex gap-2 overflow-x-auto px-2 pb-2`,r),"aria-label":`Attachments`,children:e.map(e=>(0,H.jsxs)(`div`,{className:X(`group relative h-20 shrink-0 overflow-hidden rounded-md border border-[var(--border)] bg-[var(--muted)]`,e.type===`input_image`?`w-20`:`w-52`),title:e.error??e.file.name,children:[e.previewUrl?(0,H.jsx)(`img`,{src:e.previewUrl,alt:e.file.name,className:`size-full object-cover`}):(0,H.jsxs)(`div`,{className:`flex size-full items-center gap-2 px-3 pr-8`,children:[(0,H.jsx)(nr,{className:`size-5 shrink-0 text-[var(--primary)]`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-xs font-medium`,children:e.file.name}),(0,H.jsx)(`div`,{className:`text-[10px] text-[var(--muted-foreground)]`,children:xk(e.file.size)})]})]}),e.state===`uploading`&&(0,H.jsx)(`div`,{className:`absolute inset-0 grid place-items-center bg-black/45 text-white`,children:(0,H.jsx)(B,{className:`size-5 animate-spin`})}),e.state===`failed`&&(0,H.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 bg-[var(--destructive)] px-1 py-0.5 text-center text-[9px] text-white`,children:`Upload failed`}),(0,H.jsx)(`button`,{type:`button`,className:`absolute right-1 top-1 grid size-5 place-items-center rounded-full bg-black/65 text-white opacity-90 transition-opacity hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-45`,"aria-label":`Remove ${e.file.name}`,disabled:t,onClick:()=>n(e),children:(0,H.jsx)(di,{className:`size-3`})})]},e.id))})}function yk({policy:e,disabled:t,onFiles:n,className:r}){let i=(0,u.useRef)(null);function a(e){n(Array.from(e.target.files??[])),e.target.value=``}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`input`,{ref:i,type:`file`,multiple:!0,className:`hidden`,onChange:a}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:X(`size-8 shrink-0`,r),disabled:t||!e.enabled,"aria-label":`Attach files`,title:`Attach images or files`,onClick:()=>i.current?.click(),children:e.enabled?(0,H.jsx)(Nr,{}):(0,H.jsx)(pr,{})})]})}function bk(e){return`${Math.round(e/1048576)} MB`}function xk(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}var Sk=200;function Ck({initialDraft:e,model:t,running:n,collaborationMode:r,streamCurrent:i,disabled:a,sessionId:o,runtimeSelector:s,onSend:c,onStop:l}){let[d,f]=(0,u.useState)(e??``),[p,m]=(0,u.useState)(gk),[h,g]=(0,u.useState)(!1),_=(0,u.useRef)(null),v=(0,u.useRef)(!1),y=(0,u.useRef)(void 0),b=(0,u.useRef)(0),x=(0,u.useRef)(!1),S=_k({policy:p,upload:(e,t,n,r)=>Y.uploadSessionResource(s,o,e,t,n,r),deleteResource:e=>Y.deleteSessionResource(s,o,e.resourceId),onChange:()=>{y.current=void 0}});(0,u.useEffect)(()=>{let e=!1;return Y.getSessionResourcePolicy(s,o).then(t=>{e||m(t)}).catch(()=>{e||m(gk)}),()=>{e=!0}},[s,o]),(0,u.useEffect)(()=>{e!==void 0&&f(t=>t||e)},[e]),(0,u.useLayoutEffect)(()=>{let e=_.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight;e.style.height=`${Math.min(t,Sk)}px`,e.style.overflowY=t>Sk?`auto`:`hidden`},[d]);async function C(){if(x.current)return;let e=d,t=b.current,n=d.trim(),r=S.readyResources;if(!n&&r.length===0||S.hasPending||S.hasFailed)return;let i=r.length>0?y.current??ND(`msg`):void 0;i&&(y.current=i),x.current=!0,g(!0),f(``);try{await c({text:n,attachments:r,clientMessageId:i}),S.clear(),y.current=void 0}catch(n){V.error(`Could not send message: ${n instanceof Error?n.message:`unknown error`}`),Ux(n)?f(n=>fk(n,e,b.current,t)):(S.clear(),y.current=void 0)}finally{x.current=!1,g(!1)}}let w=!a&&!h&&!S.hasPending&&!S.hasFailed&&(!!d.trim()||S.items.length>0);return(0,H.jsx)(`div`,{className:`px-4 pb-3 pt-1`,children:(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl rounded-xl border border-[var(--border)] bg-[var(--card)] p-2 shadow-[var(--shadow-sm)] transition-[border-color,box-shadow] focus-within:border-[color-mix(in_srgb,var(--primary)_55%,var(--border))] focus-within:shadow-[0_0_0_3px_color-mix(in_srgb,var(--primary)_9%,transparent),var(--shadow-sm)]`,children:[(0,H.jsx)(vk,{items:S.items,disabled:h,onRemove:S.remove}),(0,H.jsx)(`textarea`,{ref:_,value:d,rows:1,placeholder:`Message… (Enter to send · Shift+Enter for newline)`,disabled:a,onChange:e=>{b.current+=1,y.current=void 0,f(e.target.value)},onPaste:e=>{h||S.onPaste(e)},onCompositionStart:()=>{v.current=!0},onCompositionEnd:()=>{v.current=!1},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!v.current&&!e.nativeEvent.isComposing&&e.keyCode!==229&&(e.preventDefault(),w&&C())},className:X(`block min-h-[52px] w-full resize-none overflow-hidden border-0 bg-transparent px-2 py-1.5`,`text-sm leading-relaxed placeholder:text-[var(--muted-foreground)]`,`focus-visible:outline-none`,`disabled:cursor-not-allowed disabled:opacity-50`),style:{maxHeight:Sk}}),(0,H.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2 pt-1`,children:[(0,H.jsx)(yk,{policy:p,disabled:a||h,onFiles:S.addFiles}),(0,H.jsx)(wk,{fallbackModel:t,running:n,collaborationMode:r,streamCurrent:i,sessionId:o,runtimeSelector:s}),n?(0,H.jsxs)(J,{variant:`outline`,className:`ml-auto h-8 shrink-0`,onClick:l,title:`Stop the running turn`,children:[(0,H.jsx)(ni,{}),` Stop`]}):(0,H.jsxs)(J,{className:`ml-auto h-8 shrink-0`,onClick:C,disabled:!w,children:[(0,H.jsx)(Ur,{}),` Send`]})]})]})})}function wk({fallbackModel:e,running:t,collaborationMode:n,streamCurrent:r,sessionId:i,runtimeSelector:a}){let[o,s]=(0,u.useState)(null),[c,l]=(0,u.useState)([]),[d,f]=(0,u.useState)(!0),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(!1),_=(0,u.useRef)({key:null,streamCurrent:void 0});(0,u.useEffect)(()=>{let e=`${a}\0${i}`,t=_.current,n={key:e,streamCurrent:r};if(_.current=n,!pk(t,n))return;let o=!1,c=t.key!==e;return c&&(f(!0),s(null),l([])),Promise.all([Y.getSessionExecutionSettings(a,i),Y.listSessionLaunchOptions(a)]).then(([e,t])=>{o||(s(e),l(t.providers.find(t=>t.id===e.provider)?.models??[]))}).catch(()=>{}).finally(()=>{!o&&c&&f(!1)}),()=>{o=!0}},[a,i,r]),(0,u.useEffect)(()=>{n&&s(e=>e&&{...e,collaborationMode:n})},[n]);let v=c.find(e=>e.id===o?.model),y=v?.reasoningOptions.find(e=>e.value===o?.reasoningEffort),b=v?`${v.label}${y?` / ${y.label}`:``}`:o?.model??e,x=t||p||d||!o||c.length===0;async function S(e,n){if(!(p||t)){m(!0);try{let t=await Y.updateSessionExecutionSettings(a,i,{model:e,reasoningEffort:n});s(t)}catch(e){V.error(`Could not change model: ${e instanceof Error?e.message:`unknown error`}`)}finally{m(!1)}}}async function C(){if(!o||h)return;let e=o,t=o.collaborationMode===`plan`?`default`:`plan`;g(!0),s({...o,collaborationMode:t});try{let e=await Y.updateSessionExecutionSettings(a,i,{model:o.model,reasoningEffort:o.reasoningEffort,collaborationMode:t});s(e)}catch(n){s(e);let r=t===`plan`?`enter`:`exit`;V.error(`Could not ${r} Plan mode: ${n instanceof Error?n.message:`unknown error`}`)}finally{g(!1)}}let w=o?.provider===`codex`||o?.provider===`traex`,T=o?.collaborationMode===`plan`,E=T?`Exit Plan mode`:`Enter Plan mode`,D=w?(0,H.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,className:X(`h-7 shrink-0 gap-1 px-2 text-[11px] font-medium`,T?`bg-[color-mix(in_srgb,var(--primary)_10%,transparent)] text-[var(--primary)] hover:bg-[color-mix(in_srgb,var(--primary)_14%,transparent)]`:`text-[var(--muted-foreground)] hover:text-[var(--foreground)]`),"aria-label":E,"aria-pressed":T,"data-testid":`session-plan-mode-toggle`,"data-active":T?`true`:void 0,title:E,disabled:h,onClick:()=>void C(),children:[h?(0,H.jsx)(B,{className:`size-3 animate-spin`}):(0,H.jsx)(nr,{className:`size-3`,strokeWidth:1.8}),(0,H.jsx)(`span`,{children:`Plan`})]}):null;return!b&&!D?null:c.length===0||!o?(0,H.jsxs)(H.Fragment,{children:[b?(0,H.jsx)(`span`,{className:`min-w-0 max-w-52 truncate px-2 font-mono text-[10px] text-[var(--muted-foreground)]`,children:b}):null,D]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(xg,{children:[(0,H.jsx)(Sg,{asChild:!0,children:(0,H.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,disabled:x,className:`h-7 min-w-0 max-w-52 justify-start gap-1.5 px-2 font-normal text-[11px] text-[var(--muted-foreground)]`,"aria-label":`Model and thinking effort`,title:t?`Model settings can be changed after the current turn finishes`:`Change model and thinking effort for the next turn`,children:[p?(0,H.jsx)(B,{className:`size-3 animate-spin`}):null,(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:b}),(0,H.jsx)(Fn,{className:`size-3 shrink-0 opacity-55`})]})}),(0,H.jsxs)(Cg,{align:`start`,className:`min-w-56`,children:[(0,H.jsx)(Tg,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:`Model → Thinking effort`}),c.map(e=>{let t=o.model===e.id;return e.reasoningOptions.length===0?(0,H.jsxs)(wg,{onSelect:()=>void S(e.id,null),children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),t&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]},e.id):(0,H.jsxs)(Dg,{children:[(0,H.jsxs)(Og,{children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),t&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]}),(0,H.jsxs)(kg,{children:[(0,H.jsx)(Tg,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:`Thinking effort`}),e.reasoningOptions.map(n=>{let r=t&&o.reasoningEffort===n.value;return(0,H.jsxs)(wg,{onSelect:()=>void S(e.id,n.value),children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.label}),r&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]},n.value)})]})]},e.id)})]})]}),D]})}var Tk=24,Ek={hasOverflow:!1,canScrollLeft:!1,canScrollRight:!1};function Dk({pages:e,order:t,selectedPageId:n,selectionDisabled:r,mutationDisabled:i,createDisabled:a,createPending:o,emulatorAttached:s,emulator:c,onSelectPage:l,onClosePage:d,onCreatePage:f,onSelectEmulator:p,onCloseEmulator:m,onAddEmulator:h,headerLeadingAction:g,settingsAction:_,leadingAction:v,trailingAction:y}){let b=(0,u.useRef)(null),x=(0,u.useRef)(null),S=(0,u.useRef)(null),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)(null),[E,D]=(0,u.useState)(Ek),O=t.flatMap(t=>{if(t===oD())return c?[{type:`emulator`,key:t,emulator:c}]:[];let n=e.find(e=>aD(e.pageId)===t);return n?[{type:`browser`,key:t,page:n}]:[]}),k=O.map(e=>e.key).join(`
|
|
56
|
+
`),A=O.length,j=(0,u.useCallback)(()=>{let e=b.current,t=x.current,n=S.current;if(!(!e||!t||!n))return jO({scrollLeft:t.scrollLeft,viewportWidth:t.clientWidth,contentWidth:n.scrollWidth,availableWidth:e.clientWidth})},[]),M=(0,u.useCallback)(()=>{let e=j();e&&D(t=>Ak(t,e)?t:e)},[j]),N=(0,u.useCallback)(()=>{w.current===null&&(w.current=window.requestAnimationFrame(()=>{w.current=null,M()}))},[M]),P=(0,u.useCallback)(e=>{let t=x.current,n=C.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=NO({scrollLeft:t.scrollLeft,viewportWidth:t.clientWidth,tabLeft:t.scrollLeft+i.left-r.left,tabWidth:i.width,inset:Tk});a!==0&&t.scrollBy({left:a,behavior:e})},[]),F=(0,u.useCallback)(e=>{let t=x.current;if(!t)return;let n=MO(t.clientWidth);t.scrollBy({left:e===`left`?-n:n,behavior:kk()})},[]);(0,u.useEffect)(()=>()=>{w.current!==null&&window.cancelAnimationFrame(w.current)},[]),(0,u.useLayoutEffect)(()=>{let e=b.current,t=x.current,n=S.current;if(!e||!t||!n)return;let r=()=>{let e=t.clientWidth,n=T.current===null||Math.abs(e-T.current)>1;T.current=e,N(),n&&P(`auto`)},i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(r);return i?.observe(e),i?.observe(t),i?.observe(n),window.addEventListener(`resize`,r),M(),()=>{i?.disconnect(),window.removeEventListener(`resize`,r)}},[P,N,M]),(0,u.useEffect)(()=>{let e=x.current;if(!e)return;let t=t=>{if(t.ctrlKey||t.deltaY===0||Math.abs(t.deltaY)<=Math.abs(t.deltaX))return;let n=j();(t.deltaY<0?n?.canScrollLeft:n?.canScrollRight)&&(t.preventDefault(),e.scrollLeft+=t.deltaY,N())};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[j,N]),(0,u.useLayoutEffect)(()=>{P(kk()),N()},[k,P,N,E.hasOverflow,n]);function I(e,t){let n;if(e.key===`ArrowLeft`?n=(t-1+A)%A:e.key===`ArrowRight`?n=(t+1)%A:e.key===`Home`?n=0:e.key===`End`&&(n=A-1),n===void 0||n===t)return;e.preventDefault();let r=S.current?.querySelectorAll(`[role="tab"]`).item(n);r?.focus(),r?.click()}return(0,H.jsxs)(`div`,{className:`desktop-macos-titlebar-header app-drag-region flex h-12 shrink-0 items-end gap-1 border-b border-[var(--border)] bg-[var(--muted)]/30 pl-2 pr-3 pt-1 sm:pr-4`,children:[g&&(0,H.jsx)(`div`,{className:`mb-1 flex h-8 shrink-0 items-center`,children:g}),(0,H.jsxs)(`div`,{ref:b,className:`flex min-w-0 flex-1 items-end gap-1`,children:[E.hasOverflow&&(0,H.jsx)(Ok,{direction:`left`,disabled:!E.canScrollLeft,onClick:()=>F(`left`)}),(0,H.jsx)(`div`,{ref:x,className:`min-w-0 flex-1 overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,style:jk(E),onScroll:N,children:(0,H.jsx)(`div`,{ref:S,className:`flex w-max items-end gap-1`,role:`tablist`,"aria-label":`Session resources`,children:O.map((e,t)=>{if(e.type===`emulator`){let n=e.emulator;return(0,H.jsxs)(`div`,{ref:n.selected?C:void 0,role:`presentation`,className:n.selected?`group flex h-8 w-44 shrink-0 items-center rounded-t-md border border-b-[var(--card)] border-[var(--border)] bg-[var(--card)] px-2`:`group flex h-8 w-44 shrink-0 items-center rounded-t-md border border-transparent px-2 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]`,children:[(0,H.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n.selected,"aria-label":n.label,title:n.label,tabIndex:n.selected?0:-1,onClick:p,onKeyDown:e=>I(e,t),className:`flex min-w-0 flex-1 items-center gap-2 text-left text-xs outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[n.busy?(0,H.jsx)(B,{className:`size-3 shrink-0 animate-spin`}):(0,H.jsx)($r,{className:`size-3 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:n.label})]}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Close emulator tab`,title:`Close emulator tab`,onClick:m,className:`ml-1`,children:(0,H.jsx)(di,{className:`size-3`})})]},e.key)}let a=e.page,o=a.pageId===n,s=a.title||a.url||`New page`;return(0,H.jsxs)(`div`,{ref:o?C:void 0,role:`presentation`,className:o?`group flex h-8 w-44 shrink-0 items-center rounded-t-md border border-b-[var(--card)] border-[var(--border)] bg-[var(--card)] px-2`:`group flex h-8 w-44 shrink-0 items-center rounded-t-md border border-transparent px-2 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]`,children:[(0,H.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":o,"aria-label":s,title:s,tabIndex:o?0:-1,disabled:r,onClick:()=>l(a.pageId),onKeyDown:e=>I(e,t),className:`flex min-w-0 flex-1 items-center gap-2 text-left text-xs outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[a.loading?(0,H.jsx)(B,{className:`size-3 shrink-0 animate-spin`}):(0,H.jsx)(Xn,{className:`size-3 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:s})]}),(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Close ${s}`,title:`Close ${s}`,disabled:i,onClick:()=>d(a.pageId),className:`ml-1`,children:(0,H.jsx)(di,{className:`size-3`})})]},e.key)})})}),E.hasOverflow&&(0,H.jsx)(Ok,{direction:`right`,disabled:!E.canScrollRight,onClick:()=>F(`right`)})]}),(0,H.jsxs)(xg,{children:[(0,H.jsx)(Sg,{asChild:!0,children:(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mb-1 size-8`,"aria-label":`Add Session resource`,title:`Add Session resource`,children:(0,H.jsx)(Ir,{})})}),(0,H.jsxs)(Cg,{align:`end`,children:[(0,H.jsxs)(wg,{disabled:a,"aria-busy":o,onSelect:f,children:[o?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Xn,{}),o?`Creating browser tab…`:`New browser tab`]}),(0,H.jsxs)(wg,{onSelect:h,children:[(0,H.jsx)($r,{}),c||s?`Show emulator`:`Attach emulator`]})]})]}),_&&(0,H.jsx)(`div`,{className:`mb-1 shrink-0`,children:_}),v&&(0,H.jsx)(`div`,{className:`mb-1 shrink-0`,children:v}),y&&(0,H.jsx)(`div`,{className:`mb-1 ml-0.5 shrink-0`,children:y})]})}function Ok({direction:e,disabled:t,onClick:n}){let r=e===`left`?In:Ln;return(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`mb-1 size-7`,"aria-label":`Scroll resource tabs ${e}`,title:`Scroll resource tabs ${e}`,disabled:t,onClick:n,children:(0,H.jsx)(r,{})})}function kk(){return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}function Ak(e,t){return e.hasOverflow===t.hasOverflow&&e.canScrollLeft===t.canScrollLeft&&e.canScrollRight===t.canScrollRight}function jk(e){let t=`${Tk}px`,n;return e.canScrollLeft&&e.canScrollRight?n=`linear-gradient(to right, transparent, #000 ${t}, #000 calc(100% - ${t}), transparent)`:e.canScrollLeft?n=`linear-gradient(to right, transparent, #000 ${t}, #000 100%)`:e.canScrollRight&&(n=`linear-gradient(to right, #000 0, #000 calc(100% - ${t}), transparent)`),n?{WebkitMaskImage:n,maskImage:n}:void 0}var Mk=8,Nk=4e3;function Pk({sessionId:e,runtimeSelector:t,controller:n,readOnly:r=!1}){return n.binding?(0,H.jsx)(Ik,{sessionId:e,runtimeSelector:t,binding:n.binding,controller:n,readOnly:r}):r?(0,H.jsx)(zk,{icon:(0,H.jsx)(xr,{className:`size-5`}),label:`No Emulator is attached.`}):(0,H.jsx)(Fk,{controller:n})}function Fk({controller:e}){let[t,n]=(0,u.useState)(null),r=async t=>{n(t);try{await e.attach(t)}catch(e){V.error(`Could not attach Emulator: ${e.message}`)}finally{n(null)}};return(0,H.jsx)(U_,{className:`min-h-0 flex-1`,children:(0,H.jsx)(`div`,{className:`p-4 sm:p-5`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,H.jsxs)(`div`,{className:`mb-4 flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Attach an Emulator`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:`Only devices available to this Session are shown. Attaching does not affect another Session.`})]}),(0,H.jsx)(J,{variant:`ghost`,size:`icon-sm`,onClick:()=>void e.reloadDevices(),title:`Refresh devices`,"aria-label":`Refresh devices`,children:(0,H.jsx)(zr,{className:X(`size-4`,e.devicesLoading&&`animate-spin`)})})]}),e.error&&(0,H.jsx)(`div`,{className:`mb-3 rounded-md border border-[var(--destructive)]/30 bg-[var(--destructive)]/5 px-3 py-2 text-xs text-[var(--destructive)]`,children:e.error.message}),e.devicesLoading&&e.devices.length===0?(0,H.jsx)(`div`,{className:`grid min-h-40 place-items-center`,"aria-live":`polite`,children:(0,H.jsx)(zk,{icon:(0,H.jsx)(B,{className:`size-5 animate-spin`}),label:`Loading devices…`})}):e.devices.length===0?(0,H.jsxs)(`div`,{className:`rounded-md border border-dashed border-[var(--border)] px-5 py-10 text-center`,children:[(0,H.jsx)(xr,{className:`mx-auto mb-3 size-6 text-[var(--muted-foreground)]`}),(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`No Emulator is available`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:`Boot a simulator on this Runtime, or release one from another Session.`})]}):(0,H.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:e.devices.map(n=>(0,H.jsxs)(`button`,{type:`button`,disabled:e.mutating,onClick:()=>void r(n.id),className:`group flex min-h-20 items-center gap-3 rounded-md border border-[var(--border)] bg-[var(--card)] p-3 text-left transition-colors hover:border-[var(--primary)]/50 hover:bg-[var(--primary)]/[0.03] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] disabled:opacity-60`,children:[(0,H.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-md bg-[var(--primary)]/10 text-[var(--primary)]`,children:t===n.id?(0,H.jsx)(B,{className:`size-4 animate-spin`}):(0,H.jsx)(xr,{className:`size-4`})}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:n.name}),(0,H.jsxs)(`span`,{className:`mt-1 flex items-center gap-2`,children:[(0,H.jsx)(Rk,{state:n.state}),(0,H.jsx)(`span`,{className:`font-mono text-[9px] uppercase text-[var(--muted-foreground)]`,children:n.backend})]})]})]},`${n.backend}:${n.id}`))})]})})})}function Ik({sessionId:e,runtimeSelector:t,binding:n,controller:r,readOnly:i}){let[a,o]=(0,u.useState)(null),[s,c]=(0,u.useState)(!1),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(null),m=(0,u.useRef)(null),h=(0,u.useRef)(null),g=(0,u.useRef)(null),_=(0,u.useRef)(null),v=(0,u.useRef)(null);(0,u.useEffect)(()=>{o(null),c(!1),p(null),d(null);let r=!1,i,a,s=0,l=0,u=!1,f=null,m,g=`png`,_=()=>{a!==void 0&&window.clearTimeout(a),a=void 0,d(null)},v=(e,t=!1)=>{if(a!==void 0&&window.clearTimeout(a),t||f===null){d(e);return}a=window.setTimeout(()=>{a=void 0,r||d(e)},Nk)},y=e=>{if(r)return;let t=URL.createObjectURL(e),n=f;f=t,o(t),_(),s=0,u=!1,n&&window.setTimeout(()=>URL.revokeObjectURL(n),1e3)},b=(e,t=!1)=>{if(r)return;i!==void 0&&window.clearTimeout(i);let n=t?0:Math.min(8e3,500*2**s++);i=window.setTimeout(()=>void e(t),n)},x=async(i=!1)=>{let a=++l;try{let o=await Qx(i);if(r||a!==l)return;let s=new WebSocket(Lk({runtimeSelector:t,sessionId:e,bindingId:n.bindingId,maximumFrameRate:n.backend===`ios`?30:5,capability:o}));m=s,s.binaryType=`arraybuffer`,s.onmessage=e=>{if(r||a!==l||m!==s)return;if(typeof e.data==`string`){try{let t=JSON.parse(e.data);if(t.type!==`emulator.surface.ready`||typeof t.surfaceId!=`string`||t.format!==`png`&&t.format!==`jpeg`)throw Error(`invalid Emulator Surface ready frame`);g=t.format,h.current={socket:s,surfaceId:t.surfaceId,inputSequence:0}}catch{s.close(4400,`invalid Emulator Surface ready frame`)}return}let t=e.data instanceof ArrayBuffer||e.data instanceof Blob?e.data:null,n=g===`jpeg`?`image/jpeg`:`image/png`;(t instanceof Blob||t)&&y(new Blob([t],{type:n}))},s.onclose=e=>{if(r||a!==l||m!==s)return;h.current?.socket===s&&(h.current=null);let t=Error(e.code===4406?`emulator_surface_upgrade_required`:e.reason||`Remote Emulator Surface disconnected`);v(t,e.code===4406),e.code!==4406&&((e.code===4403||e.code===1006)&&!u?(u=!0,b(x,!0)):b(x))},s.onerror=()=>void 0}catch(e){if(r||a!==l)return;v(e instanceof Error?e:Error(String(e))),b(x)}};return x(),()=>{r=!0,l+=1,h.current=null,m?.close(1e3,`Session Emulator pane closed`),i!==void 0&&window.clearTimeout(i),a!==void 0&&window.clearTimeout(a),f&&URL.revokeObjectURL(f)}},[n.backend,n.bindingId,t,e]);let y=(0,u.useCallback)((e,t,n)=>{let r=h.current;if(!r||r.socket.readyState!==WebSocket.OPEN||n!==void 0&&r.surfaceId!==n)return!1;try{return r.socket.send(JSON.stringify({type:`emulator.surface.touch`,surfaceId:r.surfaceId,inputSequence:r.inputSequence++,phase:e,...t})),!0}catch{return!1}},[]),b=(0,u.useCallback)(()=>{_.current!==null&&window.cancelAnimationFrame(_.current),_.current=null;let e=g.current;g.current=null,e&&y(`move`,e,e.surfaceId)},[y]),x=(0,u.useCallback)(e=>{let t=m.current;if(!t)return null;let n=t.getBoundingClientRect();return n.width<=0||n.height<=0?null:{x:Math.max(0,Math.min(1,(e.clientX-n.left)/n.width)),y:Math.max(0,Math.min(1,(e.clientY-n.top)/n.height))}},[]),S=e=>{if(r.mutating)return;let t=x(e.nativeEvent);if(!t)return;e.currentTarget.setPointerCapture(e.pointerId);let n=h.current?.surfaceId??null,i=n!==null&&y(`begin`,t,n);v.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,lastPoint:t,points:[{type:`begin`,...t}],live:i,surfaceId:i?n:null}},C=e=>{let t=v.current;if(!t||t.pointerId!==e.pointerId)return;let n=x(e.nativeEvent);n&&t.live?(t.lastPoint=n,g.current=t.surfaceId?{...n,surfaceId:t.surfaceId}:null,_.current===null&&(_.current=window.requestAnimationFrame(()=>b()))):n&&t.points.length<255&&(t.lastPoint=n,t.points.push({type:`move`,...n}))},w=e=>{let t=v.current;if(v.current=null,!t||t.pointerId!==e.pointerId)return;let n=x(e.nativeEvent);if(n){if(t.live){b(),t.surfaceId&&y(`end`,n,t.surfaceId);return}(Math.hypot(e.clientX-t.startX,e.clientY-t.startY)>Mk?r.gesture([...t.points,{type:`end`,...n}]):r.tap(n.x,n.y)).catch(e=>V.error(`Emulator input failed: ${e.message}`))}},T=async()=>{try{await r.detach()}catch(e){V.error(`Could not detach Emulator: ${e.message}`)}};return(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-[var(--background)]`,children:[(0,H.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between gap-3 border-b border-[var(--border)] px-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-xs font-medium`,children:n.deviceName??n.deviceId}),(0,H.jsx)(Rk,{state:n.deviceState}),!n.available&&(0,H.jsx)(MC,{variant:`outline`,children:`Unavailable`}),l&&a&&(0,H.jsxs)(MC,{variant:`outline`,className:`gap-1 border-[var(--warning)]/30 font-mono text-[8px] uppercase text-[var(--warning)]`,children:[(0,H.jsx)(B,{className:`size-2.5 animate-spin`}),`Reconnecting`]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsx)(J,{variant:`ghost`,size:`icon-sm`,disabled:!n.available||r.mutating,title:`Home`,"aria-label":`Home`,onClick:()=>void r.button(`home`).catch(e=>V.error(`Home failed: ${e.message}`)),children:(0,H.jsx)(dr,{})}),(0,H.jsxs)(J,{variant:`ghost`,size:`sm`,disabled:r.mutating,title:`Detach from this session`,onClick:()=>void T(),children:[r.mutating?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(li,{}),`Detach`]})]})]}),(0,H.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3`,children:[!s&&!l&&(0,H.jsx)(`div`,{className:`absolute inset-0 z-10 grid place-items-center bg-[var(--background)]`,children:(0,H.jsx)(zk,{icon:(0,H.jsx)(B,{className:`size-5 animate-spin`}),label:`Connecting to Emulator…`})}),l&&!a&&(0,H.jsxs)(`div`,{className:`max-w-sm text-center`,children:[(0,H.jsx)(xr,{className:`mx-auto mb-3 size-7 text-[var(--muted-foreground)]`}),(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:t===`local`?`Preview is unavailable`:`Remote Emulator Surface is unavailable`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-foreground)]`,children:l.message===`emulator_surface_upgrade_required`?`Upgrade the selected Runtime daemon to a version with Emulator Surface support.`:l.message})]}),a&&(0,H.jsx)(`img`,{ref:m,src:a,alt:n.deviceName??n.deviceId,draggable:!1,onLoad:e=>{p({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight}),c(!0)},onPointerDown:i?void 0:S,onPointerMove:i?void 0:C,onPointerUp:i?void 0:w,onPointerCancel:i?void 0:()=>{let e=v.current;v.current=null,e?.live&&(b(),e.surfaceId&&y(`end`,e.lastPoint,e.surfaceId))},className:`max-h-full max-w-full touch-none select-none rounded-md bg-black object-contain shadow-[var(--shadow-md)]`,style:f?{aspectRatio:`${f.width} / ${f.height}`}:void 0})]})]})}function Lk(e){let t=location.protocol===`https:`?`wss`:`ws`,n=new URLSearchParams({bindingId:e.bindingId,maximumFrameRate:String(e.maximumFrameRate),capability:e.capability});return Vx(n),`${t}://${location.host}/api/runtimes/${encodeURIComponent(e.runtimeSelector)}/sessions/${encodeURIComponent(e.sessionId)}/emulator/surface?${n.toString()}`}function Rk({state:e}){return(0,H.jsxs)(MC,{variant:`outline`,className:X(`gap-1 px-1.5 py-0 font-mono text-[8px] uppercase`,e===`booted`&&`border-[var(--success)]/30 text-[var(--success)]`,e===`shutdown`&&`text-[var(--muted-foreground)]`),children:[(0,H.jsx)(`span`,{className:X(`size-1 rounded-full bg-current`,e===`booted`&&`animate-pulse`)}),e]})}function zk({icon:e,label:t}){return(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-2 text-[var(--muted-foreground)]`,children:[e,(0,H.jsx)(`span`,{className:`text-xs`,children:t})]})}var Bk=`Collapsible`,[Vk,Hk]=Wi(Bk),[Uk,Wk]=Vk(Bk),Gk=u.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=ea({prop:r,defaultProp:i??!1,onChange:o,caller:Bk});return(0,H.jsx)(Uk,{scope:n,disabled:a,contentId:Qi(),open:c,onOpenToggle:u.useCallback(()=>l(e=>!e),[l]),children:(0,H.jsx)(W.div,{"data-state":Zk(c),"data-disabled":a?``:void 0,...s,ref:t})})});Gk.displayName=Bk;var Kk=`CollapsibleTrigger`,qk=u.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=Wk(Kk,n);return(0,H.jsx)(W.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":Zk(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:U(e.onClick,i.onOpenToggle)})});qk.displayName=Kk;var Jk=`CollapsibleContent`,Yk=u.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Wk(Jk,e.__scopeCollapsible);return(0,H.jsx)(Qa,{present:n||i.open,children:({present:e})=>(0,H.jsx)(Xk,{...r,ref:t,present:e})})});Yk.displayName=Jk;var Xk=u.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=Wk(Jk,n),[s,c]=u.useState(r),l=u.useRef(null),d=Ji(t,l),f=u.useRef(0),p=f.current,m=u.useRef(0),h=m.current,g=o.open||s,_=u.useRef(g),v=u.useRef(void 0);return u.useEffect(()=>{let e=requestAnimationFrame(()=>_.current=!1);return()=>cancelAnimationFrame(e)},[]),Yi(()=>{let e=l.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();f.current=t.height,m.current=t.width,_.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),c(r)}},[o.open,r]),(0,H.jsx)(W.div,{"data-state":Zk(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!g,...a,ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":h?`${h}px`:void 0,...e.style},children:g&&i})});function Zk(e){return e?`open`:`closed`}var Qk=Gk,$k=qk,eA=Yk,tA=Qk,nA=$k,rA=eA;function iA({status:e}){return e===`completed`?(0,H.jsx)(Pn,{className:`size-3 shrink-0 text-[var(--success)]`}):e===`in_progress`?(0,H.jsx)(B,{className:`size-3 shrink-0 animate-spin text-[var(--primary)]`}):(0,H.jsx)(Kn,{className:`size-3 shrink-0 text-[var(--muted-foreground)]`})}function aA({todos:e}){let[t,n]=(0,u.useState)(!0);if(e.length===0)return null;let r=e.filter(e=>e.status===`completed`).length;return(0,H.jsxs)(tA,{open:t,onOpenChange:n,className:`mx-auto mt-2 w-[calc(100%-2rem)] max-w-3xl rounded-md border border-[var(--border)] bg-[var(--muted)]/30`,children:[(0,H.jsxs)(nA,{className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs`,children:[(0,H.jsx)(Ln,{className:X(`size-3 shrink-0 text-[var(--muted-foreground)] transition-transform`,t&&`rotate-90`)}),(0,H.jsx)(`span`,{className:`label-caps text-[var(--muted-foreground)]`,children:`Tasks`}),(0,H.jsxs)(`span`,{className:`font-mono text-[var(--muted-foreground)]`,children:[r,`/`,e.length]})]}),(0,H.jsx)(rA,{className:`overflow-hidden px-3 pb-2`,children:(0,H.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,H.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,H.jsx)(iA,{status:e.status}),(0,H.jsx)(`span`,{className:X(`truncate`,e.status===`completed`&&`text-[var(--muted-foreground)] line-through`),children:e.subject})]},e.id))})})]})}function oA({item:e}){return(0,H.jsxs)(`div`,{className:`my-1 flex items-center gap-2 px-1 py-1 text-sm italic text-[var(--muted-foreground)]`,children:[(0,H.jsx)(Qr,{className:`size-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:e.status===`in_progress`?`animate-pulse`:void 0,children:e.status===`in_progress`?`Compacting conversation…`:`Conversation compacted`})]})}function sA({open:e,src:t,alt:n,onOpenChange:r}){return(0,H.jsx)(Su,{open:e,onOpenChange:r,children:(0,H.jsxs)(Du,{showCloseButton:!1,"aria-describedby":void 0,className:`inset-0 left-0 top-0 h-dvh max-h-none w-screen max-w-none translate-x-0 translate-y-0 place-items-center gap-0 rounded-none bg-black/80 p-4 text-white ring-0 sm:max-w-none`,onClick:()=>r(!1),children:[(0,H.jsx)(Au,{className:`sr-only`,children:n}),(0,H.jsxs)(`div`,{className:`absolute right-4 top-4 z-10 flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,H.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`grid size-9 place-items-center rounded-full bg-black/60 text-white transition-colors hover:bg-black/75 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white`,"aria-label":`Open original image`,children:(0,H.jsx)(er,{className:`size-4`})}),(0,H.jsx)(Tu,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:`grid size-9 place-items-center rounded-full bg-black/60 text-white transition-colors hover:bg-black/75 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white`,"aria-label":`Close image preview`,children:(0,H.jsx)(di,{className:`size-5`})})})]}),(0,H.jsx)(`img`,{src:t,alt:n,className:`block h-auto max-h-[calc(100dvh-2rem)] min-h-0 w-auto max-w-[calc(100vw-2rem)] min-w-0 rounded-md object-contain shadow-2xl`,onClick:e=>e.stopPropagation()})]})})}function cA(e,t,n){let[r,i]=(0,u.useState)(e),a=(0,u.useRef)(0),o=(0,u.useRef)(0),s=(0,u.useRef)(e);return s.current=e,(0,u.useEffect)(()=>{if(!n){window.clearTimeout(o.current),o.current=0,a.current=0,i(e);return}if(Object.is(r,e))return;let c=Date.now()-a.current;if(a.current===0||c>=t){window.clearTimeout(o.current),o.current=0,a.current=Date.now(),i(e);return}o.current===0&&(o.current=window.setTimeout(()=>{o.current=0,a.current=Date.now(),i(s.current)},t-c))},[n,t,r,e]),(0,u.useEffect)(()=>()=>{window.clearTimeout(o.current)},[]),n?r:e}var lA=/^\$(?:\{[A-Z_][A-Z0-9_]*\}|[A-Z_][A-Z0-9_]+(?![A-Za-z0-9_]))/,uA=/^ {0,3}(`{3,}|~{3,})/;function dA(e){let t=``,n=``,r=0,i=!1;for(let a=0;a<e.length;a+=1){let o=e[a],s=a===0||e[a-1]===`
|
|
57
|
+
`;if(!r&&s){let r=e.slice(a).match(uA);if(r){let e=r[1];n?e[0]===n[0]&&e.length>=n.length&&(n=``):n=e,t+=r[0],a+=r[0].length-1;continue}}if(n){t+=o;continue}if(o==="`"){let n=1;for(;e[a+n]==="`";)n+=1;r===0?r=n:n===r&&(r=0),t+=e.slice(a,a+n),a+=n-1;continue}if(r){t+=o;continue}if(o===`\\`&&(e[a+1]===`\\`||e[a+1]===`$`)){t+=e.slice(a,a+2),a+=1;continue}if(o===`$`){let n=1;for(;e[a+n]===`$`;)n+=1;if(n===1&&!i&&(/\d/.test(e[a+1]??``)||lA.test(e.slice(a)))){t+=`\\$`;continue}i=!i,t+=e.slice(a,a+n),a+=n-1;continue}if(!i){let n=e.slice(a,a+2);if(n===`\\(`||n===`\\)`){t+=`$`,a+=1;continue}if(n===`\\[`||n===`\\]`){t+=`$$`,a+=1;continue}}t+=o}return t}var fA=/:\d+(?::\d+)?$/,pA=/^[a-z][a-z\d+.-]*:/i;function mA(e,t){let n;try{n=decodeURI(e).replace(fA,``)}catch{return null}if(!n||n.includes(`\0`)||n.includes(`
|
|
58
|
+
`)||n.includes(`\r`)||n.includes(`?`)||n.includes(`#`)||pA.test(n)||n.startsWith(`//`))return null;if(n.startsWith(`/`)||t)return n;let r=n.indexOf(`/`);return r>0&&!/\s/.test(n.slice(0,r))?n:null}var hA=`data-rynx-workspace-image`,gA=`/__rynx_workspace_image__`,_A=(0,u.lazy)(()=>g(()=>import(`./markdown-streamdown-4N4AcNp5.js`).then(e=>({default:e.MarkdownStreamdown})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]))),vA=100,yA=5e4,bA=5e3,xA=2e5,SA=X(`min-w-0 wrap-anywhere text-sm leading-relaxed`,`[&_p]:my-1.5 [&_ul]:my-1.5 [&_ol]:my-1.5 [&_li]:my-0.5`,`[&_pre]:my-2 [&_pre]:rounded-md [&_pre]:text-xs`,`[&_code]:font-mono [&_h1]:mt-3 [&_h2]:mt-3 [&_h3]:mt-2`,`[&_a]:text-[var(--primary)] [&_a]:underline [&_a]:underline-offset-2`);function CA(e){let t=0,n=0;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);i===32||i>=9&&i<=13?n=0:(n+=1,n>t&&(t=n))}return t}function wA(e){return e.length>yA||CA(e)>bA}function TA({text:e,className:t}){let n=e.length>xA,r=n?e.slice(0,xA):e;return(0,H.jsxs)(`div`,{className:X(`whitespace-pre-wrap break-all font-mono text-sm`,t),children:[r,n&&(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:`\n… [${e.length-xA} more characters not shown]`})]})}var EA=(0,u.createContext)(null),DA=`wrap-anywhere font-medium text-[var(--primary)] underline`;function OA(e){let t=(0,u.useContext)(EA),n=(0,u.useMemo)(()=>t&&e?Y.sessionWorkspaceFileContentUrl(t.runtimeSelector,t.sessionId,e):null,[e,t]),[r,i]=(0,u.useState)(null);return(0,u.useEffect)(()=>{if(i(null),!n)return;let e=new AbortController;return fetch(n,{method:`HEAD`,signal:e.signal}).then(e=>{e.ok&&i(n)}).catch(()=>void 0),()=>e.abort()},[n]),r}function kA({href:e,children:t,className:n,title:r,node:i,...a}){let o=typeof e==`string`?mA(e,!0):null,s=OA(o),[c,l]=(0,u.useState)(!1);return o?s?(0,H.jsx)(`a`,{...a,href:s,target:`_blank`,rel:`noreferrer`,title:r??o,"data-streamdown":`link`,className:X(DA,`decoration-dotted underline-offset-2`,n),children:t}):(0,H.jsx)(`span`,{title:r??o,children:t}):e?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,className:X(`wrap-anywhere appearance-none text-left font-medium text-[var(--primary)] underline`,n),"data-streamdown":`link`,onClick:()=>l(!0),children:t}),(0,H.jsx)(Bw,{open:c,url:e,onOpenChange:l,onConfirm:()=>window.open(e,`_blank`,`noreferrer`)})]}):(0,H.jsx)(`span`,{className:n,children:t})}function AA({children:e,className:t,node:n,...r}){let i=OA(mA(typeof e==`string`?e:``,!1));if(!i)return(0,H.jsx)(`code`,{...r,className:X(`rounded bg-[var(--muted)] px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,children:e});let a=()=>window.open(i,`_blank`,`noreferrer`);return(0,H.jsx)(`code`,{...r,role:`link`,tabIndex:0,className:X(`cursor-pointer font-mono underline decoration-dotted underline-offset-2 transition-colors hover:text-[var(--foreground)]`,t),"data-streamdown":`inline-code`,onClick:a,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},children:e})}function jA({src:e,alt:t=``,className:n,node:r,...i}){let a=i[hA],o=typeof a==`string`?mA(a,!0):null,s=OA(o),[c,l]=(0,u.useState)(!1),[d,f]=(0,u.useState)(!1);if((0,u.useEffect)(()=>f(!1),[s]),!o||!s)return(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:t||`Image unavailable`});if(d)return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[var(--muted-foreground)]`,children:[(0,H.jsx)(fr,{className:`size-4`,"aria-hidden":`true`}),t||`Image unavailable`]});let p={...i};return delete p[hA],(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,className:`group my-2 block max-w-full overflow-hidden rounded-md text-left focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ring)]`,"aria-label":`Open ${t||`image`}`,onClick:()=>l(!0),children:(0,H.jsx)(`img`,{...p,src:s,alt:t,loading:`lazy`,className:X(`block h-auto max-h-80 max-w-full rounded-md object-contain transition-opacity group-hover:opacity-90`,n),onError:()=>f(!0)})}),(0,H.jsx)(sA,{open:c,src:s,alt:t||`Markdown image`,onOpenChange:l})]})}var MA={a:kA,inlineCode:AA,img:jA};function NA({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,H.jsx)(Bw,{open:e,url:r,onOpenChange:e=>{e||t()},onConfirm:n})}function PA({children:e,className:t,workspaceFiles:n,breaks:r=!1,streaming:i=!1}){let a=(0,u.useMemo)(()=>n?{runtimeSelector:n.runtimeSelector,sessionId:n.sessionId}:null,[n?.runtimeSelector,n?.sessionId]),o=(0,u.useMemo)(()=>wA(e),[e]),s=cA((0,u.useMemo)(()=>o?e:dA(e),[e,o]),vA,i);return o?(0,H.jsx)(TA,{text:e,className:t}):(0,H.jsx)(u.Suspense,{fallback:(0,H.jsx)(`div`,{className:X(`whitespace-pre-wrap break-words text-sm`,t),children:s}),children:(0,H.jsx)(EA.Provider,{value:a,children:(0,H.jsx)(_A,{breaks:r,shikiTheme:[`github-light`,`github-dark`],linkSafety:{enabled:!0,renderModal:NA},components:MA,className:X(SA,t),children:s})})})}function FA(e,t,n={},r={},i=!0){let a={},o={};for(let s of e){if(s.type===`text`){let e=typeof t[s.id]==`string`?t[s.id]:``;i&&s.required&&!e.trim()?o[s.id]=`${s.label} is required`:e.length>0&&(a[s.id]=e);continue}let e=new Set(s.options.map(e=>e.value)),c=s.allowOther===!0&&r[s.id]===!0,l=c?(n[s.id]??``).trim():``;if(s.multiple){let e=Array.isArray(t[s.id])?t[s.id]:[],n=s.options.map(e=>e.value).filter(t=>e.includes(t));l&&!n.includes(l)&&n.push(l),i&&c&&!l?o[s.id]=`${s.label}: enter a value for Other`:i&&s.required&&n.length===0?o[s.id]=`${s.label} is required`:n.length>0&&(a[s.id]=n);continue}let u=typeof t[s.id]==`string`?t[s.id]:``,d=c?l:e.has(u)?u:``;i&&c&&!l?o[s.id]=`${s.label}: enter a value for Other`:i&&s.required&&!d?o[s.id]=`${s.label} is required`:d&&(a[s.id]=d)}return Object.keys(o).length>0?{ok:!1,errors:o}:{ok:!0,answers:a}}function IA({sessionId:e,item:t,canResolve:n=!0}){let{runtimeSelector:r}=xS(),i=(0,u.useId)().replaceAll(`:`,``),[a,o]=(0,u.useState)({}),[s,c]=(0,u.useState)({}),[l,d]=(0,u.useState)({}),[f,p]=(0,u.useState)({}),[m,h]=(0,u.useState)(()=>t.request.fields[0]?.id),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(),b=t.status===`pending`;function x(e){p(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})}function S(e,t){o(n=>({...n,[e]:t})),x(e)}function C(e,t){d(n=>({...n,[e]:t})),x(e)}function w(e){let n=t.request.fields,r=Math.max(n.findIndex(e=>e.id===m),0),i=n.findIndex(t=>t.id===e);if(!(i<0)){if(i>r){let e=n[r];if(e){let t=FA([e],a,s,l);if(!t.ok){p(e=>({...e,...t.errors}));return}x(e.id)}}h(e)}}async function T(i){if(!n)return;let o=FA(t.request.fields,a,s,l,i.requiresAnswers);if(!o.ok){p(o.errors);let e=t.request.fields.find(e=>o.errors[e.id]);e&&h(e.id);return}p({}),_(void 0),y(i.id);try{await Yx(e,t.id,{actionId:i.id,...Object.keys(o.answers).length>0?{answers:o.answers}:{}},r)}catch(e){y(void 0),_(e instanceof Error?e.message:String(e))}}let E=t.request.kind===`permission`?Jr:t.request.kind===`form`?vr:Hn,D=Math.max(t.request.fields.findIndex(e=>e.id===m),0),O=t.request.fields.length===0||D===t.request.fields.length-1,k=t.request.actions.filter(e=>!e.requiresAnswers||O),A=t.request.context?.toolName===`ExitPlanMode`&&!!t.request.context.summary;return(0,H.jsxs)(`section`,{"aria-labelledby":`${i}-title`,"aria-busy":v!==void 0,className:X(`min-w-0 max-w-full overflow-hidden rounded-lg border p-3 text-xs shadow-sm`,t.request.kind===`permission`?`border-[var(--warning)]/40 bg-[var(--warning)]/5`:`border-[var(--primary)]/30 bg-[var(--primary)]/5`),children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(E,{"aria-hidden":`true`,className:X(`mt-0.5 size-4 shrink-0`,t.request.kind===`permission`?`text-[var(--warning)]`:`text-[var(--primary)]`)}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{id:`${i}-title`,className:`font-medium text-[var(--foreground)]`,children:t.request.title}),t.request.description&&(0,H.jsx)(`p`,{className:`mt-1 leading-relaxed text-[var(--muted-foreground)]`,children:t.request.description})]})]}),(0,H.jsx)(RA,{item:t}),b&&!n?(0,H.jsx)(`div`,{role:`status`,className:`mt-3 text-[var(--muted-foreground)]`,children:`Pending interaction · resolve it on the owning Runtime.`}):b?(0,H.jsxs)(`div`,{className:`mt-3 grid min-w-0 gap-3`,children:[A?(0,H.jsx)(LA,{plan:t.request.context.summary,actions:t.request.actions,feedback:typeof a.feedback==`string`?a.feedback:``,busyActionId:v,onFeedback:e=>S(`feedback`,e),onSubmit:e=>void T(e)}):(0,H.jsx)(Mg,{idPrefix:i,fields:t.request.fields,activeFieldId:m,answers:a,otherValues:s,otherSelections:l,errors:f,disabled:v!==void 0,onNavigate:w,onAnswerChange:S,onOtherSelectionChange:C,onOtherValueChange:(e,t)=>{c(n=>({...n,[e]:t})),x(e)}}),g&&(0,H.jsxs)(`p`,{role:`alert`,className:`text-[var(--destructive)]`,children:[`Could not submit: `,g]}),!A&&(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[k.map(e=>(0,H.jsxs)(J,{type:`button`,size:`sm`,variant:VA(e),className:`h-auto max-w-full whitespace-normal break-words py-1.5 text-left`,disabled:v!==void 0,title:e.description,"aria-label":e.description?`${e.label}. ${e.description}`:void 0,onClick:()=>void T(e),children:[v===e.id&&(0,H.jsx)(B,{"aria-hidden":`true`,className:`animate-spin`}),e.label]},e.id)),v&&(0,H.jsxs)(`span`,{role:`status`,className:`text-[var(--muted-foreground)]`,children:[`Submitting `,t.request.actions.find(e=>e.id===v)?.label,`…`]})]})]}):(0,H.jsx)(BA,{item:t})]})}function LA({plan:e,actions:t,feedback:n,busyActionId:r,onFeedback:i,onSubmit:a}){let[o,s]=(0,u.useState)(!1),c=e=>t.find(t=>t.id===e),l=e=>{let t=c(e);t&&a(t)};return(0,H.jsxs)(`div`,{className:`grid min-w-0 gap-3`,"data-testid":`exit-plan-mode-review`,children:[(0,H.jsx)(`p`,{className:`text-[var(--muted-foreground)]`,children:`Claude finished planning and wants to proceed.`}),(0,H.jsx)(`div`,{className:`rounded-md border bg-[var(--background)]/60 p-3`,children:(0,H.jsx)(PA,{className:`[&>:first-child]:mt-0 [&>:last-child]:mb-0`,children:e})}),o?(0,H.jsxs)(`div`,{className:`grid gap-2`,"data-testid":`exit-plan-mode-feedback`,children:[(0,H.jsx)(jg,{autoFocus:!0,className:`min-h-20 text-xs`,placeholder:`What should change about the plan? (optional)`,value:n,disabled:r!==void 0,onChange:e=>i(e.target.value)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsxs)(J,{size:`sm`,disabled:r!==void 0,onClick:()=>l(`deny_feedback`),children:[r===`deny_feedback`?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(di,{}),`Reject plan`]}),(0,H.jsx)(J,{size:`sm`,variant:`ghost`,disabled:r!==void 0,onClick:()=>s(!1),children:`Cancel`})]})]}):(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsxs)(J,{size:`sm`,disabled:r!==void 0,onClick:()=>l(`allow_auto`),children:[r===`allow_auto`?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(fi,{}),`Yes, and use auto mode`]}),(0,H.jsxs)(J,{size:`sm`,variant:`outline`,disabled:r!==void 0,onClick:()=>l(`allow_manual`),children:[r===`allow_manual`?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Pn,{}),`Yes, manually approve edits`]}),(0,H.jsxs)(J,{size:`sm`,variant:`outline`,disabled:r!==void 0,onClick:()=>s(!0),children:[(0,H.jsx)(di,{}),` Reject with feedback`]})]})]})}function RA({item:e}){let t=e.request.context;return!t||t.toolName===`ExitPlanMode`?null:(0,H.jsxs)(`div`,{className:`mt-3 grid min-w-0 gap-1.5`,children:[t.summary&&(0,H.jsx)(`p`,{className:`break-words leading-relaxed text-[var(--muted-foreground)]`,children:t.summary}),t.toolName&&(0,H.jsxs)(`div`,{className:`font-mono text-[10px] text-[var(--muted-foreground)]`,children:[`tool · `,t.toolName]}),t.command&&(0,H.jsx)(zA,{value:t.command}),t.cwd&&(0,H.jsx)(`div`,{className:`min-w-0 whitespace-pre-wrap break-all font-mono text-[10px] text-[var(--muted-foreground)]`,children:t.cwd}),t.diff&&(0,H.jsx)(zA,{value:t.diff,tall:!0})]})}function zA({value:e,tall:t=!1}){return(0,H.jsx)(`pre`,{className:X(`min-w-0 max-w-full overflow-auto whitespace-pre-wrap [overflow-wrap:anywhere] rounded-md bg-[var(--muted)] p-2 font-mono text-[11px] leading-relaxed`,t?`max-h-56`:`max-h-32`),children:(0,H.jsx)(`code`,{className:`block min-w-0`,children:e})})}function BA({item:e}){if(e.status!==`resolved`){let t=e.status===`expired`?`Expired`:e.status===`inactive`?`No longer active`:`Cancelled`;return(0,H.jsxs)(`div`,{role:`status`,className:`mt-3 text-[var(--muted-foreground)]`,children:[t,e.reason?` · ${e.reason}`:``]})}let t=e.request.actions.find(t=>t.id===e.resolution?.actionId),n=e.request.fields.flatMap(t=>{let n=e.resolution?.answers?.[t.id];if(n===void 0)return[];let r=t.type===`text`&&t.secret?`••••••••`:Array.isArray(n)?n.join(`, `):n;return[{id:t.id,label:t.label,value:r}]});return(0,H.jsxs)(`div`,{"aria-live":`polite`,className:`mt-3 grid gap-1.5 text-[var(--muted-foreground)]`,children:[(0,H.jsxs)(`div`,{children:[`Resolved · `,t?.label??e.resolution?.actionId??`answered`]}),n.map(e=>(0,H.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-2 text-[11px]`,children:[(0,H.jsx)(`span`,{children:e.label}),(0,H.jsx)(`span`,{className:`break-words text-[var(--foreground)]`,children:e.value})]},e.id))]})}function VA(e){return e.style===`primary`?`default`:e.style===`danger`?`destructive`:`outline`}function HA({item:e}){let t=e.rotateKind===`fork`?cr:Qn;return(0,H.jsxs)(`div`,{className:`my-2 flex items-center gap-2 text-[10px] text-[var(--muted-foreground)]`,children:[(0,H.jsx)(`div`,{className:`h-px flex-1 bg-[var(--border)]`}),(0,H.jsx)(t,{className:`size-3 shrink-0 text-[var(--primary)]`}),(0,H.jsx)(`span`,{className:`label-caps`,children:e.label}),(0,H.jsx)(`span`,{className:`font-mono opacity-70`,children:e.newSessionId.slice(0,12)}),(0,H.jsx)(`div`,{className:`h-px flex-1 bg-[var(--border)]`})]})}function UA({item:e}){return e.code===`response_stopped`?(0,H.jsxs)(`div`,{className:`my-1 flex items-center gap-2 px-1 py-1 text-xs text-[var(--muted-foreground)]`,children:[(0,H.jsx)(Wn,{className:`size-3.5 shrink-0`}),(0,H.jsx)(`span`,{children:`Response stopped`})]}):(0,H.jsxs)(`div`,{className:`my-1 flex gap-2 rounded-md border border-[var(--destructive)]/40 bg-[var(--destructive)]/5 px-3 py-2 text-sm`,children:[(0,H.jsx)(ci,{className:`size-4 shrink-0 text-[var(--destructive)]`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`label-caps text-[10px] text-[var(--destructive)]`,children:[e.source,` error · `,e.code]}),(0,H.jsx)(`div`,{className:`mt-0.5 whitespace-pre-wrap break-words text-[var(--foreground)]/80`,children:e.message})]})]})}function WA({item:e,sessionId:t,runtimeSelector:n}){let[r,i]=(0,u.useState)(null),[a,o]=(0,u.useState)(()=>new Set),[s,c]=(0,u.useState)({}),l=e.images??[],d=e.files??[],f=l.find(e=>GA(e)===r);return e.role===`user`?(0,H.jsx)(`div`,{className:`flex justify-end`,children:(0,H.jsxs)(`div`,{className:`max-w-[85%] rounded-md rounded-br-sm bg-[var(--primary)]/10 p-2 text-sm dark:bg-[var(--primary)]/25 dark:ring-1 dark:ring-inset dark:ring-[var(--primary)]/35`,children:[l.length>0&&(0,H.jsx)(`div`,{className:`grid gap-1.5 ${l.length===1?`grid-cols-1`:`grid-cols-2`}`,children:l.map(r=>{let l=GA(r),u=JA(KA(n,t,e.id,r),s[l]??0),d=a.has(l);return(0,H.jsx)(`button`,{type:`button`,className:`group relative size-28 overflow-hidden rounded-md border border-black/10 bg-[var(--muted)] text-[var(--muted-foreground)] sm:size-36`,onClick:()=>{d?(o(e=>{let t=new Set(e);return t.delete(l),t}),c(e=>({...e,[l]:(e[l]??0)+1}))):i(l)},"aria-label":`${d?`Retry`:`Open`} ${r.filename??`attached image`}`,children:d?(0,H.jsxs)(`span`,{className:`flex size-full items-center justify-center gap-2 px-3 text-xs`,children:[(0,H.jsx)(fr,{className:`size-4`}),`Image unavailable`]}):(0,H.jsx)(`img`,{src:u,alt:r.filename??`Attached image`,loading:`lazy`,className:`size-full object-cover transition-transform group-hover:scale-[1.02]`,onError:()=>o(e=>new Set(e).add(l))})},l)})}),d.length>0&&(0,H.jsx)(`div`,{className:l.length>0?`mt-2 space-y-1.5`:`space-y-1.5`,children:d.map(r=>(0,H.jsxs)(`a`,{href:KA(n,t,e.id,r),target:`_blank`,rel:`noreferrer`,className:`flex min-w-0 items-center gap-2 rounded-md border border-black/10 bg-[var(--card)]/80 px-2.5 py-2 text-left text-[var(--foreground)] transition-colors hover:bg-[var(--card)]`,children:[(0,H.jsx)(nr,{className:`size-4 shrink-0 text-[var(--primary)]`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block truncate text-xs font-medium`,children:r.filename??`Attached file`}),(0,H.jsxs)(`span`,{className:`block truncate text-[10px] text-[var(--muted-foreground)]`,children:[r.mediaType,r.byteLength?` · ${qA(r.byteLength)}`:``]})]}),(0,H.jsx)(er,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`})]},GA(r)))}),e.text&&(0,H.jsx)(PA,{breaks:!0,className:`px-1 [&>:first-child]:mt-0 [&>:last-child]:mb-0 ${l.length||d.length?`pt-2`:``}`,workspaceFiles:{runtimeSelector:n,sessionId:t},children:e.text}),f&&(0,H.jsx)(sA,{open:!0,src:KA(n,t,e.id,f),alt:f.filename??`Attached image`,onOpenChange:e=>{e||i(null)}})]})}):(0,H.jsx)(`div`,{className:`flex justify-start`,children:(0,H.jsxs)(`div`,{className:`flex min-w-0 max-w-[90%] flex-col items-start`,children:[(0,H.jsxs)(`div`,{className:`rounded-md rounded-bl-sm bg-[var(--muted)] px-3.5 py-2.5`,children:[e.text&&(0,H.jsx)(PA,{className:`[&>:first-child]:mt-0 [&>:last-child]:mb-0`,streaming:e.streaming,workspaceFiles:{runtimeSelector:n,sessionId:t},children:e.text}),e.streaming&&(0,H.jsx)(`span`,{className:`ml-0.5 inline-block h-4 w-[3px] translate-y-0.5 animate-pulse rounded-full bg-[var(--primary)] align-middle`})]}),e.interrupted&&(0,H.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 px-1 text-xs text-[var(--muted-foreground)]`,"data-testid":`assistant-interrupted-indicator`,children:[(0,H.jsx)(Wn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:`Response stopped`})]})]})})}function GA(e){return`resourceId`in e&&e.resourceId?`resource:${e.resourceId}`:`path:${e.partIndex}`}function KA(e,t,n,r){return`resourceId`in r&&r.resourceId?Y.sessionResourceContentUrl(e,t,r):Y.sessionItemFileContentUrl(e,t,n,r.partIndex)}function qA(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function JA(e,t){return t===0?e:`${e}${e.includes(`?`)?`&`:`?`}retry=${t}`}function YA({item:e}){let t=e.summary.filter(Boolean).join(`
|
|
59
59
|
|
|
60
|
-
`).trim(),[n,r]=(0,u.useState)(e.streaming??!1);return(0,u.useEffect)(()=>{r(e.streaming??!1)},[e.streaming]),!t&&!e.streaming?null:(0,H.jsxs)(
|
|
61
|
-
`);return r.length
|
|
62
|
-
`),n=!0),t.length>QA&&(t=t.slice(0,QA),n=!0),{text:t,truncated:n}}function rj({status:e}){return e===`in_progress`?(0,H.jsx)(B,{className:`size-3.5 shrink-0 animate-spin text-[var(--primary)]`}):e===`failed`?(0,H.jsx)(Gn,{className:`size-3.5 shrink-0 text-[var(--destructive)]`}):e===`incomplete`?(0,H.jsx)(Un,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}):(0,H.jsx)(Pn,{className:`size-3.5 shrink-0 text-[var(--success)]`})}function ij({item:e,sessionId:t,runtimeSelector:n,canResolveInteractions:r=!0}){let[i,a]=(0,u.useState)(!1),o=tj(e.name,e.arguments),s=e.output?nj(e.output):null,c=!!e.arguments&&e.arguments!==`{}`,l=e.children??[],d=e.generatedImage?`resourceId`in e.generatedImage&&e.generatedImage.resourceId?Y.sessionResourceContentUrl(n,t,e.generatedImage):e.generatedImageItemId?Y.sessionItemFileContentUrl(n,t,e.generatedImageItemId,0):void 0:void 0,[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(!1);return(0,H.jsxs)(eA,{open:i,onOpenChange:a,className:`my-0.5`,children:[(0,H.jsxs)(tA,{className:`flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-xs hover:bg-[var(--muted)]/50`,children:[(0,H.jsx)(Ln,{className:X(`size-3 shrink-0 text-[var(--muted-foreground)] transition-transform`,i&&`rotate-90`)}),(0,H.jsx)(rj,{status:e.status}),(0,H.jsx)(`span`,{className:`shrink-0 font-mono font-medium`,children:o.name}),o.summary&&(0,H.jsx)(`span`,{className:`truncate text-[var(--muted-foreground)]`,children:o.summary})]}),d&&(0,H.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>h(!0),className:`ml-7 mt-1 block w-fit max-w-[min(28rem,calc(100%-1.75rem))] overflow-hidden rounded-md border border-[var(--border)] bg-[var(--muted)]`,"aria-label":`Preview ${e.generatedImage?.filename??`generated image`}`,children:f?(0,H.jsxs)(`span`,{className:`flex h-24 items-center justify-center gap-2 px-5 text-xs text-[var(--muted-foreground)]`,children:[(0,H.jsx)(fr,{className:`size-4`}),` Image unavailable`]}):(0,H.jsx)(`img`,{src:d,alt:e.generatedImage?.filename??`Generated image`,loading:`lazy`,className:`block max-h-80 w-auto max-w-full object-contain`,onError:()=>p(!0)})}),d&&!f&&(0,H.jsx)(aA,{open:m,src:d,alt:e.generatedImage?.filename??`Generated image`,onOpenChange:h}),(0,H.jsxs)(nA,{className:`overflow-hidden pl-7`,children:[c&&(0,H.jsx)(`pre`,{className:`mt-1 overflow-auto rounded-md bg-[var(--muted)] p-2 text-[11px] leading-relaxed`,children:(0,H.jsx)(`code`,{children:$A(e.arguments)})}),s&&(0,H.jsxs)(`pre`,{className:`mt-1 overflow-auto rounded-md border border-[var(--border)] p-2 text-[11px] leading-relaxed`,children:[(0,H.jsx)(`code`,{children:s.text}),s.truncated&&(0,H.jsx)(`div`,{className:`mt-1 text-[var(--muted-foreground)]`,children:`… output truncated`})]}),e.exitCode!=null&&e.exitCode!==0&&(0,H.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--destructive)]`,children:[`exit code `,e.exitCode]}),l.length>0&&(0,H.jsxs)(`div`,{className:`mt-1 border-l border-[var(--primary)]/30 pl-2`,children:[(0,H.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-1.5 text-[11px] text-[var(--muted-foreground)]`,children:[(0,H.jsx)(ui,{className:`size-3 shrink-0 text-[var(--primary)]`}),(0,H.jsxs)(`span`,{className:`font-mono`,children:[l.length,` sub-agent step`,l.length===1?``:`s`]})]}),l.map(e=>(0,H.jsx)(aj,{item:e,sessionId:t,runtimeSelector:n,canResolveInteractions:r},e.id))]})]})]})}function aj({item:e,sessionId:t,runtimeSelector:n,canResolveInteractions:r=!0}){switch(e.kind){case`message`:return e.isMeta?null:(0,H.jsx)(HA,{item:e,sessionId:t,runtimeSelector:n});case`tool`:return(0,H.jsx)(ij,{item:e,sessionId:t,runtimeSelector:n,canResolveInteractions:r});case`reasoning`:return(0,H.jsx)(qA,{item:e});case`terminal_command`:return(0,H.jsx)(XA,{item:e});case`divider`:return(0,H.jsx)(BA,{item:e});case`error`:return(0,H.jsx)(VA,{item:e});case`interaction`:return(0,H.jsx)(PA,{sessionId:t,item:e,canResolve:r})}}function oj(){return(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 py-2 pl-1`,children:[0,1,2].map(e=>(0,H.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--primary)]`,style:{animation:`typing-dot 1.3s ease-in-out infinite`,animationDelay:`${e*.18}s`}},e))})}function sj({count:e}){return(0,H.jsxs)(`div`,{"data-testid":`background-task-indicator`,role:`status`,"aria-live":`polite`,className:`flex items-center gap-2 py-2 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{children:[e,` background `,e===1?`task`:`tasks`,` still running`]})]})}function cj({message:e}){return(0,H.jsxs)(`div`,{"data-testid":`runner-starting-indicator`,role:`status`,"aria-live":`polite`,className:`flex items-center gap-2 py-2 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 shrink-0 animate-spin text-[var(--muted-foreground)]`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:e??`Starting up… getting your terminal ready.`})]})}function lj({message:e}){let t=/^MCP startup (?:failed|cancelled|incomplete)/i.test(e);return(0,H.jsxs)(`div`,{"data-testid":`mcp-startup-indicator`,role:`status`,"aria-live":`polite`,className:`flex items-center gap-2 py-2 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(t?ci:B,{className:`size-4 shrink-0 ${t?``:`animate-spin`}`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:e})]})}function uj(e){return e<60?`${e}s`:`${Math.floor(e/60)}m ${e%60}s`}function dj({message:e}){let t=(0,u.useRef)(Date.now()),[n,r]=(0,u.useState)(0);return(0,u.useEffect)(()=>{let e=()=>r(Math.floor((Date.now()-t.current)/1e3));e();let n=window.setInterval(e,1e3);return()=>window.clearInterval(n)},[]),(0,H.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex gap-3 rounded-lg border border-[color-mix(in_srgb,var(--warning)_35%,var(--border))] bg-[color-mix(in_srgb,var(--warning)_8%,var(--card))] px-3 py-2.5`,children:[(0,H.jsx)(B,{className:`mt-0.5 size-4 shrink-0 animate-spin text-[var(--warning)]`,"aria-hidden":`true`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-[var(--foreground)]`,children:`Queued for capacity`}),(0,H.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--muted-foreground)]`,children:[`Waiting `,uj(n)]})]}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-[var(--muted-foreground)]`,children:e}),(0,H.jsx)(`p`,{className:`mt-1 font-mono text-[10px] text-[var(--muted-foreground)]`,children:`Use Stop below to interrupt.`})]})]})}function fj({items:e,historyLoaded:t,running:n,backgroundTaskCount:r=0,startingUp:i=!1,startupStatus:a,mcpStatus:o,waitingForInteraction:s,queueStatus:c,sessionId:l,runtimeSelector:d,canResolveInteractions:f=!0}){let p=(0,u.useRef)(null),[m,h]=(0,u.useState)(!0),g=e[e.length-1],_=g?.kind===`message`&&g.role===`assistant`&&!!g.streaming,v=(i||!!a)&&!c,y=n&&!v&&!_&&!s&&!c;return(0,u.useEffect)(()=>{m&&p.current&&(p.current.scrollTop=p.current.scrollHeight)},[e,n,r,i,a,o,c,m]),(0,H.jsx)(U_,{className:`min-w-0 flex-1`,viewportRef:p,viewportProps:{onScroll:e=>{let t=e.currentTarget;h(t.scrollHeight-t.scrollTop-t.clientHeight<40)},"aria-busy":!t},children:(0,H.jsx)(`div`,{className:`mx-auto w-full max-w-3xl space-y-3 px-4 py-3`,children:!t&&e.length===0&&!c&&!v?(0,H.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex items-center justify-center gap-2 py-10 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin text-[var(--primary)]`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:`Loading conversation…`})]}):e.length===0&&!n&&r===0&&!c&&!v?(0,H.jsx)(`p`,{className:`py-10 text-center text-sm text-[var(--muted-foreground)]`,children:`Send a message to start a turn.`}):(0,H.jsxs)(H.Fragment,{children:[e.map(e=>(0,H.jsx)(aj,{item:e,sessionId:l,runtimeSelector:d,canResolveInteractions:f},e.id)),v&&(0,H.jsx)(cj,{message:a}),o&&(0,H.jsx)(lj,{message:o}),c&&(0,H.jsx)(dj,{message:c}),y&&(0,H.jsx)(oj,{}),r>0&&(0,H.jsx)(sj,{count:r})]})})})}var pj=2500,mj=new Map;function hj({sessionId:e,runtimeSelector:t,active:n,polling:r=n,readOnly:i=!1}){let a=`${t}\n${e}`,o=(0,u.useRef)(a);o.current=a;let s=(0,u.useRef)(n);s.current=n;let c=(0,u.useRef)(0),l=(0,u.useRef)(0),d=(0,u.useRef)(!1),f=(0,u.useRef)(null),p=(0,u.useRef)(null),[m,h]=(0,u.useState)(()=>mj.get(a)??null),[g,_]=(0,u.useState)(()=>!mj.has(a)),[v,y]=(0,u.useState)(null),[b,x]=(0,u.useState)(null),S=(0,u.useCallback)(e=>{p.current=e,x(e)},[]),C=(0,u.useCallback)(e=>{f.current=e,mj.set(a,e),h(e)},[a]),w=(0,u.useCallback)(async n=>{if(!s.current||d.current)return;let r=a,i=c.current,u=l.current;n&&_(!0);try{let a=await Y.getRuntimeBrowserState(t,e);return!s.current||c.current!==i||l.current!==u||o.current!==r||d.current?void 0:(C(a),n&&S(null),a)}catch(e){if(!s.current||c.current!==i||l.current!==u||o.current!==r)return;n&&S(TO(e));return}finally{s.current&&c.current===i&&l.current===u&&o.current===r&&n&&_(!1)}},[a,t,e,C,S]);(0,u.useEffect)(()=>{let e=++c.current,t=mj.has(a);if(C(mj.get(a)??null),S(null),_(n&&!t),y(null),d.current=!1,n)return w(!t),()=>{c.current===e&&(c.current+=1)}},[a,n,w,C,S]),(0,u.useEffect)(()=>{if(!n||!r)return;let e=window.setInterval(()=>void w(!1),pj);return()=>window.clearInterval(e)},[n,w,r]);let T=(0,u.useCallback)(async(e,t)=>{if(i||!s.current||d.current)return;let n=a,r=c.current;l.current+=1,d.current=!0,y(e),S(null);try{let e=await t();return s.current&&c.current===r&&o.current===n?(C(e),e):void 0}catch(e){s.current&&c.current===r&&o.current===n&&S(TO(e));return}finally{s.current&&c.current===r&&o.current===n&&(d.current=!1,y(null),_(!1))}},[i,a,C,S]),E=(0,u.useCallback)((e,t)=>{let n=f.current;return n?T(e,()=>t(n.browserGeneration)):Promise.resolve(void 0)},[T]),D=(0,u.useCallback)(n=>T(`Starting browser`,()=>Y.openRuntimeBrowser(t,e,n)),[t,e,T]),O=(0,u.useCallback)(async()=>{if(i)return;let n=f.current;if(!s.current||!n||d.current)return;let r=a,u=c.current;l.current+=1,d.current=!0,y(`Closing browser`),S(null);try{await Y.closeRuntimeBrowser(t,e,n.browserGeneration),s.current&&c.current===u&&o.current===r&&C(null)}catch(e){s.current&&c.current===u&&o.current===r&&S(TO(e))}finally{s.current&&c.current===u&&o.current===r&&(d.current=!1,y(null))}},[i,a,t,e,C,S]),k=(0,u.useCallback)(async()=>{if(i)return;let n=f.current;if(!s.current||!n||d.current)return;let r=a,u=c.current;l.current+=1,d.current=!0,y(`Opening in Desktop`),S(null);try{let i=await kO(n,{close:n=>Y.closeRuntimeBrowser(t,e,n).then(()=>void 0),open:n=>Y.openRuntimeBrowser(t,e,n),createPage:(n,r)=>Y.createRuntimeBrowserPage(t,e,n,r),activatePage:(n,r)=>Y.activateRuntimeBrowserPage(t,e,n,r),onProgress:e=>{s.current&&c.current===u&&o.current===r&&(C(e),y(`Restoring browser tabs`))}});return s.current&&c.current===u&&o.current===r?(C(i),(i.executionBackend!==`embedded-electron`||!i.capabilities.includes(`desktop-direct-view`))&&S(`Desktop Browser Host is unavailable; using streamed browser`),i):void 0}catch(n){let i=await Y.getRuntimeBrowserState(t,e).catch(()=>void 0);s.current&&c.current===u&&o.current===r&&(i!==void 0&&C(i),S(TO(n)));return}finally{s.current&&c.current===u&&o.current===r&&(d.current=!1,y(null),_(!1))}},[i,a,t,e,C,S]);return{browser:m,loading:g,pendingAction:v,error:b,currentError:()=>p.current,disabled:i||v!==null||m?.status!==`ready`,createDisabled:i||v!==null,load:w,openBrowser:D,closeBrowser:O,recreateForDesktop:k,createPage:()=>E(`Creating page`,n=>Y.createRuntimeBrowserPage(t,e,n)),closePage:n=>E(`Closing page`,r=>Y.closeRuntimeBrowserPage(t,e,r,n)),activatePage:n=>E(`Switching page`,r=>Y.activateRuntimeBrowserPage(t,e,r,n)),navigatePage:(n,r)=>E(`Navigating`,i=>Y.navigateRuntimeBrowserPage(t,e,i,n,r)),backPage:n=>E(`Going back`,r=>Y.backRuntimeBrowserPage(t,e,r,n)),forwardPage:n=>E(`Going forward`,r=>Y.forwardRuntimeBrowserPage(t,e,r,n)),reloadPage:n=>E(`Reloading page`,r=>Y.reloadRuntimeBrowserPage(t,e,r,n))}}var gj=2500,_j=new Map;function vj({sessionId:e,runtimeSelector:t,active:n,polling:r=n,devicesActive:i=!1,readOnly:a=!1}){let o=`${t}\n${e}`,[s,c]=(0,u.useState)(()=>_j.get(o)??null),[l,d]=(0,u.useState)([]),[f,p]=(0,u.useState)(()=>n&&!_j.has(o)),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(!1),[v,y]=(0,u.useState)(null),b=(0,u.useRef)(0),x=(0,u.useRef)(0),S=(0,u.useRef)(!1),C=(0,u.useRef)(!1),w=(0,u.useRef)(!1),T=(0,u.useRef)(null);T.current=s;let E=(0,u.useCallback)(e=>{T.current=e,_j.set(o,e),c(e)},[o]),D=(0,u.useCallback)(async()=>{if(S.current)return;let n=b.current,r=x.current;C.current||p(!0);try{let i=await Y.getSessionEmulator(t,e);if(b.current!==n||x.current!==r||S.current)return;E(i),y(null)}catch(e){if(b.current!==n||x.current!==r||S.current)return;y(yj(e))}finally{b.current===n&&x.current===r&&!S.current&&(C.current=!0,p(!1))}},[t,e,E]),O=(0,u.useCallback)(async()=>{if(S.current)return;let n=b.current,r=x.current;h(!0);try{let i=await Y.listSessionEmulatorDevices(t,e);if(b.current!==n||x.current!==r||S.current)return;d(i),y(null)}catch(e){if(b.current!==n||x.current!==r||S.current)return;y(yj(e))}finally{b.current===n&&x.current===r&&!S.current&&(w.current=!0,h(!1))}},[t,e]);(0,u.useEffect)(()=>{b.current+=1;let e=_j.has(o);E(_j.get(o)??null),d([]),y(null),p(n&&!e),h(!1),_(!1),S.current=!1,C.current=e,w.current=!1,n&&D()},[n,D,o,E]),(0,u.useEffect)(()=>{if(!n||!r)return;let e=window.setInterval(()=>void D(),gj);return()=>window.clearInterval(e)},[n,r,D]),(0,u.useEffect)(()=>{!n||!i||f||g||s||w.current||O()},[n,s,i,f,g,O]);let k=(0,u.useCallback)(async(e,t)=>{if(a)throw Error(`Session Portal is read only`);let n=b.current,r=++x.current;S.current=!0,_(!0),y(null);try{let i=await e();return b.current!==n||x.current!==r?null:(t?.(i),i)}catch(e){throw b.current===n&&x.current===r&&y(yj(e)),e}finally{b.current===n&&x.current===r&&(S.current=!1,_(!1))}},[a]),A=(0,u.useCallback)(n=>k(()=>Y.attachSessionEmulator(t,e,n),e=>E(e)),[k,t,e]),j=(0,u.useCallback)(async()=>{let n=T.current;return n?await k(()=>Y.detachSessionEmulator(t,e,n.bindingId),()=>E(null))!==null:!1},[k,t,e]),M=(0,u.useCallback)(async e=>{let t=T.current;if(!t)throw Error(`This Session has no Emulator attached`);await k(()=>e(t))},[k]);return{binding:s,devices:l,loading:f,devicesLoading:m,mutating:a||g,error:v,reload:D,reloadDevices:O,attach:A,detach:j,tap:(n,r)=>M(i=>Y.tapSessionEmulator(t,e,i.bindingId,n,r)),gesture:n=>M(r=>Y.gestureSessionEmulator(t,e,r.bindingId,n)),button:n=>M(r=>Y.buttonSessionEmulator(t,e,r.bindingId,n))}}function yj(e){return e instanceof Error?e:Error(String(e))}var bj=`rynx.session-resource-dock-width`;function xj({session:e,runtimeSelector:t,leadingControls:n,initialDraft:r,initialMessage:i,sendInitialMessage:a=!1,onInitialMessageStarted:o,onInitialMessageConsumed:s,onInitialMessageFailed:c,terminalSlotRef:l,onTerminalActiveChange:d,readOnly:f=!1}){let[p,m]=bn(),h=p.get(`view`),g=h===`terminal`?`terminal`:`chat`;(0,u.useEffect)(()=>(d?.(e.id,g===`terminal`),()=>d?.(e.id,!1)),[d,e.id,g]);let _=rD(p.get(`surface`)),v=p.get(`panel`)===`resources`,y=h===`browser`||_!==null||v,b=_?.type===`browser`?_.pageId:null,x=(0,u.useRef)(null),S=(0,u.useRef)(null),C=(0,u.useRef)(`browser`),w=(0,u.useRef)(null),T=(0,u.useRef)(0),E=(0,u.useRef)(null),[D]=(0,u.useState)(Sj),O=(0,u.useRef)(D),k=(0,u.useRef)(null),A=(0,u.useRef)(null),j=(0,u.useRef)(null),M=(0,u.useRef)(null),N=(0,u.useRef)(null),P=(0,u.useRef)(null),F=(0,u.useRef)(!1),[I,L]=(0,u.useState)(!1),[ee,te]=(0,u.useState)(!1),[ne,re]=(0,u.useState)(null),[R,ie]=(0,u.useState)(360),[ae,oe]=(0,u.useState)(!1),[se,ce]=(0,u.useState)(!1),[le,ue]=(0,u.useState)([]),[de,fe]=(0,u.useState)(!!i),[pe,me]=(0,u.useState)(!1),he=(0,u.useRef)(null),{state:ge,pendingSend:_e,current:ve,send:ye,stop:be}=BD(e.id,{runtimeSelector:t,allowSend:!f}),xe=hj({sessionId:e.id,runtimeSelector:t,active:!0,polling:y,readOnly:f}),Se=vj({sessionId:e.id,runtimeSelector:t,active:!0,polling:y,devicesActive:_?.type===`emulator`,readOnly:f}),Ce=(0,u.useMemo)(()=>cD(xe.browser,b,x.current),[xe.browser,b]),we=FD(_e,ge.runStatus===`running`||ge.waitingForInteraction,ve,e.status===`running`),Te=ve?ge.backgroundTaskCount:0,Ee=e.agent??(e.provider?uE(e.provider):void 0),De=$E(ge)?.model,Oe=(0,u.useMemo)(()=>eD(ge.items),[ge.items]),ke=(0,u.useMemo)(()=>!i||Oe.length>0?Oe:[{kind:`message`,id:`optimistic_initial`,responseId:`optimistic_initial`,role:`user`,text:i,images:[],files:[],streaming:!1,optimistic:!0}],[i,Oe]),Ae=_E(ge.statusKind,ge.note)?ge.note:void 0,je=ge.statusKind===`startup`&&Ae===void 0,Me=ge.waitingForInteraction||ge.runStatus===`running`&&!je,Ne=je||!Me&&(_e||de),Pe=xe.browser?.pages??[],Fe=_?.type===`emulator`||I,Ie=xe.loading||Se.loading,Le=Pe.length>0||Fe,Re=(0,u.useMemo)(()=>[...Pe.map(e=>iD(e.pageId)),...Fe?[aD()]:[]],[Pe,Fe]),ze=(0,u.useMemo)(()=>oD(le,Re),[Re,le]);(0,u.useEffect)(()=>{ue(e=>{let t=oD(e,Re);return wj(e,t)?e:t})},[Re]),(0,u.useEffect)(()=>{let e=E.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().width,n=sD(t,1/0);ie(n);let r=O.current,i=sD(t,r??t*.44);r!==null&&e.style.setProperty(`--session-resource-dock-width`,`${i}px`),k.current=i,re(i)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,u.useEffect)(()=>()=>{j.current!==null&&window.cancelAnimationFrame(j.current),N.current?.(),Cj(P)},[]),(0,u.useEffect)(()=>{x.current=null,S.current=null,C.current=`browser`,w.current=null,L(!1),ce(!1),ue([]),T.current+=1},[t,e.id]),(0,u.useEffect)(()=>{!i||!a||he.current===i||(he.current=i,fe(!0),o?.(),ye(i).catch(e=>{fe(!1),Ux(e)&&c?.(i)}))},[i,c,o,ye,a]),(0,u.useEffect)(()=>{i&&Oe.some(e=>e.kind===`message`&&e.role===`user`&&e.optimistic!==!0&&e.text===i)&&(fe(!1),s?.())},[i,s,Oe]);let Be=(e,t=!0)=>{t&&(T.current+=1);let n=new URLSearchParams(p);e?(n.set(`surface`,e),n.delete(`panel`)):(n.delete(`surface`),n.set(`panel`,`resources`)),n.get(`view`)===`browser`&&n.set(`view`,`chat`),m(n,{replace:!0})},Ve=()=>{T.current+=1,ce(!1);let e=new URLSearchParams(p);e.delete(`surface`),e.delete(`panel`),e.get(`view`)===`browser`&&e.set(`view`,`chat`),m(e,{replace:!0})},He=()=>{if(C.current===`emulator`&&I){Be(aD(w.current));return}if(x.current){Be(iD(x.current));return}if(I){Be(aD(w.current));return}Be(null)};(0,u.useEffect)(()=>{_&&(C.current=_.type,_.type===`emulator`&&L(!0))},[_?.type]),(0,u.useEffect)(()=>{let e=Se.binding?.bindingId??null;e&&(w.current&&e!==w.current?L(!0):w.current||L(!0),w.current=e)},[Se.binding?.bindingId]),(0,u.useEffect)(()=>{if(h!==`browser`)return;let e=new URLSearchParams(p);e.set(`view`,`chat`),e.set(`surface`,iD(Ce)),e.delete(`panel`),m(e,{replace:!0})},[h,p,Ce,m]),(0,u.useEffect)(()=>{if(_?.type!==`browser`)return;Ce&&(x.current=Ce);let e=iD(Ce);if(p.get(`surface`)===e)return;let t=new URLSearchParams(p);t.set(`surface`,e),m(t,{replace:!0})},[_?.type,p,Ce,m]),(0,u.useEffect)(()=>{let e=Pe.map(e=>e.pageId),t=lD(S.current,xe.browser);S.current=e,!(!t||_?.type!==`browser`)&&(x.current=t,Be(iD(t),!1))},[Pe,xe.browser,_?.type]),(0,u.useEffect)(()=>{if(_?.type!==`emulator`)return;let e=aD(Se.binding?.bindingId);if(p.get(`surface`)===e)return;let t=new URLSearchParams(p);t.set(`surface`,e),m(t,{replace:!0})},[Se.binding?.bindingId,_?.type,p,m]),(0,u.useEffect)(()=>{if(!(!y||Ie)){if(!Le){_&&Be(null,!1);return}_?.type===`browser`&&Ce||_?.type===`emulator`&&Fe||(C.current===`emulator`&&Fe?Be(aD(Se.binding?.bindingId),!1):Ce?Be(iD(Ce),!1):Fe&&Be(aD(Se.binding?.bindingId),!1))}},[Se.binding?.bindingId,Fe,Le,_?.type,y,Ie,Ce]);let Ue=async()=>{if(F.current)return;F.current=!0,te(!0);let e=T.current;try{let t=xe.browser?.status===`ready`?await xe.createPage():await xe.openBrowser(),n=t?.activePageId??t?.pages.at(-1)?.pageId;if(!t){V.error(`Could not create Browser tab: ${xe.currentError()??`Browser is unavailable`}`);return}n&&T.current===e&&Be(iD(n),!1)}finally{F.current=!1,te(!1)}},We=e=>{let t=E.current;if(!t)return null;let n=sD(t.getBoundingClientRect().width,e);return t.style.setProperty(`--session-resource-dock-width`,`${n}px`),k.current=n,n},Ge=e=>{let t=E.current;return t?We(t.getBoundingClientRect().right-e):null},Ke=e=>{if(e!==null){O.current=e,re(e);try{window.localStorage.setItem(bj,String(Math.round(e)))}catch{}}},qe=e=>{M.current=e,j.current===null&&(j.current=window.requestAnimationFrame(()=>{j.current=null;let e=M.current;M.current=null,e!==null&&Ge(e)}))},Je=(e,t,n)=>{if(A.current!==t)return;j.current!==null&&(window.cancelAnimationFrame(j.current),j.current=null),M.current=null;let r=n===void 0?k.current:Ge(n);Ke(r),A.current=null,N.current?.(),N.current=null,e.hasPointerCapture(t)&&e.releasePointerCapture(t),Cj(P),oe(!1)},Ye=e=>{if(e.button!==0)return;e.preventDefault(),N.current?.(),A.current=e.pointerId;let t=e.currentTarget;t.setPointerCapture(e.pointerId);let n=e=>{A.current===e.pointerId&&qe(e.clientX)},r=e=>{Je(t,e.pointerId,e.clientX)},i=e=>{Je(t,e.pointerId)};window.addEventListener(`pointermove`,n,!0),window.addEventListener(`pointerup`,r,!0),window.addEventListener(`pointercancel`,i,!0),N.current=()=>{window.removeEventListener(`pointermove`,n,!0),window.removeEventListener(`pointerup`,r,!0),window.removeEventListener(`pointercancel`,i,!0)};let a=document.documentElement.style;P.current={cursor:a.cursor,userSelect:a.userSelect},a.cursor=`col-resize`,a.userSelect=`none`,oe(!0),Ge(e.clientX)},Xe=e=>{let t=E.current;if(!t)return;let n=k.current??sD(t.getBoundingClientRect().width,t.getBoundingClientRect().width*.44),r=e.shiftKey?32:16,i=null;e.key===`ArrowLeft`&&(i=n+r),e.key===`ArrowRight`&&(i=n-r),e.key===`Home`&&(i=0),e.key===`End`&&(i=1/0),i!==null&&(e.preventDefault(),Ke(We(i)))},Ze=e=>{T.current+=1;let t=new URLSearchParams(p);t.set(`view`,e),m(t,{replace:!0})},Qe=(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`size-9 shrink-0`,"aria-label":g===`chat`?`Open terminal`:`Open chat`,title:g===`chat`?`Open terminal`:`Open chat`,onClick:()=>Ze(g===`chat`?`terminal`:`chat`),children:g===`chat`?(0,H.jsx)(oi,{}):(0,H.jsx)(br,{})}),$e=(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`size-9 shrink-0`,"aria-label":y?`Hide Session resources`:`Show Session resources`,title:y?`Hide Session resources`:`Show Session resources`,onClick:y?Ve:He,children:y?(0,H.jsx)(jr,{}):(0,H.jsx)(Mr,{})}),et=(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`hidden size-8 shrink-0 lg:inline-flex`,"aria-label":se?`Restore split view`:`Expand resource pane`,"aria-pressed":se,title:se?`Restore split view`:`Expand resource pane`,onClick:()=>ce(e=>!e),children:se?(0,H.jsx)(Qr,{}):(0,H.jsx)($n,{})}),tt=f?void 0:(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`size-8 shrink-0`,"aria-label":`Session settings`,title:`Session settings`,onClick:()=>me(!0),children:(0,H.jsx)(Kr,{})});return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,H.jsxs)(`div`,{ref:E,className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden [--session-resource-dock-width:44%]`,children:[(0,H.jsxs)(`section`,{"aria-hidden":se,className:X(`min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,se?`hidden`:`flex`),children:[(0,H.jsxs)(`header`,{className:`desktop-macos-titlebar-header app-drag-region flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--border)] px-3 sm:px-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[n,(0,H.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e.title??Ee??`session`})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[Qe,!y&&$e]})]}),(0,H.jsxs)(fE,{value:g,className:`relative flex min-h-0 min-w-0 flex-1 flex-col gap-0`,children:[(0,H.jsxs)(hE,{value:`chat`,forceMount:!0,className:`mt-0 flex min-h-0 flex-1 flex-col data-[state=inactive]:hidden`,children:[(0,H.jsx)(iA,{todos:ge.todos}),(0,H.jsx)(fj,{items:ke,historyLoaded:ge.historyLoaded,running:we,backgroundTaskCount:Te,startingUp:Ne,startupStatus:je?ge.note:void 0,mcpStatus:Ae,waitingForInteraction:ge.waitingForInteraction,queueStatus:ge.statusKind===`queue`?ge.note:void 0,sessionId:e.id,runtimeSelector:t,canResolveInteractions:!f}),!f&&(0,H.jsx)(Sk,{initialDraft:r,model:De,running:we,collaborationMode:ge.collaborationMode,streamCurrent:ve,sessionId:e.id,runtimeSelector:t,onSend:ye,onStop:be})]}),(0,H.jsx)(hE,{value:`terminal`,forceMount:!0,"aria-hidden":g!==`terminal`,className:`mt-0 flex min-h-0 flex-1 flex-col data-[state=inactive]:invisible data-[state=inactive]:absolute data-[state=inactive]:inset-0`,children:(0,H.jsx)(`div`,{ref:l,className:`flex min-h-0 flex-1 flex-col`})})]})]}),y&&(0,H.jsxs)(H.Fragment,{children:[!se&&(0,H.jsx)(`div`,{role:`separator`,"aria-label":`Resize Session resources`,"aria-orientation":`vertical`,"aria-valuemin":Math.min(360,R),"aria-valuemax":R,"aria-valuenow":Math.round(ne??360),"aria-valuetext":`${Math.round(ne??360)} pixels wide`,tabIndex:0,title:`Drag to resize Session resources`,className:`group relative z-30 -mx-1 hidden w-2 shrink-0 cursor-col-resize touch-none outline-none lg:block`,onPointerDown:Ye,onKeyDown:Xe,children:(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 left-1/2 -translate-x-1/2 bg-[var(--border)] transition-[width,background-color] duration-150 group-hover:w-0.5 group-hover:bg-[var(--primary)] group-focus-visible:w-0.5 group-focus-visible:bg-[var(--primary)] ${ae?`w-0.5 bg-[var(--primary)]`:`w-px`}`})}),(0,H.jsxs)(`aside`,{className:X(`flex min-h-0 min-w-0 flex-col overflow-hidden bg-[var(--card)]`,se?`h-full w-full`:`absolute inset-0 z-20 lg:static lg:z-auto lg:w-[var(--session-resource-dock-width)] lg:min-w-[22.5rem] lg:max-w-[calc(100%_-_26.25rem)]`),"aria-label":`Session resources`,children:[Le&&(0,H.jsx)(Ek,{pages:Pe,order:ze,selectedPageId:_?.type===`browser`?Ce:null,selectionDisabled:xe.pendingAction!==null,mutationDisabled:xe.disabled,createDisabled:f||xe.createDisabled||ee,createPending:ee,emulatorAttached:!!Se.binding,emulator:Fe?{selected:_?.type===`emulator`,label:Se.binding?.deviceName??`Emulator`,busy:Se.loading||Se.mutating}:null,onSelectPage:e=>{x.current=e,Be(iD(e)),xe.browser?.status===`ready`&&xe.activatePage(e)},onClosePage:e=>{T.current+=1,x.current===e&&(x.current=null),xe.closePage(e)},onCreatePage:()=>{f||Ue()},onSelectEmulator:()=>{L(!0),Be(aD(Se.binding?.bindingId))},onCloseEmulator:()=>{L(!1),C.current=`browser`,Be(Ce?iD(Ce):null)},onAddEmulator:()=>{L(!0),Be(aD(Se.binding?.bindingId))},headerLeadingAction:se?n:void 0,settingsAction:tt,leadingAction:et,trailingAction:$e}),!Le&&(0,H.jsxs)(H.Fragment,{children:[se&&n&&(0,H.jsx)(`div`,{className:`absolute left-3 top-1.5 z-10 flex h-8 items-center`,children:n}),(0,H.jsxs)(`div`,{className:`absolute right-3 top-1.5 z-10 flex items-center gap-1 sm:right-4`,children:[tt,et,$e]})]}),Le?_?.type===`emulator`?(0,H.jsx)(Nk,{sessionId:e.id,runtimeSelector:t,controller:Se,readOnly:f}):_?.type===`browser`?(0,H.jsx)(ek,{sessionId:e.id,runtimeSelector:t,pageId:Ce,browserResource:xe,readOnly:f}):(0,H.jsxs)(`div`,{className:`grid min-h-0 flex-1 place-items-center`,"aria-live":`polite`,children:[(0,H.jsx)(B,{className:`size-5 animate-spin text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Selecting Session resource`})]}):(0,H.jsx)(Tj,{browserBusy:f||xe.createDisabled||ee,emulatorBusy:f||Se.mutating,onOpenBrowser:()=>{f||Ue()},onOpenEmulator:()=>{L(!0),Be(aD(Se.binding?.bindingId))}})]})]})]}),(0,H.jsx)(uk,{open:pe,onOpenChange:me,runtimeSelector:t,sessionId:e.id})]})}function Sj(){if(typeof window>`u`)return null;try{let e=Number(window.localStorage.getItem(bj));return Number.isFinite(e)&&e>0?e:null}catch{return null}}function Cj(e){let t=e.current;!t||typeof document>`u`||(document.documentElement.style.cursor=t.cursor,document.documentElement.style.userSelect=t.userSelect,e.current=null)}function wj(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Tj({browserBusy:e,emulatorBusy:t,onOpenBrowser:n,onOpenEmulator:r}){return(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-6`,children:(0,H.jsxs)(`div`,{className:`w-full max-w-64 space-y-1`,"aria-label":`Session resource choices`,children:[(0,H.jsxs)(`button`,{type:`button`,disabled:e,onClick:n,className:`flex h-11 w-full items-center gap-3 rounded-md px-3 text-left text-sm outline-none transition-colors hover:bg-[var(--muted)] focus-visible:ring-2 focus-visible:ring-[var(--ring)] disabled:pointer-events-none disabled:opacity-50`,children:[e?(0,H.jsx)(B,{className:`size-4 shrink-0 animate-spin`}):(0,H.jsx)(Xn,{className:`size-4 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{children:`Browser`})]}),(0,H.jsxs)(`button`,{type:`button`,disabled:t,onClick:r,className:`flex h-11 w-full items-center gap-3 rounded-md px-3 text-left text-sm outline-none transition-colors hover:bg-[var(--muted)] focus-visible:ring-2 focus-visible:ring-[var(--ring)] disabled:pointer-events-none disabled:opacity-50`,children:[t?(0,H.jsx)(B,{className:`size-4 shrink-0 animate-spin`}):(0,H.jsx)($r,{className:`size-4 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{children:`Emulator`})]})]})})}var Ej=400,Dj=160;function Oj({sessions:e,runtimeSelector:t,runtimeLabel:n,listError:r,loading:i,selectedId:a,onCollapsedChange:o,onSelect:s,onNew:c,onRetry:l,onFork:d,onDeleted:f,readOnly:p=!1}){let[m,h]=(0,u.useState)(``),g=m.trim().toLocaleLowerCase(),_=(0,u.useMemo)(()=>g?e.filter(e=>[e.title,e.id,e.provider,e.provider?uE(e.provider):void 0,e.agent,e.source].some(e=>e?.toLocaleLowerCase().includes(g))):e,[g,e]);async function v(e){try{await Y.closeSession(e,t)}catch(e){V.error(`Delete session failed: ${e instanceof Error?e.message:String(e)}`);return}f(e)}return(0,H.jsxs)(`aside`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-[var(--card)]/35`,"aria-label":`Sessions`,children:[(0,H.jsxs)(`div`,{className:`app-drag-region desktop-macos-titlebar-inset shrink-0 border-b border-[var(--border)] p-2.5`,children:[(0,H.jsxs)(`div`,{className:`mb-2 flex h-7 items-center gap-2 px-0.5`,children:[(0,H.jsxs)(hn,{to:zx(jx(t)),className:`app-no-drag flex items-center gap-2`,"aria-label":`Rynx Sessions`,children:[(0,H.jsx)(`img`,{src:NS,alt:`rynx`,className:`h-5 w-auto dark:brightness-0 dark:invert`}),(0,H.jsx)(`span`,{className:`label-caps text-[8px] text-[var(--muted-foreground)]`,children:`control`})]}),(0,H.jsx)(J,{variant:`ghost`,size:`icon-sm`,className:`app-no-drag ml-auto hidden md:inline-flex`,onClick:()=>o(!0),title:`Collapse session list`,"aria-label":`Collapse session list`,"aria-expanded":`true`,children:(0,H.jsx)(kr,{className:`size-3.5`})})]}),(0,H.jsxs)(`div`,{className:`app-no-drag flex items-center gap-2`,children:[(0,H.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`sr-only`,children:`Search sessions`}),(0,H.jsx)(Hr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-[var(--muted-foreground)]`}),(0,H.jsx)(Ag,{value:m,onChange:e=>h(e.target.value),placeholder:`Search sessions`,className:`h-11 rounded-md pl-8 text-xs md:h-8`})]}),!p&&(0,H.jsx)(J,{size:`icon`,className:`size-11 shrink-0 md:size-8`,onClick:c,title:`New session`,"aria-label":`New session`,children:(0,H.jsx)(Ir,{})})]})]}),r&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 border-b border-[var(--border)] bg-[var(--warning)]/8 px-3 py-2 text-xs`,children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 text-[var(--warning)]`,children:r}),(0,H.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 shrink-0 px-2 text-[10px]`,onClick:l,children:`Retry`})]}),(0,H.jsx)(U_,{className:`min-h-0 flex-1`,children:i&&e.length===0?(0,H.jsx)(Aj,{}):e.length===0?(0,H.jsxs)(`div`,{className:`grid place-items-center gap-3 px-5 py-10 text-center`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`p`,{className:`text-sm font-medium`,children:[`No sessions on `,n]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:`Create one to start a conversation and terminal.`})]}),!p&&(0,H.jsxs)(J,{size:`sm`,className:`h-11 md:h-8`,onClick:c,children:[(0,H.jsx)(Ir,{}),` New session`]})]}):_.length===0?(0,H.jsxs)(`div`,{className:`px-5 py-10 text-center text-xs text-[var(--muted-foreground)]`,children:[`No sessions match “`,m.trim(),`”.`]}):(0,H.jsx)(`ul`,{className:`space-y-0.5 px-1.5 py-1.5`,children:_.map(e=>(0,H.jsx)(kj,{session:e,runtimeLabel:n,selected:a===e.id,onSelect:()=>s(e.id),onFork:()=>d(e.id),onDelete:()=>v(e.id),readOnly:p},e.id))})})]})}function kj({session:e,runtimeLabel:t,selected:n,onSelect:r,onFork:i,onDelete:a,readOnly:o}){let[s,c]=(0,u.useState)(!1),[l,d]=(0,u.useState)(!1),[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(!1),g=(0,u.useRef)(null),_=(0,u.useRef)(null),v=jj(e.updatedAt??e.createdAt),y=e.agent??(e.provider?uE(e.provider):void 0),b=e.title??y??e.source??`Untitled session`;(0,u.useEffect)(()=>()=>{g.current!==null&&window.clearTimeout(g.current),_.current!==null&&window.clearTimeout(_.current)},[]);let x=()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},S=()=>{_.current!==null&&(window.clearTimeout(_.current),_.current=null)},C=()=>{x(),S(),!f&&d(!0)},w=()=>{S(),!(f||l||g.current!==null)&&(g.current=window.setTimeout(()=>{g.current=null,d(!0)},Ej))},T=()=>{x(),S(),d(!1)},E=()=>{x(),S(),l&&(_.current=window.setTimeout(()=>{_.current=null,d(!1)},Dj))};return(0,H.jsxs)(`li`,{className:X(`group relative flex min-h-9 items-center rounded-md transition-colors`,n?`bg-[var(--muted)]/70`:`hover:bg-[var(--muted)]/40`),onMouseEnter:w,onMouseLeave:E,children:[(0,H.jsxs)(xg,{modal:!1,open:l,onOpenChange:e=>{e?C():T()},children:[(0,H.jsx)(Sg,{asChild:!0,children:(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute right-0 top-2 size-px`})}),(0,H.jsxs)(Cg,{side:`right`,align:`start`,sideOffset:8,className:`w-72 p-3`,"aria-label":`Details for ${b}`,onMouseEnter:C,onMouseLeave:E,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:[(0,H.jsxs)(`div`,{className:`mb-2.5 flex min-w-0 items-center justify-between gap-3`,children:[(0,H.jsx)(`p`,{className:`min-w-0 truncate text-xs font-medium`,children:b}),(0,H.jsx)(`span`,{className:`shrink-0 text-[10px] text-[var(--muted-foreground)]`,children:v})]}),(0,H.jsxs)(`div`,{className:`space-y-2 font-mono text-[11px] leading-4`,children:[y&&(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,"aria-label":`Target: ${y}`,children:[(0,H.jsx)(Mn,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:y})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,"aria-label":`Source: ${e.source}`,children:[(0,H.jsx)(Nn,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:e.source})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,"aria-label":`Session: ${e.id}`,children:[(0,H.jsx)(rr,{"aria-hidden":`true`,className:`mt-px size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`min-w-0 select-text break-all`,children:e.id})]})]})]})]}),(0,H.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 px-2.5 py-2 text-left outline-none focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--ring)]`,"aria-current":n?`page`:void 0,onClick:r,onFocus:C,onBlur:E,children:(0,H.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:b})}),!o&&(0,H.jsxs)(`div`,{className:`group/actions relative mr-2 size-8 shrink-0`,onMouseEnter:T,onMouseLeave:w,children:[e.status===`running`&&(0,H.jsx)(`span`,{role:`status`,"aria-label":`Running`,title:`Running`,className:`pointer-events-none absolute inset-0 grid place-items-center text-[var(--muted-foreground)] transition-opacity duration-150 group-hover:opacity-0 group-focus-within/actions:opacity-0 group-has-data-[state=open]/actions:opacity-0 [@media(hover:none)]:opacity-0`,children:(0,H.jsx)(B,{className:`size-3.5 animate-spin motion-reduce:animate-none`})}),(0,H.jsxs)(xg,{open:f,onOpenChange:e=>{p(e),e&&T()},children:[(0,H.jsx)(Sg,{asChild:!0,children:(0,H.jsx)(J,{variant:`ghost`,size:`icon`,className:`absolute inset-0 size-8 text-[var(--muted-foreground)] opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100 [@media(hover:none)]:opacity-100`,title:`Session actions for ${b}`,"aria-label":`Session actions for ${b}`,children:(0,H.jsx)(Zn,{})})}),(0,H.jsxs)(Cg,{align:`end`,children:[(0,H.jsxs)(wg,{disabled:m||e.status===`running`,onSelect:()=>{h(!0),i().finally(()=>h(!1))},children:[m?(0,H.jsx)(B,{className:`animate-spin motion-reduce:animate-none`}):(0,H.jsx)(lr,{}),`Fork session`]}),(0,H.jsxs)(wg,{variant:`destructive`,onSelect:()=>c(!0),children:[(0,H.jsx)(si,{}),`Delete session`]})]})]}),(0,H.jsx)(uu,{open:s,onOpenChange:c,children:(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsx)(vu,{children:`Delete this session?`}),(0,H.jsxs)(yu,{children:[`“`,b,`” will be deleted from `,t,`. This cannot be undone.`]})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>void a(),children:`Delete`})]})]})})]})]})}function Aj(){return(0,H.jsx)(`div`,{"aria-label":`Loading sessions`,className:`space-y-0.5 px-1.5 py-1.5`,children:Array.from({length:6},(e,t)=>(0,H.jsx)(`div`,{className:`grid min-h-9 content-center rounded-md px-2.5`,children:(0,H.jsx)(`div`,{className:`h-3 w-2/3 animate-pulse rounded bg-[var(--muted)]`})},t))})}function jj(e){let t=Date.parse(e);if(!Number.isFinite(t))return`unknown`;let n=Math.max(0,Math.round((Date.now()-t)/1e3));return n<60?`now`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:n<604800?`${Math.floor(n/86400)}d ago`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(t)}var Mj=`!no-project`,Nj=`!new-project`;function Pj({runtimeLabel:e,options:t,selection:n,configuration:r,projects:i,projectId:a,loading:o,projectsLoading:s,submitting:c,error:l,projectError:d,listCollapsed:f,onShowSessions:p,onRetryOptions:m,onSelectionChange:h,onConfigurationChange:g,onProjectChange:_,onNewProject:v,onSubmit:y}){let[b,x]=(0,u.useState)(``),S=(0,u.useRef)(null),C=(0,u.useRef)(!1),w=(0,u.useRef)(void 0),T=gk({policy:mk,onChange:()=>{w.current=void 0}}),E=dE(n,t),D=a?i.find(e=>e.id===a):void 0,O=!!((b.trim()||T.items.length>0)&&n&&!o&&!c&&!T.hasPending&&!T.hasFailed);async function k(){let e=b.trim();if(!e&&T.items.length===0||!n||o||c||T.hasPending||T.hasFailed)return;let t=T.items.length>0?w.current??MD(`msg`):void 0;t&&(w.current=t),await y({text:e,attachments:T.readyUploads,...t?{clientMessageId:t}:{}})&&(T.clear(),x(``),w.current=void 0)}return(0,H.jsxs)(`main`,{className:`relative h-full min-h-0 min-w-0 flex-1 overflow-hidden bg-[radial-gradient(circle_at_50%_-10%,color-mix(in_srgb,var(--primary)_9%,transparent),transparent_38%)]`,children:[f&&(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`desktop-macos-titlebar-leading-control absolute left-3 top-2.5 z-10 hidden md:inline-flex`,onClick:p,title:`Show session list`,"aria-label":`Show session list`,children:(0,H.jsx)(Ar,{className:`size-3.5`})}),(0,H.jsx)(`div`,{className:`desktop-macos-home-titlebar`,"aria-hidden":`true`}),(0,H.jsx)(U_,{className:`h-full`,viewportClassName:`[&>div]:!flex [&>div]:min-h-full [&>div]:flex-col`,children:(0,H.jsxs)(`div`,{className:`mx-auto grid w-full max-w-3xl flex-1 content-center px-4 py-8 sm:px-6 lg:py-12`,children:[(0,H.jsx)(`div`,{className:`mb-6 flex items-center gap-2 md:hidden`,children:(0,H.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,className:`h-11 px-2`,onClick:p,children:[(0,H.jsx)(An,{}),` Sessions`]})}),(0,H.jsxs)(`div`,{className:`mb-7`,children:[(0,H.jsx)(`p`,{className:`label-caps mb-3 text-[10px] text-[var(--primary)]`,children:`New session`}),(0,H.jsx)(`h1`,{className:`text-3xl font-semibold tracking-[-0.035em] sm:text-4xl`,children:`What should we work on?`}),(0,H.jsxs)(`p`,{className:`mt-3 max-w-2xl text-sm leading-6 text-[var(--muted-foreground)] sm:text-base`,children:[`Describe the outcome you want. The session and terminal will run on`,` `,(0,H.jsx)(`span`,{className:`font-medium text-[var(--foreground)]`,children:e}),`.`]})]}),(0,H.jsxs)(`form`,{ref:S,onSubmit:e=>{e.preventDefault(),k()},children:[(0,H.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--card)] shadow-[0_12px_34px_rgba(24,24,27,0.08)] transition-[border-color,box-shadow] focus-within:border-[color-mix(in_srgb,var(--primary)_55%,var(--border))] focus-within:shadow-[0_0_0_3px_color-mix(in_srgb,var(--primary)_9%,transparent),0_12px_34px_rgba(24,24,27,0.08)]`,"aria-busy":c,children:[(0,H.jsx)(`label`,{htmlFor:`session-initial-prompt`,className:`sr-only`,children:`Initial task`}),(0,H.jsx)(_k,{items:T.items,disabled:c,onRemove:T.remove,className:`px-5 pt-4`}),(0,H.jsx)(jg,{id:`session-initial-prompt`,value:b,disabled:c,rows:7,className:`min-h-40 max-h-[min(45dvh,24rem)] resize-none overflow-y-auto rounded-none border-0 bg-transparent px-5 py-5 text-base leading-7 shadow-none focus-visible:border-0 focus-visible:ring-0 md:text-base`,placeholder:`Fix a bug, build a feature, or investigate the codebase…`,onChange:e=>{w.current=void 0,x(e.target.value)},onPaste:T.onPaste,onCompositionStart:()=>{C.current=!0},onCompositionEnd:()=>{C.current=!1},onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||C.current||e.nativeEvent.isComposing||e.keyCode===229||(e.preventDefault(),S.current?.requestSubmit())}}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-[var(--border)] bg-[var(--muted)]/15 p-2.5 sm:flex-nowrap sm:pl-4`,children:[(0,H.jsx)(vk,{policy:mk,disabled:c,onFiles:T.addFiles}),(0,H.jsx)(`label`,{htmlFor:`session-project`,className:`sr-only`,children:`Project`}),(0,H.jsxs)(my,{value:a?`project:${a}`:Mj,disabled:s||c,onValueChange:e=>{if(e===Nj){v();return}_(e===Mj?null:e.startsWith(`project:`)?e.slice(8):null)},children:[(0,H.jsx)(_y,{id:`session-project`,className:`w-36 bg-[var(--background)] sm:w-40`,"aria-label":`Project`,children:(0,H.jsx)(gy,{placeholder:s?`Loading projects…`:`Choose project`,children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[D?(0,H.jsx)(sr,{className:`size-3.5 shrink-0 text-[var(--primary)]`}):(0,H.jsx)(or,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`truncate`,children:D?.name??`No project`})]})})}),(0,H.jsxs)(by,{align:`start`,children:[i.length>0&&(0,H.jsxs)(hy,{children:[(0,H.jsxs)(xy,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:[`Projects on `,e]}),i.map(e=>(0,H.jsx)(Sy,{value:`project:${e.id}`,textValue:e.name,children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(sr,{className:`size-3.5 shrink-0 text-[var(--primary)]`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))]}),i.length>0&&(0,H.jsx)(Cy,{}),(0,H.jsx)(Sy,{value:Nj,children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(or,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{children:`New project`})]})}),(0,H.jsx)(Sy,{value:Mj,children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(di,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{children:`No project`})]})})]})]}),(0,H.jsx)(Fj,{options:t,selection:n,configuration:r,selectedOption:E,disabled:o||c,loading:o,onSelectionChange:h,onConfigurationChange:g}),(0,H.jsx)(`label`,{htmlFor:`session-permission`,className:`sr-only`,children:`Permissions`}),(0,H.jsxs)(my,{value:r.permissionPreset,disabled:c,onValueChange:e=>g({...r,permissionPreset:e}),children:[(0,H.jsx)(_y,{id:`session-permission`,className:`w-36 bg-[var(--background)] sm:w-40`,"aria-label":`Permissions`,children:(0,H.jsx)(gy,{children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(Zr,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`truncate`,children:Ij(r.permissionPreset)})]})})}),(0,H.jsxs)(by,{align:`end`,children:[(0,H.jsx)(Sy,{value:`default`,children:`Default permissions`}),(0,H.jsx)(Sy,{value:`read-only`,children:`Read only`}),(0,H.jsx)(Sy,{value:`workspace-write`,children:`Workspace write`}),(0,H.jsx)(Sy,{value:`full-access`,children:`Full access`})]})]}),(0,H.jsx)(J,{type:`submit`,size:`icon`,className:`size-11 shrink-0 rounded-full md:size-10`,disabled:!O,"aria-label":c?`Starting session`:`Start session`,children:c?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Ur,{})})]})]}),(0,H.jsxs)(`div`,{className:`mt-2 flex min-h-6 flex-wrap items-start justify-between gap-x-4 gap-y-1 px-1 text-xs text-[var(--muted-foreground)]`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,role:l||d?`alert`:`status`,"aria-live":l||d?`assertive`:`polite`,children:[(0,H.jsx)(`span`,{children:l??d??(E&&!E.ready?`${E.reason??`${E.name} needs setup on ${e}.`} Start to open its login terminal; your task will wait safely.`:``)}),l&&t.providers.length===0&&t.agents.length===0&&!o&&(0,H.jsx)(J,{type:`button`,variant:`link`,size:`sm`,className:`h-auto px-0 text-xs`,onClick:m,children:`Retry`})]}),(0,H.jsx)(`span`,{className:`hidden font-mono text-[10px] sm:inline`,children:`Enter to start · Shift+Enter for newline`})]})]})]})})]})}function Fj({options:e,selection:t,configuration:n,selectedOption:r,disabled:i,loading:a,onSelectionChange:o,onConfigurationChange:s}){let c=(t?.kind===`provider`?e.providers.find(e=>e.id===t.id):void 0)?.models?.find(e=>e.id===n.model),l=c?.reasoningOptions.find(e=>e.value===n.reasoningEffort),u=(e,t,r)=>{o({kind:`provider`,id:e}),s({permissionPreset:n.permissionPreset,...t?{model:t}:{},...r?{reasoningEffort:r}:{}})};return(0,H.jsxs)(xg,{children:[(0,H.jsx)(Sg,{asChild:!0,children:(0,H.jsxs)(J,{id:`session-launch-target`,type:`button`,variant:`outline`,disabled:i,className:`w-44 justify-start bg-[var(--background)] font-normal sm:w-48 md:ml-auto`,"aria-label":`Run with`,children:[r?(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,H.jsx)(Lj,{status:lE(r)}),(0,H.jsxs)(`span`,{className:`truncate`,children:[r.name,c?` / ${c.label}`:``,l?` / ${l.label}`:``]})]}):(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[var(--muted-foreground)]`,children:a?`Loading…`:`Choose runtime / model / thinking`}),(0,H.jsx)(Fn,{className:`ml-auto size-3.5 shrink-0 opacity-55`})]})}),(0,H.jsxs)(Cg,{align:`end`,className:`min-w-56`,children:[e.providers.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Tg,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:`Providers · Runtime → Model → Thinking`}),e.providers.map(e=>{let r=e.models??[],i=t?.kind===`provider`&&t.id===e.id;return r.length===0?(0,H.jsxs)(wg,{onSelect:()=>u(e.id),children:[(0,H.jsx)(Lj,{status:lE(e)}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),i&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]},`provider:${e.id}`):(0,H.jsxs)(Dg,{children:[(0,H.jsxs)(Og,{children:[(0,H.jsx)(Lj,{status:lE(e)}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]}),(0,H.jsxs)(kg,{children:[(0,H.jsx)(Tg,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:`Model`}),r.map(t=>{let r=i&&n.model===t.id;return t.reasoningOptions.length===0?(0,H.jsxs)(wg,{onSelect:()=>u(e.id,t.id),children:[(0,H.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[t.label,t.isDefault?` · default`:``]}),r&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]},t.id):(0,H.jsxs)(Dg,{children:[(0,H.jsx)(Og,{children:(0,H.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[t.label,t.isDefault?` · default`:``]})}),(0,H.jsxs)(kg,{children:[(0,H.jsx)(Tg,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:`Thinking effort`}),t.reasoningOptions.map(i=>{let a=r&&n.reasoningEffort===i.value;return(0,H.jsxs)(wg,{onSelect:()=>u(e.id,t.id,i.value),children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i.label}),a&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]},i.value)})]})]},t.id)})]})]},`provider:${e.id}`)})]}),e.providers.length>0&&e.agents.length>0&&(0,H.jsx)(Eg,{}),e.agents.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Tg,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:`Agents`}),e.agents.map(e=>{let n=t?.kind===`agent`&&t.id===e.id;return(0,H.jsxs)(wg,{onSelect:()=>o({kind:`agent`,id:e.id}),children:[(0,H.jsx)(Lj,{status:lE(e)}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name??e.id}),n&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]},`agent:${e.id}`)})]})]})]})}function Ij(e){return{default:`Default`,"read-only":`Read only`,"workspace-write":`Workspace write`,"full-access":`Full access`}[e]}function Lj({status:e}){let t=e===`ready`?`Ready`:e===`needs_setup`?`Needs setup`:`Readiness not reported`;return(0,H.jsxs)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,title:t,children:[(0,H.jsx)(`span`,{className:`size-2 rounded-full ${e===`ready`?`bg-[var(--success)]`:e===`needs_setup`?`bg-[var(--warning)]`:`bg-[var(--muted-foreground)]/55`}`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`sr-only`,children:t})]})}var Rj=`rynx.control.theme`;function zj(){let e=localStorage.getItem(Rj);return e===`light`||e===`dark`?e:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function Bj(){let[e,t]=(0,u.useState)(zj);return(0,u.useEffect)(()=>{document.documentElement.classList.toggle(`dark`,e===`dark`),localStorage.setItem(Rj,e)},[e]),{theme:e,toggle:()=>t(e=>e===`dark`?`light`:`dark`)}}var Vj=2,Hj=1,Uj=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(Vj,Math.floor(u/e.css.cell.width)),rows:Math.max(Hj,Math.floor(l/e.css.cell.height))}}},Wj=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=Kj.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function Gj(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var Kj=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!Gj(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),!(!n.isWrapped||o.indexOf(` `)!==-1)););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},qj=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Jj(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var Yj=class{constructor(e=Jj,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||qj;this._linkProvider=this._terminal.registerLinkProvider(new Wj(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},Xj=Object.defineProperty,Zj=Object.getOwnPropertyDescriptor,Qj=(e,t,n,r)=>{for(var i=r>1?void 0:r?Zj(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Xj(t,n,i),i},$j=(e,t)=>(n,r)=>t(n,r,e),eM=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?aM.isErrorNoTelemetry(e)?new aM(e.message+`
|
|
60
|
+
`).trim(),[n,r]=(0,u.useState)(e.streaming??!1);return(0,u.useEffect)(()=>{r(e.streaming??!1)},[e.streaming]),!t&&!e.streaming?null:(0,H.jsxs)(tA,{open:n,onOpenChange:r,className:`my-0.5`,children:[(0,H.jsxs)(nA,{className:`flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-xs text-[var(--muted-foreground)] hover:bg-[var(--muted)]/50`,children:[(0,H.jsx)(Ln,{className:X(`size-3 shrink-0 transition-transform`,n&&`rotate-90`)}),(0,H.jsx)(ei,{className:`size-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:X(`label-caps text-[10px]`,e.streaming&&`animate-pulse`),children:e.streaming?`Thinking…`:`Thought`})]}),(0,H.jsx)(rA,{className:`overflow-hidden pl-7`,children:(0,H.jsx)(`div`,{className:`mt-1 border-l-2 border-[var(--border)] pl-3 text-[var(--muted-foreground)]`,children:t?(0,H.jsx)(PA,{children:t}):(0,H.jsx)(`span`,{className:`animate-pulse text-xs`,children:`…`})})})]})}var XA=12e3;function ZA(e){return e.length<=XA?{text:e,truncated:!1}:{text:e.slice(0,XA),truncated:!0}}function QA({item:e}){let[t,n]=(0,u.useState)(!1),r=e.stdout?ZA(e.stdout):null,i=e.stderr?ZA(e.stderr):null,a=!!(r||i);return(0,H.jsxs)(tA,{open:t,onOpenChange:n,className:`my-0.5`,children:[(0,H.jsxs)(nA,{className:`flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-xs hover:bg-[var(--muted)]/50`,children:[(0,H.jsx)(Ln,{className:X(`size-3 shrink-0 text-[var(--muted-foreground)] transition-transform`,t&&`rotate-90`)}),(0,H.jsx)(ti,{className:`size-3.5 shrink-0 text-[var(--primary)]`}),(0,H.jsxs)(`span`,{className:`truncate font-mono`,children:[(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:`$ `}),e.command]})]}),(0,H.jsxs)(rA,{className:`overflow-hidden pl-7`,children:[r&&(0,H.jsxs)(`pre`,{className:`mt-1 overflow-auto rounded-md border border-[var(--border)] p-2 text-[11px] leading-relaxed`,children:[(0,H.jsx)(`code`,{children:r.text}),r.truncated&&(0,H.jsx)(`div`,{className:`mt-1 text-[var(--muted-foreground)]`,children:`… output truncated`})]}),i&&(0,H.jsxs)(`pre`,{className:`mt-1 overflow-auto rounded-md border border-[var(--destructive)]/40 p-2 text-[11px] leading-relaxed text-[var(--destructive)]`,children:[(0,H.jsx)(`code`,{children:i.text}),i.truncated&&(0,H.jsx)(`div`,{className:`mt-1 text-[var(--muted-foreground)]`,children:`… output truncated`})]}),!a&&(0,H.jsx)(`div`,{className:`mt-1 text-[11px] text-[var(--muted-foreground)]`,children:`(no output)`})]})]})}var $A=80,ej=12e3;function tj(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function nj(e){try{let t=JSON.parse(e);for(let e of[`command`,`cmd`,`path`,`file`,`file_path`,`query`,`url`,`pattern`,`description`]){let n=t[e];if(typeof n==`string`&&n)return n}let n=JSON.stringify(t);return n===`{}`?``:n}catch{return e}}function rj(e,t){if(e===`apply_patch`)try{let e=JSON.parse(t);if(Array.isArray(e.changes)&&e.changes.length>0){if(e.changes.length===1){let t=e.changes[0];if(t&&typeof t==`object`){let e=Reflect.get(t,`path`);if(typeof e==`string`&&e)return{name:`Edit`,summary:e}}}return{name:`Edit`,summary:`${e.changes.length} files`}}}catch{}return{name:e,summary:nj(t)}}function ij(e){let t=e,n=!1,r=t.split(`
|
|
61
|
+
`);return r.length>$A&&(t=r.slice(0,$A).join(`
|
|
62
|
+
`),n=!0),t.length>ej&&(t=t.slice(0,ej),n=!0),{text:t,truncated:n}}function aj({status:e}){return e===`in_progress`?(0,H.jsx)(B,{className:`size-3.5 shrink-0 animate-spin text-[var(--primary)]`}):e===`failed`?(0,H.jsx)(Gn,{className:`size-3.5 shrink-0 text-[var(--destructive)]`}):e===`incomplete`?(0,H.jsx)(Un,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}):(0,H.jsx)(Pn,{className:`size-3.5 shrink-0 text-[var(--success)]`})}function oj({item:e,sessionId:t,runtimeSelector:n,canResolveInteractions:r=!0}){let[i,a]=(0,u.useState)(!1),o=rj(e.name,e.arguments),s=e.output?ij(e.output):null,c=!!e.arguments&&e.arguments!==`{}`,l=e.children??[],d=e.generatedImage?`resourceId`in e.generatedImage&&e.generatedImage.resourceId?Y.sessionResourceContentUrl(n,t,e.generatedImage):e.generatedImageItemId?Y.sessionItemFileContentUrl(n,t,e.generatedImageItemId,0):void 0:void 0,[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(!1);return(0,H.jsxs)(tA,{open:i,onOpenChange:a,className:`my-0.5`,children:[(0,H.jsxs)(nA,{className:`flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-xs hover:bg-[var(--muted)]/50`,children:[(0,H.jsx)(Ln,{className:X(`size-3 shrink-0 text-[var(--muted-foreground)] transition-transform`,i&&`rotate-90`)}),(0,H.jsx)(aj,{status:e.status}),(0,H.jsx)(`span`,{className:`shrink-0 font-mono font-medium`,children:o.name}),o.summary&&(0,H.jsx)(`span`,{className:`truncate text-[var(--muted-foreground)]`,children:o.summary})]}),d&&(0,H.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>h(!0),className:`ml-7 mt-1 block w-fit max-w-[min(28rem,calc(100%-1.75rem))] overflow-hidden rounded-md border border-[var(--border)] bg-[var(--muted)]`,"aria-label":`Preview ${e.generatedImage?.filename??`generated image`}`,children:f?(0,H.jsxs)(`span`,{className:`flex h-24 items-center justify-center gap-2 px-5 text-xs text-[var(--muted-foreground)]`,children:[(0,H.jsx)(fr,{className:`size-4`}),` Image unavailable`]}):(0,H.jsx)(`img`,{src:d,alt:e.generatedImage?.filename??`Generated image`,loading:`lazy`,className:`block max-h-80 w-auto max-w-full object-contain`,onError:()=>p(!0)})}),d&&!f&&(0,H.jsx)(sA,{open:m,src:d,alt:e.generatedImage?.filename??`Generated image`,onOpenChange:h}),(0,H.jsxs)(rA,{className:`overflow-hidden pl-7`,children:[c&&(0,H.jsx)(`pre`,{className:`mt-1 overflow-auto rounded-md bg-[var(--muted)] p-2 text-[11px] leading-relaxed`,children:(0,H.jsx)(`code`,{children:tj(e.arguments)})}),s&&(0,H.jsxs)(`pre`,{className:`mt-1 overflow-auto rounded-md border border-[var(--border)] p-2 text-[11px] leading-relaxed`,children:[(0,H.jsx)(`code`,{children:s.text}),s.truncated&&(0,H.jsx)(`div`,{className:`mt-1 text-[var(--muted-foreground)]`,children:`… output truncated`})]}),e.exitCode!=null&&e.exitCode!==0&&(0,H.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--destructive)]`,children:[`exit code `,e.exitCode]}),l.length>0&&(0,H.jsxs)(`div`,{className:`mt-1 border-l border-[var(--primary)]/30 pl-2`,children:[(0,H.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-1.5 text-[11px] text-[var(--muted-foreground)]`,children:[(0,H.jsx)(ui,{className:`size-3 shrink-0 text-[var(--primary)]`}),(0,H.jsxs)(`span`,{className:`font-mono`,children:[l.length,` sub-agent step`,l.length===1?``:`s`]})]}),l.map(e=>(0,H.jsx)(sj,{item:e,sessionId:t,runtimeSelector:n,canResolveInteractions:r},e.id))]})]})]})}function sj({item:e,sessionId:t,runtimeSelector:n,canResolveInteractions:r=!0}){switch(e.kind){case`message`:return e.isMeta?null:(0,H.jsx)(WA,{item:e,sessionId:t,runtimeSelector:n});case`tool`:return(0,H.jsx)(oj,{item:e,sessionId:t,runtimeSelector:n,canResolveInteractions:r});case`reasoning`:return(0,H.jsx)(YA,{item:e});case`terminal_command`:return(0,H.jsx)(QA,{item:e});case`compaction`:return(0,H.jsx)(oA,{item:e});case`divider`:return(0,H.jsx)(HA,{item:e});case`error`:return(0,H.jsx)(UA,{item:e});case`interaction`:return(0,H.jsx)(IA,{sessionId:t,item:e,canResolve:r})}}function cj(){return(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 py-2 pl-1`,children:[0,1,2].map(e=>(0,H.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--primary)]`,style:{animation:`typing-dot 1.3s ease-in-out infinite`,animationDelay:`${e*.18}s`}},e))})}function lj({count:e}){return(0,H.jsxs)(`div`,{"data-testid":`background-task-indicator`,role:`status`,"aria-live":`polite`,className:`flex items-center gap-2 py-2 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{children:[e,` background `,e===1?`task`:`tasks`,` still running`]})]})}function uj({message:e}){return(0,H.jsxs)(`div`,{"data-testid":`runner-starting-indicator`,role:`status`,"aria-live":`polite`,className:`flex items-center gap-2 py-2 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 shrink-0 animate-spin text-[var(--muted-foreground)]`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:e??`Starting up… getting your terminal ready.`})]})}function dj({message:e}){let t=/^MCP startup (?:failed|cancelled|incomplete)/i.test(e);return(0,H.jsxs)(`div`,{"data-testid":`mcp-startup-indicator`,role:`status`,"aria-live":`polite`,className:`flex items-center gap-2 py-2 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(t?ci:B,{className:`size-4 shrink-0 ${t?``:`animate-spin`}`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:e})]})}function fj(e){return e<60?`${e}s`:`${Math.floor(e/60)}m ${e%60}s`}function pj({message:e}){let t=(0,u.useRef)(Date.now()),[n,r]=(0,u.useState)(0);return(0,u.useEffect)(()=>{let e=()=>r(Math.floor((Date.now()-t.current)/1e3));e();let n=window.setInterval(e,1e3);return()=>window.clearInterval(n)},[]),(0,H.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex gap-3 rounded-lg border border-[color-mix(in_srgb,var(--warning)_35%,var(--border))] bg-[color-mix(in_srgb,var(--warning)_8%,var(--card))] px-3 py-2.5`,children:[(0,H.jsx)(B,{className:`mt-0.5 size-4 shrink-0 animate-spin text-[var(--warning)]`,"aria-hidden":`true`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-[var(--foreground)]`,children:`Queued for capacity`}),(0,H.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--muted-foreground)]`,children:[`Waiting `,fj(n)]})]}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-[var(--muted-foreground)]`,children:e}),(0,H.jsx)(`p`,{className:`mt-1 font-mono text-[10px] text-[var(--muted-foreground)]`,children:`Use Stop below to interrupt.`})]})]})}function mj({items:e,historyLoaded:t,running:n,backgroundTaskCount:r=0,startingUp:i=!1,startupStatus:a,mcpStatus:o,waitingForInteraction:s,queueStatus:c,sessionId:l,runtimeSelector:d,canResolveInteractions:f=!0}){let p=(0,u.useRef)(null),[m,h]=(0,u.useState)(!0),g=e[e.length-1],_=g?.kind===`message`&&g.role===`assistant`&&!!g.streaming,v=(i||!!a)&&!c,y=n&&!v&&!_&&!s&&!c;return(0,u.useEffect)(()=>{m&&p.current&&(p.current.scrollTop=p.current.scrollHeight)},[e,n,r,i,a,o,c,m]),(0,H.jsx)(U_,{className:`min-w-0 flex-1`,viewportRef:p,viewportProps:{onScroll:e=>{let t=e.currentTarget;h(t.scrollHeight-t.scrollTop-t.clientHeight<40)},"aria-busy":!t},children:(0,H.jsx)(`div`,{className:`mx-auto w-full max-w-3xl space-y-3 px-4 py-3`,children:!t&&e.length===0&&!c&&!v?(0,H.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex items-center justify-center gap-2 py-10 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin text-[var(--primary)]`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:`Loading conversation…`})]}):e.length===0&&!n&&r===0&&!c&&!v?(0,H.jsx)(`p`,{className:`py-10 text-center text-sm text-[var(--muted-foreground)]`,children:`Send a message to start a turn.`}):(0,H.jsxs)(H.Fragment,{children:[e.map(e=>(0,H.jsx)(sj,{item:e,sessionId:l,runtimeSelector:d,canResolveInteractions:f},e.id)),v&&(0,H.jsx)(uj,{message:a}),o&&(0,H.jsx)(dj,{message:o}),c&&(0,H.jsx)(pj,{message:c}),y&&(0,H.jsx)(cj,{}),r>0&&(0,H.jsx)(lj,{count:r})]})})})}var hj=2500,gj=new Map;function _j({sessionId:e,runtimeSelector:t,active:n,polling:r=n,readOnly:i=!1}){let a=`${t}\n${e}`,o=(0,u.useRef)(a);o.current=a;let s=(0,u.useRef)(n);s.current=n;let c=(0,u.useRef)(0),l=(0,u.useRef)(0),d=(0,u.useRef)(!1),f=(0,u.useRef)(null),p=(0,u.useRef)(null),[m,h]=(0,u.useState)(()=>gj.get(a)??null),[g,_]=(0,u.useState)(()=>!gj.has(a)),[v,y]=(0,u.useState)(null),[b,x]=(0,u.useState)(null),S=(0,u.useCallback)(e=>{p.current=e,x(e)},[]),C=(0,u.useCallback)(e=>{f.current=e,gj.set(a,e),h(e)},[a]),w=(0,u.useCallback)(async n=>{if(!s.current||d.current)return;let r=a,i=c.current,u=l.current;n&&_(!0);try{let a=await Y.getRuntimeBrowserState(t,e);return!s.current||c.current!==i||l.current!==u||o.current!==r||d.current?void 0:(C(a),n&&S(null),a)}catch(e){if(!s.current||c.current!==i||l.current!==u||o.current!==r)return;n&&S(EO(e));return}finally{s.current&&c.current===i&&l.current===u&&o.current===r&&n&&_(!1)}},[a,t,e,C,S]);(0,u.useEffect)(()=>{let e=++c.current,t=gj.has(a);if(C(gj.get(a)??null),S(null),_(n&&!t),y(null),d.current=!1,n)return w(!t),()=>{c.current===e&&(c.current+=1)}},[a,n,w,C,S]),(0,u.useEffect)(()=>{if(!n||!r)return;let e=window.setInterval(()=>void w(!1),hj);return()=>window.clearInterval(e)},[n,w,r]);let T=(0,u.useCallback)(async(e,t)=>{if(i||!s.current||d.current)return;let n=a,r=c.current;l.current+=1,d.current=!0,y(e),S(null);try{let e=await t();return s.current&&c.current===r&&o.current===n?(C(e),e):void 0}catch(e){s.current&&c.current===r&&o.current===n&&S(EO(e));return}finally{s.current&&c.current===r&&o.current===n&&(d.current=!1,y(null),_(!1))}},[i,a,C,S]),E=(0,u.useCallback)((e,t)=>{let n=f.current;return n?T(e,()=>t(n.browserGeneration)):Promise.resolve(void 0)},[T]),D=(0,u.useCallback)(n=>T(`Starting browser`,()=>Y.openRuntimeBrowser(t,e,n)),[t,e,T]),O=(0,u.useCallback)(async()=>{if(i)return;let n=f.current;if(!s.current||!n||d.current)return;let r=a,u=c.current;l.current+=1,d.current=!0,y(`Closing browser`),S(null);try{await Y.closeRuntimeBrowser(t,e,n.browserGeneration),s.current&&c.current===u&&o.current===r&&C(null)}catch(e){s.current&&c.current===u&&o.current===r&&S(EO(e))}finally{s.current&&c.current===u&&o.current===r&&(d.current=!1,y(null))}},[i,a,t,e,C,S]),k=(0,u.useCallback)(async()=>{if(i)return;let n=f.current;if(!s.current||!n||d.current)return;let r=a,u=c.current;l.current+=1,d.current=!0,y(`Opening in Desktop`),S(null);try{let i=await AO(n,{close:n=>Y.closeRuntimeBrowser(t,e,n).then(()=>void 0),open:n=>Y.openRuntimeBrowser(t,e,n),createPage:(n,r)=>Y.createRuntimeBrowserPage(t,e,n,r),activatePage:(n,r)=>Y.activateRuntimeBrowserPage(t,e,n,r),onProgress:e=>{s.current&&c.current===u&&o.current===r&&(C(e),y(`Restoring browser tabs`))}});return s.current&&c.current===u&&o.current===r?(C(i),(i.executionBackend!==`embedded-electron`||!i.capabilities.includes(`desktop-direct-view`))&&S(`Desktop Browser Host is unavailable; using streamed browser`),i):void 0}catch(n){let i=await Y.getRuntimeBrowserState(t,e).catch(()=>void 0);s.current&&c.current===u&&o.current===r&&(i!==void 0&&C(i),S(EO(n)));return}finally{s.current&&c.current===u&&o.current===r&&(d.current=!1,y(null),_(!1))}},[i,a,t,e,C,S]);return{browser:m,loading:g,pendingAction:v,error:b,currentError:()=>p.current,disabled:i||v!==null||m?.status!==`ready`,createDisabled:i||v!==null,load:w,openBrowser:D,closeBrowser:O,recreateForDesktop:k,createPage:()=>E(`Creating page`,n=>Y.createRuntimeBrowserPage(t,e,n)),closePage:n=>E(`Closing page`,r=>Y.closeRuntimeBrowserPage(t,e,r,n)),activatePage:n=>E(`Switching page`,r=>Y.activateRuntimeBrowserPage(t,e,r,n)),navigatePage:(n,r)=>E(`Navigating`,i=>Y.navigateRuntimeBrowserPage(t,e,i,n,r)),backPage:n=>E(`Going back`,r=>Y.backRuntimeBrowserPage(t,e,r,n)),forwardPage:n=>E(`Going forward`,r=>Y.forwardRuntimeBrowserPage(t,e,r,n)),reloadPage:n=>E(`Reloading page`,r=>Y.reloadRuntimeBrowserPage(t,e,r,n))}}var vj=2500,yj=new Map;function bj({sessionId:e,runtimeSelector:t,active:n,polling:r=n,devicesActive:i=!1,readOnly:a=!1}){let o=`${t}\n${e}`,[s,c]=(0,u.useState)(()=>yj.get(o)??null),[l,d]=(0,u.useState)([]),[f,p]=(0,u.useState)(()=>n&&!yj.has(o)),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(!1),[v,y]=(0,u.useState)(null),b=(0,u.useRef)(0),x=(0,u.useRef)(0),S=(0,u.useRef)(!1),C=(0,u.useRef)(!1),w=(0,u.useRef)(!1),T=(0,u.useRef)(null);T.current=s;let E=(0,u.useCallback)(e=>{T.current=e,yj.set(o,e),c(e)},[o]),D=(0,u.useCallback)(async()=>{if(S.current)return;let n=b.current,r=x.current;C.current||p(!0);try{let i=await Y.getSessionEmulator(t,e);if(b.current!==n||x.current!==r||S.current)return;E(i),y(null)}catch(e){if(b.current!==n||x.current!==r||S.current)return;y(xj(e))}finally{b.current===n&&x.current===r&&!S.current&&(C.current=!0,p(!1))}},[t,e,E]),O=(0,u.useCallback)(async()=>{if(S.current)return;let n=b.current,r=x.current;h(!0);try{let i=await Y.listSessionEmulatorDevices(t,e);if(b.current!==n||x.current!==r||S.current)return;d(i),y(null)}catch(e){if(b.current!==n||x.current!==r||S.current)return;y(xj(e))}finally{b.current===n&&x.current===r&&!S.current&&(w.current=!0,h(!1))}},[t,e]);(0,u.useEffect)(()=>{b.current+=1;let e=yj.has(o);E(yj.get(o)??null),d([]),y(null),p(n&&!e),h(!1),_(!1),S.current=!1,C.current=e,w.current=!1,n&&D()},[n,D,o,E]),(0,u.useEffect)(()=>{if(!n||!r)return;let e=window.setInterval(()=>void D(),vj);return()=>window.clearInterval(e)},[n,r,D]),(0,u.useEffect)(()=>{!n||!i||f||g||s||w.current||O()},[n,s,i,f,g,O]);let k=(0,u.useCallback)(async(e,t)=>{if(a)throw Error(`Session Portal is read only`);let n=b.current,r=++x.current;S.current=!0,_(!0),y(null);try{let i=await e();return b.current!==n||x.current!==r?null:(t?.(i),i)}catch(e){throw b.current===n&&x.current===r&&y(xj(e)),e}finally{b.current===n&&x.current===r&&(S.current=!1,_(!1))}},[a]),A=(0,u.useCallback)(n=>k(()=>Y.attachSessionEmulator(t,e,n),e=>E(e)),[k,t,e]),j=(0,u.useCallback)(async()=>{let n=T.current;return n?await k(()=>Y.detachSessionEmulator(t,e,n.bindingId),()=>E(null))!==null:!1},[k,t,e]),M=(0,u.useCallback)(async e=>{let t=T.current;if(!t)throw Error(`This Session has no Emulator attached`);await k(()=>e(t))},[k]);return{binding:s,devices:l,loading:f,devicesLoading:m,mutating:a||g,error:v,reload:D,reloadDevices:O,attach:A,detach:j,tap:(n,r)=>M(i=>Y.tapSessionEmulator(t,e,i.bindingId,n,r)),gesture:n=>M(r=>Y.gestureSessionEmulator(t,e,r.bindingId,n)),button:n=>M(r=>Y.buttonSessionEmulator(t,e,r.bindingId,n))}}function xj(e){return e instanceof Error?e:Error(String(e))}var Sj=`rynx.session-resource-dock-width`;function Cj({session:e,runtimeSelector:t,leadingControls:n,initialDraft:r,initialMessage:i,sendInitialMessage:a=!1,onInitialMessageStarted:o,onInitialMessageConsumed:s,onInitialMessageFailed:c,terminalSlotRef:l,onTerminalActiveChange:d,readOnly:f=!1}){let[p,m]=bn(),h=p.get(`view`),g=h===`terminal`?`terminal`:`chat`;(0,u.useEffect)(()=>(d?.(e.id,g===`terminal`),()=>d?.(e.id,!1)),[d,e.id,g]);let _=iD(p.get(`surface`)),v=p.get(`panel`)===`resources`,y=h===`browser`||_!==null||v,b=_?.type===`browser`?_.pageId:null,x=(0,u.useRef)(null),S=(0,u.useRef)(null),C=(0,u.useRef)(`browser`),w=(0,u.useRef)(null),T=(0,u.useRef)(0),E=(0,u.useRef)(null),[D]=(0,u.useState)(wj),O=(0,u.useRef)(D),k=(0,u.useRef)(null),A=(0,u.useRef)(null),j=(0,u.useRef)(null),M=(0,u.useRef)(null),N=(0,u.useRef)(null),P=(0,u.useRef)(null),F=(0,u.useRef)(!1),[I,L]=(0,u.useState)(!1),[ee,te]=(0,u.useState)(!1),[ne,re]=(0,u.useState)(null),[R,ie]=(0,u.useState)(360),[ae,oe]=(0,u.useState)(!1),[se,ce]=(0,u.useState)(!1),[le,ue]=(0,u.useState)([]),[de,fe]=(0,u.useState)(!!i),[pe,me]=(0,u.useState)(!1),he=(0,u.useRef)(null),{state:ge,pendingSend:_e,current:ve,send:ye,stop:be}=VD(e.id,{runtimeSelector:t,allowSend:!f}),xe=_j({sessionId:e.id,runtimeSelector:t,active:!0,polling:y,readOnly:f}),Se=bj({sessionId:e.id,runtimeSelector:t,active:!0,polling:y,devicesActive:_?.type===`emulator`,readOnly:f}),Ce=(0,u.useMemo)(()=>lD(xe.browser,b,x.current),[xe.browser,b]),we=ID(_e,ge.runStatus===`running`||ge.waitingForInteraction,ve,e.status===`running`),Te=ve?ge.backgroundTaskCount:0,Ee=e.agent??(e.provider?uE(e.provider):void 0),De=eD(ge)?.model,Oe=(0,u.useMemo)(()=>tD(ge.items),[ge.items]),ke=(0,u.useMemo)(()=>!i||Oe.length>0?Oe:[{kind:`message`,id:`optimistic_initial`,responseId:`optimistic_initial`,role:`user`,text:i,images:[],files:[],streaming:!1,optimistic:!0}],[i,Oe]),Ae=_E(ge.statusKind,ge.note)?ge.note:void 0,je=ge.statusKind===`startup`&&Ae===void 0,Me=ge.waitingForInteraction||ge.runStatus===`running`&&!je,Ne=je||!Me&&(_e||de),Pe=xe.browser?.pages??[],Fe=_?.type===`emulator`||I,Ie=xe.loading||Se.loading,Le=Pe.length>0||Fe,Re=(0,u.useMemo)(()=>[...Pe.map(e=>aD(e.pageId)),...Fe?[oD()]:[]],[Pe,Fe]),ze=(0,u.useMemo)(()=>sD(le,Re),[Re,le]);(0,u.useEffect)(()=>{ue(e=>{let t=sD(e,Re);return Ej(e,t)?e:t})},[Re]),(0,u.useEffect)(()=>{let e=E.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().width,n=cD(t,1/0);ie(n);let r=O.current,i=cD(t,r??t*.44);r!==null&&e.style.setProperty(`--session-resource-dock-width`,`${i}px`),k.current=i,re(i)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,u.useEffect)(()=>()=>{j.current!==null&&window.cancelAnimationFrame(j.current),N.current?.(),Tj(P)},[]),(0,u.useEffect)(()=>{x.current=null,S.current=null,C.current=`browser`,w.current=null,L(!1),ce(!1),ue([]),T.current+=1},[t,e.id]),(0,u.useEffect)(()=>{!i||!a||he.current===i||(he.current=i,fe(!0),o?.(),ye(i).catch(e=>{fe(!1),Ux(e)&&c?.(i)}))},[i,c,o,ye,a]),(0,u.useEffect)(()=>{i&&Oe.some(e=>e.kind===`message`&&e.role===`user`&&e.optimistic!==!0&&e.text===i)&&(fe(!1),s?.())},[i,s,Oe]);let Be=(e,t=!0)=>{t&&(T.current+=1);let n=new URLSearchParams(p);e?(n.set(`surface`,e),n.delete(`panel`)):(n.delete(`surface`),n.set(`panel`,`resources`)),n.get(`view`)===`browser`&&n.set(`view`,`chat`),m(n,{replace:!0})},Ve=()=>{T.current+=1,ce(!1);let e=new URLSearchParams(p);e.delete(`surface`),e.delete(`panel`),e.get(`view`)===`browser`&&e.set(`view`,`chat`),m(e,{replace:!0})},He=()=>{if(C.current===`emulator`&&I){Be(oD(w.current));return}if(x.current){Be(aD(x.current));return}if(I){Be(oD(w.current));return}Be(null)};(0,u.useEffect)(()=>{_&&(C.current=_.type,_.type===`emulator`&&L(!0))},[_?.type]),(0,u.useEffect)(()=>{let e=Se.binding?.bindingId??null;e&&(w.current&&e!==w.current?L(!0):w.current||L(!0),w.current=e)},[Se.binding?.bindingId]),(0,u.useEffect)(()=>{if(h!==`browser`)return;let e=new URLSearchParams(p);e.set(`view`,`chat`),e.set(`surface`,aD(Ce)),e.delete(`panel`),m(e,{replace:!0})},[h,p,Ce,m]),(0,u.useEffect)(()=>{if(_?.type!==`browser`)return;Ce&&(x.current=Ce);let e=aD(Ce);if(p.get(`surface`)===e)return;let t=new URLSearchParams(p);t.set(`surface`,e),m(t,{replace:!0})},[_?.type,p,Ce,m]),(0,u.useEffect)(()=>{let e=Pe.map(e=>e.pageId),t=uD(S.current,xe.browser);S.current=e,!(!t||_?.type!==`browser`)&&(x.current=t,Be(aD(t),!1))},[Pe,xe.browser,_?.type]),(0,u.useEffect)(()=>{if(_?.type!==`emulator`)return;let e=oD(Se.binding?.bindingId);if(p.get(`surface`)===e)return;let t=new URLSearchParams(p);t.set(`surface`,e),m(t,{replace:!0})},[Se.binding?.bindingId,_?.type,p,m]),(0,u.useEffect)(()=>{if(!(!y||Ie)){if(!Le){_&&Be(null,!1);return}_?.type===`browser`&&Ce||_?.type===`emulator`&&Fe||(C.current===`emulator`&&Fe?Be(oD(Se.binding?.bindingId),!1):Ce?Be(aD(Ce),!1):Fe&&Be(oD(Se.binding?.bindingId),!1))}},[Se.binding?.bindingId,Fe,Le,_?.type,y,Ie,Ce]);let Ue=async()=>{if(F.current)return;F.current=!0,te(!0);let e=T.current;try{let t=xe.browser?.status===`ready`?await xe.createPage():await xe.openBrowser(),n=t?.activePageId??t?.pages.at(-1)?.pageId;if(!t){V.error(`Could not create Browser tab: ${xe.currentError()??`Browser is unavailable`}`);return}n&&T.current===e&&Be(aD(n),!1)}finally{F.current=!1,te(!1)}},We=e=>{let t=E.current;if(!t)return null;let n=cD(t.getBoundingClientRect().width,e);return t.style.setProperty(`--session-resource-dock-width`,`${n}px`),k.current=n,n},Ge=e=>{let t=E.current;return t?We(t.getBoundingClientRect().right-e):null},Ke=e=>{if(e!==null){O.current=e,re(e);try{window.localStorage.setItem(Sj,String(Math.round(e)))}catch{}}},qe=e=>{M.current=e,j.current===null&&(j.current=window.requestAnimationFrame(()=>{j.current=null;let e=M.current;M.current=null,e!==null&&Ge(e)}))},Je=(e,t,n)=>{if(A.current!==t)return;j.current!==null&&(window.cancelAnimationFrame(j.current),j.current=null),M.current=null;let r=n===void 0?k.current:Ge(n);Ke(r),A.current=null,N.current?.(),N.current=null,e.hasPointerCapture(t)&&e.releasePointerCapture(t),Tj(P),oe(!1)},Ye=e=>{if(e.button!==0)return;e.preventDefault(),N.current?.(),A.current=e.pointerId;let t=e.currentTarget;t.setPointerCapture(e.pointerId);let n=e=>{A.current===e.pointerId&&qe(e.clientX)},r=e=>{Je(t,e.pointerId,e.clientX)},i=e=>{Je(t,e.pointerId)};window.addEventListener(`pointermove`,n,!0),window.addEventListener(`pointerup`,r,!0),window.addEventListener(`pointercancel`,i,!0),N.current=()=>{window.removeEventListener(`pointermove`,n,!0),window.removeEventListener(`pointerup`,r,!0),window.removeEventListener(`pointercancel`,i,!0)};let a=document.documentElement.style;P.current={cursor:a.cursor,userSelect:a.userSelect},a.cursor=`col-resize`,a.userSelect=`none`,oe(!0),Ge(e.clientX)},Xe=e=>{let t=E.current;if(!t)return;let n=k.current??cD(t.getBoundingClientRect().width,t.getBoundingClientRect().width*.44),r=e.shiftKey?32:16,i=null;e.key===`ArrowLeft`&&(i=n+r),e.key===`ArrowRight`&&(i=n-r),e.key===`Home`&&(i=0),e.key===`End`&&(i=1/0),i!==null&&(e.preventDefault(),Ke(We(i)))},Ze=e=>{T.current+=1;let t=new URLSearchParams(p);t.set(`view`,e),m(t,{replace:!0})},Qe=(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`size-9 shrink-0`,"aria-label":g===`chat`?`Open terminal`:`Open chat`,title:g===`chat`?`Open terminal`:`Open chat`,onClick:()=>Ze(g===`chat`?`terminal`:`chat`),children:g===`chat`?(0,H.jsx)(oi,{}):(0,H.jsx)(br,{})}),$e=(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`size-9 shrink-0`,"aria-label":y?`Hide Session resources`:`Show Session resources`,title:y?`Hide Session resources`:`Show Session resources`,onClick:y?Ve:He,children:y?(0,H.jsx)(jr,{}):(0,H.jsx)(Mr,{})}),et=(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`hidden size-8 shrink-0 lg:inline-flex`,"aria-label":se?`Restore split view`:`Expand resource pane`,"aria-pressed":se,title:se?`Restore split view`:`Expand resource pane`,onClick:()=>ce(e=>!e),children:se?(0,H.jsx)(Qr,{}):(0,H.jsx)($n,{})}),tt=f?void 0:(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`size-8 shrink-0`,"aria-label":`Session settings`,title:`Session settings`,onClick:()=>me(!0),children:(0,H.jsx)(Kr,{})});return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,H.jsxs)(`div`,{ref:E,className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden [--session-resource-dock-width:44%]`,children:[(0,H.jsxs)(`section`,{"aria-hidden":se,className:X(`min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,se?`hidden`:`flex`),children:[(0,H.jsxs)(`header`,{className:`desktop-macos-titlebar-header app-drag-region flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--border)] px-3 sm:px-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[n,(0,H.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e.title??Ee??`session`})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[Qe,!y&&$e]})]}),(0,H.jsxs)(fE,{value:g,className:`relative flex min-h-0 min-w-0 flex-1 flex-col gap-0`,children:[(0,H.jsxs)(hE,{value:`chat`,forceMount:!0,className:`mt-0 flex min-h-0 flex-1 flex-col data-[state=inactive]:hidden`,children:[(0,H.jsx)(aA,{todos:ge.todos}),(0,H.jsx)(mj,{items:ke,historyLoaded:ge.historyLoaded,running:we,backgroundTaskCount:Te,startingUp:Ne,startupStatus:je?ge.note:void 0,mcpStatus:Ae,waitingForInteraction:ge.waitingForInteraction,queueStatus:ge.statusKind===`queue`?ge.note:void 0,sessionId:e.id,runtimeSelector:t,canResolveInteractions:!f}),!f&&(0,H.jsx)(Ck,{initialDraft:r,model:De,running:we,collaborationMode:ge.collaborationMode,streamCurrent:ve,sessionId:e.id,runtimeSelector:t,onSend:ye,onStop:be})]}),(0,H.jsx)(hE,{value:`terminal`,forceMount:!0,"aria-hidden":g!==`terminal`,className:`mt-0 flex min-h-0 flex-1 flex-col data-[state=inactive]:invisible data-[state=inactive]:absolute data-[state=inactive]:inset-0`,children:(0,H.jsx)(`div`,{ref:l,className:`flex min-h-0 flex-1 flex-col`})})]})]}),y&&(0,H.jsxs)(H.Fragment,{children:[!se&&(0,H.jsx)(`div`,{role:`separator`,"aria-label":`Resize Session resources`,"aria-orientation":`vertical`,"aria-valuemin":Math.min(360,R),"aria-valuemax":R,"aria-valuenow":Math.round(ne??360),"aria-valuetext":`${Math.round(ne??360)} pixels wide`,tabIndex:0,title:`Drag to resize Session resources`,className:`group relative z-30 -mx-1 hidden w-2 shrink-0 cursor-col-resize touch-none outline-none lg:block`,onPointerDown:Ye,onKeyDown:Xe,children:(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 left-1/2 -translate-x-1/2 bg-[var(--border)] transition-[width,background-color] duration-150 group-hover:w-0.5 group-hover:bg-[var(--primary)] group-focus-visible:w-0.5 group-focus-visible:bg-[var(--primary)] ${ae?`w-0.5 bg-[var(--primary)]`:`w-px`}`})}),(0,H.jsxs)(`aside`,{className:X(`flex min-h-0 min-w-0 flex-col overflow-hidden bg-[var(--card)]`,se?`h-full w-full`:`absolute inset-0 z-20 lg:static lg:z-auto lg:w-[var(--session-resource-dock-width)] lg:min-w-[22.5rem] lg:max-w-[calc(100%_-_26.25rem)]`),"aria-label":`Session resources`,children:[Le&&(0,H.jsx)(Dk,{pages:Pe,order:ze,selectedPageId:_?.type===`browser`?Ce:null,selectionDisabled:xe.pendingAction!==null,mutationDisabled:xe.disabled,createDisabled:f||xe.createDisabled||ee,createPending:ee,emulatorAttached:!!Se.binding,emulator:Fe?{selected:_?.type===`emulator`,label:Se.binding?.deviceName??`Emulator`,busy:Se.loading||Se.mutating}:null,onSelectPage:e=>{x.current=e,Be(aD(e)),xe.browser?.status===`ready`&&xe.activatePage(e)},onClosePage:e=>{T.current+=1,x.current===e&&(x.current=null),xe.closePage(e)},onCreatePage:()=>{f||Ue()},onSelectEmulator:()=>{L(!0),Be(oD(Se.binding?.bindingId))},onCloseEmulator:()=>{L(!1),C.current=`browser`,Be(Ce?aD(Ce):null)},onAddEmulator:()=>{L(!0),Be(oD(Se.binding?.bindingId))},headerLeadingAction:se?n:void 0,settingsAction:tt,leadingAction:et,trailingAction:$e}),!Le&&(0,H.jsxs)(H.Fragment,{children:[se&&n&&(0,H.jsx)(`div`,{className:`absolute left-3 top-1.5 z-10 flex h-8 items-center`,children:n}),(0,H.jsxs)(`div`,{className:`absolute right-3 top-1.5 z-10 flex items-center gap-1 sm:right-4`,children:[tt,et,$e]})]}),Le?_?.type===`emulator`?(0,H.jsx)(Pk,{sessionId:e.id,runtimeSelector:t,controller:Se,readOnly:f}):_?.type===`browser`?(0,H.jsx)(tk,{sessionId:e.id,runtimeSelector:t,pageId:Ce,browserResource:xe,readOnly:f}):(0,H.jsxs)(`div`,{className:`grid min-h-0 flex-1 place-items-center`,"aria-live":`polite`,children:[(0,H.jsx)(B,{className:`size-5 animate-spin text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Selecting Session resource`})]}):(0,H.jsx)(Dj,{browserBusy:f||xe.createDisabled||ee,emulatorBusy:f||Se.mutating,onOpenBrowser:()=>{f||Ue()},onOpenEmulator:()=>{L(!0),Be(oD(Se.binding?.bindingId))}})]})]})]}),(0,H.jsx)(dk,{open:pe,onOpenChange:me,runtimeSelector:t,sessionId:e.id})]})}function wj(){if(typeof window>`u`)return null;try{let e=Number(window.localStorage.getItem(Sj));return Number.isFinite(e)&&e>0?e:null}catch{return null}}function Tj(e){let t=e.current;!t||typeof document>`u`||(document.documentElement.style.cursor=t.cursor,document.documentElement.style.userSelect=t.userSelect,e.current=null)}function Ej(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Dj({browserBusy:e,emulatorBusy:t,onOpenBrowser:n,onOpenEmulator:r}){return(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-6`,children:(0,H.jsxs)(`div`,{className:`w-full max-w-64 space-y-1`,"aria-label":`Session resource choices`,children:[(0,H.jsxs)(`button`,{type:`button`,disabled:e,onClick:n,className:`flex h-11 w-full items-center gap-3 rounded-md px-3 text-left text-sm outline-none transition-colors hover:bg-[var(--muted)] focus-visible:ring-2 focus-visible:ring-[var(--ring)] disabled:pointer-events-none disabled:opacity-50`,children:[e?(0,H.jsx)(B,{className:`size-4 shrink-0 animate-spin`}):(0,H.jsx)(Xn,{className:`size-4 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{children:`Browser`})]}),(0,H.jsxs)(`button`,{type:`button`,disabled:t,onClick:r,className:`flex h-11 w-full items-center gap-3 rounded-md px-3 text-left text-sm outline-none transition-colors hover:bg-[var(--muted)] focus-visible:ring-2 focus-visible:ring-[var(--ring)] disabled:pointer-events-none disabled:opacity-50`,children:[t?(0,H.jsx)(B,{className:`size-4 shrink-0 animate-spin`}):(0,H.jsx)($r,{className:`size-4 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{children:`Emulator`})]})]})})}var Oj=400,kj=160;function Aj({sessions:e,runtimeSelector:t,runtimeLabel:n,listError:r,loading:i,selectedId:a,onCollapsedChange:o,onSelect:s,onNew:c,onRetry:l,onFork:d,onDeleted:f,readOnly:p=!1}){let[m,h]=(0,u.useState)(``),g=m.trim().toLocaleLowerCase(),_=(0,u.useMemo)(()=>g?e.filter(e=>[e.title,e.id,e.provider,e.provider?uE(e.provider):void 0,e.agent,e.source].some(e=>e?.toLocaleLowerCase().includes(g))):e,[g,e]);async function v(e){try{await Y.closeSession(e,t)}catch(e){V.error(`Delete session failed: ${e instanceof Error?e.message:String(e)}`);return}f(e)}return(0,H.jsxs)(`aside`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-[var(--card)]/35`,"aria-label":`Sessions`,children:[(0,H.jsxs)(`div`,{className:`app-drag-region desktop-macos-titlebar-inset shrink-0 border-b border-[var(--border)] p-2.5`,children:[(0,H.jsxs)(`div`,{className:`mb-2 flex h-7 items-center gap-2 px-0.5`,children:[(0,H.jsxs)(hn,{to:zx(jx(t)),className:`app-no-drag flex items-center gap-2`,"aria-label":`Rynx Sessions`,children:[(0,H.jsx)(`img`,{src:NS,alt:`rynx`,className:`h-5 w-auto dark:brightness-0 dark:invert`}),(0,H.jsx)(`span`,{className:`label-caps text-[8px] text-[var(--muted-foreground)]`,children:`control`})]}),(0,H.jsx)(J,{variant:`ghost`,size:`icon-sm`,className:`app-no-drag ml-auto hidden md:inline-flex`,onClick:()=>o(!0),title:`Collapse session list`,"aria-label":`Collapse session list`,"aria-expanded":`true`,children:(0,H.jsx)(kr,{className:`size-3.5`})})]}),(0,H.jsxs)(`div`,{className:`app-no-drag flex items-center gap-2`,children:[(0,H.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`sr-only`,children:`Search sessions`}),(0,H.jsx)(Hr,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-[var(--muted-foreground)]`}),(0,H.jsx)(Ag,{value:m,onChange:e=>h(e.target.value),placeholder:`Search sessions`,className:`h-11 rounded-md pl-8 text-xs md:h-8`})]}),!p&&(0,H.jsx)(J,{size:`icon`,className:`size-11 shrink-0 md:size-8`,onClick:c,title:`New session`,"aria-label":`New session`,children:(0,H.jsx)(Ir,{})})]})]}),r&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 border-b border-[var(--border)] bg-[var(--warning)]/8 px-3 py-2 text-xs`,children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 text-[var(--warning)]`,children:r}),(0,H.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 shrink-0 px-2 text-[10px]`,onClick:l,children:`Retry`})]}),(0,H.jsx)(U_,{className:`min-h-0 flex-1`,children:i&&e.length===0?(0,H.jsx)(Mj,{}):e.length===0?(0,H.jsxs)(`div`,{className:`grid place-items-center gap-3 px-5 py-10 text-center`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`p`,{className:`text-sm font-medium`,children:[`No sessions on `,n]}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:`Create one to start a conversation and terminal.`})]}),!p&&(0,H.jsxs)(J,{size:`sm`,className:`h-11 md:h-8`,onClick:c,children:[(0,H.jsx)(Ir,{}),` New session`]})]}):_.length===0?(0,H.jsxs)(`div`,{className:`px-5 py-10 text-center text-xs text-[var(--muted-foreground)]`,children:[`No sessions match “`,m.trim(),`”.`]}):(0,H.jsx)(`ul`,{className:`space-y-0.5 px-1.5 py-1.5`,children:_.map(e=>(0,H.jsx)(jj,{session:e,runtimeLabel:n,selected:a===e.id,onSelect:()=>s(e.id),onFork:()=>d(e.id),onDelete:()=>v(e.id),readOnly:p},e.id))})})]})}function jj({session:e,runtimeLabel:t,selected:n,onSelect:r,onFork:i,onDelete:a,readOnly:o}){let[s,c]=(0,u.useState)(!1),[l,d]=(0,u.useState)(!1),[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(!1),g=(0,u.useRef)(null),_=(0,u.useRef)(null),v=Nj(e.updatedAt??e.createdAt),y=e.agent??(e.provider?uE(e.provider):void 0),b=e.title??y??e.source??`Untitled session`;(0,u.useEffect)(()=>()=>{g.current!==null&&window.clearTimeout(g.current),_.current!==null&&window.clearTimeout(_.current)},[]);let x=()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},S=()=>{_.current!==null&&(window.clearTimeout(_.current),_.current=null)},C=()=>{x(),S(),!f&&d(!0)},w=()=>{S(),!(f||l||g.current!==null)&&(g.current=window.setTimeout(()=>{g.current=null,d(!0)},Oj))},T=()=>{x(),S(),d(!1)},E=()=>{x(),S(),l&&(_.current=window.setTimeout(()=>{_.current=null,d(!1)},kj))};return(0,H.jsxs)(`li`,{className:X(`group relative flex min-h-9 items-center rounded-md transition-colors`,n?`bg-[var(--muted)]/70`:`hover:bg-[var(--muted)]/40`),onMouseEnter:w,onMouseLeave:E,children:[(0,H.jsxs)(xg,{modal:!1,open:l,onOpenChange:e=>{e?C():T()},children:[(0,H.jsx)(Sg,{asChild:!0,children:(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute right-0 top-2 size-px`})}),(0,H.jsxs)(Cg,{side:`right`,align:`start`,sideOffset:8,className:`w-72 p-3`,"aria-label":`Details for ${b}`,onMouseEnter:C,onMouseLeave:E,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:[(0,H.jsxs)(`div`,{className:`mb-2.5 flex min-w-0 items-center justify-between gap-3`,children:[(0,H.jsx)(`p`,{className:`min-w-0 truncate text-xs font-medium`,children:b}),(0,H.jsx)(`span`,{className:`shrink-0 text-[10px] text-[var(--muted-foreground)]`,children:v})]}),(0,H.jsxs)(`div`,{className:`space-y-2 font-mono text-[11px] leading-4`,children:[y&&(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,"aria-label":`Target: ${y}`,children:[(0,H.jsx)(Mn,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:y})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,"aria-label":`Source: ${e.source}`,children:[(0,H.jsx)(Nn,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:e.source})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,"aria-label":`Session: ${e.id}`,children:[(0,H.jsx)(rr,{"aria-hidden":`true`,className:`mt-px size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`min-w-0 select-text break-all`,children:e.id})]})]})]})]}),(0,H.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 px-2.5 py-2 text-left outline-none focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--ring)]`,"aria-current":n?`page`:void 0,onClick:r,onFocus:C,onBlur:E,children:(0,H.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:b})}),!o&&(0,H.jsxs)(`div`,{className:`group/actions relative mr-2 size-8 shrink-0`,onMouseEnter:T,onMouseLeave:w,children:[e.status===`running`&&(0,H.jsx)(`span`,{role:`status`,"aria-label":`Running`,title:`Running`,className:`pointer-events-none absolute inset-0 grid place-items-center text-[var(--muted-foreground)] transition-opacity duration-150 group-hover:opacity-0 group-focus-within/actions:opacity-0 group-has-data-[state=open]/actions:opacity-0 [@media(hover:none)]:opacity-0`,children:(0,H.jsx)(B,{className:`size-3.5 animate-spin motion-reduce:animate-none`})}),(0,H.jsxs)(xg,{open:f,onOpenChange:e=>{p(e),e&&T()},children:[(0,H.jsx)(Sg,{asChild:!0,children:(0,H.jsx)(J,{variant:`ghost`,size:`icon`,className:`absolute inset-0 size-8 text-[var(--muted-foreground)] opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100 [@media(hover:none)]:opacity-100`,title:`Session actions for ${b}`,"aria-label":`Session actions for ${b}`,children:(0,H.jsx)(Zn,{})})}),(0,H.jsxs)(Cg,{align:`end`,children:[(0,H.jsxs)(wg,{disabled:m||e.status===`running`,onSelect:()=>{h(!0),i().finally(()=>h(!1))},children:[m?(0,H.jsx)(B,{className:`animate-spin motion-reduce:animate-none`}):(0,H.jsx)(lr,{}),`Fork session`]}),(0,H.jsxs)(wg,{variant:`destructive`,onSelect:()=>c(!0),children:[(0,H.jsx)(si,{}),`Delete session`]})]})]}),(0,H.jsx)(uu,{open:s,onOpenChange:c,children:(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsx)(vu,{children:`Delete this session?`}),(0,H.jsxs)(yu,{children:[`“`,b,`” will be deleted from `,t,`. This cannot be undone.`]})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:()=>void a(),children:`Delete`})]})]})})]})]})}function Mj(){return(0,H.jsx)(`div`,{"aria-label":`Loading sessions`,className:`space-y-0.5 px-1.5 py-1.5`,children:Array.from({length:6},(e,t)=>(0,H.jsx)(`div`,{className:`grid min-h-9 content-center rounded-md px-2.5`,children:(0,H.jsx)(`div`,{className:`h-3 w-2/3 animate-pulse rounded bg-[var(--muted)]`})},t))})}function Nj(e){let t=Date.parse(e);if(!Number.isFinite(t))return`unknown`;let n=Math.max(0,Math.round((Date.now()-t)/1e3));return n<60?`now`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:n<604800?`${Math.floor(n/86400)}d ago`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(t)}var Pj=`!no-project`,Fj=`!new-project`;function Ij({runtimeLabel:e,options:t,selection:n,configuration:r,projects:i,projectId:a,loading:o,projectsLoading:s,submitting:c,error:l,projectError:d,listCollapsed:f,onShowSessions:p,onRetryOptions:m,onSelectionChange:h,onConfigurationChange:g,onProjectChange:_,onNewProject:v,onSubmit:y}){let[b,x]=(0,u.useState)(``),S=(0,u.useRef)(null),C=(0,u.useRef)(!1),w=(0,u.useRef)(void 0),T=_k({policy:hk,onChange:()=>{w.current=void 0}}),E=dE(n,t),D=a?i.find(e=>e.id===a):void 0,O=!!((b.trim()||T.items.length>0)&&n&&!o&&!c&&!T.hasPending&&!T.hasFailed);async function k(){let e=b.trim();if(!e&&T.items.length===0||!n||o||c||T.hasPending||T.hasFailed)return;let t=T.items.length>0?w.current??ND(`msg`):void 0;t&&(w.current=t),await y({text:e,attachments:T.readyUploads,...t?{clientMessageId:t}:{}})&&(T.clear(),x(``),w.current=void 0)}return(0,H.jsxs)(`main`,{className:`relative h-full min-h-0 min-w-0 flex-1 overflow-hidden bg-[radial-gradient(circle_at_50%_-10%,color-mix(in_srgb,var(--primary)_9%,transparent),transparent_38%)]`,children:[f&&(0,H.jsx)(J,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`desktop-macos-titlebar-leading-control absolute left-3 top-2.5 z-10 hidden md:inline-flex`,onClick:p,title:`Show session list`,"aria-label":`Show session list`,children:(0,H.jsx)(Ar,{className:`size-3.5`})}),(0,H.jsx)(`div`,{className:`desktop-macos-home-titlebar`,"aria-hidden":`true`}),(0,H.jsx)(U_,{className:`h-full`,viewportClassName:`[&>div]:!flex [&>div]:min-h-full [&>div]:flex-col`,children:(0,H.jsxs)(`div`,{className:`mx-auto grid w-full max-w-3xl flex-1 content-center px-4 py-8 sm:px-6 lg:py-12`,children:[(0,H.jsx)(`div`,{className:`mb-6 flex items-center gap-2 md:hidden`,children:(0,H.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,className:`h-11 px-2`,onClick:p,children:[(0,H.jsx)(An,{}),` Sessions`]})}),(0,H.jsxs)(`div`,{className:`mb-7`,children:[(0,H.jsx)(`p`,{className:`label-caps mb-3 text-[10px] text-[var(--primary)]`,children:`New session`}),(0,H.jsx)(`h1`,{className:`text-3xl font-semibold tracking-[-0.035em] sm:text-4xl`,children:`What should we work on?`}),(0,H.jsxs)(`p`,{className:`mt-3 max-w-2xl text-sm leading-6 text-[var(--muted-foreground)] sm:text-base`,children:[`Describe the outcome you want. The session and terminal will run on`,` `,(0,H.jsx)(`span`,{className:`font-medium text-[var(--foreground)]`,children:e}),`.`]})]}),(0,H.jsxs)(`form`,{ref:S,onSubmit:e=>{e.preventDefault(),k()},children:[(0,H.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--card)] shadow-[0_12px_34px_rgba(24,24,27,0.08)] transition-[border-color,box-shadow] focus-within:border-[color-mix(in_srgb,var(--primary)_55%,var(--border))] focus-within:shadow-[0_0_0_3px_color-mix(in_srgb,var(--primary)_9%,transparent),0_12px_34px_rgba(24,24,27,0.08)]`,"aria-busy":c,children:[(0,H.jsx)(`label`,{htmlFor:`session-initial-prompt`,className:`sr-only`,children:`Initial task`}),(0,H.jsx)(vk,{items:T.items,disabled:c,onRemove:T.remove,className:`px-5 pt-4`}),(0,H.jsx)(jg,{id:`session-initial-prompt`,value:b,disabled:c,rows:7,className:`min-h-40 max-h-[min(45dvh,24rem)] resize-none overflow-y-auto rounded-none border-0 bg-transparent px-5 py-5 text-base leading-7 shadow-none focus-visible:border-0 focus-visible:ring-0 md:text-base`,placeholder:`Fix a bug, build a feature, or investigate the codebase…`,onChange:e=>{w.current=void 0,x(e.target.value)},onPaste:T.onPaste,onCompositionStart:()=>{C.current=!0},onCompositionEnd:()=>{C.current=!1},onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||C.current||e.nativeEvent.isComposing||e.keyCode===229||(e.preventDefault(),S.current?.requestSubmit())}}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-[var(--border)] bg-[var(--muted)]/15 p-2.5 sm:flex-nowrap sm:pl-4`,children:[(0,H.jsx)(yk,{policy:hk,disabled:c,onFiles:T.addFiles}),(0,H.jsx)(`label`,{htmlFor:`session-project`,className:`sr-only`,children:`Project`}),(0,H.jsxs)(my,{value:a?`project:${a}`:Pj,disabled:s||c,onValueChange:e=>{if(e===Fj){v();return}_(e===Pj?null:e.startsWith(`project:`)?e.slice(8):null)},children:[(0,H.jsx)(_y,{id:`session-project`,className:`w-36 bg-[var(--background)] sm:w-40`,"aria-label":`Project`,children:(0,H.jsx)(gy,{placeholder:s?`Loading projects…`:`Choose project`,children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[D?(0,H.jsx)(sr,{className:`size-3.5 shrink-0 text-[var(--primary)]`}):(0,H.jsx)(or,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`truncate`,children:D?.name??`No project`})]})})}),(0,H.jsxs)(by,{align:`start`,children:[i.length>0&&(0,H.jsxs)(hy,{children:[(0,H.jsxs)(xy,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:[`Projects on `,e]}),i.map(e=>(0,H.jsx)(Sy,{value:`project:${e.id}`,textValue:e.name,children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(sr,{className:`size-3.5 shrink-0 text-[var(--primary)]`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))]}),i.length>0&&(0,H.jsx)(Cy,{}),(0,H.jsx)(Sy,{value:Fj,children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(or,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{children:`New project`})]})}),(0,H.jsx)(Sy,{value:Pj,children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(di,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{children:`No project`})]})})]})]}),(0,H.jsx)(Lj,{options:t,selection:n,configuration:r,selectedOption:E,disabled:o||c,loading:o,onSelectionChange:h,onConfigurationChange:g}),(0,H.jsx)(`label`,{htmlFor:`session-permission`,className:`sr-only`,children:`Permissions`}),(0,H.jsxs)(my,{value:r.permissionPreset,disabled:c,onValueChange:e=>g({...r,permissionPreset:e}),children:[(0,H.jsx)(_y,{id:`session-permission`,className:`w-36 bg-[var(--background)] sm:w-40`,"aria-label":`Permissions`,children:(0,H.jsx)(gy,{children:(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(Zr,{className:`size-3.5 shrink-0 text-[var(--muted-foreground)]`}),(0,H.jsx)(`span`,{className:`truncate`,children:Rj(r.permissionPreset)})]})})}),(0,H.jsxs)(by,{align:`end`,children:[(0,H.jsx)(Sy,{value:`default`,children:`Default permissions`}),(0,H.jsx)(Sy,{value:`read-only`,children:`Read only`}),(0,H.jsx)(Sy,{value:`workspace-write`,children:`Workspace write`}),(0,H.jsx)(Sy,{value:`full-access`,children:`Full access`})]})]}),(0,H.jsx)(J,{type:`submit`,size:`icon`,className:`size-11 shrink-0 rounded-full md:size-10`,disabled:!O,"aria-label":c?`Starting session`:`Start session`,children:c?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Ur,{})})]})]}),(0,H.jsxs)(`div`,{className:`mt-2 flex min-h-6 flex-wrap items-start justify-between gap-x-4 gap-y-1 px-1 text-xs text-[var(--muted-foreground)]`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,role:l||d?`alert`:`status`,"aria-live":l||d?`assertive`:`polite`,children:[(0,H.jsx)(`span`,{children:l??d??(E&&!E.ready?`${E.reason??`${E.name} needs setup on ${e}.`} Start to open its login terminal; your task will wait safely.`:``)}),l&&t.providers.length===0&&t.agents.length===0&&!o&&(0,H.jsx)(J,{type:`button`,variant:`link`,size:`sm`,className:`h-auto px-0 text-xs`,onClick:m,children:`Retry`})]}),(0,H.jsx)(`span`,{className:`hidden font-mono text-[10px] sm:inline`,children:`Enter to start · Shift+Enter for newline`})]})]})]})})]})}function Lj({options:e,selection:t,configuration:n,selectedOption:r,disabled:i,loading:a,onSelectionChange:o,onConfigurationChange:s}){let c=(t?.kind===`provider`?e.providers.find(e=>e.id===t.id):void 0)?.models?.find(e=>e.id===n.model),l=c?.reasoningOptions.find(e=>e.value===n.reasoningEffort),u=(e,t,r)=>{o({kind:`provider`,id:e}),s({permissionPreset:n.permissionPreset,...t?{model:t}:{},...r?{reasoningEffort:r}:{}})};return(0,H.jsxs)(xg,{children:[(0,H.jsx)(Sg,{asChild:!0,children:(0,H.jsxs)(J,{id:`session-launch-target`,type:`button`,variant:`outline`,disabled:i,className:`w-44 justify-start bg-[var(--background)] font-normal sm:w-48 md:ml-auto`,"aria-label":`Run with`,children:[r?(0,H.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,H.jsx)(zj,{status:lE(r)}),(0,H.jsxs)(`span`,{className:`truncate`,children:[r.name,c?` / ${c.label}`:``,l?` / ${l.label}`:``]})]}):(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[var(--muted-foreground)]`,children:a?`Loading…`:`Choose runtime / model / thinking`}),(0,H.jsx)(Fn,{className:`ml-auto size-3.5 shrink-0 opacity-55`})]})}),(0,H.jsxs)(Cg,{align:`end`,className:`min-w-56`,children:[e.providers.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Tg,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:`Providers · Runtime → Model → Thinking`}),e.providers.map(e=>{let r=e.models??[],i=t?.kind===`provider`&&t.id===e.id;return r.length===0?(0,H.jsxs)(wg,{onSelect:()=>u(e.id),children:[(0,H.jsx)(zj,{status:lE(e)}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),i&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]},`provider:${e.id}`):(0,H.jsxs)(Dg,{children:[(0,H.jsxs)(Og,{children:[(0,H.jsx)(zj,{status:lE(e)}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]}),(0,H.jsxs)(kg,{children:[(0,H.jsx)(Tg,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:`Model`}),r.map(t=>{let r=i&&n.model===t.id;return t.reasoningOptions.length===0?(0,H.jsxs)(wg,{onSelect:()=>u(e.id,t.id),children:[(0,H.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[t.label,t.isDefault?` · default`:``]}),r&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]},t.id):(0,H.jsxs)(Dg,{children:[(0,H.jsx)(Og,{children:(0,H.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[t.label,t.isDefault?` · default`:``]})}),(0,H.jsxs)(kg,{children:[(0,H.jsx)(Tg,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:`Thinking effort`}),t.reasoningOptions.map(i=>{let a=r&&n.reasoningEffort===i.value;return(0,H.jsxs)(wg,{onSelect:()=>u(e.id,t.id,i.value),children:[(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i.label}),a&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]},i.value)})]})]},t.id)})]})]},`provider:${e.id}`)})]}),e.providers.length>0&&e.agents.length>0&&(0,H.jsx)(Eg,{}),e.agents.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Tg,{className:`font-mono text-[9px] uppercase tracking-[0.12em]`,children:`Agents`}),e.agents.map(e=>{let n=t?.kind===`agent`&&t.id===e.id;return(0,H.jsxs)(wg,{onSelect:()=>o({kind:`agent`,id:e.id}),children:[(0,H.jsx)(zj,{status:lE(e)}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name??e.id}),n&&(0,H.jsx)(Pn,{className:`size-3.5 text-[var(--primary)]`})]},`agent:${e.id}`)})]})]})]})}function Rj(e){return{default:`Default`,"read-only":`Read only`,"workspace-write":`Workspace write`,"full-access":`Full access`}[e]}function zj({status:e}){let t=e===`ready`?`Ready`:e===`needs_setup`?`Needs setup`:`Readiness not reported`;return(0,H.jsxs)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,title:t,children:[(0,H.jsx)(`span`,{className:`size-2 rounded-full ${e===`ready`?`bg-[var(--success)]`:e===`needs_setup`?`bg-[var(--warning)]`:`bg-[var(--muted-foreground)]/55`}`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`sr-only`,children:t})]})}var Bj=`rynx.control.theme`;function Vj(){let e=localStorage.getItem(Bj);return e===`light`||e===`dark`?e:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function Hj(){let[e,t]=(0,u.useState)(Vj);return(0,u.useEffect)(()=>{document.documentElement.classList.toggle(`dark`,e===`dark`),localStorage.setItem(Bj,e)},[e]),{theme:e,toggle:()=>t(e=>e===`dark`?`light`:`dark`)}}var Uj=2,Wj=1,Gj=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(Uj,Math.floor(u/e.css.cell.width)),rows:Math.max(Wj,Math.floor(l/e.css.cell.height))}}},Kj=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=Jj.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function qj(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var Jj=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!qj(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),!(!n.isWrapped||o.indexOf(` `)!==-1)););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},Yj=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Xj(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var Zj=class{constructor(e=Xj,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||Yj;this._linkProvider=this._terminal.registerLinkProvider(new Kj(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},Qj=Object.defineProperty,$j=Object.getOwnPropertyDescriptor,eM=(e,t,n,r)=>{for(var i=r>1?void 0:r?$j(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Qj(t,n,i),i},tM=(e,t)=>(n,r)=>t(n,r,e),nM=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?sM.isErrorNoTelemetry(e)?new sM(e.message+`
|
|
63
63
|
|
|
64
64
|
`+e.stack):Error(e.message+`
|
|
65
65
|
|
|
66
|
-
`+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)}};function tM(e){rM(e)||eM.onUnexpectedError(e)}var nM=`Canceled`;function rM(e){return e instanceof iM||e instanceof Error&&e.name===nM&&e.message===nM}var iM=class extends Error{constructor(){super(nM),this.name=this.message}},aM=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},oM;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(oM||={});var sM=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||oM.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};sM.empty=new sM(e=>{});function cM(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var lM;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(lM||={});var uM=null;function dM(e){return uM?.trackDisposable(e),e}function fM(e){uM?.markAsDisposed(e)}function pM(e,t){uM?.setParent(e,t)}function mM(e){if(lM.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function hM(...e){return gM(()=>mM(e))}function gM(e){let t=dM({dispose:cM(()=>{fM(t),e()})});return t}var _M=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,dM(this)}dispose(){this._isDisposed||(fM(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{mM(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return pM(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(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(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),pM(e,null))}};_M.DISABLE_DISPOSED_WARNING=!1;var vM=_M,yM=class{constructor(){this._store=new vM,dM(this),pM(this._store,this)}dispose(){fM(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};yM.None=Object.freeze({dispose(){}});var bM=class{constructor(){this._isDisposed=!1,dM(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&pM(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,fM(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&pM(e,null),e}},xM=typeof process<`u`&&`title`in process,SM=xM?`node`:navigator.userAgent,CM=xM?`node`:navigator.platform,wM=SM.includes(`Firefox`),TM=SM.includes(`Edge`),EM=/^((?!chrome|android).)*safari/i.test(SM);function DM(){if(!EM)return 0;let e=SM.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(CM),[`Windows`,`Win16`,`Win32`,`WinCE`].includes(CM),CM.indexOf(`Linux`),/\bCrOS\b/.test(SM);var OM=``,kM=0,AM=0,jM=0,MM=0,NM={css:`#00000000`,rgba:0},PM;(e=>{function t(e,t,n,r){return r===void 0?`#${zM(e)}${zM(t)}${zM(n)}`:`#${zM(e)}${zM(t)}${zM(n)}${zM(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(PM||={});var FM;(e=>{function t(e,t){if(MM=(t.rgba&255)/255,MM===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return kM=a+Math.round((n-a)*MM),AM=o+Math.round((r-o)*MM),jM=s+Math.round((i-s)*MM),{css:PM.toCss(kM,AM,jM),rgba:PM.toRgba(kM,AM,jM)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=RM.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return PM.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[kM,AM,jM]=RM.toChannels(t),{css:PM.toCss(kM,AM,jM),rgba:t}}e.opaque=i;function a(e,t){return MM=Math.round(t*255),[kM,AM,jM]=RM.toChannels(e.rgba),{css:PM.toCss(kM,AM,jM,MM),rgba:PM.toRgba(kM,AM,jM,MM)}}e.opacity=a;function o(e,t){return MM=e.rgba&255,a(e,MM*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(FM||={});var IM;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return kM=parseInt(e.slice(1,2).repeat(2),16),AM=parseInt(e.slice(2,3).repeat(2),16),jM=parseInt(e.slice(3,4).repeat(2),16),PM.toColor(kM,AM,jM);case 5:return kM=parseInt(e.slice(1,2).repeat(2),16),AM=parseInt(e.slice(2,3).repeat(2),16),jM=parseInt(e.slice(3,4).repeat(2),16),MM=parseInt(e.slice(4,5).repeat(2),16),PM.toColor(kM,AM,jM,MM);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return kM=parseInt(r[1]),AM=parseInt(r[2]),jM=parseInt(r[3]),MM=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),PM.toColor(kM,AM,jM,MM);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[kM,AM,jM,MM]=t.getImageData(0,0,1,1).data,MM!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:PM.toRgba(kM,AM,jM,MM),css:e}}e.toColor=r})(IM||={});var LM;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(LM||={});var RM;(e=>{function t(e,t){if(MM=(t&255)/255,MM===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return kM=a+Math.round((n-a)*MM),AM=o+Math.round((r-o)*MM),jM=s+Math.round((i-s)*MM),PM.toRgba(kM,AM,jM)}e.blend=t;function n(e,t,n){let a=LM.relativeLuminance(e>>8),o=LM.relativeLuminance(t>>8);if(BM(a,o)<n){if(o<a){let o=r(e,t,n),s=BM(a,LM.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>BM(a,LM.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=BM(a,LM.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>BM(a,LM.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=BM(LM.relativeLuminance2(o,s,c),LM.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=BM(LM.relativeLuminance2(o,s,c),LM.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=BM(LM.relativeLuminance2(o,s,c),LM.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=BM(LM.relativeLuminance2(o,s,c),LM.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(RM||={});function zM(e){let t=e.toString(16);return t.length<2?`0`+t:t}function BM(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function VM(e){if(!e)throw Error(`value must not be falsy`);return e}function HM(e){return 57508<=e&&e<=57558}function UM(e){return 57520<=e&&e<=57527}function WM(e){return 57344<=e&&e<=63743}function GM(e){return 9472<=e&&e<=9631}function KM(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}function qM(e,t,n,r){return t===1&&n>Math.ceil(r*1.5)&&e!==void 0&&e>255&&!KM(e)&&!HM(e)&&!WM(e)}function JM(e){return HM(e)||GM(e)}function YM(){return{css:{canvas:XM(),cell:XM()},device:{canvas:XM(),cell:XM(),char:{width:0,height:0,left:0,top:0}}}}function XM(){return{width:0,height:0}}function ZM(e,t,n=0){return(e-(Math.round(t)*2-n))%(Math.round(t)*2)}var QM=0,$M=0,eN=!1,tN=!1,nN=!1,rN,iN=0,aN=class{constructor(e,t,n,r,i,a){this._terminal=e,this._optionService=t,this._selectionRenderModel=n,this._decorationService=r,this._coreBrowserService=i,this._themeService=a,this.result={fg:0,bg:0,ext:0}}resolve(e,t,n,r){if(this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=e.bg&268435456?e.extended.ext:0,$M=0,QM=0,tN=!1,eN=!1,nN=!1,rN=this._themeService.colors,iN=0,e.getCode()!==0&&e.extended.underlineStyle===4){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));iN=t*r%(Math.round(e)*2)}if(this._decorationService.forEachDecorationAtCell(t,n,`bottom`,e=>{e.backgroundColorRGB&&($M=e.backgroundColorRGB.rgba>>8&16777215,tN=!0),e.foregroundColorRGB&&(QM=e.foregroundColorRGB.rgba>>8&16777215,eN=!0)}),nN=this._selectionRenderModel.isCellSelected(this._terminal,t,n),nN){if(this.result.fg&67108864||this.result.bg&50331648){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:$M=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:$M=(this.result.fg&16777215)<<8|255;break;default:$M=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:$M=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:$M=(this.result.bg&16777215)<<8|255}$M=RM.blend($M,(this._coreBrowserService.isFocused?rN.selectionBackgroundOpaque:rN.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else $M=(this._coreBrowserService.isFocused?rN.selectionBackgroundOpaque:rN.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(tN=!0,rN.selectionForeground&&(QM=rN.selectionForeground.rgba>>8&16777215,eN=!0),JM(e.getCode())){if(this.result.fg&67108864&&!(this.result.bg&50331648))QM=(this._coreBrowserService.isFocused?rN.selectionBackgroundOpaque:rN.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:QM=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:QM=(this.result.bg&16777215)<<8|255}else switch(this.result.fg&50331648){case 16777216:case 33554432:QM=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:QM=(this.result.fg&16777215)<<8|255;break;default:QM=this._themeService.colors.foreground.rgba}QM=RM.blend(QM,(this._coreBrowserService.isFocused?rN.selectionBackgroundOpaque:rN.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}eN=!0}}this._decorationService.forEachDecorationAtCell(t,n,`top`,e=>{e.backgroundColorRGB&&($M=e.backgroundColorRGB.rgba>>8&16777215,tN=!0),e.foregroundColorRGB&&(QM=e.foregroundColorRGB.rgba>>8&16777215,eN=!0)}),tN&&($M=nN?e.bg&-150994944|$M|50331648:e.bg&-16777216|$M|50331648),eN&&(QM=e.fg&-83886080|QM|50331648),this.result.fg&67108864&&(tN&&!eN&&(QM=this.result.bg&50331648?this.result.fg&-134217728|this.result.bg&67108863:this.result.fg&-134217728|rN.background.rgba>>8&16777215|50331648,eN=!0),!tN&&eN&&($M=this.result.fg&50331648?this.result.bg&-67108864|this.result.fg&67108863:this.result.bg&-67108864|rN.foreground.rgba>>8&16777215|50331648,tN=!0)),rN=void 0,this.result.bg=tN?$M:this.result.bg,this.result.fg=eN?QM:this.result.fg,this.result.ext&=536870911,this.result.ext|=iN<<29&3758096384}},oN=.5,sN=wM||TM?`bottom`:`ideographic`,cN={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},lN={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},uN={"─":{1:`M0,.5 L1,.5`},"━":{3:`M0,.5 L1,.5`},"│":{1:`M.5,0 L.5,1`},"┃":{3:`M.5,0 L.5,1`},"┌":{1:`M0.5,1 L.5,.5 L1,.5`},"┏":{3:`M0.5,1 L.5,.5 L1,.5`},"┐":{1:`M0,.5 L.5,.5 L.5,1`},"┓":{3:`M0,.5 L.5,.5 L.5,1`},"└":{1:`M.5,0 L.5,.5 L1,.5`},"┗":{3:`M.5,0 L.5,.5 L1,.5`},"┘":{1:`M.5,0 L.5,.5 L0,.5`},"┛":{3:`M.5,0 L.5,.5 L0,.5`},"├":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┣":{3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┤":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┫":{3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┬":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┳":{3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┴":{1:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┻":{3:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┼":{1:`M0,.5 L1,.5 M.5,0 L.5,1`},"╋":{3:`M0,.5 L1,.5 M.5,0 L.5,1`},"╴":{1:`M.5,.5 L0,.5`},"╸":{3:`M.5,.5 L0,.5`},"╵":{1:`M.5,.5 L.5,0`},"╹":{3:`M.5,.5 L.5,0`},"╶":{1:`M.5,.5 L1,.5`},"╺":{3:`M.5,.5 L1,.5`},"╷":{1:`M.5,.5 L.5,1`},"╻":{3:`M.5,.5 L.5,1`},"═":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"║":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╒":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╓":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"╔":{1:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╕":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"╖":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"╗":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`},"╘":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"╙":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╚":{1:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`},"╛":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"╜":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"╝":{1:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`},"╞":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╟":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`},"╠":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╡":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"╢":{1:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╣":{1:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`},"╤":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"╥":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"╦":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╧":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╨":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╩":{1:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╪":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╫":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╬":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╱":{1:`M1,0 L0,1`},"╲":{1:`M0,0 L1,1`},"╳":{1:`M1,0 L0,1 M0,0 L1,1`},"╼":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"╽":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L.5,1`},"╾":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"╿":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┍":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┎":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┑":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L0,.5`},"┒":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┕":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L1,.5`},"┖":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┙":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L0,.5`},"┚":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,0`},"┝":{1:`M.5,0 L.5,1`,3:`M.5,.5 L1,.5`},"┞":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┟":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┠":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1`},"┡":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"┢":{1:`M.5,.5 L.5,0`,3:`M0.5,1 L.5,.5 L1,.5`},"┥":{1:`M.5,0 L.5,1`,3:`M.5,.5 L0,.5`},"┦":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┧":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┨":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1`},"┩":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L0,.5`},"┪":{1:`M.5,.5 L.5,0`,3:`M0,.5 L.5,.5 L.5,1`},"┭":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┮":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┯":{1:`M.5,.5 L.5,1`,3:`M0,.5 L1,.5`},"┰":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┱":{1:`M.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"┲":{1:`M.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"┵":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┶":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┷":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5`},"┸":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┹":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"┺":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,.5 L1,.5`},"┽":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┾":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┿":{1:`M.5,0 L.5,1`,3:`M0,.5 L1,.5`},"╀":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"╁":{1:`M.5,.5 L.5,0 M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"╂":{1:`M0,.5 L1,.5`,3:`M.5,0 L.5,1`},"╃":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"╄":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"╅":{1:`M.5,0 L.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"╆":{1:`M.5,0 L.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"╇":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0 M0,.5 L1,.5`},"╈":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"╉":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"╊":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"╌":{1:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"╍":{3:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"┄":{1:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┅":{3:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┈":{1:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"┉":{3:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"╎":{1:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"╏":{3:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"┆":{1:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┇":{3:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┊":{1:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"┋":{3:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"╭":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"╮":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"╯":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"╰":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},dN={"":{d:`M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655`,type:0},"":{d:`M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5`,type:0},"":{d:`M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82`,type:0},"":{d:`M0,0 L1,.5 L0,1`,type:0,rightPadding:2},"":{d:`M-1,-.5 L1,.5 L-1,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1,0 L0,.5 L1,1`,type:0,leftPadding:2},"":{d:`M2,-.5 L0,.5 L2,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0`,type:0,rightPadding:1},"":{d:`M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0`,type:1,rightPadding:1},"":{d:`M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0`,type:0,leftPadding:1},"":{d:`M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0`,type:1,leftPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L-.5,1.5`,type:0},"":{d:`M-.5,-.5 L1.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1.5,-.5 L-.5,1.5 L1.5,1.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5 L-.5,-.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L1.5,-.5`,type:0}};dN[``]=dN[``],dN[``]=dN[``];function fN(e,t,n,r,i,a,o,s){let c=cN[t];if(c)return pN(e,c,n,r,i,a),!0;let l=lN[t];if(l)return hN(e,l,n,r,i,a),!0;let u=uN[t];if(u)return gN(e,u,n,r,i,a,s),!0;let d=dN[t];return d?(_N(e,d,n,r,i,a,o,s),!0):!1}function pN(e,t,n,r,i,a){for(let o=0;o<t.length;o++){let s=t[o],c=i/8,l=a/8;e.fillRect(n+s.x*c,r+s.y*l,s.w*c,s.h*l)}}var mN=new Map;function hN(e,t,n,r,i,a){let o=mN.get(t);o||(o=new Map,mN.set(t,o));let s=e.fillStyle;if(typeof s!=`string`)throw Error(`Unexpected fillStyle type "${s}"`);let c=o.get(s);if(!c){let n=t[0].length,r=t.length,i=e.canvas.ownerDocument.createElement(`canvas`);i.width=n,i.height=r;let a=VM(i.getContext(`2d`)),l=new ImageData(n,r),u,d,f,p;if(s.startsWith(`#`))u=parseInt(s.slice(1,3),16),d=parseInt(s.slice(3,5),16),f=parseInt(s.slice(5,7),16),p=s.length>7&&parseInt(s.slice(7,9),16)||1;else if(s.startsWith(`rgba`))[u,d,f,p]=s.substring(5,s.length-1).split(`,`).map(e=>parseFloat(e));else throw Error(`Unexpected fillStyle color format "${s}" when drawing pattern glyph`);for(let e=0;e<r;e++)for(let r=0;r<n;r++)l.data[(e*n+r)*4]=u,l.data[(e*n+r)*4+1]=d,l.data[(e*n+r)*4+2]=f,l.data[(e*n+r)*4+3]=t[e][r]*(p*255);a.putImageData(l,0,0),c=VM(e.createPattern(i,null)),o.set(s,c)}e.fillStyle=c,e.fillRect(n,r,i,a)}function gN(e,t,n,r,i,a,o){e.strokeStyle=e.fillStyle;for(let[s,c]of Object.entries(t)){e.beginPath(),e.lineWidth=o*Number.parseInt(s);let t;t=typeof c==`function`?c(.15,.15/a*i):c;for(let s of t.split(` `)){let t=s[0],c=yN[t];if(!c){console.error(`Could not find drawing instructions for "${t}"`);continue}let l=s.substring(1).split(`,`);!l[0]||!l[1]||c(e,bN(l,i,a,n,r,!0,o))}e.stroke(),e.closePath()}}function _N(e,t,n,r,i,a,o,s){let c=new Path2D;c.rect(n,r,i,a),e.clip(c),e.beginPath();let l=o/12;e.lineWidth=s*l;for(let o of t.d.split(` `)){let c=o[0],u=yN[c];if(!u){console.error(`Could not find drawing instructions for "${c}"`);continue}let d=o.substring(1).split(`,`);!d[0]||!d[1]||u(e,bN(d,i,a,n,r,!1,s,(t.leftPadding??0)*(l/2),(t.rightPadding??0)*(l/2)))}t.type===1?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}function vN(e,t,n=0){return Math.max(Math.min(e,t),n)}var yN={C:(e,t)=>e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),L:(e,t)=>e.lineTo(t[0],t[1]),M:(e,t)=>e.moveTo(t[0],t[1])};function bN(e,t,n,r,i,a,o,s=0,c=0){let l=e.map(e=>parseFloat(e)||parseInt(e));if(l.length<2)throw Error(`Too few arguments for instruction`);for(let e=0;e<l.length;e+=2)l[e]*=t-s*o-c*o,a&&l[e]!==0&&(l[e]=vN(Math.round(l[e]+.5)-.5,t,0)),l[e]+=r+s*o;for(let e=1;e<l.length;e+=2)l[e]*=n,a&&l[e]!==0&&(l[e]=vN(Math.round(l[e]+.5)-.5,n,0)),l[e]+=i;return l}var xN=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},SN=class{constructor(){this._data=new xN}set(e,t,n,r,i){this._data.get(e,t)||this._data.set(e,t,new xN),this._data.get(e,t).set(n,r,i)}get(e,t,n,r){return this._data.get(e,t)?.get(n,r)}clear(){this._data.clear()}},CN=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),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},wN=class extends CN{_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())}}},TN=class extends CN{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},EN=!xM&&`requestIdleCallback`in window?TN:wN,DN=class e{constructor(){this.fg=0,this.bg=0,this.extended=new ON}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;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)}isBgDefault(){return!(this.bg&50331648)}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):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ON=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},kN=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};kN.Undefined=new kN(void 0);var AN=globalThis.performance&&typeof globalThis.performance.now==`function`,jN=class e{static create(t){return new e(t)}constructor(e){this._now=AN&&e===!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._now()-this._startTime:this._stopTime-this._startTime}},MN;(e=>{e.None=()=>yM.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(hM(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new WN({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new WN({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new WN({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new WN({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new WN({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new WN;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new WN(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof vM?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(MN||={});var NN=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new jN,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};NN.all=new Set,NN._idPool=0;var PN=NN,FN=-1,IN=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new zN(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};IN._idPool=1;var LN=IN,RN=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
66
|
+
`+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)}};function rM(e){aM(e)||nM.onUnexpectedError(e)}var iM=`Canceled`;function aM(e){return e instanceof oM||e instanceof Error&&e.name===iM&&e.message===iM}var oM=class extends Error{constructor(){super(iM),this.name=this.message}},sM=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},cM;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(cM||={});var lM=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||cM.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};lM.empty=new lM(e=>{});function uM(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var dM;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(dM||={});var fM=null;function pM(e){return fM?.trackDisposable(e),e}function mM(e){fM?.markAsDisposed(e)}function hM(e,t){fM?.setParent(e,t)}function gM(e){if(dM.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function _M(...e){return vM(()=>gM(e))}function vM(e){let t=pM({dispose:uM(()=>{mM(t),e()})});return t}var yM=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,pM(this)}dispose(){this._isDisposed||(mM(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{gM(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return hM(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(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(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),hM(e,null))}};yM.DISABLE_DISPOSED_WARNING=!1;var bM=yM,xM=class{constructor(){this._store=new bM,pM(this),hM(this._store,this)}dispose(){mM(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};xM.None=Object.freeze({dispose(){}});var SM=class{constructor(){this._isDisposed=!1,pM(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&hM(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,mM(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&hM(e,null),e}},CM=typeof process<`u`&&`title`in process,wM=CM?`node`:navigator.userAgent,TM=CM?`node`:navigator.platform,EM=wM.includes(`Firefox`),DM=wM.includes(`Edge`),OM=/^((?!chrome|android).)*safari/i.test(wM);function kM(){if(!OM)return 0;let e=wM.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(TM),[`Windows`,`Win16`,`Win32`,`WinCE`].includes(TM),TM.indexOf(`Linux`),/\bCrOS\b/.test(wM);var AM=``,jM=0,MM=0,NM=0,PM=0,FM={css:`#00000000`,rgba:0},IM;(e=>{function t(e,t,n,r){return r===void 0?`#${VM(e)}${VM(t)}${VM(n)}`:`#${VM(e)}${VM(t)}${VM(n)}${VM(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(IM||={});var LM;(e=>{function t(e,t){if(PM=(t.rgba&255)/255,PM===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return jM=a+Math.round((n-a)*PM),MM=o+Math.round((r-o)*PM),NM=s+Math.round((i-s)*PM),{css:IM.toCss(jM,MM,NM),rgba:IM.toRgba(jM,MM,NM)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=BM.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return IM.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[jM,MM,NM]=BM.toChannels(t),{css:IM.toCss(jM,MM,NM),rgba:t}}e.opaque=i;function a(e,t){return PM=Math.round(t*255),[jM,MM,NM]=BM.toChannels(e.rgba),{css:IM.toCss(jM,MM,NM,PM),rgba:IM.toRgba(jM,MM,NM,PM)}}e.opacity=a;function o(e,t){return PM=e.rgba&255,a(e,PM*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(LM||={});var RM;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return jM=parseInt(e.slice(1,2).repeat(2),16),MM=parseInt(e.slice(2,3).repeat(2),16),NM=parseInt(e.slice(3,4).repeat(2),16),IM.toColor(jM,MM,NM);case 5:return jM=parseInt(e.slice(1,2).repeat(2),16),MM=parseInt(e.slice(2,3).repeat(2),16),NM=parseInt(e.slice(3,4).repeat(2),16),PM=parseInt(e.slice(4,5).repeat(2),16),IM.toColor(jM,MM,NM,PM);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return jM=parseInt(r[1]),MM=parseInt(r[2]),NM=parseInt(r[3]),PM=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),IM.toColor(jM,MM,NM,PM);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[jM,MM,NM,PM]=t.getImageData(0,0,1,1).data,PM!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:IM.toRgba(jM,MM,NM,PM),css:e}}e.toColor=r})(RM||={});var zM;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(zM||={});var BM;(e=>{function t(e,t){if(PM=(t&255)/255,PM===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return jM=a+Math.round((n-a)*PM),MM=o+Math.round((r-o)*PM),NM=s+Math.round((i-s)*PM),IM.toRgba(jM,MM,NM)}e.blend=t;function n(e,t,n){let a=zM.relativeLuminance(e>>8),o=zM.relativeLuminance(t>>8);if(HM(a,o)<n){if(o<a){let o=r(e,t,n),s=HM(a,zM.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>HM(a,zM.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=HM(a,zM.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>HM(a,zM.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=HM(zM.relativeLuminance2(o,s,c),zM.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=HM(zM.relativeLuminance2(o,s,c),zM.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=HM(zM.relativeLuminance2(o,s,c),zM.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=HM(zM.relativeLuminance2(o,s,c),zM.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(BM||={});function VM(e){let t=e.toString(16);return t.length<2?`0`+t:t}function HM(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function UM(e){if(!e)throw Error(`value must not be falsy`);return e}function WM(e){return 57508<=e&&e<=57558}function GM(e){return 57520<=e&&e<=57527}function KM(e){return 57344<=e&&e<=63743}function qM(e){return 9472<=e&&e<=9631}function JM(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}function YM(e,t,n,r){return t===1&&n>Math.ceil(r*1.5)&&e!==void 0&&e>255&&!JM(e)&&!WM(e)&&!KM(e)}function XM(e){return WM(e)||qM(e)}function ZM(){return{css:{canvas:QM(),cell:QM()},device:{canvas:QM(),cell:QM(),char:{width:0,height:0,left:0,top:0}}}}function QM(){return{width:0,height:0}}function $M(e,t,n=0){return(e-(Math.round(t)*2-n))%(Math.round(t)*2)}var eN=0,tN=0,nN=!1,rN=!1,iN=!1,aN,oN=0,sN=class{constructor(e,t,n,r,i,a){this._terminal=e,this._optionService=t,this._selectionRenderModel=n,this._decorationService=r,this._coreBrowserService=i,this._themeService=a,this.result={fg:0,bg:0,ext:0}}resolve(e,t,n,r){if(this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=e.bg&268435456?e.extended.ext:0,tN=0,eN=0,rN=!1,nN=!1,iN=!1,aN=this._themeService.colors,oN=0,e.getCode()!==0&&e.extended.underlineStyle===4){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));oN=t*r%(Math.round(e)*2)}if(this._decorationService.forEachDecorationAtCell(t,n,`bottom`,e=>{e.backgroundColorRGB&&(tN=e.backgroundColorRGB.rgba>>8&16777215,rN=!0),e.foregroundColorRGB&&(eN=e.foregroundColorRGB.rgba>>8&16777215,nN=!0)}),iN=this._selectionRenderModel.isCellSelected(this._terminal,t,n),iN){if(this.result.fg&67108864||this.result.bg&50331648){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:tN=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:tN=(this.result.fg&16777215)<<8|255;break;default:tN=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:tN=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:tN=(this.result.bg&16777215)<<8|255}tN=BM.blend(tN,(this._coreBrowserService.isFocused?aN.selectionBackgroundOpaque:aN.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else tN=(this._coreBrowserService.isFocused?aN.selectionBackgroundOpaque:aN.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(rN=!0,aN.selectionForeground&&(eN=aN.selectionForeground.rgba>>8&16777215,nN=!0),XM(e.getCode())){if(this.result.fg&67108864&&!(this.result.bg&50331648))eN=(this._coreBrowserService.isFocused?aN.selectionBackgroundOpaque:aN.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:eN=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:eN=(this.result.bg&16777215)<<8|255}else switch(this.result.fg&50331648){case 16777216:case 33554432:eN=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:eN=(this.result.fg&16777215)<<8|255;break;default:eN=this._themeService.colors.foreground.rgba}eN=BM.blend(eN,(this._coreBrowserService.isFocused?aN.selectionBackgroundOpaque:aN.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}nN=!0}}this._decorationService.forEachDecorationAtCell(t,n,`top`,e=>{e.backgroundColorRGB&&(tN=e.backgroundColorRGB.rgba>>8&16777215,rN=!0),e.foregroundColorRGB&&(eN=e.foregroundColorRGB.rgba>>8&16777215,nN=!0)}),rN&&(tN=iN?e.bg&-150994944|tN|50331648:e.bg&-16777216|tN|50331648),nN&&(eN=e.fg&-83886080|eN|50331648),this.result.fg&67108864&&(rN&&!nN&&(eN=this.result.bg&50331648?this.result.fg&-134217728|this.result.bg&67108863:this.result.fg&-134217728|aN.background.rgba>>8&16777215|50331648,nN=!0),!rN&&nN&&(tN=this.result.fg&50331648?this.result.bg&-67108864|this.result.fg&67108863:this.result.bg&-67108864|aN.foreground.rgba>>8&16777215|50331648,rN=!0)),aN=void 0,this.result.bg=rN?tN:this.result.bg,this.result.fg=nN?eN:this.result.fg,this.result.ext&=536870911,this.result.ext|=oN<<29&3758096384}},cN=.5,lN=EM||DM?`bottom`:`ideographic`,uN={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},dN={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},fN={"─":{1:`M0,.5 L1,.5`},"━":{3:`M0,.5 L1,.5`},"│":{1:`M.5,0 L.5,1`},"┃":{3:`M.5,0 L.5,1`},"┌":{1:`M0.5,1 L.5,.5 L1,.5`},"┏":{3:`M0.5,1 L.5,.5 L1,.5`},"┐":{1:`M0,.5 L.5,.5 L.5,1`},"┓":{3:`M0,.5 L.5,.5 L.5,1`},"└":{1:`M.5,0 L.5,.5 L1,.5`},"┗":{3:`M.5,0 L.5,.5 L1,.5`},"┘":{1:`M.5,0 L.5,.5 L0,.5`},"┛":{3:`M.5,0 L.5,.5 L0,.5`},"├":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┣":{3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┤":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┫":{3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┬":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┳":{3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┴":{1:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┻":{3:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┼":{1:`M0,.5 L1,.5 M.5,0 L.5,1`},"╋":{3:`M0,.5 L1,.5 M.5,0 L.5,1`},"╴":{1:`M.5,.5 L0,.5`},"╸":{3:`M.5,.5 L0,.5`},"╵":{1:`M.5,.5 L.5,0`},"╹":{3:`M.5,.5 L.5,0`},"╶":{1:`M.5,.5 L1,.5`},"╺":{3:`M.5,.5 L1,.5`},"╷":{1:`M.5,.5 L.5,1`},"╻":{3:`M.5,.5 L.5,1`},"═":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"║":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╒":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╓":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"╔":{1:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╕":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"╖":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"╗":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`},"╘":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"╙":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╚":{1:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`},"╛":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"╜":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"╝":{1:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`},"╞":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╟":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`},"╠":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╡":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"╢":{1:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╣":{1:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`},"╤":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"╥":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"╦":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╧":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╨":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╩":{1:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╪":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╫":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╬":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╱":{1:`M1,0 L0,1`},"╲":{1:`M0,0 L1,1`},"╳":{1:`M1,0 L0,1 M0,0 L1,1`},"╼":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"╽":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L.5,1`},"╾":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"╿":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┍":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┎":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┑":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L0,.5`},"┒":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┕":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L1,.5`},"┖":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┙":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L0,.5`},"┚":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,0`},"┝":{1:`M.5,0 L.5,1`,3:`M.5,.5 L1,.5`},"┞":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┟":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┠":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1`},"┡":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"┢":{1:`M.5,.5 L.5,0`,3:`M0.5,1 L.5,.5 L1,.5`},"┥":{1:`M.5,0 L.5,1`,3:`M.5,.5 L0,.5`},"┦":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┧":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┨":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1`},"┩":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L0,.5`},"┪":{1:`M.5,.5 L.5,0`,3:`M0,.5 L.5,.5 L.5,1`},"┭":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┮":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┯":{1:`M.5,.5 L.5,1`,3:`M0,.5 L1,.5`},"┰":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┱":{1:`M.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"┲":{1:`M.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"┵":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┶":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┷":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5`},"┸":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┹":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"┺":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,.5 L1,.5`},"┽":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┾":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┿":{1:`M.5,0 L.5,1`,3:`M0,.5 L1,.5`},"╀":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"╁":{1:`M.5,.5 L.5,0 M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"╂":{1:`M0,.5 L1,.5`,3:`M.5,0 L.5,1`},"╃":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"╄":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"╅":{1:`M.5,0 L.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"╆":{1:`M.5,0 L.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"╇":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0 M0,.5 L1,.5`},"╈":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"╉":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"╊":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"╌":{1:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"╍":{3:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"┄":{1:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┅":{3:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┈":{1:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"┉":{3:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"╎":{1:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"╏":{3:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"┆":{1:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┇":{3:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┊":{1:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"┋":{3:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"╭":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"╮":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"╯":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"╰":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},pN={"":{d:`M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655`,type:0},"":{d:`M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5`,type:0},"":{d:`M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82`,type:0},"":{d:`M0,0 L1,.5 L0,1`,type:0,rightPadding:2},"":{d:`M-1,-.5 L1,.5 L-1,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1,0 L0,.5 L1,1`,type:0,leftPadding:2},"":{d:`M2,-.5 L0,.5 L2,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0`,type:0,rightPadding:1},"":{d:`M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0`,type:1,rightPadding:1},"":{d:`M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0`,type:0,leftPadding:1},"":{d:`M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0`,type:1,leftPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L-.5,1.5`,type:0},"":{d:`M-.5,-.5 L1.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1.5,-.5 L-.5,1.5 L1.5,1.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5 L-.5,-.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L1.5,-.5`,type:0}};pN[``]=pN[``],pN[``]=pN[``];function mN(e,t,n,r,i,a,o,s){let c=uN[t];if(c)return hN(e,c,n,r,i,a),!0;let l=dN[t];if(l)return _N(e,l,n,r,i,a),!0;let u=fN[t];if(u)return vN(e,u,n,r,i,a,s),!0;let d=pN[t];return d?(yN(e,d,n,r,i,a,o,s),!0):!1}function hN(e,t,n,r,i,a){for(let o=0;o<t.length;o++){let s=t[o],c=i/8,l=a/8;e.fillRect(n+s.x*c,r+s.y*l,s.w*c,s.h*l)}}var gN=new Map;function _N(e,t,n,r,i,a){let o=gN.get(t);o||(o=new Map,gN.set(t,o));let s=e.fillStyle;if(typeof s!=`string`)throw Error(`Unexpected fillStyle type "${s}"`);let c=o.get(s);if(!c){let n=t[0].length,r=t.length,i=e.canvas.ownerDocument.createElement(`canvas`);i.width=n,i.height=r;let a=UM(i.getContext(`2d`)),l=new ImageData(n,r),u,d,f,p;if(s.startsWith(`#`))u=parseInt(s.slice(1,3),16),d=parseInt(s.slice(3,5),16),f=parseInt(s.slice(5,7),16),p=s.length>7&&parseInt(s.slice(7,9),16)||1;else if(s.startsWith(`rgba`))[u,d,f,p]=s.substring(5,s.length-1).split(`,`).map(e=>parseFloat(e));else throw Error(`Unexpected fillStyle color format "${s}" when drawing pattern glyph`);for(let e=0;e<r;e++)for(let r=0;r<n;r++)l.data[(e*n+r)*4]=u,l.data[(e*n+r)*4+1]=d,l.data[(e*n+r)*4+2]=f,l.data[(e*n+r)*4+3]=t[e][r]*(p*255);a.putImageData(l,0,0),c=UM(e.createPattern(i,null)),o.set(s,c)}e.fillStyle=c,e.fillRect(n,r,i,a)}function vN(e,t,n,r,i,a,o){e.strokeStyle=e.fillStyle;for(let[s,c]of Object.entries(t)){e.beginPath(),e.lineWidth=o*Number.parseInt(s);let t;t=typeof c==`function`?c(.15,.15/a*i):c;for(let s of t.split(` `)){let t=s[0],c=xN[t];if(!c){console.error(`Could not find drawing instructions for "${t}"`);continue}let l=s.substring(1).split(`,`);!l[0]||!l[1]||c(e,SN(l,i,a,n,r,!0,o))}e.stroke(),e.closePath()}}function yN(e,t,n,r,i,a,o,s){let c=new Path2D;c.rect(n,r,i,a),e.clip(c),e.beginPath();let l=o/12;e.lineWidth=s*l;for(let o of t.d.split(` `)){let c=o[0],u=xN[c];if(!u){console.error(`Could not find drawing instructions for "${c}"`);continue}let d=o.substring(1).split(`,`);!d[0]||!d[1]||u(e,SN(d,i,a,n,r,!1,s,(t.leftPadding??0)*(l/2),(t.rightPadding??0)*(l/2)))}t.type===1?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}function bN(e,t,n=0){return Math.max(Math.min(e,t),n)}var xN={C:(e,t)=>e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),L:(e,t)=>e.lineTo(t[0],t[1]),M:(e,t)=>e.moveTo(t[0],t[1])};function SN(e,t,n,r,i,a,o,s=0,c=0){let l=e.map(e=>parseFloat(e)||parseInt(e));if(l.length<2)throw Error(`Too few arguments for instruction`);for(let e=0;e<l.length;e+=2)l[e]*=t-s*o-c*o,a&&l[e]!==0&&(l[e]=bN(Math.round(l[e]+.5)-.5,t,0)),l[e]+=r+s*o;for(let e=1;e<l.length;e+=2)l[e]*=n,a&&l[e]!==0&&(l[e]=bN(Math.round(l[e]+.5)-.5,n,0)),l[e]+=i;return l}var CN=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},wN=class{constructor(){this._data=new CN}set(e,t,n,r,i){this._data.get(e,t)||this._data.set(e,t,new CN),this._data.get(e,t).set(n,r,i)}get(e,t,n,r){return this._data.get(e,t)?.get(n,r)}clear(){this._data.clear()}},TN=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),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},EN=class extends TN{_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())}}},DN=class extends TN{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ON=!CM&&`requestIdleCallback`in window?DN:EN,kN=class e{constructor(){this.fg=0,this.bg=0,this.extended=new AN}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;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)}isBgDefault(){return!(this.bg&50331648)}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):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},AN=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},jN=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};jN.Undefined=new jN(void 0);var MN=globalThis.performance&&typeof globalThis.performance.now==`function`,NN=class e{static create(t){return new e(t)}constructor(e){this._now=MN&&e===!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._now()-this._startTime:this._stopTime-this._startTime}},PN;(e=>{e.None=()=>xM.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(_M(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new KN({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new KN({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new KN({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new KN({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new KN({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new KN;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new KN(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof bM?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(PN||={});var FN=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new NN,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};FN.all=new Set,FN._idPool=0;var IN=FN,LN=-1,RN=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new VN(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};RN._idPool=1;var zN=RN,BN=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
67
67
|
`).slice(2).join(`
|
|
68
|
-
`))}},zN=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},BN=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},VN=0,HN=class{constructor(e){this.value=e,this.id=VN++}},UN=2,WN=class{constructor(e){this._size=0,this._options=e,this._leakageMon=FN>0||this._options?.leakWarningThreshold?new LN(e?.onListenerError??tM,this._options?.leakWarningThreshold??FN):void 0,this._perfMon=this._options?._profName?new PN(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new BN(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||tM)(n),yM.None}if(this._disposed)return yM.None;t&&(e=e.bind(t));let r=new HN(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=RN.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof HN?(this._deliveryQueue??=new GN,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=gM(()=>{i?.(),this._removeListener(r)});return n instanceof vM?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*UN<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||tM;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_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 HN)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}},GN=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},KN={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},qN=2,JN,YN=class e{constructor(e,t,n){this._document=e,this._config=t,this._unicodeService=n,this._didWarmUp=!1,this._cacheMap=new SN,this._cacheMapCombined=new SN,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new DN,this._textureSize=512,this._onAddTextureAtlasCanvas=new WN,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new WN,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=$N(e,this._config.deviceCellWidth*4+qN*2,this._config.deviceCellHeight+qN*2),this._tmpCtx=VM(this._tmpCanvas.getContext(`2d`,{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||=(this._doWarmUp(),!0)}_doWarmUp(){let e=new EN;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let e=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,e)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(this._pages[0].currentRow.x!==0||this._pages[0].currentRow.y!==0){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(e.maxAtlasPages&&this._pages.length>=Math.max(4,e.maxAtlasPages)){let t=this._pages.filter(t=>t.canvas.width*2<=(e.maxTextureSize||4096)).sort((e,t)=>t.canvas.width===e.canvas.width?t.percentageUsed-e.percentageUsed:t.canvas.width-e.canvas.width),n=-1,r=0;for(let e=0;e<t.length;e++)if(t[e].canvas.width!==r)n=e,r=t[e].canvas.width;else if(e-n===3)break;let i=t.slice(n,n+4),a=i.map(e=>e.glyphs[0].texturePage).sort((e,t)=>e>t?1:-1),o=this.pages.length-i.length,s=this._mergePages(i,o);s.version++;for(let e=a.length-1;e>=0;e--)this._deletePage(a[e]);this.pages.push(s),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(s.canvas)}let t=new XN(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(e,t){let n=e[0].canvas.width*2,r=new XN(this._document,n,e);for(let[i,a]of e.entries()){let e=i*a.canvas.width%n,o=Math.floor(i/2)*a.canvas.height;r.ctx.drawImage(a.canvas,e,o);for(let r of a.glyphs)r.texturePage=t,r.sizeClipSpace.x=r.size.x/n,r.sizeClipSpace.y=r.size.y/n,r.texturePosition.x+=e,r.texturePosition.y+=o,r.texturePositionClipSpace.x=r.texturePosition.x/n,r.texturePositionClipSpace.y=r.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(a.canvas);let s=this._activePages.indexOf(a);s!==-1&&this._activePages.splice(s,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t<this._pages.length;t++){let e=this._pages[t];for(let t of e.glyphs)t.texturePage--;e.version++}}getRasterizedGlyphCombinedChar(e,t,n,r,i,a){return this._getFromCacheMap(this._cacheMapCombined,e,t,n,r,i,a)}getRasterizedGlyph(e,t,n,r,i,a){return this._getFromCacheMap(this._cacheMap,e,t,n,r,i,a)}_getFromCacheMap(e,t,n,r,i,a,o){return JN=e.get(t,n,r,i),JN||(JN=this._drawToCache(t,n,r,i,a,o),e.set(t,n,r,i,JN)),JN}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw Error(`No color found for idx `+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,n,r){if(this._config.allowTransparency)return NM;let i;switch(e){case 16777216:case 33554432:i=this._getColorFromAnsiIndex(t);break;case 50331648:let e=DN.toColorRGB(t);i=PM.toColor(e[0],e[1],e[2]);break;default:i=n?FM.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(i=FM.opaque(i)),i}_getForegroundColor(e,t,n,r,i,a,o,s,c,l){let u=this._getMinimumContrastColor(e,t,n,r,i,a,o,c,s,l);if(u)return u;let d;switch(i){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&c&&a<8&&(a+=8),d=this._getColorFromAnsiIndex(a);break;case 50331648:let e=DN.toColorRGB(a);d=PM.toColor(e[0],e[1],e[2]);break;default:d=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(d=FM.opaque(d)),s&&(d=FM.multiplyOpacity(d,oN)),d}_resolveBackgroundRgba(e,t,n){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,n,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,n,r,i,a,o,s,c,l){if(this._config.minimumContrastRatio===1||l)return;let u=this._getContrastCache(c),d=u.getColor(e,r);if(d!==void 0)return d||void 0;let f=this._resolveBackgroundRgba(t,n,o),p=this._resolveForegroundRgba(i,a,o,s),m=RM.ensureContrastRatio(f,p,this._config.minimumContrastRatio/(c?2:1));if(!m){u.setColor(e,r,null);return}let h=PM.toColor(m>>24&255,m>>16&255,m>>8&255);return u.setColor(e,r,h),h}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,n,r,i,a,o){let s=typeof t==`number`?String.fromCharCode(t):t;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display=`none`,o.append(this._tmpCanvas));let c=Math.min(this._config.deviceCellWidth*Math.max(s.length,2)+qN*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<c&&(this._tmpCanvas.width=c);let l=Math.min(this._config.deviceCellHeight+qN*4,this._textureSize);if(this._tmpCanvas.height<l&&(this._tmpCanvas.height=l),this._tmpCtx.save(),this._workAttributeData.fg=r,this._workAttributeData.bg=n,this._workAttributeData.extended.ext=i,this._workAttributeData.isInvisible())return KN;let u=!!this._workAttributeData.isBold(),d=!!this._workAttributeData.isInverse(),f=!!this._workAttributeData.isDim(),p=!!this._workAttributeData.isItalic(),m=!!this._workAttributeData.isUnderline(),h=!!this._workAttributeData.isStrikethrough(),g=!!this._workAttributeData.isOverline(),_=this._workAttributeData.getFgColor(),v=this._workAttributeData.getFgColorMode(),y=this._workAttributeData.getBgColor(),b=this._workAttributeData.getBgColorMode();if(d){let e=_;_=y,y=e;let t=v;v=b,b=t}let x=this._getBackgroundColor(b,y,d,f);this._tmpCtx.globalCompositeOperation=`copy`,this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation=`source-over`;let S=u?this._config.fontWeightBold:this._config.fontWeight,C=p?`italic`:``;this._tmpCtx.font=`${C} ${S} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=sN;let w=s.length===1&&HM(s.charCodeAt(0)),T=s.length===1&&UM(s.charCodeAt(0)),E=this._getForegroundColor(n,b,y,r,v,_,d,f,u,JM(s.charCodeAt(0)));this._tmpCtx.fillStyle=E.css;let D=T?0:qN*2,O=!1;this._config.customGlyphs!==!1&&(O=fN(this._tmpCtx,s,D,D,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let k=!w,A;if(A=typeof t==`number`?this._unicodeService.wcwidth(t):this._unicodeService.getStringCellWidth(t),m){this._tmpCtx.save();let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;if(this._tmpCtx.lineWidth=e,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())k=!1,this._tmpCtx.strokeStyle=`rgb(${DN.toColorRGB(this._workAttributeData.getUnderlineColor()).join(`,`)})`;else{k=!1;let e=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&e<8&&(e+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(e).css}this._tmpCtx.beginPath();let n=D,r=Math.ceil(D+this._config.deviceCharHeight)-t-(a?e*2:0),i=r+e,o=r+e*2,c=this._workAttributeData.getUnderlineVariantOffset();for(let a=0;a<A;a++){this._tmpCtx.save();let s=n+a*this._config.deviceCellWidth,l=n+(a+1)*this._config.deviceCellWidth,u=s+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r),this._tmpCtx.moveTo(s,o),this._tmpCtx.lineTo(l,o);break;case 3:let n=e<=1?o:Math.ceil(D+this._config.deviceCharHeight-e/2)-t,a=e<=1?r:Math.ceil(D+this._config.deviceCharHeight+e/2)-t,d=new Path2D;d.rect(s,r,this._config.deviceCellWidth,o-r),this._tmpCtx.clip(d),this._tmpCtx.moveTo(s-this._config.deviceCellWidth/2,i),this._tmpCtx.bezierCurveTo(s-this._config.deviceCellWidth/2,a,s,a,s,i),this._tmpCtx.bezierCurveTo(s,n,u,n,u,i),this._tmpCtx.bezierCurveTo(u,a,l,a,l,i),this._tmpCtx.bezierCurveTo(l,n,l+this._config.deviceCellWidth/2,n,l+this._config.deviceCellWidth/2,i);break;case 4:let f=c===0?0:c>=e?e*2-c:e-c;c>=e||f===0?(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s+f,r),this._tmpCtx.lineTo(l,r)):(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(s+f,r),this._tmpCtx.moveTo(s+f+e,r),this._tmpCtx.lineTo(l,r)),c=ZM(l-s,e,c);break;case 5:let p=l-s,m=Math.floor(.6*p),h=Math.floor(.3*p),g=p-m-h;this._tmpCtx.setLineDash([m,h,g]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r);break;default:this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!O&&this._config.fontSize>=12&&!this._config.allowTransparency&&s!==` `){this._tmpCtx.save(),this._tmpCtx.textBaseline=`alphabetic`;let t=this._tmpCtx.measureText(s);if(this._tmpCtx.restore(),`actualBoundingBoxDescent`in t&&t.actualBoundingBoxDescent>0){this._tmpCtx.save();let t=new Path2D;t.rect(n,r-Math.ceil(e/2),this._config.deviceCellWidth*A,o-r+Math.ceil(e/2)),this._tmpCtx.clip(t),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=x.css,this._tmpCtx.strokeText(s,D,D+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(g){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(D,D+t),this._tmpCtx.lineTo(D+this._config.deviceCharWidth*A,D+t),this._tmpCtx.stroke()}if(O||this._tmpCtx.fillText(s,D,D+this._config.deviceCharHeight),s===`_`&&!this._config.allowTransparency){let e=ZN(this._tmpCtx.getImageData(D,D,this._config.deviceCellWidth,this._config.deviceCellHeight),x,E,k);if(e)for(let t=1;t<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(s,D,D+this._config.deviceCharHeight-t),e=ZN(this._tmpCtx.getImageData(D,D,this._config.deviceCellWidth,this._config.deviceCellHeight),x,E,k),e);t++);}if(h){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(D,D+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(D+this._config.deviceCharWidth*A,D+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let j=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),M;if(M=this._config.allowTransparency?QN(j):ZN(j,x,E,k),M)return KN;let N=this._findGlyphBoundingBox(j,this._workBoundingBox,c,T,O,D),P,F;for(;;){if(this._activePages.length===0){let e=this._createNewPage();P=e,F=e.currentRow,F.height=N.size.y;break}P=this._activePages[this._activePages.length-1],F=P.currentRow;for(let e of this._activePages)N.size.y<=e.currentRow.height&&(P=e,F=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=F.height&&N.size.y<=t.height&&(P=this._activePages[e],F=t);if(N.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new XN(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),P=this._overflowSizePage,F=this._overflowSizePage.currentRow,F.x+N.size.x>=P.canvas.width&&(F.x=0,F.y+=F.height,F.height=0);break}if(F.y+N.size.y>=P.canvas.height||F.height>N.size.y+2){let t=!1;if(P.currentRow.y+P.currentRow.height+N.size.y>=P.canvas.height){let n;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+N.size.y<e.canvas.height){n=e;break}if(n)P=n;else if(e.maxAtlasPages&&this._pages.length>=e.maxAtlasPages&&F.y+N.size.y<=P.canvas.height&&F.height>=N.size.y&&F.x+N.size.x<=P.canvas.width)t=!0;else{let e=this._createNewPage();P=e,F=e.currentRow,F.height=N.size.y,t=!0}}t||(P.currentRow.height>0&&P.fixedRows.push(P.currentRow),F={x:0,y:P.currentRow.y+P.currentRow.height,height:N.size.y},P.fixedRows.push(F),P.currentRow={x:0,y:F.y+F.height,height:0})}if(F.x+N.size.x<=P.canvas.width)break;F===P.currentRow?(F.x=0,F.y+=F.height,F.height=0):P.fixedRows.splice(P.fixedRows.indexOf(F),1)}return N.texturePage=this._pages.indexOf(P),N.texturePosition.x=F.x,N.texturePosition.y=F.y,N.texturePositionClipSpace.x=F.x/P.canvas.width,N.texturePositionClipSpace.y=F.y/P.canvas.height,N.sizeClipSpace.x/=P.canvas.width,N.sizeClipSpace.y/=P.canvas.height,F.height=Math.max(F.height,N.size.y),F.x+=N.size.x,P.ctx.putImageData(j,N.texturePosition.x-this._workBoundingBox.left,N.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,N.size.x,N.size.y),P.addGlyph(N),P.version++,N}_findGlyphBoundingBox(e,t,n,r,i,a){t.top=0;let o=r?this._config.deviceCellHeight:this._tmpCanvas.height,s=r?this._config.deviceCellWidth:n,c=!1;for(let n=0;n<o;n++){for(let r=0;r<s;r++){let i=n*this._tmpCanvas.width*4+r*4+3;if(e.data[i]!==0){t.top=n,c=!0;break}}if(c)break}t.left=0,c=!1;for(let n=0;n<a+s;n++){for(let r=0;r<o;r++){let i=r*this._tmpCanvas.width*4+n*4+3;if(e.data[i]!==0){t.left=n,c=!0;break}}if(c)break}t.right=s,c=!1;for(let n=a+s-1;n>=a;n--){for(let r=0;r<o;r++){let i=r*this._tmpCanvas.width*4+n*4+3;if(e.data[i]!==0){t.right=n,c=!0;break}}if(c)break}t.bottom=o,c=!1;for(let n=o-1;n>=0;n--){for(let r=0;r<s;r++){let i=n*this._tmpCanvas.width*4+r*4+3;if(e.data[i]!==0){t.bottom=n,c=!0;break}}if(c)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:t.right-t.left+1,y:t.bottom-t.top+1},sizeClipSpace:{x:t.right-t.left+1,y:t.bottom-t.top+1},offset:{x:-t.left+a+(r||i?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-t.top+a+(r||i?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},XN=class{constructor(e,t,n){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],n)for(let e of n)this._glyphs.push(...e.glyphs),this._usedPixels+=e._usedPixels;this.canvas=$N(e,t,t),this.ctx=VM(this.canvas.getContext(`2d`,{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(e){this._glyphs.push(e),this._usedPixels+=e.size.x*e.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}};function ZN(e,t,n,r){let i=t.rgba>>>24,a=t.rgba>>>16&255,o=t.rgba>>>8&255,s=n.rgba>>>24,c=n.rgba>>>16&255,l=n.rgba>>>8&255,u=Math.floor((Math.abs(i-s)+Math.abs(a-c)+Math.abs(o-l))/12),d=!0;for(let t=0;t<e.data.length;t+=4)e.data[t]===i&&e.data[t+1]===a&&e.data[t+2]===o||r&&Math.abs(e.data[t]-i)+Math.abs(e.data[t+1]-a)+Math.abs(e.data[t+2]-o)<u?e.data[t+3]=0:d=!1;return d}function QN(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}function $N(e,t,n){let r=e.createElement(`canvas`);return r.width=t,r.height=n,r}function eP(e,t,n,r,i,a,o,s){let c={foreground:a.foreground,background:a.background,cursor:NM,cursorAccent:NM,selectionForeground:NM,selectionBackgroundTransparent:NM,selectionBackgroundOpaque:NM,selectionInactiveBackgroundTransparent:NM,selectionInactiveBackgroundOpaque:NM,overviewRulerBorder:NM,scrollbarSliderBackground:NM,scrollbarSliderHoverBackground:NM,scrollbarSliderActiveBackground:NM,ansi:a.ansi.slice(),contrastCache:a.contrastCache,halfContrastCache:a.halfContrastCache};return{customGlyphs:i.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:s,letterSpacing:i.letterSpacing,lineHeight:i.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:n,deviceCharHeight:r,fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontWeightBold:i.fontWeightBold,allowTransparency:i.allowTransparency,drawBoldTextInBrightColors:i.drawBoldTextInBrightColors,minimumContrastRatio:i.minimumContrastRatio,colors:c}}function tP(e,t){for(let n=0;n<e.colors.ansi.length;n++)if(e.colors.ansi[n].rgba!==t.colors.ansi[n].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.customGlyphs===t.customGlyphs&&e.lineHeight===t.lineHeight&&e.letterSpacing===t.letterSpacing&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.deviceCharWidth===t.deviceCharWidth&&e.deviceCharHeight===t.deviceCharHeight&&e.drawBoldTextInBrightColors===t.drawBoldTextInBrightColors&&e.minimumContrastRatio===t.minimumContrastRatio&&e.colors.foreground.rgba===t.colors.foreground.rgba&&e.colors.background.rgba===t.colors.background.rgba}function nP(e){return(e&50331648)==16777216||(e&50331648)==33554432}var rP=[];function iP(e,t,n,r,i,a,o,s,c){let l=eP(r,i,a,o,t,n,s,c);for(let t=0;t<rP.length;t++){let n=rP[t],r=n.ownedBy.indexOf(e);if(r>=0){if(tP(n.config,l))return n.atlas;n.ownedBy.length===1?(n.atlas.dispose(),rP.splice(t,1)):n.ownedBy.splice(r,1);break}}for(let t=0;t<rP.length;t++){let n=rP[t];if(tP(n.config,l))return n.ownedBy.push(e),n.atlas}let u=e._core,d={atlas:new YN(document,l,u.unicodeService),config:l,ownedBy:[e]};return rP.push(d),d.atlas}function aP(e){for(let t=0;t<rP.length;t++){let n=rP[t].ownedBy.indexOf(e);if(n!==-1){rP[t].ownedBy.length===1?(rP[t].atlas.dispose(),rP.splice(t,1)):rP[t].ownedBy.splice(n,1);break}}}var oP=600,sP=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout&&=(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),void 0),this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}))}_restartInterval(e=oP){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=oP-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=oP-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},oP)},e)}pause(){this.isCursorVisible=!0,this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout&&=(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),void 0),this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function cP(e,t,n){let r=new t.ResizeObserver(t=>{let i=t.find(t=>t.target===e);if(!i)return;if(!(`devicePixelContentBoxSize`in i)){r?.disconnect(),r=void 0;return}let a=i.devicePixelContentBoxSize[0].inlineSize,o=i.devicePixelContentBoxSize[0].blockSize;a>0&&o>0&&n(a,o)});try{r.observe(e,{box:[`device-pixel-content-box`]})}catch{r.disconnect(),r=void 0}return gM(()=>r?.disconnect())}function lP(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var uP=class e extends DN{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ON,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?lP(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},dP=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function fP(e,t,n){let r=VM(e.createProgram());if(e.attachShader(r,VM(pP(e,e.VERTEX_SHADER,t))),e.attachShader(r,VM(pP(e,e.FRAGMENT_SHADER,n))),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS))return r;console.error(e.getProgramInfoLog(r)),e.deleteProgram(r)}function pP(e,t,n){let r=VM(e.createShader(t));if(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS))return r;console.error(e.getShaderInfoLog(r)),e.deleteShader(r)}function mP(e,t){let n=Math.min(e.length*2,t),r=new Float32Array(n);for(let t=0;t<e.length;t++)r[t]=e[t];return r}var hP=class{constructor(e){this.texture=e,this.version=-1}},gP=`#version 300 es
|
|
68
|
+
`))}},VN=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},HN=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},UN=0,WN=class{constructor(e){this.value=e,this.id=UN++}},GN=2,KN=class{constructor(e){this._size=0,this._options=e,this._leakageMon=LN>0||this._options?.leakWarningThreshold?new zN(e?.onListenerError??rM,this._options?.leakWarningThreshold??LN):void 0,this._perfMon=this._options?._profName?new IN(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new HN(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||rM)(n),xM.None}if(this._disposed)return xM.None;t&&(e=e.bind(t));let r=new WN(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=BN.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof WN?(this._deliveryQueue??=new qN,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=vM(()=>{i?.(),this._removeListener(r)});return n instanceof bM?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*GN<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||rM;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_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 WN)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}},qN=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},JN={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},YN=2,XN,ZN=class e{constructor(e,t,n){this._document=e,this._config=t,this._unicodeService=n,this._didWarmUp=!1,this._cacheMap=new wN,this._cacheMapCombined=new wN,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new kN,this._textureSize=512,this._onAddTextureAtlasCanvas=new KN,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new KN,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=tP(e,this._config.deviceCellWidth*4+YN*2,this._config.deviceCellHeight+YN*2),this._tmpCtx=UM(this._tmpCanvas.getContext(`2d`,{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||=(this._doWarmUp(),!0)}_doWarmUp(){let e=new ON;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let e=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,e)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(this._pages[0].currentRow.x!==0||this._pages[0].currentRow.y!==0){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(e.maxAtlasPages&&this._pages.length>=Math.max(4,e.maxAtlasPages)){let t=this._pages.filter(t=>t.canvas.width*2<=(e.maxTextureSize||4096)).sort((e,t)=>t.canvas.width===e.canvas.width?t.percentageUsed-e.percentageUsed:t.canvas.width-e.canvas.width),n=-1,r=0;for(let e=0;e<t.length;e++)if(t[e].canvas.width!==r)n=e,r=t[e].canvas.width;else if(e-n===3)break;let i=t.slice(n,n+4),a=i.map(e=>e.glyphs[0].texturePage).sort((e,t)=>e>t?1:-1),o=this.pages.length-i.length,s=this._mergePages(i,o);s.version++;for(let e=a.length-1;e>=0;e--)this._deletePage(a[e]);this.pages.push(s),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(s.canvas)}let t=new QN(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(e,t){let n=e[0].canvas.width*2,r=new QN(this._document,n,e);for(let[i,a]of e.entries()){let e=i*a.canvas.width%n,o=Math.floor(i/2)*a.canvas.height;r.ctx.drawImage(a.canvas,e,o);for(let r of a.glyphs)r.texturePage=t,r.sizeClipSpace.x=r.size.x/n,r.sizeClipSpace.y=r.size.y/n,r.texturePosition.x+=e,r.texturePosition.y+=o,r.texturePositionClipSpace.x=r.texturePosition.x/n,r.texturePositionClipSpace.y=r.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(a.canvas);let s=this._activePages.indexOf(a);s!==-1&&this._activePages.splice(s,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t<this._pages.length;t++){let e=this._pages[t];for(let t of e.glyphs)t.texturePage--;e.version++}}getRasterizedGlyphCombinedChar(e,t,n,r,i,a){return this._getFromCacheMap(this._cacheMapCombined,e,t,n,r,i,a)}getRasterizedGlyph(e,t,n,r,i,a){return this._getFromCacheMap(this._cacheMap,e,t,n,r,i,a)}_getFromCacheMap(e,t,n,r,i,a,o){return XN=e.get(t,n,r,i),XN||(XN=this._drawToCache(t,n,r,i,a,o),e.set(t,n,r,i,XN)),XN}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw Error(`No color found for idx `+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,n,r){if(this._config.allowTransparency)return FM;let i;switch(e){case 16777216:case 33554432:i=this._getColorFromAnsiIndex(t);break;case 50331648:let e=kN.toColorRGB(t);i=IM.toColor(e[0],e[1],e[2]);break;default:i=n?LM.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(i=LM.opaque(i)),i}_getForegroundColor(e,t,n,r,i,a,o,s,c,l){let u=this._getMinimumContrastColor(e,t,n,r,i,a,o,c,s,l);if(u)return u;let d;switch(i){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&c&&a<8&&(a+=8),d=this._getColorFromAnsiIndex(a);break;case 50331648:let e=kN.toColorRGB(a);d=IM.toColor(e[0],e[1],e[2]);break;default:d=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(d=LM.opaque(d)),s&&(d=LM.multiplyOpacity(d,cN)),d}_resolveBackgroundRgba(e,t,n){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,n,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,n,r,i,a,o,s,c,l){if(this._config.minimumContrastRatio===1||l)return;let u=this._getContrastCache(c),d=u.getColor(e,r);if(d!==void 0)return d||void 0;let f=this._resolveBackgroundRgba(t,n,o),p=this._resolveForegroundRgba(i,a,o,s),m=BM.ensureContrastRatio(f,p,this._config.minimumContrastRatio/(c?2:1));if(!m){u.setColor(e,r,null);return}let h=IM.toColor(m>>24&255,m>>16&255,m>>8&255);return u.setColor(e,r,h),h}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,n,r,i,a,o){let s=typeof t==`number`?String.fromCharCode(t):t;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display=`none`,o.append(this._tmpCanvas));let c=Math.min(this._config.deviceCellWidth*Math.max(s.length,2)+YN*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<c&&(this._tmpCanvas.width=c);let l=Math.min(this._config.deviceCellHeight+YN*4,this._textureSize);if(this._tmpCanvas.height<l&&(this._tmpCanvas.height=l),this._tmpCtx.save(),this._workAttributeData.fg=r,this._workAttributeData.bg=n,this._workAttributeData.extended.ext=i,this._workAttributeData.isInvisible())return JN;let u=!!this._workAttributeData.isBold(),d=!!this._workAttributeData.isInverse(),f=!!this._workAttributeData.isDim(),p=!!this._workAttributeData.isItalic(),m=!!this._workAttributeData.isUnderline(),h=!!this._workAttributeData.isStrikethrough(),g=!!this._workAttributeData.isOverline(),_=this._workAttributeData.getFgColor(),v=this._workAttributeData.getFgColorMode(),y=this._workAttributeData.getBgColor(),b=this._workAttributeData.getBgColorMode();if(d){let e=_;_=y,y=e;let t=v;v=b,b=t}let x=this._getBackgroundColor(b,y,d,f);this._tmpCtx.globalCompositeOperation=`copy`,this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation=`source-over`;let S=u?this._config.fontWeightBold:this._config.fontWeight,C=p?`italic`:``;this._tmpCtx.font=`${C} ${S} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=lN;let w=s.length===1&&WM(s.charCodeAt(0)),T=s.length===1&&GM(s.charCodeAt(0)),E=this._getForegroundColor(n,b,y,r,v,_,d,f,u,XM(s.charCodeAt(0)));this._tmpCtx.fillStyle=E.css;let D=T?0:YN*2,O=!1;this._config.customGlyphs!==!1&&(O=mN(this._tmpCtx,s,D,D,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let k=!w,A;if(A=typeof t==`number`?this._unicodeService.wcwidth(t):this._unicodeService.getStringCellWidth(t),m){this._tmpCtx.save();let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;if(this._tmpCtx.lineWidth=e,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())k=!1,this._tmpCtx.strokeStyle=`rgb(${kN.toColorRGB(this._workAttributeData.getUnderlineColor()).join(`,`)})`;else{k=!1;let e=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&e<8&&(e+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(e).css}this._tmpCtx.beginPath();let n=D,r=Math.ceil(D+this._config.deviceCharHeight)-t-(a?e*2:0),i=r+e,o=r+e*2,c=this._workAttributeData.getUnderlineVariantOffset();for(let a=0;a<A;a++){this._tmpCtx.save();let s=n+a*this._config.deviceCellWidth,l=n+(a+1)*this._config.deviceCellWidth,u=s+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r),this._tmpCtx.moveTo(s,o),this._tmpCtx.lineTo(l,o);break;case 3:let n=e<=1?o:Math.ceil(D+this._config.deviceCharHeight-e/2)-t,a=e<=1?r:Math.ceil(D+this._config.deviceCharHeight+e/2)-t,d=new Path2D;d.rect(s,r,this._config.deviceCellWidth,o-r),this._tmpCtx.clip(d),this._tmpCtx.moveTo(s-this._config.deviceCellWidth/2,i),this._tmpCtx.bezierCurveTo(s-this._config.deviceCellWidth/2,a,s,a,s,i),this._tmpCtx.bezierCurveTo(s,n,u,n,u,i),this._tmpCtx.bezierCurveTo(u,a,l,a,l,i),this._tmpCtx.bezierCurveTo(l,n,l+this._config.deviceCellWidth/2,n,l+this._config.deviceCellWidth/2,i);break;case 4:let f=c===0?0:c>=e?e*2-c:e-c;c>=e||f===0?(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s+f,r),this._tmpCtx.lineTo(l,r)):(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(s+f,r),this._tmpCtx.moveTo(s+f+e,r),this._tmpCtx.lineTo(l,r)),c=$M(l-s,e,c);break;case 5:let p=l-s,m=Math.floor(.6*p),h=Math.floor(.3*p),g=p-m-h;this._tmpCtx.setLineDash([m,h,g]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r);break;default:this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!O&&this._config.fontSize>=12&&!this._config.allowTransparency&&s!==` `){this._tmpCtx.save(),this._tmpCtx.textBaseline=`alphabetic`;let t=this._tmpCtx.measureText(s);if(this._tmpCtx.restore(),`actualBoundingBoxDescent`in t&&t.actualBoundingBoxDescent>0){this._tmpCtx.save();let t=new Path2D;t.rect(n,r-Math.ceil(e/2),this._config.deviceCellWidth*A,o-r+Math.ceil(e/2)),this._tmpCtx.clip(t),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=x.css,this._tmpCtx.strokeText(s,D,D+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(g){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(D,D+t),this._tmpCtx.lineTo(D+this._config.deviceCharWidth*A,D+t),this._tmpCtx.stroke()}if(O||this._tmpCtx.fillText(s,D,D+this._config.deviceCharHeight),s===`_`&&!this._config.allowTransparency){let e=$N(this._tmpCtx.getImageData(D,D,this._config.deviceCellWidth,this._config.deviceCellHeight),x,E,k);if(e)for(let t=1;t<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(s,D,D+this._config.deviceCharHeight-t),e=$N(this._tmpCtx.getImageData(D,D,this._config.deviceCellWidth,this._config.deviceCellHeight),x,E,k),e);t++);}if(h){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(D,D+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(D+this._config.deviceCharWidth*A,D+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let j=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),M;if(M=this._config.allowTransparency?eP(j):$N(j,x,E,k),M)return JN;let N=this._findGlyphBoundingBox(j,this._workBoundingBox,c,T,O,D),P,F;for(;;){if(this._activePages.length===0){let e=this._createNewPage();P=e,F=e.currentRow,F.height=N.size.y;break}P=this._activePages[this._activePages.length-1],F=P.currentRow;for(let e of this._activePages)N.size.y<=e.currentRow.height&&(P=e,F=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=F.height&&N.size.y<=t.height&&(P=this._activePages[e],F=t);if(N.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new QN(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),P=this._overflowSizePage,F=this._overflowSizePage.currentRow,F.x+N.size.x>=P.canvas.width&&(F.x=0,F.y+=F.height,F.height=0);break}if(F.y+N.size.y>=P.canvas.height||F.height>N.size.y+2){let t=!1;if(P.currentRow.y+P.currentRow.height+N.size.y>=P.canvas.height){let n;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+N.size.y<e.canvas.height){n=e;break}if(n)P=n;else if(e.maxAtlasPages&&this._pages.length>=e.maxAtlasPages&&F.y+N.size.y<=P.canvas.height&&F.height>=N.size.y&&F.x+N.size.x<=P.canvas.width)t=!0;else{let e=this._createNewPage();P=e,F=e.currentRow,F.height=N.size.y,t=!0}}t||(P.currentRow.height>0&&P.fixedRows.push(P.currentRow),F={x:0,y:P.currentRow.y+P.currentRow.height,height:N.size.y},P.fixedRows.push(F),P.currentRow={x:0,y:F.y+F.height,height:0})}if(F.x+N.size.x<=P.canvas.width)break;F===P.currentRow?(F.x=0,F.y+=F.height,F.height=0):P.fixedRows.splice(P.fixedRows.indexOf(F),1)}return N.texturePage=this._pages.indexOf(P),N.texturePosition.x=F.x,N.texturePosition.y=F.y,N.texturePositionClipSpace.x=F.x/P.canvas.width,N.texturePositionClipSpace.y=F.y/P.canvas.height,N.sizeClipSpace.x/=P.canvas.width,N.sizeClipSpace.y/=P.canvas.height,F.height=Math.max(F.height,N.size.y),F.x+=N.size.x,P.ctx.putImageData(j,N.texturePosition.x-this._workBoundingBox.left,N.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,N.size.x,N.size.y),P.addGlyph(N),P.version++,N}_findGlyphBoundingBox(e,t,n,r,i,a){t.top=0;let o=r?this._config.deviceCellHeight:this._tmpCanvas.height,s=r?this._config.deviceCellWidth:n,c=!1;for(let n=0;n<o;n++){for(let r=0;r<s;r++){let i=n*this._tmpCanvas.width*4+r*4+3;if(e.data[i]!==0){t.top=n,c=!0;break}}if(c)break}t.left=0,c=!1;for(let n=0;n<a+s;n++){for(let r=0;r<o;r++){let i=r*this._tmpCanvas.width*4+n*4+3;if(e.data[i]!==0){t.left=n,c=!0;break}}if(c)break}t.right=s,c=!1;for(let n=a+s-1;n>=a;n--){for(let r=0;r<o;r++){let i=r*this._tmpCanvas.width*4+n*4+3;if(e.data[i]!==0){t.right=n,c=!0;break}}if(c)break}t.bottom=o,c=!1;for(let n=o-1;n>=0;n--){for(let r=0;r<s;r++){let i=n*this._tmpCanvas.width*4+r*4+3;if(e.data[i]!==0){t.bottom=n,c=!0;break}}if(c)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:t.right-t.left+1,y:t.bottom-t.top+1},sizeClipSpace:{x:t.right-t.left+1,y:t.bottom-t.top+1},offset:{x:-t.left+a+(r||i?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-t.top+a+(r||i?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},QN=class{constructor(e,t,n){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],n)for(let e of n)this._glyphs.push(...e.glyphs),this._usedPixels+=e._usedPixels;this.canvas=tP(e,t,t),this.ctx=UM(this.canvas.getContext(`2d`,{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(e){this._glyphs.push(e),this._usedPixels+=e.size.x*e.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}};function $N(e,t,n,r){let i=t.rgba>>>24,a=t.rgba>>>16&255,o=t.rgba>>>8&255,s=n.rgba>>>24,c=n.rgba>>>16&255,l=n.rgba>>>8&255,u=Math.floor((Math.abs(i-s)+Math.abs(a-c)+Math.abs(o-l))/12),d=!0;for(let t=0;t<e.data.length;t+=4)e.data[t]===i&&e.data[t+1]===a&&e.data[t+2]===o||r&&Math.abs(e.data[t]-i)+Math.abs(e.data[t+1]-a)+Math.abs(e.data[t+2]-o)<u?e.data[t+3]=0:d=!1;return d}function eP(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}function tP(e,t,n){let r=e.createElement(`canvas`);return r.width=t,r.height=n,r}function nP(e,t,n,r,i,a,o,s){let c={foreground:a.foreground,background:a.background,cursor:FM,cursorAccent:FM,selectionForeground:FM,selectionBackgroundTransparent:FM,selectionBackgroundOpaque:FM,selectionInactiveBackgroundTransparent:FM,selectionInactiveBackgroundOpaque:FM,overviewRulerBorder:FM,scrollbarSliderBackground:FM,scrollbarSliderHoverBackground:FM,scrollbarSliderActiveBackground:FM,ansi:a.ansi.slice(),contrastCache:a.contrastCache,halfContrastCache:a.halfContrastCache};return{customGlyphs:i.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:s,letterSpacing:i.letterSpacing,lineHeight:i.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:n,deviceCharHeight:r,fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontWeightBold:i.fontWeightBold,allowTransparency:i.allowTransparency,drawBoldTextInBrightColors:i.drawBoldTextInBrightColors,minimumContrastRatio:i.minimumContrastRatio,colors:c}}function rP(e,t){for(let n=0;n<e.colors.ansi.length;n++)if(e.colors.ansi[n].rgba!==t.colors.ansi[n].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.customGlyphs===t.customGlyphs&&e.lineHeight===t.lineHeight&&e.letterSpacing===t.letterSpacing&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.deviceCharWidth===t.deviceCharWidth&&e.deviceCharHeight===t.deviceCharHeight&&e.drawBoldTextInBrightColors===t.drawBoldTextInBrightColors&&e.minimumContrastRatio===t.minimumContrastRatio&&e.colors.foreground.rgba===t.colors.foreground.rgba&&e.colors.background.rgba===t.colors.background.rgba}function iP(e){return(e&50331648)==16777216||(e&50331648)==33554432}var aP=[];function oP(e,t,n,r,i,a,o,s,c){let l=nP(r,i,a,o,t,n,s,c);for(let t=0;t<aP.length;t++){let n=aP[t],r=n.ownedBy.indexOf(e);if(r>=0){if(rP(n.config,l))return n.atlas;n.ownedBy.length===1?(n.atlas.dispose(),aP.splice(t,1)):n.ownedBy.splice(r,1);break}}for(let t=0;t<aP.length;t++){let n=aP[t];if(rP(n.config,l))return n.ownedBy.push(e),n.atlas}let u=e._core,d={atlas:new ZN(document,l,u.unicodeService),config:l,ownedBy:[e]};return aP.push(d),d.atlas}function sP(e){for(let t=0;t<aP.length;t++){let n=aP[t].ownedBy.indexOf(e);if(n!==-1){aP[t].ownedBy.length===1?(aP[t].atlas.dispose(),aP.splice(t,1)):aP[t].ownedBy.splice(n,1);break}}}var cP=600,lP=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout&&=(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),void 0),this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}))}_restartInterval(e=cP){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=cP-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=cP-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},cP)},e)}pause(){this.isCursorVisible=!0,this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout&&=(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),void 0),this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function uP(e,t,n){let r=new t.ResizeObserver(t=>{let i=t.find(t=>t.target===e);if(!i)return;if(!(`devicePixelContentBoxSize`in i)){r?.disconnect(),r=void 0;return}let a=i.devicePixelContentBoxSize[0].inlineSize,o=i.devicePixelContentBoxSize[0].blockSize;a>0&&o>0&&n(a,o)});try{r.observe(e,{box:[`device-pixel-content-box`]})}catch{r.disconnect(),r=void 0}return vM(()=>r?.disconnect())}function dP(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var fP=class e extends kN{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new AN,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?dP(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},pP=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function mP(e,t,n){let r=UM(e.createProgram());if(e.attachShader(r,UM(hP(e,e.VERTEX_SHADER,t))),e.attachShader(r,UM(hP(e,e.FRAGMENT_SHADER,n))),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS))return r;console.error(e.getProgramInfoLog(r)),e.deleteProgram(r)}function hP(e,t,n){let r=UM(e.createShader(t));if(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS))return r;console.error(e.getShaderInfoLog(r)),e.deleteShader(r)}function gP(e,t){let n=Math.min(e.length*2,t),r=new Float32Array(n);for(let t=0;t<e.length;t++)r[t]=e[t];return r}var _P=class{constructor(e){this.texture=e,this.version=-1}},vP=`#version 300 es
|
|
69
69
|
layout (location = 0) in vec2 a_unitquad;
|
|
70
70
|
layout (location = 1) in vec2 a_cellpos;
|
|
71
71
|
layout (location = 2) in vec2 a_offset;
|
|
@@ -85,7 +85,7 @@ void main() {
|
|
|
85
85
|
gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
|
|
86
86
|
v_texpage = int(a_texpage);
|
|
87
87
|
v_texcoord = a_texcoord + a_unitquad * a_texsize;
|
|
88
|
-
}`;function
|
|
88
|
+
}`;function yP(e){let t=``;for(let n=1;n<e;n++)t+=` else if (v_texpage == ${n}) { outColor = texture(u_texture[${n}], v_texcoord); }`;return`#version 300 es
|
|
89
89
|
precision lowp float;
|
|
90
90
|
|
|
91
91
|
in vec2 v_texcoord;
|
|
@@ -99,7 +99,7 @@ void main() {
|
|
|
99
99
|
if (v_texpage == 0) {
|
|
100
100
|
outColor = texture(u_texture[0], v_texcoord);
|
|
101
101
|
} ${t}
|
|
102
|
-
}`}var
|
|
102
|
+
}`}var bP=11,xP=bP*Float32Array.BYTES_PER_ELEMENT,SP=2,CP=0,wP,TP=0,EP=0,DP=class extends xM{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._optionsService=r,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array,attributesBuffers:[new Float32Array,new Float32Array]};let i=this._gl;ZN.maxAtlasPages===void 0&&(ZN.maxAtlasPages=Math.min(32,UM(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS))),ZN.maxTextureSize=UM(i.getParameter(i.MAX_TEXTURE_SIZE))),this._program=UM(mP(i,vP,yP(ZN.maxAtlasPages))),this._register(vM(()=>i.deleteProgram(this._program))),this._projectionLocation=UM(i.getUniformLocation(this._program,`u_projection`)),this._resolutionLocation=UM(i.getUniformLocation(this._program,`u_resolution`)),this._textureLocation=UM(i.getUniformLocation(this._program,`u_texture`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(vM(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(vM(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=UM(i.createBuffer()),this._register(vM(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,2,i.FLOAT,!1,xP,0),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,xP,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,1,i.FLOAT,!1,xP,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,2,i.FLOAT,!1,xP,5*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,2,i.FLOAT,!1,xP,7*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(6,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,xP,9*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.useProgram(this._program);let l=new Int32Array(ZN.maxAtlasPages);for(let e=0;e<ZN.maxAtlasPages;e++)l[e]=e;i.uniform1iv(this._textureLocation,l),i.uniformMatrix4fv(this._projectionLocation,!1,pP),this._atlasTextures=[];for(let e=0;e<ZN.maxAtlasPages;e++){let t=new _P(UM(i.createTexture()));this._register(vM(()=>i.deleteTexture(t.texture))),i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,t.texture),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[e]=t}i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return!this._atlas||this._atlas.beginFrame()}updateCell(e,t,n,r,i,a,o,s,c){this._updateCell(this._vertices.attributes,e,t,n,r,i,a,o,s,c)}_updateCell(e,t,n,r,i,a,o,s,c,l){if(CP=(n*this._terminal.cols+t)*bP,r===0||r===void 0){e.fill(0,CP,CP+bP-1-SP);return}this._atlas&&(wP=s&&s.length>1?this._atlas.getRasterizedGlyphCombinedChar(s,i,a,o,!1,this._terminal.element):this._atlas.getRasterizedGlyph(r,i,a,o,!1,this._terminal.element),TP=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),i!==l&&wP.offset.x>TP?(EP=wP.offset.x-TP,e[CP]=-(wP.offset.x-EP)+this._dimensions.device.char.left,e[CP+1]=-wP.offset.y+this._dimensions.device.char.top,e[CP+2]=(wP.size.x-EP)/this._dimensions.device.canvas.width,e[CP+3]=wP.size.y/this._dimensions.device.canvas.height,e[CP+4]=wP.texturePage,e[CP+5]=wP.texturePositionClipSpace.x+EP/this._atlas.pages[wP.texturePage].canvas.width,e[CP+6]=wP.texturePositionClipSpace.y,e[CP+7]=wP.sizeClipSpace.x-EP/this._atlas.pages[wP.texturePage].canvas.width,e[CP+8]=wP.sizeClipSpace.y):(e[CP]=-wP.offset.x+this._dimensions.device.char.left,e[CP+1]=-wP.offset.y+this._dimensions.device.char.top,e[CP+2]=wP.size.x/this._dimensions.device.canvas.width,e[CP+3]=wP.size.y/this._dimensions.device.canvas.height,e[CP+4]=wP.texturePage,e[CP+5]=wP.texturePositionClipSpace.x,e[CP+6]=wP.texturePositionClipSpace.y,e[CP+7]=wP.sizeClipSpace.x,e[CP+8]=wP.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&YM(r,c,wP.size.x,this._dimensions.device.cell.width)&&(e[CP+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let e=this._terminal,t=e.cols*e.rows*bP;this._vertices.count===t?this._vertices.attributes.fill(0):this._vertices.attributes=new Float32Array(t);let n=0;for(;n<this._vertices.attributesBuffers.length;n++)this._vertices.count===t?this._vertices.attributesBuffers[n].fill(0):this._vertices.attributesBuffers[n]=new Float32Array(t);this._vertices.count=t,n=0;for(let t=0;t<e.rows;t++)for(let r=0;r<e.cols;r++)this._vertices.attributes[n+9]=r/e.cols,this._vertices.attributes[n+10]=t/e.rows,n+=bP}handleResize(){let e=this._gl;e.useProgram(this._program),e.viewport(0,0,e.canvas.width,e.canvas.height),e.uniform2f(this._resolutionLocation,e.canvas.width,e.canvas.height),this.clear()}render(e){if(!this._atlas)return;let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let n=this._vertices.attributesBuffers[this._activeBuffer],r=0;for(let t=0;t<e.lineLengths.length;t++){let i=t*this._terminal.cols*bP,a=this._vertices.attributes.subarray(i,i+e.lineLengths[t]*bP);n.set(a,r),r+=a.length}t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,n.subarray(0,r),t.STREAM_DRAW);for(let e=0;e<this._atlas.pages.length;e++)this._atlas.pages[e].version!==this._atlasTextures[e].version&&this._bindAtlasPageTexture(t,this._atlas,e);t.drawElementsInstanced(t.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,r/bP)}setAtlas(e){this._atlas=e;for(let e of this._atlasTextures)e.version=-1}_bindAtlasPageTexture(e,t,n){e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,this._atlasTextures[n].texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.pages[n].canvas),e.generateMipmap(e.TEXTURE_2D),this._atlasTextures[n].version=t.pages[n].version}setDimensions(e){this._dimensions=e}},OP=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function kP(){return new OP}var AP=4,jP=1,MP=2,NP=3,PP=2147483648,FP=class{constructor(){this.cells=new Uint32Array,this.lineLengths=new Uint32Array,this.selection=kP()}resize(e,t){let n=e*t*AP;n!==this.cells.length&&(this.cells=new Uint32Array(n),this.lineLengths=new Uint32Array(t))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},IP=`#version 300 es
|
|
103
103
|
layout (location = 0) in vec2 a_position;
|
|
104
104
|
layout (location = 1) in vec2 a_size;
|
|
105
105
|
layout (location = 2) in vec4 a_color;
|
|
@@ -113,7 +113,7 @@ void main() {
|
|
|
113
113
|
vec2 zeroToOne = a_position + (a_unitquad * a_size);
|
|
114
114
|
gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
|
|
115
115
|
v_color = a_color;
|
|
116
|
-
}`,
|
|
116
|
+
}`,LP=`#version 300 es
|
|
117
117
|
precision lowp float;
|
|
118
118
|
|
|
119
119
|
in vec4 v_color;
|
|
@@ -122,19 +122,19 @@ out vec4 outColor;
|
|
|
122
122
|
|
|
123
123
|
void main() {
|
|
124
124
|
outColor = v_color;
|
|
125
|
-
}`,IP=8,LP=IP*Float32Array.BYTES_PER_ELEMENT,RP=20*IP,zP=class{constructor(){this.attributes=new Float32Array(RP),this.count=0}},BP=0,VP=0,HP=0,UP=0,WP=0,GP=0,KP=0,qP=class extends yM{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._themeService=r,this._vertices=new zP,this._verticesCursor=new zP;let i=this._gl;this._program=VM(fP(i,PP,FP)),this._register(gM(()=>i.deleteProgram(this._program))),this._projectionLocation=VM(i.getUniformLocation(this._program,`u_projection`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(gM(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(gM(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=VM(i.createBuffer()),this._register(gM(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,LP,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,LP,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,LP,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,dP),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(e){let t=this._terminal,n=this._vertices,r=1,i,a,o,s,c,l,u,d,f,p,m;for(i=0;i<t.rows;i++){for(o=-1,s=0,c=0,l=!1,a=0;a<t.cols;a++)u=(i*t.cols+a)*OP,d=e.cells[u+kP],f=e.cells[u+AP],p=!!(f&67108864),(d!==s||f!==c&&(l||p))&&((s!==0||l&&c!==0)&&(m=r++*IP,this._updateRectangle(n,m,c,s,o,a,i)),o=a,s=d,c=f,l=p);(s!==0||l&&c!==0)&&(m=r++*IP,this._updateRectangle(n,m,c,s,o,t.cols,i))}n.count=r}updateCursor(e){let t=this._verticesCursor,n=e.cursor;if(!n||n.style===`block`){t.count=0;return}let r,i=0;(n.style===`bar`||n.style===`outline`)&&(r=i++*IP,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.style===`bar`?n.dpr*n.cursorWidth:n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(n.style===`underline`||n.style===`outline`)&&(r=i++*IP,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,(n.y+1)*this._dimensions.device.cell.height-n.dpr,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat)),n.style===`outline`&&(r=i++*IP,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat),r=i++*IP,this._addRectangleFloat(t.attributes,r,(n.x+n.width)*this._dimensions.device.cell.width-n.dpr,n.y*this._dimensions.device.cell.height,n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),t.count=i}_updateRectangle(e,t,n,r,i,a,o){if(n&67108864)switch(n&50331648){case 16777216:case 33554432:BP=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:BP=(n&16777215)<<8;break;default:BP=this._themeService.colors.foreground.rgba}else switch(r&50331648){case 16777216:case 33554432:BP=this._themeService.colors.ansi[r&255].rgba;break;case 50331648:BP=(r&16777215)<<8;break;default:BP=this._themeService.colors.background.rgba}e.attributes.length<t+4&&(e.attributes=mP(e.attributes,this._terminal.rows*this._terminal.cols*IP)),VP=i*this._dimensions.device.cell.width,HP=o*this._dimensions.device.cell.height,UP=(BP>>24&255)/255,WP=(BP>>16&255)/255,GP=(BP>>8&255)/255,KP=1,this._addRectangle(e.attributes,t,VP,HP,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,UP,WP,GP,KP)}_addRectangle(e,t,n,r,i,a,o,s,c,l){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=s,e[t+6]=c,e[t+7]=l}_addRectangleFloat(e,t,n,r,i,a,o){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(e.rgba&255)/255])}},JP=class extends yM{constructor(e,t,n,r,i,a,o,s){super(),this._container=t,this._alpha=i,this._coreBrowserService=a,this._optionsService=o,this._themeService=s,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(gM(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=VM(this._canvas.getContext(`2d`,{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,n){}handleSelectionChanged(e,t,n,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let n=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=iP(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,n=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,n,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,n,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=sN,this._clipCell(n,r,t.getWidth()),this._ctx.fillText(t.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,n){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,n){let r=t?e.options.fontWeightBold:e.options.fontWeight;return`${n?`italic`:``} ${r} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},YP=class extends JP{constructor(e,t,n,r,i,a,o){super(n,e,`link`,t,!0,i,a,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(e.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:e.fg!==void 0&&nP(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t<e.y2;t++)this._fillBottomLineAtCells(0,t,e.cols);this._fillBottomLineAtCells(0,e.y2,e.x2)}this._state=e}_handleHideLinkUnderline(e){this._clearCurrentLink()}},XP=typeof window==`object`?window:globalThis,ZP=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new WN,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new WN,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};ZP.INSTANCE=new ZP;var QP=ZP;function $P(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}QP.INSTANCE.onDidChangeZoomLevel,QP.INSTANCE.onDidChangeFullscreen;var eF=typeof navigator==`object`?navigator.userAgent:``;eF.indexOf(`Firefox`);var tF=eF.indexOf(`AppleWebKit`)>=0;!(eF.indexOf(`Chrome`)>=0)&&eF.indexOf(`Safari`),eF.indexOf(`Electron/`),eF.indexOf(`Android`);var nF=!1;if(typeof XP.matchMedia==`function`){let e=XP.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=XP.matchMedia(`(display-mode: fullscreen)`);nF=e.matches,$P(XP,e,({matches:e})=>{nF&&t.matches||(nF=e)})}function rF(){return nF}var iF=`en`,aF=!1,oF=!1,sF=!1,cF=iF,lF,uF=globalThis,dF;typeof uF.vscode<`u`&&typeof uF.vscode.process<`u`?dF=uF.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(dF=process);var fF=typeof dF?.versions?.electron==`string`&&dF?.type===`renderer`;if(typeof dF==`object`){dF.platform,dF.platform,aF=dF.platform===`linux`,aF&&dF.env.SNAP&&dF.env.SNAP_REVISION,dF.env.CI||dF.env.BUILD_ARTIFACTSTAGINGDIRECTORY,cF=iF;let e=dF.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,cF=t.resolvedLanguage||iF,t.languagePack?.translationsConfigFile}catch{}oF=!0}else typeof navigator==`object`&&!fF?(lF=navigator.userAgent,lF.indexOf(`Windows`),lF.indexOf(`Macintosh`),(lF.indexOf(`Macintosh`)>=0||lF.indexOf(`iPad`)>=0||lF.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,aF=lF.indexOf(`Linux`)>=0,lF?.indexOf(`Mobi`),sF=!0,cF=globalThis._VSCODE_NLS_LANGUAGE||iF,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var pF=oF;sF&&typeof uF.importScripts==`function`&&uF.origin;var mF=lF,hF=cF,gF;(e=>{function t(){return hF}e.value=t;function n(){return hF.length===2?hF===`en`:hF.length>=3&&hF[0]===`e`&&hF[1]===`n`&&hF[2]===`-`}e.isDefaultVariant=n;function r(){return hF===`en`}e.isDefault=r})(gF||={});var _F=typeof uF.postMessage==`function`&&!uF.importScripts;(()=>{if(_F){let e=[];uF.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),uF.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var vF=!!(mF&&mF.indexOf(`Chrome`)>=0);mF&&mF.indexOf(`Firefox`),!vF&&mF&&mF.indexOf(`Safari`),mF&&mF.indexOf(`Edg/`),mF&&mF.indexOf(`Android`);var yF=typeof navigator==`object`?navigator:{};pF||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||yF&&yF.clipboard&&yF.clipboard.writeText,pF||yF&&yF.clipboard&&yF.clipboard.readText,pF||rF()||yF.keyboard,`ontouchstart`in XP||yF.maxTouchPoints,XP.PointerEvent&&(`ontouchstart`in XP||navigator.maxTouchPoints);var bF=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}},xF=new bF,SF=new bF,CF=new bF;Array(230);var wF;(e=>{function t(e){return xF.keyCodeToStr(e)}e.toString=t;function n(e){return xF.strToKeyCode(e)}e.fromString=n;function r(e){return SF.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return CF.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return SF.strToKeyCode(e)||CF.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return xF.keyCodeToStr(e)}e.toElectronAccelerator=o})(wF||={});var TF=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),EF;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof DF?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:MN.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:TF})})(EF||={});var DF=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?TF:(this._emitter||=new WN,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var OF;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(OF||={});var kF=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new WN,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await MN.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};kF.EMPTY=kF.fromArray([]);function AF(e){return jF(e,0)}function jF(e,t){switch(typeof e){case`object`:return e===null?MF(349,t):Array.isArray(e)?FF(e,t):IF(e,t);case`string`:return PF(e,t);case`boolean`:return NF(e,t);case`number`:return MF(e,t);case`undefined`:return MF(937,t);default:return MF(617,t)}}function MF(e,t){return(t<<5)-t+e|0}function NF(e,t){return MF(e?433:863,t)}function PF(e,t){t=MF(149417,t);for(let n=0,r=e.length;n<r;n++)t=MF(e.charCodeAt(n),t);return t}function FF(e,t){return t=MF(104579,t),e.reduce((e,t)=>jF(t,e),t)}function IF(e,t){return t=MF(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=PF(n,t),jF(e[n],t)),t)}var{registerWindow:LF,getWindow:RF,getDocument:zF,getWindows:BF,getWindowsCount:VF,getWindowId:HF,getWindowById:UF,hasWindow:WF,onDidRegisterWindow:GF,onWillUnregisterWindow:KF,onDidUnregisterWindow:qF}=function(){let e=new Map,t={window:XP,disposables:new vM};e.set(XP.vscodeWindowId,t);let n=new WN,r=new WN,i=new WN;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return yM.None;let a=new vM,o={window:t,disposables:a.add(new vM)};return e.set(t.vscodeWindowId,o),a.add(gM(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(YF(t,ZF.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:XP},getDocument(e){return RF(e).document}}}(),JF=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!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,null)}};function YF(e,t,n,r){return new JF(e,t,n,r)}var XF=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};XF.None=new XF(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=AF(n),a=r.get(i);if(a)a.users+=1;else{let o=new WN,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(gM(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var ZF={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:tF?`webkitAnimationStart`:`animationstart`,ANIMATION_END:tF?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:tF?`webkitAnimationIteration`:`animationiteration`},QF=class extends yM{constructor(e,t,n,r,i,a,o,s,c){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._optionsService=o,this._themeService=s,this._cursorBlinkStateManager=new bM,this._charAtlasDisposable=this._register(new bM),this._observerDisposable=this._register(new bM),this._model=new NP,this._workCell=new uP,this._workCell2=new uP,this._rectangleRenderer=this._register(new bM),this._glyphRenderer=this._register(new bM),this._onChangeTextureAtlas=this._register(new WN),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new WN),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new WN),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new WN),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new WN),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`);let l={antialias:!1,depth:!1,preserveDrawingBuffer:c};if(this._gl=this._canvas.getContext(`webgl2`,l),!this._gl)throw Error(`WebGL2 not supported `+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new aN(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new YP(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=YM(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(YF(this._canvas,`webglcontextlost`,e=>{console.log(`webglcontextlost event received`),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn(`webgl context not restored; firing onContextLoss`),this._onContextLoss.fire(e)},3e3)})),this._register(YF(this._canvas,`webglcontextrestored`,e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,aP(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=cP(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=cP(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(gM(()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),aP(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let e of this._renderLayers)e.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,n){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,n);this._model.selection.update(this._core,e,t,n),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new qP(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new TP(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let e=iP(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=hM(MN.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),MN.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){if(!this._isAttached){if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return}for(let n of this._renderLayers)n.handleGridChanged(this._terminal,e,t);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new sP(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let n=this._core,r=this._workCell,i,a,o,s,c,l,u=0,d=!0,f,p,m,h,g,_,v,y,b;e=eI(e,n.rows-1,0),t=eI(t,n.rows-1,0);let x=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??`block`,S=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,C=S-n.buffer.ydisp,w=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),T=-1,E=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let D=!1;for(a=e;a<=t;a++)for(o=a+n.buffer.ydisp,s=n.buffer.lines.get(o),this._model.lineLengths[a]=0,m=S===o,u=0,c=this._characterJoinerService.getJoinedCharacters(o),y=0;y<n.cols;y++){if(i=this._cellColorResolver.result.bg,s.loadCell(y,r),y===0&&(i=this._cellColorResolver.result.bg),l=!1,d=y>=u,f=y,c.length>0&&y===c[0][0]&&d){p=c.shift();let e=this._model.selection.isCellSelected(this._terminal,p[0],o);for(v=p[0]+1;v<p[1];v++)d&&=e===this._model.selection.isCellSelected(this._terminal,v,o);d&&=!m||w<p[0]||w>=p[1],d?(l=!0,r=new $F(r,s.translateToString(!0,p[0],p[1]),p[1]-p[0]),f=p[1]-1):u=p[1]}if(h=r.getChars(),g=r.getCode(),v=(a*n.cols+y)*OP,this._cellColorResolver.resolve(r,y,o,this.dimensions.device.cell.width),E&&o===S&&(y===w&&(this._model.cursor={x:w,y:C,width:r.getWidth(),style:this._coreBrowserService.isFocused?x:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},T=w+r.getWidth()-1),y>=w&&y<=T&&(this._coreBrowserService.isFocused&&x===`block`||this._coreBrowserService.isFocused===!1&&n.options.cursorInactiveStyle===`block`)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),g!==0&&(this._model.lineLengths[a]=y+1),(this._model.cells[v]!==g||this._model.cells[v+kP]!==this._cellColorResolver.result.bg||this._model.cells[v+AP]!==this._cellColorResolver.result.fg||this._model.cells[v+jP]!==this._cellColorResolver.result.ext)&&(D=!0,h.length>1&&(g|=MP),this._model.cells[v]=g,this._model.cells[v+kP]=this._cellColorResolver.result.bg,this._model.cells[v+AP]=this._cellColorResolver.result.fg,this._model.cells[v+jP]=this._cellColorResolver.result.ext,_=r.getWidth(),this._glyphRenderer.value.updateCell(y,a,g,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,h,_,i),l)){for(r=this._workCell,y++;y<=f;y++)b=(a*n.cols+y)*OP,this._glyphRenderer.value.updateCell(y,a,0,0,0,0,OM,0,0),this._model.cells[b]=0,this._model.cells[b+kP]=this._cellColorResolver.result.bg,this._model.cells[b+AP]=this._cellColorResolver.result.fg,this._model.cells[b+jP]=this._cellColorResolver.result.ext;y--}}D&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},$F=class extends DN{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function eI(e,t,n=0){return Math.max(Math.min(e,t),n)}var tI=`di$target`,nI=`di$dependencies`,rI=new Map;function iI(e){if(rI.has(e))return rI.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);aI(t,e,r)};return t._id=e,rI.set(e,t),t}function aI(e,t,n){t[tI]===t?t[nI].push({id:e,index:n}):(t[nI]=[{id:e,index:n}],t[tI]=t)}iI(`BufferService`),iI(`CoreMouseService`),iI(`CoreService`),iI(`CharsetService`),iI(`InstantiationService`),iI(`LogService`);var oI=iI(`OptionsService`);iI(`OscLinkService`),iI(`UnicodeService`),iI(`DecorationService`);var sI={trace:0,debug:1,info:2,warn:3,error:4,off:5},cI=`xterm.js: `,lI=class extends yM{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),uI=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=sI[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:cI)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};lI=Qj([$j(0,oI)],lI);var uI,dI=class extends yM{constructor(e){if(EM&&DM()<16&&!document.createElement(`canvas`).getContext(`webgl2`,{antialias:!1,depth:!1,preserveDrawingBuffer:!0}))throw Error(`Webgl2 is only supported on Safari 16 and above`);super(),this._preserveDrawingBuffer=e,this._onChangeTextureAtlas=this._register(new WN),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new WN),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new WN),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new WN),this.onContextLoss=this._onContextLoss.event}activate(e){let t=e._core;if(!e.element){this._register(t.onWillOpen(()=>this.activate(e)));return}this._terminal=e;let n=t.coreService,r=t.optionsService,i=t,a=i._renderService,o=i._characterJoinerService,s=i._charSizeService,c=i._coreBrowserService,l=i._decorationService;i._logService;let u=i._themeService;this._renderer=this._register(new QF(e,o,s,c,n,l,r,u,this._preserveDrawingBuffer)),this._register(MN.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(MN.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(MN.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(MN.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(gM(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}},fI=Object.defineProperty,pI=Object.getOwnPropertyDescriptor,mI=(e,t)=>{for(var n in t)fI(e,n,{get:t[n],enumerable:!0})},hI=(e,t,n,r)=>{for(var i=r>1?void 0:r?pI(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&fI(t,n,i),i},Z=(e,t)=>(n,r)=>t(n,r,e),gI=`Terminal input`,_I={get:()=>gI,set:e=>gI=e},vI=`Too much output to announce, navigate to rows manually to read`,yI={get:()=>vI,set:e=>vI=e};function bI(e){return e.replace(/\r?\n/g,`\r`)}function xI(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function SI(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function CI(e,t,n,r){e.stopPropagation(),e.clipboardData&&wI(e.clipboardData.getData(`text/plain`),t,n,r)}function wI(e,t,n,r){e=bI(e),e=xI(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function TI(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function EI(e,t,n,r,i){TI(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function DI(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function OI(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var kI=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},AI=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},jI=``,MI=` `,NI=class e{constructor(){this.fg=0,this.bg=0,this.extended=new PI}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;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)}isBgDefault(){return!(this.bg&50331648)}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):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},PI=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},FI=class e extends NI{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new PI,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?DI(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},II=`di$target`,LI=`di$dependencies`,RI=new Map;function zI(e){return e[LI]||[]}function BI(e){if(RI.has(e))return RI.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);VI(t,e,r)};return t._id=e,RI.set(e,t),t}function VI(e,t,n){t[II]===t?t[LI].push({id:e,index:n}):(t[LI]=[{id:e,index:n}],t[II]=t)}var HI=BI(`BufferService`),UI=BI(`CoreMouseService`),WI=BI(`CoreService`),GI=BI(`CharsetService`),KI=BI(`InstantiationService`),qI=BI(`LogService`),JI=BI(`OptionsService`),YI=BI(`OscLinkService`),XI=BI(`UnicodeService`),ZI=BI(`DecorationService`),QI=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new FI,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):$I(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};QI=hI([Z(0,HI),Z(1,JI),Z(2,YI)],QI);function $I(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
125
|
+
}`,RP=8,zP=RP*Float32Array.BYTES_PER_ELEMENT,BP=20*RP,VP=class{constructor(){this.attributes=new Float32Array(BP),this.count=0}},HP=0,UP=0,WP=0,GP=0,KP=0,qP=0,JP=0,YP=class extends xM{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._themeService=r,this._vertices=new VP,this._verticesCursor=new VP;let i=this._gl;this._program=UM(mP(i,IP,LP)),this._register(vM(()=>i.deleteProgram(this._program))),this._projectionLocation=UM(i.getUniformLocation(this._program,`u_projection`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(vM(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(vM(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=UM(i.createBuffer()),this._register(vM(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,zP,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,zP,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,zP,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,pP),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(e){let t=this._terminal,n=this._vertices,r=1,i,a,o,s,c,l,u,d,f,p,m;for(i=0;i<t.rows;i++){for(o=-1,s=0,c=0,l=!1,a=0;a<t.cols;a++)u=(i*t.cols+a)*AP,d=e.cells[u+jP],f=e.cells[u+MP],p=!!(f&67108864),(d!==s||f!==c&&(l||p))&&((s!==0||l&&c!==0)&&(m=r++*RP,this._updateRectangle(n,m,c,s,o,a,i)),o=a,s=d,c=f,l=p);(s!==0||l&&c!==0)&&(m=r++*RP,this._updateRectangle(n,m,c,s,o,t.cols,i))}n.count=r}updateCursor(e){let t=this._verticesCursor,n=e.cursor;if(!n||n.style===`block`){t.count=0;return}let r,i=0;(n.style===`bar`||n.style===`outline`)&&(r=i++*RP,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.style===`bar`?n.dpr*n.cursorWidth:n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(n.style===`underline`||n.style===`outline`)&&(r=i++*RP,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,(n.y+1)*this._dimensions.device.cell.height-n.dpr,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat)),n.style===`outline`&&(r=i++*RP,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat),r=i++*RP,this._addRectangleFloat(t.attributes,r,(n.x+n.width)*this._dimensions.device.cell.width-n.dpr,n.y*this._dimensions.device.cell.height,n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),t.count=i}_updateRectangle(e,t,n,r,i,a,o){if(n&67108864)switch(n&50331648){case 16777216:case 33554432:HP=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:HP=(n&16777215)<<8;break;default:HP=this._themeService.colors.foreground.rgba}else switch(r&50331648){case 16777216:case 33554432:HP=this._themeService.colors.ansi[r&255].rgba;break;case 50331648:HP=(r&16777215)<<8;break;default:HP=this._themeService.colors.background.rgba}e.attributes.length<t+4&&(e.attributes=gP(e.attributes,this._terminal.rows*this._terminal.cols*RP)),UP=i*this._dimensions.device.cell.width,WP=o*this._dimensions.device.cell.height,GP=(HP>>24&255)/255,KP=(HP>>16&255)/255,qP=(HP>>8&255)/255,JP=1,this._addRectangle(e.attributes,t,UP,WP,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,GP,KP,qP,JP)}_addRectangle(e,t,n,r,i,a,o,s,c,l){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=s,e[t+6]=c,e[t+7]=l}_addRectangleFloat(e,t,n,r,i,a,o){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(e.rgba&255)/255])}},XP=class extends xM{constructor(e,t,n,r,i,a,o,s){super(),this._container=t,this._alpha=i,this._coreBrowserService=a,this._optionsService=o,this._themeService=s,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(vM(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=UM(this._canvas.getContext(`2d`,{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,n){}handleSelectionChanged(e,t,n,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let n=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=oP(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,n=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,n,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,n,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=lN,this._clipCell(n,r,t.getWidth()),this._ctx.fillText(t.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,n){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,n){let r=t?e.options.fontWeightBold:e.options.fontWeight;return`${n?`italic`:``} ${r} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},ZP=class extends XP{constructor(e,t,n,r,i,a,o){super(n,e,`link`,t,!0,i,a,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(e.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:e.fg!==void 0&&iP(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t<e.y2;t++)this._fillBottomLineAtCells(0,t,e.cols);this._fillBottomLineAtCells(0,e.y2,e.x2)}this._state=e}_handleHideLinkUnderline(e){this._clearCurrentLink()}},QP=typeof window==`object`?window:globalThis,$P=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new KN,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new KN,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};$P.INSTANCE=new $P;var eF=$P;function tF(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}eF.INSTANCE.onDidChangeZoomLevel,eF.INSTANCE.onDidChangeFullscreen;var nF=typeof navigator==`object`?navigator.userAgent:``;nF.indexOf(`Firefox`);var rF=nF.indexOf(`AppleWebKit`)>=0;!(nF.indexOf(`Chrome`)>=0)&&nF.indexOf(`Safari`),nF.indexOf(`Electron/`),nF.indexOf(`Android`);var iF=!1;if(typeof QP.matchMedia==`function`){let e=QP.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=QP.matchMedia(`(display-mode: fullscreen)`);iF=e.matches,tF(QP,e,({matches:e})=>{iF&&t.matches||(iF=e)})}function aF(){return iF}var oF=`en`,sF=!1,cF=!1,lF=!1,uF=oF,dF,fF=globalThis,pF;typeof fF.vscode<`u`&&typeof fF.vscode.process<`u`?pF=fF.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(pF=process);var mF=typeof pF?.versions?.electron==`string`&&pF?.type===`renderer`;if(typeof pF==`object`){pF.platform,pF.platform,sF=pF.platform===`linux`,sF&&pF.env.SNAP&&pF.env.SNAP_REVISION,pF.env.CI||pF.env.BUILD_ARTIFACTSTAGINGDIRECTORY,uF=oF;let e=pF.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,uF=t.resolvedLanguage||oF,t.languagePack?.translationsConfigFile}catch{}cF=!0}else typeof navigator==`object`&&!mF?(dF=navigator.userAgent,dF.indexOf(`Windows`),dF.indexOf(`Macintosh`),(dF.indexOf(`Macintosh`)>=0||dF.indexOf(`iPad`)>=0||dF.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,sF=dF.indexOf(`Linux`)>=0,dF?.indexOf(`Mobi`),lF=!0,uF=globalThis._VSCODE_NLS_LANGUAGE||oF,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var hF=cF;lF&&typeof fF.importScripts==`function`&&fF.origin;var gF=dF,_F=uF,vF;(e=>{function t(){return _F}e.value=t;function n(){return _F.length===2?_F===`en`:_F.length>=3&&_F[0]===`e`&&_F[1]===`n`&&_F[2]===`-`}e.isDefaultVariant=n;function r(){return _F===`en`}e.isDefault=r})(vF||={});var yF=typeof fF.postMessage==`function`&&!fF.importScripts;(()=>{if(yF){let e=[];fF.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),fF.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var bF=!!(gF&&gF.indexOf(`Chrome`)>=0);gF&&gF.indexOf(`Firefox`),!bF&&gF&&gF.indexOf(`Safari`),gF&&gF.indexOf(`Edg/`),gF&&gF.indexOf(`Android`);var xF=typeof navigator==`object`?navigator:{};hF||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||xF&&xF.clipboard&&xF.clipboard.writeText,hF||xF&&xF.clipboard&&xF.clipboard.readText,hF||aF()||xF.keyboard,`ontouchstart`in QP||xF.maxTouchPoints,QP.PointerEvent&&(`ontouchstart`in QP||navigator.maxTouchPoints);var SF=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}},CF=new SF,wF=new SF,TF=new SF;Array(230);var EF;(e=>{function t(e){return CF.keyCodeToStr(e)}e.toString=t;function n(e){return CF.strToKeyCode(e)}e.fromString=n;function r(e){return wF.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return TF.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return wF.strToKeyCode(e)||TF.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return CF.keyCodeToStr(e)}e.toElectronAccelerator=o})(EF||={});var DF=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),OF;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof kF?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:PN.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:DF})})(OF||={});var kF=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?DF:(this._emitter||=new KN,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var AF;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(AF||={});var jF=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new KN,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await PN.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};jF.EMPTY=jF.fromArray([]);function MF(e){return NF(e,0)}function NF(e,t){switch(typeof e){case`object`:return e===null?PF(349,t):Array.isArray(e)?LF(e,t):RF(e,t);case`string`:return IF(e,t);case`boolean`:return FF(e,t);case`number`:return PF(e,t);case`undefined`:return PF(937,t);default:return PF(617,t)}}function PF(e,t){return(t<<5)-t+e|0}function FF(e,t){return PF(e?433:863,t)}function IF(e,t){t=PF(149417,t);for(let n=0,r=e.length;n<r;n++)t=PF(e.charCodeAt(n),t);return t}function LF(e,t){return t=PF(104579,t),e.reduce((e,t)=>NF(t,e),t)}function RF(e,t){return t=PF(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=IF(n,t),NF(e[n],t)),t)}var{registerWindow:zF,getWindow:BF,getDocument:VF,getWindows:HF,getWindowsCount:UF,getWindowId:WF,getWindowById:GF,hasWindow:KF,onDidRegisterWindow:qF,onWillUnregisterWindow:JF,onDidUnregisterWindow:YF}=function(){let e=new Map,t={window:QP,disposables:new bM};e.set(QP.vscodeWindowId,t);let n=new KN,r=new KN,i=new KN;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return xM.None;let a=new bM,o={window:t,disposables:a.add(new bM)};return e.set(t.vscodeWindowId,o),a.add(vM(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(ZF(t,$F.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:QP},getDocument(e){return BF(e).document}}}(),XF=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!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,null)}};function ZF(e,t,n,r){return new XF(e,t,n,r)}var QF=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};QF.None=new QF(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=MF(n),a=r.get(i);if(a)a.users+=1;else{let o=new KN,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(vM(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var $F={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:rF?`webkitAnimationStart`:`animationstart`,ANIMATION_END:rF?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:rF?`webkitAnimationIteration`:`animationiteration`},eI=class extends xM{constructor(e,t,n,r,i,a,o,s,c){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._optionsService=o,this._themeService=s,this._cursorBlinkStateManager=new SM,this._charAtlasDisposable=this._register(new SM),this._observerDisposable=this._register(new SM),this._model=new FP,this._workCell=new fP,this._workCell2=new fP,this._rectangleRenderer=this._register(new SM),this._glyphRenderer=this._register(new SM),this._onChangeTextureAtlas=this._register(new KN),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new KN),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new KN),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new KN),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new KN),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`);let l={antialias:!1,depth:!1,preserveDrawingBuffer:c};if(this._gl=this._canvas.getContext(`webgl2`,l),!this._gl)throw Error(`WebGL2 not supported `+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new sN(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new ZP(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=ZM(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(ZF(this._canvas,`webglcontextlost`,e=>{console.log(`webglcontextlost event received`),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn(`webgl context not restored; firing onContextLoss`),this._onContextLoss.fire(e)},3e3)})),this._register(ZF(this._canvas,`webglcontextrestored`,e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,sP(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=uP(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=uP(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(vM(()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),sP(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let e of this._renderLayers)e.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,n){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,n);this._model.selection.update(this._core,e,t,n),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new YP(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new DP(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let e=oP(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=_M(PN.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),PN.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){if(!this._isAttached){if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return}for(let n of this._renderLayers)n.handleGridChanged(this._terminal,e,t);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new lP(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let n=this._core,r=this._workCell,i,a,o,s,c,l,u=0,d=!0,f,p,m,h,g,_,v,y,b;e=nI(e,n.rows-1,0),t=nI(t,n.rows-1,0);let x=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??`block`,S=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,C=S-n.buffer.ydisp,w=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),T=-1,E=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let D=!1;for(a=e;a<=t;a++)for(o=a+n.buffer.ydisp,s=n.buffer.lines.get(o),this._model.lineLengths[a]=0,m=S===o,u=0,c=this._characterJoinerService.getJoinedCharacters(o),y=0;y<n.cols;y++){if(i=this._cellColorResolver.result.bg,s.loadCell(y,r),y===0&&(i=this._cellColorResolver.result.bg),l=!1,d=y>=u,f=y,c.length>0&&y===c[0][0]&&d){p=c.shift();let e=this._model.selection.isCellSelected(this._terminal,p[0],o);for(v=p[0]+1;v<p[1];v++)d&&=e===this._model.selection.isCellSelected(this._terminal,v,o);d&&=!m||w<p[0]||w>=p[1],d?(l=!0,r=new tI(r,s.translateToString(!0,p[0],p[1]),p[1]-p[0]),f=p[1]-1):u=p[1]}if(h=r.getChars(),g=r.getCode(),v=(a*n.cols+y)*AP,this._cellColorResolver.resolve(r,y,o,this.dimensions.device.cell.width),E&&o===S&&(y===w&&(this._model.cursor={x:w,y:C,width:r.getWidth(),style:this._coreBrowserService.isFocused?x:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},T=w+r.getWidth()-1),y>=w&&y<=T&&(this._coreBrowserService.isFocused&&x===`block`||this._coreBrowserService.isFocused===!1&&n.options.cursorInactiveStyle===`block`)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),g!==0&&(this._model.lineLengths[a]=y+1),(this._model.cells[v]!==g||this._model.cells[v+jP]!==this._cellColorResolver.result.bg||this._model.cells[v+MP]!==this._cellColorResolver.result.fg||this._model.cells[v+NP]!==this._cellColorResolver.result.ext)&&(D=!0,h.length>1&&(g|=PP),this._model.cells[v]=g,this._model.cells[v+jP]=this._cellColorResolver.result.bg,this._model.cells[v+MP]=this._cellColorResolver.result.fg,this._model.cells[v+NP]=this._cellColorResolver.result.ext,_=r.getWidth(),this._glyphRenderer.value.updateCell(y,a,g,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,h,_,i),l)){for(r=this._workCell,y++;y<=f;y++)b=(a*n.cols+y)*AP,this._glyphRenderer.value.updateCell(y,a,0,0,0,0,AM,0,0),this._model.cells[b]=0,this._model.cells[b+jP]=this._cellColorResolver.result.bg,this._model.cells[b+MP]=this._cellColorResolver.result.fg,this._model.cells[b+NP]=this._cellColorResolver.result.ext;y--}}D&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},tI=class extends kN{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function nI(e,t,n=0){return Math.max(Math.min(e,t),n)}var rI=`di$target`,iI=`di$dependencies`,aI=new Map;function oI(e){if(aI.has(e))return aI.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);sI(t,e,r)};return t._id=e,aI.set(e,t),t}function sI(e,t,n){t[rI]===t?t[iI].push({id:e,index:n}):(t[iI]=[{id:e,index:n}],t[rI]=t)}oI(`BufferService`),oI(`CoreMouseService`),oI(`CoreService`),oI(`CharsetService`),oI(`InstantiationService`),oI(`LogService`);var cI=oI(`OptionsService`);oI(`OscLinkService`),oI(`UnicodeService`),oI(`DecorationService`);var lI={trace:0,debug:1,info:2,warn:3,error:4,off:5},uI=`xterm.js: `,dI=class extends xM{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),fI=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=lI[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:uI)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};dI=eM([tM(0,cI)],dI);var fI,pI=class extends xM{constructor(e){if(OM&&kM()<16&&!document.createElement(`canvas`).getContext(`webgl2`,{antialias:!1,depth:!1,preserveDrawingBuffer:!0}))throw Error(`Webgl2 is only supported on Safari 16 and above`);super(),this._preserveDrawingBuffer=e,this._onChangeTextureAtlas=this._register(new KN),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new KN),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new KN),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new KN),this.onContextLoss=this._onContextLoss.event}activate(e){let t=e._core;if(!e.element){this._register(t.onWillOpen(()=>this.activate(e)));return}this._terminal=e;let n=t.coreService,r=t.optionsService,i=t,a=i._renderService,o=i._characterJoinerService,s=i._charSizeService,c=i._coreBrowserService,l=i._decorationService;i._logService;let u=i._themeService;this._renderer=this._register(new eI(e,o,s,c,n,l,r,u,this._preserveDrawingBuffer)),this._register(PN.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(PN.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(PN.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(PN.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(vM(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}},mI=Object.defineProperty,hI=Object.getOwnPropertyDescriptor,gI=(e,t)=>{for(var n in t)mI(e,n,{get:t[n],enumerable:!0})},_I=(e,t,n,r)=>{for(var i=r>1?void 0:r?hI(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&mI(t,n,i),i},Z=(e,t)=>(n,r)=>t(n,r,e),vI=`Terminal input`,yI={get:()=>vI,set:e=>vI=e},bI=`Too much output to announce, navigate to rows manually to read`,xI={get:()=>bI,set:e=>bI=e};function SI(e){return e.replace(/\r?\n/g,`\r`)}function CI(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function wI(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function TI(e,t,n,r){e.stopPropagation(),e.clipboardData&&EI(e.clipboardData.getData(`text/plain`),t,n,r)}function EI(e,t,n,r){e=SI(e),e=CI(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function DI(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function OI(e,t,n,r,i){DI(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function kI(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function AI(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var jI=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},MI=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},NI=``,PI=` `,FI=class e{constructor(){this.fg=0,this.bg=0,this.extended=new II}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;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)}isBgDefault(){return!(this.bg&50331648)}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):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},II=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},LI=class e extends FI{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new II,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?kI(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},RI=`di$target`,zI=`di$dependencies`,BI=new Map;function VI(e){return e[zI]||[]}function HI(e){if(BI.has(e))return BI.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);UI(t,e,r)};return t._id=e,BI.set(e,t),t}function UI(e,t,n){t[RI]===t?t[zI].push({id:e,index:n}):(t[zI]=[{id:e,index:n}],t[RI]=t)}var WI=HI(`BufferService`),GI=HI(`CoreMouseService`),KI=HI(`CoreService`),qI=HI(`CharsetService`),JI=HI(`InstantiationService`),YI=HI(`LogService`),XI=HI(`OptionsService`),ZI=HI(`OscLinkService`),QI=HI(`UnicodeService`),$I=HI(`DecorationService`),eL=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new LI,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):tL(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};eL=_I([Z(0,WI),Z(1,XI),Z(2,ZI)],eL);function tL(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
126
126
|
|
|
127
|
-
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var
|
|
127
|
+
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var nL=HI(`CharSizeService`),rL=HI(`CoreBrowserService`),iL=HI(`MouseService`),aL=HI(`RenderService`),oL=HI(`SelectionService`),sL=HI(`CharacterJoinerService`),cL=HI(`ThemeService`),lL=HI(`LinkProviderService`),uL=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?gL.isErrorNoTelemetry(e)?new gL(e.message+`
|
|
128
128
|
|
|
129
129
|
`+e.stack):Error(e.message+`
|
|
130
130
|
|
|
131
|
-
`+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)}};function lL(e){dL(e)||cL.onUnexpectedError(e)}var uL=`Canceled`;function dL(e){return e instanceof fL||e instanceof Error&&e.name===uL&&e.message===uL}var fL=class extends Error{constructor(){super(uL),this.name=this.message}};function pL(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var mL=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},hL=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function gL(e,t=0){return e[e.length-(1+t)]}var _L;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(_L||={});var vL=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||_L.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};vL.empty=new vL(e=>{});function yL(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var bL;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(bL||={});var xL=null;function SL(e){return xL?.trackDisposable(e),e}function CL(e){xL?.markAsDisposed(e)}function wL(e,t){xL?.setParent(e,t)}function TL(e){return xL?.markAsSingleton(e),e}function EL(e){if(bL.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function DL(...e){return OL(()=>EL(e))}function OL(e){let t=SL({dispose:yL(()=>{CL(t),e()})});return t}var kL=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,SL(this)}dispose(){this._isDisposed||(CL(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{EL(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return wL(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(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(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),wL(e,null))}};kL.DISABLE_DISPOSED_WARNING=!1;var AL=kL,jL=class{constructor(){this._store=new AL,SL(this),wL(this._store,this)}dispose(){CL(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};jL.None=Object.freeze({dispose(){}});var ML=class{constructor(){this._isDisposed=!1,SL(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&wL(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,CL(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&wL(e,null),e}},NL=typeof window==`object`?window:globalThis,PL=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};PL.Undefined=new PL(void 0);var FL=PL,IL=class{constructor(){this._first=FL.Undefined,this._last=FL.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===FL.Undefined}clear(){let e=this._first;for(;e!==FL.Undefined;){let t=e.next;e.prev=FL.Undefined,e.next=FL.Undefined,e=t}this._first=FL.Undefined,this._last=FL.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new FL(e);if(this._first===FL.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==FL.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==FL.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==FL.Undefined&&e.next!==FL.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===FL.Undefined&&e.next===FL.Undefined?(this._first=FL.Undefined,this._last=FL.Undefined):e.next===FL.Undefined?(this._last=this._last.prev,this._last.next=FL.Undefined):e.prev===FL.Undefined&&(this._first=this._first.next,this._first.prev=FL.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==FL.Undefined;)yield e.element,e=e.next}},LL=globalThis.performance&&typeof globalThis.performance.now==`function`,RL=class e{static create(t){return new e(t)}constructor(e){this._now=LL&&e===!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._now()-this._startTime:this._stopTime-this._startTime}},zL;(e=>{e.None=()=>jL.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(DL(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new Q({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new Q({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Q({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new Q;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Q(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof AL?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(zL||={});var BL=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new RL,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};BL.all=new Set,BL._idPool=0;var VL=BL,HL=-1,UL=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new KL(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};UL._idPool=1;var WL=UL,GL=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
131
|
+
`+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)}};function dL(e){pL(e)||uL.onUnexpectedError(e)}var fL=`Canceled`;function pL(e){return e instanceof mL||e instanceof Error&&e.name===fL&&e.message===fL}var mL=class extends Error{constructor(){super(fL),this.name=this.message}};function hL(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var gL=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},_L=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function vL(e,t=0){return e[e.length-(1+t)]}var yL;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(yL||={});var bL=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||yL.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};bL.empty=new bL(e=>{});function xL(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var SL;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(SL||={});var CL=null;function wL(e){return CL?.trackDisposable(e),e}function TL(e){CL?.markAsDisposed(e)}function EL(e,t){CL?.setParent(e,t)}function DL(e){return CL?.markAsSingleton(e),e}function OL(e){if(SL.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function kL(...e){return AL(()=>OL(e))}function AL(e){let t=wL({dispose:xL(()=>{TL(t),e()})});return t}var jL=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,wL(this)}dispose(){this._isDisposed||(TL(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{OL(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return EL(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(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(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),EL(e,null))}};jL.DISABLE_DISPOSED_WARNING=!1;var ML=jL,NL=class{constructor(){this._store=new ML,wL(this),EL(this._store,this)}dispose(){TL(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};NL.None=Object.freeze({dispose(){}});var PL=class{constructor(){this._isDisposed=!1,wL(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&EL(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,TL(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&EL(e,null),e}},FL=typeof window==`object`?window:globalThis,IL=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};IL.Undefined=new IL(void 0);var LL=IL,RL=class{constructor(){this._first=LL.Undefined,this._last=LL.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===LL.Undefined}clear(){let e=this._first;for(;e!==LL.Undefined;){let t=e.next;e.prev=LL.Undefined,e.next=LL.Undefined,e=t}this._first=LL.Undefined,this._last=LL.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new LL(e);if(this._first===LL.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==LL.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==LL.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==LL.Undefined&&e.next!==LL.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===LL.Undefined&&e.next===LL.Undefined?(this._first=LL.Undefined,this._last=LL.Undefined):e.next===LL.Undefined?(this._last=this._last.prev,this._last.next=LL.Undefined):e.prev===LL.Undefined&&(this._first=this._first.next,this._first.prev=LL.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==LL.Undefined;)yield e.element,e=e.next}},zL=globalThis.performance&&typeof globalThis.performance.now==`function`,BL=class e{static create(t){return new e(t)}constructor(e){this._now=zL&&e===!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._now()-this._startTime:this._stopTime-this._startTime}},VL;(e=>{e.None=()=>NL.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(kL(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new Q({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new Q({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Q({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new Q;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Q(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof ML?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(VL||={});var HL=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new BL,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};HL.all=new Set,HL._idPool=0;var UL=HL,WL=-1,GL=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new JL(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};GL._idPool=1;var KL=GL,qL=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
132
132
|
`).slice(2).join(`
|
|
133
|
-
`))}},KL=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},qL=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},JL=0,YL=class{constructor(e){this.value=e,this.id=JL++}},XL=2,Q=class{constructor(e){this._size=0,this._options=e,this._leakageMon=HL>0||this._options?.leakWarningThreshold?new WL(e?.onListenerError??lL,this._options?.leakWarningThreshold??HL):void 0,this._perfMon=this._options?._profName?new VL(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new qL(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||lL)(n),jL.None}if(this._disposed)return jL.None;t&&(e=e.bind(t));let r=new YL(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=GL.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof YL?(this._deliveryQueue??=new ZL,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=OL(()=>{i?.(),this._removeListener(r)});return n instanceof AL?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*XL<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||lL;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_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 YL)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}},ZL=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},QL=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Q,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};QL.INSTANCE=new QL;var $L=QL;function eR(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}$L.INSTANCE.onDidChangeZoomLevel;function tR(e){return $L.INSTANCE.getZoomFactor(e)}$L.INSTANCE.onDidChangeFullscreen;var nR=typeof navigator==`object`?navigator.userAgent:``,rR=nR.indexOf(`Firefox`)>=0,iR=nR.indexOf(`AppleWebKit`)>=0,aR=nR.indexOf(`Chrome`)>=0,oR=!aR&&nR.indexOf(`Safari`)>=0;nR.indexOf(`Electron/`),nR.indexOf(`Android`);var sR=!1;if(typeof NL.matchMedia==`function`){let e=NL.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=NL.matchMedia(`(display-mode: fullscreen)`);sR=e.matches,eR(NL,e,({matches:e})=>{sR&&t.matches||(sR=e)})}function cR(){return sR}var lR=`en`,uR=!1,dR=!1,fR=!1,pR=!1,mR=!1,hR=lR,gR,_R=globalThis,vR;typeof _R.vscode<`u`&&typeof _R.vscode.process<`u`?vR=_R.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(vR=process);var yR=typeof vR?.versions?.electron==`string`&&vR?.type===`renderer`;if(typeof vR==`object`){uR=vR.platform===`win32`,dR=vR.platform===`darwin`,fR=vR.platform===`linux`,fR&&vR.env.SNAP&&vR.env.SNAP_REVISION,vR.env.CI||vR.env.BUILD_ARTIFACTSTAGINGDIRECTORY,hR=lR;let e=vR.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,hR=t.resolvedLanguage||lR,t.languagePack?.translationsConfigFile}catch{}pR=!0}else typeof navigator==`object`&&!yR?(gR=navigator.userAgent,uR=gR.indexOf(`Windows`)>=0,dR=gR.indexOf(`Macintosh`)>=0,(gR.indexOf(`Macintosh`)>=0||gR.indexOf(`iPad`)>=0||gR.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,fR=gR.indexOf(`Linux`)>=0,gR?.indexOf(`Mobi`),mR=!0,hR=globalThis._VSCODE_NLS_LANGUAGE||lR,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var bR=uR,xR=dR,SR=fR,CR=pR;mR&&typeof _R.importScripts==`function`&&_R.origin;var wR=gR,TR=hR,ER;(e=>{function t(){return TR}e.value=t;function n(){return TR.length===2?TR===`en`:TR.length>=3&&TR[0]===`e`&&TR[1]===`n`&&TR[2]===`-`}e.isDefaultVariant=n;function r(){return TR===`en`}e.isDefault=r})(ER||={});var DR=typeof _R.postMessage==`function`&&!_R.importScripts;(()=>{if(DR){let e=[];_R.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),_R.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var OR=!!(wR&&wR.indexOf(`Chrome`)>=0);wR&&wR.indexOf(`Firefox`),!OR&&wR&&wR.indexOf(`Safari`),wR&&wR.indexOf(`Edg/`),wR&&wR.indexOf(`Android`);var kR=typeof navigator==`object`?navigator:{};CR||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||kR&&kR.clipboard&&kR.clipboard.writeText,CR||kR&&kR.clipboard&&kR.clipboard.readText,CR||cR()||kR.keyboard,`ontouchstart`in NL||kR.maxTouchPoints,NL.PointerEvent&&(`ontouchstart`in NL||navigator.maxTouchPoints);var AR=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}},jR=new AR,MR=new AR,NR=new AR,PR=Array(230),FR;(e=>{function t(e){return jR.keyCodeToStr(e)}e.toString=t;function n(e){return jR.strToKeyCode(e)}e.fromString=n;function r(e){return MR.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return NR.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return MR.strToKeyCode(e)||NR.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return jR.keyCodeToStr(e)}e.toElectronAccelerator=o})(FR||={});var IR=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new LR([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},LR=class{constructor(e){if(e.length===0)throw pL(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function RR(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return FR.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(rR)switch(t){case 59:return 85;case 60:if(SR)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(xR)return 57}else if(iR&&(xR&&t===93||!xR&&t===92))return 57;return PR[t]||0}var zR=xR?256:2048,BR=512,VR=1024,HR=xR?2048:256,UR=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=RR(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|=zR),this.altKey&&(t|=BR),this.shiftKey&&(t|=VR),this.metaKey&&(t|=HR),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new IR(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},WR=new WeakMap;function GR(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var KR=class{static getSameOriginWindowChain(e){let t=WR.get(e);if(!t){t=[],WR.set(e,t);let n=e,r;do r=GR(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},qR=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=KR.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},JR=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(aR){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)this.deltaY=r?t.wheelDeltaY/(120*i):t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;this.deltaY=t.deltaMode===t.DOM_DELTA_LINE?rR&&!xR?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=oR&&bR?-(t.wheelDeltaX/120):r?t.wheelDeltaX/(120*i):t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;this.deltaX=t.deltaMode===t.DOM_DELTA_LINE?rR&&!xR?-e.deltaX/3:-e.deltaX:-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(this.deltaY=r?e.wheelDelta/(120*i):e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},YR=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),XR;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof ZR?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:zL.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:YR})})(XR||={});var ZR=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?YR:(this._emitter||=new Q,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},QR=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 hL(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new hL(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},$R=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new hL(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=OL(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var ez;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(ez||={});var tz=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Q,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await zL.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};tz.EMPTY=tz.fromArray([]);function nz(e){return rz(e,0)}function rz(e,t){switch(typeof e){case`object`:return e===null?iz(349,t):Array.isArray(e)?sz(e,t):cz(e,t);case`string`:return oz(e,t);case`boolean`:return az(e,t);case`number`:return iz(e,t);case`undefined`:return iz(937,t);default:return iz(617,t)}}function iz(e,t){return(t<<5)-t+e|0}function az(e,t){return iz(e?433:863,t)}function oz(e,t){t=iz(149417,t);for(let n=0,r=e.length;n<r;n++)t=iz(e.charCodeAt(n),t);return t}function sz(e,t){return t=iz(104579,t),e.reduce((e,t)=>rz(t,e),t)}function cz(e,t){return t=iz(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=oz(n,t),rz(e[n],t)),t)}var{registerWindow:lz,getWindow:uz,getDocument:dz,getWindows:fz,getWindowsCount:pz,getWindowId:mz,getWindowById:hz,hasWindow:gz,onDidRegisterWindow:_z,onWillUnregisterWindow:vz,onDidUnregisterWindow:yz}=function(){let e=new Map,t={window:NL,disposables:new AL};e.set(NL.vscodeWindowId,t);let n=new Q,r=new Q,i=new Q;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return jL.None;let a=new AL,o={window:t,disposables:a.add(new AL)};return e.set(t.vscodeWindowId,o),a.add(OL(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(xz(t,Az.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:NL},getDocument(e){return uz(e).document}}}(),bz=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!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,null)}};function xz(e,t,n,r){return new bz(e,t,n,r)}function Sz(e,t){return function(n){return t(new qR(e,n))}}function Cz(e){return function(t){return e(new UR(t))}}var wz=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=Sz(uz(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=Cz(n)),xz(e,t,i,r)},Tz,Ez=class extends $R{constructor(e){super(),this.defaultTarget=e&&uz(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Dz=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){lL(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(Dz.sort),a.shift().execute();r.set(i,!1)};Tz=(t,r,a=0)=>{let o=mz(t),s=new Dz(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var Oz=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};Oz.None=new Oz(0,0);function kz(e){let t=e.getBoundingClientRect(),n=uz(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=nz(n),a=r.get(i);if(a)a.users+=1;else{let o=new Q,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(OL(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var Az={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:iR?`webkitAnimationStart`:`animationstart`,ANIMATION_END:iR?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:iR?`webkitAnimationIteration`:`animationiteration`},jz=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=Mz(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Mz(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Mz(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Mz(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Mz(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Mz(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Mz(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Mz(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Mz(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Mz(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Mz(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=Mz(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=Mz(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Mz(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 Mz(e){return typeof e==`number`?`${e}px`:e}function Nz(e){return new jz(e)}var Pz=class{constructor(){this._hooks=new AL,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(OL(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=uz(e)}this._hooks.add(xz(a,Az.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(xz(a,Az.POINTER_UP,e=>this.stopMonitoring(!0)))}};function Fz(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var Iz;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(Iz||={});var Lz=class e extends jL{constructor(){super(),this.dispatched=!1,this.targets=new IL,this.ignoreTargets=new IL,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(zL.runAndSubscribe(_z,({window:e,disposables:t})=>{t.add(xz(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(xz(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(xz(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:NL,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=TL(new e),OL(e.INSTANCE.targets.push(t))):jL.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=TL(new e),OL(e.INSTANCE.ignoreTargets.push(t))):jL.None}static isTouchDevice(){return`ontouchstart`in NL||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(Iz.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-gL(s.rollingPageX))<30&&Math.abs(s.initialPageY-gL(s.rollingPageY))<30){let e=this.newGestureEvent(Iz.Tap,s.initialTarget);e.pageX=gL(s.rollingPageX),e.pageY=gL(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-gL(s.rollingPageX))<30&&Math.abs(s.initialPageY-gL(s.rollingPageY))<30){let e=this.newGestureEvent(Iz.Contextmenu,s.initialTarget);e.pageX=gL(s.rollingPageX),e.pageY=gL(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=gL(s.rollingPageX),n=gL(s.rollingPageY),i=gL(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(Iz.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===Iz.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Iz.Change||t.type===Iz.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=Tz(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(Iz.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(Iz.Change,i.initialTarget);a.translationX=r.pageX-gL(i.rollingPageX),a.translationY=r.pageY-gL(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};Lz.SCROLL_FRICTION=-.005,Lz.HOLD_DELAY=700,Lz.CLEAR_TAP_COUNT_TIME=400,hI([Fz],Lz,`isTouchDevice`,1);var Rz=Lz,zz=class extends jL{onclick(e,t){this._register(xz(e,Az.CLICK,n=>t(new qR(uz(e),n))))}onmousedown(e,t){this._register(xz(e,Az.MOUSE_DOWN,n=>t(new qR(uz(e),n))))}onmouseover(e,t){this._register(xz(e,Az.MOUSE_OVER,n=>t(new qR(uz(e),n))))}onmouseleave(e,t){this._register(xz(e,Az.MOUSE_LEAVE,n=>t(new qR(uz(e),n))))}onkeydown(e,t){this._register(xz(e,Az.KEY_DOWN,e=>t(new UR(e))))}onkeyup(e,t){this._register(xz(e,Az.KEY_UP,e=>t(new UR(e))))}oninput(e,t){this._register(xz(e,Az.INPUT,t))}onblur(e,t){this._register(xz(e,Az.BLUR,t))}onfocus(e,t){this._register(xz(e,Az.FOCUS,t))}onchange(e,t){this._register(xz(e,Az.CHANGE,t))}ignoreGesture(e){return Rz.ignoreTarget(e)}},Bz=11,Vz=class extends zz{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=Bz+`px`,this.domNode.style.height=Bz+`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 Pz),this._register(wz(this.bgDomNode,Az.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(wz(this.domNode,Az.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new Ez),this._pointerdownScheduleRepeatTimer=this._register(new QR)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,uz(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},Hz=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(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(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},Uz=class extends jL{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Hz(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new qz(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=qz.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},Wz=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Gz(e,t){let n=t-e;return function(t){return e+n*Yz(t)}}function Kz(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var qz=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,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(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),Kz(Gz(e,r),Gz(i,t),.33)}return Gz(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new Wz(this.scrollLeft(t),this.scrollTop(t),!1):new Wz(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function Jz(e){return e**3}function Yz(e){return 1-Jz(1-e)}var Xz=class extends jL{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new QR)}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||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`:``)))}},Zz=140,Qz=class extends zz{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 Xz(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Pz),this._shouldRender=!0,this.domNode=Nz(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(xz(this.domNode.domNode,Az.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new Vz(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Nz(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(xz(this.slider.domNode,Az.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=kz(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(bR&&a>Zz){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{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()}},$z=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._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(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},eB=class extends Qz{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new $z(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw 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}},tB=class extends Qz{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new $z(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw 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}},nB=500,rB=50,iB=!0,aB=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},oB=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(aR){let t=tR(uz(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new aB(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=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]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};oB.INSTANCE=new oB;var sB=oB,cB=class extends zz{constructor(e,t,n){super(),this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Q),this.onWillScroll=this._onWillScroll.event,this._options=uB(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new tB(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new eB(this._scrollable,this._options,r)),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=Nz(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Nz(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Nz(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,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new QR),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=EL(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,xR&&(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 JR(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=EL(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(xz(this._listenOnDomNode,Az.MOUSE_WHEEL,e=>{this._onMouseWheel(new JR(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=sB.INSTANCE;iB&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!xR&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=rB*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=rB*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(iB&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(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 Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_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(),nB)}},lB=class extends cB{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function uB(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,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,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,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,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,xR&&(t.className+=` mac`),t}var dB=class extends jL{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new Uz({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>Tz(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new lB(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(zL.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(OL(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(OL(()=>this._styleElement.remove())),this._register(zL.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
|
|
134
|
-
`)})),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(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};dB=hI([Z(2,HI),Z(3,tL),Z(4,UI),Z(5,oL),Z(6,JI),Z(7,rL)],dB);var fB=class extends jL{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,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(e=>this._removeDecoration(e))),this._register(OL(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};fB=hI([Z(1,HI),Z(2,tL),Z(3,ZI),Z(4,rL)],fB);var pB=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},mB={full:0,left:0,center:0,right:0},hB={full:0,left:0,center:0,right:0},gB={full:0,left:0,center:0,right:0},_B=class extends jL{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new pB,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(OL(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw 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);hB.full=this._canvas.width,hB.left=e,hB.center=t,hB.right=e,this._refreshDrawHeightConstants(),gB.full=1,gB.left=1,gB.center=1+hB.left,gB.right=1+hB.left+hB.center}_refreshDrawHeightConstants(){mB.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);mB.left=t,mB.center=t,mB.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*mB.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*mB.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*mB.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*mB.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 e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);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(gB[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-mB[e.position||`full`]/2),hB[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+mB[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}))}};_B=hI([Z(2,HI),Z(3,ZI),Z(4,rL),Z(5,JI),Z(6,oL),Z(7,tL)],_B);var $;(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=`
|
|
135
|
-
`,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=``))($||={});var vB;(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=``))(vB||={});var yB;(e=>e.ST=`${$.ESC}\\`)(yB||={});var bB=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,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)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.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 e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};bB=hI([Z(2,HI),Z(3,JI),Z(4,WI),Z(5,rL)],bB);var xB=0,SB=0,CB=0,wB=0,TB={css:`#00000000`,rgba:0},EB;(e=>{function t(e,t,n,r){return r===void 0?`#${jB(e)}${jB(t)}${jB(n)}`:`#${jB(e)}${jB(t)}${jB(n)}${jB(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(EB||={});var DB;(e=>{function t(e,t){if(wB=(t.rgba&255)/255,wB===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return xB=a+Math.round((n-a)*wB),SB=o+Math.round((r-o)*wB),CB=s+Math.round((i-s)*wB),{css:EB.toCss(xB,SB,CB),rgba:EB.toRgba(xB,SB,CB)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=AB.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return EB.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[xB,SB,CB]=AB.toChannels(t),{css:EB.toCss(xB,SB,CB),rgba:t}}e.opaque=i;function a(e,t){return wB=Math.round(t*255),[xB,SB,CB]=AB.toChannels(e.rgba),{css:EB.toCss(xB,SB,CB,wB),rgba:EB.toRgba(xB,SB,CB,wB)}}e.opacity=a;function o(e,t){return wB=e.rgba&255,a(e,wB*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(DB||={});var OB;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return xB=parseInt(e.slice(1,2).repeat(2),16),SB=parseInt(e.slice(2,3).repeat(2),16),CB=parseInt(e.slice(3,4).repeat(2),16),EB.toColor(xB,SB,CB);case 5:return xB=parseInt(e.slice(1,2).repeat(2),16),SB=parseInt(e.slice(2,3).repeat(2),16),CB=parseInt(e.slice(3,4).repeat(2),16),wB=parseInt(e.slice(4,5).repeat(2),16),EB.toColor(xB,SB,CB,wB);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return xB=parseInt(r[1]),SB=parseInt(r[2]),CB=parseInt(r[3]),wB=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),EB.toColor(xB,SB,CB,wB);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[xB,SB,CB,wB]=t.getImageData(0,0,1,1).data,wB!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:EB.toRgba(xB,SB,CB,wB),css:e}}e.toColor=r})(OB||={});var kB;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(kB||={});var AB;(e=>{function t(e,t){if(wB=(t&255)/255,wB===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return xB=a+Math.round((n-a)*wB),SB=o+Math.round((r-o)*wB),CB=s+Math.round((i-s)*wB),EB.toRgba(xB,SB,CB)}e.blend=t;function n(e,t,n){let a=kB.relativeLuminance(e>>8),o=kB.relativeLuminance(t>>8);if(MB(a,o)<n){if(o<a){let o=r(e,t,n),s=MB(a,kB.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>MB(a,kB.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=MB(a,kB.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>MB(a,kB.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=MB(kB.relativeLuminance2(o,s,c),kB.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=MB(kB.relativeLuminance2(o,s,c),kB.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=MB(kB.relativeLuminance2(o,s,c),kB.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=MB(kB.relativeLuminance2(o,s,c),kB.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(AB||={});function jB(e){let t=e.toString(16);return t.length<2?`0`+t:t}function MB(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var NB=class extends NI{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},PB=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new FI}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||MI.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)PB._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||MI.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};PB=hI([Z(0,HI)],PB);function FB(e){return 57508<=e&&e<=57558}function IB(e){return 9472<=e&&e<=9631}function LB(e){return FB(e)||IB(e)}function RB(){return{css:{canvas:zB(),cell:zB()},device:{canvas:zB(),cell:zB(),char:{width:0,height:0,left:0,top:0}}}}function zB(){return{width:0,height:0}}var BB=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new FI,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new NB(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let P=this._isCellInSelection(k,t),F=n&&k===a,I=O&&k>=l&&k<=u,L=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{L=!0});let ee=N.getChars()||MI;if(ee===` `&&(N.isUnderline()||N.isOverline())&&(ee=`\xA0`),T=m*s-c.get(ee,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(P&&w||!P&&!w&&N.bg===y)&&(P&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&I===S&&T===C&&!F&&!A&&!L&&j){N.isInvisible()?_+=MI:_+=ee,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=I,C=T,w=P,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&F&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`)}}if(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?MI:N.getChars()||MI,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault())){if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${NI.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),I&&(h.style.textDecoration=`underline`);let te=N.getFgColor(),ne=N.getFgColorMode(),re=N.getBgColor(),R=N.getBgColorMode(),ie=!!N.isInverse();if(ie){let e=te;te=re,re=e;let t=ne;ne=R,R=t}let ae,oe,se=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&se||(e.backgroundColorRGB&&(R=50331648,re=e.backgroundColorRGB.rgba>>8&16777215,ae=e.backgroundColorRGB),e.foregroundColorRGB&&(ne=50331648,te=e.foregroundColorRGB.rgba>>8&16777215,oe=e.foregroundColorRGB),se=e.options.layer===`top`)}),!se&&P&&(ae=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,re=ae.rgba>>8&16777215,R=50331648,se=!0,p.selectionForeground&&(ne=50331648,te=p.selectionForeground.rgba>>8&16777215,oe=p.selectionForeground)),se&&D.push(`xterm-decoration-top`);let ce;switch(R){case 16777216:case 33554432:ce=p.ansi[re],D.push(`xterm-bg-${re}`);break;case 50331648:ce=EB.toColor(re>>16,re>>8&255,re&255),this._addStyle(h,`background-color:#${VB((re>>>0).toString(16),`0`,6)}`);break;default:ie?(ce=p.foreground,D.push(`xterm-bg-257`)):ce=p.background}switch(ae||N.isDim()&&(ae=DB.multiplyOpacity(ce,.5)),ne){case 16777216:case 33554432:N.isBold()&&te<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(te+=8),this._applyMinimumContrast(h,ce,p.ansi[te],N,ae,void 0)||D.push(`xterm-fg-${te}`);break;case 50331648:let e=EB.toColor(te>>16&255,te>>8&255,te&255);this._applyMinimumContrast(h,ce,e,N,ae,oe)||this._addStyle(h,`color:#${VB(te.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,ce,p.foreground,N,ae,oe)||ie&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!F&&!A&&!L&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||LB(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=DB.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};BB=hI([Z(1,aL),Z(2,JI),Z(3,tL),Z(4,WI),Z(5,ZI),Z(6,oL)],BB);function VB(e,t,n){for(;e.length<n;)e=t+e;return e}var HB=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},UB=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function WB(){return new UB}var GB=`xterm-dom-renderer-owner-`,KB=`xterm-rows`,qB=`xterm-fg-`,JB=`xterm-bg-`,YB=`xterm-focus`,XB=`xterm-selection`,ZB=1,QB=class extends jL{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=ZB++,this._rowElements=[],this._selectionRenderModel=WB(),this.onRequestRedraw=this._register(new Q).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(KB),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(XB),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=RB(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(BB,document),this._element.classList.add(GB+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(OL(()=>{this._element.classList.remove(GB+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new HB(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 e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${KB} 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} .${KB} { 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} .${KB} .xterm-dim { color: ${DB.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${KB}.${YB} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${KB}.${YB} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${KB}.${YB} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${KB} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${KB} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${KB} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${KB} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${KB} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${XB} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${XB} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${XB} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${qB}${n} { color: ${r.css}; }${this._terminalSelector} .${qB}${n}.xterm-dim { color: ${DB.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${JB}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${qB}257 { color: ${DB.opaque(e.background).css}; }${this._terminalSelector} .${qB}257.xterm-dim { color: ${DB.multiplyOpacity(DB.opaque(e.background),.5).css}; }${this._terminalSelector} .${JB}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 e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}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(YB),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(YB),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${GB}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};QB=hI([Z(7,KI),Z(8,eL),Z(9,JI),Z(10,HI),Z(11,WI),Z(12,tL),Z(13,oL)],QB);var $B=class extends jL{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new nV(this._optionsService))}catch{this._measureStrategy=this._register(new tV(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())}};$B=hI([Z(2,JI)],$B);var eV=class extends jL{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)}},tV=class extends eV{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},nV=class extends eV{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 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}},rV=class extends jL{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new iV(this._window)),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(zL.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(xz(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(xz(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}},iV=class extends jL{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ML),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(OL(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=xz(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)}},aV=class extends jL{constructor(){super(),this.linkProviders=[],this._register(OL(()=>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 oV(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function sV(e,t,n,r,i,a,o,s,c){if(!a)return;let l=oV(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var cV=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return sV(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=oV(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};cV=hI([Z(0,rL),Z(1,eL)],cV);var lV=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,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=[]}},uV={};mI(uV,{getSafariVersion:()=>_V,isChromeOS:()=>CV,isFirefox:()=>mV,isIpad:()=>yV,isIphone:()=>bV,isLegacyEdge:()=>hV,isLinux:()=>SV,isMac:()=>vV,isNode:()=>dV,isSafari:()=>gV,isWindows:()=>xV});var dV=typeof process<`u`&&`title`in process,fV=dV?`node`:navigator.userAgent,pV=dV?`node`:navigator.platform,mV=fV.includes(`Firefox`),hV=fV.includes(`Edge`),gV=/^((?!chrome|android).)*safari/i.test(fV);function _V(){if(!gV)return 0;let e=fV.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var vV=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(pV),yV=pV===`iPad`,bV=pV===`iPhone`,xV=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(pV),SV=pV.indexOf(`Linux`)>=0,CV=/\bCrOS\b/.test(fV),wV=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),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},TV=class extends wV{_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())}}},EV=class extends wV{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},DV=!dV&&`requestIdleCallback`in window?EV:TV,OV=class{constructor(){this._queue=new DV}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},kV=class extends jL{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new ML),this._pausedResizeTask=new OV,this._observerDisposable=this._register(new ML),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 Q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new lV((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new AV(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(OL(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=OL(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!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(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};kV=hI([Z(2,JI),Z(3,eL),Z(4,WI),Z(5,ZI),Z(6,HI),Z(7,tL),Z(8,oL)],kV);var AV=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function jV(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return PV(i,a,e,t,n,r)+FV(a,t,n,r)+IV(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,UV(Math.abs(i-e),HV(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return UV(NV(a>t?e:i,n)+(s-1)*n.cols+1+MV(a>t?i:e,n),HV(o,r))}function MV(e,t){return e-1}function NV(e,t){return t.cols-e}function PV(e,t,n,r,i,a){return FV(t,r,i,a).length===0?``:UV(VV(e,t,e,t-RV(t,i),!1,i).length,HV(`D`,a))}function FV(e,t,n,r){let i=e-RV(e,n),a=t-RV(t,n);return UV(Math.abs(i-a)-LV(e,t,n),HV(BV(e,t),r))}function IV(e,t,n,r,i,a){let o;o=FV(t,r,i,a).length>0?r-RV(r,i):t;let s=r,c=zV(e,t,n,r,i,a);return UV(VV(e,o,n,s,c===`C`,i).length,HV(c,a))}function LV(e,t,n){let r=0,i=e-RV(e,n),a=t-RV(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=BV(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function RV(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function zV(e,t,n,r,i,a){let o;return o=FV(n,r,i,a).length>0?r-RV(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function BV(e,t){return e>t?`A`:`B`}function VV(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function HV(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function UV(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var WV=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 GV(e,t){if(e.start.y>e.end.y)throw 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 KV=50,qV=15,JV=50,YV=500,XV=RegExp(`\xA0`,`g`),ZV=class extends jL{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new FI,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new WV(this._bufferService),this._activeSelectionMode=0,this._register(OL(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(XV,` `)).join(xV?`\r
|
|
133
|
+
`))}},JL=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},YL=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},XL=0,ZL=class{constructor(e){this.value=e,this.id=XL++}},QL=2,Q=class{constructor(e){this._size=0,this._options=e,this._leakageMon=WL>0||this._options?.leakWarningThreshold?new KL(e?.onListenerError??dL,this._options?.leakWarningThreshold??WL):void 0,this._perfMon=this._options?._profName?new UL(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new YL(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||dL)(n),NL.None}if(this._disposed)return NL.None;t&&(e=e.bind(t));let r=new ZL(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=qL.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof ZL?(this._deliveryQueue??=new $L,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=AL(()=>{i?.(),this._removeListener(r)});return n instanceof ML?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*QL<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||dL;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_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 ZL)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}},$L=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},eR=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Q,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};eR.INSTANCE=new eR;var tR=eR;function nR(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}tR.INSTANCE.onDidChangeZoomLevel;function rR(e){return tR.INSTANCE.getZoomFactor(e)}tR.INSTANCE.onDidChangeFullscreen;var iR=typeof navigator==`object`?navigator.userAgent:``,aR=iR.indexOf(`Firefox`)>=0,oR=iR.indexOf(`AppleWebKit`)>=0,sR=iR.indexOf(`Chrome`)>=0,cR=!sR&&iR.indexOf(`Safari`)>=0;iR.indexOf(`Electron/`),iR.indexOf(`Android`);var lR=!1;if(typeof FL.matchMedia==`function`){let e=FL.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=FL.matchMedia(`(display-mode: fullscreen)`);lR=e.matches,nR(FL,e,({matches:e})=>{lR&&t.matches||(lR=e)})}function uR(){return lR}var dR=`en`,fR=!1,pR=!1,mR=!1,hR=!1,gR=!1,_R=dR,vR,yR=globalThis,bR;typeof yR.vscode<`u`&&typeof yR.vscode.process<`u`?bR=yR.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(bR=process);var xR=typeof bR?.versions?.electron==`string`&&bR?.type===`renderer`;if(typeof bR==`object`){fR=bR.platform===`win32`,pR=bR.platform===`darwin`,mR=bR.platform===`linux`,mR&&bR.env.SNAP&&bR.env.SNAP_REVISION,bR.env.CI||bR.env.BUILD_ARTIFACTSTAGINGDIRECTORY,_R=dR;let e=bR.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,_R=t.resolvedLanguage||dR,t.languagePack?.translationsConfigFile}catch{}hR=!0}else typeof navigator==`object`&&!xR?(vR=navigator.userAgent,fR=vR.indexOf(`Windows`)>=0,pR=vR.indexOf(`Macintosh`)>=0,(vR.indexOf(`Macintosh`)>=0||vR.indexOf(`iPad`)>=0||vR.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,mR=vR.indexOf(`Linux`)>=0,vR?.indexOf(`Mobi`),gR=!0,_R=globalThis._VSCODE_NLS_LANGUAGE||dR,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var SR=fR,CR=pR,wR=mR,TR=hR;gR&&typeof yR.importScripts==`function`&&yR.origin;var ER=vR,DR=_R,OR;(e=>{function t(){return DR}e.value=t;function n(){return DR.length===2?DR===`en`:DR.length>=3&&DR[0]===`e`&&DR[1]===`n`&&DR[2]===`-`}e.isDefaultVariant=n;function r(){return DR===`en`}e.isDefault=r})(OR||={});var kR=typeof yR.postMessage==`function`&&!yR.importScripts;(()=>{if(kR){let e=[];yR.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),yR.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var AR=!!(ER&&ER.indexOf(`Chrome`)>=0);ER&&ER.indexOf(`Firefox`),!AR&&ER&&ER.indexOf(`Safari`),ER&&ER.indexOf(`Edg/`),ER&&ER.indexOf(`Android`);var jR=typeof navigator==`object`?navigator:{};TR||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||jR&&jR.clipboard&&jR.clipboard.writeText,TR||jR&&jR.clipboard&&jR.clipboard.readText,TR||uR()||jR.keyboard,`ontouchstart`in FL||jR.maxTouchPoints,FL.PointerEvent&&(`ontouchstart`in FL||navigator.maxTouchPoints);var MR=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}},NR=new MR,PR=new MR,FR=new MR,IR=Array(230),LR;(e=>{function t(e){return NR.keyCodeToStr(e)}e.toString=t;function n(e){return NR.strToKeyCode(e)}e.fromString=n;function r(e){return PR.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return FR.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return PR.strToKeyCode(e)||FR.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return NR.keyCodeToStr(e)}e.toElectronAccelerator=o})(LR||={});var RR=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new zR([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},zR=class{constructor(e){if(e.length===0)throw hL(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function BR(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return LR.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(aR)switch(t){case 59:return 85;case 60:if(wR)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(CR)return 57}else if(oR&&(CR&&t===93||!CR&&t===92))return 57;return IR[t]||0}var VR=CR?256:2048,HR=512,UR=1024,WR=CR?2048:256,GR=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=BR(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=VR),this.altKey&&(t|=HR),this.shiftKey&&(t|=UR),this.metaKey&&(t|=WR),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new RR(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},KR=new WeakMap;function qR(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var JR=class{static getSameOriginWindowChain(e){let t=KR.get(e);if(!t){t=[],KR.set(e,t);let n=e,r;do r=qR(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},YR=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=JR.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},XR=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(sR){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)this.deltaY=r?t.wheelDeltaY/(120*i):t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;this.deltaY=t.deltaMode===t.DOM_DELTA_LINE?aR&&!CR?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=cR&&SR?-(t.wheelDeltaX/120):r?t.wheelDeltaX/(120*i):t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;this.deltaX=t.deltaMode===t.DOM_DELTA_LINE?aR&&!CR?-e.deltaX/3:-e.deltaX:-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(this.deltaY=r?e.wheelDelta/(120*i):e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},ZR=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),QR;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof $R?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:VL.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ZR})})(QR||={});var $R=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?ZR:(this._emitter||=new Q,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},ez=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 _L(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new _L(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},tz=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new _L(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=AL(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var nz;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(nz||={});var rz=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Q,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await VL.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};rz.EMPTY=rz.fromArray([]);function iz(e){return az(e,0)}function az(e,t){switch(typeof e){case`object`:return e===null?oz(349,t):Array.isArray(e)?lz(e,t):uz(e,t);case`string`:return cz(e,t);case`boolean`:return sz(e,t);case`number`:return oz(e,t);case`undefined`:return oz(937,t);default:return oz(617,t)}}function oz(e,t){return(t<<5)-t+e|0}function sz(e,t){return oz(e?433:863,t)}function cz(e,t){t=oz(149417,t);for(let n=0,r=e.length;n<r;n++)t=oz(e.charCodeAt(n),t);return t}function lz(e,t){return t=oz(104579,t),e.reduce((e,t)=>az(t,e),t)}function uz(e,t){return t=oz(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=cz(n,t),az(e[n],t)),t)}var{registerWindow:dz,getWindow:fz,getDocument:pz,getWindows:mz,getWindowsCount:hz,getWindowId:gz,getWindowById:_z,hasWindow:vz,onDidRegisterWindow:yz,onWillUnregisterWindow:bz,onDidUnregisterWindow:xz}=function(){let e=new Map,t={window:FL,disposables:new ML};e.set(FL.vscodeWindowId,t);let n=new Q,r=new Q,i=new Q;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return NL.None;let a=new ML,o={window:t,disposables:a.add(new ML)};return e.set(t.vscodeWindowId,o),a.add(AL(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(Cz(t,Mz.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:FL},getDocument(e){return fz(e).document}}}(),Sz=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!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,null)}};function Cz(e,t,n,r){return new Sz(e,t,n,r)}function wz(e,t){return function(n){return t(new YR(e,n))}}function Tz(e){return function(t){return e(new GR(t))}}var Ez=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=wz(fz(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=Tz(n)),Cz(e,t,i,r)},Dz,Oz=class extends tz{constructor(e){super(),this.defaultTarget=e&&fz(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},kz=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){dL(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(kz.sort),a.shift().execute();r.set(i,!1)};Dz=(t,r,a=0)=>{let o=gz(t),s=new kz(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var Az=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};Az.None=new Az(0,0);function jz(e){let t=e.getBoundingClientRect(),n=fz(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=iz(n),a=r.get(i);if(a)a.users+=1;else{let o=new Q,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(AL(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var Mz={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:oR?`webkitAnimationStart`:`animationstart`,ANIMATION_END:oR?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:oR?`webkitAnimationIteration`:`animationiteration`},Nz=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=Pz(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Pz(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Pz(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Pz(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Pz(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Pz(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Pz(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Pz(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Pz(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Pz(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Pz(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=Pz(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=Pz(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Pz(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 Pz(e){return typeof e==`number`?`${e}px`:e}function Fz(e){return new Nz(e)}var Iz=class{constructor(){this._hooks=new ML,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(AL(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=fz(e)}this._hooks.add(Cz(a,Mz.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(Cz(a,Mz.POINTER_UP,e=>this.stopMonitoring(!0)))}};function Lz(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var Rz;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(Rz||={});var zz=class e extends NL{constructor(){super(),this.dispatched=!1,this.targets=new RL,this.ignoreTargets=new RL,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(VL.runAndSubscribe(yz,({window:e,disposables:t})=>{t.add(Cz(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(Cz(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(Cz(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:FL,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=DL(new e),AL(e.INSTANCE.targets.push(t))):NL.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=DL(new e),AL(e.INSTANCE.ignoreTargets.push(t))):NL.None}static isTouchDevice(){return`ontouchstart`in FL||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(Rz.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-vL(s.rollingPageX))<30&&Math.abs(s.initialPageY-vL(s.rollingPageY))<30){let e=this.newGestureEvent(Rz.Tap,s.initialTarget);e.pageX=vL(s.rollingPageX),e.pageY=vL(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-vL(s.rollingPageX))<30&&Math.abs(s.initialPageY-vL(s.rollingPageY))<30){let e=this.newGestureEvent(Rz.Contextmenu,s.initialTarget);e.pageX=vL(s.rollingPageX),e.pageY=vL(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=vL(s.rollingPageX),n=vL(s.rollingPageY),i=vL(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(Rz.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===Rz.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Rz.Change||t.type===Rz.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=Dz(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(Rz.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(Rz.Change,i.initialTarget);a.translationX=r.pageX-vL(i.rollingPageX),a.translationY=r.pageY-vL(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};zz.SCROLL_FRICTION=-.005,zz.HOLD_DELAY=700,zz.CLEAR_TAP_COUNT_TIME=400,_I([Lz],zz,`isTouchDevice`,1);var Bz=zz,Vz=class extends NL{onclick(e,t){this._register(Cz(e,Mz.CLICK,n=>t(new YR(fz(e),n))))}onmousedown(e,t){this._register(Cz(e,Mz.MOUSE_DOWN,n=>t(new YR(fz(e),n))))}onmouseover(e,t){this._register(Cz(e,Mz.MOUSE_OVER,n=>t(new YR(fz(e),n))))}onmouseleave(e,t){this._register(Cz(e,Mz.MOUSE_LEAVE,n=>t(new YR(fz(e),n))))}onkeydown(e,t){this._register(Cz(e,Mz.KEY_DOWN,e=>t(new GR(e))))}onkeyup(e,t){this._register(Cz(e,Mz.KEY_UP,e=>t(new GR(e))))}oninput(e,t){this._register(Cz(e,Mz.INPUT,t))}onblur(e,t){this._register(Cz(e,Mz.BLUR,t))}onfocus(e,t){this._register(Cz(e,Mz.FOCUS,t))}onchange(e,t){this._register(Cz(e,Mz.CHANGE,t))}ignoreGesture(e){return Bz.ignoreTarget(e)}},Hz=11,Uz=class extends Vz{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=Hz+`px`,this.domNode.style.height=Hz+`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 Iz),this._register(Ez(this.bgDomNode,Mz.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(Ez(this.domNode,Mz.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new Oz),this._pointerdownScheduleRepeatTimer=this._register(new ez)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,fz(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},Wz=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(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(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},Gz=class extends NL{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Wz(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new Yz(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=Yz.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},Kz=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function qz(e,t){let n=t-e;return function(t){return e+n*Zz(t)}}function Jz(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var Yz=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,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(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),Jz(qz(e,r),qz(i,t),.33)}return qz(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new Kz(this.scrollLeft(t),this.scrollTop(t),!1):new Kz(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function Xz(e){return e**3}function Zz(e){return 1-Xz(1-e)}var Qz=class extends NL{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new ez)}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||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`:``)))}},$z=140,eB=class extends Vz{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 Qz(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Iz),this._shouldRender=!0,this.domNode=Fz(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(Cz(this.domNode.domNode,Mz.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new Uz(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Fz(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Cz(this.slider.domNode,Mz.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=jz(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(SR&&a>$z){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{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()}},tB=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._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(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},nB=class extends eB{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new tB(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw 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}},rB=class extends eB{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new tB(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw 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}},iB=500,aB=50,oB=!0,sB=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},cB=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(sR){let t=rR(fz(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new sB(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=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]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};cB.INSTANCE=new cB;var lB=cB,uB=class extends Vz{constructor(e,t,n){super(),this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Q),this.onWillScroll=this._onWillScroll.event,this._options=fB(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new rB(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new nB(this._scrollable,this._options,r)),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=Fz(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Fz(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Fz(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,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new ez),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=OL(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,CR&&(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 XR(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=OL(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(Cz(this._listenOnDomNode,Mz.MOUSE_WHEEL,e=>{this._onMouseWheel(new XR(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=lB.INSTANCE;oB&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!CR&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=aB*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=aB*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(oB&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(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 Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_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(),iB)}},dB=class extends uB{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function fB(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,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,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,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,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,CR&&(t.className+=` mac`),t}var pB=class extends NL{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new Gz({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>Dz(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new dB(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(VL.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(AL(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(AL(()=>this._styleElement.remove())),this._register(VL.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
|
|
134
|
+
`)})),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(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};pB=_I([Z(2,WI),Z(3,rL),Z(4,GI),Z(5,cL),Z(6,XI),Z(7,aL)],pB);var mB=class extends NL{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,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(e=>this._removeDecoration(e))),this._register(AL(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};mB=_I([Z(1,WI),Z(2,rL),Z(3,$I),Z(4,aL)],mB);var hB=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},gB={full:0,left:0,center:0,right:0},_B={full:0,left:0,center:0,right:0},vB={full:0,left:0,center:0,right:0},yB=class extends NL{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new hB,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(AL(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw 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);_B.full=this._canvas.width,_B.left=e,_B.center=t,_B.right=e,this._refreshDrawHeightConstants(),vB.full=1,vB.left=1,vB.center=1+_B.left,vB.right=1+_B.left+_B.center}_refreshDrawHeightConstants(){gB.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);gB.left=t,gB.center=t,gB.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gB.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gB.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gB.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gB.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 e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);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(vB[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-gB[e.position||`full`]/2),_B[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+gB[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}))}};yB=_I([Z(2,WI),Z(3,$I),Z(4,aL),Z(5,XI),Z(6,cL),Z(7,rL)],yB);var $;(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=`
|
|
135
|
+
`,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=``))($||={});var bB;(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=``))(bB||={});var xB;(e=>e.ST=`${$.ESC}\\`)(xB||={});var SB=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,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)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.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 e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};SB=_I([Z(2,WI),Z(3,XI),Z(4,KI),Z(5,aL)],SB);var CB=0,wB=0,TB=0,EB=0,DB={css:`#00000000`,rgba:0},OB;(e=>{function t(e,t,n,r){return r===void 0?`#${NB(e)}${NB(t)}${NB(n)}`:`#${NB(e)}${NB(t)}${NB(n)}${NB(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(OB||={});var kB;(e=>{function t(e,t){if(EB=(t.rgba&255)/255,EB===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return CB=a+Math.round((n-a)*EB),wB=o+Math.round((r-o)*EB),TB=s+Math.round((i-s)*EB),{css:OB.toCss(CB,wB,TB),rgba:OB.toRgba(CB,wB,TB)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=MB.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return OB.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[CB,wB,TB]=MB.toChannels(t),{css:OB.toCss(CB,wB,TB),rgba:t}}e.opaque=i;function a(e,t){return EB=Math.round(t*255),[CB,wB,TB]=MB.toChannels(e.rgba),{css:OB.toCss(CB,wB,TB,EB),rgba:OB.toRgba(CB,wB,TB,EB)}}e.opacity=a;function o(e,t){return EB=e.rgba&255,a(e,EB*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(kB||={});var AB;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return CB=parseInt(e.slice(1,2).repeat(2),16),wB=parseInt(e.slice(2,3).repeat(2),16),TB=parseInt(e.slice(3,4).repeat(2),16),OB.toColor(CB,wB,TB);case 5:return CB=parseInt(e.slice(1,2).repeat(2),16),wB=parseInt(e.slice(2,3).repeat(2),16),TB=parseInt(e.slice(3,4).repeat(2),16),EB=parseInt(e.slice(4,5).repeat(2),16),OB.toColor(CB,wB,TB,EB);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return CB=parseInt(r[1]),wB=parseInt(r[2]),TB=parseInt(r[3]),EB=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),OB.toColor(CB,wB,TB,EB);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[CB,wB,TB,EB]=t.getImageData(0,0,1,1).data,EB!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:OB.toRgba(CB,wB,TB,EB),css:e}}e.toColor=r})(AB||={});var jB;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(jB||={});var MB;(e=>{function t(e,t){if(EB=(t&255)/255,EB===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return CB=a+Math.round((n-a)*EB),wB=o+Math.round((r-o)*EB),TB=s+Math.round((i-s)*EB),OB.toRgba(CB,wB,TB)}e.blend=t;function n(e,t,n){let a=jB.relativeLuminance(e>>8),o=jB.relativeLuminance(t>>8);if(PB(a,o)<n){if(o<a){let o=r(e,t,n),s=PB(a,jB.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>PB(a,jB.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=PB(a,jB.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>PB(a,jB.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=PB(jB.relativeLuminance2(o,s,c),jB.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=PB(jB.relativeLuminance2(o,s,c),jB.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=PB(jB.relativeLuminance2(o,s,c),jB.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=PB(jB.relativeLuminance2(o,s,c),jB.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(MB||={});function NB(e){let t=e.toString(16);return t.length<2?`0`+t:t}function PB(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var FB=class extends FI{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},IB=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new LI}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||PI.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)IB._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||PI.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};IB=_I([Z(0,WI)],IB);function LB(e){return 57508<=e&&e<=57558}function RB(e){return 9472<=e&&e<=9631}function zB(e){return LB(e)||RB(e)}function BB(){return{css:{canvas:VB(),cell:VB()},device:{canvas:VB(),cell:VB(),char:{width:0,height:0,left:0,top:0}}}}function VB(){return{width:0,height:0}}var HB=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new LI,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new FB(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let P=this._isCellInSelection(k,t),F=n&&k===a,I=O&&k>=l&&k<=u,L=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{L=!0});let ee=N.getChars()||PI;if(ee===` `&&(N.isUnderline()||N.isOverline())&&(ee=`\xA0`),T=m*s-c.get(ee,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(P&&w||!P&&!w&&N.bg===y)&&(P&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&I===S&&T===C&&!F&&!A&&!L&&j){N.isInvisible()?_+=PI:_+=ee,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=I,C=T,w=P,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&F&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`)}}if(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?PI:N.getChars()||PI,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault())){if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${FI.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),I&&(h.style.textDecoration=`underline`);let te=N.getFgColor(),ne=N.getFgColorMode(),re=N.getBgColor(),R=N.getBgColorMode(),ie=!!N.isInverse();if(ie){let e=te;te=re,re=e;let t=ne;ne=R,R=t}let ae,oe,se=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&se||(e.backgroundColorRGB&&(R=50331648,re=e.backgroundColorRGB.rgba>>8&16777215,ae=e.backgroundColorRGB),e.foregroundColorRGB&&(ne=50331648,te=e.foregroundColorRGB.rgba>>8&16777215,oe=e.foregroundColorRGB),se=e.options.layer===`top`)}),!se&&P&&(ae=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,re=ae.rgba>>8&16777215,R=50331648,se=!0,p.selectionForeground&&(ne=50331648,te=p.selectionForeground.rgba>>8&16777215,oe=p.selectionForeground)),se&&D.push(`xterm-decoration-top`);let ce;switch(R){case 16777216:case 33554432:ce=p.ansi[re],D.push(`xterm-bg-${re}`);break;case 50331648:ce=OB.toColor(re>>16,re>>8&255,re&255),this._addStyle(h,`background-color:#${UB((re>>>0).toString(16),`0`,6)}`);break;default:ie?(ce=p.foreground,D.push(`xterm-bg-257`)):ce=p.background}switch(ae||N.isDim()&&(ae=kB.multiplyOpacity(ce,.5)),ne){case 16777216:case 33554432:N.isBold()&&te<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(te+=8),this._applyMinimumContrast(h,ce,p.ansi[te],N,ae,void 0)||D.push(`xterm-fg-${te}`);break;case 50331648:let e=OB.toColor(te>>16&255,te>>8&255,te&255);this._applyMinimumContrast(h,ce,e,N,ae,oe)||this._addStyle(h,`color:#${UB(te.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,ce,p.foreground,N,ae,oe)||ie&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!F&&!A&&!L&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||zB(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=kB.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};HB=_I([Z(1,sL),Z(2,XI),Z(3,rL),Z(4,KI),Z(5,$I),Z(6,cL)],HB);function UB(e,t,n){for(;e.length<n;)e=t+e;return e}var WB=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},GB=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function KB(){return new GB}var qB=`xterm-dom-renderer-owner-`,JB=`xterm-rows`,YB=`xterm-fg-`,XB=`xterm-bg-`,ZB=`xterm-focus`,QB=`xterm-selection`,$B=1,eV=class extends NL{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=$B++,this._rowElements=[],this._selectionRenderModel=KB(),this.onRequestRedraw=this._register(new Q).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(JB),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(QB),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=BB(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(HB,document),this._element.classList.add(qB+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(AL(()=>{this._element.classList.remove(qB+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new WB(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 e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${JB} 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} .${JB} { 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} .${JB} .xterm-dim { color: ${kB.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${JB}.${ZB} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${JB}.${ZB} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${JB}.${ZB} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${JB} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${JB} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${JB} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${JB} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${JB} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${QB} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${QB} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${QB} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${YB}${n} { color: ${r.css}; }${this._terminalSelector} .${YB}${n}.xterm-dim { color: ${kB.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${XB}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${YB}257 { color: ${kB.opaque(e.background).css}; }${this._terminalSelector} .${YB}257.xterm-dim { color: ${kB.multiplyOpacity(kB.opaque(e.background),.5).css}; }${this._terminalSelector} .${XB}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 e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}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(ZB),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ZB),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${qB}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};eV=_I([Z(7,JI),Z(8,nL),Z(9,XI),Z(10,WI),Z(11,KI),Z(12,rL),Z(13,cL)],eV);var tV=class extends NL{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new iV(this._optionsService))}catch{this._measureStrategy=this._register(new rV(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())}};tV=_I([Z(2,XI)],tV);var nV=class extends NL{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)}},rV=class extends nV{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},iV=class extends nV{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 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}},aV=class extends NL{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new oV(this._window)),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(VL.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Cz(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(Cz(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}},oV=class extends NL{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new PL),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(AL(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Cz(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)}},sV=class extends NL{constructor(){super(),this.linkProviders=[],this._register(AL(()=>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 cV(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function lV(e,t,n,r,i,a,o,s,c){if(!a)return;let l=cV(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var uV=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return lV(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=cV(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};uV=_I([Z(0,aL),Z(1,nL)],uV);var dV=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,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=[]}},fV={};gI(fV,{getSafariVersion:()=>yV,isChromeOS:()=>TV,isFirefox:()=>gV,isIpad:()=>xV,isIphone:()=>SV,isLegacyEdge:()=>_V,isLinux:()=>wV,isMac:()=>bV,isNode:()=>pV,isSafari:()=>vV,isWindows:()=>CV});var pV=typeof process<`u`&&`title`in process,mV=pV?`node`:navigator.userAgent,hV=pV?`node`:navigator.platform,gV=mV.includes(`Firefox`),_V=mV.includes(`Edge`),vV=/^((?!chrome|android).)*safari/i.test(mV);function yV(){if(!vV)return 0;let e=mV.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var bV=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(hV),xV=hV===`iPad`,SV=hV===`iPhone`,CV=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(hV),wV=hV.indexOf(`Linux`)>=0,TV=/\bCrOS\b/.test(mV),EV=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),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},DV=class extends EV{_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())}}},OV=class extends EV{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},kV=!pV&&`requestIdleCallback`in window?OV:DV,AV=class{constructor(){this._queue=new kV}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},jV=class extends NL{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new PL),this._pausedResizeTask=new AV,this._observerDisposable=this._register(new PL),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 Q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new dV((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new MV(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(AL(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=AL(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!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(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};jV=_I([Z(2,XI),Z(3,nL),Z(4,KI),Z(5,$I),Z(6,WI),Z(7,rL),Z(8,cL)],jV);var MV=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function NV(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return IV(i,a,e,t,n,r)+LV(a,t,n,r)+RV(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,GV(Math.abs(i-e),WV(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return GV(FV(a>t?e:i,n)+(s-1)*n.cols+1+PV(a>t?i:e,n),WV(o,r))}function PV(e,t){return e-1}function FV(e,t){return t.cols-e}function IV(e,t,n,r,i,a){return LV(t,r,i,a).length===0?``:GV(UV(e,t,e,t-BV(t,i),!1,i).length,WV(`D`,a))}function LV(e,t,n,r){let i=e-BV(e,n),a=t-BV(t,n);return GV(Math.abs(i-a)-zV(e,t,n),WV(HV(e,t),r))}function RV(e,t,n,r,i,a){let o;o=LV(t,r,i,a).length>0?r-BV(r,i):t;let s=r,c=VV(e,t,n,r,i,a);return GV(UV(e,o,n,s,c===`C`,i).length,WV(c,a))}function zV(e,t,n){let r=0,i=e-BV(e,n),a=t-BV(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=HV(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function BV(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function VV(e,t,n,r,i,a){let o;return o=LV(n,r,i,a).length>0?r-BV(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function HV(e,t){return e>t?`A`:`B`}function UV(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function WV(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function GV(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var KV=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 qV(e,t){if(e.start.y>e.end.y)throw 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 JV=50,YV=15,XV=50,ZV=500,QV=RegExp(`\xA0`,`g`),$V=class extends NL{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new LI,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new KV(this._bufferService),this._activeSelectionMode=0,this._register(AL(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(QV,` `)).join(CV?`\r
|
|
136
136
|
`:`
|
|
137
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),SV&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=GV(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,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=oV(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-KV),KV),t/=KV,t/Math.abs(t)+Math.round(t*(qV-1)))}shouldForceSelection(e){return vV?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(),JV)}_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&&!(vV&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.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<YV&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=jV(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=GV(n,this._bufferService.cols)}};ZV=hI([Z(3,HI),Z(4,WI),Z(5,nL),Z(6,JI),Z(7,rL),Z(8,tL)],ZV);var QV=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},$V=class{constructor(){this._color=new QV,this._css=new QV}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},eH=Object.freeze((()=>{let e=[OB.toColor(`#2e3436`),OB.toColor(`#cc0000`),OB.toColor(`#4e9a06`),OB.toColor(`#c4a000`),OB.toColor(`#3465a4`),OB.toColor(`#75507b`),OB.toColor(`#06989a`),OB.toColor(`#d3d7cf`),OB.toColor(`#555753`),OB.toColor(`#ef2929`),OB.toColor(`#8ae234`),OB.toColor(`#fce94f`),OB.toColor(`#729fcf`),OB.toColor(`#ad7fa8`),OB.toColor(`#34e2e2`),OB.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:EB.toCss(r,i,a),rgba:EB.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:EB.toCss(n,n,n),rgba:EB.toRgba(n,n,n)})}return e})()),tH=OB.toColor(`#ffffff`),nH=OB.toColor(`#000000`),rH=OB.toColor(`#ffffff`),iH=nH,aH={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},oH=tH,sH=class extends jL{constructor(e){super(),this._optionsService=e,this._contrastCache=new $V,this._halfContrastCache=new $V,this._onChangeColors=this._register(new Q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:tH,background:nH,cursor:rH,cursorAccent:iH,selectionForeground:void 0,selectionBackgroundTransparent:aH,selectionBackgroundOpaque:DB.blend(nH,aH),selectionInactiveBackgroundTransparent:aH,selectionInactiveBackgroundOpaque:DB.blend(nH,aH),scrollbarSliderBackground:DB.opacity(tH,.2),scrollbarSliderHoverBackground:DB.opacity(tH,.4),scrollbarSliderActiveBackground:DB.opacity(tH,.5),overviewRulerBorder:tH,ansi:eH.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=cH(e.foreground,tH),t.background=cH(e.background,nH),t.cursor=DB.blend(t.background,cH(e.cursor,rH)),t.cursorAccent=DB.blend(t.background,cH(e.cursorAccent,iH)),t.selectionBackgroundTransparent=cH(e.selectionBackground,aH),t.selectionBackgroundOpaque=DB.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=cH(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=DB.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?cH(e.selectionForeground,TB):void 0,t.selectionForeground===TB&&(t.selectionForeground=void 0),DB.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=DB.opacity(t.selectionBackgroundTransparent,.3)),DB.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=DB.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=cH(e.scrollbarSliderBackground,DB.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=cH(e.scrollbarSliderHoverBackground,DB.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=cH(e.scrollbarSliderActiveBackground,DB.opacity(t.foreground,.5)),t.overviewRulerBorder=cH(e.overviewRulerBorder,oH),t.ansi=eH.slice(),t.ansi[0]=cH(e.black,eH[0]),t.ansi[1]=cH(e.red,eH[1]),t.ansi[2]=cH(e.green,eH[2]),t.ansi[3]=cH(e.yellow,eH[3]),t.ansi[4]=cH(e.blue,eH[4]),t.ansi[5]=cH(e.magenta,eH[5]),t.ansi[6]=cH(e.cyan,eH[6]),t.ansi[7]=cH(e.white,eH[7]),t.ansi[8]=cH(e.brightBlack,eH[8]),t.ansi[9]=cH(e.brightRed,eH[9]),t.ansi[10]=cH(e.brightGreen,eH[10]),t.ansi[11]=cH(e.brightYellow,eH[11]),t.ansi[12]=cH(e.brightBlue,eH[12]),t.ansi[13]=cH(e.brightMagenta,eH[13]),t.ansi[14]=cH(e.brightCyan,eH[14]),t.ansi[15]=cH(e.brightWhite,eH[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=cH(e.extendedAnsi[r],eH[r+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 e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];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()}}};sH=hI([Z(0,JI)],sH);function cH(e,t){if(e!==void 0)try{return OB.toColor(e)}catch{}return t}var lH=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},uH=class{constructor(){this._services=new lH,this._services.set(KI,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=zI(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},dH={trace:0,debug:1,info:2,warn:3,error:4,off:5},fH=`xterm.js: `,pH=class extends jL{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),mH=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=dH[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:fH)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};pH=hI([Z(0,JI)],pH);var mH,hH=class extends jL{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Q),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},gH=3,_H=Object.freeze(new NI),vH=0,yH=2,bH=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*gH);let r=t||FI.fromCharData([0,jI,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*gH+0],n=t&2097151;return[this._data[e*gH+1],t&2097152?this._combined[e]:n?DI(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*gH+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*gH+0]=e|2097152|t[2]<<22):this._data[e*gH+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*gH+0]>>22}hasWidth(e){return this._data[e*gH+0]&12582912}getFg(e){return this._data[e*gH+1]}getBg(e){return this._data[e*gH+2]}hasContent(e){return this._data[e*gH+0]&4194303}getCodePoint(e){let t=this._data[e*gH+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*gH+0]&2097152}getString(e){let t=this._data[e*gH+0];return t&2097152?this._combined[e]:t&2097151?DI(t&2097151):``}isProtected(e){return this._data[e*gH+2]&536870912}loadCell(e,t){return vH=e*gH,t.content=this._data[vH+0],t.fg=this._data[vH+1],t.bg=this._data[vH+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*gH+0]=t.content,this._data[e*gH+1]=t.fg,this._data[e*gH+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*gH+0]=t|n<<22,this._data[e*gH+1]=r.fg,this._data[e*gH+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*gH+0];r&2097152?this._combined[e]+=DI(t):r&2097151?(this._combined[e]=DI(r&2097151)+DI(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*gH+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new FI;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new FI;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*yH<this._data.buffer.byteLength;let n=e*gH;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*yH<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*yH<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*gH+0]&4194303)return e+(this._data[e*gH+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*gH+0]&4194303||this._data[e*gH+2]&50331648)return e+(this._data[e*gH+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<gH;e++)this._data[(n+i)*gH+e]=a[(t+i)*gH+e];a[(t+i)*gH+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<gH;e++)this._data[(n+i)*gH+e]=a[(t+i)*gH+e];a[(t+i)*gH+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*gH+0],n=e&2097151,a=e&2097152?this._combined[t]:n?DI(n):MI;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function xH(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=TH(u,d,t),p=1,m=0;for(;p<u.length;){let e=TH(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function SH(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function CH(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function wH(e,t,n){let r=[],i=e.map((n,r)=>TH(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=TH(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function TH(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var EH=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),EL(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};EH._nextId=1;var DH=EH,OH={},kH=OH.B;OH[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},OH.A={"#":`£`},OH.B=void 0,OH[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},OH.C=OH[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},OH.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},OH.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},OH.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},OH.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},OH.E=OH[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},OH.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},OH.H=OH[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},OH[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var AH=4294967295,jH=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=_H.clone(),this.savedCharset=kH,this.markers=[],this._nullCell=FI.fromCharData([0,jI,1,0]),this._whitespaceCell=FI.fromCharData([0,MI,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new DV,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new hH(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 PI),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 PI),this._whitespaceCell}getBlankLine(e,t){return new bH(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>AH?AH:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=_H);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 hH(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(_H),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)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 bH(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new bH(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),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 t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=xH(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(_H),n);if(r.length>0){let n=SH(this.lines,r);CH(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(_H),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new bH(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(_H),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=wH(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(_H,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=TH(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->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+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(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 DH(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},MH=class extends jL{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Q),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 jH(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new jH(!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)}},NH=2,PH=1,FH=class extends jL{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,NH),this.rows=Math.max(e.rawOptions.rows||0,PH),this.buffers=this._register(new MH(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};FH=hI([Z(0,JI)],FH);var IH={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:vV,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},LH=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],RH=class extends jL{constructor(e){super(),this._onOptionChange=this._register(new Q),this.onOptionChange=this._onOptionChange.event;let t={...IH};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(OL(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in IH))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in IH))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=IH[e],!zH(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=IH[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=LH.includes(t)?t:IH[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw 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 Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function zH(e){return e===`block`||e===`underline`||e===`bar`}function BH(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&BH(e[r],t-1);return n}var VH=Object.freeze({insertMode:!1}),HH=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),UH=class extends jL{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Q),this.onData=this._onData.event,this._onUserInput=this._register(new Q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=BH(VH),this.decPrivateModes=BH(HH)}reset(){this.modes=BH(VH),this.decPrivateModes=BH(HH)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.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(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};UH=hI([Z(0,HI),Z(1,qI),Z(2,JI)],UH);var WH={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 GH(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var KH=String.fromCharCode,qH={DEFAULT:e=>{let t=[GH(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${KH(t[0])}${KH(t[1])}${KH(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${GH(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${GH(e,!0)};${e.x};${e.y}${t}`}},JH=class extends jL{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Q),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(WH))this.addProtocol(e,WH[e]);for(let e of Object.keys(qH))this.addEncoding(e,qH[e]);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 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 Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};JH=hI([Z(0,HI),Z(1,WI),Z(2,JI)],JH);var YH=[[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]],XH=[[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]],ZH;function QH(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var $H=class{constructor(){if(this.version=`6`,!ZH){ZH=new Uint8Array(65536),ZH.fill(1),ZH[0]=0,ZH.fill(0,1,32),ZH.fill(0,127,160),ZH.fill(2,4352,4448),ZH[9001]=2,ZH[9002]=2,ZH.fill(2,11904,42192),ZH[12351]=1,ZH.fill(2,44032,55204),ZH.fill(2,63744,64256),ZH.fill(2,65040,65050),ZH.fill(2,65072,65136),ZH.fill(2,65280,65377),ZH.fill(2,65504,65511);for(let e=0;e<YH.length;++e)ZH.fill(0,YH[e][0],YH[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ZH[e]:QH(e,XH)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=eU.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return eU.createPropertyValue(0,n,r)}},eU=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Q,this.onChange=this._onChange.event;let e=new $H;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},tU=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 nU(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var rU=2147483647,iU=256,aU=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>iU)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(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 e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>rU?rU:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>rU?rU:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,rU):e}},oU=[],sU=class{constructor(){this._state=0,this._active=oU,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,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=oU}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=oU,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||oU,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,OI(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=oU,this._id=-1,this._state=0}}},cU=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=OI(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},lU=[],uU=class{constructor(){this._handlers=Object.create(null),this._active=lU,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=lU}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,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=lU,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||lU,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,OI(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=lU,this._ident=0}},dU=new aU;dU.addParam(0);var fU=class{constructor(e){this._handler=e,this._data=``,this._params=dU,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():dU,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=OI(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=dU,this._data=``,this._hitLimit=!1,e));return this._params=dU,this._data=``,this._hitLimit=!1,t}},pU=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},mU=160,hU=function(){let e=new pU(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(mU,0,2,0),e.add(mU,8,5,8),e.add(mU,6,0,6),e.add(mU,11,0,11),e.add(mU,13,13,13),e}(),gU=class extends jL{constructor(e=hU){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 aU,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(OL(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new sU),this._dcsParser=this._register(new uU),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:mU)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<mU){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<mU){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<mU){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<mU){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<mU){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=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 i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<mU){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},_U=/^([\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})$/,vU=/^[\da-f]+$/;function yU(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=_U.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),vU.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function bU(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function xU(e,t=16){let[n,r,i]=e;return`rgb:${bU(n,t)}/${bU(r,t)}/${bU(i,t)}`}var SU={"(":0,")":1,"*":2,"+":3,"-":1,".":2},CU=131072,wU=10;function TU(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 EU=5e3,DU=0,OU=class extends jL{constructor(e,t,n,r,i,a,o,s,c=new gU){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new kI,this._utf8Decoder=new AI,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=_H.clone(),this._eraseAttrDataInternal=_H.clone(),this._onRequestBell=this._register(new Q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Q),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 kU(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(vB.IND,()=>this.index()),this._parser.setExecuteHandler(vB.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(vB.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new cU(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new cU(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new cU(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new cU(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new cU(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new cU(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new cU(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new cU(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new cU(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new cU(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new cU(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new cU(e=>this.restoreCursorColor(e))),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 e in OH)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new fU((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),EU))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${EU} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>CU&&(a=this._parseStack.position+CU)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<CU&&(this._parseBuffer=new Uint32Array(Math.min(e.length,CU))),o||this._dirtyRowTracker.clearRange(),e.length>CU)for(let t=a;t<e.length;t+=CU){let a=t+CU<e.length?t+CU:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=eU.extractWidth(t);let n=eU.extractShouldJoin(t),m=n?eU.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(DI(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof bH&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!TU(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new fU(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new cU(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}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)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,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}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(_H));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 e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=eU.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.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}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,kH),this._charsetService.setgCharset(1,kH),this._charsetService.setgCharset(2,kH),this._charsetService.setgCharset(3,kH);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}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}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)}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=NI.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_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=_H.fg,e.bg=_H.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=_H.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=_H.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=_H.fg&16777215,r.bg&=-67108864,r.bg|=_H.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}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=_H.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`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!TU(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(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>wU&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>wU&&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())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(AU(n)){if(r===`?`)t.push({type:0,index:n});else{let e=yU(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=yU(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);AU(r)&&t.push({type:2,index:r})}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,kH),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(SU[e[0]],OH[e[1]]||kH),!0):(this.selectDefaultCharset(),!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=_H.clone(),this._eraseAttrDataInternal=_H.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 FI;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},kU=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&&(DU=e,e=t,t=DU),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};kU=hI([Z(0,HI)],kU);function AU(e){return 0<=e&&e<256}var jU=5e7,MU=12,NU=50,PU=class extends jL{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 Q),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>jU)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=MU?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=MU)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>NU&&(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()}},FU=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 n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};FU=hI([Z(0,HI)],FU);var IU=!1,LU=class extends jL{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ML),this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onData=this._register(new Q),this.onData=this._onData.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Q),this._instantiationService=new uH,this.optionsService=this._register(new RH(e)),this._instantiationService.setService(JI,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(FH)),this._instantiationService.setService(HI,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(pH)),this._instantiationService.setService(qI,this._logService),this.coreService=this._register(this._instantiationService.createInstance(UH)),this._instantiationService.setService(WI,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(JH)),this._instantiationService.setService(UI,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(eU)),this._instantiationService.setService(XI,this.unicodeService),this._charsetService=this._instantiationService.createInstance(tU),this._instantiationService.setService(GI,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(FU),this._instantiationService.setService(YI,this._oscLinkService),this._inputHandler=this._register(new OU(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(zL.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(zL.forward(this._bufferService.onResize,this._onResize)),this._register(zL.forward(this.coreService.onData,this._onData)),this._register(zL.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 PU((e,t)=>this._inputHandler.parse(e,t))),this._register(zL.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Q),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&&!IU&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),IU=!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,NH),t=Math.max(t,PH),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(nU.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(nU(this._bufferService),!1))),this._windowsWrappingHeuristics.value=OL(()=>{for(let t of e)t.dispose()})}}},RU={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 zU(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?$.ESC+`OA`:$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?$.ESC+`OD`:$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?$.ESC+`OC`:$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?$.ESC+`OB`:$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`D`:t?$.ESC+`OD`:$.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`C`:t?$.ESC+`OC`:$.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`A`:t?$.ESC+`OA`:$.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`B`:t?$.ESC+`OB`:$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:i.key=a?$.ESC+`[3;`+(a+1)+`~`:$.ESC+`[3~`;break;case 36:i.key=a?$.ESC+`[1;`+(a+1)+`H`:t?$.ESC+`OH`:$.ESC+`[H`;break;case 35:i.key=a?$.ESC+`[1;`+(a+1)+`F`:t?$.ESC+`OF`:$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?$.ESC+`[5;`+(a+1)+`~`:$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?$.ESC+`[6;`+(a+1)+`~`:$.ESC+`[6~`;break;case 112:i.key=a?$.ESC+`[1;`+(a+1)+`P`:$.ESC+`OP`;break;case 113:i.key=a?$.ESC+`[1;`+(a+1)+`Q`:$.ESC+`OQ`;break;case 114:i.key=a?$.ESC+`[1;`+(a+1)+`R`:$.ESC+`OR`;break;case 115:i.key=a?$.ESC+`[1;`+(a+1)+`S`:$.ESC+`OS`;break;case 116:i.key=a?$.ESC+`[15;`+(a+1)+`~`:$.ESC+`[15~`;break;case 117:i.key=a?$.ESC+`[17;`+(a+1)+`~`:$.ESC+`[17~`;break;case 118:i.key=a?$.ESC+`[18;`+(a+1)+`~`:$.ESC+`[18~`;break;case 119:i.key=a?$.ESC+`[19;`+(a+1)+`~`:$.ESC+`[19~`;break;case 120:i.key=a?$.ESC+`[20;`+(a+1)+`~`:$.ESC+`[20~`;break;case 121:i.key=a?$.ESC+`[21;`+(a+1)+`~`:$.ESC+`[21~`;break;case 122:i.key=a?$.ESC+`[23;`+(a+1)+`~`:$.ESC+`[23~`;break;case 123:i.key=a?$.ESC+`[24;`+(a+1)+`~`:$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=RU[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL))}return i}var BU=0,VU=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new DV,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new DV,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((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,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||(BU=this._search(t),BU===-1)||this._getKey(this._array[BU])!==t)return!1;do if(this._array[BU]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(BU),!0;while(++BU<this._array.length&&this._getKey(this._array[BU])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(BU=this._search(e),!(BU<0||BU>=this._array.length)&&this._getKey(this._array[BU])===e))do yield this._array[BU];while(++BU<this._array.length&&this._getKey(this._array[BU])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(BU=this._search(e),!(BU<0||BU>=this._array.length)&&this._getKey(this._array[BU])===e))do t(this._array[BU]);while(++BU<this._array.length&&this._getKey(this._array[BU])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},HU=0,UU=0,WU=class extends jL{constructor(){super(),this._decorations=new VU(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(OL(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new GU(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{HU=t.options.x??0,UU=HU+(t.options.width??1),e>=HU&&e<UU&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},GU=class extends AL{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Q),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._cachedBg=this.options.backgroundColor?OB.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?OB.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},KU=1e3,qU=class{constructor(e,t=KU){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_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)}},JU=20,YU=class extends jL{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,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=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new qU(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
138
|
-
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(
|
|
139
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===JU+1&&(this._liveRegion.textContent+=yI.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};YU=hI([Z(1,KI),Z(2,tL),Z(3,rL)],YU);var XU=class extends jL{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(OL(()=>{EL(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(xz(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(xz(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(xz(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(xz(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.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(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&ZU(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,EL(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||e.link.decorations.underline,pointerCursor:e.link.decorations===void 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:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};XU=hI([Z(1,nL),Z(2,rL),Z(3,HI),Z(4,sL)],XU);function ZU(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 QU=class extends LU{constructor(e={}){super(e),this._linkifier=this._register(new ML),this.browser=uV,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ML),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(WU),this._instantiationService.setService(ZI,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(aV),this._instantiationService.setService(sL,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(QI)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(zL.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(zL.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(zL.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(zL.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(OL(()=>{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 e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=DB.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${xU(r)}${yB.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=EB.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=EB.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_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(YU,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.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($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(xz(this.element,`copy`,e=>{this.hasSelection()&&SI(e,this._selectionService)}));let e=e=>CI(e,this.textarea,this.coreService,this.optionsService);this._register(xz(this.textarea,`paste`,e)),this._register(xz(this.element,`paste`,e)),mV?this._register(xz(this.element,`mousedown`,e=>{e.button===2&&EI(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(xz(this.element,`contextmenu`,e=>{EI(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),SV&&this._register(xz(this.element,`auxclick`,e=>{e.button===1&&TI(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(xz(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(xz(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(xz(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(xz(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(xz(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(xz(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(xz(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw 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(xz(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,_I.get()),CV||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(rV,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(tL,this._coreBrowserService),this._register(xz(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(xz(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance($B,this._document,this._helperContainer),this._instantiationService.setService(eL,this._charSizeService),this._themeService=this._instantiationService.createInstance(sH),this._instantiationService.setService(oL,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(PB),this._instantiationService.setService(aL,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(kV,this.rows,this.screenElement)),this._instantiationService.setService(rL,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(bB,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(cV),this._instantiationService.setService(nL,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(XU,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(dB,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(ZV,this.element,this.screenElement,r)),this._instantiationService.setService(iL,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(zL.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(fB,this.screenElement)),this._register(xz(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),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(YU,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_B,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_B,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(QB,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),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()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(xz(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(xz(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!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){wI(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 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 Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=zU(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&($U(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(_H));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($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`)}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function $U(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var eW=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},tW=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 FI)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},nW=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 tW(t)}getNullCell(){return new FI}},rW=class extends jL{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new nW(this._core.buffers.normal,`normal`),this._alternate=new nW(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 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)}},iW=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.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)}},aW=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}},oW=[`cols`,`rows`],sW=0,cW=class extends jL{constructor(e){super(),this._core=this._register(new QU(e)),this._addonManager=this._register(new eW),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(oW.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw 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||=new iW(this._core),this._parser}get unicode(){return this._checkProposedApi(),new aW(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._register(new rW(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`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
140
|
-
`,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 _I.get()},set promptLabel(e){_I.set(e)},get tooMuchOutput(){return yI.get()},set tooMuchOutput(e){yI.set(e)}}}_verifyIntegers(...e){for(sW of e)if(sW===1/0||isNaN(sW)||sW%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(sW of e)if(sW&&(sW===1/0||isNaN(sW)||sW%1!=0||sW<0))throw Error(`This API only accepts positive integers`)}};function lW(e,t){if(typeof document>`u`)return t;try{let n=document.createElement(`span`);n.style.color=`var(${e})`,n.style.position=`absolute`,n.style.opacity=`0`,n.style.pointerEvents=`none`,document.body.appendChild(n);let r=getComputedStyle(n).color;return n.remove(),r||t}catch{return t}}function uW(){let e=lW(`--card`,`#0b0b12`),t=lW(`--foreground`,`#e5e5ef`);return{background:e,foreground:t,cursor:`#a855f7`,cursorAccent:e,selectionBackground:`#9333ea55`,...typeof document<`u`&&document.documentElement.classList.contains(`dark`)?{}:{black:t,white:`#3f3f46`,brightWhite:t,brightBlack:`#a1a1aa`}}}function dW(e,t){e.preventDefault(),window.open(t,`_blank`,`noopener,noreferrer`)}function fW(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t;if(n.t===`opened`){let e=Number.isInteger(n.cols)&&Number.isInteger(n.rows)&&n.cols>0&&n.rows>0?{cols:n.cols,rows:n.rows}:void 0;return{kind:`opened`,...e?{dimensions:e}:{}}}return n.t===`dimensions`&&Number.isInteger(n.cols)&&Number.isInteger(n.rows)&&n.cols>0&&n.rows>0?{kind:`dimensions`,dimensions:{cols:n.cols,rows:n.rows}}:n.t===`error`?{kind:`error`,message:typeof n.message==`string`&&n.message.trim()?n.message:`Terminal bridge error`}:null}function pW(e){return e===1001||e===1006||e===1012||e===1013}function mW(e,t,n){return!e&&t&&n.kind===`closed`&&(n.code===4404||pW(n.code))}function hW(e){if(typeof e==`object`&&e){let t=e.status;if(typeof t==`number`&&t>=500)return!0}let t=e instanceof Error?e.message:String(e);return/failed to fetch|fetch failed|load failed|network\s*error/i.test(t)}var gW=`\x1B[13;2u`;function _W(e){return e.key===`Enter`&&e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey?gW:null}var vW=new TextEncoder,yW=2e4;function bW(e,t,n){return e===0?``:`\x1b[<${e<0?64:65};${t};${n}M`.repeat(Math.abs(e))}function xW(e,t,n,r){if(t.mouseTrackingMode===`none`||!t.sgrEncoding)return{consume:!1,data:``,partial:0};if(e.shiftKey||e.deltaY===0||n===null)return{consume:!1,data:``,partial:r};let i;i=e.deltaMode===1?e.deltaY:e.deltaMode===2?e.deltaY*n.rows:e.deltaY/n.cellHeight;let a=r+i,o=Math.trunc(a),s=Math.max(-50,Math.min(50,o)),c=(e,t)=>Math.min(Math.max(e,1),t);return{consume:!0,data:bW(s,c(Math.floor((e.clientX-n.left)/n.cellWidth)+1,n.cols),c(Math.floor((e.clientY-n.top)/n.cellHeight)+1,n.rows)),partial:s===o?a-o:0}}function SW(e){let t;try{t=new dI}catch{return null}t.onContextLoss(()=>t.dispose());try{e.loadAddon(t)}catch{return t.dispose(),null}return t}function CW(e,t){return t?(e.clipboardData?.setData(`text/plain`,t),e.preventDefault(),!0):!1}var wW=class{url;onState;term;fit;webgl;listenerCtl;resizeObserver;ws=null;dataDispose=null;disposed=!1;connectedOnce=!1;connectionGeneration=0;layoutVisible=!1;wheelPartialLines=0;constructor(e,t,n,r=!1){this.url=t,this.onState=n,this.term=new cW({fontFamily:`'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:13,scrollback:yW,cursorBlink:!0,theme:uW(),minimumContrastRatio:4.5,macOptionClickForcesSelection:!0,allowProposedApi:!0,disableStdin:!1}),this.fit=new Uj,this.term.loadAddon(this.fit),this.term.loadAddon(new Yj(dW)),this.term.open(e),this.webgl=SW(this.term),this.listenerCtl=new AbortController;let{signal:i}=this.listenerCtl;e.addEventListener(`copy`,e=>CW(e,this.term.getSelection()),{capture:!0,signal:i}),this.onState({kind:`connecting`}),this.resizeObserver=new ResizeObserver(e=>{if(this.disposed)return;let t=e[0]?.contentRect,n=!!t&&t.width>0&&t.height>0;if(this.layoutVisible=n,!this.connectedOnce&&!this.ws){n&&this.connect();return}n&&this.sendResize()}),this.resizeObserver.observe(e)}async connect(){if(this.disposed)return;let e=++this.connectionGeneration;this.connectedOnce=!0;try{this.fit.fit()}catch{this.term.resize(80,24)}let t;try{if(t=typeof this.url==`function`?await this.url({cols:this.term.cols,rows:this.term.rows}):this.url,this.disposed||e!==this.connectionGeneration)return;let n=new URL(t);n.searchParams.set(`cols`,String(this.term.cols)),n.searchParams.set(`rows`,String(this.term.rows)),t=n.toString()}catch(t){if(this.disposed||e!==this.connectionGeneration)return;hW(t)?this.onState({kind:`closed`,code:1006,reason:`Terminal connection temporarily unavailable`}):this.onState({kind:`error`,message:t instanceof Error?t.message:`Could not prepare terminal connection`});return}let n;try{n=new WebSocket(t)}catch(t){if(this.disposed||e!==this.connectionGeneration)return;this.onState({kind:`error`,message:t instanceof Error?t.message:`Could not open terminal connection`});return}n.binaryType=`arraybuffer`,this.ws=n;let r=null;n.addEventListener(`open`,()=>{this.sendResize(),this.term.focus()},{signal:this.listenerCtl.signal}),n.addEventListener(`message`,e=>{if(e.data instanceof ArrayBuffer){this.writeOutput(new Uint8Array(e.data));return}if(typeof e.data!=`string`)return;let t=fW(e.data);t?.kind===`opened`?this.onState({kind:`connected`}):t?.kind===`error`&&(r=t.message,this.onState({kind:`error`,message:t.message}))},{signal:this.listenerCtl.signal}),n.addEventListener(`close`,e=>{this.ws===n&&(this.ws=null,this.dataDispose?.dispose(),this.dataDispose=null,(r===null||e.code!==4500)&&this.onState({kind:`closed`,reason:e.reason||`code ${e.code}`,code:e.code}))},{signal:this.listenerCtl.signal}),n.addEventListener(`error`,()=>{this.ws===n&&this.onState({kind:`error`,message:`Terminal WebSocket error`})},{signal:this.listenerCtl.signal}),this.dataDispose?.dispose(),this.dataDispose=this.term.onData(e=>{n.readyState===WebSocket.OPEN&&n.send(vW.encode(e))}),this.term.attachCustomKeyEventHandler(e=>{let t=_W(e);return t===null||(e.type===`keydown`&&(e.preventDefault(),n.readyState===WebSocket.OPEN&&n.send(vW.encode(t))),!1)}),this.term.attachCustomWheelEventHandler(e=>{let t=xW(e,{mouseTrackingMode:this.term.modes.mouseTrackingMode,sgrEncoding:this.sgrMouseEncodingActive()},this.screenMetrics(),this.wheelPartialLines);return this.wheelPartialLines=t.partial,!t.consume||(t.data&&this.term.input(t.data,!0),e.preventDefault(),!1)})}setTheme(){this.term.options.theme=uW()}focus(){this.term.focus()}dispose(){if(this.disposed)return;this.disposed=!0,this.connectionGeneration+=1,this.listenerCtl.abort(),this.resizeObserver.disconnect(),this.dataDispose?.dispose();let e=this.ws;this.ws=null;try{e?.close()}catch{}this.webgl?.dispose(),this.term.dispose()}writeOutput(e){this.term.write(e)}sgrMouseEncodingActive(){return this.term._core?.coreMouseService?.activeEncoding===`SGR`}screenMetrics(){let{cols:e,rows:t}=this.term,n=this.term.element?.querySelector(`.xterm-screen`)?.getBoundingClientRect();return!n||n.width<=0||n.height<=0||e<=0||t<=0?null:{left:n.left,top:n.top,cellWidth:n.width/e,cellHeight:n.height/t,cols:e,rows:t}}sendResize(){if(!(!this.layoutVisible||!this.ws||this.ws.readyState!==WebSocket.OPEN)){try{this.fit.fit()}catch{return}this.ws.send(JSON.stringify({t:`resize`,cols:this.term.cols,rows:this.term.rows}))}}},TW=[500,1e3,2e3,4e3,8e3];function EW({sessionId:e,runtimeSelector:t,active:n,role:r=`owner`,setup:i}){let[a,o]=(0,u.useState)({kind:`connecting`}),[s,c]=(0,u.useState)(0),[l,d]=(0,u.useState)(!1),[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(null),g=(0,u.useRef)(0),_=(0,u.useRef)(null),v=(0,u.useRef)(null),y=(0,u.useRef)(n),b=`${t}\u0000${e}`,x=(0,u.useRef)(b);x.current=b;let{theme:S}=Bj(),C=(0,u.useCallback)(e=>o(e),[]);(0,u.useEffect)(()=>{v.current?.setTheme()},[S]),(0,u.useEffect)(()=>{h(null),p(!1)},[b]);let w=(0,u.useCallback)(n=>{if(n===null)return;C({kind:`connecting`});let i=null,a=!1;return queueMicrotask(()=>{a||(i=new wW(n,({cols:n,rows:i})=>qx(t,e,{role:r,cols:n,rows:i,refreshCapability:!0}),C,r===`read-only`),v.current=i)}),()=>{a=!0,i?.dispose(),v.current=null}},[e,t,r,C]);(0,u.useEffect)(()=>{if(a.kind===`connected`){_.current=Date.now(),d(!1);return}if(a.kind!==`closed`)return;if(!pW(a.code)){d(!1);return}if(_.current!==null&&Date.now()-_.current>=3e4&&(g.current=0),_.current=null,g.current>=TW.length){d(!1);return}let e=TW[g.current];g.current+=1,d(!0);let t=!1,n=()=>{t||(t=!0,c(e=>e+1))},r=window.setTimeout(n,e),i=()=>{document.visibilityState===`visible`&&n()};return document.addEventListener(`visibilitychange`,i),()=>{window.clearTimeout(r),document.removeEventListener(`visibilitychange`,i)}},[a]);let T=(0,u.useCallback)(()=>{g.current=0,_.current=null,d(!1),c(e=>e+1)},[]);(0,u.useEffect)(()=>{let e=y.current;y.current=n,!e&&n&&v.current?.focus(),mW(e,n,a)&&(g.current=0,_.current=null,d(!1),a.kind===`closed`&&a.code===4404&&C({kind:`probing`}),c(e=>e+1))},[n,a,C]);let E=(0,u.useCallback)(async()=>{if(f)return;let n=b;p(!0),h(null);try{if(await Y.startSessionTerminal(t,e),x.current!==n)return;T()}catch(e){if(x.current!==n)return;h(e instanceof Error?e.message:`Could not start terminal`)}finally{x.current===n&&p(!1)}},[T,t,e,f,b]);return(0,H.jsx)(`div`,{"data-state":a.kind,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-[var(--card)]`,children:(0,H.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden p-1`,children:[(0,H.jsx)(`div`,{ref:w,className:`h-full w-full overflow-hidden`},s),a.kind!==`connected`&&(0,H.jsx)(DW,{state:a,reconnectPending:l,startingTerminal:f,startError:m,onRetry:T,onStartTerminal:()=>void E(),setup:i,readOnly:r===`read-only`})]})})}function DW({state:e,reconnectPending:t,startingTerminal:n,startError:r,onRetry:i,onStartTerminal:a,setup:o,readOnly:s}){return(0,H.jsxs)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-[var(--background)]/85 text-sm text-[var(--foreground)] backdrop-blur-[1px]`,children:[e.kind===`connecting`&&(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),`Connecting…`]}),e.kind===`closed`&&t&&(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),`Reconnecting…`]}),e.kind===`closed`&&!t&&(e.code===4404?(0,H.jsx)(OW,{starting:n,error:r,onStart:a,setup:o,readOnly:s}):(0,H.jsx)(kW,{message:e.reason||`Terminal connection closed`,onRetry:i})),e.kind===`probing`&&(0,H.jsxs)(`span`,{className:`flex items-center gap-2 text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),`Checking terminal…`]}),e.kind===`error`&&(0,H.jsx)(kW,{message:e.message,onRetry:i})]})}function OW({starting:e,error:t,onStart:n,setup:r,readOnly:i}){let a=r?.target??`Provider`,o=r?.kind===`delivery_unknown`?`Task delivery needs confirmation`:r?.kind===`required`?`${a} needs setup`:`Terminal is not running`,s=r?.kind===`delivery_unknown`?`Rynx could not confirm whether the queued task was accepted. Open the terminal and check its history before retrying.`:r?.kind===`required`?r.taskQueued?`Complete login or first-run setup. The queued task will start automatically when ${a} is ready.`:r.reason??`Complete ${a} login or first-run setup before starting this Session.`:`Start it when you need terminal access for this Session.`,c=r?.kind===`required`?`Open ${a} setup`:`Start terminal`;return(0,H.jsxs)(`div`,{className:`grid max-w-sm place-items-center gap-3 px-6 text-center`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:o}),(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:s})]}),t&&(0,H.jsx)(`span`,{className:`text-[var(--destructive)]`,children:t}),!i&&(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:e,onClick:n,children:[e?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Fr,{}),e?`Opening…`:c]})]})}function kW({message:e,onRetry:t}){return(0,H.jsxs)(`div`,{className:`grid max-w-sm place-items-center gap-3 px-6 text-center`,children:[(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:e}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,onClick:t,children:[(0,H.jsx)(zr,{}),` Retry`]})]})}function AW(e,t){return`${e}\u0000${t}`}function jW(e,t){return[...e.filter(e=>e.runtimeSelector===t.runtimeSelector&&e.key!==t.key),t].slice(-8)}function MW({selected:e,slot:t,visible:n}){let[r,i]=(0,u.useState)([]),[a,o]=(0,u.useState)(null);(0,u.useEffect)(()=>{e&&i(t=>{let n=t[t.length-1];return n&&NW(n,e)?t:jW(t,e)})},[e]);let s=e?jW(r,e):r;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{ref:o,className:`pointer-events-none invisible absolute inset-0 min-h-0 min-w-0 overflow-hidden`,"aria-hidden":`true`}),s.map(r=>(0,H.jsx)(PW,{entry:r,parkingHost:a,slot:e?.key===r.key?t:null,visible:e?.key===r.key&&n},r.key))]})}function NW(e,t){return e.key===t.key&&e.runtimeSelector===t.runtimeSelector&&e.sessionId===t.sessionId&&e.readOnly===t.readOnly&&e.setup?.kind===t.setup?.kind&&e.setup?.target===t.setup?.target&&(e.setup?.kind!==`required`||t.setup?.kind!==`required`||e.setup.taskQueued===t.setup.taskQueued&&e.setup.reason===t.setup.reason)}function PW({entry:e,parkingHost:t,slot:n,visible:r}){let i=(0,u.useRef)(null);if(i.current===null&&typeof document<`u`){let t=document.createElement(`div`);t.className=`flex h-full min-h-0 w-full min-w-0 flex-col`,t.dataset.warmTerminal=e.key,i.current=t}(0,u.useLayoutEffect)(()=>{let e=i.current,r=n??t;if(!(!e||!r))return r.appendChild(e),()=>e.remove()},[t,n]);let a=i.current;return a?(0,d.createPortal)((0,H.jsx)(EW,{sessionId:e.sessionId,runtimeSelector:e.runtimeSelector,active:r,role:e.readOnly?`read-only`:`owner`,setup:e.setup}),a,e.key):null}function FW(){let e=Rx(),t=e?.access===`read_only`,n=e?.scope===`single_session`?e.sessionId:void 0,r=!!n,i=nt(),{sessionId:a}=it(),{runtimeSelector:o,selectedRuntime:s}=xS(),{status:c,operation:l}=kS(),d=YT(c,l),[f,p]=(0,u.useState)([]),[m,h]=(0,u.useState)({providers:[],agents:[]}),[g,_]=(0,u.useState)(null),[v,y]=(0,u.useState)({permissionPreset:`default`}),[b,x]=(0,u.useState)([]),[S,C]=(0,u.useState)(null),[w,T]=(0,u.useState)(!0),[E,D]=(0,u.useState)(!0),[O,k]=(0,u.useState)(),[A,j]=(0,u.useState)(),[M,N]=(0,u.useState)(),[P,F]=(0,u.useState)(!0),[I,L]=(0,u.useState)(!1),[ee,te]=(0,u.useState)(!1),[ne,re]=(0,u.useState)(null),[R,ie]=(0,u.useState)(null),[ae,oe]=(0,u.useState)(!1),[se,ce]=(0,u.useState)(),[le,ue]=(0,u.useState)(),de=(0,u.useRef)(!1),fe=(0,u.useRef)(0),pe=(0,u.useRef)(0),me=(0,u.useRef)(0),he=(0,u.useRef)(0),ge=(0,u.useRef)(void 0),_e=(0,u.useRef)(o),ve=(0,u.useRef)(o),ye=(0,u.useRef)(d);ye.current=d;let be=(0,u.useRef)({selector:o});be.current.selector!==o&&(be.current={selector:o});let xe=be.current,Se=n??a??null,Ce=(0,u.useRef)(Se);(0,u.useEffect)(()=>{!n||a===n||i(zx(Ax(o,n)),{replace:!0})},[i,o,a,n]),(0,u.useEffect)(()=>()=>{he.current+=1},[]),(0,u.useEffect)(()=>{Ce.current!==Se&&(Ce.current=Se,he.current+=1)},[Se]);let we=(0,u.useCallback)(async(e=!1)=>{if(ye.current)return;let t=++fe.current;e&&F(!0);try{let e=await Y.listSessions(o);if(fe.current!==t)return;_e.current=o,p(e),N(void 0)}catch(e){if(fe.current!==t||ye.current)return;N(`Could not load sessions: ${e.message}`)}finally{fe.current===t&&F(!1)}},[o]);(0,u.useEffect)(()=>{ve.current!==o&&(ve.current=o,ge.current=void 0,me.current+=1,fe.current+=1,p([]),x([]),C(null),j(void 0),D(!0),N(void 0),F(!0))},[o]);let Te=(0,u.useCallback)(async()=>{if(e){x([]),C(null),j(void 0),D(!1);return}if(ye.current)return;let t=++me.current;D(!0),j(void 0);try{let e=await Y.listProjects(o);if(me.current!==t)return;x(e),C(t=>t&&e.some(e=>e.id===t)?t:null)}catch(e){if(me.current!==t||ye.current)return;x([]),C(null),j(`Could not load projects: ${e.message}`)}finally{me.current===t&&D(!1)}},[e,t,o]);(0,u.useEffect)(()=>{if(d){fe.current+=1,N(void 0),F(!1);return}we(!0);let e=setInterval(()=>void we(),4e3);return()=>clearInterval(e)},[we,d]);let Ee=(0,u.useCallback)(async()=>{if(e){h({providers:[],agents:[]}),_(null),k(void 0),T(!1);return}if(ye.current)return;let t=++pe.current;T(!0),k(void 0);try{let e;try{e=await Y.listSessionLaunchOptions(o)}catch(t){if(!(t instanceof Hx)||t.code!==`incompatible`&&t.code!==`method_not_found`)throw t;e=cE(await Y.listSessionAgentOptions(o))}if(pe.current!==t)return;let n=nE(o,typeof window>`u`?void 0:window.localStorage),r=tE(e,n);h(e),_(r),y(oE(r,e))}catch(e){if(pe.current!==t||ye.current)return;h({providers:[],agents:[]}),_(null),y({permissionPreset:`default`}),k(`Could not load launch options: ${e.message}`)}finally{pe.current===t&&T(!1)}},[e,t,o]);(0,u.useEffect)(()=>{if(d){pe.current+=1,k(void 0),T(!1);return}return h({providers:[],agents:[]}),_(null),y({permissionPreset:`default`}),T(!0),k(void 0),te(!1),ce(void 0),ue(void 0),Ee(),()=>{pe.current+=1}},[Ee,d]),(0,u.useEffect)(()=>{if(d){me.current+=1,j(void 0),D(!1);return}return x([]),C(null),D(!0),j(void 0),Te(),()=>{me.current+=1}},[Te,d]);let De=(0,u.useCallback)(async e=>{if(de.current)return!1;let t=e.text,n=g;if(!n)return k(`Choose a provider or Agent before starting.`),!1;let r=dE(n,m);if(!r)return k(`Choose a provider or Agent before starting.`),!1;let a=!r.ready&&r.readiness!==`unverified`;if(a&&e.attachments.length>0)return k(`${r.name} must finish login or first-run setup before starting with files.`),!1;let o=be.current,c=s.displayName,l=++he.current,u=sE(t||e.attachments[0]?.file.name||`File`),d;de.current=!0,oe(!0),k(void 0);try{let s=ge.current,f=s&&s.selector===o.selector&&s.selection.kind===n.kind&&s.selection.id===n.id&&s.projectId===S&&s.configuration.model===v.model&&s.configuration.reasoningEffort===v.reasoningEffort&&s.configuration.permissionPreset===v.permissionPreset?s.sessionId:(await Y.createSession(aE(n,u,S??void 0,v),o.selector)).sessionId;if(d=f,ge.current={selector:o.selector,selection:n,projectId:S,configuration:{...v},sessionId:f},!a&&e.attachments.length===0){let e=new Date().toISOString(),r=n.kind===`agent`?m.agents.find(e=>e.id===n.id)?.runtime:void 0,a=n.kind===`provider`?n.id:IW(r)?r:void 0,s={id:f,...a?{provider:a}:{},title:u,status:`running`,createdAt:e,updatedAt:e,source:`console`};return _e.current=o.selector,p(e=>[s,...e.filter(e=>e.id!==f)]),ue({sessionId:f,message:t,started:!1}),te(!1),ge.current=void 0,i(zx(Ax(o.selector,f))),!0}let h,g=!1,_=!1;if(a)try{await Y.enqueueSessionMessage(o.selector,f,t),g=!0}catch(e){h=e}else try{if(!(await Y.getSessionResourcePolicy(o.selector,f)).enabled)throw new Hx(`Session file resources are unavailable on this Runtime`,409,`failed_precondition`,`not_started`);let n=await Promise.all(e.attachments.map(e=>Y.uploadSessionResource(o.selector,f,e.file,e.clientUploadId,e.type)));_=!0,await Y.sendSessionMessage(f,{content:[...n.map(e=>e.type===`input_image`?{type:e.type,resourceId:e.resourceId,mediaType:e.mediaType,filename:e.filename,byteLength:e.byteLength,width:e.width,height:e.height}:{type:e.type,resourceId:e.resourceId,mediaType:e.mediaType,filename:e.filename,byteLength:e.byteLength}),...t?[{type:`input_text`,text:t}]:[]],clientMessageId:e.clientMessageId},()=>{},void 0,o.selector)}catch(e){h=e}let y=!!(!g&&(e.attachments.length>0&&!_&&h||Ux(h)));if(be.current!==o)return ge.current=void 0,h?y?V.error(`Session created on ${c}, but the first message was not sent: ${h.message}`):V.warning(`Session created on ${c}, but message delivery is unknown. Check its history before retrying.`):V.success(`Session started on ${c}; switch back to view it.`),!0;if(he.current!==l)return ge.current=void 0,h?y?V.error(`Session created on ${c}, but the first message was not sent. Open it to retry.`):V.warning(`Session created on ${c}, but message delivery is unknown. Check its history before retrying.`):V.success(`Session started on ${c} in the background.`),!0;if(e.attachments.length>0&&y)return k(`Session created, but the first file message was not sent: ${h.message}. Retry will reuse this Session.`),we(),!1;let b=new Date().toISOString(),x={id:f,...n.kind===`provider`?{provider:n.id}:{agent:n.id},title:u,status:y?`idle`:`running`,createdAt:b,updatedAt:b,source:`console`,...g?{setupStatus:`waiting_for_provider`}:{}};return _e.current=o.selector,p(e=>[x,...e.filter(e=>e.id!==f)]),ce(y?{sessionId:f,message:t}:void 0),te(!1),ge.current=void 0,i(zx(g?`${Ax(o.selector,f)}?view=terminal`:Ax(o.selector,f))),we(),g?V.info(`${r.name} needs setup. The task is queued and will start automatically when the Provider is ready.`):h&&(y?V.error(`Session created, but the first message was not sent: ${h.message}`):V.warning(`Session created, but message delivery is unknown. Check its history before retrying.`)),!0}catch(e){let t=e instanceof Hx&&e.outcome===`unknown`,n=d?`Session created, but its first message was not sent: ${e.message}. Retry will reuse this Session.`:t?`Session creation outcome is unknown. Check the Session list before retrying.`:`Could not start session: ${e.message}`;return be.current===o&&he.current===l?k(n):t?V.warning(`Session creation on ${c} may have succeeded. Check its Session list before retrying.`):V.error(`Could not start Session on ${c}: ${e.message}`),!d&&t?(ge.current=void 0,!0):!1}finally{de.current=!1,oe(!1)}},[m,v,g,i,S,we,s.displayName]),Oe=_e.current===o?f:[],ke=Oe.find(e=>e.id===Se)??null,Ae=ke?dE(ke.provider?{kind:`provider`,id:ke.provider}:ke.agent?{kind:`agent`,id:ke.agent}:null,m):null,je=ke?.setupStatus===`delivery_unknown`?{kind:`delivery_unknown`,target:Ae?.name??(ke.provider?uE(ke.provider):ke.agent)}:ke&&(ke.setupStatus===`waiting_for_provider`||Ae?.ready===!1)?{kind:`required`,target:Ae?.name??(ke.provider?uE(ke.provider):ke.agent),taskQueued:ke.setupStatus===`waiting_for_provider`,...Ae?.reason?{reason:Ae.reason}:{}}:void 0;(0,u.useEffect)(()=>{se?.sessionId===ke?.id&&ce(void 0)},[se,ke?.id]);let Me=ke&&!r?(0,H.jsxs)(`div`,{className:X(`flex shrink-0 items-center gap-1`,I&&`desktop-macos-titlebar-leading-inset`),children:[(0,H.jsx)(J,{variant:`ghost`,size:`icon`,className:`size-10 md:hidden`,title:`Back to sessions`,"aria-label":`Back to sessions`,onClick:()=>{te(!0),i(zx(jx(o)),{replace:!0})},children:(0,H.jsx)(An,{})}),I&&(0,H.jsx)(J,{variant:`ghost`,size:`icon-sm`,className:`-ml-1 hidden md:inline-flex`,title:`Show session list`,"aria-label":`Show session list`,onClick:()=>L(!1),children:(0,H.jsx)(Ar,{className:`size-3.5`})})]}):void 0,Ne=(0,u.useCallback)((e,t)=>{ie(n=>t?e:n===e?null:n)},[]),Pe=ke?{key:AW(o,ke.id),runtimeSelector:o,sessionId:ke.id,readOnly:!!t,setup:je}:null;return(0,H.jsxs)(`div`,{className:X(`grid h-full min-h-0 min-w-0 bg-[var(--background)]`,r||I?`grid-cols-[minmax(0,1fr)]`:`md:grid-cols-[14rem_minmax(0,1fr)]`),children:[!r&&!I&&(0,H.jsx)(`div`,{className:X(`min-h-0 min-w-0 border-r border-[var(--border)]`,(!ee||ke)&&`hidden md:block`),children:(0,H.jsx)(Oj,{sessions:Oe,runtimeSelector:o,runtimeLabel:s.displayName,listError:M,loading:P,selectedId:Se,readOnly:!!e,onCollapsedChange:L,onSelect:e=>{he.current+=1,ge.current=void 0,te(!1),ce(void 0),i(zx(Ax(o,e)))},onNew:()=>{he.current+=1,ge.current=void 0,te(!1),ce(void 0),ue(void 0),i(zx(jx(o)))},onRetry:()=>void we(!0),onFork:async e=>{try{let t=await Y.forkSession(o,e,{operationId:`web_${crypto.randomUUID()}`});if(be.current!==xe)return;await we(),te(!1),i(zx(Ax(o,t.sessionId))),V.success(`Session forked`)}catch(e){V.error(`Fork session failed: ${e instanceof Error?e.message:String(e)}`)}},onDeleted:e=>{be.current===xe&&(Se===e&&i(zx(jx(o)),{replace:!0}),we())}},o)}),(0,H.jsxs)(`div`,{className:`relative min-h-0 min-w-0 overflow-hidden`,children:[ke?(0,H.jsx)(xj,{session:ke,runtimeSelector:o,readOnly:t,leadingControls:Me,initialDraft:se?.sessionId===ke.id?se.message:void 0,initialMessage:le?.sessionId===ke.id?le.message:void 0,sendInitialMessage:le?.sessionId===ke.id&&!le.started,onInitialMessageStarted:()=>{ue(e=>e?.sessionId===ke.id?{...e,started:!0}:e)},onInitialMessageConsumed:()=>{ue(e=>e?.sessionId===ke.id?void 0:e)},onInitialMessageFailed:e=>{ue(e=>e?.sessionId===ke.id?void 0:e),ce({sessionId:ke.id,message:e})},terminalSlotRef:re,onTerminalActiveChange:Ne},`${o}:${ke.id}`):Se&&P?(0,H.jsx)(`div`,{className:`grid h-full min-h-0 min-w-0 place-items-center`,role:`status`,"aria-live":`polite`,children:(0,H.jsxs)(`span`,{className:`flex items-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),` Loading session…`]})}):e?(0,H.jsx)(`div`,{className:`grid h-full min-h-0 min-w-0 place-items-center px-6 text-center text-sm text-[var(--muted-foreground)]`,children:Se?`Session not found.`:`Choose a Session from the list.`}):(0,H.jsx)(`div`,{className:X(`h-full min-h-0 min-w-0`,ee&&!I&&`hidden md:block`),children:(0,H.jsx)(Pj,{runtimeLabel:s.displayName,options:m,selection:g,configuration:v,projects:b,projectId:S,loading:w,projectsLoading:E,submitting:ae,error:O??M??(Se?`Session not found. Start a new session or choose another from the list.`:void 0),projectError:A,listCollapsed:I,onShowSessions:()=>{he.current+=1,L(!1),te(!0)},onRetryOptions:()=>{Ee()},onSelectionChange:e=>{ge.current=void 0,_(e),y(t=>oE(e,m,t.permissionPreset)),k(void 0),rE(o,typeof window>`u`?void 0:window.localStorage,e)},onConfigurationChange:e=>{ge.current=void 0,y(e),k(void 0)},onProjectChange:e=>{ge.current=void 0,C(e),k(void 0)},onNewProject:()=>{i(px.projects,{state:{returnTo:jx(o),createProject:!0}})},onSubmit:De},o)}),(0,H.jsx)(MW,{selected:Pe,slot:ne,visible:R===ke?.id})]})]})}function IW(e){return e===`codex`||e===`claude`||e===`traex`}function LW(){let[e,t]=(0,u.useState)(null),[n,r]=(0,u.useState)(``),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(``),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(!1),[_,v]=(0,u.useState)(!1);async function y(){try{let e=await Y.listSkills();t(e),r(t=>e.some(e=>e.name===t)?t:e[0]?.name??``)}catch(e){t([]),V.error(`Failed to load Skills: ${e.message}`)}}(0,u.useEffect)(()=>{y()},[]),(0,u.useEffect)(()=>{if(!n){a(null);return}let e=!1;return s(!0),Y.getSkill(n).then(t=>{e||(a(t),l((t.files.find(e=>e.path===`SKILL.md`)??t.files[0])?.path??``))}).catch(t=>!e&&V.error(`Load Skill failed: ${t.message}`)).finally(()=>!e&&s(!1)),()=>{e=!0}},[n]),(0,u.useEffect)(()=>{if(!n||!c){f(``);return}let e=!1;return m(!0),Y.readSkillFile(n,c).then(t=>!e&&f(t.content)).catch(t=>!e&&f(`⚠ ${t.message}`)).finally(()=>!e&&m(!1)),()=>{e=!0}},[c,n]);let b=e?.filter(e=>{let t=e.ref?.install.tool===`skills-cli`?e.ref.install.source:``;return t.includes(`/artifacts/skills/`)||t.includes(`\\artifacts\\skills\\`)}).length??0;return(0,H.jsxs)(`div`,{className:`grid gap-5`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Skills`}),(0,H.jsxs)(`p`,{className:`mt-1 text-sm text-[var(--muted-foreground)]`,children:[`Local catalog discovered from `,(0,H.jsx)(`code`,{children:`~/.rynx/skills`}),`.`]})]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(J,{variant:`outline`,onClick:()=>void y(),children:[(0,H.jsx)(zr,{}),` Refresh`]}),(0,H.jsx)(KS,{onInstalled:e=>{t(e),r(e[0]?.name??``)},triggerLabel:`From URL`,triggerVariant:`outline`}),(0,H.jsxs)(J,{variant:`outline`,onClick:()=>v(!0),children:[(0,H.jsx)(tr,{}),` From ZIP`]}),(0,H.jsxs)(J,{onClick:()=>g(!0),children:[(0,H.jsx)(Dr,{}),` From runtime`]})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,H.jsx)(GW,{label:`skills`,value:e?.length??0,detail:`Registered catalog entries`}),(0,H.jsx)(GW,{label:`local imports`,value:b,detail:`Immutable runtime copies`}),(0,H.jsx)(GW,{label:`selectable`,value:e?.filter(e=>e.ref).length??0,detail:`Skills with a valid receipt`})]}),(0,H.jsxs)(`div`,{className:`grid min-h-[640px] gap-4 lg:grid-cols-[320px_minmax(0,1fr)]`,children:[(0,H.jsxs)(fC,{className:`overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--border)] px-4 py-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Skill list`}),(0,H.jsx)(`span`,{className:`text-xs text-[var(--muted-foreground)]`,children:e?.length??0})]}),(0,H.jsxs)(`div`,{className:`grid gap-2 p-2`,children:[e===null&&(0,H.jsx)(`div`,{className:`px-3 py-6 text-sm text-[var(--muted-foreground)]`,children:`Loading Skills…`}),e?.length===0&&(0,H.jsx)(`div`,{className:`rounded-lg border border-dashed border-[var(--border)] px-4 py-6 text-sm text-[var(--muted-foreground)]`,children:`No local Skills registered yet.`}),e?.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>r(e.name),className:X(`flex w-full items-start gap-3 rounded-lg border px-3 py-3 text-left transition-colors`,n===e.name?`border-[var(--primary)] bg-[var(--primary)]/10`:`border-[var(--border)] hover:bg-[var(--muted)]/45`),children:[(0,H.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-md bg-amber-500/10 text-amber-600`,children:(0,H.jsx)(nr,{className:`size-4`})}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate font-mono text-sm font-semibold`,children:e.name}),n===e.name&&(0,H.jsx)(Ln,{className:`size-4 shrink-0 text-[var(--primary)]`})]}),(0,H.jsx)(`span`,{className:`mt-1 block line-clamp-2 text-xs text-[var(--muted-foreground)]`,children:e.description}),(0,H.jsx)(`span`,{className:`mt-2 inline-block rounded bg-[var(--muted)] px-1.5 py-1 text-[10px] text-[var(--muted-foreground)]`,children:e.ref?HW(e):`receipt-less`})]})]},e.name))]})]}),(0,H.jsx)(zW,{detail:i,loading:o,activeFile:c,onSelectFile:l,fileContent:d,fileLoading:p,onDeleted:y})]}),(0,H.jsx)(BW,{open:h,onOpenChange:g,onImported:async e=>{await y(),e&&r(e)}}),(0,H.jsx)(RW,{open:_,onOpenChange:v,onImported:async e=>{await y(),e&&r(e)}})]})}function RW({open:e,onOpenChange:t,onImported:n}){let[r,i]=(0,u.useState)(null),[a,o]=(0,u.useState)(!1),[s,c]=(0,u.useState)([]),l=r&&(!r.name.toLowerCase().endsWith(`.zip`)||r.size>20971520);async function d(){if(!(!r||l)){o(!0),c([]);try{let e=await Y.importSkillArchive(r.name,await WW(r));c(e);let t=e.find(e=>e.status===`created`||e.status===`updated`)?.name;await n(t)}catch(e){V.error(`Import ZIP failed: ${e.message}`)}finally{o(!1)}}}return(0,H.jsx)(Su,{open:e,onOpenChange:e=>{t(e),e||(i(null),c([]))},children:(0,H.jsxs)(Du,{className:`sm:max-w-xl`,children:[(0,H.jsx)(Ou,{children:(0,H.jsx)(Au,{children:`Import Skills from ZIP`})}),(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`label`,{className:`grid cursor-pointer place-items-center gap-2 rounded-lg border border-dashed border-[var(--border)] px-4 py-8 text-center hover:bg-[var(--muted)]/30`,children:[(0,H.jsx)(`input`,{type:`file`,accept:`.zip,application/zip`,className:`sr-only`,onChange:e=>{i(e.target.files?.[0]??null),c([])}}),(0,H.jsx)(tr,{className:`size-6 text-[var(--primary)]`}),(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:r?.name??`Choose a .zip archive`}),(0,H.jsx)(`span`,{className:`text-xs text-[var(--muted-foreground)]`,children:`One Skill at the root or multiple Skill directories, up to 20 MB.`})]}),l&&(0,H.jsx)(`div`,{className:`text-xs text-[var(--destructive)]`,children:`Choose a .zip archive no larger than 20 MB.`}),s.length>0&&(0,H.jsx)(UW,{results:s})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:`Done`}),(0,H.jsx)(J,{disabled:!r||!!l||a,onClick:()=>void d(),children:a?`Importing…`:`Import`})]})]})})}function zW({detail:e,loading:t,activeFile:n,onSelectFile:r,fileContent:i,fileLoading:a,onDeleted:o}){if(t||!e)return(0,H.jsx)(fC,{className:`p-6 text-sm text-[var(--muted-foreground)]`,children:t?`Loading Skill…`:`Select a Skill to inspect its files.`});let s=pk(e.ref?.install);return(0,H.jsxs)(fC,{className:`overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-[var(--border)] px-5 py-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`font-mono text-lg font-semibold`,children:e.name}),(0,H.jsx)(`span`,{className:`rounded bg-[var(--muted)] px-2 py-1 text-[10px] text-[var(--muted-foreground)]`,children:HW(e)})]}),(0,H.jsx)(`p`,{className:`mt-2 text-sm text-[var(--muted-foreground)]`,children:e.description}),s.source&&(0,H.jsx)(`div`,{className:`mt-2 max-w-2xl truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:s.source})]}),(0,H.jsx)(VW,{name:e.name,onDeleted:o})]}),(0,H.jsxs)(`div`,{className:`grid min-h-[500px] lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,H.jsxs)(`div`,{className:`border-b border-[var(--border)] p-3 lg:border-b-0 lg:border-r`,children:[(0,H.jsxs)(`div`,{className:`label-caps mb-2 px-1 text-[10px] text-[var(--muted-foreground)]`,children:[`files · `,e.files.length]}),(0,H.jsx)(`div`,{className:`grid gap-1`,children:e.files.map(e=>(0,H.jsxs)(`button`,{onClick:()=>r(e.path),className:X(`flex items-center gap-2 rounded-md px-2 py-2 text-left text-xs`,n===e.path?`bg-[var(--primary)]/10 text-[var(--primary)]`:`hover:bg-[var(--muted)]/50`),children:[(0,H.jsx)(nr,{className:`size-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.path}),(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--muted-foreground)]`,children:KW(e.size)})]},e.path))})]}),(0,H.jsxs)(`div`,{className:`min-w-0 p-4`,children:[(0,H.jsx)(`div`,{className:`mb-3 truncate font-mono text-xs text-[var(--muted-foreground)]`,children:n||`No file selected`}),(0,H.jsx)(`pre`,{className:`min-h-[440px] overflow-auto whitespace-pre-wrap break-words rounded-lg border border-[var(--border)] bg-[var(--muted)]/25 p-4 font-mono text-xs leading-5`,children:a?`Loading…`:i})]})]})]})}function BW({open:e,onOpenChange:t,onImported:n}){let[r,i]=(0,u.useState)([]),[a,o]=(0,u.useState)(``),[s,c]=(0,u.useState)([]),[l,d]=(0,u.useState)(new Set),[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)([]);(0,u.useEffect)(()=>{if(!e)return;let t=!1;return Y.listAgentRuntimeOptions().then(e=>{if(t)return;i(e);let n=e.find(e=>e.available)??e[0];o(n?.id??``)}).catch(e=>!t&&V.error(`Load runtimes failed: ${e.message}`)),()=>{t=!0}},[e]);function v(){c([]),d(new Set),_([]),p(!1),h(!1)}async function y(){if(a){p(!0),c([]),d(new Set),_([]);try{let e=await Y.scanLocalSkills(a);c(e)}catch(e){V.error(`Scan local Skills failed: ${e.message}`)}finally{p(!1)}}}async function b(){if(!(!a||l.size===0)){h(!0);try{let e=await Y.importLocalSkills(a,[...l]);_(e);let t=e.find(e=>e.status===`created`||e.status===`updated`)?.name;await n(t),V.success(`Local Skill import finished: ${e.filter(e=>e.status===`created`||e.status===`updated`).length} changed`)}catch(e){V.error(`Import local Skills failed: ${e.message}`)}finally{h(!1)}}}let x=s.length>0&&s.every(e=>l.has(e.key));return(0,H.jsx)(Su,{open:e,onOpenChange:e=>{t(e),e||v()},children:(0,H.jsxs)(Du,{className:`sm:max-w-3xl`,children:[(0,H.jsx)(Ou,{children:(0,H.jsx)(Au,{children:`Import Skills from a local runtime`})}),(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto_auto]`,children:[(0,H.jsxs)(my,{value:a,onValueChange:e=>{o(e),v()},disabled:r.length===0,children:[(0,H.jsx)(_y,{children:(0,H.jsx)(gy,{placeholder:`No local runtime found`})}),(0,H.jsx)(by,{children:r.map(e=>(0,H.jsxs)(Sy,{value:e.id,children:[e.name,e.version?` · ${e.version}`:``,e.available?``:` · CLI missing`]},e.id))})]}),(0,H.jsxs)(J,{variant:`outline`,disabled:!a||f,onClick:()=>void y(),children:[(0,H.jsx)(zr,{className:f?`animate-spin`:``}),` Scan`]}),(0,H.jsxs)(J,{variant:`outline`,disabled:s.length===0,onClick:()=>d(x?new Set:new Set(s.map(e=>e.key))),children:[(0,H.jsx)(Pn,{}),` `,x?`Clear`:`All`]})]}),(0,H.jsxs)(`div`,{className:`max-h-80 overflow-y-auto rounded-lg border border-[var(--border)]`,children:[f&&(0,H.jsx)(`div`,{className:`px-4 py-6 text-sm text-[var(--muted-foreground)]`,children:`Scanning local runtime Skill roots…`}),!f&&s.length===0&&(0,H.jsx)(`div`,{className:`px-4 py-6 text-sm text-[var(--muted-foreground)]`,children:`Choose a runtime family and click Scan. The local Skill directory can be scanned even when its CLI is missing.`}),!f&&s.map(e=>(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 border-b border-[var(--border)] px-4 py-3 last:border-0 hover:bg-[var(--muted)]/40`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-4`,checked:l.has(e.key),onChange:()=>d(t=>{let n=new Set(t);return n.has(e.key)?n.delete(e.key):n.add(e.key),n})}),(0,H.jsx)(ur,{className:`mt-0.5 size-4 shrink-0 text-[var(--primary)]`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.name}),(0,H.jsx)(`span`,{className:`rounded bg-[var(--muted)] px-1.5 py-1 text-[10px] text-[var(--muted-foreground)]`,children:e.root}),(0,H.jsxs)(`span`,{className:`rounded bg-[var(--muted)] px-1.5 py-1 text-[10px] text-[var(--muted-foreground)]`,children:[e.fileCount,` files`]})]}),(0,H.jsx)(`span`,{className:`mt-1 block text-xs text-[var(--muted-foreground)]`,children:e.description}),(0,H.jsx)(`span`,{className:`mt-1 block truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:e.sourcePath})]})]},e.key))]}),g.length>0&&(0,H.jsx)(`div`,{className:`max-h-44 overflow-y-auto rounded-lg border border-[var(--border)]`,children:g.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-[var(--border)] px-4 py-3 text-sm last:border-0`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`font-mono font-medium`,children:e.name}),e.message&&(0,H.jsx)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:e.message})]}),(0,H.jsx)(`span`,{className:X(`rounded px-2 py-1 text-xs`,e.status===`failed`||e.status===`conflict`?`bg-red-500/10 text-red-600`:e.status===`skipped`?`bg-[var(--muted)] text-[var(--muted-foreground)]`:`bg-emerald-500/10 text-emerald-600`),children:e.status})]},`${e.name}-${t}`))})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:`Done`}),(0,H.jsx)(J,{disabled:l.size===0||m,onClick:()=>void b(),children:m?`Importing…`:`Import ${l.size||``}`})]})]})})}function VW({name:e,onDeleted:t}){return(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsxs)(J,{variant:`ghost`,size:`sm`,className:`text-[var(--destructive)]`,children:[(0,H.jsx)(si,{}),` Remove`]})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[`Remove Skill "`,e,`"?`]}),(0,H.jsx)(yu,{children:`Removes the current catalog registration. Immutable artifacts referenced by existing Agents are preserved.`})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:async()=>{try{await Y.deleteSkill(e),V.success(`Skill "${e}" removed`),await t()}catch(e){V.error(`Remove failed: ${e.message}`)}},children:`Remove`})]})]})]})}function HW(e){let t=e.ref?.install.tool===`skills-cli`?e.ref.install.source:``;return t.includes(`/artifacts/skills/`)||t.includes(`\\artifacts\\skills\\`)?`local runtime`:e.ref?.install.tool===`command`?e.ref.install.command:t?`URL / repository`:`receipt-less`}function UW({results:e}){return(0,H.jsx)(`div`,{className:`max-h-44 overflow-y-auto rounded-lg border border-[var(--border)]`,children:e.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-[var(--border)] px-4 py-3 text-sm last:border-0`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`font-mono font-medium`,children:e.name}),e.message&&(0,H.jsx)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:e.message})]}),(0,H.jsx)(`span`,{className:X(`rounded px-2 py-1 text-xs`,e.status===`failed`||e.status===`conflict`?`bg-red-500/10 text-red-600`:e.status===`skipped`?`bg-[var(--muted)] text-[var(--muted-foreground)]`:`bg-emerald-500/10 text-emerald-600`),children:e.status})]},`${e.name}-${t}`))})}function WW(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`File read failed`)),r.onload=()=>{let e=String(r.result??``);t(e.includes(`,`)?e.slice(e.indexOf(`,`)+1):e)},r.readAsDataURL(e)})}function GW({label:e,value:t,detail:n}){return(0,H.jsxs)(fC,{className:`p-4`,children:[(0,H.jsx)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:e}),(0,H.jsx)(`div`,{className:`mt-2 text-2xl font-semibold`,children:t}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:n})]})}function KW(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function qW(e){return e.daemonBuild?.restartRequired??!0}function JW(){let e=wS();return e?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(PS,{bridge:e,children:(0,H.jsx)(YW,{desktopIntegrationAvailable:!0})}),(0,H.jsx)(zS,{bridge:e})]}):(0,H.jsx)(YW,{desktopIntegrationAvailable:!1})}function YW({desktopIntegrationAvailable:e}){let t=Rx(),{theme:n,toggle:r}=Bj(),i=$e(),a=Ex(i.pathname,e),o=(0,u.useRef)(null),[s,c]=(0,u.useState)([]),[l,d]=(0,u.useState)([]),[f,p]=(0,u.useState)(!1),m=(0,u.useCallback)(async()=>{try{c(await Y.listAgents())}catch(e){V.error(`Failed to load agents: ${e.message}`)}},[]),h=(0,u.useCallback)(async()=>{let e=await Promise.allSettled([Y.listPlugins(),Y.listAgents()]);e[0].status===`fulfilled`&&d(e[0].value),e[1].status===`fulfilled`&&c(e[1].value)},[]);(0,u.useEffect)(()=>{a&&a!==`emulator`&&h()},[h,a]),(0,u.useEffect)(()=>{if(t)return;let e=!0,n=async()=>{try{let t=await Y.meta();e&&p(qW(t))}catch{}};n();let r=window.setInterval(()=>void n(),15e3);return()=>{e=!1,window.clearInterval(r)}},[t]),(0,u.useEffect)(()=>{let e=window.requestAnimationFrame(()=>o.current?.focus({preventScroll:!0}));return()=>window.cancelAnimationFrame(e)},[i.pathname]);let g=ot([{path:`/`,element:(0,H.jsx)(Et,{replace:!0,to:px.sessions})},{path:mx,element:(0,H.jsx)(Et,{replace:!0,to:hx})},{path:px.overview,element:(0,H.jsx)(Rw,{plugins:l,agents:s,desktopIntegrationAvailable:e})},{path:px.runtimes,element:(0,H.jsx)(IT,{})},{path:px.providers,element:(0,H.jsx)(TT,{})},{path:px.projects,element:(0,H.jsx)(_T,{})},{path:px.plugins,element:(0,H.jsx)(Jw,{plugins:l,theme:n,onChange:h})},{path:px.agents,element:(0,H.jsx)(CC,{agents:s,onChange:m})},{path:px.skills,element:(0,H.jsx)(LW,{})},{path:gx,element:(0,H.jsx)(FW,{})},{path:_x,element:(0,H.jsx)(FW,{})},{path:px.sessions,element:(0,H.jsx)(FW,{})},{path:`${px.sessions}/:sessionId`,element:(0,H.jsx)(XW,{})},{path:px.emulator,element:(0,H.jsx)(ww,{})},...e?[{path:px.localRuntime,element:(0,H.jsx)(jw,{})},{path:px.computerUse,element:(0,H.jsx)(WC,{})}]:Sx.map(e=>({path:px[e],element:(0,H.jsx)(Et,{replace:!0,to:hx})})),...Object.entries(bx).map(([e,t])=>({path:t,element:(0,H.jsx)(Et,{replace:!0,to:px[e]})})),...Object.entries(xx).map(([e,t])=>({path:e,element:(0,H.jsx)(Et,{replace:!0,to:t})})),{path:`*`,element:(0,H.jsx)(Et,{replace:!0,to:px.sessions})}]);return(0,H.jsx)(MS,{theme:n,onToggleTheme:r,children:(0,H.jsxs)(`div`,{ref:o,id:`main-content`,tabIndex:-1,className:`flex h-full min-h-0 flex-col overflow-hidden focus:outline-none`,children:[f&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-start gap-2 border-b border-[color-mix(in_srgb,var(--warning)_35%,var(--border))] bg-[color-mix(in_srgb,var(--warning)_8%,var(--background))] px-4 py-2 text-xs text-[var(--warning)]`,children:[(0,H.jsx)(ci,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}),e?(0,H.jsxs)(`span`,{children:[`The local Runtime is running an older build. Restart it from`,` `,(0,H.jsx)(`strong`,{children:`Settings → Local Runtime`}),`, then reload this page.`]}):(0,H.jsxs)(`span`,{children:[`The resident daemon is running an older build. Run`,` `,(0,H.jsx)(`code`,{className:`font-mono font-semibold`,children:`rynx restart`}),`, then reload this page.`]})]}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:a?(0,H.jsx)(VS,{activeView:a,desktopIntegrationAvailable:e,children:g}):g})]})})}function XW(){let{sessionId:e}=it(),t=$e();if(!e)return(0,H.jsx)(Et,{replace:!0,to:px.sessions});let n=Ox(t.search)??`local`;return(0,H.jsx)(Et,{replace:!0,to:Ax(n,e)})}function ZW(e){let{theme:t}=Bj();return(0,H.jsx)(Vi,{theme:t,...e})}window.rynxDesktopIntegration?.platform===`darwin`&&(document.documentElement.dataset.rynxDesktopPlatform=`macos`),(0,f.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(u.StrictMode,{children:(0,H.jsx)(pn,{children:(0,H.jsx)(bS,{children:(0,H.jsxs)(OS,{children:[(0,H.jsx)(JW,{}),(0,H.jsx)(ZW,{richColors:!0,position:`top-right`})]})})})}));export{iu as a,z as c,r as d,X as i,g as l,mA as n,Mc as o,fA as r,Ui as s,pA as t,s as u};
|
|
137
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),wV&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=qV(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,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=cV(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-JV),JV),t/=JV,t/Math.abs(t)+Math.round(t*(YV-1)))}shouldForceSelection(e){return bV?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(),XV)}_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&&!(bV&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.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<ZV&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=NV(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=qV(n,this._bufferService.cols)}};$V=_I([Z(3,WI),Z(4,KI),Z(5,iL),Z(6,XI),Z(7,aL),Z(8,rL)],$V);var eH=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},tH=class{constructor(){this._color=new eH,this._css=new eH}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},nH=Object.freeze((()=>{let e=[AB.toColor(`#2e3436`),AB.toColor(`#cc0000`),AB.toColor(`#4e9a06`),AB.toColor(`#c4a000`),AB.toColor(`#3465a4`),AB.toColor(`#75507b`),AB.toColor(`#06989a`),AB.toColor(`#d3d7cf`),AB.toColor(`#555753`),AB.toColor(`#ef2929`),AB.toColor(`#8ae234`),AB.toColor(`#fce94f`),AB.toColor(`#729fcf`),AB.toColor(`#ad7fa8`),AB.toColor(`#34e2e2`),AB.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:OB.toCss(r,i,a),rgba:OB.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:OB.toCss(n,n,n),rgba:OB.toRgba(n,n,n)})}return e})()),rH=AB.toColor(`#ffffff`),iH=AB.toColor(`#000000`),aH=AB.toColor(`#ffffff`),oH=iH,sH={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},cH=rH,lH=class extends NL{constructor(e){super(),this._optionsService=e,this._contrastCache=new tH,this._halfContrastCache=new tH,this._onChangeColors=this._register(new Q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:rH,background:iH,cursor:aH,cursorAccent:oH,selectionForeground:void 0,selectionBackgroundTransparent:sH,selectionBackgroundOpaque:kB.blend(iH,sH),selectionInactiveBackgroundTransparent:sH,selectionInactiveBackgroundOpaque:kB.blend(iH,sH),scrollbarSliderBackground:kB.opacity(rH,.2),scrollbarSliderHoverBackground:kB.opacity(rH,.4),scrollbarSliderActiveBackground:kB.opacity(rH,.5),overviewRulerBorder:rH,ansi:nH.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=uH(e.foreground,rH),t.background=uH(e.background,iH),t.cursor=kB.blend(t.background,uH(e.cursor,aH)),t.cursorAccent=kB.blend(t.background,uH(e.cursorAccent,oH)),t.selectionBackgroundTransparent=uH(e.selectionBackground,sH),t.selectionBackgroundOpaque=kB.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=uH(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=kB.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?uH(e.selectionForeground,DB):void 0,t.selectionForeground===DB&&(t.selectionForeground=void 0),kB.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=kB.opacity(t.selectionBackgroundTransparent,.3)),kB.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=kB.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=uH(e.scrollbarSliderBackground,kB.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=uH(e.scrollbarSliderHoverBackground,kB.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=uH(e.scrollbarSliderActiveBackground,kB.opacity(t.foreground,.5)),t.overviewRulerBorder=uH(e.overviewRulerBorder,cH),t.ansi=nH.slice(),t.ansi[0]=uH(e.black,nH[0]),t.ansi[1]=uH(e.red,nH[1]),t.ansi[2]=uH(e.green,nH[2]),t.ansi[3]=uH(e.yellow,nH[3]),t.ansi[4]=uH(e.blue,nH[4]),t.ansi[5]=uH(e.magenta,nH[5]),t.ansi[6]=uH(e.cyan,nH[6]),t.ansi[7]=uH(e.white,nH[7]),t.ansi[8]=uH(e.brightBlack,nH[8]),t.ansi[9]=uH(e.brightRed,nH[9]),t.ansi[10]=uH(e.brightGreen,nH[10]),t.ansi[11]=uH(e.brightYellow,nH[11]),t.ansi[12]=uH(e.brightBlue,nH[12]),t.ansi[13]=uH(e.brightMagenta,nH[13]),t.ansi[14]=uH(e.brightCyan,nH[14]),t.ansi[15]=uH(e.brightWhite,nH[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=uH(e.extendedAnsi[r],nH[r+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 e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];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()}}};lH=_I([Z(0,XI)],lH);function uH(e,t){if(e!==void 0)try{return AB.toColor(e)}catch{}return t}var dH=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},fH=class{constructor(){this._services=new dH,this._services.set(JI,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=VI(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},pH={trace:0,debug:1,info:2,warn:3,error:4,off:5},mH=`xterm.js: `,hH=class extends NL{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),gH=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=pH[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:mH)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};hH=_I([Z(0,XI)],hH);var gH,_H=class extends NL{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Q),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},vH=3,yH=Object.freeze(new FI),bH=0,xH=2,SH=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*vH);let r=t||LI.fromCharData([0,NI,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*vH+0],n=t&2097151;return[this._data[e*vH+1],t&2097152?this._combined[e]:n?kI(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*vH+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*vH+0]=e|2097152|t[2]<<22):this._data[e*vH+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*vH+0]>>22}hasWidth(e){return this._data[e*vH+0]&12582912}getFg(e){return this._data[e*vH+1]}getBg(e){return this._data[e*vH+2]}hasContent(e){return this._data[e*vH+0]&4194303}getCodePoint(e){let t=this._data[e*vH+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*vH+0]&2097152}getString(e){let t=this._data[e*vH+0];return t&2097152?this._combined[e]:t&2097151?kI(t&2097151):``}isProtected(e){return this._data[e*vH+2]&536870912}loadCell(e,t){return bH=e*vH,t.content=this._data[bH+0],t.fg=this._data[bH+1],t.bg=this._data[bH+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*vH+0]=t.content,this._data[e*vH+1]=t.fg,this._data[e*vH+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*vH+0]=t|n<<22,this._data[e*vH+1]=r.fg,this._data[e*vH+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*vH+0];r&2097152?this._combined[e]+=kI(t):r&2097151?(this._combined[e]=kI(r&2097151)+kI(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*vH+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new LI;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new LI;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*xH<this._data.buffer.byteLength;let n=e*vH;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*xH<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*xH<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*vH+0]&4194303)return e+(this._data[e*vH+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*vH+0]&4194303||this._data[e*vH+2]&50331648)return e+(this._data[e*vH+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<vH;e++)this._data[(n+i)*vH+e]=a[(t+i)*vH+e];a[(t+i)*vH+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<vH;e++)this._data[(n+i)*vH+e]=a[(t+i)*vH+e];a[(t+i)*vH+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*vH+0],n=e&2097151,a=e&2097152?this._combined[t]:n?kI(n):PI;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function CH(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=DH(u,d,t),p=1,m=0;for(;p<u.length;){let e=DH(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function wH(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function TH(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function EH(e,t,n){let r=[],i=e.map((n,r)=>DH(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=DH(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function DH(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var OH=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),OL(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};OH._nextId=1;var kH=OH,AH={},jH=AH.B;AH[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},AH.A={"#":`£`},AH.B=void 0,AH[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},AH.C=AH[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},AH.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},AH.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},AH.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},AH.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},AH.E=AH[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},AH.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},AH.H=AH[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},AH[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var MH=4294967295,NH=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=yH.clone(),this.savedCharset=jH,this.markers=[],this._nullCell=LI.fromCharData([0,NI,1,0]),this._whitespaceCell=LI.fromCharData([0,PI,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new kV,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new _H(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 II),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 II),this._whitespaceCell}getBlankLine(e,t){return new SH(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>MH?MH:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=yH);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 _H(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(yH),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)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 SH(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new SH(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),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 t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=CH(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(yH),n);if(r.length>0){let n=wH(this.lines,r);TH(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(yH),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new SH(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(yH),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=EH(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(yH,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=DH(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->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+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(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 kH(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},PH=class extends NL{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Q),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 NH(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new NH(!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)}},FH=2,IH=1,LH=class extends NL{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,FH),this.rows=Math.max(e.rawOptions.rows||0,IH),this.buffers=this._register(new PH(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};LH=_I([Z(0,XI)],LH);var RH={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:bV,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},zH=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],BH=class extends NL{constructor(e){super(),this._onOptionChange=this._register(new Q),this.onOptionChange=this._onOptionChange.event;let t={...RH};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(AL(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in RH))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in RH))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=RH[e],!VH(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=RH[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=zH.includes(t)?t:RH[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw 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 Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function VH(e){return e===`block`||e===`underline`||e===`bar`}function HH(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&HH(e[r],t-1);return n}var UH=Object.freeze({insertMode:!1}),WH=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),GH=class extends NL{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Q),this.onData=this._onData.event,this._onUserInput=this._register(new Q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=HH(UH),this.decPrivateModes=HH(WH)}reset(){this.modes=HH(UH),this.decPrivateModes=HH(WH)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.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(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};GH=_I([Z(0,WI),Z(1,YI),Z(2,XI)],GH);var KH={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 qH(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var JH=String.fromCharCode,YH={DEFAULT:e=>{let t=[qH(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${JH(t[0])}${JH(t[1])}${JH(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${qH(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${qH(e,!0)};${e.x};${e.y}${t}`}},XH=class extends NL{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Q),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(KH))this.addProtocol(e,KH[e]);for(let e of Object.keys(YH))this.addEncoding(e,YH[e]);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 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 Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};XH=_I([Z(0,WI),Z(1,KI),Z(2,XI)],XH);var ZH=[[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]],QH=[[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]],$H;function eU(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var tU=class{constructor(){if(this.version=`6`,!$H){$H=new Uint8Array(65536),$H.fill(1),$H[0]=0,$H.fill(0,1,32),$H.fill(0,127,160),$H.fill(2,4352,4448),$H[9001]=2,$H[9002]=2,$H.fill(2,11904,42192),$H[12351]=1,$H.fill(2,44032,55204),$H.fill(2,63744,64256),$H.fill(2,65040,65050),$H.fill(2,65072,65136),$H.fill(2,65280,65377),$H.fill(2,65504,65511);for(let e=0;e<ZH.length;++e)$H.fill(0,ZH[e][0],ZH[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?$H[e]:eU(e,QH)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=nU.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return nU.createPropertyValue(0,n,r)}},nU=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Q,this.onChange=this._onChange.event;let e=new tU;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},rU=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 iU(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var aU=2147483647,oU=256,sU=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>oU)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(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 e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>aU?aU:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>aU?aU:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,aU):e}},cU=[],lU=class{constructor(){this._state=0,this._active=cU,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,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=cU}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=cU,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||cU,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,AI(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=cU,this._id=-1,this._state=0}}},uU=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=AI(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},dU=[],fU=class{constructor(){this._handlers=Object.create(null),this._active=dU,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=dU}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,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=dU,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||dU,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,AI(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=dU,this._ident=0}},pU=new sU;pU.addParam(0);var mU=class{constructor(e){this._handler=e,this._data=``,this._params=pU,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():pU,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=AI(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=pU,this._data=``,this._hitLimit=!1,e));return this._params=pU,this._data=``,this._hitLimit=!1,t}},hU=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},gU=160,_U=function(){let e=new hU(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(gU,0,2,0),e.add(gU,8,5,8),e.add(gU,6,0,6),e.add(gU,11,0,11),e.add(gU,13,13,13),e}(),vU=class extends NL{constructor(e=_U){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 sU,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(AL(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new lU),this._dcsParser=this._register(new fU),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:gU)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<gU){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<gU){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<gU){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<gU){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<gU){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=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 i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<gU){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},yU=/^([\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})$/,bU=/^[\da-f]+$/;function xU(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=yU.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),bU.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function SU(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function CU(e,t=16){let[n,r,i]=e;return`rgb:${SU(n,t)}/${SU(r,t)}/${SU(i,t)}`}var wU={"(":0,")":1,"*":2,"+":3,"-":1,".":2},TU=131072,EU=10;function DU(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 OU=5e3,kU=0,AU=class extends NL{constructor(e,t,n,r,i,a,o,s,c=new vU){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new jI,this._utf8Decoder=new MI,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=yH.clone(),this._eraseAttrDataInternal=yH.clone(),this._onRequestBell=this._register(new Q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Q),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 jU(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(bB.IND,()=>this.index()),this._parser.setExecuteHandler(bB.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(bB.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new uU(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new uU(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new uU(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new uU(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new uU(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new uU(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new uU(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new uU(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new uU(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new uU(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new uU(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new uU(e=>this.restoreCursorColor(e))),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 e in AH)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new mU((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),OU))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${OU} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>TU&&(a=this._parseStack.position+TU)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<TU&&(this._parseBuffer=new Uint32Array(Math.min(e.length,TU))),o||this._dirtyRowTracker.clearRange(),e.length>TU)for(let t=a;t<e.length;t+=TU){let a=t+TU<e.length?t+TU:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=nU.extractWidth(t);let n=nU.extractShouldJoin(t),m=n?nU.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(kI(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof SH&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!DU(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new mU(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new uU(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}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)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,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}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(yH));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 e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=nU.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.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}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,jH),this._charsetService.setgCharset(1,jH),this._charsetService.setgCharset(2,jH),this._charsetService.setgCharset(3,jH);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}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}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)}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=FI.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_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=yH.fg,e.bg=yH.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=yH.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=yH.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=yH.fg&16777215,r.bg&=-67108864,r.bg|=yH.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}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=yH.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`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!DU(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(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>EU&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>EU&&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())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(MU(n)){if(r===`?`)t.push({type:0,index:n});else{let e=xU(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=xU(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);MU(r)&&t.push({type:2,index:r})}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,jH),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(wU[e[0]],AH[e[1]]||jH),!0):(this.selectDefaultCharset(),!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=yH.clone(),this._eraseAttrDataInternal=yH.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 LI;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},jU=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&&(kU=e,e=t,t=kU),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};jU=_I([Z(0,WI)],jU);function MU(e){return 0<=e&&e<256}var NU=5e7,PU=12,FU=50,IU=class extends NL{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 Q),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>NU)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=PU?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=PU)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>FU&&(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()}},LU=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 n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};LU=_I([Z(0,WI)],LU);var RU=!1,zU=class extends NL{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new PL),this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onData=this._register(new Q),this.onData=this._onData.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Q),this._instantiationService=new fH,this.optionsService=this._register(new BH(e)),this._instantiationService.setService(XI,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(LH)),this._instantiationService.setService(WI,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(hH)),this._instantiationService.setService(YI,this._logService),this.coreService=this._register(this._instantiationService.createInstance(GH)),this._instantiationService.setService(KI,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(XH)),this._instantiationService.setService(GI,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(nU)),this._instantiationService.setService(QI,this.unicodeService),this._charsetService=this._instantiationService.createInstance(rU),this._instantiationService.setService(qI,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(LU),this._instantiationService.setService(ZI,this._oscLinkService),this._inputHandler=this._register(new AU(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(VL.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(VL.forward(this._bufferService.onResize,this._onResize)),this._register(VL.forward(this.coreService.onData,this._onData)),this._register(VL.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 IU((e,t)=>this._inputHandler.parse(e,t))),this._register(VL.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Q),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&&!RU&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),RU=!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,FH),t=Math.max(t,IH),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(iU.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(iU(this._bufferService),!1))),this._windowsWrappingHeuristics.value=AL(()=>{for(let t of e)t.dispose()})}}},BU={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 VU(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?$.ESC+`OA`:$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?$.ESC+`OD`:$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?$.ESC+`OC`:$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?$.ESC+`OB`:$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`D`:t?$.ESC+`OD`:$.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`C`:t?$.ESC+`OC`:$.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`A`:t?$.ESC+`OA`:$.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`B`:t?$.ESC+`OB`:$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:i.key=a?$.ESC+`[3;`+(a+1)+`~`:$.ESC+`[3~`;break;case 36:i.key=a?$.ESC+`[1;`+(a+1)+`H`:t?$.ESC+`OH`:$.ESC+`[H`;break;case 35:i.key=a?$.ESC+`[1;`+(a+1)+`F`:t?$.ESC+`OF`:$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?$.ESC+`[5;`+(a+1)+`~`:$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?$.ESC+`[6;`+(a+1)+`~`:$.ESC+`[6~`;break;case 112:i.key=a?$.ESC+`[1;`+(a+1)+`P`:$.ESC+`OP`;break;case 113:i.key=a?$.ESC+`[1;`+(a+1)+`Q`:$.ESC+`OQ`;break;case 114:i.key=a?$.ESC+`[1;`+(a+1)+`R`:$.ESC+`OR`;break;case 115:i.key=a?$.ESC+`[1;`+(a+1)+`S`:$.ESC+`OS`;break;case 116:i.key=a?$.ESC+`[15;`+(a+1)+`~`:$.ESC+`[15~`;break;case 117:i.key=a?$.ESC+`[17;`+(a+1)+`~`:$.ESC+`[17~`;break;case 118:i.key=a?$.ESC+`[18;`+(a+1)+`~`:$.ESC+`[18~`;break;case 119:i.key=a?$.ESC+`[19;`+(a+1)+`~`:$.ESC+`[19~`;break;case 120:i.key=a?$.ESC+`[20;`+(a+1)+`~`:$.ESC+`[20~`;break;case 121:i.key=a?$.ESC+`[21;`+(a+1)+`~`:$.ESC+`[21~`;break;case 122:i.key=a?$.ESC+`[23;`+(a+1)+`~`:$.ESC+`[23~`;break;case 123:i.key=a?$.ESC+`[24;`+(a+1)+`~`:$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=BU[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL))}return i}var HU=0,UU=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new kV,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new kV,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((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,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||(HU=this._search(t),HU===-1)||this._getKey(this._array[HU])!==t)return!1;do if(this._array[HU]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(HU),!0;while(++HU<this._array.length&&this._getKey(this._array[HU])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(HU=this._search(e),!(HU<0||HU>=this._array.length)&&this._getKey(this._array[HU])===e))do yield this._array[HU];while(++HU<this._array.length&&this._getKey(this._array[HU])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(HU=this._search(e),!(HU<0||HU>=this._array.length)&&this._getKey(this._array[HU])===e))do t(this._array[HU]);while(++HU<this._array.length&&this._getKey(this._array[HU])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},WU=0,GU=0,KU=class extends NL{constructor(){super(),this._decorations=new UU(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(AL(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new qU(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{WU=t.options.x??0,GU=WU+(t.options.width??1),e>=WU&&e<GU&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},qU=class extends ML{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Q),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._cachedBg=this.options.backgroundColor?AB.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?AB.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},JU=1e3,YU=class{constructor(e,t=JU){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_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)}},XU=20,ZU=class extends NL{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,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=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new YU(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
138
|
+
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Cz(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(AL(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<XU+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
139
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===XU+1&&(this._liveRegion.textContent+=xI.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};ZU=_I([Z(1,JI),Z(2,rL),Z(3,aL)],ZU);var QU=class extends NL{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(AL(()=>{OL(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(Cz(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Cz(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(Cz(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(Cz(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.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(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&$U(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,OL(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||e.link.decorations.underline,pointerCursor:e.link.decorations===void 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:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};QU=_I([Z(1,iL),Z(2,aL),Z(3,WI),Z(4,lL)],QU);function $U(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 eW=class extends zU{constructor(e={}){super(e),this._linkifier=this._register(new PL),this.browser=fV,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new PL),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(KU),this._instantiationService.setService($I,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(sV),this._instantiationService.setService(lL,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(eL)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(VL.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(VL.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(VL.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(VL.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(AL(()=>{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 e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=kB.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${CU(r)}${xB.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=OB.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=OB.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_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(ZU,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.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($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(Cz(this.element,`copy`,e=>{this.hasSelection()&&wI(e,this._selectionService)}));let e=e=>TI(e,this.textarea,this.coreService,this.optionsService);this._register(Cz(this.textarea,`paste`,e)),this._register(Cz(this.element,`paste`,e)),gV?this._register(Cz(this.element,`mousedown`,e=>{e.button===2&&OI(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Cz(this.element,`contextmenu`,e=>{OI(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),wV&&this._register(Cz(this.element,`auxclick`,e=>{e.button===1&&DI(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Cz(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(Cz(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(Cz(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(Cz(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(Cz(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(Cz(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(Cz(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw 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(Cz(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,yI.get()),TV||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(aV,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(rL,this._coreBrowserService),this._register(Cz(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(Cz(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(tV,this._document,this._helperContainer),this._instantiationService.setService(nL,this._charSizeService),this._themeService=this._instantiationService.createInstance(lH),this._instantiationService.setService(cL,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(IB),this._instantiationService.setService(sL,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(jV,this.rows,this.screenElement)),this._instantiationService.setService(aL,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(SB,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(uV),this._instantiationService.setService(iL,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(QU,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(pB,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance($V,this.element,this.screenElement,r)),this._instantiationService.setService(oL,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(VL.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(mB,this.screenElement)),this._register(Cz(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),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(ZU,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(yB,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(yB,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(eV,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),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()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Cz(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(Cz(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!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){EI(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 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 Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=VU(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(tW(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(yH));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($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`)}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function tW(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var nW=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},rW=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 LI)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},iW=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 rW(t)}getNullCell(){return new LI}},aW=class extends NL{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new iW(this._core.buffers.normal,`normal`),this._alternate=new iW(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 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)}},oW=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.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)}},sW=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}},cW=[`cols`,`rows`],lW=0,uW=class extends NL{constructor(e){super(),this._core=this._register(new eW(e)),this._addonManager=this._register(new nW),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(cW.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw 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||=new oW(this._core),this._parser}get unicode(){return this._checkProposedApi(),new sW(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._register(new aW(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`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
140
|
+
`,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 yI.get()},set promptLabel(e){yI.set(e)},get tooMuchOutput(){return xI.get()},set tooMuchOutput(e){xI.set(e)}}}_verifyIntegers(...e){for(lW of e)if(lW===1/0||isNaN(lW)||lW%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(lW of e)if(lW&&(lW===1/0||isNaN(lW)||lW%1!=0||lW<0))throw Error(`This API only accepts positive integers`)}};function dW(e,t){if(typeof document>`u`)return t;try{let n=document.createElement(`span`);n.style.color=`var(${e})`,n.style.position=`absolute`,n.style.opacity=`0`,n.style.pointerEvents=`none`,document.body.appendChild(n);let r=getComputedStyle(n).color;return n.remove(),r||t}catch{return t}}function fW(){let e=dW(`--card`,`#0b0b12`),t=dW(`--foreground`,`#e5e5ef`);return{background:e,foreground:t,cursor:`#a855f7`,cursorAccent:e,selectionBackground:`#9333ea55`,...typeof document<`u`&&document.documentElement.classList.contains(`dark`)?{}:{black:t,white:`#3f3f46`,brightWhite:t,brightBlack:`#a1a1aa`}}}function pW(e,t){e.preventDefault(),window.open(t,`_blank`,`noopener,noreferrer`)}function mW(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t;if(n.t===`opened`){let e=Number.isInteger(n.cols)&&Number.isInteger(n.rows)&&n.cols>0&&n.rows>0?{cols:n.cols,rows:n.rows}:void 0;return{kind:`opened`,...e?{dimensions:e}:{}}}return n.t===`dimensions`&&Number.isInteger(n.cols)&&Number.isInteger(n.rows)&&n.cols>0&&n.rows>0?{kind:`dimensions`,dimensions:{cols:n.cols,rows:n.rows}}:n.t===`error`?{kind:`error`,message:typeof n.message==`string`&&n.message.trim()?n.message:`Terminal bridge error`}:null}function hW(e){return e===1001||e===1006||e===1012||e===1013}function gW(e,t,n){return!e&&t&&n.kind===`closed`&&(n.code===4404||hW(n.code))}function _W(e){if(typeof e==`object`&&e){let t=e.status;if(typeof t==`number`&&t>=500)return!0}let t=e instanceof Error?e.message:String(e);return/failed to fetch|fetch failed|load failed|network\s*error/i.test(t)}var vW=`\x1B[13;2u`;function yW(e){return e.key===`Enter`&&e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey?vW:null}var bW=new TextEncoder,xW=2e4;function SW(e,t,n){return e===0?``:`\x1b[<${e<0?64:65};${t};${n}M`.repeat(Math.abs(e))}function CW(e,t,n,r){if(t.mouseTrackingMode===`none`||!t.sgrEncoding)return{consume:!1,data:``,partial:0};if(e.shiftKey||e.deltaY===0||n===null)return{consume:!1,data:``,partial:r};let i;i=e.deltaMode===1?e.deltaY:e.deltaMode===2?e.deltaY*n.rows:e.deltaY/n.cellHeight;let a=r+i,o=Math.trunc(a),s=Math.max(-50,Math.min(50,o)),c=(e,t)=>Math.min(Math.max(e,1),t);return{consume:!0,data:SW(s,c(Math.floor((e.clientX-n.left)/n.cellWidth)+1,n.cols),c(Math.floor((e.clientY-n.top)/n.cellHeight)+1,n.rows)),partial:s===o?a-o:0}}function wW(e){let t;try{t=new pI}catch{return null}t.onContextLoss(()=>t.dispose());try{e.loadAddon(t)}catch{return t.dispose(),null}return t}function TW(e,t){return t?(e.clipboardData?.setData(`text/plain`,t),e.preventDefault(),!0):!1}var EW=class{url;onState;term;fit;webgl;listenerCtl;resizeObserver;ws=null;dataDispose=null;disposed=!1;connectedOnce=!1;connectionGeneration=0;layoutVisible=!1;wheelPartialLines=0;constructor(e,t,n,r=!1){this.url=t,this.onState=n,this.term=new uW({fontFamily:`'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:13,scrollback:xW,cursorBlink:!0,theme:fW(),minimumContrastRatio:4.5,macOptionClickForcesSelection:!0,allowProposedApi:!0,disableStdin:!1}),this.fit=new Gj,this.term.loadAddon(this.fit),this.term.loadAddon(new Zj(pW)),this.term.open(e),this.webgl=wW(this.term),this.listenerCtl=new AbortController;let{signal:i}=this.listenerCtl;e.addEventListener(`copy`,e=>TW(e,this.term.getSelection()),{capture:!0,signal:i}),this.onState({kind:`connecting`}),this.resizeObserver=new ResizeObserver(e=>{if(this.disposed)return;let t=e[0]?.contentRect,n=!!t&&t.width>0&&t.height>0;if(this.layoutVisible=n,!this.connectedOnce&&!this.ws){n&&this.connect();return}n&&this.sendResize()}),this.resizeObserver.observe(e)}async connect(){if(this.disposed)return;let e=++this.connectionGeneration;this.connectedOnce=!0;try{this.fit.fit()}catch{this.term.resize(80,24)}let t;try{if(t=typeof this.url==`function`?await this.url({cols:this.term.cols,rows:this.term.rows}):this.url,this.disposed||e!==this.connectionGeneration)return;let n=new URL(t);n.searchParams.set(`cols`,String(this.term.cols)),n.searchParams.set(`rows`,String(this.term.rows)),t=n.toString()}catch(t){if(this.disposed||e!==this.connectionGeneration)return;_W(t)?this.onState({kind:`closed`,code:1006,reason:`Terminal connection temporarily unavailable`}):this.onState({kind:`error`,message:t instanceof Error?t.message:`Could not prepare terminal connection`});return}let n;try{n=new WebSocket(t)}catch(t){if(this.disposed||e!==this.connectionGeneration)return;this.onState({kind:`error`,message:t instanceof Error?t.message:`Could not open terminal connection`});return}n.binaryType=`arraybuffer`,this.ws=n;let r=null;n.addEventListener(`open`,()=>{this.sendResize(),this.term.focus()},{signal:this.listenerCtl.signal}),n.addEventListener(`message`,e=>{if(e.data instanceof ArrayBuffer){this.writeOutput(new Uint8Array(e.data));return}if(typeof e.data!=`string`)return;let t=mW(e.data);t?.kind===`opened`?this.onState({kind:`connected`}):t?.kind===`error`&&(r=t.message,this.onState({kind:`error`,message:t.message}))},{signal:this.listenerCtl.signal}),n.addEventListener(`close`,e=>{this.ws===n&&(this.ws=null,this.dataDispose?.dispose(),this.dataDispose=null,(r===null||e.code!==4500)&&this.onState({kind:`closed`,reason:e.reason||`code ${e.code}`,code:e.code}))},{signal:this.listenerCtl.signal}),n.addEventListener(`error`,()=>{this.ws===n&&this.onState({kind:`error`,message:`Terminal WebSocket error`})},{signal:this.listenerCtl.signal}),this.dataDispose?.dispose(),this.dataDispose=this.term.onData(e=>{n.readyState===WebSocket.OPEN&&n.send(bW.encode(e))}),this.term.attachCustomKeyEventHandler(e=>{let t=yW(e);return t===null||(e.type===`keydown`&&(e.preventDefault(),n.readyState===WebSocket.OPEN&&n.send(bW.encode(t))),!1)}),this.term.attachCustomWheelEventHandler(e=>{let t=CW(e,{mouseTrackingMode:this.term.modes.mouseTrackingMode,sgrEncoding:this.sgrMouseEncodingActive()},this.screenMetrics(),this.wheelPartialLines);return this.wheelPartialLines=t.partial,!t.consume||(t.data&&this.term.input(t.data,!0),e.preventDefault(),!1)})}setTheme(){this.term.options.theme=fW()}focus(){this.term.focus()}dispose(){if(this.disposed)return;this.disposed=!0,this.connectionGeneration+=1,this.listenerCtl.abort(),this.resizeObserver.disconnect(),this.dataDispose?.dispose();let e=this.ws;this.ws=null;try{e?.close()}catch{}this.webgl?.dispose(),this.term.dispose()}writeOutput(e){this.term.write(e)}sgrMouseEncodingActive(){return this.term._core?.coreMouseService?.activeEncoding===`SGR`}screenMetrics(){let{cols:e,rows:t}=this.term,n=this.term.element?.querySelector(`.xterm-screen`)?.getBoundingClientRect();return!n||n.width<=0||n.height<=0||e<=0||t<=0?null:{left:n.left,top:n.top,cellWidth:n.width/e,cellHeight:n.height/t,cols:e,rows:t}}sendResize(){if(!(!this.layoutVisible||!this.ws||this.ws.readyState!==WebSocket.OPEN)){try{this.fit.fit()}catch{return}this.ws.send(JSON.stringify({t:`resize`,cols:this.term.cols,rows:this.term.rows}))}}},DW=[500,1e3,2e3,4e3,8e3];function OW({sessionId:e,runtimeSelector:t,active:n,role:r=`owner`,setup:i}){let[a,o]=(0,u.useState)({kind:`connecting`}),[s,c]=(0,u.useState)(0),[l,d]=(0,u.useState)(!1),[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(null),g=(0,u.useRef)(0),_=(0,u.useRef)(null),v=(0,u.useRef)(null),y=(0,u.useRef)(n),b=`${t}\u0000${e}`,x=(0,u.useRef)(b);x.current=b;let{theme:S}=Hj(),C=(0,u.useCallback)(e=>o(e),[]);(0,u.useEffect)(()=>{v.current?.setTheme()},[S]),(0,u.useEffect)(()=>{h(null),p(!1)},[b]);let w=(0,u.useCallback)(n=>{if(n===null)return;C({kind:`connecting`});let i=null,a=!1;return queueMicrotask(()=>{a||(i=new EW(n,({cols:n,rows:i})=>qx(t,e,{role:r,cols:n,rows:i,refreshCapability:!0}),C,r===`read-only`),v.current=i)}),()=>{a=!0,i?.dispose(),v.current=null}},[e,t,r,C]);(0,u.useEffect)(()=>{if(a.kind===`connected`){_.current=Date.now(),d(!1);return}if(a.kind!==`closed`)return;if(!hW(a.code)){d(!1);return}if(_.current!==null&&Date.now()-_.current>=3e4&&(g.current=0),_.current=null,g.current>=DW.length){d(!1);return}let e=DW[g.current];g.current+=1,d(!0);let t=!1,n=()=>{t||(t=!0,c(e=>e+1))},r=window.setTimeout(n,e),i=()=>{document.visibilityState===`visible`&&n()};return document.addEventListener(`visibilitychange`,i),()=>{window.clearTimeout(r),document.removeEventListener(`visibilitychange`,i)}},[a]);let T=(0,u.useCallback)(()=>{g.current=0,_.current=null,d(!1),c(e=>e+1)},[]);(0,u.useEffect)(()=>{let e=y.current;y.current=n,!e&&n&&v.current?.focus(),gW(e,n,a)&&(g.current=0,_.current=null,d(!1),a.kind===`closed`&&a.code===4404&&C({kind:`probing`}),c(e=>e+1))},[n,a,C]);let E=(0,u.useCallback)(async()=>{if(f)return;let n=b;p(!0),h(null);try{if(await Y.startSessionTerminal(t,e),x.current!==n)return;T()}catch(e){if(x.current!==n)return;h(e instanceof Error?e.message:`Could not start terminal`)}finally{x.current===n&&p(!1)}},[T,t,e,f,b]);return(0,H.jsx)(`div`,{"data-state":a.kind,className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-[var(--card)]`,children:(0,H.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden p-1`,children:[(0,H.jsx)(`div`,{ref:w,className:`h-full w-full overflow-hidden`},s),a.kind!==`connected`&&(0,H.jsx)(kW,{state:a,reconnectPending:l,startingTerminal:f,startError:m,onRetry:T,onStartTerminal:()=>void E(),setup:i,readOnly:r===`read-only`})]})})}function kW({state:e,reconnectPending:t,startingTerminal:n,startError:r,onRetry:i,onStartTerminal:a,setup:o,readOnly:s}){return(0,H.jsxs)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-[var(--background)]/85 text-sm text-[var(--foreground)] backdrop-blur-[1px]`,children:[e.kind===`connecting`&&(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),`Connecting…`]}),e.kind===`closed`&&t&&(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),`Reconnecting…`]}),e.kind===`closed`&&!t&&(e.code===4404?(0,H.jsx)(AW,{starting:n,error:r,onStart:a,setup:o,readOnly:s}):(0,H.jsx)(jW,{message:e.reason||`Terminal connection closed`,onRetry:i})),e.kind===`probing`&&(0,H.jsxs)(`span`,{className:`flex items-center gap-2 text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),`Checking terminal…`]}),e.kind===`error`&&(0,H.jsx)(jW,{message:e.message,onRetry:i})]})}function AW({starting:e,error:t,onStart:n,setup:r,readOnly:i}){let a=r?.target??`Provider`,o=r?.kind===`delivery_unknown`?`Task delivery needs confirmation`:r?.kind===`required`?`${a} needs setup`:`Terminal is not running`,s=r?.kind===`delivery_unknown`?`Rynx could not confirm whether the queued task was accepted. Open the terminal and check its history before retrying.`:r?.kind===`required`?r.taskQueued?`Complete login or first-run setup. The queued task will start automatically when ${a} is ready.`:r.reason??`Complete ${a} login or first-run setup before starting this Session.`:`Start it when you need terminal access for this Session.`,c=r?.kind===`required`?`Open ${a} setup`:`Start terminal`;return(0,H.jsxs)(`div`,{className:`grid max-w-sm place-items-center gap-3 px-6 text-center`,children:[(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:o}),(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:s})]}),t&&(0,H.jsx)(`span`,{className:`text-[var(--destructive)]`,children:t}),!i&&(0,H.jsxs)(J,{variant:`outline`,size:`sm`,disabled:e,onClick:n,children:[e?(0,H.jsx)(B,{className:`animate-spin`}):(0,H.jsx)(Fr,{}),e?`Opening…`:c]})]})}function jW({message:e,onRetry:t}){return(0,H.jsxs)(`div`,{className:`grid max-w-sm place-items-center gap-3 px-6 text-center`,children:[(0,H.jsx)(`span`,{className:`text-[var(--muted-foreground)]`,children:e}),(0,H.jsxs)(J,{variant:`outline`,size:`sm`,onClick:t,children:[(0,H.jsx)(zr,{}),` Retry`]})]})}function MW(e,t){return`${e}\u0000${t}`}function NW(e,t){return[...e.filter(e=>e.runtimeSelector===t.runtimeSelector&&e.key!==t.key),t].slice(-8)}function PW({selected:e,slot:t,visible:n}){let[r,i]=(0,u.useState)([]),[a,o]=(0,u.useState)(null);(0,u.useEffect)(()=>{e&&i(t=>{let n=t[t.length-1];return n&&FW(n,e)?t:NW(t,e)})},[e]);let s=e?NW(r,e):r;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{ref:o,className:`pointer-events-none invisible absolute inset-0 min-h-0 min-w-0 overflow-hidden`,"aria-hidden":`true`}),s.map(r=>(0,H.jsx)(IW,{entry:r,parkingHost:a,slot:e?.key===r.key?t:null,visible:e?.key===r.key&&n},r.key))]})}function FW(e,t){return e.key===t.key&&e.runtimeSelector===t.runtimeSelector&&e.sessionId===t.sessionId&&e.readOnly===t.readOnly&&e.setup?.kind===t.setup?.kind&&e.setup?.target===t.setup?.target&&(e.setup?.kind!==`required`||t.setup?.kind!==`required`||e.setup.taskQueued===t.setup.taskQueued&&e.setup.reason===t.setup.reason)}function IW({entry:e,parkingHost:t,slot:n,visible:r}){let i=(0,u.useRef)(null);if(i.current===null&&typeof document<`u`){let t=document.createElement(`div`);t.className=`flex h-full min-h-0 w-full min-w-0 flex-col`,t.dataset.warmTerminal=e.key,i.current=t}(0,u.useLayoutEffect)(()=>{let e=i.current,r=n??t;if(!(!e||!r))return r.appendChild(e),()=>e.remove()},[t,n]);let a=i.current;return a?(0,d.createPortal)((0,H.jsx)(OW,{sessionId:e.sessionId,runtimeSelector:e.runtimeSelector,active:r,role:e.readOnly?`read-only`:`owner`,setup:e.setup}),a,e.key):null}function LW(){let e=Rx(),t=e?.access===`read_only`,n=e?.scope===`single_session`?e.sessionId:void 0,r=!!n,i=nt(),{sessionId:a}=it(),{runtimeSelector:o,selectedRuntime:s}=xS(),{status:c,operation:l}=kS(),d=YT(c,l),[f,p]=(0,u.useState)([]),[m,h]=(0,u.useState)({providers:[],agents:[]}),[g,_]=(0,u.useState)(null),[v,y]=(0,u.useState)({permissionPreset:`default`}),[b,x]=(0,u.useState)([]),[S,C]=(0,u.useState)(null),[w,T]=(0,u.useState)(!0),[E,D]=(0,u.useState)(!0),[O,k]=(0,u.useState)(),[A,j]=(0,u.useState)(),[M,N]=(0,u.useState)(),[P,F]=(0,u.useState)(!0),[I,L]=(0,u.useState)(!1),[ee,te]=(0,u.useState)(!1),[ne,re]=(0,u.useState)(null),[R,ie]=(0,u.useState)(null),[ae,oe]=(0,u.useState)(!1),[se,ce]=(0,u.useState)(),[le,ue]=(0,u.useState)(),de=(0,u.useRef)(!1),fe=(0,u.useRef)(0),pe=(0,u.useRef)(0),me=(0,u.useRef)(0),he=(0,u.useRef)(0),ge=(0,u.useRef)(void 0),_e=(0,u.useRef)(o),ve=(0,u.useRef)(o),ye=(0,u.useRef)(d);ye.current=d;let be=(0,u.useRef)({selector:o});be.current.selector!==o&&(be.current={selector:o});let xe=be.current,Se=n??a??null,Ce=(0,u.useRef)(Se);(0,u.useEffect)(()=>{!n||a===n||i(zx(Ax(o,n)),{replace:!0})},[i,o,a,n]),(0,u.useEffect)(()=>()=>{he.current+=1},[]),(0,u.useEffect)(()=>{Ce.current!==Se&&(Ce.current=Se,he.current+=1)},[Se]);let we=(0,u.useCallback)(async(e=!1)=>{if(ye.current)return;let t=++fe.current;e&&F(!0);try{let e=await Y.listSessions(o);if(fe.current!==t)return;_e.current=o,p(e),N(void 0)}catch(e){if(fe.current!==t||ye.current)return;N(`Could not load sessions: ${e.message}`)}finally{fe.current===t&&F(!1)}},[o]);(0,u.useEffect)(()=>{ve.current!==o&&(ve.current=o,ge.current=void 0,me.current+=1,fe.current+=1,p([]),x([]),C(null),j(void 0),D(!0),N(void 0),F(!0))},[o]);let Te=(0,u.useCallback)(async()=>{if(e){x([]),C(null),j(void 0),D(!1);return}if(ye.current)return;let t=++me.current;D(!0),j(void 0);try{let e=await Y.listProjects(o);if(me.current!==t)return;x(e),C(t=>t&&e.some(e=>e.id===t)?t:null)}catch(e){if(me.current!==t||ye.current)return;x([]),C(null),j(`Could not load projects: ${e.message}`)}finally{me.current===t&&D(!1)}},[e,t,o]);(0,u.useEffect)(()=>{if(d){fe.current+=1,N(void 0),F(!1);return}we(!0);let e=setInterval(()=>void we(),4e3);return()=>clearInterval(e)},[we,d]);let Ee=(0,u.useCallback)(async()=>{if(e){h({providers:[],agents:[]}),_(null),k(void 0),T(!1);return}if(ye.current)return;let t=++pe.current;T(!0),k(void 0);try{let e;try{e=await Y.listSessionLaunchOptions(o)}catch(t){if(!(t instanceof Hx)||t.code!==`incompatible`&&t.code!==`method_not_found`)throw t;e=cE(await Y.listSessionAgentOptions(o))}if(pe.current!==t)return;let n=nE(o,typeof window>`u`?void 0:window.localStorage),r=tE(e,n);h(e),_(r),y(oE(r,e))}catch(e){if(pe.current!==t||ye.current)return;h({providers:[],agents:[]}),_(null),y({permissionPreset:`default`}),k(`Could not load launch options: ${e.message}`)}finally{pe.current===t&&T(!1)}},[e,t,o]);(0,u.useEffect)(()=>{if(d){pe.current+=1,k(void 0),T(!1);return}return h({providers:[],agents:[]}),_(null),y({permissionPreset:`default`}),T(!0),k(void 0),te(!1),ce(void 0),ue(void 0),Ee(),()=>{pe.current+=1}},[Ee,d]),(0,u.useEffect)(()=>{if(d){me.current+=1,j(void 0),D(!1);return}return x([]),C(null),D(!0),j(void 0),Te(),()=>{me.current+=1}},[Te,d]);let De=(0,u.useCallback)(async e=>{if(de.current)return!1;let t=e.text,n=g;if(!n)return k(`Choose a provider or Agent before starting.`),!1;let r=dE(n,m);if(!r)return k(`Choose a provider or Agent before starting.`),!1;let a=!r.ready&&r.readiness!==`unverified`;if(a&&e.attachments.length>0)return k(`${r.name} must finish login or first-run setup before starting with files.`),!1;let o=be.current,c=s.displayName,l=++he.current,u=sE(t||e.attachments[0]?.file.name||`File`),d;de.current=!0,oe(!0),k(void 0);try{let s=ge.current,f=s&&s.selector===o.selector&&s.selection.kind===n.kind&&s.selection.id===n.id&&s.projectId===S&&s.configuration.model===v.model&&s.configuration.reasoningEffort===v.reasoningEffort&&s.configuration.permissionPreset===v.permissionPreset?s.sessionId:(await Y.createSession(aE(n,u,S??void 0,v),o.selector)).sessionId;if(d=f,ge.current={selector:o.selector,selection:n,projectId:S,configuration:{...v},sessionId:f},!a&&e.attachments.length===0){let e=new Date().toISOString(),r=n.kind===`agent`?m.agents.find(e=>e.id===n.id)?.runtime:void 0,a=n.kind===`provider`?n.id:RW(r)?r:void 0,s={id:f,...a?{provider:a}:{},title:u,status:`running`,createdAt:e,updatedAt:e,source:`console`};return _e.current=o.selector,p(e=>[s,...e.filter(e=>e.id!==f)]),ue({sessionId:f,message:t,started:!1}),te(!1),ge.current=void 0,i(zx(Ax(o.selector,f))),!0}let h,g=!1,_=!1;if(a)try{await Y.enqueueSessionMessage(o.selector,f,t),g=!0}catch(e){h=e}else try{if(!(await Y.getSessionResourcePolicy(o.selector,f)).enabled)throw new Hx(`Session file resources are unavailable on this Runtime`,409,`failed_precondition`,`not_started`);let n=await Promise.all(e.attachments.map(e=>Y.uploadSessionResource(o.selector,f,e.file,e.clientUploadId,e.type)));_=!0,await Y.sendSessionMessage(f,{content:[...n.map(e=>e.type===`input_image`?{type:e.type,resourceId:e.resourceId,mediaType:e.mediaType,filename:e.filename,byteLength:e.byteLength,width:e.width,height:e.height}:{type:e.type,resourceId:e.resourceId,mediaType:e.mediaType,filename:e.filename,byteLength:e.byteLength}),...t?[{type:`input_text`,text:t}]:[]],clientMessageId:e.clientMessageId},()=>{},void 0,o.selector)}catch(e){h=e}let y=!!(!g&&(e.attachments.length>0&&!_&&h||Ux(h)));if(be.current!==o)return ge.current=void 0,h?y?V.error(`Session created on ${c}, but the first message was not sent: ${h.message}`):V.warning(`Session created on ${c}, but message delivery is unknown. Check its history before retrying.`):V.success(`Session started on ${c}; switch back to view it.`),!0;if(he.current!==l)return ge.current=void 0,h?y?V.error(`Session created on ${c}, but the first message was not sent. Open it to retry.`):V.warning(`Session created on ${c}, but message delivery is unknown. Check its history before retrying.`):V.success(`Session started on ${c} in the background.`),!0;if(e.attachments.length>0&&y)return k(`Session created, but the first file message was not sent: ${h.message}. Retry will reuse this Session.`),we(),!1;let b=new Date().toISOString(),x={id:f,...n.kind===`provider`?{provider:n.id}:{agent:n.id},title:u,status:y?`idle`:`running`,createdAt:b,updatedAt:b,source:`console`,...g?{setupStatus:`waiting_for_provider`}:{}};return _e.current=o.selector,p(e=>[x,...e.filter(e=>e.id!==f)]),ce(y?{sessionId:f,message:t}:void 0),te(!1),ge.current=void 0,i(zx(g?`${Ax(o.selector,f)}?view=terminal`:Ax(o.selector,f))),we(),g?V.info(`${r.name} needs setup. The task is queued and will start automatically when the Provider is ready.`):h&&(y?V.error(`Session created, but the first message was not sent: ${h.message}`):V.warning(`Session created, but message delivery is unknown. Check its history before retrying.`)),!0}catch(e){let t=e instanceof Hx&&e.outcome===`unknown`,n=d?`Session created, but its first message was not sent: ${e.message}. Retry will reuse this Session.`:t?`Session creation outcome is unknown. Check the Session list before retrying.`:`Could not start session: ${e.message}`;return be.current===o&&he.current===l?k(n):t?V.warning(`Session creation on ${c} may have succeeded. Check its Session list before retrying.`):V.error(`Could not start Session on ${c}: ${e.message}`),!d&&t?(ge.current=void 0,!0):!1}finally{de.current=!1,oe(!1)}},[m,v,g,i,S,we,s.displayName]),Oe=_e.current===o?f:[],ke=Oe.find(e=>e.id===Se)??null,Ae=ke?dE(ke.provider?{kind:`provider`,id:ke.provider}:ke.agent?{kind:`agent`,id:ke.agent}:null,m):null,je=ke?.setupStatus===`delivery_unknown`?{kind:`delivery_unknown`,target:Ae?.name??(ke.provider?uE(ke.provider):ke.agent)}:ke&&(ke.setupStatus===`waiting_for_provider`||Ae?.ready===!1)?{kind:`required`,target:Ae?.name??(ke.provider?uE(ke.provider):ke.agent),taskQueued:ke.setupStatus===`waiting_for_provider`,...Ae?.reason?{reason:Ae.reason}:{}}:void 0;(0,u.useEffect)(()=>{se?.sessionId===ke?.id&&ce(void 0)},[se,ke?.id]);let Me=ke&&!r?(0,H.jsxs)(`div`,{className:X(`flex shrink-0 items-center gap-1`,I&&`desktop-macos-titlebar-leading-inset`),children:[(0,H.jsx)(J,{variant:`ghost`,size:`icon`,className:`size-10 md:hidden`,title:`Back to sessions`,"aria-label":`Back to sessions`,onClick:()=>{te(!0),i(zx(jx(o)),{replace:!0})},children:(0,H.jsx)(An,{})}),I&&(0,H.jsx)(J,{variant:`ghost`,size:`icon-sm`,className:`-ml-1 hidden md:inline-flex`,title:`Show session list`,"aria-label":`Show session list`,onClick:()=>L(!1),children:(0,H.jsx)(Ar,{className:`size-3.5`})})]}):void 0,Ne=(0,u.useCallback)((e,t)=>{ie(n=>t?e:n===e?null:n)},[]),Pe=ke?{key:MW(o,ke.id),runtimeSelector:o,sessionId:ke.id,readOnly:!!t,setup:je}:null;return(0,H.jsxs)(`div`,{className:X(`grid h-full min-h-0 min-w-0 bg-[var(--background)]`,r||I?`grid-cols-[minmax(0,1fr)]`:`md:grid-cols-[14rem_minmax(0,1fr)]`),children:[!r&&!I&&(0,H.jsx)(`div`,{className:X(`min-h-0 min-w-0 border-r border-[var(--border)]`,(!ee||ke)&&`hidden md:block`),children:(0,H.jsx)(Aj,{sessions:Oe,runtimeSelector:o,runtimeLabel:s.displayName,listError:M,loading:P,selectedId:Se,readOnly:!!e,onCollapsedChange:L,onSelect:e=>{he.current+=1,ge.current=void 0,te(!1),ce(void 0),i(zx(Ax(o,e)))},onNew:()=>{he.current+=1,ge.current=void 0,te(!1),ce(void 0),ue(void 0),i(zx(jx(o)))},onRetry:()=>void we(!0),onFork:async e=>{try{let t=await Y.forkSession(o,e,{operationId:`web_${crypto.randomUUID()}`});if(be.current!==xe)return;await we(),te(!1),i(zx(Ax(o,t.sessionId))),V.success(`Session forked`)}catch(e){V.error(`Fork session failed: ${e instanceof Error?e.message:String(e)}`)}},onDeleted:e=>{be.current===xe&&(Se===e&&i(zx(jx(o)),{replace:!0}),we())}},o)}),(0,H.jsxs)(`div`,{className:`relative min-h-0 min-w-0 overflow-hidden`,children:[ke?(0,H.jsx)(Cj,{session:ke,runtimeSelector:o,readOnly:t,leadingControls:Me,initialDraft:se?.sessionId===ke.id?se.message:void 0,initialMessage:le?.sessionId===ke.id?le.message:void 0,sendInitialMessage:le?.sessionId===ke.id&&!le.started,onInitialMessageStarted:()=>{ue(e=>e?.sessionId===ke.id?{...e,started:!0}:e)},onInitialMessageConsumed:()=>{ue(e=>e?.sessionId===ke.id?void 0:e)},onInitialMessageFailed:e=>{ue(e=>e?.sessionId===ke.id?void 0:e),ce({sessionId:ke.id,message:e})},terminalSlotRef:re,onTerminalActiveChange:Ne},`${o}:${ke.id}`):Se&&P?(0,H.jsx)(`div`,{className:`grid h-full min-h-0 min-w-0 place-items-center`,role:`status`,"aria-live":`polite`,children:(0,H.jsxs)(`span`,{className:`flex items-center gap-2 text-sm text-[var(--muted-foreground)]`,children:[(0,H.jsx)(B,{className:`size-4 animate-spin`}),` Loading session…`]})}):e?(0,H.jsx)(`div`,{className:`grid h-full min-h-0 min-w-0 place-items-center px-6 text-center text-sm text-[var(--muted-foreground)]`,children:Se?`Session not found.`:`Choose a Session from the list.`}):(0,H.jsx)(`div`,{className:X(`h-full min-h-0 min-w-0`,ee&&!I&&`hidden md:block`),children:(0,H.jsx)(Ij,{runtimeLabel:s.displayName,options:m,selection:g,configuration:v,projects:b,projectId:S,loading:w,projectsLoading:E,submitting:ae,error:O??M??(Se?`Session not found. Start a new session or choose another from the list.`:void 0),projectError:A,listCollapsed:I,onShowSessions:()=>{he.current+=1,L(!1),te(!0)},onRetryOptions:()=>{Ee()},onSelectionChange:e=>{ge.current=void 0,_(e),y(t=>oE(e,m,t.permissionPreset)),k(void 0),rE(o,typeof window>`u`?void 0:window.localStorage,e)},onConfigurationChange:e=>{ge.current=void 0,y(e),k(void 0)},onProjectChange:e=>{ge.current=void 0,C(e),k(void 0)},onNewProject:()=>{i(px.projects,{state:{returnTo:jx(o),createProject:!0}})},onSubmit:De},o)}),(0,H.jsx)(PW,{selected:Pe,slot:ne,visible:R===ke?.id})]})]})}function RW(e){return e===`codex`||e===`claude`||e===`traex`}function zW(){let[e,t]=(0,u.useState)(null),[n,r]=(0,u.useState)(``),[i,a]=(0,u.useState)(null),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(``),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(!1),[_,v]=(0,u.useState)(!1);async function y(){try{let e=await Y.listSkills();t(e),r(t=>e.some(e=>e.name===t)?t:e[0]?.name??``)}catch(e){t([]),V.error(`Failed to load Skills: ${e.message}`)}}(0,u.useEffect)(()=>{y()},[]),(0,u.useEffect)(()=>{if(!n){a(null);return}let e=!1;return s(!0),Y.getSkill(n).then(t=>{e||(a(t),l((t.files.find(e=>e.path===`SKILL.md`)??t.files[0])?.path??``))}).catch(t=>!e&&V.error(`Load Skill failed: ${t.message}`)).finally(()=>!e&&s(!1)),()=>{e=!0}},[n]),(0,u.useEffect)(()=>{if(!n||!c){f(``);return}let e=!1;return m(!0),Y.readSkillFile(n,c).then(t=>!e&&f(t.content)).catch(t=>!e&&f(`⚠ ${t.message}`)).finally(()=>!e&&m(!1)),()=>{e=!0}},[c,n]);let b=e?.filter(e=>{let t=e.ref?.install.tool===`skills-cli`?e.ref.install.source:``;return t.includes(`/artifacts/skills/`)||t.includes(`\\artifacts\\skills\\`)}).length??0;return(0,H.jsxs)(`div`,{className:`grid gap-5`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Skills`}),(0,H.jsxs)(`p`,{className:`mt-1 text-sm text-[var(--muted-foreground)]`,children:[`Local catalog discovered from `,(0,H.jsx)(`code`,{children:`~/.rynx/skills`}),`.`]})]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(J,{variant:`outline`,onClick:()=>void y(),children:[(0,H.jsx)(zr,{}),` Refresh`]}),(0,H.jsx)(KS,{onInstalled:e=>{t(e),r(e[0]?.name??``)},triggerLabel:`From URL`,triggerVariant:`outline`}),(0,H.jsxs)(J,{variant:`outline`,onClick:()=>v(!0),children:[(0,H.jsx)(tr,{}),` From ZIP`]}),(0,H.jsxs)(J,{onClick:()=>g(!0),children:[(0,H.jsx)(Dr,{}),` From runtime`]})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,H.jsx)(qW,{label:`skills`,value:e?.length??0,detail:`Registered catalog entries`}),(0,H.jsx)(qW,{label:`local imports`,value:b,detail:`Immutable runtime copies`}),(0,H.jsx)(qW,{label:`selectable`,value:e?.filter(e=>e.ref).length??0,detail:`Skills with a valid receipt`})]}),(0,H.jsxs)(`div`,{className:`grid min-h-[640px] gap-4 lg:grid-cols-[320px_minmax(0,1fr)]`,children:[(0,H.jsxs)(fC,{className:`overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--border)] px-4 py-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Skill list`}),(0,H.jsx)(`span`,{className:`text-xs text-[var(--muted-foreground)]`,children:e?.length??0})]}),(0,H.jsxs)(`div`,{className:`grid gap-2 p-2`,children:[e===null&&(0,H.jsx)(`div`,{className:`px-3 py-6 text-sm text-[var(--muted-foreground)]`,children:`Loading Skills…`}),e?.length===0&&(0,H.jsx)(`div`,{className:`rounded-lg border border-dashed border-[var(--border)] px-4 py-6 text-sm text-[var(--muted-foreground)]`,children:`No local Skills registered yet.`}),e?.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>r(e.name),className:X(`flex w-full items-start gap-3 rounded-lg border px-3 py-3 text-left transition-colors`,n===e.name?`border-[var(--primary)] bg-[var(--primary)]/10`:`border-[var(--border)] hover:bg-[var(--muted)]/45`),children:[(0,H.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-md bg-amber-500/10 text-amber-600`,children:(0,H.jsx)(nr,{className:`size-4`})}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate font-mono text-sm font-semibold`,children:e.name}),n===e.name&&(0,H.jsx)(Ln,{className:`size-4 shrink-0 text-[var(--primary)]`})]}),(0,H.jsx)(`span`,{className:`mt-1 block line-clamp-2 text-xs text-[var(--muted-foreground)]`,children:e.description}),(0,H.jsx)(`span`,{className:`mt-2 inline-block rounded bg-[var(--muted)] px-1.5 py-1 text-[10px] text-[var(--muted-foreground)]`,children:e.ref?WW(e):`receipt-less`})]})]},e.name))]})]}),(0,H.jsx)(VW,{detail:i,loading:o,activeFile:c,onSelectFile:l,fileContent:d,fileLoading:p,onDeleted:y})]}),(0,H.jsx)(HW,{open:h,onOpenChange:g,onImported:async e=>{await y(),e&&r(e)}}),(0,H.jsx)(BW,{open:_,onOpenChange:v,onImported:async e=>{await y(),e&&r(e)}})]})}function BW({open:e,onOpenChange:t,onImported:n}){let[r,i]=(0,u.useState)(null),[a,o]=(0,u.useState)(!1),[s,c]=(0,u.useState)([]),l=r&&(!r.name.toLowerCase().endsWith(`.zip`)||r.size>20971520);async function d(){if(!(!r||l)){o(!0),c([]);try{let e=await Y.importSkillArchive(r.name,await KW(r));c(e);let t=e.find(e=>e.status===`created`||e.status===`updated`)?.name;await n(t)}catch(e){V.error(`Import ZIP failed: ${e.message}`)}finally{o(!1)}}}return(0,H.jsx)(Su,{open:e,onOpenChange:e=>{t(e),e||(i(null),c([]))},children:(0,H.jsxs)(Du,{className:`sm:max-w-xl`,children:[(0,H.jsx)(Ou,{children:(0,H.jsx)(Au,{children:`Import Skills from ZIP`})}),(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`label`,{className:`grid cursor-pointer place-items-center gap-2 rounded-lg border border-dashed border-[var(--border)] px-4 py-8 text-center hover:bg-[var(--muted)]/30`,children:[(0,H.jsx)(`input`,{type:`file`,accept:`.zip,application/zip`,className:`sr-only`,onChange:e=>{i(e.target.files?.[0]??null),c([])}}),(0,H.jsx)(tr,{className:`size-6 text-[var(--primary)]`}),(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:r?.name??`Choose a .zip archive`}),(0,H.jsx)(`span`,{className:`text-xs text-[var(--muted-foreground)]`,children:`One Skill at the root or multiple Skill directories, up to 20 MB.`})]}),l&&(0,H.jsx)(`div`,{className:`text-xs text-[var(--destructive)]`,children:`Choose a .zip archive no larger than 20 MB.`}),s.length>0&&(0,H.jsx)(GW,{results:s})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:`Done`}),(0,H.jsx)(J,{disabled:!r||!!l||a,onClick:()=>void d(),children:a?`Importing…`:`Import`})]})]})})}function VW({detail:e,loading:t,activeFile:n,onSelectFile:r,fileContent:i,fileLoading:a,onDeleted:o}){if(t||!e)return(0,H.jsx)(fC,{className:`p-6 text-sm text-[var(--muted-foreground)]`,children:t?`Loading Skill…`:`Select a Skill to inspect its files.`});let s=mk(e.ref?.install);return(0,H.jsxs)(fC,{className:`overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-[var(--border)] px-5 py-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`font-mono text-lg font-semibold`,children:e.name}),(0,H.jsx)(`span`,{className:`rounded bg-[var(--muted)] px-2 py-1 text-[10px] text-[var(--muted-foreground)]`,children:WW(e)})]}),(0,H.jsx)(`p`,{className:`mt-2 text-sm text-[var(--muted-foreground)]`,children:e.description}),s.source&&(0,H.jsx)(`div`,{className:`mt-2 max-w-2xl truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:s.source})]}),(0,H.jsx)(UW,{name:e.name,onDeleted:o})]}),(0,H.jsxs)(`div`,{className:`grid min-h-[500px] lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,H.jsxs)(`div`,{className:`border-b border-[var(--border)] p-3 lg:border-b-0 lg:border-r`,children:[(0,H.jsxs)(`div`,{className:`label-caps mb-2 px-1 text-[10px] text-[var(--muted-foreground)]`,children:[`files · `,e.files.length]}),(0,H.jsx)(`div`,{className:`grid gap-1`,children:e.files.map(e=>(0,H.jsxs)(`button`,{onClick:()=>r(e.path),className:X(`flex items-center gap-2 rounded-md px-2 py-2 text-left text-xs`,n===e.path?`bg-[var(--primary)]/10 text-[var(--primary)]`:`hover:bg-[var(--muted)]/50`),children:[(0,H.jsx)(nr,{className:`size-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.path}),(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--muted-foreground)]`,children:JW(e.size)})]},e.path))})]}),(0,H.jsxs)(`div`,{className:`min-w-0 p-4`,children:[(0,H.jsx)(`div`,{className:`mb-3 truncate font-mono text-xs text-[var(--muted-foreground)]`,children:n||`No file selected`}),(0,H.jsx)(`pre`,{className:`min-h-[440px] overflow-auto whitespace-pre-wrap break-words rounded-lg border border-[var(--border)] bg-[var(--muted)]/25 p-4 font-mono text-xs leading-5`,children:a?`Loading…`:i})]})]})]})}function HW({open:e,onOpenChange:t,onImported:n}){let[r,i]=(0,u.useState)([]),[a,o]=(0,u.useState)(``),[s,c]=(0,u.useState)([]),[l,d]=(0,u.useState)(new Set),[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)([]);(0,u.useEffect)(()=>{if(!e)return;let t=!1;return Y.listAgentRuntimeOptions().then(e=>{if(t)return;i(e);let n=e.find(e=>e.available)??e[0];o(n?.id??``)}).catch(e=>!t&&V.error(`Load runtimes failed: ${e.message}`)),()=>{t=!0}},[e]);function v(){c([]),d(new Set),_([]),p(!1),h(!1)}async function y(){if(a){p(!0),c([]),d(new Set),_([]);try{let e=await Y.scanLocalSkills(a);c(e)}catch(e){V.error(`Scan local Skills failed: ${e.message}`)}finally{p(!1)}}}async function b(){if(!(!a||l.size===0)){h(!0);try{let e=await Y.importLocalSkills(a,[...l]);_(e);let t=e.find(e=>e.status===`created`||e.status===`updated`)?.name;await n(t),V.success(`Local Skill import finished: ${e.filter(e=>e.status===`created`||e.status===`updated`).length} changed`)}catch(e){V.error(`Import local Skills failed: ${e.message}`)}finally{h(!1)}}}let x=s.length>0&&s.every(e=>l.has(e.key));return(0,H.jsx)(Su,{open:e,onOpenChange:e=>{t(e),e||v()},children:(0,H.jsxs)(Du,{className:`sm:max-w-3xl`,children:[(0,H.jsx)(Ou,{children:(0,H.jsx)(Au,{children:`Import Skills from a local runtime`})}),(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto_auto]`,children:[(0,H.jsxs)(my,{value:a,onValueChange:e=>{o(e),v()},disabled:r.length===0,children:[(0,H.jsx)(_y,{children:(0,H.jsx)(gy,{placeholder:`No local runtime found`})}),(0,H.jsx)(by,{children:r.map(e=>(0,H.jsxs)(Sy,{value:e.id,children:[e.name,e.version?` · ${e.version}`:``,e.available?``:` · CLI missing`]},e.id))})]}),(0,H.jsxs)(J,{variant:`outline`,disabled:!a||f,onClick:()=>void y(),children:[(0,H.jsx)(zr,{className:f?`animate-spin`:``}),` Scan`]}),(0,H.jsxs)(J,{variant:`outline`,disabled:s.length===0,onClick:()=>d(x?new Set:new Set(s.map(e=>e.key))),children:[(0,H.jsx)(Pn,{}),` `,x?`Clear`:`All`]})]}),(0,H.jsxs)(`div`,{className:`max-h-80 overflow-y-auto rounded-lg border border-[var(--border)]`,children:[f&&(0,H.jsx)(`div`,{className:`px-4 py-6 text-sm text-[var(--muted-foreground)]`,children:`Scanning local runtime Skill roots…`}),!f&&s.length===0&&(0,H.jsx)(`div`,{className:`px-4 py-6 text-sm text-[var(--muted-foreground)]`,children:`Choose a runtime family and click Scan. The local Skill directory can be scanned even when its CLI is missing.`}),!f&&s.map(e=>(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 border-b border-[var(--border)] px-4 py-3 last:border-0 hover:bg-[var(--muted)]/40`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-4`,checked:l.has(e.key),onChange:()=>d(t=>{let n=new Set(t);return n.has(e.key)?n.delete(e.key):n.add(e.key),n})}),(0,H.jsx)(ur,{className:`mt-0.5 size-4 shrink-0 text-[var(--primary)]`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.name}),(0,H.jsx)(`span`,{className:`rounded bg-[var(--muted)] px-1.5 py-1 text-[10px] text-[var(--muted-foreground)]`,children:e.root}),(0,H.jsxs)(`span`,{className:`rounded bg-[var(--muted)] px-1.5 py-1 text-[10px] text-[var(--muted-foreground)]`,children:[e.fileCount,` files`]})]}),(0,H.jsx)(`span`,{className:`mt-1 block text-xs text-[var(--muted-foreground)]`,children:e.description}),(0,H.jsx)(`span`,{className:`mt-1 block truncate font-mono text-[10px] text-[var(--muted-foreground)]`,children:e.sourcePath})]})]},e.key))]}),g.length>0&&(0,H.jsx)(`div`,{className:`max-h-44 overflow-y-auto rounded-lg border border-[var(--border)]`,children:g.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-[var(--border)] px-4 py-3 text-sm last:border-0`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`font-mono font-medium`,children:e.name}),e.message&&(0,H.jsx)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:e.message})]}),(0,H.jsx)(`span`,{className:X(`rounded px-2 py-1 text-xs`,e.status===`failed`||e.status===`conflict`?`bg-red-500/10 text-red-600`:e.status===`skipped`?`bg-[var(--muted)] text-[var(--muted-foreground)]`:`bg-emerald-500/10 text-emerald-600`),children:e.status})]},`${e.name}-${t}`))})]}),(0,H.jsxs)(ku,{children:[(0,H.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:`Done`}),(0,H.jsx)(J,{disabled:l.size===0||m,onClick:()=>void b(),children:m?`Importing…`:`Import ${l.size||``}`})]})]})})}function UW({name:e,onDeleted:t}){return(0,H.jsxs)(uu,{children:[(0,H.jsx)(du,{asChild:!0,children:(0,H.jsxs)(J,{variant:`ghost`,size:`sm`,className:`text-[var(--destructive)]`,children:[(0,H.jsx)(si,{}),` Remove`]})}),(0,H.jsxs)(mu,{children:[(0,H.jsxs)(hu,{children:[(0,H.jsxs)(vu,{children:[`Remove Skill "`,e,`"?`]}),(0,H.jsx)(yu,{children:`Removes the current catalog registration. Immutable artifacts referenced by existing Agents are preserved.`})]}),(0,H.jsxs)(gu,{children:[(0,H.jsx)(xu,{children:`Cancel`}),(0,H.jsx)(bu,{variant:`destructive`,onClick:async()=>{try{await Y.deleteSkill(e),V.success(`Skill "${e}" removed`),await t()}catch(e){V.error(`Remove failed: ${e.message}`)}},children:`Remove`})]})]})]})}function WW(e){let t=e.ref?.install.tool===`skills-cli`?e.ref.install.source:``;return t.includes(`/artifacts/skills/`)||t.includes(`\\artifacts\\skills\\`)?`local runtime`:e.ref?.install.tool===`command`?e.ref.install.command:t?`URL / repository`:`receipt-less`}function GW({results:e}){return(0,H.jsx)(`div`,{className:`max-h-44 overflow-y-auto rounded-lg border border-[var(--border)]`,children:e.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-[var(--border)] px-4 py-3 text-sm last:border-0`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`font-mono font-medium`,children:e.name}),e.message&&(0,H.jsx)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:e.message})]}),(0,H.jsx)(`span`,{className:X(`rounded px-2 py-1 text-xs`,e.status===`failed`||e.status===`conflict`?`bg-red-500/10 text-red-600`:e.status===`skipped`?`bg-[var(--muted)] text-[var(--muted-foreground)]`:`bg-emerald-500/10 text-emerald-600`),children:e.status})]},`${e.name}-${t}`))})}function KW(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`File read failed`)),r.onload=()=>{let e=String(r.result??``);t(e.includes(`,`)?e.slice(e.indexOf(`,`)+1):e)},r.readAsDataURL(e)})}function qW({label:e,value:t,detail:n}){return(0,H.jsxs)(fC,{className:`p-4`,children:[(0,H.jsx)(`div`,{className:`label-caps text-[10px] text-[var(--muted-foreground)]`,children:e}),(0,H.jsx)(`div`,{className:`mt-2 text-2xl font-semibold`,children:t}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-[var(--muted-foreground)]`,children:n})]})}function JW(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function YW(e){return e.daemonBuild?.restartRequired??!0}function XW(){let e=wS();return e?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(PS,{bridge:e,children:(0,H.jsx)(ZW,{desktopIntegrationAvailable:!0})}),(0,H.jsx)(zS,{bridge:e})]}):(0,H.jsx)(ZW,{desktopIntegrationAvailable:!1})}function ZW({desktopIntegrationAvailable:e}){let t=Rx(),{theme:n,toggle:r}=Hj(),i=$e(),a=Ex(i.pathname,e),o=(0,u.useRef)(null),[s,c]=(0,u.useState)([]),[l,d]=(0,u.useState)([]),[f,p]=(0,u.useState)(!1),m=(0,u.useCallback)(async()=>{try{c(await Y.listAgents())}catch(e){V.error(`Failed to load agents: ${e.message}`)}},[]),h=(0,u.useCallback)(async()=>{let e=await Promise.allSettled([Y.listPlugins(),Y.listAgents()]);e[0].status===`fulfilled`&&d(e[0].value),e[1].status===`fulfilled`&&c(e[1].value)},[]);(0,u.useEffect)(()=>{a&&a!==`emulator`&&h()},[h,a]),(0,u.useEffect)(()=>{if(t)return;let e=!0,n=async()=>{try{let t=await Y.meta();e&&p(YW(t))}catch{}};n();let r=window.setInterval(()=>void n(),15e3);return()=>{e=!1,window.clearInterval(r)}},[t]),(0,u.useEffect)(()=>{let e=window.requestAnimationFrame(()=>o.current?.focus({preventScroll:!0}));return()=>window.cancelAnimationFrame(e)},[i.pathname]);let g=ot([{path:`/`,element:(0,H.jsx)(Et,{replace:!0,to:px.sessions})},{path:mx,element:(0,H.jsx)(Et,{replace:!0,to:hx})},{path:px.overview,element:(0,H.jsx)(Rw,{plugins:l,agents:s,desktopIntegrationAvailable:e})},{path:px.runtimes,element:(0,H.jsx)(IT,{})},{path:px.providers,element:(0,H.jsx)(TT,{})},{path:px.projects,element:(0,H.jsx)(_T,{})},{path:px.plugins,element:(0,H.jsx)(Jw,{plugins:l,theme:n,onChange:h})},{path:px.agents,element:(0,H.jsx)(CC,{agents:s,onChange:m})},{path:px.skills,element:(0,H.jsx)(zW,{})},{path:gx,element:(0,H.jsx)(LW,{})},{path:_x,element:(0,H.jsx)(LW,{})},{path:px.sessions,element:(0,H.jsx)(LW,{})},{path:`${px.sessions}/:sessionId`,element:(0,H.jsx)(QW,{})},{path:px.emulator,element:(0,H.jsx)(ww,{})},...e?[{path:px.localRuntime,element:(0,H.jsx)(jw,{})},{path:px.computerUse,element:(0,H.jsx)(WC,{})}]:Sx.map(e=>({path:px[e],element:(0,H.jsx)(Et,{replace:!0,to:hx})})),...Object.entries(bx).map(([e,t])=>({path:t,element:(0,H.jsx)(Et,{replace:!0,to:px[e]})})),...Object.entries(xx).map(([e,t])=>({path:e,element:(0,H.jsx)(Et,{replace:!0,to:t})})),{path:`*`,element:(0,H.jsx)(Et,{replace:!0,to:px.sessions})}]);return(0,H.jsx)(MS,{theme:n,onToggleTheme:r,children:(0,H.jsxs)(`div`,{ref:o,id:`main-content`,tabIndex:-1,className:`flex h-full min-h-0 flex-col overflow-hidden focus:outline-none`,children:[f&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-start gap-2 border-b border-[color-mix(in_srgb,var(--warning)_35%,var(--border))] bg-[color-mix(in_srgb,var(--warning)_8%,var(--background))] px-4 py-2 text-xs text-[var(--warning)]`,children:[(0,H.jsx)(ci,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}),e?(0,H.jsxs)(`span`,{children:[`The local Runtime is running an older build. Restart it from`,` `,(0,H.jsx)(`strong`,{children:`Settings → Local Runtime`}),`, then reload this page.`]}):(0,H.jsxs)(`span`,{children:[`The resident daemon is running an older build. Run`,` `,(0,H.jsx)(`code`,{className:`font-mono font-semibold`,children:`rynx restart`}),`, then reload this page.`]})]}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:a?(0,H.jsx)(VS,{activeView:a,desktopIntegrationAvailable:e,children:g}):g})]})})}function QW(){let{sessionId:e}=it(),t=$e();if(!e)return(0,H.jsx)(Et,{replace:!0,to:px.sessions});let n=Ox(t.search)??`local`;return(0,H.jsx)(Et,{replace:!0,to:Ax(n,e)})}function $W(e){let{theme:t}=Hj();return(0,H.jsx)(Vi,{theme:t,...e})}window.rynxDesktopIntegration?.platform===`darwin`&&(document.documentElement.dataset.rynxDesktopPlatform=`macos`),(0,f.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(u.StrictMode,{children:(0,H.jsx)(pn,{children:(0,H.jsx)(bS,{children:(0,H.jsxs)(OS,{children:[(0,H.jsx)(XW,{}),(0,H.jsx)($W,{richColors:!0,position:`top-right`})]})})})}));export{iu as a,z as c,r as d,X as i,g as l,gA as n,Mc as o,mA as r,Ui as s,hA as t,s as u};
|