openfox 2.0.103 → 2.0.105
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/CHANGELOG.md +32 -0
- package/dist/CHANGELOG.md +32 -0
- package/dist/{ask-TOBEA6KD.js → ask-CJMU6EW7.js} +2 -2
- package/dist/{chat-handler-IBFSBSGV.js → chat-handler-CQIDZUR7.js} +20 -20
- package/dist/chunk-4H427UBV.js +1298 -0
- package/dist/{chunk-5ZJYEINJ.js → chunk-5M45NHQ2.js} +2 -2
- package/dist/{chunk-W5FTCTGY.js → chunk-5VKT34HE.js} +2 -2
- package/dist/{chunk-W5RC44R6.js → chunk-6IXRISXA.js} +8 -8
- package/dist/{chunk-FQS7A5M4.js → chunk-6SIX7P6O.js} +2 -2
- package/dist/{chunk-REQIAJTV.js → chunk-6XDKVVYS.js} +75 -70
- package/dist/{chunk-DPRJYQ5U.js → chunk-AKUTOOSV.js} +25 -25
- package/dist/{chunk-MGKS2NG2.js → chunk-B76OP3OE.js} +3 -3
- package/dist/{chunk-WPCYFH6X.js → chunk-DMI2BXHA.js} +4 -4
- package/dist/{chunk-KKEBXFB3.js → chunk-EF7KGWF6.js} +2 -2
- package/dist/{chunk-Z753S3X7.js → chunk-EIJFYENT.js} +22 -15
- package/dist/{chunk-MR7ZEGOF.js → chunk-ERKPMNC7.js} +5 -2
- package/dist/{chunk-ZLCPNTRT.js → chunk-ERTTKKCE.js} +6 -2
- package/dist/{chunk-73EV6QYX.js → chunk-FGYOSQUR.js} +4 -4
- package/dist/{chunk-4Z2ARCY3.js → chunk-J27BLIPY.js} +2 -2
- package/dist/{chunk-EU3WWTFH.js → chunk-JAX5OEMM.js} +5 -1
- package/dist/{chunk-QL2G5UWE.js → chunk-KDJZGHSZ.js} +23 -13
- package/dist/{chunk-JL657X72.js → chunk-LG57PZYL.js} +16 -16
- package/dist/{chunk-RZC6DAT2.js → chunk-OUMHR7LR.js} +2 -2
- package/dist/{chunk-BJDQPILB.js → chunk-PP3WNUA6.js} +3 -3
- package/dist/{chunk-2EYTYXWN.js → chunk-S5HDT5RQ.js} +2 -2
- package/dist/{chunk-K6VVTE6C.js → chunk-SGGFVTMP.js} +30 -20
- package/dist/{chunk-YZSBJUGC.js → chunk-SPA7PQPJ.js} +3 -1
- package/dist/{chunk-KLK5N4OX.js → chunk-TFQSCHVU.js} +3 -3
- package/dist/{chunk-7HIJP4PC.js → chunk-UADZ2LZJ.js} +2 -2
- package/dist/chunk-UBF62JJI.js +7 -0
- package/dist/{chunk-AI27N57J.js → chunk-UUMJ5PAW.js} +4 -8
- package/dist/{chunk-KCED2X4H.js → chunk-WDJOSRIB.js} +12 -5
- package/dist/cli/dev.js +2 -2
- package/dist/cli/index.js +2 -2
- package/dist/{client-Q7BHKOCD.js → client-XT4VHS7E.js} +5 -5
- package/dist/{client-pure-ONSVWEG5.js → client-pure-USVHN4WG.js} +2 -2
- package/dist/{compactor-43P3LGDU.js → compactor-JMO7FHYA.js} +11 -11
- package/dist/{dynamic-context-AMPVZXUU.js → dynamic-context-UJE6F7XT.js} +7 -7
- package/dist/{events-RCC32JOA.js → events-BGVLDGLK.js} +6 -6
- package/dist/{folding-ZNUXPQUD.js → folding-AJMZBHNR.js} +4 -4
- package/dist/{http-client-WGNBG7PC.js → http-client-A7A4XWNK.js} +3 -3
- package/dist/{manager-HFGJLW7Q.js → manager-GGIIENDX.js} +4 -4
- package/dist/{model-overrides-DQDT5Y7R.js → model-overrides-BLEFI7FQ.js} +3 -3
- package/dist/{orchestrator-QDXKDLOW.js → orchestrator-Y2MBWVOB.js} +19 -19
- package/dist/package.json +1 -1
- package/dist/{path-security-SUFEIBTC.js → path-security-JCDBLFIE.js} +7 -7
- package/dist/{platform-2RLL7RAE.js → platform-GZ2WIDS5.js} +3 -3
- package/dist/{processor-YWNLWAZW.js → processor-3IURFW2N.js} +19 -19
- package/dist/{protocol-BXgdUKgZ.d.ts → protocol-rfiBDoXm.d.ts} +1 -1
- package/dist/provider/index.d.ts +4 -4
- package/dist/{provider-FX3QCGAF.js → provider-ZXYITGFU.js} +69 -69
- package/dist/{provider-manager-GLG6BA32.js → provider-manager-QH5IIGHB.js} +6 -6
- package/dist/{pwa-SEWCVKZX.js → pwa-XPHP3PY2.js} +35 -35
- package/dist/{registry-GBNLVWYQ.js → registry-M2QVGRNK.js} +3 -3
- package/dist/{serve-FE4UAXGE.js → serve-OYLEY3HD.js} +27 -27
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +26 -26
- package/dist/server-L6YS6A6J.js +47 -0
- package/dist/{session-overrides-MBGBX6TM.js → session-overrides-HA5IQYLI.js} +5 -5
- package/dist/{sessions-FEIFYGH7.js → sessions-ZV2WRC6K.js} +4 -4
- package/dist/{settings-FT7HF7ZB.js → settings-TGCITCVA.js} +2 -2
- package/dist/shared/index.d.ts +3 -3
- package/dist/skill-defaults/browser/SKILL.md +36 -22
- package/dist/{tools-M5DKWCJJ.js → tools-BG44DIYU.js} +17 -17
- package/dist/{types-DBftgbfl.d.ts → types-o-YQ3Bfq.d.ts} +1 -1
- package/dist/{types-7idXD8Bq.d.ts → types-o0v5xVxu.d.ts} +1 -1
- package/dist/{update-KMPQUPQT.js → update-SOCIS7KO.js} +2 -2
- package/dist/web/assets/index-B7wjVPjL.css +40 -0
- package/dist/web/assets/index-BHIT-lGU.js +323 -0
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/dist/web/workbox-9c191d2f.js +1 -0
- package/package.json +1 -1
- package/dist/chunk-SQYMFWY7.js +0 -7
- package/dist/chunk-XY3LESVZ.js +0 -1000
- package/dist/server-QGQGSHW6.js +0 -47
- package/dist/web/assets/index-B0CNNl1k.css +0 -32
- package/dist/web/assets/index-FWViKQkM.js +0 -324
- package/dist/web/workbox-8c29f6e4.js +0 -1
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-DA-rfuFy.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/angular-ts-BrjP3tb8.js","assets/scss-D5BDwBP9.js","assets/apl-CORt7UWP.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-HNnZUWAn.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-2xfisSek.js","assets/html-derivative-DlHx6ybY.js","assets/sql-CRqJ_cUM.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nBiQ_Alo.js","assets/coffee-Ch7k5sss.js","assets/cpp-UfJy6YNI.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-DGywbUpC.js","assets/shellscript-Yzrsuije.js","assets/edge-FbVlp4U3.js","assets/elixir-CkH2-t6x.js","assets/elm-DbKCFpqz.js","assets/erb-Dm6A9KJ5.js","assets/ruby-DyJCeAvU.js","assets/haml-D5jkg6IW.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/erlang-DsQrWhSR.js","assets/markdown-Cvjx9yec.js","assets/fortran-fixed-form-CkoXwp7k.js","assets/fortran-free-form-BxgE0vQu.js","assets/fsharp-CXgrBDvD.js","assets/gdresource-BOOCDP_w.js","assets/gdshader-DkwncUOv.js","assets/gdscript-C5YyOfLZ.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-ByusRIyA.js","assets/glimmer-ts-BfAWNZQY.js","assets/hack-DbPARsA_.js","assets/handlebars-BpdQsYii.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-f2NsQr07.js","assets/jison-wvAkD_A8.js","assets/julia-D7OTSIA_.js","assets/r-Dspwwk_N.js","assets/just-CUsbIsdP.js","assets/perl-B9cMNwum.js","assets/latex-CaSxy8MP.js","assets/tex-idrVyKtj.js","assets/liquid-C0sCDyMI.js","assets/marko-DjSrsDqO.js","assets/less-B1dDrJ26.js","assets/mdc-DTYItulj.js","assets/nextflow-C-mBbutL.js","assets/nextflow-groovy-vE_lwT2v.js","assets/nginx-BpAMiNFr.js","assets/nim-BIad80T-.js","assets/php-Csjmro_R.js","assets/pug-DKIMFp6K.js","assets/qml-3beO22l8.js","assets/razor-BjBPvh-w.js","assets/csharp-DSvCPggb.js","assets/rst-CpCqk9r5.js","assets/cmake-D1j8_8rp.js","assets/sas-DEy46yEz.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-8wufbnw4.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-DI20mbqo.js","assets/surrealql-Bq5Q-fJD.js","assets/svelte-Cy7k_4gC.js","assets/templ-DhtptRzy.js","assets/go-C27-OAKa.js","assets/ts-tags-D351s5mN.js","assets/twig-CW1WmMYd.js","assets/vue-D2xRrEX4.js","assets/vue-html-AaS7Mt5G.js","assets/vue-vine-BoDAl6tE.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var nL=Object.defineProperty;var rL=Object.getPrototypeOf;var sL=Reflect.get;var Q0=e=>{throw TypeError(e)};var iL=(e,t,n)=>t in e?nL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ne=(e,t,n)=>iL(e,typeof t!="symbol"?t+"":t,n),Ep=(e,t,n)=>t.has(e)||Q0("Cannot "+n);var Xn=(e,t,n)=>(Ep(e,t,"read from private field"),n?n.call(e):t.get(e)),ha=(e,t,n)=>t.has(e)?Q0("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Yr=(e,t,n,r)=>(Ep(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Np=(e,t,n)=>(Ep(e,t,"access private method"),n);var J0=(e,t,n)=>sL(rL(e),n,t);function aL(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const l=Object.getOwnPropertyDescriptor(r,a);l&&Object.defineProperty(e,a,l.get?l:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();function Lh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Tp={exports:{}},Jl={};/**
|
|
3
|
+
* @license React
|
|
4
|
+
* react-jsx-runtime.production.js
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/var Z0;function oL(){if(Z0)return Jl;Z0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,l){var u=null;if(l!==void 0&&(u=""+l),a.key!==void 0&&(u=""+a.key),"key"in a){l={};for(var c in a)c!=="key"&&(l[c]=a[c])}else l=a;return a=l.ref,{$$typeof:e,type:r,key:u,ref:a!==void 0?a:null,props:l}}return Jl.Fragment=t,Jl.jsx=n,Jl.jsxs=n,Jl}var eS;function lL(){return eS||(eS=1,Tp.exports=oL()),Tp.exports}var i=lL(),Ap={exports:{}},bt={};/**
|
|
11
|
+
* @license React
|
|
12
|
+
* react.production.js
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the MIT license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*/var tS;function cL(){if(tS)return bt;tS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),x=Symbol.iterator;function y(B){return B===null||typeof B!="object"?null:(B=x&&B[x]||B["@@iterator"],typeof B=="function"?B:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,v={};function w(B,q,$){this.props=B,this.context=q,this.refs=v,this.updater=$||S}w.prototype.isReactComponent={},w.prototype.setState=function(B,q){if(typeof B!="object"&&typeof B!="function"&&B!=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,B,q,"setState")},w.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function _(){}_.prototype=w.prototype;function b(B,q,$){this.props=B,this.context=q,this.refs=v,this.updater=$||S}var k=b.prototype=new _;k.constructor=b,C(k,w.prototype),k.isPureReactComponent=!0;var E=Array.isArray;function T(){}var D={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function R(B,q,$){var Y=$.ref;return{$$typeof:e,type:B,key:q,ref:Y!==void 0?Y:null,props:$}}function M(B,q){return R(B.type,q,B.props)}function W(B){return typeof B=="object"&&B!==null&&B.$$typeof===e}function z(B){var q={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function($){return q[$]})}var H=/\/+/g;function I(B,q){return typeof B=="object"&&B!==null&&B.key!=null?z(""+B.key):q.toString(36)}function U(B){switch(B.status){case"fulfilled":return B.value;case"rejected":throw B.reason;default:switch(typeof B.status=="string"?B.then(T,T):(B.status="pending",B.then(function(q){B.status==="pending"&&(B.status="fulfilled",B.value=q)},function(q){B.status==="pending"&&(B.status="rejected",B.reason=q)})),B.status){case"fulfilled":return B.value;case"rejected":throw B.reason}}throw B}function V(B,q,$,Y,Q){var X=typeof B;(X==="undefined"||X==="boolean")&&(B=null);var K=!1;if(B===null)K=!0;else switch(X){case"bigint":case"string":case"number":K=!0;break;case"object":switch(B.$$typeof){case e:case t:K=!0;break;case p:return K=B._init,V(K(B._payload),q,$,Y,Q)}}if(K)return Q=Q(B),K=Y===""?"."+I(B,0):Y,E(Q)?($="",K!=null&&($=K.replace(H,"$&/")+"/"),V(Q,q,$,"",function(ne){return ne})):Q!=null&&(W(Q)&&(Q=M(Q,$+(Q.key==null||B&&B.key===Q.key?"":(""+Q.key).replace(H,"$&/")+"/")+K)),q.push(Q)),1;K=0;var P=Y===""?".":Y+":";if(E(B))for(var J=0;J<B.length;J++)Y=B[J],X=P+I(Y,J),K+=V(Y,q,$,X,Q);else if(J=y(B),typeof J=="function")for(B=J.call(B),J=0;!(Y=B.next()).done;)Y=Y.value,X=P+I(Y,J++),K+=V(Y,q,$,X,Q);else if(X==="object"){if(typeof B.then=="function")return V(U(B),q,$,Y,Q);throw q=String(B),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return K}function Z(B,q,$){if(B==null)return B;var Y=[],Q=0;return V(B,Y,"","",function(X){return q.call($,X,Q++)}),Y}function ee(B){if(B._status===-1){var q=B._result;q=q(),q.then(function($){(B._status===0||B._status===-1)&&(B._status=1,B._result=$)},function($){(B._status===0||B._status===-1)&&(B._status=2,B._result=$)}),B._status===-1&&(B._status=0,B._result=q)}if(B._status===1)return B._result.default;throw B._result}var F=typeof reportError=="function"?reportError:function(B){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof B=="object"&&B!==null&&typeof B.message=="string"?String(B.message):String(B),error:B});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",B);return}console.error(B)},O={map:Z,forEach:function(B,q,$){Z(B,function(){q.apply(this,arguments)},$)},count:function(B){var q=0;return Z(B,function(){q++}),q},toArray:function(B){return Z(B,function(q){return q})||[]},only:function(B){if(!W(B))throw Error("React.Children.only expected to receive a single React element child.");return B}};return bt.Activity=m,bt.Children=O,bt.Component=w,bt.Fragment=n,bt.Profiler=a,bt.PureComponent=b,bt.StrictMode=r,bt.Suspense=d,bt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=D,bt.__COMPILER_RUNTIME={__proto__:null,c:function(B){return D.H.useMemoCache(B)}},bt.cache=function(B){return function(){return B.apply(null,arguments)}},bt.cacheSignal=function(){return null},bt.cloneElement=function(B,q,$){if(B==null)throw Error("The argument must be a React element, but you passed "+B+".");var Y=C({},B.props),Q=B.key;if(q!=null)for(X in q.key!==void 0&&(Q=""+q.key),q)!L.call(q,X)||X==="key"||X==="__self"||X==="__source"||X==="ref"&&q.ref===void 0||(Y[X]=q[X]);var X=arguments.length-2;if(X===1)Y.children=$;else if(1<X){for(var K=Array(X),P=0;P<X;P++)K[P]=arguments[P+2];Y.children=K}return R(B.type,Q,Y)},bt.createContext=function(B){return B={$$typeof:u,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null},B.Provider=B,B.Consumer={$$typeof:l,_context:B},B},bt.createElement=function(B,q,$){var Y,Q={},X=null;if(q!=null)for(Y in q.key!==void 0&&(X=""+q.key),q)L.call(q,Y)&&Y!=="key"&&Y!=="__self"&&Y!=="__source"&&(Q[Y]=q[Y]);var K=arguments.length-2;if(K===1)Q.children=$;else if(1<K){for(var P=Array(K),J=0;J<K;J++)P[J]=arguments[J+2];Q.children=P}if(B&&B.defaultProps)for(Y in K=B.defaultProps,K)Q[Y]===void 0&&(Q[Y]=K[Y]);return R(B,X,Q)},bt.createRef=function(){return{current:null}},bt.forwardRef=function(B){return{$$typeof:c,render:B}},bt.isValidElement=W,bt.lazy=function(B){return{$$typeof:p,_payload:{_status:-1,_result:B},_init:ee}},bt.memo=function(B,q){return{$$typeof:h,type:B,compare:q===void 0?null:q}},bt.startTransition=function(B){var q=D.T,$={};D.T=$;try{var Y=B(),Q=D.S;Q!==null&&Q($,Y),typeof Y=="object"&&Y!==null&&typeof Y.then=="function"&&Y.then(T,F)}catch(X){F(X)}finally{q!==null&&$.types!==null&&(q.types=$.types),D.T=q}},bt.unstable_useCacheRefresh=function(){return D.H.useCacheRefresh()},bt.use=function(B){return D.H.use(B)},bt.useActionState=function(B,q,$){return D.H.useActionState(B,q,$)},bt.useCallback=function(B,q){return D.H.useCallback(B,q)},bt.useContext=function(B){return D.H.useContext(B)},bt.useDebugValue=function(){},bt.useDeferredValue=function(B,q){return D.H.useDeferredValue(B,q)},bt.useEffect=function(B,q){return D.H.useEffect(B,q)},bt.useEffectEvent=function(B){return D.H.useEffectEvent(B)},bt.useId=function(){return D.H.useId()},bt.useImperativeHandle=function(B,q,$){return D.H.useImperativeHandle(B,q,$)},bt.useInsertionEffect=function(B,q){return D.H.useInsertionEffect(B,q)},bt.useLayoutEffect=function(B,q){return D.H.useLayoutEffect(B,q)},bt.useMemo=function(B,q){return D.H.useMemo(B,q)},bt.useOptimistic=function(B,q){return D.H.useOptimistic(B,q)},bt.useReducer=function(B,q,$){return D.H.useReducer(B,q,$)},bt.useRef=function(B){return D.H.useRef(B)},bt.useState=function(B){return D.H.useState(B)},bt.useSyncExternalStore=function(B,q,$){return D.H.useSyncExternalStore(B,q,$)},bt.useTransition=function(){return D.H.useTransition()},bt.version="19.2.8",bt}var nS;function Dh(){return nS||(nS=1,Ap.exports=cL()),Ap.exports}var N=Dh();const bs=Lh(N),uL=aL({__proto__:null,default:bs},[N]);var Lp={exports:{}},Zl={},Dp={exports:{}},Rp={};/**
|
|
19
|
+
* @license React
|
|
20
|
+
* scheduler.production.js
|
|
21
|
+
*
|
|
22
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the MIT license found in the
|
|
25
|
+
* LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/var rS;function dL(){return rS||(rS=1,(function(e){function t(V,Z){var ee=V.length;V.push(Z);e:for(;0<ee;){var F=ee-1>>>1,O=V[F];if(0<a(O,Z))V[F]=Z,V[ee]=O,ee=F;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var Z=V[0],ee=V.pop();if(ee!==Z){V[0]=ee;e:for(var F=0,O=V.length,B=O>>>1;F<B;){var q=2*(F+1)-1,$=V[q],Y=q+1,Q=V[Y];if(0>a($,ee))Y<O&&0>a(Q,$)?(V[F]=Q,V[Y]=ee,F=Y):(V[F]=$,V[q]=ee,F=q);else if(Y<O&&0>a(Q,ee))V[F]=Q,V[Y]=ee,F=Y;else break e}}return Z}function a(V,Z){var ee=V.sortIndex-Z.sortIndex;return ee!==0?ee:V.id-Z.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],h=[],p=1,m=null,x=3,y=!1,S=!1,C=!1,v=!1,w=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;function k(V){for(var Z=n(h);Z!==null;){if(Z.callback===null)r(h);else if(Z.startTime<=V)r(h),Z.sortIndex=Z.expirationTime,t(d,Z);else break;Z=n(h)}}function E(V){if(C=!1,k(V),!S)if(n(d)!==null)S=!0,T||(T=!0,z());else{var Z=n(h);Z!==null&&U(E,Z.startTime-V)}}var T=!1,D=-1,L=5,R=-1;function M(){return v?!0:!(e.unstable_now()-R<L)}function W(){if(v=!1,T){var V=e.unstable_now();R=V;var Z=!0;try{e:{S=!1,C&&(C=!1,_(D),D=-1),y=!0;var ee=x;try{t:{for(k(V),m=n(d);m!==null&&!(m.expirationTime>V&&M());){var F=m.callback;if(typeof F=="function"){m.callback=null,x=m.priorityLevel;var O=F(m.expirationTime<=V);if(V=e.unstable_now(),typeof O=="function"){m.callback=O,k(V),Z=!0;break t}m===n(d)&&r(d),k(V)}else r(d);m=n(d)}if(m!==null)Z=!0;else{var B=n(h);B!==null&&U(E,B.startTime-V),Z=!1}}break e}finally{m=null,x=ee,y=!1}Z=void 0}}finally{Z?z():T=!1}}}var z;if(typeof b=="function")z=function(){b(W)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,I=H.port2;H.port1.onmessage=W,z=function(){I.postMessage(null)}}else z=function(){w(W,0)};function U(V,Z){D=w(function(){V(e.unstable_now())},Z)}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(V){V.callback=null},e.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<V?Math.floor(1e3/V):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(V){switch(x){case 1:case 2:case 3:var Z=3;break;default:Z=x}var ee=x;x=Z;try{return V()}finally{x=ee}},e.unstable_requestPaint=function(){v=!0},e.unstable_runWithPriority=function(V,Z){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var ee=x;x=V;try{return Z()}finally{x=ee}},e.unstable_scheduleCallback=function(V,Z,ee){var F=e.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?F+ee:F):ee=F,V){case 1:var O=-1;break;case 2:O=250;break;case 5:O=1073741823;break;case 4:O=1e4;break;default:O=5e3}return O=ee+O,V={id:p++,callback:Z,priorityLevel:V,startTime:ee,expirationTime:O,sortIndex:-1},ee>F?(V.sortIndex=ee,t(h,V),n(d)===null&&V===n(h)&&(C?(_(D),D=-1):C=!0,U(E,ee-F))):(V.sortIndex=O,t(d,V),S||y||(S=!0,T||(T=!0,z()))),V},e.unstable_shouldYield=M,e.unstable_wrapCallback=function(V){var Z=x;return function(){var ee=x;x=Z;try{return V.apply(this,arguments)}finally{x=ee}}}})(Rp)),Rp}var sS;function hL(){return sS||(sS=1,Dp.exports=dL()),Dp.exports}var Op={exports:{}},Hn={};/**
|
|
27
|
+
* @license React
|
|
28
|
+
* react-dom.production.js
|
|
29
|
+
*
|
|
30
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
31
|
+
*
|
|
32
|
+
* This source code is licensed under the MIT license found in the
|
|
33
|
+
* LICENSE file in the root directory of this source tree.
|
|
34
|
+
*/var iS;function fL(){if(iS)return Hn;iS=1;var e=Dh();function t(d){var h="https://react.dev/errors/"+d;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)h+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+d+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");function l(d,h,p){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:m==null?null:""+m,children:d,containerInfo:h,implementation:p}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(d,h){if(d==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Hn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Hn.createPortal=function(d,h){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return l(d,h,null,p)},Hn.flushSync=function(d){var h=u.T,p=r.p;try{if(u.T=null,r.p=2,d)return d()}finally{u.T=h,r.p=p,r.d.f()}},Hn.preconnect=function(d,h){typeof d=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,r.d.C(d,h))},Hn.prefetchDNS=function(d){typeof d=="string"&&r.d.D(d)},Hn.preinit=function(d,h){if(typeof d=="string"&&h&&typeof h.as=="string"){var p=h.as,m=c(p,h.crossOrigin),x=typeof h.integrity=="string"?h.integrity:void 0,y=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;p==="style"?r.d.S(d,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:m,integrity:x,fetchPriority:y}):p==="script"&&r.d.X(d,{crossOrigin:m,integrity:x,fetchPriority:y,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Hn.preinitModule=function(d,h){if(typeof d=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var p=c(h.as,h.crossOrigin);r.d.M(d,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&r.d.M(d)},Hn.preload=function(d,h){if(typeof d=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var p=h.as,m=c(p,h.crossOrigin);r.d.L(d,p,{crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Hn.preloadModule=function(d,h){if(typeof d=="string")if(h){var p=c(h.as,h.crossOrigin);r.d.m(d,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(d)},Hn.requestFormReset=function(d){r.d.r(d)},Hn.unstable_batchedUpdates=function(d,h){return d(h)},Hn.useFormState=function(d,h,p){return u.H.useFormState(d,h,p)},Hn.useFormStatus=function(){return u.H.useHostTransitionStatus()},Hn.version="19.2.8",Hn}var aS;function CC(){if(aS)return Op.exports;aS=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Op.exports=fL(),Op.exports}/**
|
|
35
|
+
* @license React
|
|
36
|
+
* react-dom-client.production.js
|
|
37
|
+
*
|
|
38
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the MIT license found in the
|
|
41
|
+
* LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/var oS;function mL(){if(oS)return Zl;oS=1;var e=hL(),t=Dh(),n=CC();function r(s){var o="https://react.dev/errors/"+s;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var f=2;f<arguments.length;f++)o+="&args[]="+encodeURIComponent(arguments[f])}return"Minified React error #"+s+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function l(s){var o=s,f=s;if(s.alternate)for(;o.return;)o=o.return;else{s=o;do o=s,(o.flags&4098)!==0&&(f=o.return),s=o.return;while(s)}return o.tag===3?f:null}function u(s){if(s.tag===13){var o=s.memoizedState;if(o===null&&(s=s.alternate,s!==null&&(o=s.memoizedState)),o!==null)return o.dehydrated}return null}function c(s){if(s.tag===31){var o=s.memoizedState;if(o===null&&(s=s.alternate,s!==null&&(o=s.memoizedState)),o!==null)return o.dehydrated}return null}function d(s){if(l(s)!==s)throw Error(r(188))}function h(s){var o=s.alternate;if(!o){if(o=l(s),o===null)throw Error(r(188));return o!==s?null:s}for(var f=s,g=o;;){var j=f.return;if(j===null)break;var A=j.alternate;if(A===null){if(g=j.return,g!==null){f=g;continue}break}if(j.child===A.child){for(A=j.child;A;){if(A===f)return d(j),s;if(A===g)return d(j),o;A=A.sibling}throw Error(r(188))}if(f.return!==g.return)f=j,g=A;else{for(var G=!1,te=j.child;te;){if(te===f){G=!0,f=j,g=A;break}if(te===g){G=!0,g=j,f=A;break}te=te.sibling}if(!G){for(te=A.child;te;){if(te===f){G=!0,f=A,g=j;break}if(te===g){G=!0,g=A,f=j;break}te=te.sibling}if(!G)throw Error(r(189))}}if(f.alternate!==g)throw Error(r(190))}if(f.tag!==3)throw Error(r(188));return f.stateNode.current===f?s:o}function p(s){var o=s.tag;if(o===5||o===26||o===27||o===6)return s;for(s=s.child;s!==null;){if(o=p(s),o!==null)return o;s=s.sibling}return null}var m=Object.assign,x=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),b=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),R=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),W=Symbol.iterator;function z(s){return s===null||typeof s!="object"?null:(s=W&&s[W]||s["@@iterator"],typeof s=="function"?s:null)}var H=Symbol.for("react.client.reference");function I(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===H?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case C:return"Fragment";case w:return"Profiler";case v:return"StrictMode";case E:return"Suspense";case T:return"SuspenseList";case R:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case S:return"Portal";case b:return s.displayName||"Context";case _:return(s._context.displayName||"Context")+".Consumer";case k:var o=s.render;return s=s.displayName,s||(s=o.displayName||o.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case D:return o=s.displayName||null,o!==null?o:I(s.type)||"Memo";case L:o=s._payload,s=s._init;try{return I(s(o))}catch{}}return null}var U=Array.isArray,V=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee={pending:!1,data:null,method:null,action:null},F=[],O=-1;function B(s){return{current:s}}function q(s){0>O||(s.current=F[O],F[O]=null,O--)}function $(s,o){O++,F[O]=s.current,s.current=o}var Y=B(null),Q=B(null),X=B(null),K=B(null);function P(s,o){switch($(X,o),$(Q,s),$(Y,null),o.nodeType){case 9:case 11:s=(s=o.documentElement)&&(s=s.namespaceURI)?v0(s):0;break;default:if(s=o.tagName,o=o.namespaceURI)o=v0(o),s=_0(o,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}q(Y),$(Y,s)}function J(){q(Y),q(Q),q(X)}function ne(s){s.memoizedState!==null&&$(K,s);var o=Y.current,f=_0(o,s.type);o!==f&&($(Q,s),$(Y,f))}function ce(s){Q.current===s&&(q(Y),q(Q)),K.current===s&&(q(K),Kl._currentValue=ee)}var ae,Ee;function ve(s){if(ae===void 0)try{throw Error()}catch(f){var o=f.stack.trim().match(/\n( *(at )?)/);ae=o&&o[1]||"",Ee=-1<f.stack.indexOf(`
|
|
43
|
+
at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
+
`+ae+s+Ee}var Le=!1;function Me(s,o){if(!s||Le)return"";Le=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(o){var Oe=function(){throw Error()};if(Object.defineProperty(Oe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Oe,[])}catch(je){var be=je}Reflect.construct(s,[],Oe)}else{try{Oe.call()}catch(je){be=je}s.call(Oe.prototype)}}else{try{throw Error()}catch(je){be=je}(Oe=s())&&typeof Oe.catch=="function"&&Oe.catch(function(){})}}catch(je){if(je&&be&&typeof je.stack=="string")return[je.stack,be.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var j=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");j&&j.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var A=g.DetermineComponentFrameRoot(),G=A[0],te=A[1];if(G&&te){var oe=G.split(`
|
|
45
|
+
`),pe=te.split(`
|
|
46
|
+
`);for(j=g=0;g<oe.length&&!oe[g].includes("DetermineComponentFrameRoot");)g++;for(;j<pe.length&&!pe[j].includes("DetermineComponentFrameRoot");)j++;if(g===oe.length||j===pe.length)for(g=oe.length-1,j=pe.length-1;1<=g&&0<=j&&oe[g]!==pe[j];)j--;for(;1<=g&&0<=j;g--,j--)if(oe[g]!==pe[j]){if(g!==1||j!==1)do if(g--,j--,0>j||oe[g]!==pe[j]){var Te=`
|
|
47
|
+
`+oe[g].replace(" at new "," at ");return s.displayName&&Te.includes("<anonymous>")&&(Te=Te.replace("<anonymous>",s.displayName)),Te}while(1<=g&&0<=j);break}}}finally{Le=!1,Error.prepareStackTrace=f}return(f=s?s.displayName||s.name:"")?ve(f):""}function ke(s,o){switch(s.tag){case 26:case 27:case 5:return ve(s.type);case 16:return ve("Lazy");case 13:return s.child!==o&&o!==null?ve("Suspense Fallback"):ve("Suspense");case 19:return ve("SuspenseList");case 0:case 15:return Me(s.type,!1);case 11:return Me(s.type.render,!1);case 1:return Me(s.type,!0);case 31:return ve("Activity");default:return""}}function Ge(s){try{var o="",f=null;do o+=ke(s,f),f=s,s=s.return;while(s);return o}catch(g){return`
|
|
48
|
+
Error generating stack: `+g.message+`
|
|
49
|
+
`+g.stack}}var Xe=Object.prototype.hasOwnProperty,Se=e.unstable_scheduleCallback,Ie=e.unstable_cancelCallback,it=e.unstable_shouldYield,ge=e.unstable_requestPaint,Fe=e.unstable_now,He=e.unstable_getCurrentPriorityLevel,ie=e.unstable_ImmediatePriority,xe=e.unstable_UserBlockingPriority,se=e.unstable_NormalPriority,he=e.unstable_LowPriority,Pe=e.unstable_IdlePriority,qe=e.log,Ke=e.unstable_setDisableYieldValue,et=null,ot=null;function ue(s){if(typeof qe=="function"&&Ke(s),ot&&typeof ot.setStrictMode=="function")try{ot.setStrictMode(et,s)}catch{}}var $e=Math.clz32?Math.clz32:cn,ut=Math.log,ct=Math.LN2;function cn(s){return s>>>=0,s===0?32:31-(ut(s)/ct|0)|0}var Xt=256,rn=262144,On=4194304;function ye(s){var o=s&42;if(o!==0)return o;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Ye(s,o,f){var g=s.pendingLanes;if(g===0)return 0;var j=0,A=s.suspendedLanes,G=s.pingedLanes;s=s.warmLanes;var te=g&134217727;return te!==0?(g=te&~A,g!==0?j=ye(g):(G&=te,G!==0?j=ye(G):f||(f=te&~s,f!==0&&(j=ye(f))))):(te=g&~A,te!==0?j=ye(te):G!==0?j=ye(G):f||(f=g&~s,f!==0&&(j=ye(f)))),j===0?0:o!==0&&o!==j&&(o&A)===0&&(A=j&-j,f=o&-o,A>=f||A===32&&(f&4194048)!==0)?o:j}function We(s,o){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&o)===0}function ze(s,o){switch(s){case 1:case 2:case 4:case 8:case 64:return o+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return o+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function tt(){var s=On;return On<<=1,(On&62914560)===0&&(On=4194304),s}function Lt(s){for(var o=[],f=0;31>f;f++)o.push(s);return o}function hn(s,o){s.pendingLanes|=o,o!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function fn(s,o,f,g,j,A){var G=s.pendingLanes;s.pendingLanes=f,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=f,s.entangledLanes&=f,s.errorRecoveryDisabledLanes&=f,s.shellSuspendCounter=0;var te=s.entanglements,oe=s.expirationTimes,pe=s.hiddenUpdates;for(f=G&~f;0<f;){var Te=31-$e(f),Oe=1<<Te;te[Te]=0,oe[Te]=-1;var be=pe[Te];if(be!==null)for(pe[Te]=null,Te=0;Te<be.length;Te++){var je=be[Te];je!==null&&(je.lane&=-536870913)}f&=~Oe}g!==0&&Kn(s,g,0),A!==0&&j===0&&s.tag!==0&&(s.suspendedLanes|=A&~(G&~o))}function Kn(s,o,f){s.pendingLanes|=o,s.suspendedLanes&=~o;var g=31-$e(o);s.entangledLanes|=o,s.entanglements[g]=s.entanglements[g]|1073741824|f&261930}function _e(s,o){var f=s.entangledLanes|=o;for(s=s.entanglements;f;){var g=31-$e(f),j=1<<g;j&o|s[g]&o&&(s[g]|=o),f&=~j}}function rt(s,o){var f=o&-o;return f=(f&42)!==0?1:fe(f),(f&(s.suspendedLanes|o))!==0?0:f}function fe(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function we(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function Be(){var s=Z.p;return s!==0?s:(s=window.event,s===void 0?32:V0(s.type))}function Qe(s,o){var f=Z.p;try{return Z.p=s,o()}finally{Z.p=f}}var Je=Math.random().toString(36).slice(2),at="__reactFiber$"+Je,dt="__reactProps$"+Je,sn="__reactContainer$"+Je,kn="__reactEvents$"+Je,fr="__reactListeners$"+Je,GN="__reactHandles$"+Je,ob="__reactResources$"+Je,cl="__reactMarker$"+Je;function bf(s){delete s[at],delete s[dt],delete s[kn],delete s[fr],delete s[GN]}function Ha(s){var o=s[at];if(o)return o;for(var f=s.parentNode;f;){if(o=f[sn]||f[at]){if(f=o.alternate,o.child!==null||f!==null&&f.child!==null)for(s=N0(s);s!==null;){if(f=s[at])return f;s=N0(s)}return o}s=f,f=s.parentNode}return null}function Fa(s){if(s=s[at]||s[sn]){var o=s.tag;if(o===5||o===6||o===13||o===31||o===26||o===27||o===3)return s}return null}function ul(s){var o=s.tag;if(o===5||o===26||o===27||o===6)return s.stateNode;throw Error(r(33))}function Ua(s){var o=s[ob];return o||(o=s[ob]={hoistableStyles:new Map,hoistableScripts:new Map}),o}function An(s){s[cl]=!0}var lb=new Set,cb={};function Yi(s,o){Va(s,o),Va(s+"Capture",o)}function Va(s,o){for(cb[s]=o,s=0;s<o.length;s++)lb.add(o[s])}var qN=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),ub={},db={};function KN(s){return Xe.call(db,s)?!0:Xe.call(ub,s)?!1:qN.test(s)?db[s]=!0:(ub[s]=!0,!1)}function tu(s,o,f){if(KN(o))if(f===null)s.removeAttribute(o);else{switch(typeof f){case"undefined":case"function":case"symbol":s.removeAttribute(o);return;case"boolean":var g=o.toLowerCase().slice(0,5);if(g!=="data-"&&g!=="aria-"){s.removeAttribute(o);return}}s.setAttribute(o,""+f)}}function nu(s,o,f){if(f===null)s.removeAttribute(o);else{switch(typeof f){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(o);return}s.setAttribute(o,""+f)}}function js(s,o,f,g){if(g===null)s.removeAttribute(f);else{switch(typeof g){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(f);return}s.setAttributeNS(o,f,""+g)}}function Nr(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function hb(s){var o=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function YN(s,o,f){var g=Object.getOwnPropertyDescriptor(s.constructor.prototype,o);if(!s.hasOwnProperty(o)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var j=g.get,A=g.set;return Object.defineProperty(s,o,{configurable:!0,get:function(){return j.call(this)},set:function(G){f=""+G,A.call(this,G)}}),Object.defineProperty(s,o,{enumerable:g.enumerable}),{getValue:function(){return f},setValue:function(G){f=""+G},stopTracking:function(){s._valueTracker=null,delete s[o]}}}}function vf(s){if(!s._valueTracker){var o=hb(s)?"checked":"value";s._valueTracker=YN(s,o,""+s[o])}}function fb(s){if(!s)return!1;var o=s._valueTracker;if(!o)return!0;var f=o.getValue(),g="";return s&&(g=hb(s)?s.checked?"true":"false":s.value),s=g,s!==f?(o.setValue(s),!0):!1}function ru(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var XN=/[\n"\\]/g;function Tr(s){return s.replace(XN,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function _f(s,o,f,g,j,A,G,te){s.name="",G!=null&&typeof G!="function"&&typeof G!="symbol"&&typeof G!="boolean"?s.type=G:s.removeAttribute("type"),o!=null?G==="number"?(o===0&&s.value===""||s.value!=o)&&(s.value=""+Nr(o)):s.value!==""+Nr(o)&&(s.value=""+Nr(o)):G!=="submit"&&G!=="reset"||s.removeAttribute("value"),o!=null?Sf(s,G,Nr(o)):f!=null?Sf(s,G,Nr(f)):g!=null&&s.removeAttribute("value"),j==null&&A!=null&&(s.defaultChecked=!!A),j!=null&&(s.checked=j&&typeof j!="function"&&typeof j!="symbol"),te!=null&&typeof te!="function"&&typeof te!="symbol"&&typeof te!="boolean"?s.name=""+Nr(te):s.removeAttribute("name")}function mb(s,o,f,g,j,A,G,te){if(A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"&&(s.type=A),o!=null||f!=null){if(!(A!=="submit"&&A!=="reset"||o!=null)){vf(s);return}f=f!=null?""+Nr(f):"",o=o!=null?""+Nr(o):f,te||o===s.value||(s.value=o),s.defaultValue=o}g=g??j,g=typeof g!="function"&&typeof g!="symbol"&&!!g,s.checked=te?s.checked:!!g,s.defaultChecked=!!g,G!=null&&typeof G!="function"&&typeof G!="symbol"&&typeof G!="boolean"&&(s.name=G),vf(s)}function Sf(s,o,f){o==="number"&&ru(s.ownerDocument)===s||s.defaultValue===""+f||(s.defaultValue=""+f)}function Wa(s,o,f,g){if(s=s.options,o){o={};for(var j=0;j<f.length;j++)o["$"+f[j]]=!0;for(f=0;f<s.length;f++)j=o.hasOwnProperty("$"+s[f].value),s[f].selected!==j&&(s[f].selected=j),j&&g&&(s[f].defaultSelected=!0)}else{for(f=""+Nr(f),o=null,j=0;j<s.length;j++){if(s[j].value===f){s[j].selected=!0,g&&(s[j].defaultSelected=!0);return}o!==null||s[j].disabled||(o=s[j])}o!==null&&(o.selected=!0)}}function pb(s,o,f){if(o!=null&&(o=""+Nr(o),o!==s.value&&(s.value=o),f==null)){s.defaultValue!==o&&(s.defaultValue=o);return}s.defaultValue=f!=null?""+Nr(f):""}function gb(s,o,f,g){if(o==null){if(g!=null){if(f!=null)throw Error(r(92));if(U(g)){if(1<g.length)throw Error(r(93));g=g[0]}f=g}f==null&&(f=""),o=f}f=Nr(o),s.defaultValue=f,g=s.textContent,g===f&&g!==""&&g!==null&&(s.value=g),vf(s)}function Ga(s,o){if(o){var f=s.firstChild;if(f&&f===s.lastChild&&f.nodeType===3){f.nodeValue=o;return}}s.textContent=o}var QN=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function xb(s,o,f){var g=o.indexOf("--")===0;f==null||typeof f=="boolean"||f===""?g?s.setProperty(o,""):o==="float"?s.cssFloat="":s[o]="":g?s.setProperty(o,f):typeof f!="number"||f===0||QN.has(o)?o==="float"?s.cssFloat=f:s[o]=(""+f).trim():s[o]=f+"px"}function yb(s,o,f){if(o!=null&&typeof o!="object")throw Error(r(62));if(s=s.style,f!=null){for(var g in f)!f.hasOwnProperty(g)||o!=null&&o.hasOwnProperty(g)||(g.indexOf("--")===0?s.setProperty(g,""):g==="float"?s.cssFloat="":s[g]="");for(var j in o)g=o[j],o.hasOwnProperty(j)&&f[j]!==g&&xb(s,j,g)}else for(var A in o)o.hasOwnProperty(A)&&xb(s,A,o[A])}function wf(s){if(s.indexOf("-")===-1)return!1;switch(s){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var JN=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),ZN=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function su(s){return ZN.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function Es(){}var Cf=null;function kf(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var qa=null,Ka=null;function bb(s){var o=Fa(s);if(o&&(s=o.stateNode)){var f=s[dt]||null;e:switch(s=o.stateNode,o.type){case"input":if(_f(s,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name),o=f.name,f.type==="radio"&&o!=null){for(f=s;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll('input[name="'+Tr(""+o)+'"][type="radio"]'),o=0;o<f.length;o++){var g=f[o];if(g!==s&&g.form===s.form){var j=g[dt]||null;if(!j)throw Error(r(90));_f(g,j.value,j.defaultValue,j.defaultValue,j.checked,j.defaultChecked,j.type,j.name)}}for(o=0;o<f.length;o++)g=f[o],g.form===s.form&&fb(g)}break e;case"textarea":pb(s,f.value,f.defaultValue);break e;case"select":o=f.value,o!=null&&Wa(s,!!f.multiple,o,!1)}}}var jf=!1;function vb(s,o,f){if(jf)return s(o,f);jf=!0;try{var g=s(o);return g}finally{if(jf=!1,(qa!==null||Ka!==null)&&(Wu(),qa&&(o=qa,s=Ka,Ka=qa=null,bb(o),s)))for(o=0;o<s.length;o++)bb(s[o])}}function dl(s,o){var f=s.stateNode;if(f===null)return null;var g=f[dt]||null;if(g===null)return null;f=g[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(s=s.type,g=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!g;break e;default:s=!1}if(s)return null;if(f&&typeof f!="function")throw Error(r(231,o,typeof f));return f}var Ns=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ef=!1;if(Ns)try{var hl={};Object.defineProperty(hl,"passive",{get:function(){Ef=!0}}),window.addEventListener("test",hl,hl),window.removeEventListener("test",hl,hl)}catch{Ef=!1}var ai=null,Nf=null,iu=null;function _b(){if(iu)return iu;var s,o=Nf,f=o.length,g,j="value"in ai?ai.value:ai.textContent,A=j.length;for(s=0;s<f&&o[s]===j[s];s++);var G=f-s;for(g=1;g<=G&&o[f-g]===j[A-g];g++);return iu=j.slice(s,1<g?1-g:void 0)}function au(s){var o=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&o===13&&(s=13)):s=o,s===10&&(s=13),32<=s||s===13?s:0}function ou(){return!0}function Sb(){return!1}function er(s){function o(f,g,j,A,G){this._reactName=f,this._targetInst=j,this.type=g,this.nativeEvent=A,this.target=G,this.currentTarget=null;for(var te in s)s.hasOwnProperty(te)&&(f=s[te],this[te]=f?f(A):A[te]);return this.isDefaultPrevented=(A.defaultPrevented!=null?A.defaultPrevented:A.returnValue===!1)?ou:Sb,this.isPropagationStopped=Sb,this}return m(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=ou)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=ou)},persist:function(){},isPersistent:ou}),o}var Xi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},lu=er(Xi),fl=m({},Xi,{view:0,detail:0}),eT=er(fl),Tf,Af,ml,cu=m({},fl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Df,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==ml&&(ml&&s.type==="mousemove"?(Tf=s.screenX-ml.screenX,Af=s.screenY-ml.screenY):Af=Tf=0,ml=s),Tf)},movementY:function(s){return"movementY"in s?s.movementY:Af}}),wb=er(cu),tT=m({},cu,{dataTransfer:0}),nT=er(tT),rT=m({},fl,{relatedTarget:0}),Lf=er(rT),sT=m({},Xi,{animationName:0,elapsedTime:0,pseudoElement:0}),iT=er(sT),aT=m({},Xi,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),oT=er(aT),lT=m({},Xi,{data:0}),Cb=er(lT),cT={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},uT={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},dT={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function hT(s){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(s):(s=dT[s])?!!o[s]:!1}function Df(){return hT}var fT=m({},fl,{key:function(s){if(s.key){var o=cT[s.key]||s.key;if(o!=="Unidentified")return o}return s.type==="keypress"?(s=au(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?uT[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Df,charCode:function(s){return s.type==="keypress"?au(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?au(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),mT=er(fT),pT=m({},cu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),kb=er(pT),gT=m({},fl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Df}),xT=er(gT),yT=m({},Xi,{propertyName:0,elapsedTime:0,pseudoElement:0}),bT=er(yT),vT=m({},cu,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),_T=er(vT),ST=m({},Xi,{newState:0,oldState:0}),wT=er(ST),CT=[9,13,27,32],Rf=Ns&&"CompositionEvent"in window,pl=null;Ns&&"documentMode"in document&&(pl=document.documentMode);var kT=Ns&&"TextEvent"in window&&!pl,jb=Ns&&(!Rf||pl&&8<pl&&11>=pl),Eb=" ",Nb=!1;function Tb(s,o){switch(s){case"keyup":return CT.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ab(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Ya=!1;function jT(s,o){switch(s){case"compositionend":return Ab(o);case"keypress":return o.which!==32?null:(Nb=!0,Eb);case"textInput":return s=o.data,s===Eb&&Nb?null:s;default:return null}}function ET(s,o){if(Ya)return s==="compositionend"||!Rf&&Tb(s,o)?(s=_b(),iu=Nf=ai=null,Ya=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return jb&&o.locale!=="ko"?null:o.data;default:return null}}var NT={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Lb(s){var o=s&&s.nodeName&&s.nodeName.toLowerCase();return o==="input"?!!NT[s.type]:o==="textarea"}function Db(s,o,f,g){qa?Ka?Ka.push(g):Ka=[g]:qa=g,o=Ju(o,"onChange"),0<o.length&&(f=new lu("onChange","change",null,f,g),s.push({event:f,listeners:o}))}var gl=null,xl=null;function TT(s){m0(s,0)}function uu(s){var o=ul(s);if(fb(o))return s}function Rb(s,o){if(s==="change")return o}var Ob=!1;if(Ns){var Of;if(Ns){var If="oninput"in document;if(!If){var Ib=document.createElement("div");Ib.setAttribute("oninput","return;"),If=typeof Ib.oninput=="function"}Of=If}else Of=!1;Ob=Of&&(!document.documentMode||9<document.documentMode)}function Mb(){gl&&(gl.detachEvent("onpropertychange",Pb),xl=gl=null)}function Pb(s){if(s.propertyName==="value"&&uu(xl)){var o=[];Db(o,xl,s,kf(s)),vb(TT,o)}}function AT(s,o,f){s==="focusin"?(Mb(),gl=o,xl=f,gl.attachEvent("onpropertychange",Pb)):s==="focusout"&&Mb()}function LT(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return uu(xl)}function DT(s,o){if(s==="click")return uu(o)}function RT(s,o){if(s==="input"||s==="change")return uu(o)}function OT(s,o){return s===o&&(s!==0||1/s===1/o)||s!==s&&o!==o}var mr=typeof Object.is=="function"?Object.is:OT;function yl(s,o){if(mr(s,o))return!0;if(typeof s!="object"||s===null||typeof o!="object"||o===null)return!1;var f=Object.keys(s),g=Object.keys(o);if(f.length!==g.length)return!1;for(g=0;g<f.length;g++){var j=f[g];if(!Xe.call(o,j)||!mr(s[j],o[j]))return!1}return!0}function Bb(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function $b(s,o){var f=Bb(s);s=0;for(var g;f;){if(f.nodeType===3){if(g=s+f.textContent.length,s<=o&&g>=o)return{node:f,offset:o-s};s=g}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=Bb(f)}}function zb(s,o){return s&&o?s===o?!0:s&&s.nodeType===3?!1:o&&o.nodeType===3?zb(s,o.parentNode):"contains"in s?s.contains(o):s.compareDocumentPosition?!!(s.compareDocumentPosition(o)&16):!1:!1}function Hb(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var o=ru(s.document);o instanceof s.HTMLIFrameElement;){try{var f=typeof o.contentWindow.location.href=="string"}catch{f=!1}if(f)s=o.contentWindow;else break;o=ru(s.document)}return o}function Mf(s){var o=s&&s.nodeName&&s.nodeName.toLowerCase();return o&&(o==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||o==="textarea"||s.contentEditable==="true")}var IT=Ns&&"documentMode"in document&&11>=document.documentMode,Xa=null,Pf=null,bl=null,Bf=!1;function Fb(s,o,f){var g=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;Bf||Xa==null||Xa!==ru(g)||(g=Xa,"selectionStart"in g&&Mf(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),bl&&yl(bl,g)||(bl=g,g=Ju(Pf,"onSelect"),0<g.length&&(o=new lu("onSelect","select",null,o,f),s.push({event:o,listeners:g}),o.target=Xa)))}function Qi(s,o){var f={};return f[s.toLowerCase()]=o.toLowerCase(),f["Webkit"+s]="webkit"+o,f["Moz"+s]="moz"+o,f}var Qa={animationend:Qi("Animation","AnimationEnd"),animationiteration:Qi("Animation","AnimationIteration"),animationstart:Qi("Animation","AnimationStart"),transitionrun:Qi("Transition","TransitionRun"),transitionstart:Qi("Transition","TransitionStart"),transitioncancel:Qi("Transition","TransitionCancel"),transitionend:Qi("Transition","TransitionEnd")},$f={},Ub={};Ns&&(Ub=document.createElement("div").style,"AnimationEvent"in window||(delete Qa.animationend.animation,delete Qa.animationiteration.animation,delete Qa.animationstart.animation),"TransitionEvent"in window||delete Qa.transitionend.transition);function Ji(s){if($f[s])return $f[s];if(!Qa[s])return s;var o=Qa[s],f;for(f in o)if(o.hasOwnProperty(f)&&f in Ub)return $f[s]=o[f];return s}var Vb=Ji("animationend"),Wb=Ji("animationiteration"),Gb=Ji("animationstart"),MT=Ji("transitionrun"),PT=Ji("transitionstart"),BT=Ji("transitioncancel"),qb=Ji("transitionend"),Kb=new Map,zf="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");zf.push("scrollEnd");function Gr(s,o){Kb.set(s,o),Yi(o,[s])}var du=typeof reportError=="function"?reportError:function(s){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var o=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof s=="object"&&s!==null&&typeof s.message=="string"?String(s.message):String(s),error:s});if(!window.dispatchEvent(o))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",s);return}console.error(s)},Ar=[],Ja=0,Hf=0;function hu(){for(var s=Ja,o=Hf=Ja=0;o<s;){var f=Ar[o];Ar[o++]=null;var g=Ar[o];Ar[o++]=null;var j=Ar[o];Ar[o++]=null;var A=Ar[o];if(Ar[o++]=null,g!==null&&j!==null){var G=g.pending;G===null?j.next=j:(j.next=G.next,G.next=j),g.pending=j}A!==0&&Yb(f,j,A)}}function fu(s,o,f,g){Ar[Ja++]=s,Ar[Ja++]=o,Ar[Ja++]=f,Ar[Ja++]=g,Hf|=g,s.lanes|=g,s=s.alternate,s!==null&&(s.lanes|=g)}function Ff(s,o,f,g){return fu(s,o,f,g),mu(s)}function Zi(s,o){return fu(s,null,null,o),mu(s)}function Yb(s,o,f){s.lanes|=f;var g=s.alternate;g!==null&&(g.lanes|=f);for(var j=!1,A=s.return;A!==null;)A.childLanes|=f,g=A.alternate,g!==null&&(g.childLanes|=f),A.tag===22&&(s=A.stateNode,s===null||s._visibility&1||(j=!0)),s=A,A=A.return;return s.tag===3?(A=s.stateNode,j&&o!==null&&(j=31-$e(f),s=A.hiddenUpdates,g=s[j],g===null?s[j]=[o]:g.push(o),o.lane=f|536870912),A):null}function mu(s){if(50<Hl)throw Hl=0,Qm=null,Error(r(185));for(var o=s.return;o!==null;)s=o,o=s.return;return s.tag===3?s.stateNode:null}var Za={};function $T(s,o,f,g){this.tag=s,this.key=f,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function pr(s,o,f,g){return new $T(s,o,f,g)}function Uf(s){return s=s.prototype,!(!s||!s.isReactComponent)}function Ts(s,o){var f=s.alternate;return f===null?(f=pr(s.tag,o,s.key,s.mode),f.elementType=s.elementType,f.type=s.type,f.stateNode=s.stateNode,f.alternate=s,s.alternate=f):(f.pendingProps=o,f.type=s.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=s.flags&65011712,f.childLanes=s.childLanes,f.lanes=s.lanes,f.child=s.child,f.memoizedProps=s.memoizedProps,f.memoizedState=s.memoizedState,f.updateQueue=s.updateQueue,o=s.dependencies,f.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},f.sibling=s.sibling,f.index=s.index,f.ref=s.ref,f.refCleanup=s.refCleanup,f}function Xb(s,o){s.flags&=65011714;var f=s.alternate;return f===null?(s.childLanes=0,s.lanes=o,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=f.childLanes,s.lanes=f.lanes,s.child=f.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=f.memoizedProps,s.memoizedState=f.memoizedState,s.updateQueue=f.updateQueue,s.type=f.type,o=f.dependencies,s.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),s}function pu(s,o,f,g,j,A){var G=0;if(g=s,typeof s=="function")Uf(s)&&(G=1);else if(typeof s=="string")G=VA(s,f,Y.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case R:return s=pr(31,f,o,j),s.elementType=R,s.lanes=A,s;case C:return ea(f.children,j,A,o);case v:G=8,j|=24;break;case w:return s=pr(12,f,o,j|2),s.elementType=w,s.lanes=A,s;case E:return s=pr(13,f,o,j),s.elementType=E,s.lanes=A,s;case T:return s=pr(19,f,o,j),s.elementType=T,s.lanes=A,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case b:G=10;break e;case _:G=9;break e;case k:G=11;break e;case D:G=14;break e;case L:G=16,g=null;break e}G=29,f=Error(r(130,s===null?"null":typeof s,"")),g=null}return o=pr(G,f,o,j),o.elementType=s,o.type=g,o.lanes=A,o}function ea(s,o,f,g){return s=pr(7,s,g,o),s.lanes=f,s}function Vf(s,o,f){return s=pr(6,s,null,o),s.lanes=f,s}function Qb(s){var o=pr(18,null,null,0);return o.stateNode=s,o}function Wf(s,o,f){return o=pr(4,s.children!==null?s.children:[],s.key,o),o.lanes=f,o.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},o}var Jb=new WeakMap;function Lr(s,o){if(typeof s=="object"&&s!==null){var f=Jb.get(s);return f!==void 0?f:(o={value:s,source:o,stack:Ge(o)},Jb.set(s,o),o)}return{value:s,source:o,stack:Ge(o)}}var eo=[],to=0,gu=null,vl=0,Dr=[],Rr=0,oi=null,os=1,ls="";function As(s,o){eo[to++]=vl,eo[to++]=gu,gu=s,vl=o}function Zb(s,o,f){Dr[Rr++]=os,Dr[Rr++]=ls,Dr[Rr++]=oi,oi=s;var g=os;s=ls;var j=32-$e(g)-1;g&=~(1<<j),f+=1;var A=32-$e(o)+j;if(30<A){var G=j-j%5;A=(g&(1<<G)-1).toString(32),g>>=G,j-=G,os=1<<32-$e(o)+j|f<<j|g,ls=A+s}else os=1<<A|f<<j|g,ls=s}function Gf(s){s.return!==null&&(As(s,1),Zb(s,1,0))}function qf(s){for(;s===gu;)gu=eo[--to],eo[to]=null,vl=eo[--to],eo[to]=null;for(;s===oi;)oi=Dr[--Rr],Dr[Rr]=null,ls=Dr[--Rr],Dr[Rr]=null,os=Dr[--Rr],Dr[Rr]=null}function ev(s,o){Dr[Rr++]=os,Dr[Rr++]=ls,Dr[Rr++]=oi,os=o.id,ls=o.overflow,oi=s}var In=null,Zt=null,At=!1,li=null,Or=!1,Kf=Error(r(519));function ci(s){var o=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw _l(Lr(o,s)),Kf}function tv(s){var o=s.stateNode,f=s.type,g=s.memoizedProps;switch(o[at]=s,o[dt]=g,f){case"dialog":Ct("cancel",o),Ct("close",o);break;case"iframe":case"object":case"embed":Ct("load",o);break;case"video":case"audio":for(f=0;f<Ul.length;f++)Ct(Ul[f],o);break;case"source":Ct("error",o);break;case"img":case"image":case"link":Ct("error",o),Ct("load",o);break;case"details":Ct("toggle",o);break;case"input":Ct("invalid",o),mb(o,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0);break;case"select":Ct("invalid",o);break;case"textarea":Ct("invalid",o),gb(o,g.value,g.defaultValue,g.children)}f=g.children,typeof f!="string"&&typeof f!="number"&&typeof f!="bigint"||o.textContent===""+f||g.suppressHydrationWarning===!0||y0(o.textContent,f)?(g.popover!=null&&(Ct("beforetoggle",o),Ct("toggle",o)),g.onScroll!=null&&Ct("scroll",o),g.onScrollEnd!=null&&Ct("scrollend",o),g.onClick!=null&&(o.onclick=Es),o=!0):o=!1,o||ci(s,!0)}function nv(s){for(In=s.return;In;)switch(In.tag){case 5:case 31:case 13:Or=!1;return;case 27:case 3:Or=!0;return;default:In=In.return}}function no(s){if(s!==In)return!1;if(!At)return nv(s),At=!0,!1;var o=s.tag,f;if((f=o!==3&&o!==27)&&((f=o===5)&&(f=s.type,f=!(f!=="form"&&f!=="button")||hp(s.type,s.memoizedProps)),f=!f),f&&Zt&&ci(s),nv(s),o===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));Zt=E0(s)}else if(o===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));Zt=E0(s)}else o===27?(o=Zt,wi(s.type)?(s=xp,xp=null,Zt=s):Zt=o):Zt=In?Mr(s.stateNode.nextSibling):null;return!0}function ta(){Zt=In=null,At=!1}function Yf(){var s=li;return s!==null&&(sr===null?sr=s:sr.push.apply(sr,s),li=null),s}function _l(s){li===null?li=[s]:li.push(s)}var Xf=B(null),na=null,Ls=null;function ui(s,o,f){$(Xf,o._currentValue),o._currentValue=f}function Ds(s){s._currentValue=Xf.current,q(Xf)}function Qf(s,o,f){for(;s!==null;){var g=s.alternate;if((s.childLanes&o)!==o?(s.childLanes|=o,g!==null&&(g.childLanes|=o)):g!==null&&(g.childLanes&o)!==o&&(g.childLanes|=o),s===f)break;s=s.return}}function Jf(s,o,f,g){var j=s.child;for(j!==null&&(j.return=s);j!==null;){var A=j.dependencies;if(A!==null){var G=j.child;A=A.firstContext;e:for(;A!==null;){var te=A;A=j;for(var oe=0;oe<o.length;oe++)if(te.context===o[oe]){A.lanes|=f,te=A.alternate,te!==null&&(te.lanes|=f),Qf(A.return,f,s),g||(G=null);break e}A=te.next}}else if(j.tag===18){if(G=j.return,G===null)throw Error(r(341));G.lanes|=f,A=G.alternate,A!==null&&(A.lanes|=f),Qf(G,f,s),G=null}else G=j.child;if(G!==null)G.return=j;else for(G=j;G!==null;){if(G===s){G=null;break}if(j=G.sibling,j!==null){j.return=G.return,G=j;break}G=G.return}j=G}}function ro(s,o,f,g){s=null;for(var j=o,A=!1;j!==null;){if(!A){if((j.flags&524288)!==0)A=!0;else if((j.flags&262144)!==0)break}if(j.tag===10){var G=j.alternate;if(G===null)throw Error(r(387));if(G=G.memoizedProps,G!==null){var te=j.type;mr(j.pendingProps.value,G.value)||(s!==null?s.push(te):s=[te])}}else if(j===K.current){if(G=j.alternate,G===null)throw Error(r(387));G.memoizedState.memoizedState!==j.memoizedState.memoizedState&&(s!==null?s.push(Kl):s=[Kl])}j=j.return}s!==null&&Jf(o,s,f,g),o.flags|=262144}function xu(s){for(s=s.firstContext;s!==null;){if(!mr(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function ra(s){na=s,Ls=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function Mn(s){return rv(na,s)}function yu(s,o){return na===null&&ra(s),rv(s,o)}function rv(s,o){var f=o._currentValue;if(o={context:o,memoizedValue:f,next:null},Ls===null){if(s===null)throw Error(r(308));Ls=o,s.dependencies={lanes:0,firstContext:o},s.flags|=524288}else Ls=Ls.next=o;return f}var zT=typeof AbortController<"u"?AbortController:function(){var s=[],o=this.signal={aborted:!1,addEventListener:function(f,g){s.push(g)}};this.abort=function(){o.aborted=!0,s.forEach(function(f){return f()})}},HT=e.unstable_scheduleCallback,FT=e.unstable_NormalPriority,bn={$$typeof:b,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Zf(){return{controller:new zT,data:new Map,refCount:0}}function Sl(s){s.refCount--,s.refCount===0&&HT(FT,function(){s.controller.abort()})}var wl=null,em=0,so=0,io=null;function UT(s,o){if(wl===null){var f=wl=[];em=0,so=rp(),io={status:"pending",value:void 0,then:function(g){f.push(g)}}}return em++,o.then(sv,sv),o}function sv(){if(--em===0&&wl!==null){io!==null&&(io.status="fulfilled");var s=wl;wl=null,so=0,io=null;for(var o=0;o<s.length;o++)(0,s[o])()}}function VT(s,o){var f=[],g={status:"pending",value:null,reason:null,then:function(j){f.push(j)}};return s.then(function(){g.status="fulfilled",g.value=o;for(var j=0;j<f.length;j++)(0,f[j])(o)},function(j){for(g.status="rejected",g.reason=j,j=0;j<f.length;j++)(0,f[j])(void 0)}),g}var iv=V.S;V.S=function(s,o){F_=Fe(),typeof o=="object"&&o!==null&&typeof o.then=="function"&&UT(s,o),iv!==null&&iv(s,o)};var sa=B(null);function tm(){var s=sa.current;return s!==null?s:Gt.pooledCache}function bu(s,o){o===null?$(sa,sa.current):$(sa,o.pool)}function av(){var s=tm();return s===null?null:{parent:bn._currentValue,pool:s}}var ao=Error(r(460)),nm=Error(r(474)),vu=Error(r(542)),_u={then:function(){}};function ov(s){return s=s.status,s==="fulfilled"||s==="rejected"}function lv(s,o,f){switch(f=s[f],f===void 0?s.push(o):f!==o&&(o.then(Es,Es),o=f),o.status){case"fulfilled":return o.value;case"rejected":throw s=o.reason,uv(s),s;default:if(typeof o.status=="string")o.then(Es,Es);else{if(s=Gt,s!==null&&100<s.shellSuspendCounter)throw Error(r(482));s=o,s.status="pending",s.then(function(g){if(o.status==="pending"){var j=o;j.status="fulfilled",j.value=g}},function(g){if(o.status==="pending"){var j=o;j.status="rejected",j.reason=g}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw s=o.reason,uv(s),s}throw aa=o,ao}}function ia(s){try{var o=s._init;return o(s._payload)}catch(f){throw f!==null&&typeof f=="object"&&typeof f.then=="function"?(aa=f,ao):f}}var aa=null;function cv(){if(aa===null)throw Error(r(459));var s=aa;return aa=null,s}function uv(s){if(s===ao||s===vu)throw Error(r(483))}var oo=null,Cl=0;function Su(s){var o=Cl;return Cl+=1,oo===null&&(oo=[]),lv(oo,s,o)}function kl(s,o){o=o.props.ref,s.ref=o!==void 0?o:null}function wu(s,o){throw o.$$typeof===x?Error(r(525)):(s=Object.prototype.toString.call(o),Error(r(31,s==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":s)))}function dv(s){function o(de,le){if(s){var me=de.deletions;me===null?(de.deletions=[le],de.flags|=16):me.push(le)}}function f(de,le){if(!s)return null;for(;le!==null;)o(de,le),le=le.sibling;return null}function g(de){for(var le=new Map;de!==null;)de.key!==null?le.set(de.key,de):le.set(de.index,de),de=de.sibling;return le}function j(de,le){return de=Ts(de,le),de.index=0,de.sibling=null,de}function A(de,le,me){return de.index=me,s?(me=de.alternate,me!==null?(me=me.index,me<le?(de.flags|=67108866,le):me):(de.flags|=67108866,le)):(de.flags|=1048576,le)}function G(de){return s&&de.alternate===null&&(de.flags|=67108866),de}function te(de,le,me,De){return le===null||le.tag!==6?(le=Vf(me,de.mode,De),le.return=de,le):(le=j(le,me),le.return=de,le)}function oe(de,le,me,De){var lt=me.type;return lt===C?Te(de,le,me.props.children,De,me.key):le!==null&&(le.elementType===lt||typeof lt=="object"&<!==null&<.$$typeof===L&&ia(lt)===le.type)?(le=j(le,me.props),kl(le,me),le.return=de,le):(le=pu(me.type,me.key,me.props,null,de.mode,De),kl(le,me),le.return=de,le)}function pe(de,le,me,De){return le===null||le.tag!==4||le.stateNode.containerInfo!==me.containerInfo||le.stateNode.implementation!==me.implementation?(le=Wf(me,de.mode,De),le.return=de,le):(le=j(le,me.children||[]),le.return=de,le)}function Te(de,le,me,De,lt){return le===null||le.tag!==7?(le=ea(me,de.mode,De,lt),le.return=de,le):(le=j(le,me),le.return=de,le)}function Oe(de,le,me){if(typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint")return le=Vf(""+le,de.mode,me),le.return=de,le;if(typeof le=="object"&&le!==null){switch(le.$$typeof){case y:return me=pu(le.type,le.key,le.props,null,de.mode,me),kl(me,le),me.return=de,me;case S:return le=Wf(le,de.mode,me),le.return=de,le;case L:return le=ia(le),Oe(de,le,me)}if(U(le)||z(le))return le=ea(le,de.mode,me,null),le.return=de,le;if(typeof le.then=="function")return Oe(de,Su(le),me);if(le.$$typeof===b)return Oe(de,yu(de,le),me);wu(de,le)}return null}function be(de,le,me,De){var lt=le!==null?le.key:null;if(typeof me=="string"&&me!==""||typeof me=="number"||typeof me=="bigint")return lt!==null?null:te(de,le,""+me,De);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case y:return me.key===lt?oe(de,le,me,De):null;case S:return me.key===lt?pe(de,le,me,De):null;case L:return me=ia(me),be(de,le,me,De)}if(U(me)||z(me))return lt!==null?null:Te(de,le,me,De,null);if(typeof me.then=="function")return be(de,le,Su(me),De);if(me.$$typeof===b)return be(de,le,yu(de,me),De);wu(de,me)}return null}function je(de,le,me,De,lt){if(typeof De=="string"&&De!==""||typeof De=="number"||typeof De=="bigint")return de=de.get(me)||null,te(le,de,""+De,lt);if(typeof De=="object"&&De!==null){switch(De.$$typeof){case y:return de=de.get(De.key===null?me:De.key)||null,oe(le,de,De,lt);case S:return de=de.get(De.key===null?me:De.key)||null,pe(le,de,De,lt);case L:return De=ia(De),je(de,le,me,De,lt)}if(U(De)||z(De))return de=de.get(me)||null,Te(le,de,De,lt,null);if(typeof De.then=="function")return je(de,le,me,Su(De),lt);if(De.$$typeof===b)return je(de,le,me,yu(le,De),lt);wu(le,De)}return null}function nt(de,le,me,De){for(var lt=null,Rt=null,st=le,St=le=0,Nt=null;st!==null&&St<me.length;St++){st.index>St?(Nt=st,st=null):Nt=st.sibling;var Ot=be(de,st,me[St],De);if(Ot===null){st===null&&(st=Nt);break}s&&st&&Ot.alternate===null&&o(de,st),le=A(Ot,le,St),Rt===null?lt=Ot:Rt.sibling=Ot,Rt=Ot,st=Nt}if(St===me.length)return f(de,st),At&&As(de,St),lt;if(st===null){for(;St<me.length;St++)st=Oe(de,me[St],De),st!==null&&(le=A(st,le,St),Rt===null?lt=st:Rt.sibling=st,Rt=st);return At&&As(de,St),lt}for(st=g(st);St<me.length;St++)Nt=je(st,de,St,me[St],De),Nt!==null&&(s&&Nt.alternate!==null&&st.delete(Nt.key===null?St:Nt.key),le=A(Nt,le,St),Rt===null?lt=Nt:Rt.sibling=Nt,Rt=Nt);return s&&st.forEach(function(Ni){return o(de,Ni)}),At&&As(de,St),lt}function ft(de,le,me,De){if(me==null)throw Error(r(151));for(var lt=null,Rt=null,st=le,St=le=0,Nt=null,Ot=me.next();st!==null&&!Ot.done;St++,Ot=me.next()){st.index>St?(Nt=st,st=null):Nt=st.sibling;var Ni=be(de,st,Ot.value,De);if(Ni===null){st===null&&(st=Nt);break}s&&st&&Ni.alternate===null&&o(de,st),le=A(Ni,le,St),Rt===null?lt=Ni:Rt.sibling=Ni,Rt=Ni,st=Nt}if(Ot.done)return f(de,st),At&&As(de,St),lt;if(st===null){for(;!Ot.done;St++,Ot=me.next())Ot=Oe(de,Ot.value,De),Ot!==null&&(le=A(Ot,le,St),Rt===null?lt=Ot:Rt.sibling=Ot,Rt=Ot);return At&&As(de,St),lt}for(st=g(st);!Ot.done;St++,Ot=me.next())Ot=je(st,de,St,Ot.value,De),Ot!==null&&(s&&Ot.alternate!==null&&st.delete(Ot.key===null?St:Ot.key),le=A(Ot,le,St),Rt===null?lt=Ot:Rt.sibling=Ot,Rt=Ot);return s&&st.forEach(function(tL){return o(de,tL)}),At&&As(de,St),lt}function Ft(de,le,me,De){if(typeof me=="object"&&me!==null&&me.type===C&&me.key===null&&(me=me.props.children),typeof me=="object"&&me!==null){switch(me.$$typeof){case y:e:{for(var lt=me.key;le!==null;){if(le.key===lt){if(lt=me.type,lt===C){if(le.tag===7){f(de,le.sibling),De=j(le,me.props.children),De.return=de,de=De;break e}}else if(le.elementType===lt||typeof lt=="object"&<!==null&<.$$typeof===L&&ia(lt)===le.type){f(de,le.sibling),De=j(le,me.props),kl(De,me),De.return=de,de=De;break e}f(de,le);break}else o(de,le);le=le.sibling}me.type===C?(De=ea(me.props.children,de.mode,De,me.key),De.return=de,de=De):(De=pu(me.type,me.key,me.props,null,de.mode,De),kl(De,me),De.return=de,de=De)}return G(de);case S:e:{for(lt=me.key;le!==null;){if(le.key===lt)if(le.tag===4&&le.stateNode.containerInfo===me.containerInfo&&le.stateNode.implementation===me.implementation){f(de,le.sibling),De=j(le,me.children||[]),De.return=de,de=De;break e}else{f(de,le);break}else o(de,le);le=le.sibling}De=Wf(me,de.mode,De),De.return=de,de=De}return G(de);case L:return me=ia(me),Ft(de,le,me,De)}if(U(me))return nt(de,le,me,De);if(z(me)){if(lt=z(me),typeof lt!="function")throw Error(r(150));return me=lt.call(me),ft(de,le,me,De)}if(typeof me.then=="function")return Ft(de,le,Su(me),De);if(me.$$typeof===b)return Ft(de,le,yu(de,me),De);wu(de,me)}return typeof me=="string"&&me!==""||typeof me=="number"||typeof me=="bigint"?(me=""+me,le!==null&&le.tag===6?(f(de,le.sibling),De=j(le,me),De.return=de,de=De):(f(de,le),De=Vf(me,de.mode,De),De.return=de,de=De),G(de)):f(de,le)}return function(de,le,me,De){try{Cl=0;var lt=Ft(de,le,me,De);return oo=null,lt}catch(st){if(st===ao||st===vu)throw st;var Rt=pr(29,st,null,de.mode);return Rt.lanes=De,Rt.return=de,Rt}finally{}}}var oa=dv(!0),hv=dv(!1),di=!1;function rm(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function sm(s,o){s=s.updateQueue,o.updateQueue===s&&(o.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function hi(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function fi(s,o,f){var g=s.updateQueue;if(g===null)return null;if(g=g.shared,(Mt&2)!==0){var j=g.pending;return j===null?o.next=o:(o.next=j.next,j.next=o),g.pending=o,o=mu(s),Yb(s,null,f),o}return fu(s,g,o,f),mu(s)}function jl(s,o,f){if(o=o.updateQueue,o!==null&&(o=o.shared,(f&4194048)!==0)){var g=o.lanes;g&=s.pendingLanes,f|=g,o.lanes=f,_e(s,f)}}function im(s,o){var f=s.updateQueue,g=s.alternate;if(g!==null&&(g=g.updateQueue,f===g)){var j=null,A=null;if(f=f.firstBaseUpdate,f!==null){do{var G={lane:f.lane,tag:f.tag,payload:f.payload,callback:null,next:null};A===null?j=A=G:A=A.next=G,f=f.next}while(f!==null);A===null?j=A=o:A=A.next=o}else j=A=o;f={baseState:g.baseState,firstBaseUpdate:j,lastBaseUpdate:A,shared:g.shared,callbacks:g.callbacks},s.updateQueue=f;return}s=f.lastBaseUpdate,s===null?f.firstBaseUpdate=o:s.next=o,f.lastBaseUpdate=o}var am=!1;function El(){if(am){var s=io;if(s!==null)throw s}}function Nl(s,o,f,g){am=!1;var j=s.updateQueue;di=!1;var A=j.firstBaseUpdate,G=j.lastBaseUpdate,te=j.shared.pending;if(te!==null){j.shared.pending=null;var oe=te,pe=oe.next;oe.next=null,G===null?A=pe:G.next=pe,G=oe;var Te=s.alternate;Te!==null&&(Te=Te.updateQueue,te=Te.lastBaseUpdate,te!==G&&(te===null?Te.firstBaseUpdate=pe:te.next=pe,Te.lastBaseUpdate=oe))}if(A!==null){var Oe=j.baseState;G=0,Te=pe=oe=null,te=A;do{var be=te.lane&-536870913,je=be!==te.lane;if(je?(Et&be)===be:(g&be)===be){be!==0&&be===so&&(am=!0),Te!==null&&(Te=Te.next={lane:0,tag:te.tag,payload:te.payload,callback:null,next:null});e:{var nt=s,ft=te;be=o;var Ft=f;switch(ft.tag){case 1:if(nt=ft.payload,typeof nt=="function"){Oe=nt.call(Ft,Oe,be);break e}Oe=nt;break e;case 3:nt.flags=nt.flags&-65537|128;case 0:if(nt=ft.payload,be=typeof nt=="function"?nt.call(Ft,Oe,be):nt,be==null)break e;Oe=m({},Oe,be);break e;case 2:di=!0}}be=te.callback,be!==null&&(s.flags|=64,je&&(s.flags|=8192),je=j.callbacks,je===null?j.callbacks=[be]:je.push(be))}else je={lane:be,tag:te.tag,payload:te.payload,callback:te.callback,next:null},Te===null?(pe=Te=je,oe=Oe):Te=Te.next=je,G|=be;if(te=te.next,te===null){if(te=j.shared.pending,te===null)break;je=te,te=je.next,je.next=null,j.lastBaseUpdate=je,j.shared.pending=null}}while(!0);Te===null&&(oe=Oe),j.baseState=oe,j.firstBaseUpdate=pe,j.lastBaseUpdate=Te,A===null&&(j.shared.lanes=0),yi|=G,s.lanes=G,s.memoizedState=Oe}}function fv(s,o){if(typeof s!="function")throw Error(r(191,s));s.call(o)}function mv(s,o){var f=s.callbacks;if(f!==null)for(s.callbacks=null,s=0;s<f.length;s++)fv(f[s],o)}var lo=B(null),Cu=B(0);function pv(s,o){s=Hs,$(Cu,s),$(lo,o),Hs=s|o.baseLanes}function om(){$(Cu,Hs),$(lo,lo.current)}function lm(){Hs=Cu.current,q(lo),q(Cu)}var gr=B(null),Ir=null;function mi(s){var o=s.alternate;$(mn,mn.current&1),$(gr,s),Ir===null&&(o===null||lo.current!==null||o.memoizedState!==null)&&(Ir=s)}function cm(s){$(mn,mn.current),$(gr,s),Ir===null&&(Ir=s)}function gv(s){s.tag===22?($(mn,mn.current),$(gr,s),Ir===null&&(Ir=s)):pi()}function pi(){$(mn,mn.current),$(gr,gr.current)}function xr(s){q(gr),Ir===s&&(Ir=null),q(mn)}var mn=B(0);function ku(s){for(var o=s;o!==null;){if(o.tag===13){var f=o.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||pp(f)||gp(f)))return o}else if(o.tag===19&&(o.memoizedProps.revealOrder==="forwards"||o.memoizedProps.revealOrder==="backwards"||o.memoizedProps.revealOrder==="unstable_legacy-backwards"||o.memoizedProps.revealOrder==="together")){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Rs=0,_t=null,zt=null,vn=null,ju=!1,co=!1,la=!1,Eu=0,Tl=0,uo=null,WT=0;function un(){throw Error(r(321))}function um(s,o){if(o===null)return!1;for(var f=0;f<o.length&&f<s.length;f++)if(!mr(s[f],o[f]))return!1;return!0}function dm(s,o,f,g,j,A){return Rs=A,_t=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,V.H=s===null||s.memoizedState===null?Zv:jm,la=!1,A=f(g,j),la=!1,co&&(A=yv(o,f,g,j)),xv(s),A}function xv(s){V.H=Dl;var o=zt!==null&&zt.next!==null;if(Rs=0,vn=zt=_t=null,ju=!1,Tl=0,uo=null,o)throw Error(r(300));s===null||_n||(s=s.dependencies,s!==null&&xu(s)&&(_n=!0))}function yv(s,o,f,g){_t=s;var j=0;do{if(co&&(uo=null),Tl=0,co=!1,25<=j)throw Error(r(301));if(j+=1,vn=zt=null,s.updateQueue!=null){var A=s.updateQueue;A.lastEffect=null,A.events=null,A.stores=null,A.memoCache!=null&&(A.memoCache.index=0)}V.H=e_,A=o(f,g)}while(co);return A}function GT(){var s=V.H,o=s.useState()[0];return o=typeof o.then=="function"?Al(o):o,s=s.useState()[0],(zt!==null?zt.memoizedState:null)!==s&&(_t.flags|=1024),o}function hm(){var s=Eu!==0;return Eu=0,s}function fm(s,o,f){o.updateQueue=s.updateQueue,o.flags&=-2053,s.lanes&=~f}function mm(s){if(ju){for(s=s.memoizedState;s!==null;){var o=s.queue;o!==null&&(o.pending=null),s=s.next}ju=!1}Rs=0,vn=zt=_t=null,co=!1,Tl=Eu=0,uo=null}function Yn(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return vn===null?_t.memoizedState=vn=s:vn=vn.next=s,vn}function pn(){if(zt===null){var s=_t.alternate;s=s!==null?s.memoizedState:null}else s=zt.next;var o=vn===null?_t.memoizedState:vn.next;if(o!==null)vn=o,zt=s;else{if(s===null)throw _t.alternate===null?Error(r(467)):Error(r(310));zt=s,s={memoizedState:zt.memoizedState,baseState:zt.baseState,baseQueue:zt.baseQueue,queue:zt.queue,next:null},vn===null?_t.memoizedState=vn=s:vn=vn.next=s}return vn}function Nu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Al(s){var o=Tl;return Tl+=1,uo===null&&(uo=[]),s=lv(uo,s,o),o=_t,(vn===null?o.memoizedState:vn.next)===null&&(o=o.alternate,V.H=o===null||o.memoizedState===null?Zv:jm),s}function Tu(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return Al(s);if(s.$$typeof===b)return Mn(s)}throw Error(r(438,String(s)))}function pm(s){var o=null,f=_t.updateQueue;if(f!==null&&(o=f.memoCache),o==null){var g=_t.alternate;g!==null&&(g=g.updateQueue,g!==null&&(g=g.memoCache,g!=null&&(o={data:g.data.map(function(j){return j.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),f===null&&(f=Nu(),_t.updateQueue=f),f.memoCache=o,f=o.data[o.index],f===void 0)for(f=o.data[o.index]=Array(s),g=0;g<s;g++)f[g]=M;return o.index++,f}function Os(s,o){return typeof o=="function"?o(s):o}function Au(s){var o=pn();return gm(o,zt,s)}function gm(s,o,f){var g=s.queue;if(g===null)throw Error(r(311));g.lastRenderedReducer=f;var j=s.baseQueue,A=g.pending;if(A!==null){if(j!==null){var G=j.next;j.next=A.next,A.next=G}o.baseQueue=j=A,g.pending=null}if(A=s.baseState,j===null)s.memoizedState=A;else{o=j.next;var te=G=null,oe=null,pe=o,Te=!1;do{var Oe=pe.lane&-536870913;if(Oe!==pe.lane?(Et&Oe)===Oe:(Rs&Oe)===Oe){var be=pe.revertLane;if(be===0)oe!==null&&(oe=oe.next={lane:0,revertLane:0,gesture:null,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null}),Oe===so&&(Te=!0);else if((Rs&be)===be){pe=pe.next,be===so&&(Te=!0);continue}else Oe={lane:0,revertLane:pe.revertLane,gesture:null,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null},oe===null?(te=oe=Oe,G=A):oe=oe.next=Oe,_t.lanes|=be,yi|=be;Oe=pe.action,la&&f(A,Oe),A=pe.hasEagerState?pe.eagerState:f(A,Oe)}else be={lane:Oe,revertLane:pe.revertLane,gesture:pe.gesture,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null},oe===null?(te=oe=be,G=A):oe=oe.next=be,_t.lanes|=Oe,yi|=Oe;pe=pe.next}while(pe!==null&&pe!==o);if(oe===null?G=A:oe.next=te,!mr(A,s.memoizedState)&&(_n=!0,Te&&(f=io,f!==null)))throw f;s.memoizedState=A,s.baseState=G,s.baseQueue=oe,g.lastRenderedState=A}return j===null&&(g.lanes=0),[s.memoizedState,g.dispatch]}function xm(s){var o=pn(),f=o.queue;if(f===null)throw Error(r(311));f.lastRenderedReducer=s;var g=f.dispatch,j=f.pending,A=o.memoizedState;if(j!==null){f.pending=null;var G=j=j.next;do A=s(A,G.action),G=G.next;while(G!==j);mr(A,o.memoizedState)||(_n=!0),o.memoizedState=A,o.baseQueue===null&&(o.baseState=A),f.lastRenderedState=A}return[A,g]}function bv(s,o,f){var g=_t,j=pn(),A=At;if(A){if(f===void 0)throw Error(r(407));f=f()}else f=o();var G=!mr((zt||j).memoizedState,f);if(G&&(j.memoizedState=f,_n=!0),j=j.queue,vm(Sv.bind(null,g,j,s),[s]),j.getSnapshot!==o||G||vn!==null&&vn.memoizedState.tag&1){if(g.flags|=2048,ho(9,{destroy:void 0},_v.bind(null,g,j,f,o),null),Gt===null)throw Error(r(349));A||(Rs&127)!==0||vv(g,o,f)}return f}function vv(s,o,f){s.flags|=16384,s={getSnapshot:o,value:f},o=_t.updateQueue,o===null?(o=Nu(),_t.updateQueue=o,o.stores=[s]):(f=o.stores,f===null?o.stores=[s]:f.push(s))}function _v(s,o,f,g){o.value=f,o.getSnapshot=g,wv(o)&&Cv(s)}function Sv(s,o,f){return f(function(){wv(o)&&Cv(s)})}function wv(s){var o=s.getSnapshot;s=s.value;try{var f=o();return!mr(s,f)}catch{return!0}}function Cv(s){var o=Zi(s,2);o!==null&&ir(o,s,2)}function ym(s){var o=Yn();if(typeof s=="function"){var f=s;if(s=f(),la){ue(!0);try{f()}finally{ue(!1)}}}return o.memoizedState=o.baseState=s,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Os,lastRenderedState:s},o}function kv(s,o,f,g){return s.baseState=f,gm(s,zt,typeof g=="function"?g:Os)}function qT(s,o,f,g,j){if(Ru(s))throw Error(r(485));if(s=o.action,s!==null){var A={payload:j,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(G){A.listeners.push(G)}};V.T!==null?f(!0):A.isTransition=!1,g(A),f=o.pending,f===null?(A.next=o.pending=A,jv(o,A)):(A.next=f.next,o.pending=f.next=A)}}function jv(s,o){var f=o.action,g=o.payload,j=s.state;if(o.isTransition){var A=V.T,G={};V.T=G;try{var te=f(j,g),oe=V.S;oe!==null&&oe(G,te),Ev(s,o,te)}catch(pe){bm(s,o,pe)}finally{A!==null&&G.types!==null&&(A.types=G.types),V.T=A}}else try{A=f(j,g),Ev(s,o,A)}catch(pe){bm(s,o,pe)}}function Ev(s,o,f){f!==null&&typeof f=="object"&&typeof f.then=="function"?f.then(function(g){Nv(s,o,g)},function(g){return bm(s,o,g)}):Nv(s,o,f)}function Nv(s,o,f){o.status="fulfilled",o.value=f,Tv(o),s.state=f,o=s.pending,o!==null&&(f=o.next,f===o?s.pending=null:(f=f.next,o.next=f,jv(s,f)))}function bm(s,o,f){var g=s.pending;if(s.pending=null,g!==null){g=g.next;do o.status="rejected",o.reason=f,Tv(o),o=o.next;while(o!==g)}s.action=null}function Tv(s){s=s.listeners;for(var o=0;o<s.length;o++)(0,s[o])()}function Av(s,o){return o}function Lv(s,o){if(At){var f=Gt.formState;if(f!==null){e:{var g=_t;if(At){if(Zt){t:{for(var j=Zt,A=Or;j.nodeType!==8;){if(!A){j=null;break t}if(j=Mr(j.nextSibling),j===null){j=null;break t}}A=j.data,j=A==="F!"||A==="F"?j:null}if(j){Zt=Mr(j.nextSibling),g=j.data==="F!";break e}}ci(g)}g=!1}g&&(o=f[0])}}return f=Yn(),f.memoizedState=f.baseState=o,g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Av,lastRenderedState:o},f.queue=g,f=Xv.bind(null,_t,g),g.dispatch=f,g=ym(!1),A=km.bind(null,_t,!1,g.queue),g=Yn(),j={state:o,dispatch:null,action:s,pending:null},g.queue=j,f=qT.bind(null,_t,j,A,f),j.dispatch=f,g.memoizedState=s,[o,f,!1]}function Dv(s){var o=pn();return Rv(o,zt,s)}function Rv(s,o,f){if(o=gm(s,o,Av)[0],s=Au(Os)[0],typeof o=="object"&&o!==null&&typeof o.then=="function")try{var g=Al(o)}catch(G){throw G===ao?vu:G}else g=o;o=pn();var j=o.queue,A=j.dispatch;return f!==o.memoizedState&&(_t.flags|=2048,ho(9,{destroy:void 0},KT.bind(null,j,f),null)),[g,A,s]}function KT(s,o){s.action=o}function Ov(s){var o=pn(),f=zt;if(f!==null)return Rv(o,f,s);pn(),o=o.memoizedState,f=pn();var g=f.queue.dispatch;return f.memoizedState=s,[o,g,!1]}function ho(s,o,f,g){return s={tag:s,create:f,deps:g,inst:o,next:null},o=_t.updateQueue,o===null&&(o=Nu(),_t.updateQueue=o),f=o.lastEffect,f===null?o.lastEffect=s.next=s:(g=f.next,f.next=s,s.next=g,o.lastEffect=s),s}function Iv(){return pn().memoizedState}function Lu(s,o,f,g){var j=Yn();_t.flags|=s,j.memoizedState=ho(1|o,{destroy:void 0},f,g===void 0?null:g)}function Du(s,o,f,g){var j=pn();g=g===void 0?null:g;var A=j.memoizedState.inst;zt!==null&&g!==null&&um(g,zt.memoizedState.deps)?j.memoizedState=ho(o,A,f,g):(_t.flags|=s,j.memoizedState=ho(1|o,A,f,g))}function Mv(s,o){Lu(8390656,8,s,o)}function vm(s,o){Du(2048,8,s,o)}function YT(s){_t.flags|=4;var o=_t.updateQueue;if(o===null)o=Nu(),_t.updateQueue=o,o.events=[s];else{var f=o.events;f===null?o.events=[s]:f.push(s)}}function Pv(s){var o=pn().memoizedState;return YT({ref:o,nextImpl:s}),function(){if((Mt&2)!==0)throw Error(r(440));return o.impl.apply(void 0,arguments)}}function Bv(s,o){return Du(4,2,s,o)}function $v(s,o){return Du(4,4,s,o)}function zv(s,o){if(typeof o=="function"){s=s();var f=o(s);return function(){typeof f=="function"?f():o(null)}}if(o!=null)return s=s(),o.current=s,function(){o.current=null}}function Hv(s,o,f){f=f!=null?f.concat([s]):null,Du(4,4,zv.bind(null,o,s),f)}function _m(){}function Fv(s,o){var f=pn();o=o===void 0?null:o;var g=f.memoizedState;return o!==null&&um(o,g[1])?g[0]:(f.memoizedState=[s,o],s)}function Uv(s,o){var f=pn();o=o===void 0?null:o;var g=f.memoizedState;if(o!==null&&um(o,g[1]))return g[0];if(g=s(),la){ue(!0);try{s()}finally{ue(!1)}}return f.memoizedState=[g,o],g}function Sm(s,o,f){return f===void 0||(Rs&1073741824)!==0&&(Et&261930)===0?s.memoizedState=o:(s.memoizedState=f,s=V_(),_t.lanes|=s,yi|=s,f)}function Vv(s,o,f,g){return mr(f,o)?f:lo.current!==null?(s=Sm(s,f,g),mr(s,o)||(_n=!0),s):(Rs&42)===0||(Rs&1073741824)!==0&&(Et&261930)===0?(_n=!0,s.memoizedState=f):(s=V_(),_t.lanes|=s,yi|=s,o)}function Wv(s,o,f,g,j){var A=Z.p;Z.p=A!==0&&8>A?A:8;var G=V.T,te={};V.T=te,km(s,!1,o,f);try{var oe=j(),pe=V.S;if(pe!==null&&pe(te,oe),oe!==null&&typeof oe=="object"&&typeof oe.then=="function"){var Te=VT(oe,g);Ll(s,o,Te,vr(s))}else Ll(s,o,g,vr(s))}catch(Oe){Ll(s,o,{then:function(){},status:"rejected",reason:Oe},vr())}finally{Z.p=A,G!==null&&te.types!==null&&(G.types=te.types),V.T=G}}function XT(){}function wm(s,o,f,g){if(s.tag!==5)throw Error(r(476));var j=Gv(s).queue;Wv(s,j,o,ee,f===null?XT:function(){return qv(s),f(g)})}function Gv(s){var o=s.memoizedState;if(o!==null)return o;o={memoizedState:ee,baseState:ee,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Os,lastRenderedState:ee},next:null};var f={};return o.next={memoizedState:f,baseState:f,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Os,lastRenderedState:f},next:null},s.memoizedState=o,s=s.alternate,s!==null&&(s.memoizedState=o),o}function qv(s){var o=Gv(s);o.next===null&&(o=s.alternate.memoizedState),Ll(s,o.next.queue,{},vr())}function Cm(){return Mn(Kl)}function Kv(){return pn().memoizedState}function Yv(){return pn().memoizedState}function QT(s){for(var o=s.return;o!==null;){switch(o.tag){case 24:case 3:var f=vr();s=hi(f);var g=fi(o,s,f);g!==null&&(ir(g,o,f),jl(g,o,f)),o={cache:Zf()},s.payload=o;return}o=o.return}}function JT(s,o,f){var g=vr();f={lane:g,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},Ru(s)?Qv(o,f):(f=Ff(s,o,f,g),f!==null&&(ir(f,s,g),Jv(f,o,g)))}function Xv(s,o,f){var g=vr();Ll(s,o,f,g)}function Ll(s,o,f,g){var j={lane:g,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null};if(Ru(s))Qv(o,j);else{var A=s.alternate;if(s.lanes===0&&(A===null||A.lanes===0)&&(A=o.lastRenderedReducer,A!==null))try{var G=o.lastRenderedState,te=A(G,f);if(j.hasEagerState=!0,j.eagerState=te,mr(te,G))return fu(s,o,j,0),Gt===null&&hu(),!1}catch{}finally{}if(f=Ff(s,o,j,g),f!==null)return ir(f,s,g),Jv(f,o,g),!0}return!1}function km(s,o,f,g){if(g={lane:2,revertLane:rp(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},Ru(s)){if(o)throw Error(r(479))}else o=Ff(s,f,g,2),o!==null&&ir(o,s,2)}function Ru(s){var o=s.alternate;return s===_t||o!==null&&o===_t}function Qv(s,o){co=ju=!0;var f=s.pending;f===null?o.next=o:(o.next=f.next,f.next=o),s.pending=o}function Jv(s,o,f){if((f&4194048)!==0){var g=o.lanes;g&=s.pendingLanes,f|=g,o.lanes=f,_e(s,f)}}var Dl={readContext:Mn,use:Tu,useCallback:un,useContext:un,useEffect:un,useImperativeHandle:un,useLayoutEffect:un,useInsertionEffect:un,useMemo:un,useReducer:un,useRef:un,useState:un,useDebugValue:un,useDeferredValue:un,useTransition:un,useSyncExternalStore:un,useId:un,useHostTransitionStatus:un,useFormState:un,useActionState:un,useOptimistic:un,useMemoCache:un,useCacheRefresh:un};Dl.useEffectEvent=un;var Zv={readContext:Mn,use:Tu,useCallback:function(s,o){return Yn().memoizedState=[s,o===void 0?null:o],s},useContext:Mn,useEffect:Mv,useImperativeHandle:function(s,o,f){f=f!=null?f.concat([s]):null,Lu(4194308,4,zv.bind(null,o,s),f)},useLayoutEffect:function(s,o){return Lu(4194308,4,s,o)},useInsertionEffect:function(s,o){Lu(4,2,s,o)},useMemo:function(s,o){var f=Yn();o=o===void 0?null:o;var g=s();if(la){ue(!0);try{s()}finally{ue(!1)}}return f.memoizedState=[g,o],g},useReducer:function(s,o,f){var g=Yn();if(f!==void 0){var j=f(o);if(la){ue(!0);try{f(o)}finally{ue(!1)}}}else j=o;return g.memoizedState=g.baseState=j,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:j},g.queue=s,s=s.dispatch=JT.bind(null,_t,s),[g.memoizedState,s]},useRef:function(s){var o=Yn();return s={current:s},o.memoizedState=s},useState:function(s){s=ym(s);var o=s.queue,f=Xv.bind(null,_t,o);return o.dispatch=f,[s.memoizedState,f]},useDebugValue:_m,useDeferredValue:function(s,o){var f=Yn();return Sm(f,s,o)},useTransition:function(){var s=ym(!1);return s=Wv.bind(null,_t,s.queue,!0,!1),Yn().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,o,f){var g=_t,j=Yn();if(At){if(f===void 0)throw Error(r(407));f=f()}else{if(f=o(),Gt===null)throw Error(r(349));(Et&127)!==0||vv(g,o,f)}j.memoizedState=f;var A={value:f,getSnapshot:o};return j.queue=A,Mv(Sv.bind(null,g,A,s),[s]),g.flags|=2048,ho(9,{destroy:void 0},_v.bind(null,g,A,f,o),null),f},useId:function(){var s=Yn(),o=Gt.identifierPrefix;if(At){var f=ls,g=os;f=(g&~(1<<32-$e(g)-1)).toString(32)+f,o="_"+o+"R_"+f,f=Eu++,0<f&&(o+="H"+f.toString(32)),o+="_"}else f=WT++,o="_"+o+"r_"+f.toString(32)+"_";return s.memoizedState=o},useHostTransitionStatus:Cm,useFormState:Lv,useActionState:Lv,useOptimistic:function(s){var o=Yn();o.memoizedState=o.baseState=s;var f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=f,o=km.bind(null,_t,!0,f),f.dispatch=o,[s,o]},useMemoCache:pm,useCacheRefresh:function(){return Yn().memoizedState=QT.bind(null,_t)},useEffectEvent:function(s){var o=Yn(),f={impl:s};return o.memoizedState=f,function(){if((Mt&2)!==0)throw Error(r(440));return f.impl.apply(void 0,arguments)}}},jm={readContext:Mn,use:Tu,useCallback:Fv,useContext:Mn,useEffect:vm,useImperativeHandle:Hv,useInsertionEffect:Bv,useLayoutEffect:$v,useMemo:Uv,useReducer:Au,useRef:Iv,useState:function(){return Au(Os)},useDebugValue:_m,useDeferredValue:function(s,o){var f=pn();return Vv(f,zt.memoizedState,s,o)},useTransition:function(){var s=Au(Os)[0],o=pn().memoizedState;return[typeof s=="boolean"?s:Al(s),o]},useSyncExternalStore:bv,useId:Kv,useHostTransitionStatus:Cm,useFormState:Dv,useActionState:Dv,useOptimistic:function(s,o){var f=pn();return kv(f,zt,s,o)},useMemoCache:pm,useCacheRefresh:Yv};jm.useEffectEvent=Pv;var e_={readContext:Mn,use:Tu,useCallback:Fv,useContext:Mn,useEffect:vm,useImperativeHandle:Hv,useInsertionEffect:Bv,useLayoutEffect:$v,useMemo:Uv,useReducer:xm,useRef:Iv,useState:function(){return xm(Os)},useDebugValue:_m,useDeferredValue:function(s,o){var f=pn();return zt===null?Sm(f,s,o):Vv(f,zt.memoizedState,s,o)},useTransition:function(){var s=xm(Os)[0],o=pn().memoizedState;return[typeof s=="boolean"?s:Al(s),o]},useSyncExternalStore:bv,useId:Kv,useHostTransitionStatus:Cm,useFormState:Ov,useActionState:Ov,useOptimistic:function(s,o){var f=pn();return zt!==null?kv(f,zt,s,o):(f.baseState=s,[s,f.queue.dispatch])},useMemoCache:pm,useCacheRefresh:Yv};e_.useEffectEvent=Pv;function Em(s,o,f,g){o=s.memoizedState,f=f(g,o),f=f==null?o:m({},o,f),s.memoizedState=f,s.lanes===0&&(s.updateQueue.baseState=f)}var Nm={enqueueSetState:function(s,o,f){s=s._reactInternals;var g=vr(),j=hi(g);j.payload=o,f!=null&&(j.callback=f),o=fi(s,j,g),o!==null&&(ir(o,s,g),jl(o,s,g))},enqueueReplaceState:function(s,o,f){s=s._reactInternals;var g=vr(),j=hi(g);j.tag=1,j.payload=o,f!=null&&(j.callback=f),o=fi(s,j,g),o!==null&&(ir(o,s,g),jl(o,s,g))},enqueueForceUpdate:function(s,o){s=s._reactInternals;var f=vr(),g=hi(f);g.tag=2,o!=null&&(g.callback=o),o=fi(s,g,f),o!==null&&(ir(o,s,f),jl(o,s,f))}};function t_(s,o,f,g,j,A,G){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(g,A,G):o.prototype&&o.prototype.isPureReactComponent?!yl(f,g)||!yl(j,A):!0}function n_(s,o,f,g){s=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(f,g),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(f,g),o.state!==s&&Nm.enqueueReplaceState(o,o.state,null)}function ca(s,o){var f=o;if("ref"in o){f={};for(var g in o)g!=="ref"&&(f[g]=o[g])}if(s=s.defaultProps){f===o&&(f=m({},f));for(var j in s)f[j]===void 0&&(f[j]=s[j])}return f}function r_(s){du(s)}function s_(s){console.error(s)}function i_(s){du(s)}function Ou(s,o){try{var f=s.onUncaughtError;f(o.value,{componentStack:o.stack})}catch(g){setTimeout(function(){throw g})}}function a_(s,o,f){try{var g=s.onCaughtError;g(f.value,{componentStack:f.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(j){setTimeout(function(){throw j})}}function Tm(s,o,f){return f=hi(f),f.tag=3,f.payload={element:null},f.callback=function(){Ou(s,o)},f}function o_(s){return s=hi(s),s.tag=3,s}function l_(s,o,f,g){var j=f.type.getDerivedStateFromError;if(typeof j=="function"){var A=g.value;s.payload=function(){return j(A)},s.callback=function(){a_(o,f,g)}}var G=f.stateNode;G!==null&&typeof G.componentDidCatch=="function"&&(s.callback=function(){a_(o,f,g),typeof j!="function"&&(bi===null?bi=new Set([this]):bi.add(this));var te=g.stack;this.componentDidCatch(g.value,{componentStack:te!==null?te:""})})}function ZT(s,o,f,g,j){if(f.flags|=32768,g!==null&&typeof g=="object"&&typeof g.then=="function"){if(o=f.alternate,o!==null&&ro(o,f,j,!0),f=gr.current,f!==null){switch(f.tag){case 31:case 13:return Ir===null?Gu():f.alternate===null&&dn===0&&(dn=3),f.flags&=-257,f.flags|=65536,f.lanes=j,g===_u?f.flags|=16384:(o=f.updateQueue,o===null?f.updateQueue=new Set([g]):o.add(g),ep(s,g,j)),!1;case 22:return f.flags|=65536,g===_u?f.flags|=16384:(o=f.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([g])},f.updateQueue=o):(f=o.retryQueue,f===null?o.retryQueue=new Set([g]):f.add(g)),ep(s,g,j)),!1}throw Error(r(435,f.tag))}return ep(s,g,j),Gu(),!1}if(At)return o=gr.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=j,g!==Kf&&(s=Error(r(422),{cause:g}),_l(Lr(s,f)))):(g!==Kf&&(o=Error(r(423),{cause:g}),_l(Lr(o,f))),s=s.current.alternate,s.flags|=65536,j&=-j,s.lanes|=j,g=Lr(g,f),j=Tm(s.stateNode,g,j),im(s,j),dn!==4&&(dn=2)),!1;var A=Error(r(520),{cause:g});if(A=Lr(A,f),zl===null?zl=[A]:zl.push(A),dn!==4&&(dn=2),o===null)return!0;g=Lr(g,f),f=o;do{switch(f.tag){case 3:return f.flags|=65536,s=j&-j,f.lanes|=s,s=Tm(f.stateNode,g,s),im(f,s),!1;case 1:if(o=f.type,A=f.stateNode,(f.flags&128)===0&&(typeof o.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&(bi===null||!bi.has(A))))return f.flags|=65536,j&=-j,f.lanes|=j,j=o_(j),l_(j,s,f,g),im(f,j),!1}f=f.return}while(f!==null);return!1}var Am=Error(r(461)),_n=!1;function Pn(s,o,f,g){o.child=s===null?hv(o,null,f,g):oa(o,s.child,f,g)}function c_(s,o,f,g,j){f=f.render;var A=o.ref;if("ref"in g){var G={};for(var te in g)te!=="ref"&&(G[te]=g[te])}else G=g;return ra(o),g=dm(s,o,f,G,A,j),te=hm(),s!==null&&!_n?(fm(s,o,j),Is(s,o,j)):(At&&te&&Gf(o),o.flags|=1,Pn(s,o,g,j),o.child)}function u_(s,o,f,g,j){if(s===null){var A=f.type;return typeof A=="function"&&!Uf(A)&&A.defaultProps===void 0&&f.compare===null?(o.tag=15,o.type=A,d_(s,o,A,g,j)):(s=pu(f.type,null,g,o,o.mode,j),s.ref=o.ref,s.return=o,o.child=s)}if(A=s.child,!Bm(s,j)){var G=A.memoizedProps;if(f=f.compare,f=f!==null?f:yl,f(G,g)&&s.ref===o.ref)return Is(s,o,j)}return o.flags|=1,s=Ts(A,g),s.ref=o.ref,s.return=o,o.child=s}function d_(s,o,f,g,j){if(s!==null){var A=s.memoizedProps;if(yl(A,g)&&s.ref===o.ref)if(_n=!1,o.pendingProps=g=A,Bm(s,j))(s.flags&131072)!==0&&(_n=!0);else return o.lanes=s.lanes,Is(s,o,j)}return Lm(s,o,f,g,j)}function h_(s,o,f,g){var j=g.children,A=s!==null?s.memoizedState:null;if(s===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.mode==="hidden"){if((o.flags&128)!==0){if(A=A!==null?A.baseLanes|f:f,s!==null){for(g=o.child=s.child,j=0;g!==null;)j=j|g.lanes|g.childLanes,g=g.sibling;g=j&~A}else g=0,o.child=null;return f_(s,o,A,f,g)}if((f&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},s!==null&&bu(o,A!==null?A.cachePool:null),A!==null?pv(o,A):om(),gv(o);else return g=o.lanes=536870912,f_(s,o,A!==null?A.baseLanes|f:f,f,g)}else A!==null?(bu(o,A.cachePool),pv(o,A),pi(),o.memoizedState=null):(s!==null&&bu(o,null),om(),pi());return Pn(s,o,j,f),o.child}function Rl(s,o){return s!==null&&s.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function f_(s,o,f,g,j){var A=tm();return A=A===null?null:{parent:bn._currentValue,pool:A},o.memoizedState={baseLanes:f,cachePool:A},s!==null&&bu(o,null),om(),gv(o),s!==null&&ro(s,o,g,!0),o.childLanes=j,null}function Iu(s,o){return o=Pu({mode:o.mode,children:o.children},s.mode),o.ref=s.ref,s.child=o,o.return=s,o}function m_(s,o,f){return oa(o,s.child,null,f),s=Iu(o,o.pendingProps),s.flags|=2,xr(o),o.memoizedState=null,s}function eA(s,o,f){var g=o.pendingProps,j=(o.flags&128)!==0;if(o.flags&=-129,s===null){if(At){if(g.mode==="hidden")return s=Iu(o,g),o.lanes=536870912,Rl(null,s);if(cm(o),(s=Zt)?(s=j0(s,Or),s=s!==null&&s.data==="&"?s:null,s!==null&&(o.memoizedState={dehydrated:s,treeContext:oi!==null?{id:os,overflow:ls}:null,retryLane:536870912,hydrationErrors:null},f=Qb(s),f.return=o,o.child=f,In=o,Zt=null)):s=null,s===null)throw ci(o);return o.lanes=536870912,null}return Iu(o,g)}var A=s.memoizedState;if(A!==null){var G=A.dehydrated;if(cm(o),j)if(o.flags&256)o.flags&=-257,o=m_(s,o,f);else if(o.memoizedState!==null)o.child=s.child,o.flags|=128,o=null;else throw Error(r(558));else if(_n||ro(s,o,f,!1),j=(f&s.childLanes)!==0,_n||j){if(g=Gt,g!==null&&(G=rt(g,f),G!==0&&G!==A.retryLane))throw A.retryLane=G,Zi(s,G),ir(g,s,G),Am;Gu(),o=m_(s,o,f)}else s=A.treeContext,Zt=Mr(G.nextSibling),In=o,At=!0,li=null,Or=!1,s!==null&&ev(o,s),o=Iu(o,g),o.flags|=4096;return o}return s=Ts(s.child,{mode:g.mode,children:g.children}),s.ref=o.ref,o.child=s,s.return=o,s}function Mu(s,o){var f=o.ref;if(f===null)s!==null&&s.ref!==null&&(o.flags|=4194816);else{if(typeof f!="function"&&typeof f!="object")throw Error(r(284));(s===null||s.ref!==f)&&(o.flags|=4194816)}}function Lm(s,o,f,g,j){return ra(o),f=dm(s,o,f,g,void 0,j),g=hm(),s!==null&&!_n?(fm(s,o,j),Is(s,o,j)):(At&&g&&Gf(o),o.flags|=1,Pn(s,o,f,j),o.child)}function p_(s,o,f,g,j,A){return ra(o),o.updateQueue=null,f=yv(o,g,f,j),xv(s),g=hm(),s!==null&&!_n?(fm(s,o,A),Is(s,o,A)):(At&&g&&Gf(o),o.flags|=1,Pn(s,o,f,A),o.child)}function g_(s,o,f,g,j){if(ra(o),o.stateNode===null){var A=Za,G=f.contextType;typeof G=="object"&&G!==null&&(A=Mn(G)),A=new f(g,A),o.memoizedState=A.state!==null&&A.state!==void 0?A.state:null,A.updater=Nm,o.stateNode=A,A._reactInternals=o,A=o.stateNode,A.props=g,A.state=o.memoizedState,A.refs={},rm(o),G=f.contextType,A.context=typeof G=="object"&&G!==null?Mn(G):Za,A.state=o.memoizedState,G=f.getDerivedStateFromProps,typeof G=="function"&&(Em(o,f,G,g),A.state=o.memoizedState),typeof f.getDerivedStateFromProps=="function"||typeof A.getSnapshotBeforeUpdate=="function"||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(G=A.state,typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount(),G!==A.state&&Nm.enqueueReplaceState(A,A.state,null),Nl(o,g,A,j),El(),A.state=o.memoizedState),typeof A.componentDidMount=="function"&&(o.flags|=4194308),g=!0}else if(s===null){A=o.stateNode;var te=o.memoizedProps,oe=ca(f,te);A.props=oe;var pe=A.context,Te=f.contextType;G=Za,typeof Te=="object"&&Te!==null&&(G=Mn(Te));var Oe=f.getDerivedStateFromProps;Te=typeof Oe=="function"||typeof A.getSnapshotBeforeUpdate=="function",te=o.pendingProps!==te,Te||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(te||pe!==G)&&n_(o,A,g,G),di=!1;var be=o.memoizedState;A.state=be,Nl(o,g,A,j),El(),pe=o.memoizedState,te||be!==pe||di?(typeof Oe=="function"&&(Em(o,f,Oe,g),pe=o.memoizedState),(oe=di||t_(o,f,oe,g,be,pe,G))?(Te||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(o.flags|=4194308)):(typeof A.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=g,o.memoizedState=pe),A.props=g,A.state=pe,A.context=G,g=oe):(typeof A.componentDidMount=="function"&&(o.flags|=4194308),g=!1)}else{A=o.stateNode,sm(s,o),G=o.memoizedProps,Te=ca(f,G),A.props=Te,Oe=o.pendingProps,be=A.context,pe=f.contextType,oe=Za,typeof pe=="object"&&pe!==null&&(oe=Mn(pe)),te=f.getDerivedStateFromProps,(pe=typeof te=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(G!==Oe||be!==oe)&&n_(o,A,g,oe),di=!1,be=o.memoizedState,A.state=be,Nl(o,g,A,j),El();var je=o.memoizedState;G!==Oe||be!==je||di||s!==null&&s.dependencies!==null&&xu(s.dependencies)?(typeof te=="function"&&(Em(o,f,te,g),je=o.memoizedState),(Te=di||t_(o,f,Te,g,be,je,oe)||s!==null&&s.dependencies!==null&&xu(s.dependencies))?(pe||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(g,je,oe),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(g,je,oe)),typeof A.componentDidUpdate=="function"&&(o.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof A.componentDidUpdate!="function"||G===s.memoizedProps&&be===s.memoizedState||(o.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||G===s.memoizedProps&&be===s.memoizedState||(o.flags|=1024),o.memoizedProps=g,o.memoizedState=je),A.props=g,A.state=je,A.context=oe,g=Te):(typeof A.componentDidUpdate!="function"||G===s.memoizedProps&&be===s.memoizedState||(o.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||G===s.memoizedProps&&be===s.memoizedState||(o.flags|=1024),g=!1)}return A=g,Mu(s,o),g=(o.flags&128)!==0,A||g?(A=o.stateNode,f=g&&typeof f.getDerivedStateFromError!="function"?null:A.render(),o.flags|=1,s!==null&&g?(o.child=oa(o,s.child,null,j),o.child=oa(o,null,f,j)):Pn(s,o,f,j),o.memoizedState=A.state,s=o.child):s=Is(s,o,j),s}function x_(s,o,f,g){return ta(),o.flags|=256,Pn(s,o,f,g),o.child}var Dm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Rm(s){return{baseLanes:s,cachePool:av()}}function Om(s,o,f){return s=s!==null?s.childLanes&~f:0,o&&(s|=br),s}function y_(s,o,f){var g=o.pendingProps,j=!1,A=(o.flags&128)!==0,G;if((G=A)||(G=s!==null&&s.memoizedState===null?!1:(mn.current&2)!==0),G&&(j=!0,o.flags&=-129),G=(o.flags&32)!==0,o.flags&=-33,s===null){if(At){if(j?mi(o):pi(),(s=Zt)?(s=j0(s,Or),s=s!==null&&s.data!=="&"?s:null,s!==null&&(o.memoizedState={dehydrated:s,treeContext:oi!==null?{id:os,overflow:ls}:null,retryLane:536870912,hydrationErrors:null},f=Qb(s),f.return=o,o.child=f,In=o,Zt=null)):s=null,s===null)throw ci(o);return gp(s)?o.lanes=32:o.lanes=536870912,null}var te=g.children;return g=g.fallback,j?(pi(),j=o.mode,te=Pu({mode:"hidden",children:te},j),g=ea(g,j,f,null),te.return=o,g.return=o,te.sibling=g,o.child=te,g=o.child,g.memoizedState=Rm(f),g.childLanes=Om(s,G,f),o.memoizedState=Dm,Rl(null,g)):(mi(o),Im(o,te))}var oe=s.memoizedState;if(oe!==null&&(te=oe.dehydrated,te!==null)){if(A)o.flags&256?(mi(o),o.flags&=-257,o=Mm(s,o,f)):o.memoizedState!==null?(pi(),o.child=s.child,o.flags|=128,o=null):(pi(),te=g.fallback,j=o.mode,g=Pu({mode:"visible",children:g.children},j),te=ea(te,j,f,null),te.flags|=2,g.return=o,te.return=o,g.sibling=te,o.child=g,oa(o,s.child,null,f),g=o.child,g.memoizedState=Rm(f),g.childLanes=Om(s,G,f),o.memoizedState=Dm,o=Rl(null,g));else if(mi(o),gp(te)){if(G=te.nextSibling&&te.nextSibling.dataset,G)var pe=G.dgst;G=pe,g=Error(r(419)),g.stack="",g.digest=G,_l({value:g,source:null,stack:null}),o=Mm(s,o,f)}else if(_n||ro(s,o,f,!1),G=(f&s.childLanes)!==0,_n||G){if(G=Gt,G!==null&&(g=rt(G,f),g!==0&&g!==oe.retryLane))throw oe.retryLane=g,Zi(s,g),ir(G,s,g),Am;pp(te)||Gu(),o=Mm(s,o,f)}else pp(te)?(o.flags|=192,o.child=s.child,o=null):(s=oe.treeContext,Zt=Mr(te.nextSibling),In=o,At=!0,li=null,Or=!1,s!==null&&ev(o,s),o=Im(o,g.children),o.flags|=4096);return o}return j?(pi(),te=g.fallback,j=o.mode,oe=s.child,pe=oe.sibling,g=Ts(oe,{mode:"hidden",children:g.children}),g.subtreeFlags=oe.subtreeFlags&65011712,pe!==null?te=Ts(pe,te):(te=ea(te,j,f,null),te.flags|=2),te.return=o,g.return=o,g.sibling=te,o.child=g,Rl(null,g),g=o.child,te=s.child.memoizedState,te===null?te=Rm(f):(j=te.cachePool,j!==null?(oe=bn._currentValue,j=j.parent!==oe?{parent:oe,pool:oe}:j):j=av(),te={baseLanes:te.baseLanes|f,cachePool:j}),g.memoizedState=te,g.childLanes=Om(s,G,f),o.memoizedState=Dm,Rl(s.child,g)):(mi(o),f=s.child,s=f.sibling,f=Ts(f,{mode:"visible",children:g.children}),f.return=o,f.sibling=null,s!==null&&(G=o.deletions,G===null?(o.deletions=[s],o.flags|=16):G.push(s)),o.child=f,o.memoizedState=null,f)}function Im(s,o){return o=Pu({mode:"visible",children:o},s.mode),o.return=s,s.child=o}function Pu(s,o){return s=pr(22,s,null,o),s.lanes=0,s}function Mm(s,o,f){return oa(o,s.child,null,f),s=Im(o,o.pendingProps.children),s.flags|=2,o.memoizedState=null,s}function b_(s,o,f){s.lanes|=o;var g=s.alternate;g!==null&&(g.lanes|=o),Qf(s.return,o,f)}function Pm(s,o,f,g,j,A){var G=s.memoizedState;G===null?s.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:g,tail:f,tailMode:j,treeForkCount:A}:(G.isBackwards=o,G.rendering=null,G.renderingStartTime=0,G.last=g,G.tail=f,G.tailMode=j,G.treeForkCount=A)}function v_(s,o,f){var g=o.pendingProps,j=g.revealOrder,A=g.tail;g=g.children;var G=mn.current,te=(G&2)!==0;if(te?(G=G&1|2,o.flags|=128):G&=1,$(mn,G),Pn(s,o,g,f),g=At?vl:0,!te&&s!==null&&(s.flags&128)!==0)e:for(s=o.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&b_(s,f,o);else if(s.tag===19)b_(s,f,o);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===o)break e;for(;s.sibling===null;){if(s.return===null||s.return===o)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(j){case"forwards":for(f=o.child,j=null;f!==null;)s=f.alternate,s!==null&&ku(s)===null&&(j=f),f=f.sibling;f=j,f===null?(j=o.child,o.child=null):(j=f.sibling,f.sibling=null),Pm(o,!1,j,f,A,g);break;case"backwards":case"unstable_legacy-backwards":for(f=null,j=o.child,o.child=null;j!==null;){if(s=j.alternate,s!==null&&ku(s)===null){o.child=j;break}s=j.sibling,j.sibling=f,f=j,j=s}Pm(o,!0,f,null,A,g);break;case"together":Pm(o,!1,null,null,void 0,g);break;default:o.memoizedState=null}return o.child}function Is(s,o,f){if(s!==null&&(o.dependencies=s.dependencies),yi|=o.lanes,(f&o.childLanes)===0)if(s!==null){if(ro(s,o,f,!1),(f&o.childLanes)===0)return null}else return null;if(s!==null&&o.child!==s.child)throw Error(r(153));if(o.child!==null){for(s=o.child,f=Ts(s,s.pendingProps),o.child=f,f.return=o;s.sibling!==null;)s=s.sibling,f=f.sibling=Ts(s,s.pendingProps),f.return=o;f.sibling=null}return o.child}function Bm(s,o){return(s.lanes&o)!==0?!0:(s=s.dependencies,!!(s!==null&&xu(s)))}function tA(s,o,f){switch(o.tag){case 3:P(o,o.stateNode.containerInfo),ui(o,bn,s.memoizedState.cache),ta();break;case 27:case 5:ne(o);break;case 4:P(o,o.stateNode.containerInfo);break;case 10:ui(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,cm(o),null;break;case 13:var g=o.memoizedState;if(g!==null)return g.dehydrated!==null?(mi(o),o.flags|=128,null):(f&o.child.childLanes)!==0?y_(s,o,f):(mi(o),s=Is(s,o,f),s!==null?s.sibling:null);mi(o);break;case 19:var j=(s.flags&128)!==0;if(g=(f&o.childLanes)!==0,g||(ro(s,o,f,!1),g=(f&o.childLanes)!==0),j){if(g)return v_(s,o,f);o.flags|=128}if(j=o.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),$(mn,mn.current),g)break;return null;case 22:return o.lanes=0,h_(s,o,f,o.pendingProps);case 24:ui(o,bn,s.memoizedState.cache)}return Is(s,o,f)}function __(s,o,f){if(s!==null)if(s.memoizedProps!==o.pendingProps)_n=!0;else{if(!Bm(s,f)&&(o.flags&128)===0)return _n=!1,tA(s,o,f);_n=(s.flags&131072)!==0}else _n=!1,At&&(o.flags&1048576)!==0&&Zb(o,vl,o.index);switch(o.lanes=0,o.tag){case 16:e:{var g=o.pendingProps;if(s=ia(o.elementType),o.type=s,typeof s=="function")Uf(s)?(g=ca(s,g),o.tag=1,o=g_(null,o,s,g,f)):(o.tag=0,o=Lm(null,o,s,g,f));else{if(s!=null){var j=s.$$typeof;if(j===k){o.tag=11,o=c_(null,o,s,g,f);break e}else if(j===D){o.tag=14,o=u_(null,o,s,g,f);break e}}throw o=I(s)||s,Error(r(306,o,""))}}return o;case 0:return Lm(s,o,o.type,o.pendingProps,f);case 1:return g=o.type,j=ca(g,o.pendingProps),g_(s,o,g,j,f);case 3:e:{if(P(o,o.stateNode.containerInfo),s===null)throw Error(r(387));g=o.pendingProps;var A=o.memoizedState;j=A.element,sm(s,o),Nl(o,g,null,f);var G=o.memoizedState;if(g=G.cache,ui(o,bn,g),g!==A.cache&&Jf(o,[bn],f,!0),El(),g=G.element,A.isDehydrated)if(A={element:g,isDehydrated:!1,cache:G.cache},o.updateQueue.baseState=A,o.memoizedState=A,o.flags&256){o=x_(s,o,g,f);break e}else if(g!==j){j=Lr(Error(r(424)),o),_l(j),o=x_(s,o,g,f);break e}else{switch(s=o.stateNode.containerInfo,s.nodeType){case 9:s=s.body;break;default:s=s.nodeName==="HTML"?s.ownerDocument.body:s}for(Zt=Mr(s.firstChild),In=o,At=!0,li=null,Or=!0,f=hv(o,null,g,f),o.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling}else{if(ta(),g===j){o=Is(s,o,f);break e}Pn(s,o,g,f)}o=o.child}return o;case 26:return Mu(s,o),s===null?(f=D0(o.type,null,o.pendingProps,null))?o.memoizedState=f:At||(f=o.type,s=o.pendingProps,g=Zu(X.current).createElement(f),g[at]=o,g[dt]=s,Bn(g,f,s),An(g),o.stateNode=g):o.memoizedState=D0(o.type,s.memoizedProps,o.pendingProps,s.memoizedState),null;case 27:return ne(o),s===null&&At&&(g=o.stateNode=T0(o.type,o.pendingProps,X.current),In=o,Or=!0,j=Zt,wi(o.type)?(xp=j,Zt=Mr(g.firstChild)):Zt=j),Pn(s,o,o.pendingProps.children,f),Mu(s,o),s===null&&(o.flags|=4194304),o.child;case 5:return s===null&&At&&((j=g=Zt)&&(g=LA(g,o.type,o.pendingProps,Or),g!==null?(o.stateNode=g,In=o,Zt=Mr(g.firstChild),Or=!1,j=!0):j=!1),j||ci(o)),ne(o),j=o.type,A=o.pendingProps,G=s!==null?s.memoizedProps:null,g=A.children,hp(j,A)?g=null:G!==null&&hp(j,G)&&(o.flags|=32),o.memoizedState!==null&&(j=dm(s,o,GT,null,null,f),Kl._currentValue=j),Mu(s,o),Pn(s,o,g,f),o.child;case 6:return s===null&&At&&((s=f=Zt)&&(f=DA(f,o.pendingProps,Or),f!==null?(o.stateNode=f,In=o,Zt=null,s=!0):s=!1),s||ci(o)),null;case 13:return y_(s,o,f);case 4:return P(o,o.stateNode.containerInfo),g=o.pendingProps,s===null?o.child=oa(o,null,g,f):Pn(s,o,g,f),o.child;case 11:return c_(s,o,o.type,o.pendingProps,f);case 7:return Pn(s,o,o.pendingProps,f),o.child;case 8:return Pn(s,o,o.pendingProps.children,f),o.child;case 12:return Pn(s,o,o.pendingProps.children,f),o.child;case 10:return g=o.pendingProps,ui(o,o.type,g.value),Pn(s,o,g.children,f),o.child;case 9:return j=o.type._context,g=o.pendingProps.children,ra(o),j=Mn(j),g=g(j),o.flags|=1,Pn(s,o,g,f),o.child;case 14:return u_(s,o,o.type,o.pendingProps,f);case 15:return d_(s,o,o.type,o.pendingProps,f);case 19:return v_(s,o,f);case 31:return eA(s,o,f);case 22:return h_(s,o,f,o.pendingProps);case 24:return ra(o),g=Mn(bn),s===null?(j=tm(),j===null&&(j=Gt,A=Zf(),j.pooledCache=A,A.refCount++,A!==null&&(j.pooledCacheLanes|=f),j=A),o.memoizedState={parent:g,cache:j},rm(o),ui(o,bn,j)):((s.lanes&f)!==0&&(sm(s,o),Nl(o,null,null,f),El()),j=s.memoizedState,A=o.memoizedState,j.parent!==g?(j={parent:g,cache:g},o.memoizedState=j,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=j),ui(o,bn,g)):(g=A.cache,ui(o,bn,g),g!==j.cache&&Jf(o,[bn],f,!0))),Pn(s,o,o.pendingProps.children,f),o.child;case 29:throw o.pendingProps}throw Error(r(156,o.tag))}function Ms(s){s.flags|=4}function $m(s,o,f,g,j){if((o=(s.mode&32)!==0)&&(o=!1),o){if(s.flags|=16777216,(j&335544128)===j)if(s.stateNode.complete)s.flags|=8192;else if(K_())s.flags|=8192;else throw aa=_u,nm}else s.flags&=-16777217}function S_(s,o){if(o.type!=="stylesheet"||(o.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!P0(o))if(K_())s.flags|=8192;else throw aa=_u,nm}function Bu(s,o){o!==null&&(s.flags|=4),s.flags&16384&&(o=s.tag!==22?tt():536870912,s.lanes|=o,go|=o)}function Ol(s,o){if(!At)switch(s.tailMode){case"hidden":o=s.tail;for(var f=null;o!==null;)o.alternate!==null&&(f=o),o=o.sibling;f===null?s.tail=null:f.sibling=null;break;case"collapsed":f=s.tail;for(var g=null;f!==null;)f.alternate!==null&&(g=f),f=f.sibling;g===null?o||s.tail===null?s.tail=null:s.tail.sibling=null:g.sibling=null}}function en(s){var o=s.alternate!==null&&s.alternate.child===s.child,f=0,g=0;if(o)for(var j=s.child;j!==null;)f|=j.lanes|j.childLanes,g|=j.subtreeFlags&65011712,g|=j.flags&65011712,j.return=s,j=j.sibling;else for(j=s.child;j!==null;)f|=j.lanes|j.childLanes,g|=j.subtreeFlags,g|=j.flags,j.return=s,j=j.sibling;return s.subtreeFlags|=g,s.childLanes=f,o}function nA(s,o,f){var g=o.pendingProps;switch(qf(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return en(o),null;case 1:return en(o),null;case 3:return f=o.stateNode,g=null,s!==null&&(g=s.memoizedState.cache),o.memoizedState.cache!==g&&(o.flags|=2048),Ds(bn),J(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(s===null||s.child===null)&&(no(o)?Ms(o):s===null||s.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Yf())),en(o),null;case 26:var j=o.type,A=o.memoizedState;return s===null?(Ms(o),A!==null?(en(o),S_(o,A)):(en(o),$m(o,j,null,g,f))):A?A!==s.memoizedState?(Ms(o),en(o),S_(o,A)):(en(o),o.flags&=-16777217):(s=s.memoizedProps,s!==g&&Ms(o),en(o),$m(o,j,s,g,f)),null;case 27:if(ce(o),f=X.current,j=o.type,s!==null&&o.stateNode!=null)s.memoizedProps!==g&&Ms(o);else{if(!g){if(o.stateNode===null)throw Error(r(166));return en(o),null}s=Y.current,no(o)?tv(o):(s=T0(j,g,f),o.stateNode=s,Ms(o))}return en(o),null;case 5:if(ce(o),j=o.type,s!==null&&o.stateNode!=null)s.memoizedProps!==g&&Ms(o);else{if(!g){if(o.stateNode===null)throw Error(r(166));return en(o),null}if(A=Y.current,no(o))tv(o);else{var G=Zu(X.current);switch(A){case 1:A=G.createElementNS("http://www.w3.org/2000/svg",j);break;case 2:A=G.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;default:switch(j){case"svg":A=G.createElementNS("http://www.w3.org/2000/svg",j);break;case"math":A=G.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;case"script":A=G.createElement("div"),A.innerHTML="<script><\/script>",A=A.removeChild(A.firstChild);break;case"select":A=typeof g.is=="string"?G.createElement("select",{is:g.is}):G.createElement("select"),g.multiple?A.multiple=!0:g.size&&(A.size=g.size);break;default:A=typeof g.is=="string"?G.createElement(j,{is:g.is}):G.createElement(j)}}A[at]=o,A[dt]=g;e:for(G=o.child;G!==null;){if(G.tag===5||G.tag===6)A.appendChild(G.stateNode);else if(G.tag!==4&&G.tag!==27&&G.child!==null){G.child.return=G,G=G.child;continue}if(G===o)break e;for(;G.sibling===null;){if(G.return===null||G.return===o)break e;G=G.return}G.sibling.return=G.return,G=G.sibling}o.stateNode=A;e:switch(Bn(A,j,g),j){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&Ms(o)}}return en(o),$m(o,o.type,s===null?null:s.memoizedProps,o.pendingProps,f),null;case 6:if(s&&o.stateNode!=null)s.memoizedProps!==g&&Ms(o);else{if(typeof g!="string"&&o.stateNode===null)throw Error(r(166));if(s=X.current,no(o)){if(s=o.stateNode,f=o.memoizedProps,g=null,j=In,j!==null)switch(j.tag){case 27:case 5:g=j.memoizedProps}s[at]=o,s=!!(s.nodeValue===f||g!==null&&g.suppressHydrationWarning===!0||y0(s.nodeValue,f)),s||ci(o,!0)}else s=Zu(s).createTextNode(g),s[at]=o,o.stateNode=s}return en(o),null;case 31:if(f=o.memoizedState,s===null||s.memoizedState!==null){if(g=no(o),f!==null){if(s===null){if(!g)throw Error(r(318));if(s=o.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(557));s[at]=o}else ta(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;en(o),s=!1}else f=Yf(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=f),s=!0;if(!s)return o.flags&256?(xr(o),o):(xr(o),null);if((o.flags&128)!==0)throw Error(r(558))}return en(o),null;case 13:if(g=o.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(j=no(o),g!==null&&g.dehydrated!==null){if(s===null){if(!j)throw Error(r(318));if(j=o.memoizedState,j=j!==null?j.dehydrated:null,!j)throw Error(r(317));j[at]=o}else ta(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;en(o),j=!1}else j=Yf(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=j),j=!0;if(!j)return o.flags&256?(xr(o),o):(xr(o),null)}return xr(o),(o.flags&128)!==0?(o.lanes=f,o):(f=g!==null,s=s!==null&&s.memoizedState!==null,f&&(g=o.child,j=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(j=g.alternate.memoizedState.cachePool.pool),A=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(A=g.memoizedState.cachePool.pool),A!==j&&(g.flags|=2048)),f!==s&&f&&(o.child.flags|=8192),Bu(o,o.updateQueue),en(o),null);case 4:return J(),s===null&&op(o.stateNode.containerInfo),en(o),null;case 10:return Ds(o.type),en(o),null;case 19:if(q(mn),g=o.memoizedState,g===null)return en(o),null;if(j=(o.flags&128)!==0,A=g.rendering,A===null)if(j)Ol(g,!1);else{if(dn!==0||s!==null&&(s.flags&128)!==0)for(s=o.child;s!==null;){if(A=ku(s),A!==null){for(o.flags|=128,Ol(g,!1),s=A.updateQueue,o.updateQueue=s,Bu(o,s),o.subtreeFlags=0,s=f,f=o.child;f!==null;)Xb(f,s),f=f.sibling;return $(mn,mn.current&1|2),At&&As(o,g.treeForkCount),o.child}s=s.sibling}g.tail!==null&&Fe()>Uu&&(o.flags|=128,j=!0,Ol(g,!1),o.lanes=4194304)}else{if(!j)if(s=ku(A),s!==null){if(o.flags|=128,j=!0,s=s.updateQueue,o.updateQueue=s,Bu(o,s),Ol(g,!0),g.tail===null&&g.tailMode==="hidden"&&!A.alternate&&!At)return en(o),null}else 2*Fe()-g.renderingStartTime>Uu&&f!==536870912&&(o.flags|=128,j=!0,Ol(g,!1),o.lanes=4194304);g.isBackwards?(A.sibling=o.child,o.child=A):(s=g.last,s!==null?s.sibling=A:o.child=A,g.last=A)}return g.tail!==null?(s=g.tail,g.rendering=s,g.tail=s.sibling,g.renderingStartTime=Fe(),s.sibling=null,f=mn.current,$(mn,j?f&1|2:f&1),At&&As(o,g.treeForkCount),s):(en(o),null);case 22:case 23:return xr(o),lm(),g=o.memoizedState!==null,s!==null?s.memoizedState!==null!==g&&(o.flags|=8192):g&&(o.flags|=8192),g?(f&536870912)!==0&&(o.flags&128)===0&&(en(o),o.subtreeFlags&6&&(o.flags|=8192)):en(o),f=o.updateQueue,f!==null&&Bu(o,f.retryQueue),f=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(f=s.memoizedState.cachePool.pool),g=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),g!==f&&(o.flags|=2048),s!==null&&q(sa),null;case 24:return f=null,s!==null&&(f=s.memoizedState.cache),o.memoizedState.cache!==f&&(o.flags|=2048),Ds(bn),en(o),null;case 25:return null;case 30:return null}throw Error(r(156,o.tag))}function rA(s,o){switch(qf(o),o.tag){case 1:return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 3:return Ds(bn),J(),s=o.flags,(s&65536)!==0&&(s&128)===0?(o.flags=s&-65537|128,o):null;case 26:case 27:case 5:return ce(o),null;case 31:if(o.memoizedState!==null){if(xr(o),o.alternate===null)throw Error(r(340));ta()}return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 13:if(xr(o),s=o.memoizedState,s!==null&&s.dehydrated!==null){if(o.alternate===null)throw Error(r(340));ta()}return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 19:return q(mn),null;case 4:return J(),null;case 10:return Ds(o.type),null;case 22:case 23:return xr(o),lm(),s!==null&&q(sa),s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 24:return Ds(bn),null;case 25:return null;default:return null}}function w_(s,o){switch(qf(o),o.tag){case 3:Ds(bn),J();break;case 26:case 27:case 5:ce(o);break;case 4:J();break;case 31:o.memoizedState!==null&&xr(o);break;case 13:xr(o);break;case 19:q(mn);break;case 10:Ds(o.type);break;case 22:case 23:xr(o),lm(),s!==null&&q(sa);break;case 24:Ds(bn)}}function Il(s,o){try{var f=o.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var j=g.next;f=j;do{if((f.tag&s)===s){g=void 0;var A=f.create,G=f.inst;g=A(),G.destroy=g}f=f.next}while(f!==j)}}catch(te){$t(o,o.return,te)}}function gi(s,o,f){try{var g=o.updateQueue,j=g!==null?g.lastEffect:null;if(j!==null){var A=j.next;g=A;do{if((g.tag&s)===s){var G=g.inst,te=G.destroy;if(te!==void 0){G.destroy=void 0,j=o;var oe=f,pe=te;try{pe()}catch(Te){$t(j,oe,Te)}}}g=g.next}while(g!==A)}}catch(Te){$t(o,o.return,Te)}}function C_(s){var o=s.updateQueue;if(o!==null){var f=s.stateNode;try{mv(o,f)}catch(g){$t(s,s.return,g)}}}function k_(s,o,f){f.props=ca(s.type,s.memoizedProps),f.state=s.memoizedState;try{f.componentWillUnmount()}catch(g){$t(s,o,g)}}function Ml(s,o){try{var f=s.ref;if(f!==null){switch(s.tag){case 26:case 27:case 5:var g=s.stateNode;break;case 30:g=s.stateNode;break;default:g=s.stateNode}typeof f=="function"?s.refCleanup=f(g):f.current=g}}catch(j){$t(s,o,j)}}function cs(s,o){var f=s.ref,g=s.refCleanup;if(f!==null)if(typeof g=="function")try{g()}catch(j){$t(s,o,j)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof f=="function")try{f(null)}catch(j){$t(s,o,j)}else f.current=null}function j_(s){var o=s.type,f=s.memoizedProps,g=s.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":f.autoFocus&&g.focus();break e;case"img":f.src?g.src=f.src:f.srcSet&&(g.srcset=f.srcSet)}}catch(j){$t(s,s.return,j)}}function zm(s,o,f){try{var g=s.stateNode;kA(g,s.type,f,o),g[dt]=o}catch(j){$t(s,s.return,j)}}function E_(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&wi(s.type)||s.tag===4}function Hm(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||E_(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&wi(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function Fm(s,o,f){var g=s.tag;if(g===5||g===6)s=s.stateNode,o?(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f).insertBefore(s,o):(o=f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,o.appendChild(s),f=f._reactRootContainer,f!=null||o.onclick!==null||(o.onclick=Es));else if(g!==4&&(g===27&&wi(s.type)&&(f=s.stateNode,o=null),s=s.child,s!==null))for(Fm(s,o,f),s=s.sibling;s!==null;)Fm(s,o,f),s=s.sibling}function $u(s,o,f){var g=s.tag;if(g===5||g===6)s=s.stateNode,o?f.insertBefore(s,o):f.appendChild(s);else if(g!==4&&(g===27&&wi(s.type)&&(f=s.stateNode),s=s.child,s!==null))for($u(s,o,f),s=s.sibling;s!==null;)$u(s,o,f),s=s.sibling}function N_(s){var o=s.stateNode,f=s.memoizedProps;try{for(var g=s.type,j=o.attributes;j.length;)o.removeAttributeNode(j[0]);Bn(o,g,f),o[at]=s,o[dt]=f}catch(A){$t(s,s.return,A)}}var Ps=!1,Sn=!1,Um=!1,T_=typeof WeakSet=="function"?WeakSet:Set,Ln=null;function sA(s,o){if(s=s.containerInfo,up=ad,s=Hb(s),Mf(s)){if("selectionStart"in s)var f={start:s.selectionStart,end:s.selectionEnd};else e:{f=(f=s.ownerDocument)&&f.defaultView||window;var g=f.getSelection&&f.getSelection();if(g&&g.rangeCount!==0){f=g.anchorNode;var j=g.anchorOffset,A=g.focusNode;g=g.focusOffset;try{f.nodeType,A.nodeType}catch{f=null;break e}var G=0,te=-1,oe=-1,pe=0,Te=0,Oe=s,be=null;t:for(;;){for(var je;Oe!==f||j!==0&&Oe.nodeType!==3||(te=G+j),Oe!==A||g!==0&&Oe.nodeType!==3||(oe=G+g),Oe.nodeType===3&&(G+=Oe.nodeValue.length),(je=Oe.firstChild)!==null;)be=Oe,Oe=je;for(;;){if(Oe===s)break t;if(be===f&&++pe===j&&(te=G),be===A&&++Te===g&&(oe=G),(je=Oe.nextSibling)!==null)break;Oe=be,be=Oe.parentNode}Oe=je}f=te===-1||oe===-1?null:{start:te,end:oe}}else f=null}f=f||{start:0,end:0}}else f=null;for(dp={focusedElem:s,selectionRange:f},ad=!1,Ln=o;Ln!==null;)if(o=Ln,s=o.child,(o.subtreeFlags&1028)!==0&&s!==null)s.return=o,Ln=s;else for(;Ln!==null;){switch(o=Ln,A=o.alternate,s=o.flags,o.tag){case 0:if((s&4)!==0&&(s=o.updateQueue,s=s!==null?s.events:null,s!==null))for(f=0;f<s.length;f++)j=s[f],j.ref.impl=j.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&A!==null){s=void 0,f=o,j=A.memoizedProps,A=A.memoizedState,g=f.stateNode;try{var nt=ca(f.type,j);s=g.getSnapshotBeforeUpdate(nt,A),g.__reactInternalSnapshotBeforeUpdate=s}catch(ft){$t(f,f.return,ft)}}break;case 3:if((s&1024)!==0){if(s=o.stateNode.containerInfo,f=s.nodeType,f===9)mp(s);else if(f===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":mp(s);break;default:s.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((s&1024)!==0)throw Error(r(163))}if(s=o.sibling,s!==null){s.return=o.return,Ln=s;break}Ln=o.return}}function A_(s,o,f){var g=f.flags;switch(f.tag){case 0:case 11:case 15:$s(s,f),g&4&&Il(5,f);break;case 1:if($s(s,f),g&4)if(s=f.stateNode,o===null)try{s.componentDidMount()}catch(G){$t(f,f.return,G)}else{var j=ca(f.type,o.memoizedProps);o=o.memoizedState;try{s.componentDidUpdate(j,o,s.__reactInternalSnapshotBeforeUpdate)}catch(G){$t(f,f.return,G)}}g&64&&C_(f),g&512&&Ml(f,f.return);break;case 3:if($s(s,f),g&64&&(s=f.updateQueue,s!==null)){if(o=null,f.child!==null)switch(f.child.tag){case 27:case 5:o=f.child.stateNode;break;case 1:o=f.child.stateNode}try{mv(s,o)}catch(G){$t(f,f.return,G)}}break;case 27:o===null&&g&4&&N_(f);case 26:case 5:$s(s,f),o===null&&g&4&&j_(f),g&512&&Ml(f,f.return);break;case 12:$s(s,f);break;case 31:$s(s,f),g&4&&R_(s,f);break;case 13:$s(s,f),g&4&&O_(s,f),g&64&&(s=f.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(f=fA.bind(null,f),RA(s,f))));break;case 22:if(g=f.memoizedState!==null||Ps,!g){o=o!==null&&o.memoizedState!==null||Sn,j=Ps;var A=Sn;Ps=g,(Sn=o)&&!A?zs(s,f,(f.subtreeFlags&8772)!==0):$s(s,f),Ps=j,Sn=A}break;case 30:break;default:$s(s,f)}}function L_(s){var o=s.alternate;o!==null&&(s.alternate=null,L_(o)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(o=s.stateNode,o!==null&&bf(o)),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}var an=null,tr=!1;function Bs(s,o,f){for(f=f.child;f!==null;)D_(s,o,f),f=f.sibling}function D_(s,o,f){if(ot&&typeof ot.onCommitFiberUnmount=="function")try{ot.onCommitFiberUnmount(et,f)}catch{}switch(f.tag){case 26:Sn||cs(f,o),Bs(s,o,f),f.memoizedState?f.memoizedState.count--:f.stateNode&&(f=f.stateNode,f.parentNode.removeChild(f));break;case 27:Sn||cs(f,o);var g=an,j=tr;wi(f.type)&&(an=f.stateNode,tr=!1),Bs(s,o,f),Wl(f.stateNode),an=g,tr=j;break;case 5:Sn||cs(f,o);case 6:if(g=an,j=tr,an=null,Bs(s,o,f),an=g,tr=j,an!==null)if(tr)try{(an.nodeType===9?an.body:an.nodeName==="HTML"?an.ownerDocument.body:an).removeChild(f.stateNode)}catch(A){$t(f,o,A)}else try{an.removeChild(f.stateNode)}catch(A){$t(f,o,A)}break;case 18:an!==null&&(tr?(s=an,C0(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,f.stateNode),Co(s)):C0(an,f.stateNode));break;case 4:g=an,j=tr,an=f.stateNode.containerInfo,tr=!0,Bs(s,o,f),an=g,tr=j;break;case 0:case 11:case 14:case 15:gi(2,f,o),Sn||gi(4,f,o),Bs(s,o,f);break;case 1:Sn||(cs(f,o),g=f.stateNode,typeof g.componentWillUnmount=="function"&&k_(f,o,g)),Bs(s,o,f);break;case 21:Bs(s,o,f);break;case 22:Sn=(g=Sn)||f.memoizedState!==null,Bs(s,o,f),Sn=g;break;default:Bs(s,o,f)}}function R_(s,o){if(o.memoizedState===null&&(s=o.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{Co(s)}catch(f){$t(o,o.return,f)}}}function O_(s,o){if(o.memoizedState===null&&(s=o.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{Co(s)}catch(f){$t(o,o.return,f)}}function iA(s){switch(s.tag){case 31:case 13:case 19:var o=s.stateNode;return o===null&&(o=s.stateNode=new T_),o;case 22:return s=s.stateNode,o=s._retryCache,o===null&&(o=s._retryCache=new T_),o;default:throw Error(r(435,s.tag))}}function zu(s,o){var f=iA(s);o.forEach(function(g){if(!f.has(g)){f.add(g);var j=mA.bind(null,s,g);g.then(j,j)}})}function nr(s,o){var f=o.deletions;if(f!==null)for(var g=0;g<f.length;g++){var j=f[g],A=s,G=o,te=G;e:for(;te!==null;){switch(te.tag){case 27:if(wi(te.type)){an=te.stateNode,tr=!1;break e}break;case 5:an=te.stateNode,tr=!1;break e;case 3:case 4:an=te.stateNode.containerInfo,tr=!0;break e}te=te.return}if(an===null)throw Error(r(160));D_(A,G,j),an=null,tr=!1,A=j.alternate,A!==null&&(A.return=null),j.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)I_(o,s),o=o.sibling}var qr=null;function I_(s,o){var f=s.alternate,g=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:nr(o,s),rr(s),g&4&&(gi(3,s,s.return),Il(3,s),gi(5,s,s.return));break;case 1:nr(o,s),rr(s),g&512&&(Sn||f===null||cs(f,f.return)),g&64&&Ps&&(s=s.updateQueue,s!==null&&(g=s.callbacks,g!==null&&(f=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=f===null?g:f.concat(g))));break;case 26:var j=qr;if(nr(o,s),rr(s),g&512&&(Sn||f===null||cs(f,f.return)),g&4){var A=f!==null?f.memoizedState:null;if(g=s.memoizedState,f===null)if(g===null)if(s.stateNode===null){e:{g=s.type,f=s.memoizedProps,j=j.ownerDocument||j;t:switch(g){case"title":A=j.getElementsByTagName("title")[0],(!A||A[cl]||A[at]||A.namespaceURI==="http://www.w3.org/2000/svg"||A.hasAttribute("itemprop"))&&(A=j.createElement(g),j.head.insertBefore(A,j.querySelector("head > title"))),Bn(A,g,f),A[at]=s,An(A),g=A;break e;case"link":var G=I0("link","href",j).get(g+(f.href||""));if(G){for(var te=0;te<G.length;te++)if(A=G[te],A.getAttribute("href")===(f.href==null||f.href===""?null:f.href)&&A.getAttribute("rel")===(f.rel==null?null:f.rel)&&A.getAttribute("title")===(f.title==null?null:f.title)&&A.getAttribute("crossorigin")===(f.crossOrigin==null?null:f.crossOrigin)){G.splice(te,1);break t}}A=j.createElement(g),Bn(A,g,f),j.head.appendChild(A);break;case"meta":if(G=I0("meta","content",j).get(g+(f.content||""))){for(te=0;te<G.length;te++)if(A=G[te],A.getAttribute("content")===(f.content==null?null:""+f.content)&&A.getAttribute("name")===(f.name==null?null:f.name)&&A.getAttribute("property")===(f.property==null?null:f.property)&&A.getAttribute("http-equiv")===(f.httpEquiv==null?null:f.httpEquiv)&&A.getAttribute("charset")===(f.charSet==null?null:f.charSet)){G.splice(te,1);break t}}A=j.createElement(g),Bn(A,g,f),j.head.appendChild(A);break;default:throw Error(r(468,g))}A[at]=s,An(A),g=A}s.stateNode=g}else M0(j,s.type,s.stateNode);else s.stateNode=O0(j,g,s.memoizedProps);else A!==g?(A===null?f.stateNode!==null&&(f=f.stateNode,f.parentNode.removeChild(f)):A.count--,g===null?M0(j,s.type,s.stateNode):O0(j,g,s.memoizedProps)):g===null&&s.stateNode!==null&&zm(s,s.memoizedProps,f.memoizedProps)}break;case 27:nr(o,s),rr(s),g&512&&(Sn||f===null||cs(f,f.return)),f!==null&&g&4&&zm(s,s.memoizedProps,f.memoizedProps);break;case 5:if(nr(o,s),rr(s),g&512&&(Sn||f===null||cs(f,f.return)),s.flags&32){j=s.stateNode;try{Ga(j,"")}catch(nt){$t(s,s.return,nt)}}g&4&&s.stateNode!=null&&(j=s.memoizedProps,zm(s,j,f!==null?f.memoizedProps:j)),g&1024&&(Um=!0);break;case 6:if(nr(o,s),rr(s),g&4){if(s.stateNode===null)throw Error(r(162));g=s.memoizedProps,f=s.stateNode;try{f.nodeValue=g}catch(nt){$t(s,s.return,nt)}}break;case 3:if(nd=null,j=qr,qr=ed(o.containerInfo),nr(o,s),qr=j,rr(s),g&4&&f!==null&&f.memoizedState.isDehydrated)try{Co(o.containerInfo)}catch(nt){$t(s,s.return,nt)}Um&&(Um=!1,M_(s));break;case 4:g=qr,qr=ed(s.stateNode.containerInfo),nr(o,s),rr(s),qr=g;break;case 12:nr(o,s),rr(s);break;case 31:nr(o,s),rr(s),g&4&&(g=s.updateQueue,g!==null&&(s.updateQueue=null,zu(s,g)));break;case 13:nr(o,s),rr(s),s.child.flags&8192&&s.memoizedState!==null!=(f!==null&&f.memoizedState!==null)&&(Fu=Fe()),g&4&&(g=s.updateQueue,g!==null&&(s.updateQueue=null,zu(s,g)));break;case 22:j=s.memoizedState!==null;var oe=f!==null&&f.memoizedState!==null,pe=Ps,Te=Sn;if(Ps=pe||j,Sn=Te||oe,nr(o,s),Sn=Te,Ps=pe,rr(s),g&8192)e:for(o=s.stateNode,o._visibility=j?o._visibility&-2:o._visibility|1,j&&(f===null||oe||Ps||Sn||ua(s)),f=null,o=s;;){if(o.tag===5||o.tag===26){if(f===null){oe=f=o;try{if(A=oe.stateNode,j)G=A.style,typeof G.setProperty=="function"?G.setProperty("display","none","important"):G.display="none";else{te=oe.stateNode;var Oe=oe.memoizedProps.style,be=Oe!=null&&Oe.hasOwnProperty("display")?Oe.display:null;te.style.display=be==null||typeof be=="boolean"?"":(""+be).trim()}}catch(nt){$t(oe,oe.return,nt)}}}else if(o.tag===6){if(f===null){oe=o;try{oe.stateNode.nodeValue=j?"":oe.memoizedProps}catch(nt){$t(oe,oe.return,nt)}}}else if(o.tag===18){if(f===null){oe=o;try{var je=oe.stateNode;j?k0(je,!0):k0(oe.stateNode,!1)}catch(nt){$t(oe,oe.return,nt)}}}else if((o.tag!==22&&o.tag!==23||o.memoizedState===null||o===s)&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break e;for(;o.sibling===null;){if(o.return===null||o.return===s)break e;f===o&&(f=null),o=o.return}f===o&&(f=null),o.sibling.return=o.return,o=o.sibling}g&4&&(g=s.updateQueue,g!==null&&(f=g.retryQueue,f!==null&&(g.retryQueue=null,zu(s,f))));break;case 19:nr(o,s),rr(s),g&4&&(g=s.updateQueue,g!==null&&(s.updateQueue=null,zu(s,g)));break;case 30:break;case 21:break;default:nr(o,s),rr(s)}}function rr(s){var o=s.flags;if(o&2){try{for(var f,g=s.return;g!==null;){if(E_(g)){f=g;break}g=g.return}if(f==null)throw Error(r(160));switch(f.tag){case 27:var j=f.stateNode,A=Hm(s);$u(s,A,j);break;case 5:var G=f.stateNode;f.flags&32&&(Ga(G,""),f.flags&=-33);var te=Hm(s);$u(s,te,G);break;case 3:case 4:var oe=f.stateNode.containerInfo,pe=Hm(s);Fm(s,pe,oe);break;default:throw Error(r(161))}}catch(Te){$t(s,s.return,Te)}s.flags&=-3}o&4096&&(s.flags&=-4097)}function M_(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var o=s;M_(o),o.tag===5&&o.flags&1024&&o.stateNode.reset(),s=s.sibling}}function $s(s,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)A_(s,o.alternate,o),o=o.sibling}function ua(s){for(s=s.child;s!==null;){var o=s;switch(o.tag){case 0:case 11:case 14:case 15:gi(4,o,o.return),ua(o);break;case 1:cs(o,o.return);var f=o.stateNode;typeof f.componentWillUnmount=="function"&&k_(o,o.return,f),ua(o);break;case 27:Wl(o.stateNode);case 26:case 5:cs(o,o.return),ua(o);break;case 22:o.memoizedState===null&&ua(o);break;case 30:ua(o);break;default:ua(o)}s=s.sibling}}function zs(s,o,f){for(f=f&&(o.subtreeFlags&8772)!==0,o=o.child;o!==null;){var g=o.alternate,j=s,A=o,G=A.flags;switch(A.tag){case 0:case 11:case 15:zs(j,A,f),Il(4,A);break;case 1:if(zs(j,A,f),g=A,j=g.stateNode,typeof j.componentDidMount=="function")try{j.componentDidMount()}catch(pe){$t(g,g.return,pe)}if(g=A,j=g.updateQueue,j!==null){var te=g.stateNode;try{var oe=j.shared.hiddenCallbacks;if(oe!==null)for(j.shared.hiddenCallbacks=null,j=0;j<oe.length;j++)fv(oe[j],te)}catch(pe){$t(g,g.return,pe)}}f&&G&64&&C_(A),Ml(A,A.return);break;case 27:N_(A);case 26:case 5:zs(j,A,f),f&&g===null&&G&4&&j_(A),Ml(A,A.return);break;case 12:zs(j,A,f);break;case 31:zs(j,A,f),f&&G&4&&R_(j,A);break;case 13:zs(j,A,f),f&&G&4&&O_(j,A);break;case 22:A.memoizedState===null&&zs(j,A,f),Ml(A,A.return);break;case 30:break;default:zs(j,A,f)}o=o.sibling}}function Vm(s,o){var f=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(f=s.memoizedState.cachePool.pool),s=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(s=o.memoizedState.cachePool.pool),s!==f&&(s!=null&&s.refCount++,f!=null&&Sl(f))}function Wm(s,o){s=null,o.alternate!==null&&(s=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==s&&(o.refCount++,s!=null&&Sl(s))}function Kr(s,o,f,g){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)P_(s,o,f,g),o=o.sibling}function P_(s,o,f,g){var j=o.flags;switch(o.tag){case 0:case 11:case 15:Kr(s,o,f,g),j&2048&&Il(9,o);break;case 1:Kr(s,o,f,g);break;case 3:Kr(s,o,f,g),j&2048&&(s=null,o.alternate!==null&&(s=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==s&&(o.refCount++,s!=null&&Sl(s)));break;case 12:if(j&2048){Kr(s,o,f,g),s=o.stateNode;try{var A=o.memoizedProps,G=A.id,te=A.onPostCommit;typeof te=="function"&&te(G,o.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(oe){$t(o,o.return,oe)}}else Kr(s,o,f,g);break;case 31:Kr(s,o,f,g);break;case 13:Kr(s,o,f,g);break;case 23:break;case 22:A=o.stateNode,G=o.alternate,o.memoizedState!==null?A._visibility&2?Kr(s,o,f,g):Pl(s,o):A._visibility&2?Kr(s,o,f,g):(A._visibility|=2,fo(s,o,f,g,(o.subtreeFlags&10256)!==0||!1)),j&2048&&Vm(G,o);break;case 24:Kr(s,o,f,g),j&2048&&Wm(o.alternate,o);break;default:Kr(s,o,f,g)}}function fo(s,o,f,g,j){for(j=j&&((o.subtreeFlags&10256)!==0||!1),o=o.child;o!==null;){var A=s,G=o,te=f,oe=g,pe=G.flags;switch(G.tag){case 0:case 11:case 15:fo(A,G,te,oe,j),Il(8,G);break;case 23:break;case 22:var Te=G.stateNode;G.memoizedState!==null?Te._visibility&2?fo(A,G,te,oe,j):Pl(A,G):(Te._visibility|=2,fo(A,G,te,oe,j)),j&&pe&2048&&Vm(G.alternate,G);break;case 24:fo(A,G,te,oe,j),j&&pe&2048&&Wm(G.alternate,G);break;default:fo(A,G,te,oe,j)}o=o.sibling}}function Pl(s,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var f=s,g=o,j=g.flags;switch(g.tag){case 22:Pl(f,g),j&2048&&Vm(g.alternate,g);break;case 24:Pl(f,g),j&2048&&Wm(g.alternate,g);break;default:Pl(f,g)}o=o.sibling}}var Bl=8192;function mo(s,o,f){if(s.subtreeFlags&Bl)for(s=s.child;s!==null;)B_(s,o,f),s=s.sibling}function B_(s,o,f){switch(s.tag){case 26:mo(s,o,f),s.flags&Bl&&s.memoizedState!==null&&WA(f,qr,s.memoizedState,s.memoizedProps);break;case 5:mo(s,o,f);break;case 3:case 4:var g=qr;qr=ed(s.stateNode.containerInfo),mo(s,o,f),qr=g;break;case 22:s.memoizedState===null&&(g=s.alternate,g!==null&&g.memoizedState!==null?(g=Bl,Bl=16777216,mo(s,o,f),Bl=g):mo(s,o,f));break;default:mo(s,o,f)}}function $_(s){var o=s.alternate;if(o!==null&&(s=o.child,s!==null)){o.child=null;do o=s.sibling,s.sibling=null,s=o;while(s!==null)}}function $l(s){var o=s.deletions;if((s.flags&16)!==0){if(o!==null)for(var f=0;f<o.length;f++){var g=o[f];Ln=g,H_(g,s)}$_(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)z_(s),s=s.sibling}function z_(s){switch(s.tag){case 0:case 11:case 15:$l(s),s.flags&2048&&gi(9,s,s.return);break;case 3:$l(s);break;case 12:$l(s);break;case 22:var o=s.stateNode;s.memoizedState!==null&&o._visibility&2&&(s.return===null||s.return.tag!==13)?(o._visibility&=-3,Hu(s)):$l(s);break;default:$l(s)}}function Hu(s){var o=s.deletions;if((s.flags&16)!==0){if(o!==null)for(var f=0;f<o.length;f++){var g=o[f];Ln=g,H_(g,s)}$_(s)}for(s=s.child;s!==null;){switch(o=s,o.tag){case 0:case 11:case 15:gi(8,o,o.return),Hu(o);break;case 22:f=o.stateNode,f._visibility&2&&(f._visibility&=-3,Hu(o));break;default:Hu(o)}s=s.sibling}}function H_(s,o){for(;Ln!==null;){var f=Ln;switch(f.tag){case 0:case 11:case 15:gi(8,f,o);break;case 23:case 22:if(f.memoizedState!==null&&f.memoizedState.cachePool!==null){var g=f.memoizedState.cachePool.pool;g!=null&&g.refCount++}break;case 24:Sl(f.memoizedState.cache)}if(g=f.child,g!==null)g.return=f,Ln=g;else e:for(f=s;Ln!==null;){g=Ln;var j=g.sibling,A=g.return;if(L_(g),g===f){Ln=null;break e}if(j!==null){j.return=A,Ln=j;break e}Ln=A}}}var aA={getCacheForType:function(s){var o=Mn(bn),f=o.data.get(s);return f===void 0&&(f=s(),o.data.set(s,f)),f},cacheSignal:function(){return Mn(bn).controller.signal}},oA=typeof WeakMap=="function"?WeakMap:Map,Mt=0,Gt=null,wt=null,Et=0,Bt=0,yr=null,xi=!1,po=!1,Gm=!1,Hs=0,dn=0,yi=0,da=0,qm=0,br=0,go=0,zl=null,sr=null,Km=!1,Fu=0,F_=0,Uu=1/0,Vu=null,bi=null,jn=0,vi=null,xo=null,Fs=0,Ym=0,Xm=null,U_=null,Hl=0,Qm=null;function vr(){return(Mt&2)!==0&&Et!==0?Et&-Et:V.T!==null?rp():Be()}function V_(){if(br===0)if((Et&536870912)===0||At){var s=rn;rn<<=1,(rn&3932160)===0&&(rn=262144),br=s}else br=536870912;return s=gr.current,s!==null&&(s.flags|=32),br}function ir(s,o,f){(s===Gt&&(Bt===2||Bt===9)||s.cancelPendingCommit!==null)&&(yo(s,0),_i(s,Et,br,!1)),hn(s,f),((Mt&2)===0||s!==Gt)&&(s===Gt&&((Mt&2)===0&&(da|=f),dn===4&&_i(s,Et,br,!1)),us(s))}function W_(s,o,f){if((Mt&6)!==0)throw Error(r(327));var g=!f&&(o&127)===0&&(o&s.expiredLanes)===0||We(s,o),j=g?uA(s,o):Zm(s,o,!0),A=g;do{if(j===0){po&&!g&&_i(s,o,0,!1);break}else{if(f=s.current.alternate,A&&!lA(f)){j=Zm(s,o,!1),A=!1;continue}if(j===2){if(A=o,s.errorRecoveryDisabledLanes&A)var G=0;else G=s.pendingLanes&-536870913,G=G!==0?G:G&536870912?536870912:0;if(G!==0){o=G;e:{var te=s;j=zl;var oe=te.current.memoizedState.isDehydrated;if(oe&&(yo(te,G).flags|=256),G=Zm(te,G,!1),G!==2){if(Gm&&!oe){te.errorRecoveryDisabledLanes|=A,da|=A,j=4;break e}A=sr,sr=j,A!==null&&(sr===null?sr=A:sr.push.apply(sr,A))}j=G}if(A=!1,j!==2)continue}}if(j===1){yo(s,0),_i(s,o,0,!0);break}e:{switch(g=s,A=j,A){case 0:case 1:throw Error(r(345));case 4:if((o&4194048)!==o)break;case 6:_i(g,o,br,!xi);break e;case 2:sr=null;break;case 3:case 5:break;default:throw Error(r(329))}if((o&62914560)===o&&(j=Fu+300-Fe(),10<j)){if(_i(g,o,br,!xi),Ye(g,0,!0)!==0)break e;Fs=o,g.timeoutHandle=S0(G_.bind(null,g,f,sr,Vu,Km,o,br,da,go,xi,A,"Throttled",-0,0),j);break e}G_(g,f,sr,Vu,Km,o,br,da,go,xi,A,null,-0,0)}}break}while(!0);us(s)}function G_(s,o,f,g,j,A,G,te,oe,pe,Te,Oe,be,je){if(s.timeoutHandle=-1,Oe=o.subtreeFlags,Oe&8192||(Oe&16785408)===16785408){Oe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Es},B_(o,A,Oe);var nt=(A&62914560)===A?Fu-Fe():(A&4194048)===A?F_-Fe():0;if(nt=GA(Oe,nt),nt!==null){Fs=A,s.cancelPendingCommit=nt(e0.bind(null,s,o,A,f,g,j,G,te,oe,Te,Oe,null,be,je)),_i(s,A,G,!pe);return}}e0(s,o,A,f,g,j,G,te,oe)}function lA(s){for(var o=s;;){var f=o.tag;if((f===0||f===11||f===15)&&o.flags&16384&&(f=o.updateQueue,f!==null&&(f=f.stores,f!==null)))for(var g=0;g<f.length;g++){var j=f[g],A=j.getSnapshot;j=j.value;try{if(!mr(A(),j))return!1}catch{return!1}}if(f=o.child,o.subtreeFlags&16384&&f!==null)f.return=o,o=f;else{if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function _i(s,o,f,g){o&=~qm,o&=~da,s.suspendedLanes|=o,s.pingedLanes&=~o,g&&(s.warmLanes|=o),g=s.expirationTimes;for(var j=o;0<j;){var A=31-$e(j),G=1<<A;g[A]=-1,j&=~G}f!==0&&Kn(s,f,o)}function Wu(){return(Mt&6)===0?(Fl(0),!1):!0}function Jm(){if(wt!==null){if(Bt===0)var s=wt.return;else s=wt,Ls=na=null,mm(s),oo=null,Cl=0,s=wt;for(;s!==null;)w_(s.alternate,s),s=s.return;wt=null}}function yo(s,o){var f=s.timeoutHandle;f!==-1&&(s.timeoutHandle=-1,NA(f)),f=s.cancelPendingCommit,f!==null&&(s.cancelPendingCommit=null,f()),Fs=0,Jm(),Gt=s,wt=f=Ts(s.current,null),Et=o,Bt=0,yr=null,xi=!1,po=We(s,o),Gm=!1,go=br=qm=da=yi=dn=0,sr=zl=null,Km=!1,(o&8)!==0&&(o|=o&32);var g=s.entangledLanes;if(g!==0)for(s=s.entanglements,g&=o;0<g;){var j=31-$e(g),A=1<<j;o|=s[j],g&=~A}return Hs=o,hu(),f}function q_(s,o){_t=null,V.H=Dl,o===ao||o===vu?(o=cv(),Bt=3):o===nm?(o=cv(),Bt=4):Bt=o===Am?8:o!==null&&typeof o=="object"&&typeof o.then=="function"?6:1,yr=o,wt===null&&(dn=1,Ou(s,Lr(o,s.current)))}function K_(){var s=gr.current;return s===null?!0:(Et&4194048)===Et?Ir===null:(Et&62914560)===Et||(Et&536870912)!==0?s===Ir:!1}function Y_(){var s=V.H;return V.H=Dl,s===null?Dl:s}function X_(){var s=V.A;return V.A=aA,s}function Gu(){dn=4,xi||(Et&4194048)!==Et&&gr.current!==null||(po=!0),(yi&134217727)===0&&(da&134217727)===0||Gt===null||_i(Gt,Et,br,!1)}function Zm(s,o,f){var g=Mt;Mt|=2;var j=Y_(),A=X_();(Gt!==s||Et!==o)&&(Vu=null,yo(s,o)),o=!1;var G=dn;e:do try{if(Bt!==0&&wt!==null){var te=wt,oe=yr;switch(Bt){case 8:Jm(),G=6;break e;case 3:case 2:case 9:case 6:gr.current===null&&(o=!0);var pe=Bt;if(Bt=0,yr=null,bo(s,te,oe,pe),f&&po){G=0;break e}break;default:pe=Bt,Bt=0,yr=null,bo(s,te,oe,pe)}}cA(),G=dn;break}catch(Te){q_(s,Te)}while(!0);return o&&s.shellSuspendCounter++,Ls=na=null,Mt=g,V.H=j,V.A=A,wt===null&&(Gt=null,Et=0,hu()),G}function cA(){for(;wt!==null;)Q_(wt)}function uA(s,o){var f=Mt;Mt|=2;var g=Y_(),j=X_();Gt!==s||Et!==o?(Vu=null,Uu=Fe()+500,yo(s,o)):po=We(s,o);e:do try{if(Bt!==0&&wt!==null){o=wt;var A=yr;t:switch(Bt){case 1:Bt=0,yr=null,bo(s,o,A,1);break;case 2:case 9:if(ov(A)){Bt=0,yr=null,J_(o);break}o=function(){Bt!==2&&Bt!==9||Gt!==s||(Bt=7),us(s)},A.then(o,o);break e;case 3:Bt=7;break e;case 4:Bt=5;break e;case 7:ov(A)?(Bt=0,yr=null,J_(o)):(Bt=0,yr=null,bo(s,o,A,7));break;case 5:var G=null;switch(wt.tag){case 26:G=wt.memoizedState;case 5:case 27:var te=wt;if(G?P0(G):te.stateNode.complete){Bt=0,yr=null;var oe=te.sibling;if(oe!==null)wt=oe;else{var pe=te.return;pe!==null?(wt=pe,qu(pe)):wt=null}break t}}Bt=0,yr=null,bo(s,o,A,5);break;case 6:Bt=0,yr=null,bo(s,o,A,6);break;case 8:Jm(),dn=6;break e;default:throw Error(r(462))}}dA();break}catch(Te){q_(s,Te)}while(!0);return Ls=na=null,V.H=g,V.A=j,Mt=f,wt!==null?0:(Gt=null,Et=0,hu(),dn)}function dA(){for(;wt!==null&&!it();)Q_(wt)}function Q_(s){var o=__(s.alternate,s,Hs);s.memoizedProps=s.pendingProps,o===null?qu(s):wt=o}function J_(s){var o=s,f=o.alternate;switch(o.tag){case 15:case 0:o=p_(f,o,o.pendingProps,o.type,void 0,Et);break;case 11:o=p_(f,o,o.pendingProps,o.type.render,o.ref,Et);break;case 5:mm(o);default:w_(f,o),o=wt=Xb(o,Hs),o=__(f,o,Hs)}s.memoizedProps=s.pendingProps,o===null?qu(s):wt=o}function bo(s,o,f,g){Ls=na=null,mm(o),oo=null,Cl=0;var j=o.return;try{if(ZT(s,j,o,f,Et)){dn=1,Ou(s,Lr(f,s.current)),wt=null;return}}catch(A){if(j!==null)throw wt=j,A;dn=1,Ou(s,Lr(f,s.current)),wt=null;return}o.flags&32768?(At||g===1?s=!0:po||(Et&536870912)!==0?s=!1:(xi=s=!0,(g===2||g===9||g===3||g===6)&&(g=gr.current,g!==null&&g.tag===13&&(g.flags|=16384))),Z_(o,s)):qu(o)}function qu(s){var o=s;do{if((o.flags&32768)!==0){Z_(o,xi);return}s=o.return;var f=nA(o.alternate,o,Hs);if(f!==null){wt=f;return}if(o=o.sibling,o!==null){wt=o;return}wt=o=s}while(o!==null);dn===0&&(dn=5)}function Z_(s,o){do{var f=rA(s.alternate,s);if(f!==null){f.flags&=32767,wt=f;return}if(f=s.return,f!==null&&(f.flags|=32768,f.subtreeFlags=0,f.deletions=null),!o&&(s=s.sibling,s!==null)){wt=s;return}wt=s=f}while(s!==null);dn=6,wt=null}function e0(s,o,f,g,j,A,G,te,oe){s.cancelPendingCommit=null;do Ku();while(jn!==0);if((Mt&6)!==0)throw Error(r(327));if(o!==null){if(o===s.current)throw Error(r(177));if(A=o.lanes|o.childLanes,A|=Hf,fn(s,f,A,G,te,oe),s===Gt&&(wt=Gt=null,Et=0),xo=o,vi=s,Fs=f,Ym=A,Xm=j,U_=g,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,pA(se,function(){return i0(),null})):(s.callbackNode=null,s.callbackPriority=0),g=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||g){g=V.T,V.T=null,j=Z.p,Z.p=2,G=Mt,Mt|=4;try{sA(s,o,f)}finally{Mt=G,Z.p=j,V.T=g}}jn=1,t0(),n0(),r0()}}function t0(){if(jn===1){jn=0;var s=vi,o=xo,f=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||f){f=V.T,V.T=null;var g=Z.p;Z.p=2;var j=Mt;Mt|=4;try{I_(o,s);var A=dp,G=Hb(s.containerInfo),te=A.focusedElem,oe=A.selectionRange;if(G!==te&&te&&te.ownerDocument&&zb(te.ownerDocument.documentElement,te)){if(oe!==null&&Mf(te)){var pe=oe.start,Te=oe.end;if(Te===void 0&&(Te=pe),"selectionStart"in te)te.selectionStart=pe,te.selectionEnd=Math.min(Te,te.value.length);else{var Oe=te.ownerDocument||document,be=Oe&&Oe.defaultView||window;if(be.getSelection){var je=be.getSelection(),nt=te.textContent.length,ft=Math.min(oe.start,nt),Ft=oe.end===void 0?ft:Math.min(oe.end,nt);!je.extend&&ft>Ft&&(G=Ft,Ft=ft,ft=G);var de=$b(te,ft),le=$b(te,Ft);if(de&&le&&(je.rangeCount!==1||je.anchorNode!==de.node||je.anchorOffset!==de.offset||je.focusNode!==le.node||je.focusOffset!==le.offset)){var me=Oe.createRange();me.setStart(de.node,de.offset),je.removeAllRanges(),ft>Ft?(je.addRange(me),je.extend(le.node,le.offset)):(me.setEnd(le.node,le.offset),je.addRange(me))}}}}for(Oe=[],je=te;je=je.parentNode;)je.nodeType===1&&Oe.push({element:je,left:je.scrollLeft,top:je.scrollTop});for(typeof te.focus=="function"&&te.focus(),te=0;te<Oe.length;te++){var De=Oe[te];De.element.scrollLeft=De.left,De.element.scrollTop=De.top}}ad=!!up,dp=up=null}finally{Mt=j,Z.p=g,V.T=f}}s.current=o,jn=2}}function n0(){if(jn===2){jn=0;var s=vi,o=xo,f=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||f){f=V.T,V.T=null;var g=Z.p;Z.p=2;var j=Mt;Mt|=4;try{A_(s,o.alternate,o)}finally{Mt=j,Z.p=g,V.T=f}}jn=3}}function r0(){if(jn===4||jn===3){jn=0,ge();var s=vi,o=xo,f=Fs,g=U_;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?jn=5:(jn=0,xo=vi=null,s0(s,s.pendingLanes));var j=s.pendingLanes;if(j===0&&(bi=null),we(f),o=o.stateNode,ot&&typeof ot.onCommitFiberRoot=="function")try{ot.onCommitFiberRoot(et,o,void 0,(o.current.flags&128)===128)}catch{}if(g!==null){o=V.T,j=Z.p,Z.p=2,V.T=null;try{for(var A=s.onRecoverableError,G=0;G<g.length;G++){var te=g[G];A(te.value,{componentStack:te.stack})}}finally{V.T=o,Z.p=j}}(Fs&3)!==0&&Ku(),us(s),j=s.pendingLanes,(f&261930)!==0&&(j&42)!==0?s===Qm?Hl++:(Hl=0,Qm=s):Hl=0,Fl(0)}}function s0(s,o){(s.pooledCacheLanes&=o)===0&&(o=s.pooledCache,o!=null&&(s.pooledCache=null,Sl(o)))}function Ku(){return t0(),n0(),r0(),i0()}function i0(){if(jn!==5)return!1;var s=vi,o=Ym;Ym=0;var f=we(Fs),g=V.T,j=Z.p;try{Z.p=32>f?32:f,V.T=null,f=Xm,Xm=null;var A=vi,G=Fs;if(jn=0,xo=vi=null,Fs=0,(Mt&6)!==0)throw Error(r(331));var te=Mt;if(Mt|=4,z_(A.current),P_(A,A.current,G,f),Mt=te,Fl(0,!1),ot&&typeof ot.onPostCommitFiberRoot=="function")try{ot.onPostCommitFiberRoot(et,A)}catch{}return!0}finally{Z.p=j,V.T=g,s0(s,o)}}function a0(s,o,f){o=Lr(f,o),o=Tm(s.stateNode,o,2),s=fi(s,o,2),s!==null&&(hn(s,2),us(s))}function $t(s,o,f){if(s.tag===3)a0(s,s,f);else for(;o!==null;){if(o.tag===3){a0(o,s,f);break}else if(o.tag===1){var g=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(bi===null||!bi.has(g))){s=Lr(f,s),f=o_(2),g=fi(o,f,2),g!==null&&(l_(f,g,o,s),hn(g,2),us(g));break}}o=o.return}}function ep(s,o,f){var g=s.pingCache;if(g===null){g=s.pingCache=new oA;var j=new Set;g.set(o,j)}else j=g.get(o),j===void 0&&(j=new Set,g.set(o,j));j.has(f)||(Gm=!0,j.add(f),s=hA.bind(null,s,o,f),o.then(s,s))}function hA(s,o,f){var g=s.pingCache;g!==null&&g.delete(o),s.pingedLanes|=s.suspendedLanes&f,s.warmLanes&=~f,Gt===s&&(Et&f)===f&&(dn===4||dn===3&&(Et&62914560)===Et&&300>Fe()-Fu?(Mt&2)===0&&yo(s,0):qm|=f,go===Et&&(go=0)),us(s)}function o0(s,o){o===0&&(o=tt()),s=Zi(s,o),s!==null&&(hn(s,o),us(s))}function fA(s){var o=s.memoizedState,f=0;o!==null&&(f=o.retryLane),o0(s,f)}function mA(s,o){var f=0;switch(s.tag){case 31:case 13:var g=s.stateNode,j=s.memoizedState;j!==null&&(f=j.retryLane);break;case 19:g=s.stateNode;break;case 22:g=s.stateNode._retryCache;break;default:throw Error(r(314))}g!==null&&g.delete(o),o0(s,f)}function pA(s,o){return Se(s,o)}var Yu=null,vo=null,tp=!1,Xu=!1,np=!1,Si=0;function us(s){s!==vo&&s.next===null&&(vo===null?Yu=vo=s:vo=vo.next=s),Xu=!0,tp||(tp=!0,xA())}function Fl(s,o){if(!np&&Xu){np=!0;do for(var f=!1,g=Yu;g!==null;){if(s!==0){var j=g.pendingLanes;if(j===0)var A=0;else{var G=g.suspendedLanes,te=g.pingedLanes;A=(1<<31-$e(42|s)+1)-1,A&=j&~(G&~te),A=A&201326741?A&201326741|1:A?A|2:0}A!==0&&(f=!0,d0(g,A))}else A=Et,A=Ye(g,g===Gt?A:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(A&3)===0||We(g,A)||(f=!0,d0(g,A));g=g.next}while(f);np=!1}}function gA(){l0()}function l0(){Xu=tp=!1;var s=0;Si!==0&&EA()&&(s=Si);for(var o=Fe(),f=null,g=Yu;g!==null;){var j=g.next,A=c0(g,o);A===0?(g.next=null,f===null?Yu=j:f.next=j,j===null&&(vo=f)):(f=g,(s!==0||(A&3)!==0)&&(Xu=!0)),g=j}jn!==0&&jn!==5||Fl(s),Si!==0&&(Si=0)}function c0(s,o){for(var f=s.suspendedLanes,g=s.pingedLanes,j=s.expirationTimes,A=s.pendingLanes&-62914561;0<A;){var G=31-$e(A),te=1<<G,oe=j[G];oe===-1?((te&f)===0||(te&g)!==0)&&(j[G]=ze(te,o)):oe<=o&&(s.expiredLanes|=te),A&=~te}if(o=Gt,f=Et,f=Ye(s,s===o?f:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),g=s.callbackNode,f===0||s===o&&(Bt===2||Bt===9)||s.cancelPendingCommit!==null)return g!==null&&g!==null&&Ie(g),s.callbackNode=null,s.callbackPriority=0;if((f&3)===0||We(s,f)){if(o=f&-f,o===s.callbackPriority)return o;switch(g!==null&&Ie(g),we(f)){case 2:case 8:f=xe;break;case 32:f=se;break;case 268435456:f=Pe;break;default:f=se}return g=u0.bind(null,s),f=Se(f,g),s.callbackPriority=o,s.callbackNode=f,o}return g!==null&&g!==null&&Ie(g),s.callbackPriority=2,s.callbackNode=null,2}function u0(s,o){if(jn!==0&&jn!==5)return s.callbackNode=null,s.callbackPriority=0,null;var f=s.callbackNode;if(Ku()&&s.callbackNode!==f)return null;var g=Et;return g=Ye(s,s===Gt?g:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),g===0?null:(W_(s,g,o),c0(s,Fe()),s.callbackNode!=null&&s.callbackNode===f?u0.bind(null,s):null)}function d0(s,o){if(Ku())return null;W_(s,o,!0)}function xA(){TA(function(){(Mt&6)!==0?Se(ie,gA):l0()})}function rp(){if(Si===0){var s=so;s===0&&(s=Xt,Xt<<=1,(Xt&261888)===0&&(Xt=256)),Si=s}return Si}function h0(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:su(""+s)}function f0(s,o){var f=o.ownerDocument.createElement("input");return f.name=o.name,f.value=o.value,s.id&&f.setAttribute("form",s.id),o.parentNode.insertBefore(f,o),s=new FormData(s),f.parentNode.removeChild(f),s}function yA(s,o,f,g,j){if(o==="submit"&&f&&f.stateNode===j){var A=h0((j[dt]||null).action),G=g.submitter;G&&(o=(o=G[dt]||null)?h0(o.formAction):G.getAttribute("formAction"),o!==null&&(A=o,G=null));var te=new lu("action","action",null,g,j);s.push({event:te,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(Si!==0){var oe=G?f0(j,G):new FormData(j);wm(f,{pending:!0,data:oe,method:j.method,action:A},null,oe)}}else typeof A=="function"&&(te.preventDefault(),oe=G?f0(j,G):new FormData(j),wm(f,{pending:!0,data:oe,method:j.method,action:A},A,oe))},currentTarget:j}]})}}for(var sp=0;sp<zf.length;sp++){var ip=zf[sp],bA=ip.toLowerCase(),vA=ip[0].toUpperCase()+ip.slice(1);Gr(bA,"on"+vA)}Gr(Vb,"onAnimationEnd"),Gr(Wb,"onAnimationIteration"),Gr(Gb,"onAnimationStart"),Gr("dblclick","onDoubleClick"),Gr("focusin","onFocus"),Gr("focusout","onBlur"),Gr(MT,"onTransitionRun"),Gr(PT,"onTransitionStart"),Gr(BT,"onTransitionCancel"),Gr(qb,"onTransitionEnd"),Va("onMouseEnter",["mouseout","mouseover"]),Va("onMouseLeave",["mouseout","mouseover"]),Va("onPointerEnter",["pointerout","pointerover"]),Va("onPointerLeave",["pointerout","pointerover"]),Yi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Yi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Yi("onBeforeInput",["compositionend","keypress","textInput","paste"]),Yi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Yi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Yi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ul="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),_A=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ul));function m0(s,o){o=(o&4)!==0;for(var f=0;f<s.length;f++){var g=s[f],j=g.event;g=g.listeners;e:{var A=void 0;if(o)for(var G=g.length-1;0<=G;G--){var te=g[G],oe=te.instance,pe=te.currentTarget;if(te=te.listener,oe!==A&&j.isPropagationStopped())break e;A=te,j.currentTarget=pe;try{A(j)}catch(Te){du(Te)}j.currentTarget=null,A=oe}else for(G=0;G<g.length;G++){if(te=g[G],oe=te.instance,pe=te.currentTarget,te=te.listener,oe!==A&&j.isPropagationStopped())break e;A=te,j.currentTarget=pe;try{A(j)}catch(Te){du(Te)}j.currentTarget=null,A=oe}}}}function Ct(s,o){var f=o[kn];f===void 0&&(f=o[kn]=new Set);var g=s+"__bubble";f.has(g)||(p0(o,s,2,!1),f.add(g))}function ap(s,o,f){var g=0;o&&(g|=4),p0(f,s,g,o)}var Qu="_reactListening"+Math.random().toString(36).slice(2);function op(s){if(!s[Qu]){s[Qu]=!0,lb.forEach(function(f){f!=="selectionchange"&&(_A.has(f)||ap(f,!1,s),ap(f,!0,s))});var o=s.nodeType===9?s:s.ownerDocument;o===null||o[Qu]||(o[Qu]=!0,ap("selectionchange",!1,o))}}function p0(s,o,f,g){switch(V0(o)){case 2:var j=YA;break;case 8:j=XA;break;default:j=Sp}f=j.bind(null,o,f,s),j=void 0,!Ef||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(j=!0),g?j!==void 0?s.addEventListener(o,f,{capture:!0,passive:j}):s.addEventListener(o,f,!0):j!==void 0?s.addEventListener(o,f,{passive:j}):s.addEventListener(o,f,!1)}function lp(s,o,f,g,j){var A=g;if((o&1)===0&&(o&2)===0&&g!==null)e:for(;;){if(g===null)return;var G=g.tag;if(G===3||G===4){var te=g.stateNode.containerInfo;if(te===j)break;if(G===4)for(G=g.return;G!==null;){var oe=G.tag;if((oe===3||oe===4)&&G.stateNode.containerInfo===j)return;G=G.return}for(;te!==null;){if(G=Ha(te),G===null)return;if(oe=G.tag,oe===5||oe===6||oe===26||oe===27){g=A=G;continue e}te=te.parentNode}}g=g.return}vb(function(){var pe=A,Te=kf(f),Oe=[];e:{var be=Kb.get(s);if(be!==void 0){var je=lu,nt=s;switch(s){case"keypress":if(au(f)===0)break e;case"keydown":case"keyup":je=mT;break;case"focusin":nt="focus",je=Lf;break;case"focusout":nt="blur",je=Lf;break;case"beforeblur":case"afterblur":je=Lf;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=wb;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=nT;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=xT;break;case Vb:case Wb:case Gb:je=iT;break;case qb:je=bT;break;case"scroll":case"scrollend":je=eT;break;case"wheel":je=_T;break;case"copy":case"cut":case"paste":je=oT;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=kb;break;case"toggle":case"beforetoggle":je=wT}var ft=(o&4)!==0,Ft=!ft&&(s==="scroll"||s==="scrollend"),de=ft?be!==null?be+"Capture":null:be;ft=[];for(var le=pe,me;le!==null;){var De=le;if(me=De.stateNode,De=De.tag,De!==5&&De!==26&&De!==27||me===null||de===null||(De=dl(le,de),De!=null&&ft.push(Vl(le,De,me))),Ft)break;le=le.return}0<ft.length&&(be=new je(be,nt,null,f,Te),Oe.push({event:be,listeners:ft}))}}if((o&7)===0){e:{if(be=s==="mouseover"||s==="pointerover",je=s==="mouseout"||s==="pointerout",be&&f!==Cf&&(nt=f.relatedTarget||f.fromElement)&&(Ha(nt)||nt[sn]))break e;if((je||be)&&(be=Te.window===Te?Te:(be=Te.ownerDocument)?be.defaultView||be.parentWindow:window,je?(nt=f.relatedTarget||f.toElement,je=pe,nt=nt?Ha(nt):null,nt!==null&&(Ft=l(nt),ft=nt.tag,nt!==Ft||ft!==5&&ft!==27&&ft!==6)&&(nt=null)):(je=null,nt=pe),je!==nt)){if(ft=wb,De="onMouseLeave",de="onMouseEnter",le="mouse",(s==="pointerout"||s==="pointerover")&&(ft=kb,De="onPointerLeave",de="onPointerEnter",le="pointer"),Ft=je==null?be:ul(je),me=nt==null?be:ul(nt),be=new ft(De,le+"leave",je,f,Te),be.target=Ft,be.relatedTarget=me,De=null,Ha(Te)===pe&&(ft=new ft(de,le+"enter",nt,f,Te),ft.target=me,ft.relatedTarget=Ft,De=ft),Ft=De,je&&nt)t:{for(ft=SA,de=je,le=nt,me=0,De=de;De;De=ft(De))me++;De=0;for(var lt=le;lt;lt=ft(lt))De++;for(;0<me-De;)de=ft(de),me--;for(;0<De-me;)le=ft(le),De--;for(;me--;){if(de===le||le!==null&&de===le.alternate){ft=de;break t}de=ft(de),le=ft(le)}ft=null}else ft=null;je!==null&&g0(Oe,be,je,ft,!1),nt!==null&&Ft!==null&&g0(Oe,Ft,nt,ft,!0)}}e:{if(be=pe?ul(pe):window,je=be.nodeName&&be.nodeName.toLowerCase(),je==="select"||je==="input"&&be.type==="file")var Rt=Rb;else if(Lb(be))if(Ob)Rt=RT;else{Rt=LT;var st=AT}else je=be.nodeName,!je||je.toLowerCase()!=="input"||be.type!=="checkbox"&&be.type!=="radio"?pe&&wf(pe.elementType)&&(Rt=Rb):Rt=DT;if(Rt&&(Rt=Rt(s,pe))){Db(Oe,Rt,f,Te);break e}st&&st(s,be,pe),s==="focusout"&&pe&&be.type==="number"&&pe.memoizedProps.value!=null&&Sf(be,"number",be.value)}switch(st=pe?ul(pe):window,s){case"focusin":(Lb(st)||st.contentEditable==="true")&&(Xa=st,Pf=pe,bl=null);break;case"focusout":bl=Pf=Xa=null;break;case"mousedown":Bf=!0;break;case"contextmenu":case"mouseup":case"dragend":Bf=!1,Fb(Oe,f,Te);break;case"selectionchange":if(IT)break;case"keydown":case"keyup":Fb(Oe,f,Te)}var St;if(Rf)e:{switch(s){case"compositionstart":var Nt="onCompositionStart";break e;case"compositionend":Nt="onCompositionEnd";break e;case"compositionupdate":Nt="onCompositionUpdate";break e}Nt=void 0}else Ya?Tb(s,f)&&(Nt="onCompositionEnd"):s==="keydown"&&f.keyCode===229&&(Nt="onCompositionStart");Nt&&(jb&&f.locale!=="ko"&&(Ya||Nt!=="onCompositionStart"?Nt==="onCompositionEnd"&&Ya&&(St=_b()):(ai=Te,Nf="value"in ai?ai.value:ai.textContent,Ya=!0)),st=Ju(pe,Nt),0<st.length&&(Nt=new Cb(Nt,s,null,f,Te),Oe.push({event:Nt,listeners:st}),St?Nt.data=St:(St=Ab(f),St!==null&&(Nt.data=St)))),(St=kT?jT(s,f):ET(s,f))&&(Nt=Ju(pe,"onBeforeInput"),0<Nt.length&&(st=new Cb("onBeforeInput","beforeinput",null,f,Te),Oe.push({event:st,listeners:Nt}),st.data=St)),yA(Oe,s,pe,f,Te)}m0(Oe,o)})}function Vl(s,o,f){return{instance:s,listener:o,currentTarget:f}}function Ju(s,o){for(var f=o+"Capture",g=[];s!==null;){var j=s,A=j.stateNode;if(j=j.tag,j!==5&&j!==26&&j!==27||A===null||(j=dl(s,f),j!=null&&g.unshift(Vl(s,j,A)),j=dl(s,o),j!=null&&g.push(Vl(s,j,A))),s.tag===3)return g;s=s.return}return[]}function SA(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function g0(s,o,f,g,j){for(var A=o._reactName,G=[];f!==null&&f!==g;){var te=f,oe=te.alternate,pe=te.stateNode;if(te=te.tag,oe!==null&&oe===g)break;te!==5&&te!==26&&te!==27||pe===null||(oe=pe,j?(pe=dl(f,A),pe!=null&&G.unshift(Vl(f,pe,oe))):j||(pe=dl(f,A),pe!=null&&G.push(Vl(f,pe,oe)))),f=f.return}G.length!==0&&s.push({event:o,listeners:G})}var wA=/\r\n?/g,CA=/\u0000|\uFFFD/g;function x0(s){return(typeof s=="string"?s:""+s).replace(wA,`
|
|
50
|
+
`).replace(CA,"")}function y0(s,o){return o=x0(o),x0(s)===o}function Ht(s,o,f,g,j,A){switch(f){case"children":typeof g=="string"?o==="body"||o==="textarea"&&g===""||Ga(s,g):(typeof g=="number"||typeof g=="bigint")&&o!=="body"&&Ga(s,""+g);break;case"className":nu(s,"class",g);break;case"tabIndex":nu(s,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":nu(s,f,g);break;case"style":yb(s,g,A);break;case"data":if(o!=="object"){nu(s,"data",g);break}case"src":case"href":if(g===""&&(o!=="a"||f!=="href")){s.removeAttribute(f);break}if(g==null||typeof g=="function"||typeof g=="symbol"||typeof g=="boolean"){s.removeAttribute(f);break}g=su(""+g),s.setAttribute(f,g);break;case"action":case"formAction":if(typeof g=="function"){s.setAttribute(f,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof A=="function"&&(f==="formAction"?(o!=="input"&&Ht(s,o,"name",j.name,j,null),Ht(s,o,"formEncType",j.formEncType,j,null),Ht(s,o,"formMethod",j.formMethod,j,null),Ht(s,o,"formTarget",j.formTarget,j,null)):(Ht(s,o,"encType",j.encType,j,null),Ht(s,o,"method",j.method,j,null),Ht(s,o,"target",j.target,j,null)));if(g==null||typeof g=="symbol"||typeof g=="boolean"){s.removeAttribute(f);break}g=su(""+g),s.setAttribute(f,g);break;case"onClick":g!=null&&(s.onclick=Es);break;case"onScroll":g!=null&&Ct("scroll",s);break;case"onScrollEnd":g!=null&&Ct("scrollend",s);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(r(61));if(f=g.__html,f!=null){if(j.children!=null)throw Error(r(60));s.innerHTML=f}}break;case"multiple":s.multiple=g&&typeof g!="function"&&typeof g!="symbol";break;case"muted":s.muted=g&&typeof g!="function"&&typeof g!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(g==null||typeof g=="function"||typeof g=="boolean"||typeof g=="symbol"){s.removeAttribute("xlink:href");break}f=su(""+g),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":g!=null&&typeof g!="function"&&typeof g!="symbol"?s.setAttribute(f,""+g):s.removeAttribute(f);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":g&&typeof g!="function"&&typeof g!="symbol"?s.setAttribute(f,""):s.removeAttribute(f);break;case"capture":case"download":g===!0?s.setAttribute(f,""):g!==!1&&g!=null&&typeof g!="function"&&typeof g!="symbol"?s.setAttribute(f,g):s.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":g!=null&&typeof g!="function"&&typeof g!="symbol"&&!isNaN(g)&&1<=g?s.setAttribute(f,g):s.removeAttribute(f);break;case"rowSpan":case"start":g==null||typeof g=="function"||typeof g=="symbol"||isNaN(g)?s.removeAttribute(f):s.setAttribute(f,g);break;case"popover":Ct("beforetoggle",s),Ct("toggle",s),tu(s,"popover",g);break;case"xlinkActuate":js(s,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":js(s,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":js(s,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":js(s,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":js(s,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":js(s,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":js(s,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":js(s,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":js(s,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":tu(s,"is",g);break;case"innerText":case"textContent":break;default:(!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(f=JN.get(f)||f,tu(s,f,g))}}function cp(s,o,f,g,j,A){switch(f){case"style":yb(s,g,A);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(r(61));if(f=g.__html,f!=null){if(j.children!=null)throw Error(r(60));s.innerHTML=f}}break;case"children":typeof g=="string"?Ga(s,g):(typeof g=="number"||typeof g=="bigint")&&Ga(s,""+g);break;case"onScroll":g!=null&&Ct("scroll",s);break;case"onScrollEnd":g!=null&&Ct("scrollend",s);break;case"onClick":g!=null&&(s.onclick=Es);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!cb.hasOwnProperty(f))e:{if(f[0]==="o"&&f[1]==="n"&&(j=f.endsWith("Capture"),o=f.slice(2,j?f.length-7:void 0),A=s[dt]||null,A=A!=null?A[f]:null,typeof A=="function"&&s.removeEventListener(o,A,j),typeof g=="function")){typeof A!="function"&&A!==null&&(f in s?s[f]=null:s.hasAttribute(f)&&s.removeAttribute(f)),s.addEventListener(o,g,j);break e}f in s?s[f]=g:g===!0?s.setAttribute(f,""):tu(s,f,g)}}}function Bn(s,o,f){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ct("error",s),Ct("load",s);var g=!1,j=!1,A;for(A in f)if(f.hasOwnProperty(A)){var G=f[A];if(G!=null)switch(A){case"src":g=!0;break;case"srcSet":j=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:Ht(s,o,A,G,f,null)}}j&&Ht(s,o,"srcSet",f.srcSet,f,null),g&&Ht(s,o,"src",f.src,f,null);return;case"input":Ct("invalid",s);var te=A=G=j=null,oe=null,pe=null;for(g in f)if(f.hasOwnProperty(g)){var Te=f[g];if(Te!=null)switch(g){case"name":j=Te;break;case"type":G=Te;break;case"checked":oe=Te;break;case"defaultChecked":pe=Te;break;case"value":A=Te;break;case"defaultValue":te=Te;break;case"children":case"dangerouslySetInnerHTML":if(Te!=null)throw Error(r(137,o));break;default:Ht(s,o,g,Te,f,null)}}mb(s,A,te,oe,pe,G,j,!1);return;case"select":Ct("invalid",s),g=G=A=null;for(j in f)if(f.hasOwnProperty(j)&&(te=f[j],te!=null))switch(j){case"value":A=te;break;case"defaultValue":G=te;break;case"multiple":g=te;default:Ht(s,o,j,te,f,null)}o=A,f=G,s.multiple=!!g,o!=null?Wa(s,!!g,o,!1):f!=null&&Wa(s,!!g,f,!0);return;case"textarea":Ct("invalid",s),A=j=g=null;for(G in f)if(f.hasOwnProperty(G)&&(te=f[G],te!=null))switch(G){case"value":g=te;break;case"defaultValue":j=te;break;case"children":A=te;break;case"dangerouslySetInnerHTML":if(te!=null)throw Error(r(91));break;default:Ht(s,o,G,te,f,null)}gb(s,g,j,A);return;case"option":for(oe in f)if(f.hasOwnProperty(oe)&&(g=f[oe],g!=null))switch(oe){case"selected":s.selected=g&&typeof g!="function"&&typeof g!="symbol";break;default:Ht(s,o,oe,g,f,null)}return;case"dialog":Ct("beforetoggle",s),Ct("toggle",s),Ct("cancel",s),Ct("close",s);break;case"iframe":case"object":Ct("load",s);break;case"video":case"audio":for(g=0;g<Ul.length;g++)Ct(Ul[g],s);break;case"image":Ct("error",s),Ct("load",s);break;case"details":Ct("toggle",s);break;case"embed":case"source":case"link":Ct("error",s),Ct("load",s);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(pe in f)if(f.hasOwnProperty(pe)&&(g=f[pe],g!=null))switch(pe){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:Ht(s,o,pe,g,f,null)}return;default:if(wf(o)){for(Te in f)f.hasOwnProperty(Te)&&(g=f[Te],g!==void 0&&cp(s,o,Te,g,f,void 0));return}}for(te in f)f.hasOwnProperty(te)&&(g=f[te],g!=null&&Ht(s,o,te,g,f,null))}function kA(s,o,f,g){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var j=null,A=null,G=null,te=null,oe=null,pe=null,Te=null;for(je in f){var Oe=f[je];if(f.hasOwnProperty(je)&&Oe!=null)switch(je){case"checked":break;case"value":break;case"defaultValue":oe=Oe;default:g.hasOwnProperty(je)||Ht(s,o,je,null,g,Oe)}}for(var be in g){var je=g[be];if(Oe=f[be],g.hasOwnProperty(be)&&(je!=null||Oe!=null))switch(be){case"type":A=je;break;case"name":j=je;break;case"checked":pe=je;break;case"defaultChecked":Te=je;break;case"value":G=je;break;case"defaultValue":te=je;break;case"children":case"dangerouslySetInnerHTML":if(je!=null)throw Error(r(137,o));break;default:je!==Oe&&Ht(s,o,be,je,g,Oe)}}_f(s,G,te,oe,pe,Te,A,j);return;case"select":je=G=te=be=null;for(A in f)if(oe=f[A],f.hasOwnProperty(A)&&oe!=null)switch(A){case"value":break;case"multiple":je=oe;default:g.hasOwnProperty(A)||Ht(s,o,A,null,g,oe)}for(j in g)if(A=g[j],oe=f[j],g.hasOwnProperty(j)&&(A!=null||oe!=null))switch(j){case"value":be=A;break;case"defaultValue":te=A;break;case"multiple":G=A;default:A!==oe&&Ht(s,o,j,A,g,oe)}o=te,f=G,g=je,be!=null?Wa(s,!!f,be,!1):!!g!=!!f&&(o!=null?Wa(s,!!f,o,!0):Wa(s,!!f,f?[]:"",!1));return;case"textarea":je=be=null;for(te in f)if(j=f[te],f.hasOwnProperty(te)&&j!=null&&!g.hasOwnProperty(te))switch(te){case"value":break;case"children":break;default:Ht(s,o,te,null,g,j)}for(G in g)if(j=g[G],A=f[G],g.hasOwnProperty(G)&&(j!=null||A!=null))switch(G){case"value":be=j;break;case"defaultValue":je=j;break;case"children":break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(r(91));break;default:j!==A&&Ht(s,o,G,j,g,A)}pb(s,be,je);return;case"option":for(var nt in f)if(be=f[nt],f.hasOwnProperty(nt)&&be!=null&&!g.hasOwnProperty(nt))switch(nt){case"selected":s.selected=!1;break;default:Ht(s,o,nt,null,g,be)}for(oe in g)if(be=g[oe],je=f[oe],g.hasOwnProperty(oe)&&be!==je&&(be!=null||je!=null))switch(oe){case"selected":s.selected=be&&typeof be!="function"&&typeof be!="symbol";break;default:Ht(s,o,oe,be,g,je)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var ft in f)be=f[ft],f.hasOwnProperty(ft)&&be!=null&&!g.hasOwnProperty(ft)&&Ht(s,o,ft,null,g,be);for(pe in g)if(be=g[pe],je=f[pe],g.hasOwnProperty(pe)&&be!==je&&(be!=null||je!=null))switch(pe){case"children":case"dangerouslySetInnerHTML":if(be!=null)throw Error(r(137,o));break;default:Ht(s,o,pe,be,g,je)}return;default:if(wf(o)){for(var Ft in f)be=f[Ft],f.hasOwnProperty(Ft)&&be!==void 0&&!g.hasOwnProperty(Ft)&&cp(s,o,Ft,void 0,g,be);for(Te in g)be=g[Te],je=f[Te],!g.hasOwnProperty(Te)||be===je||be===void 0&&je===void 0||cp(s,o,Te,be,g,je);return}}for(var de in f)be=f[de],f.hasOwnProperty(de)&&be!=null&&!g.hasOwnProperty(de)&&Ht(s,o,de,null,g,be);for(Oe in g)be=g[Oe],je=f[Oe],!g.hasOwnProperty(Oe)||be===je||be==null&&je==null||Ht(s,o,Oe,be,g,je)}function b0(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function jA(){if(typeof performance.getEntriesByType=="function"){for(var s=0,o=0,f=performance.getEntriesByType("resource"),g=0;g<f.length;g++){var j=f[g],A=j.transferSize,G=j.initiatorType,te=j.duration;if(A&&te&&b0(G)){for(G=0,te=j.responseEnd,g+=1;g<f.length;g++){var oe=f[g],pe=oe.startTime;if(pe>te)break;var Te=oe.transferSize,Oe=oe.initiatorType;Te&&b0(Oe)&&(oe=oe.responseEnd,G+=Te*(oe<te?1:(te-pe)/(oe-pe)))}if(--g,o+=8*(A+G)/(j.duration/1e3),s++,10<s)break}}if(0<s)return o/s/1e6}return navigator.connection&&(s=navigator.connection.downlink,typeof s=="number")?s:5}var up=null,dp=null;function Zu(s){return s.nodeType===9?s:s.ownerDocument}function v0(s){switch(s){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function _0(s,o){if(s===0)switch(o){case"svg":return 1;case"math":return 2;default:return 0}return s===1&&o==="foreignObject"?0:s}function hp(s,o){return s==="textarea"||s==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.children=="bigint"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var fp=null;function EA(){var s=window.event;return s&&s.type==="popstate"?s===fp?!1:(fp=s,!0):(fp=null,!1)}var S0=typeof setTimeout=="function"?setTimeout:void 0,NA=typeof clearTimeout=="function"?clearTimeout:void 0,w0=typeof Promise=="function"?Promise:void 0,TA=typeof queueMicrotask=="function"?queueMicrotask:typeof w0<"u"?function(s){return w0.resolve(null).then(s).catch(AA)}:S0;function AA(s){setTimeout(function(){throw s})}function wi(s){return s==="head"}function C0(s,o){var f=o,g=0;do{var j=f.nextSibling;if(s.removeChild(f),j&&j.nodeType===8)if(f=j.data,f==="/$"||f==="/&"){if(g===0){s.removeChild(j),Co(o);return}g--}else if(f==="$"||f==="$?"||f==="$~"||f==="$!"||f==="&")g++;else if(f==="html")Wl(s.ownerDocument.documentElement);else if(f==="head"){f=s.ownerDocument.head,Wl(f);for(var A=f.firstChild;A;){var G=A.nextSibling,te=A.nodeName;A[cl]||te==="SCRIPT"||te==="STYLE"||te==="LINK"&&A.rel.toLowerCase()==="stylesheet"||f.removeChild(A),A=G}}else f==="body"&&Wl(s.ownerDocument.body);f=j}while(f);Co(o)}function k0(s,o){var f=s;s=0;do{var g=f.nextSibling;if(f.nodeType===1?o?(f._stashedDisplay=f.style.display,f.style.display="none"):(f.style.display=f._stashedDisplay||"",f.getAttribute("style")===""&&f.removeAttribute("style")):f.nodeType===3&&(o?(f._stashedText=f.nodeValue,f.nodeValue=""):f.nodeValue=f._stashedText||""),g&&g.nodeType===8)if(f=g.data,f==="/$"){if(s===0)break;s--}else f!=="$"&&f!=="$?"&&f!=="$~"&&f!=="$!"||s++;f=g}while(f)}function mp(s){var o=s.firstChild;for(o&&o.nodeType===10&&(o=o.nextSibling);o;){var f=o;switch(o=o.nextSibling,f.nodeName){case"HTML":case"HEAD":case"BODY":mp(f),bf(f);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(f.rel.toLowerCase()==="stylesheet")continue}s.removeChild(f)}}function LA(s,o,f,g){for(;s.nodeType===1;){var j=f;if(s.nodeName.toLowerCase()!==o.toLowerCase()){if(!g&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(g){if(!s[cl])switch(o){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(A=s.getAttribute("rel"),A==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(A!==j.rel||s.getAttribute("href")!==(j.href==null||j.href===""?null:j.href)||s.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin)||s.getAttribute("title")!==(j.title==null?null:j.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(A=s.getAttribute("src"),(A!==(j.src==null?null:j.src)||s.getAttribute("type")!==(j.type==null?null:j.type)||s.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin))&&A&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(o==="input"&&s.type==="hidden"){var A=j.name==null?null:""+j.name;if(j.type==="hidden"&&s.getAttribute("name")===A)return s}else return s;if(s=Mr(s.nextSibling),s===null)break}return null}function DA(s,o,f){if(o==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!f||(s=Mr(s.nextSibling),s===null))return null;return s}function j0(s,o){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!o||(s=Mr(s.nextSibling),s===null))return null;return s}function pp(s){return s.data==="$?"||s.data==="$~"}function gp(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function RA(s,o){var f=s.ownerDocument;if(s.data==="$~")s._reactRetry=o;else if(s.data!=="$?"||f.readyState!=="loading")o();else{var g=function(){o(),f.removeEventListener("DOMContentLoaded",g)};f.addEventListener("DOMContentLoaded",g),s._reactRetry=g}}function Mr(s){for(;s!=null;s=s.nextSibling){var o=s.nodeType;if(o===1||o===3)break;if(o===8){if(o=s.data,o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"||o==="F!"||o==="F")break;if(o==="/$"||o==="/&")return null}}return s}var xp=null;function E0(s){s=s.nextSibling;for(var o=0;s;){if(s.nodeType===8){var f=s.data;if(f==="/$"||f==="/&"){if(o===0)return Mr(s.nextSibling);o--}else f!=="$"&&f!=="$!"&&f!=="$?"&&f!=="$~"&&f!=="&"||o++}s=s.nextSibling}return null}function N0(s){s=s.previousSibling;for(var o=0;s;){if(s.nodeType===8){var f=s.data;if(f==="$"||f==="$!"||f==="$?"||f==="$~"||f==="&"){if(o===0)return s;o--}else f!=="/$"&&f!=="/&"||o++}s=s.previousSibling}return null}function T0(s,o,f){switch(o=Zu(f),s){case"html":if(s=o.documentElement,!s)throw Error(r(452));return s;case"head":if(s=o.head,!s)throw Error(r(453));return s;case"body":if(s=o.body,!s)throw Error(r(454));return s;default:throw Error(r(451))}}function Wl(s){for(var o=s.attributes;o.length;)s.removeAttributeNode(o[0]);bf(s)}var Pr=new Map,A0=new Set;function ed(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var Us=Z.d;Z.d={f:OA,r:IA,D:MA,C:PA,L:BA,m:$A,X:HA,S:zA,M:FA};function OA(){var s=Us.f(),o=Wu();return s||o}function IA(s){var o=Fa(s);o!==null&&o.tag===5&&o.type==="form"?qv(o):Us.r(s)}var _o=typeof document>"u"?null:document;function L0(s,o,f){var g=_o;if(g&&typeof o=="string"&&o){var j=Tr(o);j='link[rel="'+s+'"][href="'+j+'"]',typeof f=="string"&&(j+='[crossorigin="'+f+'"]'),A0.has(j)||(A0.add(j),s={rel:s,crossOrigin:f,href:o},g.querySelector(j)===null&&(o=g.createElement("link"),Bn(o,"link",s),An(o),g.head.appendChild(o)))}}function MA(s){Us.D(s),L0("dns-prefetch",s,null)}function PA(s,o){Us.C(s,o),L0("preconnect",s,o)}function BA(s,o,f){Us.L(s,o,f);var g=_o;if(g&&s&&o){var j='link[rel="preload"][as="'+Tr(o)+'"]';o==="image"&&f&&f.imageSrcSet?(j+='[imagesrcset="'+Tr(f.imageSrcSet)+'"]',typeof f.imageSizes=="string"&&(j+='[imagesizes="'+Tr(f.imageSizes)+'"]')):j+='[href="'+Tr(s)+'"]';var A=j;switch(o){case"style":A=So(s);break;case"script":A=wo(s)}Pr.has(A)||(s=m({rel:"preload",href:o==="image"&&f&&f.imageSrcSet?void 0:s,as:o},f),Pr.set(A,s),g.querySelector(j)!==null||o==="style"&&g.querySelector(Gl(A))||o==="script"&&g.querySelector(ql(A))||(o=g.createElement("link"),Bn(o,"link",s),An(o),g.head.appendChild(o)))}}function $A(s,o){Us.m(s,o);var f=_o;if(f&&s){var g=o&&typeof o.as=="string"?o.as:"script",j='link[rel="modulepreload"][as="'+Tr(g)+'"][href="'+Tr(s)+'"]',A=j;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":A=wo(s)}if(!Pr.has(A)&&(s=m({rel:"modulepreload",href:s},o),Pr.set(A,s),f.querySelector(j)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(f.querySelector(ql(A)))return}g=f.createElement("link"),Bn(g,"link",s),An(g),f.head.appendChild(g)}}}function zA(s,o,f){Us.S(s,o,f);var g=_o;if(g&&s){var j=Ua(g).hoistableStyles,A=So(s);o=o||"default";var G=j.get(A);if(!G){var te={loading:0,preload:null};if(G=g.querySelector(Gl(A)))te.loading=5;else{s=m({rel:"stylesheet",href:s,"data-precedence":o},f),(f=Pr.get(A))&&yp(s,f);var oe=G=g.createElement("link");An(oe),Bn(oe,"link",s),oe._p=new Promise(function(pe,Te){oe.onload=pe,oe.onerror=Te}),oe.addEventListener("load",function(){te.loading|=1}),oe.addEventListener("error",function(){te.loading|=2}),te.loading|=4,td(G,o,g)}G={type:"stylesheet",instance:G,count:1,state:te},j.set(A,G)}}}function HA(s,o){Us.X(s,o);var f=_o;if(f&&s){var g=Ua(f).hoistableScripts,j=wo(s),A=g.get(j);A||(A=f.querySelector(ql(j)),A||(s=m({src:s,async:!0},o),(o=Pr.get(j))&&bp(s,o),A=f.createElement("script"),An(A),Bn(A,"link",s),f.head.appendChild(A)),A={type:"script",instance:A,count:1,state:null},g.set(j,A))}}function FA(s,o){Us.M(s,o);var f=_o;if(f&&s){var g=Ua(f).hoistableScripts,j=wo(s),A=g.get(j);A||(A=f.querySelector(ql(j)),A||(s=m({src:s,async:!0,type:"module"},o),(o=Pr.get(j))&&bp(s,o),A=f.createElement("script"),An(A),Bn(A,"link",s),f.head.appendChild(A)),A={type:"script",instance:A,count:1,state:null},g.set(j,A))}}function D0(s,o,f,g){var j=(j=X.current)?ed(j):null;if(!j)throw Error(r(446));switch(s){case"meta":case"title":return null;case"style":return typeof f.precedence=="string"&&typeof f.href=="string"?(o=So(f.href),f=Ua(j).hoistableStyles,g=f.get(o),g||(g={type:"style",instance:null,count:0,state:null},f.set(o,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(f.rel==="stylesheet"&&typeof f.href=="string"&&typeof f.precedence=="string"){s=So(f.href);var A=Ua(j).hoistableStyles,G=A.get(s);if(G||(j=j.ownerDocument||j,G={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},A.set(s,G),(A=j.querySelector(Gl(s)))&&!A._p&&(G.instance=A,G.state.loading=5),Pr.has(s)||(f={rel:"preload",as:"style",href:f.href,crossOrigin:f.crossOrigin,integrity:f.integrity,media:f.media,hrefLang:f.hrefLang,referrerPolicy:f.referrerPolicy},Pr.set(s,f),A||UA(j,s,f,G.state))),o&&g===null)throw Error(r(528,""));return G}if(o&&g!==null)throw Error(r(529,""));return null;case"script":return o=f.async,f=f.src,typeof f=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=wo(f),f=Ua(j).hoistableScripts,g=f.get(o),g||(g={type:"script",instance:null,count:0,state:null},f.set(o,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,s))}}function So(s){return'href="'+Tr(s)+'"'}function Gl(s){return'link[rel="stylesheet"]['+s+"]"}function R0(s){return m({},s,{"data-precedence":s.precedence,precedence:null})}function UA(s,o,f,g){s.querySelector('link[rel="preload"][as="style"]['+o+"]")?g.loading=1:(o=s.createElement("link"),g.preload=o,o.addEventListener("load",function(){return g.loading|=1}),o.addEventListener("error",function(){return g.loading|=2}),Bn(o,"link",f),An(o),s.head.appendChild(o))}function wo(s){return'[src="'+Tr(s)+'"]'}function ql(s){return"script[async]"+s}function O0(s,o,f){if(o.count++,o.instance===null)switch(o.type){case"style":var g=s.querySelector('style[data-href~="'+Tr(f.href)+'"]');if(g)return o.instance=g,An(g),g;var j=m({},f,{"data-href":f.href,"data-precedence":f.precedence,href:null,precedence:null});return g=(s.ownerDocument||s).createElement("style"),An(g),Bn(g,"style",j),td(g,f.precedence,s),o.instance=g;case"stylesheet":j=So(f.href);var A=s.querySelector(Gl(j));if(A)return o.state.loading|=4,o.instance=A,An(A),A;g=R0(f),(j=Pr.get(j))&&yp(g,j),A=(s.ownerDocument||s).createElement("link"),An(A);var G=A;return G._p=new Promise(function(te,oe){G.onload=te,G.onerror=oe}),Bn(A,"link",g),o.state.loading|=4,td(A,f.precedence,s),o.instance=A;case"script":return A=wo(f.src),(j=s.querySelector(ql(A)))?(o.instance=j,An(j),j):(g=f,(j=Pr.get(A))&&(g=m({},f),bp(g,j)),s=s.ownerDocument||s,j=s.createElement("script"),An(j),Bn(j,"link",g),s.head.appendChild(j),o.instance=j);case"void":return null;default:throw Error(r(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(g=o.instance,o.state.loading|=4,td(g,f.precedence,s));return o.instance}function td(s,o,f){for(var g=f.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),j=g.length?g[g.length-1]:null,A=j,G=0;G<g.length;G++){var te=g[G];if(te.dataset.precedence===o)A=te;else if(A!==j)break}A?A.parentNode.insertBefore(s,A.nextSibling):(o=f.nodeType===9?f.head:f,o.insertBefore(s,o.firstChild))}function yp(s,o){s.crossOrigin==null&&(s.crossOrigin=o.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=o.referrerPolicy),s.title==null&&(s.title=o.title)}function bp(s,o){s.crossOrigin==null&&(s.crossOrigin=o.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=o.referrerPolicy),s.integrity==null&&(s.integrity=o.integrity)}var nd=null;function I0(s,o,f){if(nd===null){var g=new Map,j=nd=new Map;j.set(f,g)}else j=nd,g=j.get(f),g||(g=new Map,j.set(f,g));if(g.has(s))return g;for(g.set(s,null),f=f.getElementsByTagName(s),j=0;j<f.length;j++){var A=f[j];if(!(A[cl]||A[at]||s==="link"&&A.getAttribute("rel")==="stylesheet")&&A.namespaceURI!=="http://www.w3.org/2000/svg"){var G=A.getAttribute(o)||"";G=s+G;var te=g.get(G);te?te.push(A):g.set(G,[A])}}return g}function M0(s,o,f){s=s.ownerDocument||s,s.head.insertBefore(f,o==="title"?s.querySelector("head > title"):null)}function VA(s,o,f){if(f===1||o.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;switch(o.rel){case"stylesheet":return s=o.disabled,typeof o.precedence=="string"&&s==null;default:return!0}case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function P0(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function WA(s,o,f,g){if(f.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(f.state.loading&4)===0){if(f.instance===null){var j=So(g.href),A=o.querySelector(Gl(j));if(A){o=A._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(s.count++,s=rd.bind(s),o.then(s,s)),f.state.loading|=4,f.instance=A,An(A);return}A=o.ownerDocument||o,g=R0(g),(j=Pr.get(j))&&yp(g,j),A=A.createElement("link"),An(A);var G=A;G._p=new Promise(function(te,oe){G.onload=te,G.onerror=oe}),Bn(A,"link",g),f.instance=A}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(f,o),(o=f.state.preload)&&(f.state.loading&3)===0&&(s.count++,f=rd.bind(s),o.addEventListener("load",f),o.addEventListener("error",f))}}var vp=0;function GA(s,o){return s.stylesheets&&s.count===0&&id(s,s.stylesheets),0<s.count||0<s.imgCount?function(f){var g=setTimeout(function(){if(s.stylesheets&&id(s,s.stylesheets),s.unsuspend){var A=s.unsuspend;s.unsuspend=null,A()}},6e4+o);0<s.imgBytes&&vp===0&&(vp=62500*jA());var j=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&id(s,s.stylesheets),s.unsuspend)){var A=s.unsuspend;s.unsuspend=null,A()}},(s.imgBytes>vp?50:800)+o);return s.unsuspend=f,function(){s.unsuspend=null,clearTimeout(g),clearTimeout(j)}}:null}function rd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)id(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var sd=null;function id(s,o){s.stylesheets=null,s.unsuspend!==null&&(s.count++,sd=new Map,o.forEach(qA,s),sd=null,rd.call(s))}function qA(s,o){if(!(o.state.loading&4)){var f=sd.get(s);if(f)var g=f.get(null);else{f=new Map,sd.set(s,f);for(var j=s.querySelectorAll("link[data-precedence],style[data-precedence]"),A=0;A<j.length;A++){var G=j[A];(G.nodeName==="LINK"||G.getAttribute("media")!=="not all")&&(f.set(G.dataset.precedence,G),g=G)}g&&f.set(null,g)}j=o.instance,G=j.getAttribute("data-precedence"),A=f.get(G)||g,A===g&&f.set(null,j),f.set(G,j),this.count++,g=rd.bind(this),j.addEventListener("load",g),j.addEventListener("error",g),A?A.parentNode.insertBefore(j,A.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(j,s.firstChild)),o.state.loading|=4}}var Kl={$$typeof:b,Provider:null,Consumer:null,_currentValue:ee,_currentValue2:ee,_threadCount:0};function KA(s,o,f,g,j,A,G,te,oe){this.tag=1,this.containerInfo=s,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Lt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Lt(0),this.hiddenUpdates=Lt(null),this.identifierPrefix=g,this.onUncaughtError=j,this.onCaughtError=A,this.onRecoverableError=G,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=oe,this.incompleteTransitions=new Map}function B0(s,o,f,g,j,A,G,te,oe,pe,Te,Oe){return s=new KA(s,o,f,G,oe,pe,Te,Oe,te),o=1,A===!0&&(o|=24),A=pr(3,null,null,o),s.current=A,A.stateNode=s,o=Zf(),o.refCount++,s.pooledCache=o,o.refCount++,A.memoizedState={element:g,isDehydrated:f,cache:o},rm(A),s}function $0(s){return s?(s=Za,s):Za}function z0(s,o,f,g,j,A){j=$0(j),g.context===null?g.context=j:g.pendingContext=j,g=hi(o),g.payload={element:f},A=A===void 0?null:A,A!==null&&(g.callback=A),f=fi(s,g,o),f!==null&&(ir(f,s,o),jl(f,s,o))}function H0(s,o){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var f=s.retryLane;s.retryLane=f!==0&&f<o?f:o}}function _p(s,o){H0(s,o),(s=s.alternate)&&H0(s,o)}function F0(s){if(s.tag===13||s.tag===31){var o=Zi(s,67108864);o!==null&&ir(o,s,67108864),_p(s,67108864)}}function U0(s){if(s.tag===13||s.tag===31){var o=vr();o=fe(o);var f=Zi(s,o);f!==null&&ir(f,s,o),_p(s,o)}}var ad=!0;function YA(s,o,f,g){var j=V.T;V.T=null;var A=Z.p;try{Z.p=2,Sp(s,o,f,g)}finally{Z.p=A,V.T=j}}function XA(s,o,f,g){var j=V.T;V.T=null;var A=Z.p;try{Z.p=8,Sp(s,o,f,g)}finally{Z.p=A,V.T=j}}function Sp(s,o,f,g){if(ad){var j=wp(g);if(j===null)lp(s,o,g,od,f),W0(s,g);else if(JA(j,s,o,f,g))g.stopPropagation();else if(W0(s,g),o&4&&-1<QA.indexOf(s)){for(;j!==null;){var A=Fa(j);if(A!==null)switch(A.tag){case 3:if(A=A.stateNode,A.current.memoizedState.isDehydrated){var G=ye(A.pendingLanes);if(G!==0){var te=A;for(te.pendingLanes|=2,te.entangledLanes|=2;G;){var oe=1<<31-$e(G);te.entanglements[1]|=oe,G&=~oe}us(A),(Mt&6)===0&&(Uu=Fe()+500,Fl(0))}}break;case 31:case 13:te=Zi(A,2),te!==null&&ir(te,A,2),Wu(),_p(A,2)}if(A=wp(g),A===null&&lp(s,o,g,od,f),A===j)break;j=A}j!==null&&g.stopPropagation()}else lp(s,o,g,null,f)}}function wp(s){return s=kf(s),Cp(s)}var od=null;function Cp(s){if(od=null,s=Ha(s),s!==null){var o=l(s);if(o===null)s=null;else{var f=o.tag;if(f===13){if(s=u(o),s!==null)return s;s=null}else if(f===31){if(s=c(o),s!==null)return s;s=null}else if(f===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;s=null}else o!==s&&(s=null)}}return od=s,null}function V0(s){switch(s){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(He()){case ie:return 2;case xe:return 8;case se:case he:return 32;case Pe:return 268435456;default:return 32}default:return 32}}var kp=!1,Ci=null,ki=null,ji=null,Yl=new Map,Xl=new Map,Ei=[],QA="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function W0(s,o){switch(s){case"focusin":case"focusout":Ci=null;break;case"dragenter":case"dragleave":ki=null;break;case"mouseover":case"mouseout":ji=null;break;case"pointerover":case"pointerout":Yl.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":Xl.delete(o.pointerId)}}function Ql(s,o,f,g,j,A){return s===null||s.nativeEvent!==A?(s={blockedOn:o,domEventName:f,eventSystemFlags:g,nativeEvent:A,targetContainers:[j]},o!==null&&(o=Fa(o),o!==null&&F0(o)),s):(s.eventSystemFlags|=g,o=s.targetContainers,j!==null&&o.indexOf(j)===-1&&o.push(j),s)}function JA(s,o,f,g,j){switch(o){case"focusin":return Ci=Ql(Ci,s,o,f,g,j),!0;case"dragenter":return ki=Ql(ki,s,o,f,g,j),!0;case"mouseover":return ji=Ql(ji,s,o,f,g,j),!0;case"pointerover":var A=j.pointerId;return Yl.set(A,Ql(Yl.get(A)||null,s,o,f,g,j)),!0;case"gotpointercapture":return A=j.pointerId,Xl.set(A,Ql(Xl.get(A)||null,s,o,f,g,j)),!0}return!1}function G0(s){var o=Ha(s.target);if(o!==null){var f=l(o);if(f!==null){if(o=f.tag,o===13){if(o=u(f),o!==null){s.blockedOn=o,Qe(s.priority,function(){U0(f)});return}}else if(o===31){if(o=c(f),o!==null){s.blockedOn=o,Qe(s.priority,function(){U0(f)});return}}else if(o===3&&f.stateNode.current.memoizedState.isDehydrated){s.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}s.blockedOn=null}function ld(s){if(s.blockedOn!==null)return!1;for(var o=s.targetContainers;0<o.length;){var f=wp(s.nativeEvent);if(f===null){f=s.nativeEvent;var g=new f.constructor(f.type,f);Cf=g,f.target.dispatchEvent(g),Cf=null}else return o=Fa(f),o!==null&&F0(o),s.blockedOn=f,!1;o.shift()}return!0}function q0(s,o,f){ld(s)&&f.delete(o)}function ZA(){kp=!1,Ci!==null&&ld(Ci)&&(Ci=null),ki!==null&&ld(ki)&&(ki=null),ji!==null&&ld(ji)&&(ji=null),Yl.forEach(q0),Xl.forEach(q0)}function cd(s,o){s.blockedOn===o&&(s.blockedOn=null,kp||(kp=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,ZA)))}var ud=null;function K0(s){ud!==s&&(ud=s,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){ud===s&&(ud=null);for(var o=0;o<s.length;o+=3){var f=s[o],g=s[o+1],j=s[o+2];if(typeof g!="function"){if(Cp(g||f)===null)continue;break}var A=Fa(f);A!==null&&(s.splice(o,3),o-=3,wm(A,{pending:!0,data:j,method:f.method,action:g},g,j))}}))}function Co(s){function o(oe){return cd(oe,s)}Ci!==null&&cd(Ci,s),ki!==null&&cd(ki,s),ji!==null&&cd(ji,s),Yl.forEach(o),Xl.forEach(o);for(var f=0;f<Ei.length;f++){var g=Ei[f];g.blockedOn===s&&(g.blockedOn=null)}for(;0<Ei.length&&(f=Ei[0],f.blockedOn===null);)G0(f),f.blockedOn===null&&Ei.shift();if(f=(s.ownerDocument||s).$$reactFormReplay,f!=null)for(g=0;g<f.length;g+=3){var j=f[g],A=f[g+1],G=j[dt]||null;if(typeof A=="function")G||K0(f);else if(G){var te=null;if(A&&A.hasAttribute("formAction")){if(j=A,G=A[dt]||null)te=G.formAction;else if(Cp(j)!==null)continue}else te=G.action;typeof te=="function"?f[g+1]=te:(f.splice(g,3),g-=3),K0(f)}}}function Y0(){function s(A){A.canIntercept&&A.info==="react-transition"&&A.intercept({handler:function(){return new Promise(function(G){return j=G})},focusReset:"manual",scroll:"manual"})}function o(){j!==null&&(j(),j=null),g||setTimeout(f,20)}function f(){if(!g&&!navigation.transition){var A=navigation.currentEntry;A&&A.url!=null&&navigation.navigate(A.url,{state:A.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var g=!1,j=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",o),navigation.addEventListener("navigateerror",o),setTimeout(f,100),function(){g=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",o),navigation.removeEventListener("navigateerror",o),j!==null&&(j(),j=null)}}}function jp(s){this._internalRoot=s}dd.prototype.render=jp.prototype.render=function(s){var o=this._internalRoot;if(o===null)throw Error(r(409));var f=o.current,g=vr();z0(f,g,s,o,null,null)},dd.prototype.unmount=jp.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var o=s.containerInfo;z0(s.current,2,null,s,null,null),Wu(),o[sn]=null}};function dd(s){this._internalRoot=s}dd.prototype.unstable_scheduleHydration=function(s){if(s){var o=Be();s={blockedOn:null,target:s,priority:o};for(var f=0;f<Ei.length&&o!==0&&o<Ei[f].priority;f++);Ei.splice(f,0,s),f===0&&G0(s)}};var X0=t.version;if(X0!=="19.2.8")throw Error(r(527,X0,"19.2.8"));Z.findDOMNode=function(s){var o=s._reactInternals;if(o===void 0)throw typeof s.render=="function"?Error(r(188)):(s=Object.keys(s).join(","),Error(r(268,s)));return s=h(o),s=s!==null?p(s):null,s=s===null?null:s.stateNode,s};var eL={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:V,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var hd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!hd.isDisabled&&hd.supportsFiber)try{et=hd.inject(eL),ot=hd}catch{}}return Zl.createRoot=function(s,o){if(!a(s))throw Error(r(299));var f=!1,g="",j=r_,A=s_,G=i_;return o!=null&&(o.unstable_strictMode===!0&&(f=!0),o.identifierPrefix!==void 0&&(g=o.identifierPrefix),o.onUncaughtError!==void 0&&(j=o.onUncaughtError),o.onCaughtError!==void 0&&(A=o.onCaughtError),o.onRecoverableError!==void 0&&(G=o.onRecoverableError)),o=B0(s,1,!1,null,null,f,g,null,j,A,G,Y0),s[sn]=o.current,op(s),new jp(o)},Zl.hydrateRoot=function(s,o,f){if(!a(s))throw Error(r(299));var g=!1,j="",A=r_,G=s_,te=i_,oe=null;return f!=null&&(f.unstable_strictMode===!0&&(g=!0),f.identifierPrefix!==void 0&&(j=f.identifierPrefix),f.onUncaughtError!==void 0&&(A=f.onUncaughtError),f.onCaughtError!==void 0&&(G=f.onCaughtError),f.onRecoverableError!==void 0&&(te=f.onRecoverableError),f.formState!==void 0&&(oe=f.formState)),o=B0(s,1,!0,o,f??null,g,j,oe,A,G,te,Y0),o.context=$0(null),f=o.current,g=vr(),g=fe(g),j=hi(g),j.callback=null,fi(f,j,g),f=g,o.current.lanes=f,hn(o,f),us(o),s[sn]=o.current,op(s),new dd(o)},Zl.version="19.2.8",Zl}var lS;function pL(){if(lS)return Lp.exports;lS=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Lp.exports=mL(),Lp.exports}var gL=pL();const xL=Lh(gL);function yL(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,a,l,u=[],c="",d=e.split("/");for(d[0]||d.shift();a=d.shift();)n=a[0],n==="*"?(u.push(n),c+=a[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(r=a.indexOf("?",1),l=a.indexOf(".",1),u.push(a.substring(1,~r?r:~l?l:a.length)),c+=~r&&!~l?"(?:/([^/]+?))?":"/([^/]+?)",~l&&(c+=(~r?"?":"")+"\\"+a.substring(l))):c+="/"+a;return{keys:u,pattern:new RegExp("^"+c+(t?"(?=$|/)":"/?$"),"i")}}var Ip={exports:{}},Mp={};/**
|
|
51
|
+
* @license React
|
|
52
|
+
* use-sync-external-store-shim.production.js
|
|
53
|
+
*
|
|
54
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
55
|
+
*
|
|
56
|
+
* This source code is licensed under the MIT license found in the
|
|
57
|
+
* LICENSE file in the root directory of this source tree.
|
|
58
|
+
*/var cS;function bL(){if(cS)return Mp;cS=1;var e=Dh();function t(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,a=e.useEffect,l=e.useLayoutEffect,u=e.useDebugValue;function c(m,x){var y=x(),S=r({inst:{value:y,getSnapshot:x}}),C=S[0].inst,v=S[1];return l(function(){C.value=y,C.getSnapshot=x,d(C)&&v({inst:C})},[m,y,x]),a(function(){return d(C)&&v({inst:C}),m(function(){d(C)&&v({inst:C})})},[m]),u(y),y}function d(m){var x=m.getSnapshot;m=m.value;try{var y=x();return!n(m,y)}catch{return!0}}function h(m,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return Mp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,Mp}var uS;function vL(){return uS||(uS=1,Ip.exports=bL()),Ip.exports}var _L=vL();const SL=uL.useInsertionEffect,wL=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",CL=wL?N.useLayoutEffect:N.useEffect,kL=SL||CL,kC=e=>{const t=N.useRef([e,(...n)=>t[0](...n)]).current;return kL(()=>{t[0]=e}),t[1]},jL="popstate",Px="pushState",Bx="replaceState",EL="hashchange",dS=[jL,Px,Bx,EL],NL=e=>{for(const t of dS)addEventListener(t,e);return()=>{for(const t of dS)removeEventListener(t,e)}},jC=(e,t)=>_L.useSyncExternalStore(NL,e,t),hS=()=>location.search,TL=({ssrSearch:e}={})=>jC(hS,e!=null?()=>e:hS),fS=()=>location.pathname,AL=({ssrPath:e}={})=>jC(fS,e!=null?()=>e:fS),LL=(e,{replace:t=!1,state:n=null}={})=>history[t?Bx:Px](n,"",e),DL=(e={})=>[AL(e),LL],mS=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[mS]>"u"){for(const e of[Px,Bx]){const t=history[e];history[e]=function(){const n=t.apply(this,arguments),r=new Event(e);return r.arguments=arguments,dispatchEvent(r),n}}Object.defineProperty(window,mS,{value:!0})}const RL=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",EC=(e="")=>e==="/"?"":e,OL=(e,t)=>e[0]==="~"?e.slice(1):EC(t)+e,IL=(e="",t)=>RL(pS(EC(e)),pS(t)),pS=e=>{try{return decodeURI(e)}catch{return e}},NC={hook:DL,searchHook:TL,parser:yL,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},TC=N.createContext(NC),Jo=()=>N.useContext(TC),AC={},LC=N.createContext(AC),ML=()=>N.useContext(LC),Rh=e=>{const[t,n]=e.hook(e);return[IL(e.base,t),kC((r,a)=>e.aroundNav(n,OL(r,e.base),a))]},zn=()=>Rh(Jo()),$x=(e,t,n,r)=>{const{pattern:a,keys:l}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",r),u=a.exec(n)||[],[c,...d]=u;return c!==void 0?[!0,(()=>{const h=l!==!1?Object.fromEntries(l.map((m,x)=>[m,d[x]])):u.groups;let p={...d};return h&&Object.assign(p,h),p})(),...r?[c]:[]]:[!1,null]},Zo=e=>$x(Jo().parser,e,zn()[0]),DC=({children:e,...t})=>{var p,m,x;const n=Jo(),r=t.hook?NC:n;let a=r;const[l,u=t.ssrSearch??""]=((p=t.ssrPath)==null?void 0:p.split("?"))??[];l&&(t.ssrSearch=u,t.ssrPath=l),t.hrefs=t.hrefs??((m=t.hook)==null?void 0:m.hrefs),t.searchHook=t.searchHook??((x=t.hook)==null?void 0:x.searchHook);let c=N.useRef({}),d=c.current,h=d;for(let y in r){const S=y==="base"?r[y]+(t[y]??""):t[y]??r[y];d===h&&S!==h[y]&&(c.current=h={...h}),h[y]=S,(S!==r[y]||S!==a[y])&&(a=h)}return N.createElement(TC.Provider,{value:a,children:e})},gS=({children:e,component:t},n)=>t?N.createElement(t,{params:n}):typeof e=="function"?e(n):e,PL=e=>{let t=N.useRef(AC);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([r,a])=>a!==n[r])?e:n},ec=({path:e,nest:t,match:n,...r})=>{const a=Jo(),[l]=Rh(a),[u,c,d]=n??$x(a.parser,e,l,t),h=PL({...ML(),...c});if(!u)return null;const p=d?N.createElement(DC,{base:d},gS(r,h)):gS(r,h);return N.createElement(LC.Provider,{value:h,children:p})},ur=N.forwardRef((e,t)=>{const n=Jo(),[r,a]=Rh(n),{to:l="",href:u=l,onClick:c,asChild:d,children:h,className:p,replace:m,state:x,transition:y,...S}=e,C=kC(w=>{w.ctrlKey||w.metaKey||w.altKey||w.shiftKey||w.button!==0||(c==null||c(w),w.defaultPrevented||(w.preventDefault(),a(u,e)))}),v=n.hrefs(u[0]==="~"?u.slice(1):n.base+u,n);return d&&N.isValidElement(h)?N.cloneElement(h,{onClick:C,href:v}):N.createElement("a",{...S,onClick:C,href:v,className:p!=null&&p.call?p(r===u):p,children:h,ref:t})}),RC=e=>Array.isArray(e)?e.flatMap(t=>RC(t&&t.type===N.Fragment?t.props.children:t)):[e],BL=({children:e,location:t})=>{const n=Jo(),[r]=Rh(n);for(const a of RC(e)){let l=0;if(N.isValidElement(a)&&(l=$x(n.parser,a.props.path,t||r,a.props.nest))[0])return N.cloneElement(a,{match:l})}return null};/*!
|
|
59
|
+
* OverlayScrollbars
|
|
60
|
+
* Version: 2.16.0
|
|
61
|
+
*
|
|
62
|
+
* Copyright (c) Rene Haas | KingSora.
|
|
63
|
+
* https://github.com/KingSora
|
|
64
|
+
*
|
|
65
|
+
* Released under the MIT license.
|
|
66
|
+
*/const wr=(e,t)=>{const{o:n,i:r,u:a}=e;let l=n,u;const c=(p,m)=>{const x=l,y=p,S=m||(r?!r(x,y):x!==y);return(S||a)&&(l=y,u=x),[l,S,u]};return[t?p=>c(t(l,u),p):c,p=>[l,!!p,u]]},$L=typeof window<"u"&&typeof HTMLElement<"u"&&!!window.document,cr=$L?window:{},OC=Math.max,zL=Math.min,zg=Math.round,Ii=Math.abs,xS=Math.sign,IC=cr.cancelAnimationFrame,zx=cr.requestAnimationFrame,Hx=cr.setTimeout,MC=cr.clearTimeout,Oh=e=>typeof cr[e]<"u"?cr[e]:void 0,HL=Oh("MutationObserver"),yS=Oh("IntersectionObserver"),Io=Oh("ResizeObserver"),gc=Oh("ScrollTimeline"),Fx=e=>e===void 0,Ih=e=>e===null,Bi=e=>typeof e=="number",el=e=>typeof e=="string",Mh=e=>typeof e=="boolean",as=e=>typeof e=="function",Wr=e=>Array.isArray(e),eh=e=>typeof e=="object"&&!Wr(e)&&!Ih(e),Ux=e=>{const t=!!e&&e.length,n=Bi(t)&&t>-1&&t%1==0;return Wr(e)||!as(e)&&n?t>0&&eh(e)?t-1 in e:!0:!1},jc=e=>!!e&&e.constructor===Object,th=e=>e instanceof HTMLElement,Ph=e=>e instanceof Element;function Wt(e,t){if(Ux(e))for(let n=0;n<e.length&&t(e[n],n,e)!==!1;n++);else e&&Wt(Object.keys(e),(n=>t(e[n],n,e)));return e}const PC=(e,t)=>e.indexOf(t)>=0,Go=(e,t)=>e.concat(t),ln=(e,t,n)=>(!el(t)&&Ux(t)?Array.prototype.push.apply(e,t):e.push(t),e),Wi=e=>Array.from(e||[]),Vx=e=>Wr(e)?e:!el(e)&&Ux(e)?Wi(e):[e],nh=e=>!!e&&!e.length,rh=e=>Wi(new Set(e)),kr=(e,t,n)=>{Wt(e,a=>a?a.apply(void 0,t||[]):!0),n||(e.length=0)},BC="paddingTop",$C="paddingRight",zC="paddingLeft",HC="paddingBottom",FC="marginLeft",UC="marginRight",VC="marginBottom",Wx="overflowX",Gx="overflowY",Bh="width",$h="height",Qs="visible",Jr="hidden",Na="scroll",FL=e=>{const t=String(e||"");return t?t[0].toUpperCase()+t.slice(1):""},zh=(e,t,n,r)=>{if(e&&t){let a=!0;return Wt(n,(l=>{const u=e[l],c=t[l];u!==c&&(a=!1)})),a}return!1},WC=(e,t)=>zh(e,t,["w","h"]),Fd=(e,t)=>zh(e,t,["x","y"]),UL=(e,t)=>zh(e,t,["t","r","b","l"]),pt=(e,...t)=>e.bind(0,...t),Mo=e=>{let t;const n=e?Hx:zx,r=e?MC:IC;return[a=>{r(t),t=n((()=>a()),as(e)?e():e)},()=>r(t)]},bS=e=>{const t=as(e)?e():e;if(Bi(t)){const n=t?Hx:zx,r=t?MC:IC;return a=>{const l=n((()=>a()),t);return()=>{r(l)}}}return t&&t._},GC=(e,t)=>{const{p:n,v:r,S:a,m:l}=t||{};let u,c,d,h;const p=function(C){c&&c(),u&&u(),h=c=u=d=void 0,e.apply(this,C)},m=S=>l&&d?l(d,S):S,x=()=>{c&&d&&p(m(d)||d)},y=function(){const C=Wi(arguments),v=bS(n);if(v){const w=typeof a=="function"?a():a,_=bS(r),k=m(C)||C,E=p.bind(0,k);c&&c(),w&&!h?(E(),h=!0,c=v((()=>h=void 0))):(c=v(E),_&&!u&&(u=_(x))),d=k}else p(C)};return y.O=x,y},qC=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),or=e=>e?Object.keys(e):[],It=(e,t,n,r,a,l,u)=>{const c=[t,n,r,a,l,u];return(typeof e!="object"||Ih(e))&&!as(e)&&(e={}),Wt(c,(d=>{Wt(d,((h,p)=>{const m=d[p];if(e===m)return!0;const x=Wr(m);if(m&&jc(m)){const y=e[p];let S=y;x&&!Wr(y)?S=[]:!x&&!jc(y)&&(S={}),e[p]=It(S,m)}else e[p]=x?m.slice():m}))})),e},KC=(e,t)=>Wt(It({},e),((n,r,a)=>{n===void 0?delete a[r]:n&&jc(n)&&(a[r]=KC(n))})),qx=e=>!or(e).length,Ec=()=>{},YC=(e,t,n)=>OC(e,zL(t,n)),Ta=e=>rh((Wr(e)?e:(e||"").split(" ")).filter((t=>t))),Kx=(e,t)=>e&&e.getAttribute(t),vS=(e,t)=>e&&e.hasAttribute(t),Ks=(e,t,n)=>{Wt(Ta(t),(r=>{e&&e.setAttribute(r,String(n||""))}))},fs=(e,t)=>{Wt(Ta(t),(n=>e&&e.removeAttribute(n)))},Hh=(e,t)=>{const n=Ta(Kx(e,t)),r=pt(Ks,e,t),a=(l,u)=>{const c=new Set(n);return Wt(Ta(l),(d=>{c[u](d)})),Wi(c).join(" ")};return{C:l=>r(a(l,"delete")),$:l=>r(a(l,"add")),H:l=>{const u=Ta(l);return u.reduce(((c,d)=>c&&n.includes(d)),u.length>0)}}},XC=(e,t,n)=>(Hh(e,t).C(n),pt(Yx,e,t,n)),Yx=(e,t,n)=>(Hh(e,t).$(n),pt(XC,e,t,n)),sh=(e,t,n,r)=>(r?Yx:XC)(e,t,n),Xx=(e,t,n)=>Hh(e,t).H(n),QC=e=>Hh(e,"class"),JC=(e,t)=>{QC(e).C(t)},Qx=(e,t)=>(QC(e).$(t),pt(JC,e,t)),ZC=(e,t)=>{const n=t?Ph(t)&&t:document;return n?Wi(n.querySelectorAll(e)):[]},VL=(e,t)=>{const n=t?Ph(t)&&t:document;return n&&n.querySelector(e)},Hg=(e,t)=>Ph(e)&&e.matches(t),ek=e=>Hg(e,"body"),Fg=e=>e?Wi(e.childNodes):[],Nc=e=>e&&e.parentElement,Po=(e,t)=>Ph(e)&&e.closest(t),Ug=e=>document.activeElement,WL=(e,t,n)=>{const r=Po(e,t),a=e&&VL(n,r),l=Po(a,t)===r;return r&&a?r===e||a===e||l&&Po(Po(e,n),t)!==r:!1},qo=e=>{Wt(Vx(e),(t=>{const n=Nc(t);t&&n&&n.removeChild(t)}))},lr=(e,t)=>pt(qo,e&&t&&Wt(Vx(t),(n=>{n&&e.appendChild(n)})));let tk;const GL=()=>tk,qL=e=>{tk=e},zo=e=>{const t=document.createElement("div");return Ks(t,"class",e),t},nk=e=>{const t=zo(),n=GL(),r=e.trim();return t.innerHTML=n?n.createHTML(r):r,Wt(Fg(t),(a=>qo(a)))},_S=(e,t)=>e.getPropertyValue(t)||e[t]||"",rk=e=>{const t=e||0;return isFinite(t)?t:0},fd=e=>rk(parseFloat(e||"")),Vg=e=>Math.round(e*1e4)/1e4,sk=e=>`${Vg(rk(e))}px`;function Tc(e,t){e&&t&&Wt(t,((n,r)=>{try{const a=e.style,l=Ih(n)||Mh(n)?"":Bi(n)?sk(n):n;r.indexOf("--")===0?a.setProperty(r,l):a[r]=l}catch{}}))}function Ss(e,t,n){const r=el(t);let a=r?"":{};if(e){const l=cr.getComputedStyle(e,n)||e.style;a=r?_S(l,t):Wi(t).reduce(((u,c)=>(u[c]=_S(l,c),u)),a)}return a}const SS=(e,t,n)=>{const r=t?`${t}-`:"",a=n?`-${n}`:"",l=`${r}top${a}`,u=`${r}right${a}`,c=`${r}bottom${a}`,d=`${r}left${a}`,h=Ss(e,[l,u,c,d]);return{t:fd(h[l]),r:fd(h[u]),b:fd(h[c]),l:fd(h[d])}},Pp=(e,t)=>`translate${eh(e)?`(${e.x},${e.y})`:`${t?"X":"Y"}(${e})`}`,KL=e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length),YL={w:0,h:0},Fh=(e,t)=>t?{w:t[`${e}Width`],h:t[`${e}Height`]}:YL,XL=e=>Fh("inner",e||cr),Ho=pt(Fh,"offset"),ik=pt(Fh,"client"),ih=pt(Fh,"scroll"),Jx=e=>{const t=parseFloat(Ss(e,Bh))||0,n=parseFloat(Ss(e,$h))||0;return{w:t-zg(t),h:n-zg(n)}},Bp=e=>e.getBoundingClientRect(),QL=e=>!!e&&KL(e),Wg=e=>!!(e&&(e[$h]||e[Bh])),ak=(e,t)=>{const n=Wg(e);return!Wg(t)&&n},wS=(e,t,n,r)=>{Wt(Ta(t),(a=>{e&&e.removeEventListener(a,n,r)}))},tn=(e,t,n,r)=>{var a;const l=(a=r&&r.D)!=null?a:!0,u=r&&r.I||!1,c=r&&r.A||!1,d={passive:l,capture:u};return pt(kr,Ta(t).map((h=>{const p=c?m=>{wS(e,h,p,u),n&&n(m)}:n;return e&&e.addEventListener(h,p,d),pt(wS,e,h,p,u)})))},ok=e=>e.stopPropagation(),Gg=e=>e.preventDefault(),lk=e=>ok(e)||Gg(e),vs=(e,t)=>{const{x:n,y:r}=Bi(t)?{x:t,y:t}:t||{};Bi(n)&&(e.scrollLeft=n),Bi(r)&&(e.scrollTop=r)},Cr=e=>({x:e.scrollLeft,y:e.scrollTop}),ck=()=>({T:{x:0,y:0},k:{x:0,y:0}}),JL=(e,t)=>{const{T:n,k:r}=e,{w:a,h:l}=t,u=(m,x,y)=>{let S=xS(m)*y,C=xS(x)*y;if(S===C){const v=Ii(m),w=Ii(x);C=v>w?0:C,S=v<w?0:S}return S=S===C?0:S,[S+0,C+0]},[c,d]=u(n.x,r.x,a),[h,p]=u(n.y,r.y,l);return{T:{x:c,y:h},k:{x:d,y:p}}},$p=({T:e,k:t})=>{const n=(r,a)=>r===0&&r<=a;return{x:n(e.x,t.x),y:n(e.y,t.y)}},CS=({T:e,k:t},n)=>{const r=(a,l,u)=>YC(0,1,(a-u)/(a-l)||0);return{x:r(e.x,t.x,n.x),y:r(e.y,t.y,n.y)}},qg=e=>{e&&e.focus&&e.focus({preventScroll:!0,focusVisible:!1})},kS=(e,t)=>{Wt(Vx(t),e)},Kg=e=>{const t=new Map,n=(l,u)=>{if(l){const c=t.get(l);kS((d=>{c&&c[d?"delete":"clear"](d)}),u)}else t.forEach((c=>{c.clear()})),t.clear()},r=(l,u)=>{if(el(l)){const h=t.get(l)||new Set;return t.set(l,h),kS((p=>{as(p)&&h.add(p)}),u),pt(n,l,u)}Mh(u)&&u&&n();const c=or(l),d=[];return Wt(c,(h=>{const p=l[h];p&&ln(d,r(h,p))})),pt(kr,d)},a=(l,u)=>{Wt(Wi(t.get(l)),(c=>{u&&!nh(u)?c.apply(0,u):c()}))};return r(e||{}),[r,n,a]},uk={},dk={},ZL=e=>{Wt(e,(t=>Wt(t,((n,r)=>{uk[r]=t[r]}))))},hk=(e,t,n)=>or(e).map((r=>{const{static:a,instance:l}=e[r],[u,c,d]=n||[],h=n?l:a;if(h){const p=n?h(u,c,t):h(t);return(d||dk)[r]=p}})),eD=(e,t)=>e[t],tl=e=>eD(dk,e),tD="__osOptionsValidationPlugin",nl="data-overlayscrollbars",Ud="os-environment",md=`${Ud}-scrollbar-hidden`,zp=`${nl}-initialize`,Vd="noClipping",jS=`${nl}-body`,$i=nl,nD="host",Ys=`${nl}-viewport`,rD=Wx,sD=Gx,iD="arrange",fk="measuring",aD="scrolling",mk="scrollbarHidden",oD="noContent",Yg=`${nl}-padding`,ES=`${nl}-content`,Zx="os-size-observer",lD=`${Zx}-appear`,cD=`${Zx}-listener`,uD="os-trinsic-observer",dD="os-theme-none",Er="os-scrollbar",hD=`${Er}-rtl`,fD=`${Er}-horizontal`,mD=`${Er}-vertical`,pk=`${Er}-track`,ey=`${Er}-handle`,pD=`${Er}-visible`,gD=`${Er}-cornerless`,NS=`${Er}-interaction`,TS=`${Er}-unusable`,Xg=`${Er}-auto-hide`,xD=`${Xg}-hidden`,AS=`${Er}-wheel`,yD=`${pk}-interactive`,bD=`${ey}-interactive`,vD="__osSizeObserverPlugin",_D=(e,t)=>{const{M:n}=t,[r,a]=e("showNativeOverlaidScrollbars");return[r&&n.x&&n.y,a]},Bo=e=>e.indexOf(Qs)===0,SD=e=>e.replace(`${Qs}-`,""),Qg=(e,t)=>{if(e==="auto")return t?Na:Jr;const n=e||Jr;return[Jr,Na,Qs].includes(n)?n:Jr},wD=(e,t)=>{const{overflowX:n,overflowY:r}=Ss(e,[Wx,Gx]);return{x:Qg(n,t.x),y:Qg(r,t.y)}},ty="__osScrollbarsHidingPlugin",CD="__osClickScrollPlugin",LS=e=>JSON.stringify(e,((t,n)=>{if(as(n))throw 0;return n})),DS=(e,t)=>e?`${t}`.split(".").reduce(((n,r)=>n&&qC(n,r)?n[r]:void 0),e):void 0,kD=[0,33],gk=[33,99],xk=[222,666,!0],jD={paddingAbsolute:!1,showNativeOverlaidScrollbars:!1,update:{elementEvents:[["img","load"]],debounce:{mutation:kD,resize:null,event:gk,env:xk},attributes:null,ignoreMutation:null,flowDirectionStyles:null},overflow:{x:"scroll",y:"scroll"},scrollbars:{theme:"os-theme-dark",visibility:"auto",autoHide:"never",autoHideDelay:1300,autoHideSuspend:!1,dragScroll:!0,clickScroll:!1,pointers:["mouse","touch","pen"]}},yk=(e,t)=>{const n={},r=Go(or(t),or(e));return Wt(r,(a=>{const l=e[a],u=t[a];if(eh(l)&&eh(u))It(n[a]={},yk(l,u)),qx(n[a])&&delete n[a];else if(qC(t,a)&&u!==l){let c=!0;if(Wr(l)||Wr(u))try{LS(l)===LS(u)&&(c=!1)}catch{}c&&(n[a]=u)}})),n},Hp=(e,t,n)=>r=>[DS(e,r),n||DS(t,r)!==void 0];let bk;const ED=()=>bk,ND=e=>{bk=e};let Fp;const TD=()=>{const e=(k,E,T)=>{lr(document.body,k),lr(document.body,k);const D=ik(k),L=Ho(k),R=Jx(E);return T&&qo(k),{x:L.h-D.h+R.h,y:L.w-D.w+R.w}},t=k=>{let E=!1;const T=Qx(k,md);try{E=Ss(k,"scrollbar-width")==="none"||Ss(k,"display","::-webkit-scrollbar")==="none"}catch{}return T(),E},n=`.${Ud}{scroll-behavior:auto!important;position:fixed;opacity:0;visibility:hidden;overflow:scroll;height:200px;width:200px;z-index:-1}.${Ud} div{width:200%;height:200%;margin:10px 0}.${md}{scrollbar-width:none!important}.${md}::-webkit-scrollbar,.${md}::-webkit-scrollbar-corner{appearance:none!important;display:none!important;width:0!important;height:0!important}`,a=nk(`<div class="${Ud}"><div></div><style>${n}</style></div>`)[0],l=a.firstChild,u=a.lastChild,c=ED();c&&(u.nonce=c);const[d,,h]=Kg(),[p,m]=wr({o:e(a,l),i:Fd},pt(e,a,l,!0)),[x]=m(),y=t(a),S={x:x.x===0,y:x.y===0},C={elements:{host:null,padding:!y,viewport:k=>y&&ek(k)&&k,content:!1},scrollbars:{slot:!0},cancel:{nativeScrollbarsOverlaid:!1,body:null}},v=It({},jD),w=pt(It,{},v),_=pt(It,{},C),b={U:x,M:S,P:y,J:!!gc,G:pt(d,"r"),K:_,Z:k=>It(C,k)&&_(),tt:w,nt:k=>It(v,k)&&w(),ot:It({},C),st:It({},v)};if(fs(a,"style"),qo(a),tn(cr,"resize",(()=>{h("r",[])})),as(cr.matchMedia)&&!y&&(!S.x||!S.y)){const k=E=>{const T=cr.matchMedia(`(resolution: ${cr.devicePixelRatio}dppx)`);tn(T,"change",(()=>{E(),k(E)}),{A:!0})};k((()=>{const[E,T]=p();It(b.U,E),h("r",[T])}))}return b},Cs=()=>(Fp||(Fp=TD()),Fp),AD=(e,t,n)=>{let r=!1;const a=n?new WeakMap:!1,l=()=>{r=!0},u=c=>{if(a&&n){const d=n.map((h=>{const[p,m]=h||[];return[m&&p?(c||ZC)(p,e):[],m]}));Wt(d,(h=>Wt(h[0],(p=>{const m=h[1],x=a.get(p)||[];if(e.contains(p)&&m){const S=tn(p,m,(C=>{r?(S(),a.delete(p)):t(C)}));a.set(p,ln(x,S))}else kr(x),a.delete(p)}))))}};return u(),[l,u]},RS=(e,t,n,r)=>{let a=!1;const{et:l,ct:u,rt:c,it:d,lt:h,ut:p}=r||{},[m,x]=AD(e,(()=>a&&n(!0)),c),y=l||[],S=u||[],C=Go(y,S),v=(_,b)=>{if(!nh(b)){const k=h||Ec,E=p||Ec,T=[],D=[];let L=!1,R=!1;if(Wt(b,(M=>{const{attributeName:W,target:z,type:H,oldValue:I,addedNodes:U,removedNodes:V}=M,Z=H==="attributes",ee=H==="childList",F=e===z,O=Z&&W,B=O&&Kx(z,W||""),q=el(B)?B:null,$=O&&I!==q,Y=PC(S,W)&&$;if(t&&(ee||!F)){const Q=Z&&$,X=Q&&d&&Hg(z,d),P=(X?!k(z,W,I,q):!Z||Q)&&!E(M,!!X,e,r);Wt(U,(J=>ln(T,J))),Wt(V,(J=>ln(T,J))),R=R||P}!t&&F&&$&&!k(z,W,I,q)&&(ln(D,W),L=L||Y)})),x((M=>rh(T).reduce(((W,z)=>(ln(W,ZC(M,z)),Hg(z,M)?ln(W,z):W)),[]))),t)return!_&&R&&n(!1),[!1];if(!nh(D)||L){const M=[rh(D),L];return _||n.apply(0,M),M}}},w=new HL(pt(v,!1));return[()=>(w.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:C,subtree:t,childList:t,characterData:t}),a=!0,()=>{a&&(m(),w.disconnect(),a=!1)}),()=>{if(a)return v(!0,w.takeRecords())}]};let fa=null;const vk=(e,t,n)=>{const{ft:r}=n||{},a=tl(vD),[l]=wr({o:!1,u:!0});return()=>{const u=[],d=nk(`<div class="${Zx}"><div class="${cD}"></div></div>`)[0],h=d.firstChild,p=m=>{const x=Wr(m)&&!nh(m);let y=!1,S=!1;if(x){const C=m[0],[v,,w]=l(C.contentRect),_=Wg(v);S=ak(v,w),y=!S&&!_}else S=m===!0;y||t({_t:!0,ft:S})};if(Io){if(!Mh(fa)){const S=new Io(Ec);S.observe(e,{get box(){fa=!0}}),fa=fa||!1,S.disconnect()}const m=GC(p,{p:0,v:0}),x=S=>m(S),y=new Io(x);if(y.observe(fa?e:h),ln(u,[()=>{y.disconnect()},!fa&&lr(e,d)]),fa){const S=new Io(x);S.observe(e,{box:"border-box"}),ln(u,(()=>S.disconnect()))}}else if(a){const[m,x]=a(h,p,r);ln(u,Go([Qx(d,lD),tn(d,"animationstart",m),lr(e,d)],x))}else return Ec;return pt(kr,u)}},LD=(e,t)=>{let n;const r=d=>d.h===0||d.isIntersecting||d.intersectionRatio>0,a=zo(uD),[l]=wr({o:!1}),u=(d,h)=>{if(d){const p=l(r(d)),[,m]=p;return m&&!h&&t(p)&&[p]}},c=(d,h)=>u(h.pop(),d);return[()=>{const d=[];if(yS)n=new yS(pt(c,!1),{root:e}),n.observe(a),ln(d,(()=>{n.disconnect()}));else{const h=()=>{const p=Ho(a);u(p)};ln(d,vk(a,h)()),h()}return pt(kr,ln(d,lr(e,a)))},()=>n&&c(!0,n.takeRecords())]},DD=(e,t,n,r)=>{let a,l,u,c,d,h,p,m;const x=`[${$i}]`,y=`[${Ys}]`,S=["id","class","style","open","wrap","cols","rows"],{dt:C,vt:v,L:w,gt:_,ht:b,V:k,bt:E,yt:T,wt:D,St:L}=e,R=K=>Ss(K,"direction")==="rtl",M=()=>{let K,P,J;const ne=GC(r,{p:()=>K,v:()=>P,S:()=>J,m(ae,Ee){const[ve]=ae,[Le]=Ee;return[Go(or(ve),or(Le)).reduce(((Me,ke)=>(Me[ke]=ve[ke]||Le[ke],Me)),{})]}}),ce=(ae,Ee)=>{if(Wr(Ee)){const[ve,Le,Me]=Ee;K=ve,P=Le,J=Me}else Bi(Ee)?(K=Ee,P=!1,J=!1):(K=!1,P=!1,J=!1);ne(ae)};return ce.O=ne.O,ce},W={Ot:!1,B:R(C)},z=Cs(),H=tl(ty),[I]=wr({i:WC,o:{w:0,h:0}},(()=>{const K=H&&H.R(e,t,W,z,n).Y,J=!(E&&k)&&Xx(v,$i,Vd),ne=!k&&T(iD),ce=ne&&Cr(_),ae=ce&&L(),Ee=D(fk,J),ve=ne&&K&&K(),Le=ih(w),Me=Jx(w);return ve&&ve(),vs(_,ce),ae&&ae(),J&&Ee(),{w:Le.w+Me.w,h:Le.h+Me.h}})),U=M(),V=K=>{const P=R(C);It(K,{Ct:m!==P}),It(W,{B:P}),m=P},Z=(K,P)=>{const[J,ne]=K,ce={$t:ne};return It(W,{Ot:J}),P||r(ce),ce},ee=({_t:K,ft:P})=>{const J=P?r:U,ne={_t:K||P,ft:P};V(ne),J(ne,l)},F=(K,P)=>{const[,J]=I(),ne={xt:J};return V(ne),J&&!P&&U(ne,K?u:a),ne},O=(K,P,J)=>{const ne={Ht:P};return V(ne),P&&!J&&U(ne,a),ne},[B,q]=b?LD(v,Z):[],$=!k&&vk(v,ee,{ft:!0}),[Y,Q]=RS(v,!1,O,{ct:S,et:S}),X=k&&Io&&new Io((K=>{const P=K[K.length-1].contentRect;ee({_t:!0,ft:ak(P,p)}),p=P}));return[()=>{X&&X.observe(v);const K=$&&$(),P=B&&B(),J=Y(),ne=z.G((ce=>{const[,ae]=I();U({Et:ce,xt:ae,_t:E},c)}));return()=>{X&&X.disconnect(),K&&K(),P&&P(),h&&h(),J(),ne()}},({Dt:K,zt:P,It:J})=>{const ne={},[ce]=K("update.ignoreMutation"),[ae,Ee]=K("update.attributes"),[ve,Le]=K("update.elementEvents"),[Me,ke]=K("update.debounce"),Ge=Le||Ee,Xe=P||J,Se=Ie=>as(ce)&&!!ce(Ie);if(Ge){d&&d(),h&&h();const[Ie,it]=RS(b||w,!0,F,{et:Go(S,ae||[]),rt:ve,it:x,ut:(ge,Fe)=>{const{target:He,attributeName:ie}=ge;return(!Fe&&ie&&!k?WL(He,x,y):!1)||!!Po(He,`.${Er}`)||Se(ge)}});h=Ie(),d=it}if(ke&&(U.O(),Wr(Me)||Bi(Me)?(a=Me,l=!1,u=gk,c=xk):jc(Me)?(a=Me.mutation,l=Me.resize,u=Me.event,c=Me.env):(a=!1,l=!1,u=!1,c=!1)),Xe){const Ie=Q(),it=q&&q(),ge=d&&d();Ie&&It(ne,O(Ie[0],Ie[1],Xe)),it&&It(ne,Z(it[0],Xe)),ge&&It(ne,F(ge[0],Xe))}return V(ne),ne},W]},_k=(e,t)=>as(t)?t.apply(0,e):t,RD=(e,t,n,r)=>{const a=Fx(r)?n:r;return _k(e,a)||t.apply(0,e)},Sk=(e,t,n,r)=>{const a=Fx(r)?n:r,l=_k(e,a);return!!l&&(th(l)?l:t.apply(0,e))},OD=(e,t)=>{const{nativeScrollbarsOverlaid:n,body:r}=t||{},{M:a,P:l,K:u}=Cs(),{nativeScrollbarsOverlaid:c,body:d}=u().cancel,h=n??c,p=Fx(r)?d:r,m=(a.x||a.y)&&h,x=e&&(Ih(p)?!l:p);return!!m||!!x},ID=(e,t,n,r)=>{const a="--os-viewport-percent",l="--os-scroll-percent",u="--os-scroll-direction",{K:c}=Cs(),{scrollbars:d}=c(),{slot:h}=d,{dt:p,vt:m,L:x,At:y,gt:S,bt:C,V:v}=t,{scrollbars:w}=y?{}:e,{slot:_}=w||{},b=[],k=[],E=[],T=Sk([p,m,x],(()=>v&&C?p:m),h,_),D=B=>{if(gc){let q=null,$=[];const Y=new gc({source:S,axis:B}),Q=()=>{q&&q.cancel(),q=null};return{Mt:K=>{const{Tt:P}=n,J=$p(P)[B],ne=B==="x",ce=[Pp(0,ne),Pp(`calc(-100% + 100cq${ne?"w":"h"})`,ne)],ae=J?ce:ce.reverse();return $[0]===ae[0]&&$[1]===ae[1]||($=ae,Q(),q=K.kt.animate({clear:["left"],transform:ae},{timeline:Y})),Q}}}},L={x:D("x"),y:D("y")},R=()=>{const{Rt:B,Vt:q}=n,$=(Y,Q)=>YC(0,1,Y/(Y+Q)||0);return{x:$(q.x,B.x),y:$(q.y,B.y)}},M=(B,q,$)=>{const Y=$?Qx:JC;Wt(B,(Q=>{Y(Q.Lt,q)}))},W=(B,q)=>{Wt(B,($=>{const[Y,Q]=q($);Tc(Y,Q)}))},z=(B,q,$)=>{const Y=Mh($),Q=Y?$:!0,X=Y?!$:!0;Q&&M(k,B,q),X&&M(E,B,q)},H=()=>{const B=R(),q=$=>Y=>[Y.Lt,{[a]:Vg($)+""}];W(k,q(B.x)),W(E,q(B.y))},I=()=>{if(!gc){const{Tt:B}=n,q=CS(B,Cr(S)),$=Y=>Q=>[Q.Lt,{[l]:Vg(Y)+""}];W(k,$(q.x)),W(E,$(q.y))}},U=()=>{const{Tt:B}=n,q=$p(B),$=Y=>Q=>[Q.Lt,{[u]:Y?"0":"1"}];W(k,$(q.x)),W(E,$(q.y)),gc&&(k.forEach(L.x.Mt),E.forEach(L.y.Mt))},V=()=>{if(v&&!C){const{Rt:B,Tt:q}=n,$=$p(q),Y=CS(q,Cr(S)),Q=X=>{const{Lt:K}=X,P=Nc(K)===x&&K,J=(ne,ce,ae)=>{const Ee=ce*ne;return sk(ae?Ee:-Ee)};return[P,P&&{transform:Pp({x:J(Y.x,B.x,$.x),y:J(Y.y,B.y,$.y)})}]};W(k,Q),W(E,Q)}},Z=B=>{const q=B?"x":"y",Y=zo(`${Er} ${B?fD:mD}`),Q=zo(pk),X=zo(ey),K={Lt:Y,Pt:Q,kt:X},P=L[q];return ln(B?k:E,K),ln(b,[lr(Y,Q),lr(Q,X),pt(qo,Y),P&&P.Mt(K),r(K,z,B)]),K},ee=pt(Z,!0),F=pt(Z,!1),O=()=>(lr(T,k[0].Lt),lr(T,E[0].Lt),pt(kr,b));return ee(),F(),[{Ut:H,Nt:I,qt:U,Bt:V,Ft:z,jt:{Xt:k,Yt:ee,Wt:pt(W,k)},Jt:{Xt:E,Yt:F,Wt:pt(W,E)}},O]},MD=(e,t,n,r,a)=>(l,u,c)=>{const{vt:d,L:h,V:p,gt:m,Gt:x,St:y}=t,{Lt:S,Pt:C,kt:v}=l,[w,_]=Mo(333),[b,k]=Mo(444),E=L=>{as(m.scrollBy)&&m.scrollBy({behavior:"smooth",left:L.x,top:L.y})},T=()=>{const L="pointerup pointercancel lostpointercapture",R=`client${c?"X":"Y"}`,M=c?Bh:$h,W=c?"left":"top",z=c?"w":"h",H=c?"x":"y",I=[];return tn(C,"pointerdown",r((U=>{const V=Po(U.target,`.${ey}`)===v,Z=V?v:C,ee=e.scrollbars,F=ee[V?"dragScroll":"clickScroll"],{button:O,isPrimary:B,pointerType:q}=U,{pointers:$}=ee;if(O===0&&B&&F&&($||[]).includes(q)){kr(I),k();const Q=!V&&(U.shiftKey||F==="instant"),X=pt(Bp,v),K=pt(Bp,C),P=(He,ie)=>(He||X())[W]-(ie||K())[W],J=zg(Bp(m)[M])/Ho(m)[z]||1,ne=Cr(m)[H],ce=He=>{vs(m,{[H]:ne+He})},ae=He=>{const{Rt:ie}=n,xe=Ho(C)[z]-Ho(v)[z],se=1/J*He/xe;ce(se*ie[H])},Ee=U[R],ve=X(),Le=K(),Me=ve[M],ke=P(ve,Le)+Me/2,Xe=Ee-Le[W]-ke,Se=V?0:Xe,Ie=He=>{kr(Fe),Z.releasePointerCapture(He.pointerId)},it=V||Q,ge=y(),Fe=[tn(x,L,Ie),tn(x,"selectstart",(He=>Gg(He)),{D:!1}),tn(C,L,Ie),it&&tn(C,"pointermove",(He=>ae(Se+He[R]-Ee))),it&&(()=>{const He=Cr(m);ge();const ie=Cr(m),xe={x:ie.x-He.x,y:ie.y-He.y};(Ii(xe.x)>3||Ii(xe.y)>3)&&(y(),vs(m,He),E(xe),b(ge))})];if(Z.setPointerCapture(U.pointerId),Q)ae(Xe);else if(!V){const He=tl(CD);if(He){const{Vt:ie}=n,xe=He(ce,ae,pt(P),Xe,ie[H],F,!!c,(se=>{se?ge():ln(Fe,ge)}));ln(Fe,xe),ln(I,pt(xe,!0))}}}})))};let D=!0;return pt(kr,[tn(v,"pointermove pointerleave",r(a)),tn(S,"pointerenter",r((()=>{u(NS,!0)}))),tn(S,"pointerleave pointercancel",r((()=>{u(NS,!1)}))),tn(S,"wheel",r((L=>{const{deltaX:R,deltaY:M,deltaMode:W}=L;D&&W===0&&Nc(S)===d&&E({x:R,y:M}),D=!1,u(AS,!0),w((()=>{D=!0,u(AS)})),Gg(L)})),{D:!1,I:!0}),!p&&tn(S,"mousedown",r((()=>{const L=Ug();(vS(L,Ys)||vS(L,$i)||L===document.body)&&Hx(pt(qg,h),25)}))),tn(S,"pointerdown",(()=>{const L=tn(x,"click",(M=>{R(),lk(M)}),{A:!0,I:!0,D:!1}),R=tn(x,"pointerup pointercancel",(()=>{R(),setTimeout(L,150)}),{I:!0,D:!0})}),{I:!0,D:!0}),T(),_,k])},PD=(e,t,n,r,a,l,u)=>{let c,d,h,p,m,x=Ec,y=0;const S=["mouse","pen"],C=X=>K=>{n.Kt||X(K)},v=X=>S.includes(X.pointerType),[w,_]=Mo(),[b,k]=Mo(100),[E,T]=Mo(50),[D,L]=Mo((()=>y)),[R,M]=ID(e,l,a,MD(t,l,a,C,(X=>v(X)&&O()))),{vt:W,Qt:z,bt:H}=l,{Ft:I,Ut:U,Nt:V,qt:Z,Bt:ee}=R,F=(X,K)=>{L();const P=J=>{n.Kt||I(xD,J)};if(X)P();else{const J=h?!c:!0;y>0&&!K?D(pt(P,J)):P(J)}},O=()=>{(h?!c:!p)&&(F(!0),b((()=>{F(!1)})))},B=X=>{v(X)&&(c=!0,!n.Kt&&h&&F(!0))},q=X=>{v(X)&&(c=!1,!n.Kt&&h&&F(!1))},$=X=>{I(Xg,X,!0),I(Xg,X,!1)},Y=[L,k,T,_,()=>x(),tn(W,"pointerover",B,{A:!0}),tn(W,"pointerenter",B),tn(W,"pointerleave",q),tn(W,"pointermove",C((X=>{v(X)&&d&&O()}))),tn(z,"scroll",C((X=>{w((()=>{V(),O()})),u(X),ee()})))],Q=tl(ty);return[()=>pt(kr,ln(Y,M())),({Dt:X,It:K,Zt:P,tn:J})=>{const{nn:ne,sn:ce,en:ae,cn:Ee}=J||{},{Ct:ve,ft:Le}=P||{},{B:Me}=r,{M:ke,P:Ge}=Cs(),{rn:Xe,j:Se}=a,[Ie,it]=X("showNativeOverlaidScrollbars"),[ge,Fe]=X("scrollbars.theme"),[He,ie]=X("scrollbars.visibility"),[xe,se]=X("scrollbars.autoHide"),[he,Pe]=X("scrollbars.autoHideSuspend"),[qe]=X("scrollbars.autoHideDelay"),[Ke,et]=X("scrollbars.dragScroll"),[ot,ue]=X("scrollbars.clickScroll"),[$e,ut]=X("overflow"),ct=Le&&!K,cn=ne||ce||Ee||ve||K,Xt=ae||ie||ut,rn=Ie&&ke.x&&ke.y,On=!Ge&&!Q,ye=rn||On,Ye=(We,ze,tt)=>{const Lt=We.includes(Na)&&(He===Qs||He==="auto"&&ze===Na);return I(pD,Lt,tt),Lt};if(y=qe,(it||On)&&I(dD,ye),Fe&&(I(m),I(ge,!0),m=ge),(Pe||ct)&&($(!he),ct&&he&&(Se.x||Se.y?(x(),E((()=>{x=tn(z,Na,C(pt($,!0)),{A:!0})}))):$(!0))),se&&(d=xe==="move",h=xe==="leave",p=xe==="never",F(p,!0)),et&&I(bD,Ke),ue&&I(yD,!!ot),Xt){const We=Ye($e.x,Xe.x,!0),ze=Ye($e.y,Xe.y,!1);I(gD,!(We&&ze))}cn&&(V(),U(),ee(),Ee&&Z(),I(TS,!Se.x,!0),I(TS,!Se.y,!1),I(hD,Me&&!H))},{},R]},BD=e=>{const t=Cs(),{K:n,P:r}=t,{elements:a}=n(),{padding:l,viewport:u,content:c}=a,d=th(e),h=d?{}:e,{elements:p}=h,{padding:m,viewport:x,content:y}=p||{},S=d?e:h.target,C=ek(S),v=S.ownerDocument,w=v.documentElement,_=()=>v.defaultView||cr,b=pt(RD,[S]),k=pt(Sk,[S]),E=pt(zo,""),T=pt(b,E,u),D=pt(k,E,c),L=ve=>{const Le=Ho(ve),Me=ih(ve),ke=Ss(ve,Wx),Ge=Ss(ve,Gx);return Me.w-Le.w>0&&!Bo(ke)||Me.h-Le.h>0&&!Bo(Ge)},R=T(x),M=R===S,W=M&&C,z=!M&&D(y),H=!M&&R===z,I=W?w:R,U=W?I:S,V=!M&&k(E,l,m),Z=!H&&z,ee=[Z,I,V,U].map((ve=>th(ve)&&!Nc(ve)&&ve)),F=ve=>ve&&PC(ee,ve),O=!F(I)&&L(I)?I:S,B=W?w:I,$={dt:S,vt:U,L:I,ln:V,ht:Z,gt:B,Qt:W?v:I,an:C?w:O,Gt:v,bt:C,At:d,V:M,un:_,yt:ve=>Xx(I,Ys,ve),wt:(ve,Le)=>sh(I,Ys,ve,Le),St:()=>sh(B,Ys,aD,!0)},{dt:Y,vt:Q,ln:X,L:K,ht:P}=$,J=[()=>{fs(Q,[$i,zp]),fs(Y,zp),C&&fs(w,[zp,$i])}];let ne=Fg([P,K,X,Q,Y].find((ve=>ve&&!F(ve))));const ce=W?Y:P||K,ae=pt(kr,J);return[$,()=>{const ve=_(),Le=Ug(),Me=Ie=>{lr(Nc(Ie),Fg(Ie)),qo(Ie)},ke=Ie=>tn(Ie,"focusin focusout focus blur",lk,{I:!0,D:!1}),Ge="tabindex",Xe=Kx(K,Ge),Se=ke(Le);return Ks(Q,$i,M?"":nD),Ks(X,Yg,""),Ks(K,Ys,""),Ks(P,ES,""),M||(Ks(K,Ge,Xe||"-1"),C&&Ks(w,jS,"")),lr(ce,ne),lr(Q,X),lr(X||Q,!M&&K),lr(K,P),ln(J,[Se,()=>{const Ie=Ug(),it=F(K),ge=it&&Ie===K?Y:Ie,Fe=ke(ge);fs(X,Yg),fs(P,ES),fs(K,Ys),C&&fs(w,jS),Xe?Ks(K,Ge,Xe):fs(K,Ge),F(P)&&Me(P),it&&Me(K),F(X)&&Me(X),qg(ge),Fe()}]),r&&!M&&(Yx(K,Ys,mk),ln(J,pt(fs,K,Ys))),qg(!M&&C&&Le===Y&&ve.top===ve?K:Le),Se(),ne=0,ae},ae]},$D=({ht:e})=>({Zt:t,fn:n,It:r})=>{const{$t:a}=t||{},{Ot:l}=n;e&&(a||r)&&Tc(e,{[$h]:l&&"100%"})},zD=({vt:e,ln:t,L:n,V:r},a)=>{const[l,u]=wr({i:UL,o:SS()},pt(SS,e,"padding",""));return({Dt:c,Zt:d,fn:h,It:p})=>{let[m,x]=u(p);const{P:y}=Cs(),{_t:S,xt:C,Ct:v}=d||{},{B:w}=h,[_,b]=c("paddingAbsolute");(S||x||(p||C))&&([m,x]=l(p));const E=!r&&(b||v||x);if(E){const T=!_||!t&&!y,D=m.r+m.l,L=m.t+m.b,R={[UC]:T&&!w?-D:0,[VC]:T?-L:0,[FC]:T&&w?-D:0,top:T?-m.t:0,right:T?w?-m.r:"auto":0,left:T?w?"auto":-m.l:0,[Bh]:T&&`calc(100% + ${D}px)`},M={[BC]:T?m.t:0,[$C]:T?m.r:0,[HC]:T?m.b:0,[zC]:T?m.l:0};Tc(t||n,R),Tc(n,M),It(a,{ln:m,_n:!T,F:t?M:It({},R,M)})}return{dn:E}}},HD=(e,t)=>{const n=Cs(),{vt:r,ln:a,L:l,V:u,Qt:c,gt:d,bt:h,wt:p,un:m}=e,{P:x}=n,y=h&&u,S=pt(OC,0),C={display:()=>!1,direction:Y=>Y!=="ltr",flexDirection:Y=>Y.endsWith("-reverse"),writingMode:Y=>Y!=="horizontal-tb"},v=or(C),w={i:WC,o:{w:0,h:0}},_={i:Fd,o:{}},b=Y=>{p(fk,!y&&Y)},k=()=>Ss(l,v),E=(Y,Q)=>{const X=!or(Y).length,K=Q?!0:v.some((Ge=>{const Xe=Y[Ge];return el(Xe)&&C[Ge](Xe)}));if(X||!K||!QL(l))return{T:{x:0,y:0},k:{x:1,y:1}};b(!0);const P=Cr(d),J=tn(c,Na,(Ge=>{const Xe=Cr(d);Ge.isTrusted&&Xe.x===P.x&&Xe.y===P.y&&ok(Ge)}),{I:!0,A:!0}),ne=p(oD,!0);vs(d,{x:0,y:0}),ne();const ce=Cr(d),ae=ih(d);vs(d,{x:ae.w,y:ae.h});const Ee=Cr(d),ve={x:Ee.x-ce.x,y:Ee.y-ce.y};vs(d,{x:-ae.w,y:-ae.h});const Le=Cr(d),Me={x:Le.x-ce.x,y:Le.y-ce.y},ke={x:Ii(ve.x)>=Ii(Me.x)?Ee.x:Le.x,y:Ii(ve.y)>=Ii(Me.y)?Ee.y:Le.y};return vs(d,P),zx((()=>J())),{T:ce,k:ke}},T=(Y,Q)=>{const X=cr.devicePixelRatio%1!==0?1:0,K={w:S(Y.w-Q.w),h:S(Y.h-Q.h)};return{w:K.w>X?K.w:0,h:K.h>X?K.h:0}},D=(Y,Q)=>{const X=(K,P,J,ne)=>{const ce=K===Qs?Jr:SD(K),ae=Bo(K),Ee=Bo(J);return!P&&!ne?Jr:ae&&Ee?Qs:ae?P&&ne?ce:P?Qs:Jr:P?ce:Ee&&ne?Qs:Jr};return{x:X(Q.x,Y.x,Q.y,Y.y),y:X(Q.y,Y.y,Q.x,Y.x)}},L=Y=>{const Q=K=>[Qs,Jr,Na].map((P=>$(Qg(P),K))),X=Q(!0).concat(Q()).join(" ");p(X),p(or(Y).map((K=>$(Y[K],K==="x"))).join(" "),!0)},[R,M]=wr(w,pt(Jx,l)),[W,z]=wr(w,pt(ih,l)),[H,I]=wr(w),[U]=wr(_),[V,Z]=wr(w),[ee]=wr(_),[F]=wr({i:(Y,Q)=>zh(Y,Q,rh(Go(or(Y),or(Q)))),o:{}}),[O,B]=wr({i:(Y,Q)=>Fd(Y.T,Q.T)&&Fd(Y.k,Q.k),o:ck()}),q=tl(ty),$=(Y,Q)=>`${Q?rD:sD}${FL(Y)}`;return({Dt:Y,Zt:Q,fn:X,It:K},{dn:P})=>{const{_t:J,Ht:ne,xt:ce,Ct:ae,ft:Ee,Et:ve}=Q||{},Le=q&&q.R(e,t,X,n,Y),{X:Me,Y:ke,W:Ge}=Le||{},[Xe,Se]=_D(Y,n),[Ie,it]=Y("overflow"),ge=Bo(Ie.x),Fe=Bo(Ie.y),He=J||P||ce||ae||ve||Se;let ie=M(K),xe=z(K),se=I(K),he=Z(K);if(Se&&x&&p(mk,!Xe),He){Xx(r,$i,Vd)&&b(!0);const fn=ke&&ke(),[Kn]=ie=R(K),[_e]=xe=W(K),rt=ik(l),fe=y&&XL(m()),we={w:S(_e.w+Kn.w),h:S(_e.h+Kn.h)},Be={w:S((fe?fe.w:rt.w+S(rt.w-_e.w))+Kn.w),h:S((fe?fe.h:rt.h+S(rt.h-_e.h))+Kn.h)};fn&&fn(),he=V(Be),se=H(T(we,Be),K)}const[Pe,qe]=he,[Ke,et]=se,[ot,ue]=xe,[$e,ut]=ie,[ct]=U({x:Ke.w>0,y:Ke.h>0}),cn=ge&&Fe&&(ct.x||ct.y)||ge&&ct.x&&!ct.y||Fe&&ct.y&&!ct.x,Xt=P||ae||ve||ut||ue||qe||et||it||Se||He||ne&&y,[rn]=Y("update.flowDirectionStyles"),[On,ye]=F(rn?rn(l)||{}:k(),K),Ye=ae||Ee||ye||K,[We,ze]=Ye?O(E(On,!!rn),K):B();let tt=D(ct,Ie);b(!1),Xt&&(L(tt),tt=wD(l,ct),Ge&&Me&&(Me(tt,ot,$e),Tc(l,Ge(tt))));const[Lt,hn]=ee(tt);return sh(r,$i,Vd,cn),sh(a,Yg,Vd,cn),It(t,{rn:Lt,Vt:{x:Pe.w,y:Pe.h},Rt:{x:Ke.w,y:Ke.h},j:ct,Tt:JL(We,Ke)}),{en:hn,nn:qe,sn:et,cn:ze||et}}},FD=e=>{const[t,n,r]=BD(e),a={ln:{t:0,r:0,b:0,l:0},_n:!1,F:{[UC]:0,[VC]:0,[FC]:0,[BC]:0,[$C]:0,[HC]:0,[zC]:0},Vt:{x:0,y:0},Rt:{x:0,y:0},rn:{x:Jr,y:Jr},j:{x:!1,y:!1},Tt:ck()},{dt:l,gt:u,V:c,St:d}=t,{P:h,M:p}=Cs(),m=!h&&(p.x||p.y),x=[$D(t),zD(t,a),HD(t,a)];return[n,y=>{const S={},v=m&&Cr(u),w=v&&d();return Wt(x,(_=>{It(S,_(y,S)||{})})),vs(u,v),w&&w(),c||vs(l,0),S},a,t,r]},UD=(e,t,n,r)=>{let a=!1;const l={Kt:!1,pn:!1},u=Hp(t,{}),[c,d,h,p,m]=FD(e),[x,y,S]=DD(p,h,u,(k=>{b({},k)})),[C,v,,w]=PD(e,t,l,S,h,p,r),_=k=>or(k).some((E=>!!k[E])),b=(k,E)=>{const{Kt:T,pn:D}=l;if(D||T&&a)return!1;const{vn:L,It:R,zt:M}=k,W=L||{},z=!!R||!a,H={Dt:Hp(t,W,z),vn:W,It:z},I=E||y(It({},H,{zt:M})),U=d(It({},H,{fn:S,Zt:I}));v(It({},H,{Zt:I,tn:U}));const V=_(I),Z=_(U),ee=V||Z||!qx(W)||z;return a=!0,ee&&n(k,{Zt:I,tn:U}),ee};return[()=>{const{an:k,gt:E,St:T}=p,D=Cr(k),L=[x(),c(),C(),()=>{l.pn=!0}],R=T();return vs(E,D),R(),pt(kr,L)},b,k=>{const E=l.Kt;l.Kt=k,!k&&E!==k&&b({It:!0,zt:!0})},()=>{v({Dt:Hp(t,{},!1),vn:{},It:!1})},()=>({gn:l,hn:S,bn:h}),{yn:p,wn:w},m]},ny=new WeakMap,VD=(e,t)=>{ny.set(e,t)},WD=e=>{ny.delete(e)},wk=e=>ny.get(e),ts=(e,t,n)=>{const{tt:r}=Cs(),a=th(e),l=a?e:e.target,u=wk(l);if(t&&!u){const c=[],d={},h=z=>{const H=KC(z),I=tl(tD);return I?I(H,!0):H},p=It({},r(),h(t)),[m,x,y]=Kg(),[S,C,v]=Kg(n),w=(z,H)=>{v(z,H),y(z,H)},[_,b,k,E,T,D,L]=UD(e,p,(({vn:z,It:H},{Zt:I,tn:U})=>{const{_t:V,Ct:Z,$t:ee,xt:F,Ht:O,ft:B}=I,{nn:q,sn:$,en:Y,cn:Q}=U;w("updated",[W,{updateHints:{sizeChanged:!!V,directionChanged:!!Z,heightIntrinsicChanged:!!ee,overflowEdgeChanged:!!q,overflowAmountChanged:!!$,overflowStyleChanged:!!Y,scrollCoordinatesChanged:!!Q,contentMutation:!!F,hostMutation:!!O,appear:!!B},changedOptions:z||{},force:!!H}])}),(z=>w("scroll",[W,z]))),R=z=>{const{gn:H}=T(),{pn:I}=H;I||(WD(l),kr(c),w("destroyed",[W,z]),x(),C())},W={options(z,H){if(z){const I=H?r():{},U=yk(p,It(I,h(z)));qx(U)||(It(p,U),b({vn:U}))}return It({},p)},on:S,off:(z,H)=>{z&&H&&C(z,H)},state(){const{gn:z,hn:H,bn:I}=T(),{pn:U,Kt:V}=z,{B:Z}=H,{Vt:ee,Rt:F,rn:O,j:B,ln:q,_n:$,Tt:Y}=I;return It({},{overflowEdge:ee,overflowAmount:F,overflowStyle:O,hasOverflow:B,scrollCoordinates:{start:Y.T,end:Y.k},padding:q,paddingAbsolute:$,directionRTL:Z,sleeping:V,destroyed:U})},elements(){const{dt:z,vt:H,ln:I,L:U,ht:V,gt:Z,Qt:ee}=D.yn,{jt:F,Jt:O}=D.wn,B=$=>{const{kt:Y,Pt:Q,Lt:X}=$;return{scrollbar:X,track:Q,handle:Y}},q=$=>{const{Xt:Y,Yt:Q}=$,X=B(Y[0]);return It({},X,{clone:()=>{const K=B(Q());return E(),K}})};return It({},{target:z,host:H,padding:I||U,viewport:U,content:V||U,scrollOffsetElement:Z,scrollEventElement:ee,scrollbarHorizontal:q(F),scrollbarVertical:q(O)})},update:z=>b({It:z,zt:!0}),destroy:pt(R,!1),sleep:k,plugin:z=>d[or(z)[0]]};return ln(c,[L]),VD(l,W),hk(uk,ts,[W,m,d]),OD(D.yn.bt,!a&&e.cancel)?(R(!0),W):(ln(c,_()),w("initialized",[W]),W.update(),W)}return u};ts.plugin=e=>{const t=Wr(e),n=t?e:[e],r=n.map((a=>hk(a,ts)[0]));return ZL(n),t?r:r[0]};ts.valid=e=>{const t=e&&e.elements,n=as(t)&&t();return jc(n)&&!!wk(n.target)};ts.env=()=>{const{U:e,M:t,P:n,J:r,ot:a,st:l,K:u,Z:c,tt:d,nt:h}=Cs();return It({},{scrollbarsSize:e,scrollbarsOverlaid:t,scrollbarsHiding:n,scrollTimeline:r,staticDefaultInitialization:a,staticDefaultOptions:l,getDefaultInitialization:u,setDefaultInitialization:c,getDefaultOptions:d,setDefaultOptions:h})};ts.nonce=ND;ts.trustedTypePolicy=qL;const GD=()=>{if(typeof window>"u"){const h=()=>{};return[h,h]}let e,t;const n=window,r=typeof n.requestIdleCallback=="function",a=n.requestAnimationFrame,l=n.cancelAnimationFrame,u=r?n.requestIdleCallback:a,c=r?n.cancelIdleCallback:l,d=()=>{c(e),l(t)};return[(h,p)=>{d(),e=u(r?()=>{d(),t=a(h)}:h,typeof p=="object"?p:{timeout:2233})},d]},qD=e=>{const{options:t,events:n,defer:r}=e||{},[a,l]=N.useMemo(GD,[]),u=N.useRef(null),c=N.useRef(r),d=N.useRef(t),h=N.useRef(n);return N.useEffect(()=>{c.current=r},[r]),N.useEffect(()=>{const{current:p}=u;d.current=t,ts.valid(p)&&p.options(t||{},!0)},[t]),N.useEffect(()=>{const{current:p}=u;h.current=n,ts.valid(p)&&p.on(n||{},!0)},[n]),N.useEffect(()=>()=>{var p;l(),(p=u.current)==null||p.destroy()},[]),N.useMemo(()=>[p=>{const m=u.current;if(ts.valid(m))return;const x=c.current,y=d.current||{},S=h.current||{},C=()=>u.current=ts(p,y,S);x?a(C,x):C()},()=>u.current],[])},KD=(e,t)=>{const{element:n="div",options:r,events:a,defer:l,children:u,...c}=e,d=n,h=N.useRef(null),p=N.useRef(null),[m,x]=qD({options:r,events:a,defer:l});return N.useEffect(()=>{const{current:y}=h,{current:S}=p;if(!y)return;const C=y;return m(n==="body"?{target:C,cancel:{body:null}}:{target:C,elements:{viewport:S,content:S}}),()=>{var v;return(v=x())==null?void 0:v.destroy()}},[m,n]),N.useImperativeHandle(t,()=>({osInstance:x,getElement:()=>h.current}),[]),bs.createElement(d,{"data-overlayscrollbars-initialize":"",ref:h,...c},n==="body"?u:bs.createElement("div",{"data-overlayscrollbars-contents":"",ref:p},u))},YD=N.forwardRef(KD),Ze=N.forwardRef(({options:e,horizontal:t,both:n,onScrollbarGesture:r,...a},l)=>{const u=t||n,c=N.useRef(r);c.current=r;const d=N.useRef(null),h=N.useMemo(()=>({initialized:m=>{var _;(_=d.current)==null||_.call(d);const x=m.elements().scrollbarVertical,y=()=>{const b=x.handle.getBoundingClientRect(),k=x.track.getBoundingClientRect();return b.height===0||k.height===0?null:Math.max(0,k.bottom-b.bottom)};let S=null;const C=()=>{var b;(b=c.current)==null||b.call(c,"up",y()),S==null||S()},v=b=>{var k;if(b.buttons===0){C();return}(k=c.current)==null||k.call(c,"move",y())},w=()=>{var b;(b=c.current)==null||b.call(c,"down",y()),S==null||S(),window.addEventListener("pointermove",v),window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C),S=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C),S=null}};x.track.addEventListener("pointerdown",w),d.current=()=>{x.track.removeEventListener("pointerdown",w),S==null||S()}}}),[]);return N.useEffect(()=>()=>{var p;return(p=d.current)==null?void 0:p.call(d)},[]),i.jsx(YD,{ref:l,events:h,options:{overflow:{x:u?"scroll":"hidden",y:n?"scroll":t?"hidden":"scroll"},scrollbars:{autoHide:u?"leave":"move",autoHideDelay:u?1500:600,clickScroll:"instant"},update:{elementEvents:[[":scope","mouseenter"]]},...e},...a})});Ze.displayName="ScrollArea";const OS=e=>{let t;const n=new Set,r=(h,p)=>{const m=typeof h=="function"?h(t):h;if(!Object.is(m,t)){const x=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(y=>y(t,x))}},a=()=>t,c={setState:r,getState:a,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h))},d=t=e(r,a,c);return c},XD=(e=>e?OS(e):OS),QD=e=>e;function JD(e,t=QD){const n=bs.useSyncExternalStore(e.subscribe,bs.useCallback(()=>t(e.getState()),[e,t]),bs.useCallback(()=>t(e.getInitialState()),[e,t]));return bs.useDebugValue(n),n}const IS=e=>{const t=XD(e),n=r=>JD(t,r);return Object.assign(n,t),n},Gn=(e=>e?IS(e):IS);function ZD(){if(typeof document>"u")return"";const e=Array.from(document.scripts).find(a=>{const l=new URL(a.src,window.location.href).pathname;return l.includes("/assets/")||l.endsWith("/src/main.tsx")});if(!e)return"";const t=new URL(e.src,window.location.href).pathname,n=t.includes("/assets/")?"/assets/":"/src/",r=t.indexOf(n);return r>0?t.slice(0,r):""}const Ck=ZD();function ni(e){return e.startsWith("/")?`${Ck}${e}`||"/":e}async function Ce(e,t={}){const n=localStorage.getItem("openfox_token"),r={...t.headers instanceof Headers?Object.fromEntries(t.headers.entries()):t.headers,...n?{"x-session-token":n}:{}};return fetch(ni(e),{...t,headers:r})}async function MS(e,t,n){try{return(await Ce(`/api/sessions/${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t,...n!==void 0?{content:n}:{}})})).ok}catch{return!1}}async function kk(e,t,n){try{const r=await Ce(`/api/sessions/${e}/fork`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t,...n!==void 0?{title:n}:{}})});return r.ok?await r.json():null}catch{return null}}const Ae={GLOBAL_INSTRUCTIONS:"global_instructions",NOTIFICATION_SETTINGS:"notification_settings",DISPLAY_SHOW_THINKING:"display.showThinking",DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT:"display.showVerboseToolOutput",DISPLAY_SHOW_STATS:"display.showStats",DISPLAY_SHOW_AGENT_DEFINITIONS:"display.showAgentDefinitions",DISPLAY_SHOW_WORKFLOW_BARS:"display.showWorkflowBars",DISPLAY_SHOW_SYNTAX_HIGHLIGHTING:"display.showSyntaxHighlighting",DISPLAY_THEME:"display.theme",DISPLAY_USER_PRESETS:"display.userPresets",DISPLAY_FOLLOW_SYSTEM_THEME:"display.followSystemTheme",DISPLAY_SYSTEM_THEME_PREFS:"display.systemThemePrefs",DISPLAY_SHOW_OPEN_IN_EDITOR:"display.showOpenInEditorLinks",DISPLAY_SHOW_CHANGELOG_ON_UPDATE:"display.showChangelogOnUpdate",DISPLAY_MAX_VISIBLE_ITEMS:"display.maxVisibleItems",DISPLAY_CUSTOM_CSS:"display.customCss",DISPLAY_TERMINAL_FONT:"display.terminalFont",LLM_DYNAMIC_SYSTEM_PROMPT:"llm.dynamicSystemPrompt",CACHE_WARMING:"cache.warming",KEYBINDINGS:"keybindings",RETRY_PATTERNS:"agent.retryPatterns",SKILLS_DIRECTORIES:"skills.directories",SEARCH_ENGINE:"search.engine",SEARCH_TAVILY_API_KEY:"search.tavilyApiKey",SEARCH_SEARXNG_URL:"search.searxngUrl",SEARCH_SEARXNG_API_KEY:"search.searxngApiKey",TOOLS_USE_RTK:"tools.useRtk",TOOLS_SHELL:"tools.shell",CONFIRM_ON_WORKSPACE_ACTIONS:"tools.confirmOnWorkspaceActions",FEATURES_PER_SESSION_MCP:"features.perSessionMcp",PROXY_URL:"network.proxyUrl",DEFAULT_AGENT:"agent.defaultAgent"};function pd(e,t){return n=>({loading:{...n.loading,[e]:t}})}function PS(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const ry=[Ae.DISPLAY_SHOW_THINKING,Ae.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,Ae.DISPLAY_SHOW_STATS,Ae.DISPLAY_SHOW_AGENT_DEFINITIONS,Ae.DISPLAY_SHOW_WORKFLOW_BARS,Ae.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,Ae.DISPLAY_FOLLOW_SYSTEM_THEME,Ae.DISPLAY_SHOW_OPEN_IN_EDITOR,Ae.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,Ae.DISPLAY_MAX_VISIBLE_ITEMS,Ae.DISPLAY_TERMINAL_FONT];function Pa(){return{showThinking:Vt(e=>e.settings[Ae.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:Vt(e=>e.settings[Ae.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:Vt(e=>e.settings[Ae.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:Vt(e=>e.settings[Ae.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:Vt(e=>e.settings[Ae.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:Vt(e=>e.settings[Ae.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true",maxVisibleItems:Number(Vt(e=>e.settings[Ae.DISPLAY_MAX_VISIBLE_ITEMS]??"300"))}}const Vt=Gn(e=>({settings:{},loading:{},getSetting:async t=>{e(pd(t,!0));try{const r=await(await Ce(`/api/settings/${t}`)).json();return e(PS(t,r.value??"")),r.value}catch{return e(pd(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const r=await(await Ce(`/api/settings?keys=${encodeURIComponent(t.join(","))}`)).json();e({settings:r,loading:Object.fromEntries(t.map(a=>[a,!1]))})}catch{e({loading:Object.fromEntries(t.map(n=>[n,!1]))})}},setSetting:async(t,n)=>{e(pd(t,!0));try{const a=await(await Ce(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(PS(t,a.value??""))}catch{e(pd(t,!1))}}})),tc=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:ry,SETTINGS_KEYS:Ae,useDisplaySettings:Pa,useSettingsStore:Vt},Symbol.toStringTag,{value:"Module"}));function eR(){const[e,t]=N.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=N.useRef(window.innerHeight);return N.useEffect(()=>{const r=window.visualViewport;if(!r)return;const a=()=>{const l=r.offsetTop,u=r.height,c=n.current-u>100;t({offsetTop:l,height:u,keyboardVisible:c})};return a(),r.addEventListener("resize",a),r.addEventListener("scroll",a),()=>{r.removeEventListener("resize",a),r.removeEventListener("scroll",a)}},[]),e}function tR(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function Wd(){if(typeof crypto<"u"&&crypto.randomUUID)try{return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}class nR{constructor(t){Ne(this,"ws",null);Ne(this,"handlers",new Set);Ne(this,"statusHandler",null);Ne(this,"baseUrl");Ne(this,"isReconnecting",!1);Ne(this,"connectingPromise",null);Ne(this,"lastCloseCode",0);Ne(this,"reconnectAttempts",0);Ne(this,"manualReconnectScheduled",!1);Ne(this,"pwaRecoveryAttempted",!1);this.baseUrl=t}getUrl(){const t=localStorage.getItem("openfox_token");if(t){const n=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${n}token=${encodeURIComponent(t)}`}return this.baseUrl}setToken(t){localStorage.setItem("openfox_token",t)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(t){this.statusHandler=t}connect(){var t,n,r;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((n=this.ws)==null?void 0:n.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((r=this.ws)==null?void 0:r.readyState)===WebSocket.CONNECTING?(console.warn("[WS CLIENT] Connection already in progress, returning existing promise"),this.connectingPromise):(this.connectingPromise=new Promise((a,l)=>{try{const u=this.getUrl();this.ws=new WebSocket(u);const c=setTimeout(()=>{var d;((d=this.ws)==null?void 0:d.readyState)===WebSocket.CONNECTING&&(this.ws.close(),l(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var d;clearTimeout(c),this.isReconnecting=!1,this.reconnectAttempts=0,this.connectingPromise=null,(d=this.statusHandler)==null||d.call(this,"connected"),a()},this.ws.onclose=d=>{var h,p,m;clearTimeout(c),this.lastCloseCode=d.code,((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(p=this.statusHandler)==null||p.call(this,"disconnected"),l(new Error(`Connection closed: ${d.code}`))):(this.connectingPromise=null,(m=this.statusHandler)==null||m.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=d=>{clearTimeout(c),console.error("WebSocket error:",d),this.connectingPromise=null,l(d)},this.ws.onmessage=d=>{try{const h=JSON.parse(d.data);tR(h)&&this.handlers.forEach(p=>p(h))}catch(h){console.error("Failed to parse WebSocket message:",h)}}}catch(u){this.connectingPromise=null,l(u)}}),this.connectingPromise)))}async recoverPwaStuckConnection(){if(this.pwaRecoveryAttempted||!window.matchMedia("(display-mode: standalone)").matches||!("serviceWorker"in navigator))return;this.pwaRecoveryAttempted=!0;const n=await navigator.serviceWorker.getRegistrations();n.length!==0&&(console.warn("[WS] PWA mode detected with stale service worker — unregistering and reloading"),await Promise.all(n.map(r=>r.unregister())),window.location.reload())}attemptReconnect(){var r;if(this.lastCloseCode===4e3&&this.hasToken()){console.warn("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(r=this.statusHandler)==null||r.call(this,"reconnecting");const n=Math.min(1e3*Math.pow(2,this.reconnectAttempts||0),3e4);this.reconnectAttempts=(this.reconnectAttempts||0)+1,setTimeout(()=>{this.isReconnecting=!1,this.manualReconnectScheduled=!1,this.connect().catch(()=>{this.reconnectAttempts>=3&&this.recoverPwaStuckConnection()})},n)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{this.recoverPwaStuckConnection()})}disconnect(){this.isReconnecting=!1,this.reconnectAttempts=0,this.ws&&(this.ws.close(),this.ws=null)}resetReconnectAttempts(){this.reconnectAttempts=0}send(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const r=Wd(),a={id:r,type:t,payload:n};return this.ws.send(JSON.stringify(a)),r}subscribe(t){return this.handlers.add(t),()=>this.handlers.delete(t)}get isConnected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}}const rR=window.location.protocol==="https:"?"wss:":"ws:";let Jg=window.location.port;Jg||(Jg=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const sR=`${rR}//${window.location.hostname}:${Jg}${ni("/ws")}`,Pt=new nR(sR),iR=3e4;function jk(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"lmstudio":return"LM Studio";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"unknown":return"Other"}}const nn=Gn((e,t)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,platform:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>{e({loading:!0,error:null});try{const n=await Ce("/api/config");if(!n.ok)throw new Error("Failed to fetch config");const r=await n.json(),a=r.platform&&typeof r.platform=="object"?{isWSL:!!r.platform.isWSL,wslDistro:String(r.platform.wslDistro??"")}:null;e({version:r.version,model:r.model,maxContext:r.maxContext,llmUrl:r.llmUrl,llmStatus:r.llmStatus,backend:r.backend,providers:r.providers??[],activeProviderId:r.activeProviderId??null,defaultModelSelection:r.defaultModelSelection??null,platform:a,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const n=await Ce("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const r=await n.json();e({model:r.model,llmStatus:r.llmStatus,backend:r.backend})}catch(n){console.error("Failed to refresh model:",n)}},activateProvider:async n=>{const{activeProviderId:r,providers:a}=t();if(n===r)return!0;e({activating:!0,error:null});try{const l=await Ce(`/api/providers/${n}/activate`,{method:"POST"});if(!l.ok){const c=await l.json();throw new Error(c.error??"Failed to activate provider")}const u=await l.json();return e({activeProviderId:u.activeProviderId,model:u.model,backend:u.backend,providers:a.map(c=>({...c,isActive:c.id===u.activeProviderId})),activating:!1}),!0}catch(l){return e({error:l instanceof Error?l.message:"Failed to switch provider",activating:!1}),!1}},setDefaultModel:async(n,r)=>{const{providers:a}=t();try{const l=await Ce("/api/default-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})});if(!l.ok)return!1;const u=await l.json();return e({activeProviderId:n,model:r,defaultModelSelection:u.defaultModelSelection,providers:a.map(c=>({...c,isActive:c.id===n}))}),!0}catch{return!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const r=await Ce(`/api/providers/${n}/refresh`,{method:"POST"});if(!r.ok){const u=await r.json();throw new Error(u.error??"Failed to refresh models")}const a=await r.json(),{providers:l}=t();return e({providers:l.map(u=>u.id===n?{...u,models:a.models,status:a.status}:u),activating:!1}),!0}catch(r){return e({error:r instanceof Error?r.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:n,refreshModel:r}=t();if(n)return;const a=setInterval(()=>{r()},iR);e({autoRefreshInterval:a})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:r}=t();return n.find(a=>a.id===r)},getModelContext:n=>{const{providers:r,activeProviderId:a}=t(),l=r.find(c=>c.id===a);if(!l)return 2e5;const u=l.models.find(c=>c.id===n);return(u==null?void 0:u.contextWindow)??2e5}})),Jt=Gn((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const r=await(await Ce("/api/projects")).json();e({projects:r.projects??[],loading:!1})}catch(n){console.error("Failed to load projects:",n),e({loading:!1})}},createProject:async(n,r)=>{try{const a=await Ce("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:r})});if(!a.ok){const u=await a.json().catch(()=>({}));return{error:{code:u.code||"UNKNOWN",path:u.path,message:u.error}}}const l=await a.json();return await t().listProjects(),l.project}catch{return null}},loadProject:async n=>{try{const r=await Ce(`/api/projects/${n}`);if(!r.ok)return null;const a=await r.json();return e({currentProject:a.project}),t().projects.length===0&&await t().listProjects(),a.project}catch{return null}},updateProject:async(n,r)=>{var a;try{const l=await Ce(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!l.ok)return null;const u=await l.json();return((a=t().currentProject)==null?void 0:a.id)===n&&e({currentProject:u.project}),await t().listProjects(),u.project}catch{return null}},deleteProject:async n=>{var r;try{return(await Ce(`/api/projects/${n}`,{method:"DELETE"})).ok?(await t().listProjects(),((r=t().currentProject)==null?void 0:r.id)===n&&e({currentProject:null}),!0):!1}catch{return!1}},toggleStar:async(n,r)=>{var a;try{const l=await Ce(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:r})});if(!l.ok)return!1;if(((a=t().currentProject)==null?void 0:a.id)===n){const u=await l.json();e({currentProject:u.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}})),Ui=async(e,t,n)=>{try{const r=await Ce(t,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return r.ok?{success:!0}:{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}},Uh=async(e,t,n)=>{try{const r=await Ce(e,{method:"POST",body:n?JSON.stringify({destination:n}):void 0,headers:n?{"Content-Type":"application/json"}:void 0}),a=await r.json();return r.ok?(await t(),{success:!0}):{success:!1,error:a.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}};function Ek(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let gd=[];const bc=Gn()((e,t)=>{function n(){if(gd.length===0)return;const a=gd;gd=[],e(l=>{const u={...l.logs};for(const c of a){const d=u[c.processId]??[];u[c.processId]=[...d,{offset:d.length,content:c.content,timestamp:Date.now(),stream:c.stream}]}return{logs:u}})}const r=Ek(n);return{processes:[],logs:{},loading:!1,setProcesses:a=>e({processes:a}),addProcess:a=>e(l=>({processes:[...l.processes,a]})),updateProcess:(a,l)=>e(u=>({processes:u.processes.map(c=>c.id===a?{...c,...l}:c)})),removeProcess:a=>e(l=>({processes:l.processes.filter(u=>u.id!==a),logs:Object.fromEntries(Object.entries(l.logs).filter(([u])=>u!==a))})),stopProcess:async(a,l)=>{try{(await Ce(`/api/sessions/${l}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,l,u)=>{gd.push({processId:a,stream:l,content:u}),r()},setLogs:(a,l)=>e(u=>({logs:{...u.logs,[a]:l}})),clearLogs:a=>e(l=>({logs:{...l.logs,[a]:[]}})),handleMessage:(a,l)=>{switch(a){case"backgroundProcess.started":{const{processId:u,name:c,pid:d,status:h}=l;e(p=>({processes:[...p.processes,{id:u,sessionId:"",name:c,command:"",cwd:"",pid:d,status:h,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const u=l.processId,c=l.stream,d=l.content;t().appendLog(u,c,d);break}case"backgroundProcess.exited":{const u=l.processId,c=l.exitCode;e(d=>({processes:d.processes.map(h=>h.id===u?{...h,status:"exited",exitCode:c}:h)}));break}case"backgroundProcess.removed":{const u=l.processId;t().removeProcess(u);break}}}}}),aR={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let Gd=null;function oR(e){Gd=e}function va(){return aR}function Up(){Gd==null||Gd()}let xd=[];const Un=Gn()((e,t)=>{function n(){if(xd.length===0)return;const a=xd;xd=[],e(l=>({logs:[...l.logs,...a]}))}const r=Ek(n);return{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:a=>{t().workdir!==a&&(e({workdir:a,status:null,logs:[],config:null,loading:!0}),a&&(t().fetchStatus(),t().fetchConfig()))},fetchStatus:async()=>{const a=t().workdir;if(a)try{const u=await(await Ce(`/api/dev-server?workdir=${encodeURIComponent(a)}`)).json();e({status:u,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const a=t().workdir;if(a)try{const u=await(await Ce(`/api/dev-server/config?workdir=${encodeURIComponent(a)}`)).json();e({config:u.config??null})}catch{}},fetchLogs:async()=>{const a=t().workdir;if(a)try{const c=(await(await Ce(`/api/dev-server/logs?workdir=${encodeURIComponent(a)}`)).json()).logs.map(d=>({stream:d.stream,content:d.content,...d.type?{type:d.type}:{}}));e({logs:c})}catch{}},clearLogs:async()=>{const a=t().workdir;if(a)try{await Ce(`/api/dev-server/clear-logs?workdir=${encodeURIComponent(a)}`,{method:"POST"}),e({logs:[]})}catch{}},insertMarker:async()=>{const a=t().workdir;if(a)try{await Ce(`/api/dev-server/insert-marker?workdir=${encodeURIComponent(a)}`,{method:"POST"}),t().fetchLogs()}catch{}},start:async()=>{const a=t().workdir;if(a)try{const u=await(await Ce(`/api/dev-server/start?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u,logs:[]})}catch{}},stop:async()=>{const a=t().workdir;if(a)try{const u=await(await Ce(`/api/dev-server/stop?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u})}catch{}},restart:async()=>{const a=t().workdir;if(a)try{const u=await(await Ce(`/api/dev-server/restart?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u,logs:[]})}catch{}},saveConfig:async a=>{const l=t().workdir;if(l)try{const c=await(await Ce(`/api/dev-server/config?workdir=${encodeURIComponent(l)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();e({config:c.config??a}),t().fetchStatus()}catch{}},handleMessage:a=>{const l=t().workdir;if(l)switch(a.type){case"devServer.output":{const u=a.payload;if(u.workdir!==l)return;xd.push({stream:u.stream,content:u.content}),r();break}case"devServer.state":{const u=a.payload;if(u.workdir!==l)return;e(c=>({status:c.status?{...c.status,state:u.state,errorMessage:u.errorMessage,...u.url!==void 0?{url:u.url}:{},...u.inspectProxyPort!==void 0?{inspectProxyPort:u.inspectProxyPort}:{}}:{state:u.state,url:u.url??null,hotReload:!1,config:null,errorMessage:u.errorMessage,inspectProxyPort:u.inspectProxyPort??null}}));break}}}}}),lR=[{key:"complete",label:"Task Complete",description:"When an agent finishes its work"},{key:"waiting_for_user",label:"Waiting for Input",description:"When the agent needs your input"},{key:"phase_done",label:"Phase Done",description:"When a build phase completes successfully"},{key:"phase_blocked",label:"Phase Blocked",description:"When a build phase is blocked and needs intervention"},{key:"new_message",label:"New Message",description:"When a new assistant message starts arriving"}],cR=[{url:"/sounds/notification.mp3",label:"Notification"},{url:"/sounds/waiting-for-user.mp3",label:"Waiting for User"},{url:"/sounds/achievement.mp3",label:"Achievement"},{url:"/sounds/intervention.mp3",label:"Intervention"},{url:"/sounds/typing.mp3",label:"Typing"}],Nk={complete:"/sounds/notification.mp3",waiting_for_user:"/sounds/waiting-for-user.mp3",phase_done:"/sounds/achievement.mp3",phase_blocked:"/sounds/intervention.mp3",new_message:"/sounds/typing.mp3"},Mi={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},Tk={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},Zg={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...Mi},waiting_for_user:{...Mi},phase_done:{...Mi},phase_blocked:{...Mi},new_message:{...Tk}},agentOverrides:{}};function Ak(e,t,n){var l;const r=e.events[t];if(!n)return r;const a=(l=e.agentOverrides[n])==null?void 0:l[t];return a?{soundEnabled:a.soundEnabled??r.soundEnabled,browserNotification:a.browserNotification??r.browserNotification,customSoundUrl:a.customSoundUrl!==void 0?a.customSoundUrl:r.customSoundUrl}:r}const Sa=Gn((e,t)=>({settings:Zg,loaded:!1,load:()=>{Vt.getState().getSetting(Ae.NOTIFICATION_SETTINGS);const r=Vt.subscribe(l=>{const u=l.settings[Ae.NOTIFICATION_SETTINGS];if(u!==void 0)try{const c=JSON.parse(u);e({settings:BS(c),loaded:!0})}catch{e({loaded:!0})}}),a=Vt.getState().settings[Ae.NOTIFICATION_SETTINGS];if(a)try{const l=JSON.parse(a);e({settings:BS(l),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),Vp(n)},updateEvent:(n,r)=>{const a=t().settings,l={...a,events:{...a.events,[n]:{...a.events[n],...r}}};e({settings:l}),Vp(l)},updateAgentOverride:(n,r,a)=>{var d;const l=t().settings,u={...l.agentOverrides};if(a===null){if(u[n]){const h={...u[n]};delete h[r],Object.keys(h).length===0?delete u[n]:u[n]=h}}else u[n]={...u[n],[r]:{...((d=u[n])==null?void 0:d[r])??{},...a}};const c={...l,agentOverrides:u};e({settings:c}),Vp(c)}}));function Vp(e){Vt.getState().setSetting(Ae.NOTIFICATION_SETTINGS,JSON.stringify(e))}function BS(e){var t,n,r,a,l;return{soundEnabled:e.soundEnabled??Zg.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??Zg.browserNotificationEnabled,events:{complete:{...Mi,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...Mi,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...Mi,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...Mi,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...Tk,...(l=e.events)==null?void 0:l.new_message}},agentOverrides:e.agentOverrides??{}}}const $S=new Map;function uR(e){let t=$S.get(e);return t||(t=new Audio(ni(e)),t.volume=.5,$S.set(e,t)),t}let Lk=typeof Notification<"u"?Notification.permission:"denied";function dR(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(Lk=e,e))}const hR={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},fR={complete:"The agent has finished its work.",waiting_for_user:"The agent needs your input to continue.",phase_done:"The build phase completed successfully.",phase_blocked:"The build phase is blocked and needs intervention.",new_message:"A new assistant message is arriving."};function mR(e){typeof Notification>"u"||Lk==="granted"&&(document.hasFocus()||new Notification(hR[e],{body:fR[e],icon:ni("/fox.svg"),tag:`openfox-${e}`}))}function Vc(e,t){const{settings:n}=Sa.getState(),r=Ak(n,e,t);if(n.soundEnabled&&r.soundEnabled){const a=r.customSoundUrl??Nk[e],l=uR(a);l.currentTime=0,l.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&mR(e)}const pR=e=>Vc("complete",e),gR=e=>Vc("phase_done",e),xR=e=>Vc("phase_blocked",e),Wp=e=>Vc("waiting_for_user",e),yR=e=>Vc("new_message",e),zS=new Map;function Lo(e,t){var l;const n=t===((l=e.currentSession)==null?void 0:l.id)?e.currentSession:null,r=e.sessions.find(u=>u.id===t),a=(n==null?void 0:n.mode)??(r==null?void 0:r.mode);return a==="planner"?"planner":a==="builder"?"build":"planner"}function bR(e,t){if(e.type==="chat.done"){const n=e.payload,r=Lo(t,e.sessionId),a=n.agentType??r;n.reason==="complete"&&pR(a),n.reason==="waiting_for_user"&&Wp(a);return}if(e.type==="chat.path_confirmation"){const n=Lo(t,e.sessionId);Wp(n);return}if(e.type==="session.confirmation_pending"){const n=Lo(t,e.sessionId);Wp(n);return}if(e.type==="task.completed"){const n=Lo(t,e.sessionId);gR(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=zS.get(e.sessionId)??null;if(zS.set(e.sessionId,n.phase),r===n.phase)return;const a=Lo(t,e.sessionId);n.phase==="blocked"&&xR(a)}}const Ac=Gn(e=>({servers:[],setServers:t=>e({servers:t}),fetchServers:async()=>{try{const t=await Ce("/api/mcp/servers");if(!t.ok)return;const r=((await t.json()).servers??[]).sort((a,l)=>a.name.localeCompare(l.name));e({servers:r})}catch{}}})),Gp=new Set;function gn(e,t){return t!==null&&e.sessionId===t}function vR(e,t,n){return e.id!==void 0||gn(e,t)||n===!0&&e.sessionId!==void 0}function _R(e,t){return e.includes(t)?e:[...e,t]}function HS(e,t){return e.filter(n=>n!==t)}function SR(e,t){const n=e.find(l=>l.id===t.id),r=t.messageCount??t.messages.length,a=n?{...n,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:r,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(l=>l.status.type==="passed").length}:{id:t.id,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(l=>l.status.type==="passed").length,messageCount:r};return n?e.map(l=>l.id===t.id?a:l):[a,...e]}function qp(e,t){const n=e.findIndex(r=>r.callId===t.callId);if(n>=0){const r=[...e];return r[n]=t,r}return[...e,t]}function wR(e,t,n){return e.map(r=>{const a=(n==null?void 0:n.id)===r.id?n:null,l=t.find(u=>u.id===r.id);return{...r,title:r.title??(l==null?void 0:l.title),mode:(a==null?void 0:a.mode)??(l==null?void 0:l.mode)??r.mode,phase:(a==null?void 0:a.phase)??(l==null?void 0:l.phase)??r.phase,isRunning:r.isRunning&&(l==null?void 0:l.isRunning)!==!1,messageCount:r.messageCount,recentUserPrompts:r.recentUserPrompts}})}function FS(e,t,n,r){var c;const a=e.sessionId,l=(c=n().currentSession)==null?void 0:c.id,u=a&&a!==l;if(t(d=>({sessions:d.sessions.map(h=>h.id===a?r(h):h)})),!u){const d=n().currentSession;if(d){const h=r(d);t(()=>({currentSession:h}))}}}function US(e,t,n){var c,d,h,p,m,x,y,S,C,v,w,_,b,k,E,T,D,L,R,M,W,z,H;const r=n();bR(e,r);const a=((c=r.currentSession)==null?void 0:c.id)??null,l=()=>{const I=e.sessionId;!I||I===a||t(U=>({unreadSessionIds:_R(U.unreadSessionIds,I)}))},u=(I,U,V)=>({messages:I.messages.map(Z=>Z.id===U?V(Z):Z)});switch(e.type){case"session.state":{const I=e.payload;if(!vR(e,a,r.pendingSessionCreate))break;const U=n().pendingSessionCreate===!0,V=I.pendingConfirmations??[],Z=I.session.id,ee={...n().crossSessionConfirmations};delete ee[Z],t({currentSession:I.session,sessions:SR(n().sessions,I.session),unreadSessionIds:HS(n().unreadSessionIds,Z),messages:I.messages,hiddenCount:I.hiddenCount??0,currentTodos:[],pendingPathConfirmations:V,crossSessionConfirmations:ee,sessionsWithPendingConfirmations:Object.keys(ee),pendingQuestions:I.pendingQuestions??[],activeWorkflowExecution:I.activeWorkflowExecution??null,...U?{pendingSessionCreate:I.session.id}:{}});break}case"session.list":{const I=e.payload;t(U=>({sessions:wR(I.sessions,U.sessions,U.currentSession)}));break}case"session.created":{const I=e.payload;t(U=>({sessions:U.sessions.some(V=>V.id===I.session.id)?U.sessions.map(V=>V.id===I.session.id?{...V,...I.session}:V):[I.session,...U.sessions]}));break}case"session.deleted":{const I=e.payload;t(U=>({unreadSessionIds:HS(U.unreadSessionIds,I.sessionId)})),n().listSessions();break}case"session.deletedAll":{n().listSessions();break}case"session.running":{const I=e.payload;FS(e,t,n,U=>({...U,isRunning:I.isRunning})),I.isRunning||t({abortInProgress:!1,queuedMessages:[]}),I.isRunning&&t({restoredInput:null});break}case"chat.message":{if(!gn(e,((d=n().currentSession)==null?void 0:d.id)??null)){l();break}const I=e.payload;t(U=>{if(U.messages.some(Z=>Z.id===I.message.id))return U;const V=I.message.role==="user";return{messages:[...U.messages,I.message],sessions:U.sessions.map(Z=>Z.id===e.sessionId&&V?{...Z,messageCount:Z.messageCount+1}:Z)}});break}case"chat.message_updated":{if(!gn(e,((h=n().currentSession)==null?void 0:h.id)??null)){l();break}const I=e.payload,U=n().messages.find(V=>V.id===I.messageId);I.updates.isStreaming===!1&&(U==null||U.isStreaming),t(V=>({messages:V.messages.map(Z=>Z.id===I.messageId?{...Z,...I.updates}:Z)}));break}case"chat.delta":{if(!gn(e,((p=n().currentSession)==null?void 0:p.id)??null)){l();break}const I=e.payload;if(!Gp.has(I.messageId)){Gp.add(I.messageId);const V=I.subAgentType?"sub-agent":Lo(n(),e.sessionId);yR(V)}const U=va();U.messageId=I.messageId,U.deltaContent+=I.content,Up();break}case"chat.thinking":{if(!gn(e,((m=n().currentSession)==null?void 0:m.id)??null)){l();break}const I=e.payload,U=va();U.messageId=I.messageId,U.thinkingContent+=I.content,Up();break}case"chat.tool_preparing":{if(!gn(e,((x=n().currentSession)==null?void 0:x.id)??null)){l();break}const I=e.payload;t(U=>{var B;const V=U.messages.find(q=>q.id===I.messageId);if(!V)return{};if((B=V.toolCalls)==null?void 0:B.find((q,$)=>$===I.index))return{};const ee=V.preparingToolCalls??[],F=ee.findIndex(q=>q.index===I.index);let O;return F>=0?O=ee.map((q,$)=>$===F?{...q,arguments:I.arguments}:q):O=[...ee,{index:I.index,name:I.name,...I.arguments?{arguments:I.arguments}:{}}],{messages:U.messages.map(q=>q.id===I.messageId?{...q,preparingToolCalls:O}:q)}});break}case"chat.tool_call":{if(!gn(e,((y=n().currentSession)==null?void 0:y.id)??null)){l();break}const I=e.payload,U=V=>{var B;const Z=(V.toolCalls??[]).length,ee=(B=V.preparingToolCalls)==null?void 0:B.filter(q=>q.index!==Z),F=va(),O=F.toolOutput.filter(q=>q.callId===I.callId);return O.length>0&&(F.toolOutput=F.toolOutput.filter(q=>q.callId!==I.callId)),{...V,toolCalls:[...V.toolCalls??[],{id:I.callId,name:I.tool,arguments:I.args,startedAt:Date.now(),...O.length>0?{streamingOutput:O.map(q=>({stream:q.stream,content:q.content,timestamp:Date.now()}))}:{}}],...ee&&ee.length>0?{preparingToolCalls:ee}:{preparingToolCalls:void 0}}};t(V=>u(V,I.messageId,U));break}case"chat.tool_output":{if(!gn(e,((S=n().currentSession)==null?void 0:S.id)??null)){l();break}const I=e.payload,U=va();U.messageId=I.messageId,U.toolOutput.push({messageId:I.messageId,callId:I.callId,stream:I.stream,content:I.output}),Up();break}case"chat.tool_result":{if(!gn(e,((C=n().currentSession)==null?void 0:C.id)??null)){l();break}const I=e.payload,U=V=>{var ee;const Z=(ee=V.toolCalls)==null?void 0:ee.map(F=>F.id===I.callId?{...F,result:I.result}:F);return{...V,toolCalls:Z}};t(V=>u(V,I.messageId,U));break}case"chat.vision_fallback":{if(!gn(e,((v=n().currentSession)==null?void 0:v.id)??null)){l();break}const I=e.payload;t(U=>{const V=`${I.messageId}-${I.attachmentId}`,Z={...U.visionFallbackByMessage};return Z[V]={type:I.type,attachmentId:I.attachmentId,filename:I.filename,description:I.description},{visionFallbackByMessage:Z}});break}case"chat.todo":{if(!gn(e,((w=n().currentSession)==null?void 0:w.id)??null)){l();break}const I=e.payload;t({currentTodos:I.todos});break}case"chat.progress":{if(!gn(e,((_=n().currentSession)==null?void 0:_.id)??null)){l();break}const I=e.payload;console.warn("Progress:",I.message,I.phase);break}case"chat.format_retry":{if(!gn(e,((b=n().currentSession)==null?void 0:b.id)??null)){l();break}const I=e.payload;console.warn("Format retry:",I.attempt,"/",I.maxAttempts);break}case"chat.done":{if(!gn(e,((k=n().currentSession)==null?void 0:k.id)??null)){l();break}const I=va();I.messageId=null,I.deltaContent="",I.thinkingContent="",I.toolOutput=[],Gp.delete(e.payload.messageId);const U=e.payload,V=U.stats;t(Z=>({messages:Z.messages.map(ee=>ee.id===U.messageId?{...ee,isStreaming:!1,stats:V??ee.stats,completeReason:U.reason,preparingToolCalls:void 0}:ee),visionFallbackByMessage:{}}));break}case"chat.error":{if(!gn(e,((E=n().currentSession)==null?void 0:E.id)??null)){l();break}const I=va(),U=e.payload;console.error("Chat error:",U.error,"recoverable:",U.recoverable),U.recoverable||(I.messageId=null,I.deltaContent="",I.thinkingContent="",I.toolOutput=[]),t(V=>({error:{code:"CHAT_ERROR",message:U.error},...U.recoverable?{}:{messages:V.messages}}));break}case"chat.path_confirmation":{const I=e.sessionId,U=I===(((T=n().currentSession)==null?void 0:T.id)??null),V=e.payload,Z={callId:V.callId,tool:V.tool,paths:V.paths,workdir:V.workdir,reason:V.reason};if(!U){l(),I&&t(ee=>({crossSessionConfirmations:{...ee.crossSessionConfirmations,[I]:qp(ee.crossSessionConfirmations[I]??[],Z)},sessionsWithPendingConfirmations:ee.sessionsWithPendingConfirmations.includes(I)?ee.sessionsWithPendingConfirmations:[...ee.sessionsWithPendingConfirmations,I]}));break}t(ee=>({pendingPathConfirmations:qp(ee.pendingPathConfirmations,Z)}));break}case"session.confirmation_pending":{const I=e.sessionId,U=e.payload,V={callId:U.callId,tool:U.tool,paths:U.paths,workdir:U.workdir,reason:U.reason};I&&t(Z=>({crossSessionConfirmations:{...Z.crossSessionConfirmations,[I]:qp(Z.crossSessionConfirmations[I]??[],V)},sessionsWithPendingConfirmations:Z.sessionsWithPendingConfirmations.includes(I)?Z.sessionsWithPendingConfirmations:[...Z.sessionsWithPendingConfirmations,I]}));break}case"session.confirmation_resolved":{const I=e.sessionId,U=e.payload;I&&t(V=>{const ee=(V.crossSessionConfirmations[I]??[]).filter(O=>O.callId!==U.callId),F={...V.crossSessionConfirmations};return ee.length===0?delete F[I]:F[I]=ee,{crossSessionConfirmations:F,sessionsWithPendingConfirmations:Object.keys(F)}});break}case"chat.ask_user":{if(!gn(e,((D=n().currentSession)==null?void 0:D.id)??null)){l();return}const I=e.payload,U={callId:I.callId,question:I.question,type:I.type??"text",options:I.options??void 0};t(V=>({pendingQuestions:[...V.pendingQuestions.filter(Z=>Z.callId!==I.callId),U]}));break}case"mode.changed":{if(!gn(e,((L=n().currentSession)==null?void 0:L.id)??null)){l();break}const I=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,mode:I.mode}:null}));break}case"phase.changed":{const I=e.payload;FS(e,t,n,U=>({...U,phase:I.phase}));break}case"workflow.execution_changed":{if(!gn(e,((R=n().currentSession)==null?void 0:R.id)??null)){l();break}const I=e.payload;t(U=>{const V=U.activeWorkflowExecution;return V?{activeWorkflowExecution:{...V,status:I.status,...I.currentStepId?{currentStepId:I.currentStepId}:{},...I.currentStepName?{currentStepName:I.currentStepName}:{}}}:{activeWorkflowExecution:{id:I.executionId,sessionId:e.sessionId??"",workflowId:I.workflowId,workflowName:I.workflowName,...I.workflowColor?{workflowColor:I.workflowColor}:{},status:I.status,...I.currentStepId?{currentStepId:I.currentStepId}:{},...I.currentStepName?{currentStepName:I.currentStepName}:{},stepOutput:{},params:{},createdAt:Date.now(),updatedAt:Date.now()}}});break}case"criteria.updated":{if(!gn(e,((M=n().currentSession)==null?void 0:M.id)??null)){l();break}const I=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,criteria:I.criteria}:null}));break}case"metadata.updated":{if(!gn(e,((W=n().currentSession)==null?void 0:W.id)??null)){l();break}const I=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,metadataEntries:{...U.currentSession.metadataEntries,[I.key]:I.entries}}:null}));break}case"context.state":{const I=e.payload,U=gn(e,((z=n().currentSession)==null?void 0:z.id)??null);I.subAgentId?U&&n().updateSubAgentContextState(I.subAgentId,I.context):U?t({contextState:I.context}):l();break}case"session.name_generated":{const I=e.payload,U=e.sessionId,V=(H=n().currentSession)==null?void 0:H.id;t(Z=>{const ee=Z.sessions.map(O=>O.id===U?{...O,title:I.name}:O),F=V===U?Z.currentSession?{...Z.currentSession,metadata:{...Z.currentSession.metadata,title:I.name}}:null:Z.currentSession;return{sessions:ee,currentSession:F}});break}case"queue.state":{const I=e.payload;t({queuedMessages:I.messages??[]});break}case"mcp.servers.changed":{const I=e.payload;if(I!=null&&I.servers){const U=[...I.servers].sort((V,Z)=>V.name.localeCompare(Z.name));Ac.getState().setServers(U)}else window.dispatchEvent(new CustomEvent("mcp-servers-changed"));break}case"git.status":{const I=e.payload;t({gitStatus:{branch:I.branch,diff:I.diff}});break}case"devServer.output":case"devServer.state":{Un.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{bc.getState().handleMessage(e.type,e.payload);break}case"error":{const I=e.payload;console.error("Server error:",I),t({error:{code:I.code,message:I.message}});break}}}let nc=!1,ds=null;const Kp=new Set,yd=new Map;function VS(e,t,n){return e==null?void 0:e.map(r=>{const a=t.filter(l=>l.callId===r.id);return a.length===0?r:(n.add(r.id),{...r,streamingOutput:[...r.streamingOutput??[],...a.map(l=>({stream:l.stream,content:l.content,timestamp:Date.now()}))]})})}async function WS(e,t,n,r,a){try{const u=await(await Ce(`/api/sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,messageKind:r})})).json();u.queueState&&a({queuedMessages:u.queueState})}catch(l){console.error("Error queueing message:",l)}}const Re=Gn((e,t)=>{oR(()=>{const r=va();if(!r.messageId)return;const a=r.deltaContent.length>0,l=r.thinkingContent.length>0,u=r.toolOutput.length>0;if(!a&&!l&&!u)return;const c=r.deltaContent,d=r.thinkingContent,h=r.toolOutput;r.deltaContent="",r.thinkingContent="",r.toolOutput=[],e(p=>{const m=p.messages.find(x=>x.id===r.messageId);if(m){const x={...m};if(a&&(x.content=x.content+c),l&&(x.thinkingContent=(x.thinkingContent??"")+d),u){const y=new Set;x.toolCalls=VS(x.toolCalls,h,y);const S=h.filter(C=>!y.has(C.callId));S.length>0&&r.toolOutput.push(...S)}return{messages:p.messages.map(y=>y.id===r.messageId?x:y)}}if(u){const x=new Set,y=p.messages.map(C=>C.id!==r.messageId?C:{...C,toolCalls:VS(C.toolCalls,h,x)}),S=h.filter(C=>!x.has(C.callId));return S.length>0&&r.toolOutput.push(...S),{messages:y}}return p})});function n(r,a,l,u){return{workflowId:r.workflowId,resumeFrom:r.currentStepId,stepOutput:r.stepOutput,...r.params&&Object.keys(r.params).length>0?{params:r.params}:{},...a!=null&&a.trim()?{content:a}:{},...l&&l.length>0?{attachments:l}:{},...u?{messageKind:u}:{}}}return{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],hiddenCount:0,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],crossSessionConfirmations:{},sessionsWithPendingConfirmations:[],pendingQuestions:[],visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,activeWorkflowExecution:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,pendingUpdate:!1,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let a=!1;try{a=(await(await Ce("/api/auth")).json()).requiresAuth}catch{}if(a&&!Pt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Pt.onStatusChange(l=>{var u;if(e({connectionStatus:l}),l==="connected"){t().listSessions(void 0),Jt.getState().listProjects();const c=(u=t().currentSession)==null?void 0:u.id;c&&t().loadSession(c)}});try{await Pt.connect(),nc||(nc=!0,ds=Pt.subscribe(l=>{US(l,e,t)}))}catch(l){console.error("Failed to connect:",l);const u=Pt.getLastCloseCode();if(!Pt.hasToken()&&(u===1006||u===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}ds&&(ds(),ds=null),nc=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Pt.disconnect(),ds&&(ds(),ds=null),nc=!1,e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Pt.disconnect(),ds&&(ds(),ds=null),nc=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async r=>{try{const a=await fetch(ni("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:r})});if(!a.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:l}=await a.json();Pt.setToken(l),e({showPasswordModal:!1}),t().connect();const{listProjects:u}=Jt.getState(),{fetchConfig:c}=nn.getState();u(),c(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Pt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(r,a)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const u=await Ce("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:r,title:a})});if(!u.ok)return e({pendingSessionCreate:!1}),null;const c=await u.json();try{Pt.send("session.load",{sessionId:c.session.id})}catch{}return c.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async r=>{if(!Kp.has(r)){Kp.add(r);try{const a=t().currentSession;if(!a||a.id!==r){const h=a==null?void 0:a.id,p=t().pendingPathConfirmations,x={...t().crossSessionConfirmations};h&&p.length>0&&(x[h]=[...x[h]??[],...p]),e({currentSession:null,unreadSessionIds:t().unreadSessionIds.filter(y=>y!==r),subAgentContextStates:{},messages:[],currentTodos:[],contextState:null,pendingPathConfirmations:[],pendingQuestions:[],queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,gitStatus:null,pendingSessionCreate:!1,crossSessionConfirmations:x,sessionsWithPendingConfirmations:Object.keys(x)})}else e({unreadSessionIds:t().unreadSessionIds.filter(h=>h!==r)});const l=await Ce(`/api/sessions/${r}`);if(!l.ok)return;const u=await l.json(),c=u.messages??[],d={...t().crossSessionConfirmations};delete d[r],e({currentSession:u.session,messages:c,hiddenCount:u.hiddenCount??0,contextState:u.contextState,queuedMessages:u.queueState??[],pendingPathConfirmations:u.pendingConfirmations??[],pendingQuestions:u.pendingQuestions??[],activeWorkflowExecution:u.activeWorkflowExecution??null,crossSessionConfirmations:d,sessionsWithPendingConfirmations:Object.keys(d)}),Pt.send("session.load",{sessionId:r});try{const h=await Ce(`/api/sessions/${r}/background-processes`);if(h.ok){const p=await h.json();bc.getState().setProcesses(p.processes??[])}}catch{}}catch{}finally{Kp.delete(r)}}},listSessions:async(r,a=20)=>{const l=r??"global";if(yd.has(l))return yd.get(l);const u=(async()=>{var c;try{const d=new URLSearchParams;d.set("limit",String(a)),r&&d.set("projectId",r);const p=await(await Ce(`/api/sessions?${d.toString()}`)).json(),m=p.sessions??[];e(y=>({sessions:m.map(S=>{var v,w;const C=y.sessions.find(_=>_.id===S.id);return{...S,title:S.title??(C==null?void 0:C.title),mode:((v=y.currentSession)==null?void 0:v.id)===S.id?y.currentSession.mode:(C==null?void 0:C.mode)??S.mode,phase:((w=y.currentSession)==null?void 0:w.id)===S.id?y.currentSession.phase:(C==null?void 0:C.phase)??S.phase,isRunning:S.isRunning&&(C==null?void 0:C.isRunning)!==!1,messageCount:S.messageCount,recentUserPrompts:S.recentUserPrompts}}),sessionsHasMore:r?p.hasMore??!1:!0}));const x=p.pendingConfirmationsBySession;if(x){const y=(c=t().currentSession)==null?void 0:c.id,S={};for(const[C,v]of Object.entries(x))C!==y&&(S[C]=v);e({crossSessionConfirmations:S,sessionsWithPendingConfirmations:Object.keys(S)})}}catch{}finally{yd.delete(l)}})();return yd.set(l,u),u},loadMoreSessions:async r=>{const a=t();if(!(a.sessionsPaginationLoading||!a.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const l=new URLSearchParams;l.set("limit","20"),l.set("offset",String(a.sessions.length)),l.set("projectId",r);const c=await(await Ce(`/api/sessions?${l.toString()}`)).json(),d=c.sessions??[];e(h=>({sessions:[...h.sessions,...d.map(p=>{const m=h.sessions.find(x=>x.id===p.id);return(m==null?void 0:m.isRunning)===!1?{...p,isRunning:!1}:p})],sessionsHasMore:c.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async r=>{var a;try{return(await Ce(`/api/sessions/${r}`,{method:"DELETE"})).ok?(await t().listSessions(),((a=t().currentSession)==null?void 0:a.id)===r&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(r,a)=>{var l;try{const u=await Ce(`/api/sessions/${r}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:a})});if(!u.ok)return!1;if(await t().listSessions(),((l=t().currentSession)==null?void 0:l.id)===r){const d=await u.json();d.session&&e({currentSession:d.session})}return!0}catch{return!1}},deleteAllSessions:async r=>{try{return(await Ce(`/api/projects/${r}/sessions`,{method:"DELETE"})).ok?(await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{e(r=>({currentSession:null,messages:[],hiddenCount:0,currentTodos:[],contextState:null,restoredInput:null,pendingSessionCreate:!1,unreadSessionIds:r.currentSession?r.unreadSessionIds.filter(a=>a!==r.currentSession.id):r.unreadSessionIds}))},sendMessage:async(r,a,l)=>{var d;e({error:null});const u=(d=t().currentSession)==null?void 0:d.id;if(!u)return;const c=t().activeWorkflowExecution;if(c&&c.status==="running"){Pt.send("runner.launch",n(c,r,a,l==null?void 0:l.messageKind));return}try{const h=r==null?void 0:r.trim(),p=a&&a.length>0,m={};h&&(m.content=r),p&&(m.attachments=a),l!=null&&l.messageKind&&(m.messageKind=l.messageKind);const y=await(await Ce(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)})).json();y.queueState&&e({queuedMessages:y.queueState})}catch(h){console.error("Error sending message:",h)}},stopGeneration:async()=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r&&!t().abortInProgress){e({abortInProgress:!0});try{const u=await(await Ce(`/api/sessions/${r}/stop`,{method:"POST"})).json();if(u.queuedMessages&&u.queuedMessages.length>0){const c=u.queuedMessages.map(d=>d.content).join(`
|
|
67
|
+
`);e({restoredInput:c})}}catch(l){console.error("Error stopping generation:",l)}}},continueGeneration:async()=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r)try{await Ce(`/api/sessions/${r}/continue`,{method:"POST"})}catch(l){console.error("Error continuing generation:",l)}},launchWorkflow:(r,a,l,u,c)=>{const d={};r!=null&&r.trim()&&(d.content=r),a&&a.length>0&&(d.attachments=a),l&&(d.workflowId=l),u&&(d.subGroup=u),c&&(d.params=c),Pt.send("runner.launch",d)},continueWorkflow:()=>{const a=t().activeWorkflowExecution;!a||a.status!=="waiting"||Pt.send("runner.launch",n(a))},exitWorkflow:()=>{Pt.send("workflow.exit",{})},switchMode:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const u=await Ce(`/api/sessions/${a}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:r})});if(!u.ok){console.error("Failed to switch mode:",await u.json());return}const c=await u.json();c.session&&e({currentSession:c.session}),c.messages&&e({messages:c.messages,hiddenCount:c.hiddenCount??0})}catch(u){console.error("Error switching mode:",u)}},switchDangerLevel:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const u=await Ce(`/api/sessions/${a}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:r})});if(!u.ok){console.error("Failed to switch danger level:",await u.json());return}const c=await u.json();c.session&&e({currentSession:c.session})}catch(u){console.error("Error switching danger level:",u)}},editCriteria:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const u=await Ce(`/api/sessions/${a}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:r})});u.ok||console.error("Failed to update criteria:",await u.json())}catch(u){console.error("Error updating criteria:",u)}},compactContext:()=>{Pt.send("context.compact",{})},setSessionProvider:async(r,a)=>{var l;try{const u=(l=t().currentSession)==null?void 0:l.id;if(!u)return null;const c=await Ce(`/api/sessions/${u}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:r,...a?{model:a}:{}})});if(!c.ok)return null;const d=await c.json();return e({currentSession:d.session,messages:d.messages??[],hiddenCount:d.hiddenCount??0,contextState:d.contextState}),d.session}catch{return null}},updateContextState:r=>{e({contextState:r})},updateSubAgentContextState:(r,a)=>{e(l=>({subAgentContextStates:{...l.subAgentContextStates,[r]:a}}))},clearSubAgentContextState:r=>{e(a=>{const l={...a.subAgentContextStates};return delete l[r],{subAgentContextStates:l}})},confirmPath:async(r,a,l=!1)=>{var c;const u=(c=t().currentSession)==null?void 0:c.id;if(u)try{const d=await Ce(`/api/sessions/${u}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:r,approved:a,alwaysAllow:l})});if(!d.ok){const h=await d.json().catch(()=>({}));console.error("Error confirming path:",h.error??`HTTP ${d.status}`)}}catch(d){console.error("Error confirming path:",d)}},answerQuestion:async(r,a,l)=>{var c;const u=(c=t().currentSession)==null?void 0:c.id;if(u){try{await Ce(`/api/sessions/${u}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:r,answer:a,skip:l})})}catch(d){console.error("Error answering question:",d)}e(d=>({pendingQuestions:d.pendingQuestions.filter(h=>h.callId!==r)}))}},queueAsap:async(r,a,l)=>{var c;const u=(c=t().currentSession)==null?void 0:c.id;u&&await WS(u,r,a,l,e)},queueCompletion:async(r,a,l)=>{var c;const u=(c=t().currentSession)==null?void 0:c.id;u&&await WS(u,r,a,l,e)},cancelQueued:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const c=await(await Ce(`/api/sessions/${a}/queue/${r}`,{method:"DELETE"})).json();c.queueState&&e({queuedMessages:c.queueState})}catch(u){console.error("Error canceling queued message:",u)}},clearError:()=>{e({error:null})},clearRestoredInput:()=>{e({restoredInput:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},queueUpdate:()=>{e({pendingUpdate:!0})},triggerPendingUpdate:()=>{t().pendingUpdate&&(e({pendingUpdate:!1}),Pt.send("context.applyDynamic",{}))},handleServerMessage:r=>{US(r,e,t)}}});function Vh(){return Re(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function CR(){return Re(e=>e.abortInProgress)}function kR(){const e=Re(a=>a.connect),t=Re(a=>a.connectionStatus),n=Sa(a=>a.load),r=Zo("/p/:projectId/s/:sessionId/readonly")[0];return N.useEffect(()=>{r||e()},[e,r]),N.useEffect(()=>{r||t==="connected"&&n()},[t,n,r]),{connectionStatus:t}}const jR="modulepreload",ER=function(e){return"/"+e},GS={},re=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let u=function(h){return Promise.all(h.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=u(n.map(h=>{if(h=ER(h),h in GS)return;GS[h]=!0;const p=h.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const x=document.createElement("link");if(x.rel=p?"stylesheet":jR,p||(x.as="script"),x.crossOrigin="",x.href=h,d&&x.setAttribute("nonce",d),document.head.appendChild(x),p)return new Promise((y,S)=>{x.addEventListener("load",y),x.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${h}`)))})}))}function l(u){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=u,window.dispatchEvent(c),!c.defaultPrevented)throw u}return a.then(u=>{for(const c of u||[])c.status==="rejected"&&l(c.reason);return t().catch(l)})},NR=[{key:"color-bg-primary",category:"background",label:"Primary Background",defaultValue:"13 17 23"},{key:"color-bg-secondary",category:"background",label:"Secondary Background",defaultValue:"22 27 34"},{key:"color-bg-tertiary",category:"background",label:"Tertiary Background",defaultValue:"33 38 45"},{key:"color-primary",category:"surface",label:"Primary Surface",defaultValue:"10 10 10"},{key:"color-secondary",category:"surface",label:"Secondary Surface",defaultValue:"20 20 20"},{key:"color-text-primary",category:"text",label:"Primary Text",defaultValue:"139 148 158"},{key:"color-text-secondary",category:"text",label:"Secondary Text",defaultValue:"139 148 158"},{key:"color-text-muted",category:"text",label:"Muted Text",defaultValue:"72 79 88"},{key:"color-accent-primary",category:"accent",label:"Primary Accent",defaultValue:"88 166 255"},{key:"color-accent-success",category:"accent",label:"Success Accent",defaultValue:"63 185 80"},{key:"color-accent-warning",category:"accent",label:"Warning Accent",defaultValue:"210 153 34"},{key:"color-accent-error",category:"accent",label:"Error Accent",defaultValue:"248 81 73"},{key:"color-border",category:"border",label:"Border",defaultValue:"48 53 60"},{key:"color-text-heading",category:"text",label:"Heading Text",defaultValue:"56 189 248"},{key:"color-text-bold",category:"text",label:"Bold Text",defaultValue:"251 191 36"},{key:"color-text-code",category:"text",label:"Inline Code Text",defaultValue:"88 166 255"},{key:"color-text-link",category:"text",label:"Link Text",defaultValue:"88 166 255"},{key:"color-bg-system",category:"background",label:"System Message Background",defaultValue:"40 35 28"},{key:"color-border-system",category:"border",label:"System Message Border",defaultValue:"65 55 25"},{key:"color-text-system",category:"text",label:"System Message Text",defaultValue:"253 230 138"},{key:"color-text-thinking",category:"text",label:"Thinking Label",defaultValue:"192 132 252"},{key:"color-text-truncated",category:"text",label:"Truncation Warning",defaultValue:"251 191 36"},{key:"color-text-tool-error",category:"text",label:"Tool Error Text",defaultValue:"248 81 73"}],TR=JSON.parse('[{"id":"system","name":"System","tokens":{}},{"id":"dark","name":"Dark","tokens":{"color-bg-primary":"13 17 23","color-bg-secondary":"22 27 34","color-bg-tertiary":"33 38 45","color-primary":"10 10 10","color-secondary":"20 20 20","color-text-primary":"255 255 255","color-text-secondary":"139 148 158","color-text-muted":"72 79 88","color-accent-primary":"88 166 255","color-accent-success":"63 185 80","color-accent-warning":"210 153 34","color-accent-error":"248 81 73","color-border":"48 53 60","color-text-heading":"56 189 248","color-text-bold":"251 191 36","color-text-code":"255 255 255","color-text-link":"88 166 255","color-bg-system":"40 35 28","color-border-system":"65 55 25","color-text-system":"253 230 138","color-text-thinking":"192 132 252","color-text-truncated":"251 191 36","color-text-tool-error":"248 113 113"},"mode":"dark"},{"id":"light","name":"Light","tokens":{"color-bg-primary":"255 255 255","color-bg-secondary":"250 251 252","color-bg-tertiary":"243 244 246","color-primary":"245 245 245","color-secondary":"229 229 229","color-text-primary":"15 23 42","color-text-secondary":"30 41 59","color-text-muted":"100 116 139","color-accent-primary":"37 99 235","color-accent-success":"22 163 74","color-accent-warning":"217 119 6","color-accent-error":"220 38 38","color-border":"203 213 225","color-text-heading":"2 132 199","color-text-bold":"217 119 6","color-text-code":"37 99 235","color-text-link":"37 99 235","color-bg-system":"254 243 199","color-border-system":"252 211 77","color-text-system":"146 100 30","color-text-thinking":"147 51 234","color-text-truncated":"217 119 6","color-text-tool-error":"220 38 38"},"mode":"light"},{"id":"monokai","name":"Monokai","tokens":{"color-bg-primary":"39 40 34","color-bg-secondary":"30 31 28","color-bg-tertiary":"62 61 50","color-primary":"30 31 28","color-secondary":"45 46 39","color-text-primary":"248 248 242","color-text-secondary":"207 207 194","color-text-muted":"117 113 94","color-accent-primary":"102 217 239","color-accent-success":"166 226 46","color-accent-warning":"230 219 116","color-accent-error":"249 38 114","color-border":"73 72 62","color-text-heading":"56 189 248","color-text-bold":"251 191 36","color-text-code":"248 248 242","color-text-link":"102 217 239","color-bg-system":"62 57 40","color-border-system":"85 75 40","color-text-system":"230 219 116","color-text-thinking":"192 132 252","color-text-truncated":"251 191 36","color-text-tool-error":"248 113 113"},"mode":"dark"},{"id":"dracula","name":"Dracula","tokens":{"color-bg-primary":"40 42 54","color-bg-secondary":"33 34 44","color-bg-tertiary":"68 71 90","color-primary":"30 31 41","color-secondary":"44 46 61","color-text-primary":"248 248 242","color-text-secondary":"230 230 230","color-text-muted":"98 114 164","color-accent-primary":"189 147 249","color-accent-success":"80 250 123","color-accent-warning":"255 184 108","color-accent-error":"255 85 85","color-border":"68 71 90","color-text-heading":"189 147 249","color-text-bold":"255 184 108","color-text-code":"189 147 249","color-text-link":"189 147 249","color-bg-system":"68 64 50","color-border-system":"90 80 60","color-text-system":"255 184 108","color-text-thinking":"255 121 198","color-text-truncated":"255 184 108","color-text-tool-error":"255 85 85"},"mode":"dark"},{"id":"nord","name":"Nord","tokens":{"color-bg-primary":"46 52 64","color-bg-secondary":"59 66 82","color-bg-tertiary":"67 76 94","color-primary":"46 52 64","color-secondary":"59 66 82","color-text-primary":"236 239 244","color-text-secondary":"229 233 240","color-text-muted":"121 133 160","color-accent-primary":"129 161 193","color-accent-success":"163 190 140","color-accent-warning":"235 203 139","color-accent-error":"191 97 106","color-border":"121 133 160","color-text-heading":"129 161 193","color-text-bold":"235 203 139","color-text-code":"129 161 193","color-text-link":"129 161 193","color-bg-system":"67 62 50","color-border-system":"85 80 60","color-text-system":"235 203 139","color-text-thinking":"184 142 173","color-text-truncated":"235 203 139","color-text-tool-error":"191 97 106"},"mode":"dark"},{"id":"rose-pine-dawn","name":"Rose Pine Dawn","tokens":{"color-bg-primary":"250 244 237","color-bg-secondary":"244 237 228","color-bg-tertiary":"235 226 216","color-primary":"250 244 237","color-secondary":"244 237 228","color-text-primary":"87 82 95","color-text-secondary":"111 105 120","color-text-muted":"175 170 180","color-accent-primary":"215 130 126","color-accent-success":"104 157 153","color-accent-warning":"234 157 84","color-accent-error":"215 85 112","color-border":"230 218 206","color-text-heading":"215 130 126","color-text-bold":"234 157 84","color-text-code":"145 117 186","color-text-link":"215 130 126","color-bg-system":"244 237 228","color-border-system":"230 218 206","color-text-system":"162 137 123","color-text-thinking":"145 117 186","color-text-truncated":"234 157 84","color-text-tool-error":"215 85 112"},"mode":"light"},{"id":"everforest-light","name":"Everforest Light","tokens":{"color-bg-primary":"255 248 235","color-bg-secondary":"245 238 220","color-bg-tertiary":"237 228 208","color-primary":"255 248 235","color-secondary":"245 238 220","color-text-primary":"91 105 86","color-text-secondary":"127 139 116","color-text-muted":"179 181 158","color-accent-primary":"100 153 117","color-accent-success":"141 169 73","color-accent-warning":"224 146 66","color-accent-error":"203 97 80","color-border":"230 216 194","color-text-heading":"100 153 117","color-text-bold":"224 146 66","color-text-code":"146 131 176","color-text-link":"100 153 117","color-bg-system":"245 238 220","color-border-system":"230 216 194","color-text-system":"163 147 121","color-text-thinking":"146 131 176","color-text-truncated":"224 146 66","color-text-tool-error":"203 97 80"},"mode":"light"},{"id":"synthwave-84","name":"Synthwave-84","tokens":{"color-bg-primary":"13 15 26","color-bg-secondary":"20 24 41","color-bg-tertiary":"26 31 51","color-primary":"10 12 20","color-secondary":"20 24 41","color-text-primary":"212 230 255","color-text-secondary":"136 153 187","color-text-muted":"68 85 119","color-accent-primary":"0 229 255","color-accent-success":"0 255 65","color-accent-warning":"255 106 0","color-accent-error":"255 0 60","color-border":"26 51 102","color-text-heading":"0 229 255","color-text-bold":"255 140 0","color-text-code":"0 255 170","color-text-link":"0 229 255","color-bg-system":"26 20 10","color-border-system":"51 40 20","color-text-system":"255 170 80","color-text-thinking":"191 0 255","color-text-truncated":"255 140 0","color-text-tool-error":"255 0 60"},"mode":"dark"},{"id":"one-dark-pro","name":"One Dark Pro","tokens":{"color-bg-primary":"40 44 52","color-bg-secondary":"33 37 43","color-bg-tertiary":"47 52 62","color-primary":"28 31 37","color-secondary":"33 37 43","color-text-primary":"171 178 191","color-text-secondary":"150 155 168","color-text-muted":"92 99 112","color-accent-primary":"97 175 239","color-accent-success":"152 195 121","color-accent-warning":"209 154 102","color-accent-error":"224 108 117","color-border":"57 62 72","color-text-heading":"97 175 239","color-text-bold":"209 154 102","color-text-code":"198 120 221","color-text-link":"97 175 239","color-bg-system":"47 42 32","color-border-system":"68 60 46","color-text-system":"224 190 79","color-text-thinking":"198 120 221","color-text-truncated":"209 154 102","color-text-tool-error":"224 108 117"},"mode":"dark"},{"id":"night-owl","name":"Night Owl","tokens":{"color-bg-primary":"1 22 39","color-bg-secondary":"0 30 55","color-bg-tertiary":"11 41 66","color-primary":"1 20 33","color-secondary":"0 30 55","color-text-primary":"214 222 235","color-text-secondary":"162 176 196","color-text-muted":"82 98 126","color-accent-primary":"130 170 255","color-accent-success":"34 218 110","color-accent-warning":"247 140 108","color-accent-error":"239 83 80","color-border":"30 56 85","color-text-heading":"130 170 255","color-text-bold":"247 140 108","color-text-code":"199 146 234","color-text-link":"130 170 255","color-bg-system":"30 25 20","color-border-system":"60 50 40","color-text-system":"247 199 120","color-text-thinking":"199 146 234","color-text-truncated":"247 140 108","color-text-tool-error":"239 83 80"},"mode":"dark"},{"id":"catppuccin-mocha","name":"Catppuccin Mocha","tokens":{"color-bg-primary":"30 30 46","color-bg-secondary":"24 24 37","color-bg-tertiary":"49 50 68","color-primary":"17 17 27","color-secondary":"24 24 37","color-text-primary":"205 214 244","color-text-secondary":"186 194 222","color-text-muted":"108 112 134","color-accent-primary":"137 180 250","color-accent-success":"166 227 161","color-accent-warning":"249 226 175","color-accent-error":"243 139 168","color-border":"69 71 90","color-text-heading":"137 180 250","color-text-bold":"249 226 175","color-text-code":"203 166 247","color-text-link":"137 180 250","color-bg-system":"37 37 54","color-border-system":"69 71 90","color-text-system":"250 179 135","color-text-thinking":"203 166 247","color-text-truncated":"249 226 175","color-text-tool-error":"243 139 168"},"mode":"dark"},{"id":"rose-pine","name":"Rose Pine","tokens":{"color-bg-primary":"25 23 36","color-bg-secondary":"31 29 46","color-bg-tertiary":"38 35 58","color-primary":"20 18 30","color-secondary":"31 29 46","color-text-primary":"224 222 244","color-text-secondary":"196 194 220","color-text-muted":"110 106 134","color-accent-primary":"235 188 186","color-accent-success":"156 207 216","color-accent-warning":"246 193 119","color-accent-error":"235 111 146","color-border":"44 40 67","color-text-heading":"235 188 186","color-text-bold":"246 193 119","color-text-code":"196 167 231","color-text-link":"235 188 186","color-bg-system":"44 38 36","color-border-system":"60 52 50","color-text-system":"246 193 119","color-text-thinking":"196 167 231","color-text-truncated":"246 193 119","color-text-tool-error":"235 111 146"},"mode":"dark"},{"id":"kanagawa-wave","name":"Kanagawa Wave","tokens":{"color-bg-primary":"31 34 44","color-bg-secondary":"25 28 36","color-bg-tertiary":"42 47 58","color-primary":"25 28 36","color-secondary":"25 28 36","color-text-primary":"220 224 206","color-text-secondary":"188 193 178","color-text-muted":"108 112 99","color-accent-primary":"133 189 168","color-accent-success":"157 198 113","color-accent-warning":"226 190 107","color-accent-error":"227 116 102","color-border":"51 59 72","color-text-heading":"133 189 168","color-text-bold":"226 190 107","color-text-code":"194 160 191","color-text-link":"133 189 168","color-bg-system":"42 38 30","color-border-system":"60 54 44","color-text-system":"226 190 107","color-text-thinking":"194 160 191","color-text-truncated":"226 190 107","color-text-tool-error":"227 116 102"},"mode":"dark"},{"id":"light-plus","name":"Light Plus","tokens":{"color-bg-primary":"255 255 255","color-bg-secondary":"243 244 245","color-bg-tertiary":"233 235 238","color-primary":"255 255 255","color-secondary":"243 244 245","color-text-primary":"0 0 0","color-text-secondary":"80 80 80","color-text-muted":"140 140 140","color-accent-primary":"0 92 197","color-accent-success":"0 128 0","color-accent-warning":"178 110 0","color-accent-error":"204 0 0","color-border":"217 217 217","color-text-heading":"0 0 0","color-text-bold":"0 0 0","color-text-code":"204 0 0","color-text-link":"0 92 197","color-bg-system":"255 243 207","color-border-system":"255 220 150","color-text-system":"130 80 0","color-text-thinking":"130 50 180","color-text-truncated":"178 110 0","color-text-tool-error":"204 0 0"},"mode":"light"}]'),Dk={tokens:NR,presets:TR},Rk=Dk.tokens,Qn=Dk.presets;function qS(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}function AR(){try{const e=localStorage.getItem("openfox:systemThemePrefs");if(e)return JSON.parse(e)}catch{}return{darkPreset:"dark",lightPreset:"light"}}const Ut=Gn((e,t)=>{const n=AR();return{currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:qS(),followSystemTheme:!0,isSystem:!1,systemDarkPreset:n.darkPreset,systemLightPreset:n.lightPreset,activeUserPresetId:null,applySavedTheme:()=>{const{getSavedTheme:r,applyPreset:a,applyTokens:l}=t(),u=r();if(u)try{const c=JSON.parse(u);c.preset&&c.tokens?(a(c.preset),e({basePreset:c.preset}),l(c.tokens)):c.preset?a(c.preset):c.tokens&&l(c.tokens)}catch{a("dark")}else a("dark")},applyPreset:r=>{if(Qn.find(l=>l.id===r))if(r==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)"),{systemDarkPreset:u,systemLightPreset:c,userPresets:d}=t(),h=l.matches?u:c,p=d.find(m=>m.id===h);e(p?{basePreset:"system",currentPreset:p.basePreset,customTokens:{...p.tokens},isCustom:!0,isCustomizing:!1,isSystem:!0,activeUserPresetId:p.id}:{basePreset:"system",currentPreset:h,customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!0,activeUserPresetId:null}),t().applyTheme()}else e({currentPreset:r,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!1,activeUserPresetId:null}),t().applyTheme()},startCustomizing:()=>{var l;const{currentPreset:r}=t(),a=((l=Qn.find(u=>u.id===r))==null?void 0:l.tokens)??{};e({basePreset:r,customTokens:{...a},isCustom:!0,isCustomizing:!0})},setCustomToken:(r,a)=>{e(l=>({customTokens:{...l.customTokens,[r]:a}})),t().applyTheme()},cancelCustomizing:()=>{t().applyPreset(t().basePreset||t().currentPreset)},saveCustomTheme:()=>{const{customTokens:r}=t();t().saveTheme(JSON.stringify({tokens:r})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:r=>{e({customTokens:r,isCustom:!0,isCustomizing:!1}),t().applyTheme()},getActiveTheme:()=>{var c,d;const{basePreset:r,customTokens:a,isCustom:l}=t();if(l&&r)return{...((c=Qn.find(p=>p.id===r))==null?void 0:c.tokens)??{},...a};if(l)return{...Rk.reduce((h,p)=>({...h,[p.key]:p.defaultValue}),{}),...a};const u=Qn.find(h=>h.id===t().currentPreset);return(u==null?void 0:u.tokens)??((d=Qn[0])==null?void 0:d.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const r=t().getActiveTheme(),a=document.documentElement;Object.entries(r).forEach(([l,u])=>{a.style.setProperty(`--${l}`,u)})},getSavedTheme:()=>{try{const r=localStorage.getItem("openfox:theme");if(!r)return null;if(r[0]!=="{")return JSON.stringify({preset:r});const a=JSON.parse(r);if(a.preset)return JSON.stringify({preset:a.preset});if(a.tokens)return JSON.stringify({tokens:a.tokens})}catch{return null}return null},saveTheme:async r=>{localStorage.setItem("openfox:theme",r);const{useSettingsStore:a}=await re(async()=>{const{useSettingsStore:l}=await Promise.resolve().then(()=>tc);return{useSettingsStore:l}},void 0);await a.getState().setSetting(Ae.DISPLAY_THEME,r)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:r=>{e({followSystemTheme:r}),re(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>tc);return{useSettingsStore:a,SETTINGS_KEYS:l}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:l})=>{a.getState().setSetting(l.DISPLAY_FOLLOW_SYSTEM_THEME,String(r))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const r=window.matchMedia("(prefers-color-scheme: dark)"),a=u=>{const{followSystemTheme:c,systemDarkPreset:d,systemLightPreset:h}=t();if(!c)return;const p=u?d:h;t().applyPreset(p),t().saveTheme(JSON.stringify({preset:p}))},l=u=>a(u.matches);return r.addEventListener("change",l),()=>r.removeEventListener("change",l)},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[],followSystemTheme:!0,systemDarkPreset:"dark",systemLightPreset:"light",activeUserPresetId:null})},addUserPreset:r=>{const{basePreset:a,customTokens:l,currentPreset:u}=t(),c=a||u,d=Qn.find(m=>m.id===c),h={id:"custom-"+Date.now(),name:r,basePreset:c,mode:d==null?void 0:d.mode,tokens:{...l}},p=[...t().userPresets,h];e({userPresets:p}),t().saveUserPresets()},applyUserPreset:r=>{const a=t().userPresets[r];a&&(e({currentPreset:a.basePreset,basePreset:a.basePreset,customTokens:{...a.tokens},isCustom:!0,isCustomizing:!1,activeUserPresetId:a.id}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:a.basePreset,tokens:a.tokens})).catch(()=>{}))},deleteUserPreset:r=>{const a=t().userPresets.filter((l,u)=>u!==r);e({userPresets:a}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:qS()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),re(async()=>{const{useSettingsStore:r}=await Promise.resolve().then(()=>tc);return{useSettingsStore:r}},void 0).then(({useSettingsStore:r})=>{r.getState().setSetting(Ae.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})},setSystemDarkPreset:r=>{e({systemDarkPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset})),re(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>tc);return{useSettingsStore:a,SETTINGS_KEYS:l}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:l})=>{a.getState().setSetting(l.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset}))}),t().isSystem&&t().applyPreset("system")},setSystemLightPreset:r=>{e({systemLightPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r})),re(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>tc);return{useSettingsStore:a,SETTINGS_KEYS:l}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:l})=>{a.getState().setSetting(l.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r}))}),t().isSystem&&t().applyPreset("system")}}});function LR({canLoad:e,projectId:t,currentProjectId:n}){const r=Jt(u=>u.loadProject),a=Re(u=>u.listSessions),l=Re(u=>u.clearSession);N.useEffect(()=>{e&&t&&(n!==t&&r(t),a(t),l())},[e,t,n,r,a,l])}function DR({canLoad:e,projectId:t,sessionId:n,currentProjectId:r,currentSessionId:a}){const l=Re(h=>h.loadSession),u=Jt(h=>h.loadProject),c=Re(h=>h.listSessions),d=Re(h=>h.pendingSessionCreate);N.useEffect(()=>{e&&t&&r!==t&&u(t)},[e,t,r,u]),N.useEffect(()=>{e&&n&&a!==n&&l(n),e&&t&&c(t)},[e,n,a,l,c,d,t])}function RR({className:e="w-5 h-5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function Ok({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function OR({className:e="w-5 h-5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}function IR({className:e="w-3 h-3 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}function Aa({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.jsx("path",{d:"M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"})})}function is({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function Ik({className:e="w-3 h-3 text-text-muted",rotate:t,direction:n="down"}){return i.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,style:t!==void 0?{transform:`rotate(${t}deg)`}:void 0,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:n==="up"?"M5 15l7-7 7 7":"M19 9l-7 7-7-7"})})}function yn(e){return i.jsx(Ik,{direction:"down",...e})}function MR(e){return i.jsx(Ik,{direction:"up",...e})}function PR({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),i.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function Lc({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function Mk({className:e="w-3 h-3"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}function Pk({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("circle",{cx:"12",cy:"5",r:"2"}),i.jsx("circle",{cx:"12",cy:"12",r:"2"}),i.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function sy({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})})}function Vr({className:e="w-5 h-5 text-accent-primary"}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}function BR({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"})})}function $R({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}function zR({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.1-.303c.652-.18 1.37.008 1.755.653a8.043 8.043 0 0 1 .683 1.18c.227.568.096 1.26-.378 1.726l-.812.804a.312.312 0 0 0-.081.283c.024.166.04.335.04.507s-.016.341-.04.507a.312.312 0 0 0 .08.283l.813.804c.474.466.605 1.158.378 1.726a8.07 8.07 0 0 1-.683 1.18c-.385.645-1.103.833-1.755.653l-1.1-.303c-.066-.019-.176-.011-.299.071a5.1 5.1 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.107c-.168.645-.714 1.196-1.458 1.26a8.094 8.094 0 0 1-1.402 0c-.744-.064-1.29-.615-1.458-1.26l-.29-1.107a.426.426 0 0 0-.211-.224 5.11 5.11 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.1.303c-.652.18-1.37-.008-1.755-.653a8.044 8.044 0 0 1-.683-1.18c-.227-.568-.096-1.26.378-1.726l.812-.804a.312.312 0 0 0 .081-.283A5.18 5.18 0 0 1 2.3 8c0-.172.016-.341.04-.507a.312.312 0 0 0-.08-.283l-.813-.804C.973 5.94.842 5.248 1.069 4.68c.181-.452.395-.882.683-1.18.385-.645 1.103-.833 1.755-.653l1.1.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386a.426.426 0 0 0 .211-.224l.29-1.107C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm0 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z"})})}function iy({className:e="w-3 h-3"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function HR({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function KS({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function Bk({className:e="w-[18px] h-[18px]"}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function $k({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M6.5 3.5H3a1 1 0 0 0-1 1V13a1 1 0 0 0 1 1h8.5a1 1 0 0 0 1-1V9.5"}),i.jsx("path",{d:"M9.5 2h4.5v4.5"}),i.jsx("path",{d:"M14 2L7.5 8.5"})]})}function zk({className:e="w-3 h-3",color:t}){return i.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{d:"M8 5v14l11-7z"})})}function ws({className:e="w-3 h-3 text-accent-primary"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function FR({className:e="w-5 h-5"}){return i.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:i.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})}function Wh({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function Hk({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function UR({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return i.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[i.jsx("title",{children:"Running"}),i.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),i.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function Fk({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z"})})}function Uk({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})}function ay({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function VR({className:e="w-3.5 h-3.5 shrink-0",color:t}){return i.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}function WR({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("polyline",{points:"4 17 10 11 4 5"}),i.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function Ba({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function Vi({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function GR({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function ex({className:e="w-2.5 h-2.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}function ri({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:i.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})}function oy({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.jsx("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.55.55 0 0 1 0-.708z"})})}function qR({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}function KR({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}function YS({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}function tx(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function XS(e,t){const n=Pt.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:tx(),type:e,payload:t}))}const Zr=Gn((e,t)=>({isOpen:!1,sessions:[],workdir:null,setOpen:n=>e({isOpen:n}),toggleOpen:()=>e(n=>({isOpen:!n.isOpen})),setWorkdir:n=>e({workdir:n}),fetchSessions:async n=>{if(!n){e({sessions:[]});return}try{const r=await Ce(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(r.ok){const a=await r.json();e({sessions:a});const l=Pt.ws;if(l&&l.readyState===WebSocket.OPEN)for(const u of a)l.send(JSON.stringify({id:tx(),type:"terminal.subscribe",payload:{sessionId:u.id}}))}}catch(r){console.error("Failed to fetch terminals:",r)}},createSession:async(n,r)=>{try{const a=await Ce("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:r})});if(a.ok){const l=await a.json();e(c=>({sessions:[...c.sessions,l]}));const u=Pt.ws;u&&u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({id:tx(),type:"terminal.subscribe",payload:{sessionId:l.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,r)=>{XS("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,a)=>{XS("terminal.resize",{sessionId:n,cols:r,rows:a})},killSession:async n=>{try{(await Ce(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(a=>({sessions:a.sessions.filter(l=>l.id!==n)}))}catch(r){console.error("Failed to kill terminal:",r)}},handleMessage:n=>{switch(n.type){case"terminal.exit":{const{sessionId:r}=n.payload||{};r&&e(a=>{const l=a.sessions.filter(u=>u.id!==r);return l.length===0&&a.isOpen?{sessions:[],isOpen:!1}:{sessions:l}});break}}}}));Pt.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&Zr.getState().handleMessage(e)});const ei=Gn((e,t)=>({status:"idle",current:null,latest:null,check:async n=>{if(!(!n&&t().status==="checking")){e({status:"checking"});try{const r=await fetch(ni(`/api/auto-update/check${n?"?force=true":""}`));if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();e({status:a.isUpdateAvailable?"available":"upToDate",current:a.current,latest:a.latest})}catch{e({status:"error"})}}}})),xs={terminalToggle:{type:"double-press",key:"Control",threshold:300},quickAction:{type:"double-press",key:"Shift",threshold:300},modelSelector:{type:"chord",key:"m",modifiers:["ctrl"]},sessionSearch:{type:"chord",key:"s",modifiers:["ctrl"]},criteriaSidebar:{type:"chord",key:"d",modifiers:["ctrl"]},agentSwitching:[{type:"chord",key:"1",modifiers:["ctrl"]},{type:"chord",key:"2",modifiers:["ctrl"]},{type:"chord",key:"3",modifiers:["ctrl"]},{type:"chord",key:"4",modifiers:["ctrl"]}]};function nx(e){if(!e)return structuredClone(xs);try{const t=JSON.parse(e),n=r=>t[r]===void 0?structuredClone(xs[r]):t[r];return{terminalToggle:n("terminalToggle"),quickAction:n("quickAction"),modelSelector:n("modelSelector"),sessionSearch:n("sessionSearch"),criteriaSidebar:n("criteriaSidebar"),agentSwitching:n("agentSwitching")}}catch{return structuredClone(xs)}}function QS(e){return e.code.startsWith("Digit")?e.code.slice(-1):/^[a-zA-Z]$/.test(e.key)?e.key.toLowerCase():e.key}function ah(e){if(e.type==="double-press")return`Double ${e.key==="Control"?"Ctrl":e.key==="Shift"?"Shift":e.key==="Alt"?"Alt":e.key==="Meta"?"Meta":e.key}`;const t=e.modifiers.map(r=>{switch(r){case"ctrl":return"Ctrl";case"meta":return"⌘";case"alt":return"Alt";case"shift":return"Shift"}}),n=e.key.length===1?e.key.toUpperCase():e.key;return[...t,n].join("+")}function YR(e){return e.type==="double-press"}function Vk(e){return e.type==="chord"}function XR(e,t){return t.length===1&&/^[a-z]$/i.test(t)?e.key.toLowerCase()===t.toLowerCase():t.length===1&&/^[0-9]$/.test(t)?e.code===`Digit${t}`:e.key.toLowerCase()===t.toLowerCase()}function Wk(e,t){const n=t.modifiers.includes("ctrl"),r=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),l=t.modifiers.includes("shift");return XR(e,t.key)&&e.ctrlKey===n&&e.metaKey===r&&e.altKey===a&&e.shiftKey===l}function Wc(){const e=Vt(t=>t.settings[Ae.KEYBINDINGS]);return nx(e)}function QR(e,t,n){const r=N.useRef(0),a=N.useRef(t);a.current=t,N.useEffect(()=>{if(!e)return;const l=e.threshold??300,u=c=>{if(c.key!==e.key)return;const d=e.key==="Control",h=e.key==="Shift",p=e.key==="Alt",m=e.key==="Meta";if(!d&&c.ctrlKey||!h&&c.shiftKey||!p&&c.altKey||!m&&c.metaKey)return;const x=Date.now();x-r.current<l?(c.preventDefault(),c.stopPropagation(),a.current(),r.current=0):r.current=x};return window.addEventListener("keydown",u,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",u,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function JR(e,t){const n=N.useRef(t);n.current=t,N.useEffect(()=>{if(!e)return;const r=a=>{Wk(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e])}function Dc(e,t,n){QR(e&&YR(e)?e:void 0,t,n),JR(e&&Vk(e)?e:void 0,t)}function ZR(e,t,n){const r=N.useRef(n);r.current=n,N.useEffect(()=>{const a=l=>{for(let u=0;u<e.length;u++){const c=e[u];if(!c)continue;const d=t[u];if(d&&Vk(c)&&Wk(l,c)){l.preventDefault(),r.current(d.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var si=CC();const Gh=N.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...r},a)=>i.jsx("button",{ref:a,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...r,children:i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));Gh.displayName="IconButton";const e3="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",ti=N.forwardRef((e,t)=>i.jsx(Gh,{ref:t,icon:e3,title:"Edit",...e}));ti.displayName="EditButton";const t3="M6 18L18 6M6 6l12 12",ly=N.forwardRef((e,t)=>i.jsx(Gh,{ref:t,icon:t3,...e}));ly.displayName="CloseButton";const n3={sm:"max-w-sm",md:"max-w-md",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95vw] h-[90vh] flex-1"};function Tt({label:e,title:t,headerRight:n,size:r="md",minHeight:a,children:l,footer:u,className:c,onClose:d,isOpen:h,closeOnBackdropClick:p=!0,closeOnEscape:m=!0,showCloseButton:x=!0,scrollable:y=!0}){const[S,C]=N.useState(!1),v=h!==void 0,w=v?h:S,_=N.useCallback(()=>{v||C(!0)},[v]),b=N.useCallback(()=>{v||C(!1),d==null||d()},[v,d]);N.useEffect(()=>{if(!w||!m)return;const E=T=>{if(T.key==="Escape"){const D=document.activeElement;if(D&&(D.tagName==="INPUT"||D.tagName==="TEXTAREA"))return;T.stopPropagation(),b()}};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[w,b,m]);const k=e&&(typeof e=="string"?i.jsx("button",{type:"button",onClick:_,className:c,children:e}):i.jsx("span",{onClick:_,className:c,style:{cursor:"pointer"},children:e}));return i.jsxs(i.Fragment,{children:[k,w&&(typeof document<"u"?si.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[i.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:p?b:void 0}),i.jsxs("div",{role:"dialog",className:`relative w-full ${n3[r]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||n||x)&&i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t&&i.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),i.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[n,x&&i.jsx(ly,{onClick:b,"aria-label":"Close"})]})]}),y?i.jsx(Ze,{className:"p-4 flex-1 min-h-0",style:a?{minHeight:a}:void 0,children:l}):i.jsx("div",{className:"p-4 flex-1 min-h-0 overflow-hidden flex flex-col",style:a?{minHeight:a}:void 0,children:l}),u&&i.jsx("div",{className:"px-4 py-3 border-t border-border",children:u})]})]}),document.body):null)]})}function r3({value:e,defaultUrl:t,disabled:n,onChange:r}){const a=e??t;return i.jsxs("div",{className:"relative",children:[i.jsx("select",{value:a,disabled:n,onChange:l=>{const u=l.target.value;r(u===t?null:u)},className:"appearance-none bg-bg-tertiary border border-border rounded px-1.5 pr-5 text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary disabled:opacity-40 cursor-pointer",style:{width:"60px"},children:cR.map(({url:l,label:u})=>i.jsx("option",{value:l,title:u,children:u.split(" ")[0]},l))}),i.jsx(yn,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const JS=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function s3(){const e=Sa(d=>d.settings),t=Sa(d=>d.update),n=Sa(d=>d.updateEvent),r=Sa(d=>d.updateAgentOverride),a=Sa(d=>d.load);N.useEffect(()=>{a()},[a]);const l=async()=>{await dR()==="granted"&&t({...e,browserNotificationEnabled:!0})},u=(d,h,p,m)=>{d==="general"?n(h,{[p]:m}):r(d,h,{[p]:m})},c=(d,h,p)=>{d==="general"?n(h,{customSoundUrl:p}):r(d,h,{customSoundUrl:p})};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-3",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),i.jsx(ZS,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>t({...e,soundEnabled:d})}),i.jsx(ZS,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:d=>{d&&typeof Notification<"u"&&Notification.permission!=="granted"?l():t({...e,browserNotificationEnabled:d})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&i.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),i.jsx("div",{className:"border border-border rounded overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:i.jsxs("tr",{className:"border-b border-border",children:[i.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),JS.map(d=>i.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:d.label},d.key))]})}),i.jsx("tbody",{children:lR.map(d=>i.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[i.jsx("td",{className:"px-3 py-2",children:i.jsx("div",{className:"text-text-primary text-xs",children:d.label})}),JS.map(h=>{const p=Ak(e,d.key,h.key==="general"?void 0:h.key),m=Nk[d.key];return i.jsx("td",{className:"px-2 py-2 align-top",children:i.jsxs("div",{className:"flex flex-col items-center gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:i.jsx("input",{type:"checkbox",checked:p.soundEnabled,onChange:x=>u(h.key,d.key,"soundEnabled",x.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),i.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:i.jsx("input",{type:"checkbox",checked:p.browserNotification,onChange:x=>u(h.key,d.key,"browserNotification",x.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&i.jsx(r3,{value:p.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:x=>c(h.key,d.key,x)})]})},h.key)})]},d.key))})]})})]})]})}function ZS({label:e,description:t,checked:n,onChange:r}){return i.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer group",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),i.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:t})]}),i.jsx("div",{className:"flex-shrink-0 pt-0.5",children:i.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${n?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:a=>{a.preventDefault(),r(!n)},children:i.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${n?"translate-x-4":"translate-x-0.5"}`})})})]})}const mt=N.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:r,...a},l)=>{const u="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",c={primary:"bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40",secondary:"bg-bg-tertiary text-text-primary hover:bg-border",danger:"bg-accent-error text-white hover:bg-accent-error/80"},d={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return i.jsx("button",{ref:l,className:`${u} ${c[e]} ${d[t]} ${n}`,...a,children:r})});mt.displayName="Button";async function e1(e,t,n){try{const r=await Ce(e,t);return r.ok?(await n(),{success:!0}):{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}}const $n=Gn((e,t)=>({defaults:[],userItems:[],projectItems:[],items:[],selectedDirectory:null,diagnostics:[],loading:!1,fetchSkills:async()=>{e({loading:!0});try{const r=await(await Ce("/api/skills")).json();e({defaults:r.defaults??[],userItems:r.userItems??[],projectItems:r.projectItems??[],items:r.items??[],selectedDirectory:r.selectedDirectory??null,diagnostics:r.diagnostics??[],loading:!1})}catch{e({loading:!1})}},toggleSkill:async n=>{try{const a=await(await Ce(`/api/skills/${n}/toggle`,{method:"POST"})).json();e(l=>({defaults:l.defaults.map(u=>u.id===n?{...u,enabled:a.enabled}:u),userItems:l.userItems.map(u=>u.id===n?{...u,enabled:a.enabled}:u),projectItems:l.projectItems.map(u=>u.id===n?{...u,enabled:a.enabled}:u),items:l.items.map(u=>u.id===n?{...u,enabled:a.enabled}:u)}))}catch{}},fetchSkill:async n=>{try{const r=await Ce(`/api/skills/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await Ce(`/api/skills/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(n,r)=>{const a=await Ui("POST","/api/skills",{...n,destination:r});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,r)=>{const a=await Ui("PUT",`/api/skills/${n}`,r);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const r=await Ce(`/api/skills/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,r)=>Uh(`/api/skills/${n}/duplicate`,()=>t().fetchSkills(),r),selectDirectory:async n=>e1("/api/skills/library",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})},t().fetchSkills),removeDirectory:async()=>{await Ce("/api/skills/library",{method:"DELETE"}),await t().fetchSkills()},installSkill:async n=>{const r=new FormData;r.append("packageName",n.packageName),r.append("paths",JSON.stringify(n.files.map(a=>a.path)));for(const a of n.files)r.append("files",a.file,a.file.name);return e1("/api/skills/install",{method:"POST",body:r},t().fetchSkills)}}));function Gc(){const[e,t]=N.useState({id:null,type:null}),n=N.useCallback(l=>t({id:l,type:"delete"}),[]),r=N.useCallback(()=>t({id:null,type:null}),[]),a=N.useCallback((l,u)=>e.id===l&&e.type===u,[e.id,e.type]);return{requestDelete:n,clearConfirm:r,isConfirming:a}}function oh({onConfirm:e,onCancel:t}){return i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:e,className:"px-1.5 py-0.5 rounded text-xs hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),i.jsx("button",{onClick:t,className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]})}function lh({onClick:e}){return i.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",title:"Delete",children:i.jsx(Ba,{})})}function Rc({onClick:e}){return i.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-text-primary transition-colors",title:"Duplicate",children:i.jsx(Lc,{})})}function Fr({label:e,value:t,onChange:n,placeholder:r,readOnly:a,hint:l,mono:u}){return i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,l&&i.jsx("span",{className:"text-text-muted ml-1",children:l})]}),i.jsx("input",{value:t,onChange:c=>n(c.target.value),readOnly:a,placeholder:r,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${u?"font-mono":""} ${a?"opacity-60":""}`})]})}function Gk({onCancel:e,onSave:t,saving:n,saveDisabled:r}){return i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx(mt,{variant:"secondary",onClick:e,children:"Cancel"}),i.jsx(mt,{variant:"primary",onClick:t,disabled:n||r,children:n?"Saving...":"Save"})]})}function Fo({message:e}){return i.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function qh({value:e,onChange:t}){return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),i.jsxs("select",{value:e,onChange:n=>t(n.target.value),className:"px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[i.jsx("option",{value:"user",children:"Global config"}),i.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]})}function qk({description:e,onNew:t,loading:n,hasItems:r,children:a}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("p",{className:"text-text-secondary text-sm",children:e}),i.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:i.jsx(mt,{variant:"primary",size:"sm",onClick:t,children:"+ New"})})]}),n&&!r?i.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."}):r?a:i.jsx("div",{className:"text-text-muted text-sm",children:"No items defined."})]})}function Kk({label:e="Custom",children:t}){return i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),i.jsx("div",{className:"space-y-2",children:t})]})}function Yk({description:e,onNew:t,newLabel:n="+ New"}){return i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("p",{className:"text-text-secondary text-sm",children:e}),i.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:i.jsx(mt,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function cy({loading:e,hasItems:t,loadingLabel:n,emptyLabel:r,children:a}){return e&&!t?i.jsx("div",{className:"text-text-muted text-sm",children:n}):t?i.jsx("div",{className:"space-y-4",children:a}):r?i.jsx("div",{className:"text-text-muted text-sm",children:r}):null}function Xk({name:e,id:t,nameLabel:n="Name",idLabel:r="ID",namePlaceholder:a="My Item",idPlaceholder:l="my-item",nameHint:u,readOnlyId:c=!1,readOnlyHint:d="(read-only)",onNameChange:h,onIdChange:p}){return i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(Fr,{label:n,value:e,onChange:h,placeholder:a,hint:u}),i.jsx(Fr,{label:r,value:t,onChange:p,readOnly:c,placeholder:l,hint:c?d:void 0,mono:!0})]})}function Qk(e={}){const{initialData:t={}}=e,[n,r]=N.useState("list"),[a,l]=N.useState(null),[u,c]=N.useState(""),[d,h]=N.useState(!1),[p,m]=N.useState(t),x=N.useCallback(()=>{m(t),c(""),l(null)},[t]),y=N.useCallback(w=>{r(w),w==="list"&&x()},[x]),S=N.useCallback(w=>{m(_=>typeof w=="function"?w(_):w)},[]),C=N.useCallback((w,_={})=>{l(w),r("edit"),m({..._}),c("")},[]),v=N.useCallback(()=>{l(null),r("edit"),m(t),c("")},[t]);return{view:n,editingId:a,formError:u,saving:d,formData:p,setView:y,setEditingId:l,setFormError:c,setFormData:S,setSaving:h,resetForm:x,startEditing:C,startNew:v}}function Oc({isOpen:e,onClose:t,onConfirm:n,title:r,message:a,confirmLabel:l="Confirm",confirmVariant:u="primary",disabled:c=!1}){return i.jsx(Tt,{isOpen:e,onClose:t,title:r,size:"sm",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"text-text-secondary",children:a}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(mt,{variant:"secondary",onClick:t,disabled:c,children:"Cancel"}),i.jsx(mt,{variant:u,onClick:n,disabled:c,autoFocus:!0,children:l})]})]})})}const i3={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function Gi({size:e="md",className:t=""}){return i.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${i3[e]} ${t}`})}function a3({text:e,...t}){return i.jsxs("div",{className:"text-center",children:[i.jsx(Gi,{...t,className:"mx-auto mb-4"}),e&&i.jsx("div",{className:"text-text-secondary",children:e})]})}function Jk(e){return e.split(/[\\/]/).filter(Boolean).pop()??""}function o3(e){const t=e.includes("\\")?"\\":"/";return e.split(/[\\/]/).filter(Boolean).map((n,r,a)=>({name:n,path:t==="/"?"/"+a.slice(0,r+1).join("/"):a.slice(0,r+1).join("\\")+(r===0?"\\":"")}))}function Zk(e,t=28){if(e.length<=t)return e;const n=e.split("/").filter(Boolean);if(n.length<=2)return e;const r=n[0],a=n[n.length-1],l=n.slice(1,-1).join("/"),u=t-r.length-a.length-3;if(u<0)return e;const c=l.slice(0,Math.floor(u/2)),d=l.slice(-Math.ceil(u/2));return`/${r}/${c}...${d}/${a}`}const zi=N.forwardRef(({className:e="",...t},n)=>i.jsx("input",{ref:n,className:`bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary ${e}`,...t}));zi.displayName="Input";function Kh({onSelect:e,onClose:t,initialPath:n}){const[r,a]=N.useState(null),[l,u]=N.useState(!0),[c,d]=N.useState(""),[h,p]=N.useState(-1),m=N.useRef(null),x=N.useRef(null),y=N.useCallback(async b=>{u(!0),d(""),p(-1);try{const k=b?`/api/directories?path=${encodeURIComponent(b)}`:"/api/directories",T=await(await Ce(k)).json();a(T)}catch(k){console.error("Failed to load directories:",k)}finally{u(!1)}},[]);N.useEffect(()=>{y(n)},[n,y]);const S=o3((r==null?void 0:r.current)??""),C=(r==null?void 0:r.directories.filter(b=>c===""||b.name.toLowerCase().includes(c.toLowerCase())))??[],v=[...!c&&(r!=null&&r.parent)?[{type:"parent",path:r.parent,name:".."}]:[],...C.map(b=>({type:"dir",path:b.path,name:b.name}))];N.useEffect(()=>{p(c?0:-1)},[c,C.length]),N.useEffect(()=>{if(h>=0&&x.current){const b=x.current.querySelector(`[data-index="${h}"]`);b==null||b.scrollIntoView({block:"nearest"})}},[h]);const w=b=>{var k;if(b.key==="ArrowDown")b.preventDefault(),p(E=>Math.min(E+1,v.length-1));else if(b.key==="ArrowUp")b.preventDefault(),p(E=>Math.max(E-1,0));else if(b.key==="Enter"){if(h<0||!v[h]||b.target instanceof HTMLElement&&b.target.dataset.select==="true")return;b.preventDefault(),b.shiftKey?y(v[h].path):e(v[h].path)}else b.key==="Escape"&&(d(""),(k=m.current)==null||k.focus())},_=i.jsx("div",{className:"flex flex-col gap-2",children:i.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})});return i.jsx(Tt,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",footer:_,scrollable:!1,children:i.jsxs("div",{ref:x,className:"flex flex-col flex-1 min-h-0 -m-4",onKeyDown:w,children:[i.jsxs("div",{className:"flex-shrink-0 bg-bg-secondary border-b border-border",children:[r&&i.jsx("div",{className:"px-3 pt-3 pb-1",children:i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsxs("div",{className:"flex items-center flex-wrap min-w-0",children:[S.map((b,k)=>i.jsxs("span",{className:"flex items-center shrink-0",children:[i.jsx("span",{className:"text-text-muted",children:"/"}),i.jsx("button",{onClick:()=>y(b.path),className:`px-1 ${k===S.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:b.name})]},b.path)),S.length===0&&i.jsx("button",{onClick:()=>y("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]}),(r==null?void 0:r.current)&&i.jsx("button",{onClick:()=>e(r.current),className:"ml-auto shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90",children:"Select"})]})}),i.jsx("div",{className:"px-4 py-2",children:i.jsxs("div",{className:"relative",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none flex items-center justify-center",children:i.jsx(Vi,{})}),i.jsx(zi,{autoFocus:!0,ref:m,value:c,onChange:b=>d(b.target.value),placeholder:"Filter directories...",className:"w-full pl-9"})]})})]}),i.jsx(Ze,{className:"flex-1",children:l?i.jsx("div",{className:"p-8 text-center",children:i.jsx(Gi,{size:"sm"})}):v.length===0?i.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:c?"No matching directories":"No subdirectories"}):i.jsx("div",{className:"divide-y divide-border",children:v.map((b,k)=>i.jsxs("div",{"data-index":k,className:`group flex items-center ${k===h?"bg-accent-primary/20":"hover:bg-bg-tertiary/50"}`,children:[i.jsxs("button",{onClick:()=>{y(b.path)},className:"flex-1 flex items-center gap-3 p-3 text-left min-w-0",tabIndex:-1,children:[b.type==="parent"?i.jsx(RR,{className:"w-5 h-5 text-text-muted shrink-0"}):i.jsx(Vr,{className:"w-5 h-5 shrink-0"}),i.jsx("span",{className:"truncate",children:b.name}),b.type==="dir"&&i.jsx(yn,{className:`w-5 h-5 text-text-muted shrink-0 ml-1 ${k===h?"opacity-100":"opacity-0 group-hover:opacity-100"}`,rotate:-90})]}),b.type==="dir"&&i.jsx("button",{"data-select":"true",tabIndex:k===h?0:-1,onClick:E=>{E.stopPropagation(),e(b.path)},className:`mr-2 shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90 ${k===h?"opacity-100":"opacity-0 group-hover:opacity-100"}`,"aria-label":`Select ${b.name}`,children:"Select"})]},b.path))})})]})})}function ej(e,t){if(!e||!t.some(n=>n.path==="SKILL.md"))throw new Error("Drop one folder containing SKILL.md.");return{packageName:e,files:t}}function l3(e){const t=[...e];if(!t.length)throw new Error("Choose one skill folder.");const n=new Set(t.map(a=>a.webkitRelativePath.split("/")[0]).filter(Boolean));if(n.size!==1)throw new Error("Choose exactly one skill folder.");const r=[...n][0];return ej(r,t.map(a=>({path:a.webkitRelativePath.slice(r.length+1),file:a})))}function c3(e){return new Promise((t,n)=>e.file(t,n))}async function tj(e,t=""){const n=e.createReader(),r=[];for(;;){const l=await new Promise((u,c)=>n.readEntries(u,c));if(!l.length)break;r.push(...l)}return(await Promise.all(r.map(async l=>{const u=t?`${t}/${l.name}`:l.name;return l.isDirectory?tj(l,u):[{path:u,file:await c3(l)}]}))).flat()}async function u3(e){const t=[...e.items].filter(r=>r.kind==="file").map(r=>{var a;return((a=r.webkitGetAsEntry)==null?void 0:a.call(r))??null}).filter(r=>!!r);if(t.length!==1||!t[0].isDirectory)throw new Error("Drop exactly one skill folder.");const n=t[0];return ej(n.name,await tj(n))}function d3({selectedDirectory:e,onSelect:t,onRemove:n,onRefresh:r,onInstall:a}){const[l,u]=N.useState(!1),[c,d]=N.useState(!1),[h,p]=N.useState(""),[m,x]=N.useState(null),[y,S]=N.useState(!1),C=N.useRef(null);N.useEffect(()=>{var k;(k=C.current)==null||k.setAttribute("webkitdirectory","")},[]);const v=k=>{x(k)},w=async()=>{if(!m||y)return;S(!0);const k=await t(m);if(k&&!k.success){p(k.error??"Cannot use selected folder."),S(!1);return}x(null),u(!1),S(!1)},_=async k=>{d(!0),p("");const E=await a(k);d(!1),E.success||p(E.error??"Failed to install skill package.")},b=async k=>{if(k.preventDefault(),!(!(e!=null&&e.available)||c))try{await _(await u3(k.dataTransfer))}catch(E){p(E instanceof Error?E.message:"Invalid skill folder.")}};return i.jsxs("section",{className:"mb-4 rounded border border-border bg-bg-tertiary/30 p-3",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Skills folder"}),i.jsx("p",{className:"mt-1 truncate text-xs text-text-muted",children:(e==null?void 0:e.configuredPath)??"No shared folder selected"})]}),i.jsxs("div",{className:"flex shrink-0 gap-2",children:[i.jsx(mt,{variant:"secondary",onClick:()=>u(!0),children:"Change folder"}),e&&i.jsxs(i.Fragment,{children:[i.jsx(mt,{variant:"secondary",onClick:r,children:"Refresh"}),e.custom&&i.jsx(mt,{variant:"secondary",onClick:n,children:"Use default"})]})]})]}),i.jsx("button",{type:"button",disabled:!(e!=null&&e.available)||c,onClick:()=>{var k;return(k=C.current)==null?void 0:k.click()},onDragOver:k=>k.preventDefault(),onDrop:b,className:"mt-3 w-full rounded border border-dashed border-border px-4 py-5 text-center text-xs text-text-secondary disabled:cursor-not-allowed disabled:opacity-50",children:e!=null&&e.available?c?"Installing skill package...":"Drop one skill folder here":"Choose a skills folder to enable drag and drop."}),i.jsx("input",{ref:C,hidden:!0,type:"file",multiple:!0,onChange:k=>{var E;if((E=k.target.files)!=null&&E.length)try{_(l3(k.target.files))}catch(T){p(T instanceof Error?T.message:"Invalid skill folder.")}finally{k.target.value=""}}}),h&&i.jsx("p",{className:"mt-2 text-xs text-error",children:h}),l&&i.jsx(Kh,{initialPath:(e==null?void 0:e.resolvedPath)??void 0,onSelect:v,onClose:()=>u(!1)}),i.jsx(Oc,{isOpen:m!==null,onClose:()=>x(null),onConfirm:w,title:"Trust this folder?",message:"Skills may contain instructions and scripts. Select this folder for discovery without executing package content?",confirmLabel:"Trust folder",disabled:y})]})}function ns({enabled:e,onClick:t,label:n,disabled:r}){return i.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":n,onClick:r?void 0:t,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-accent-primary":"bg-bg-tertiary"} ${r?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function nj({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:r,onDuplicate:a,onDelete:l,onCancelDelete:u,actions:c,children:d}){return i.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[i.jsx("div",{className:"min-w-0 flex-1 mr-3",children:d}),i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&r&&i.jsx(ti,{onClick:r}),e&&!r&&n&&i.jsx("button",{onClick:n,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:i.jsx(sy,{})}),i.jsx(Rc,{onClick:a}),!e&&r&&i.jsx(ti,{onClick:r}),!e&&l&&(t?i.jsx(oh,{onConfirm:()=>{l==null||l()},onCancel:()=>u==null?void 0:u()}):i.jsx(lh,{onClick:()=>l==null?void 0:l()})),c]})]})}function h3({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,onCancelDelete:h,actions:p}){return i.jsxs(nj,{isBuiltIn:r,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,onCancelDelete:h,actions:p,children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),i.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&i.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function t1({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:l,onDelete:u,onToggle:c,readOnly:d=!1}){return i.jsx(h3,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:d?void 0:a,onDuplicate:l,onDelete:d?void 0:u,actions:i.jsx(ns,{enabled:e.enabled,onClick:c,label:`Activation for ${e.name}`})})}function f3({skill:e,deleting:t,error:n,onClose:r,onConfirm:a}){return i.jsxs(Tt,{isOpen:e!==null,onClose:r,title:"Delete skill?",size:"sm",closeOnBackdropClick:!t,closeOnEscape:!t,footer:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(mt,{variant:"secondary",onClick:r,disabled:t,children:"Cancel"}),i.jsx(mt,{variant:"danger",onClick:a,disabled:t,children:t?"Deleting...":"Delete skill"})]}),children:[i.jsx("p",{className:"text-sm font-medium text-text-primary",children:"This skill files will be deleted."}),i.jsx("p",{className:"mt-2 text-sm text-text-secondary",children:"The full skill folder and all its contents will be removed."}),e&&i.jsx("p",{className:"mt-3 break-all font-mono text-xs text-text-muted",children:e.path}),n&&i.jsx("p",{className:"mt-3 text-sm text-error",children:n})]})}function m3({isOpen:e}){const t=$n(J=>J.defaults),n=$n(J=>J.userItems),r=$n(J=>J.projectItems),a=$n(J=>J.items),l=$n(J=>J.selectedDirectory),u=$n(J=>J.diagnostics),c=$n(J=>J.loading),d=$n(J=>J.fetchSkills),h=$n(J=>J.fetchSkill),p=$n(J=>J.fetchDefaultContent),m=$n(J=>J.createSkill),x=$n(J=>J.updateSkill),y=$n(J=>J.deleteSkill),S=$n(J=>J.selectDirectory),C=$n(J=>J.removeDirectory),v=$n(J=>J.installSkill),w=$n(J=>J.toggleSkill),[_,b]=N.useState(null),[k,E]=N.useState(!1),[T,D]=N.useState(""),{view:L,editingId:R,formError:M,saving:W,formData:z,setView:H,setEditingId:I,setFormError:U,setFormData:V,setSaving:Z}=Qk(),{clearConfirm:ee}=Gc();N.useEffect(()=>{e&&(d(),H("list"),I(null),ee())},[e,d,ee]);const F=(J,ne,ce,ae)=>{V({name:ae??J.metadata.name,id:ce??J.metadata.id,description:J.metadata.description??"",version:J.metadata.version??"1.0.0",prompt:J.prompt,isReadOnly:ne,destination:"user"})},O=async J=>{if(t.some(ce=>ce.id===J)){const ce=await p(J);if(!ce)return;F(ce,!0),I(J),U(""),H("edit")}else{const ce=await h(J);if(!ce)return;F(ce,!0),I(J),U(""),H("edit")}},B=async J=>{const ce=t.some(Ee=>Ee.id===J)?await p(J):await h(J);if(!ce)return;const ae=`${J}-copy-${Date.now()}`;F(ce,!1,ae,`${ce.metadata.name} (copy)`),I(null),U(""),H("edit")},q=()=>{V({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),H("edit")},$=async J=>{const ne=await h(J);ne&&(F(ne,!1),I(J),U(""),H("edit"))},Y=async()=>{if(!_)return;E(!0),D("");const J=await y(_.id);if(E(!1),!J.success){D(J.error??"Failed to delete skill.");return}await d(),b(null),ee()},Q=async()=>{const J=R??z.id;if(!J||!z.name||!z.prompt){U("Name, ID, and prompt are required.");return}Z(!0),U("");const ne={metadata:{id:J,name:z.name,description:z.description,version:z.version},prompt:z.prompt},ce=R?await x(R,ne):await m(ne,z.destination);if(Z(!1),!ce.success){U(ce.error??"Failed to save skill.");return}H("list")},X=J=>{V(ne=>({...ne,name:J})),R||V(ne=>({...ne,id:J.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},K=z.isReadOnly;if(L==="edit")return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-3",children:[i.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:K?z.name:R?"Edit Skill":"New Skill"}),i.jsx("button",{onClick:()=>H("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),M&&i.jsx(Fo,{message:M}),i.jsxs("div",{className:"space-y-3 mb-3",children:[i.jsx(Xk,{name:z.name,id:z.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:X,onIdChange:()=>{}}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(Fr,{label:"Description",value:z.description,onChange:J=>V(ne=>({...ne,description:J})),placeholder:"What this skill does...",readOnly:K}),i.jsx(Fr,{label:"Version",value:z.version,onChange:J=>V(ne=>({...ne,version:J})),placeholder:"1.0.0",readOnly:K})]})]}),i.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),i.jsx("textarea",{value:z.prompt,onChange:J=>V(ne=>({...ne,prompt:J.target.value})),readOnly:K,placeholder:"The system prompt for this skill...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),!R&&i.jsx(qh,{value:z.destination,onChange:J=>V(ne=>({...ne,destination:J}))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[i.jsx(mt,{variant:"secondary",onClick:()=>H("list"),children:"Cancel"}),K?i.jsx(mt,{variant:"primary",onClick:()=>{V(J=>({...J,name:J.name+" (copy)",id:`${R}-copy-${Date.now()}`,isReadOnly:!1})),I(null)},children:"Duplicate & Customize"}):i.jsx(mt,{variant:"primary",onClick:Q,disabled:W||!z.name||!z.id||!z.prompt,children:W?"Saving...":"Save"})]})]});function P({items:J}){return J.map(ne=>i.jsx(t1,{skill:ne,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>O(ne.id),onEdit:()=>$(ne.id),onDuplicate:()=>B(ne.id),onDelete:()=>{D(""),b(ne)},onToggle:()=>w(ne.id),readOnly:ne.readOnly},ne.id))}return i.jsxs("div",{children:[i.jsx(f3,{skill:_,deleting:k,error:T,onClose:()=>{k||b(null)},onConfirm:Y}),i.jsx(d3,{selectedDirectory:l,onSelect:S,onRemove:C,onRefresh:d,onInstall:v}),u.length>0&&i.jsx("div",{className:"mb-3 rounded border border-accent-warning/40 bg-accent-warning/10 p-2 text-xs text-text-secondary",children:u.map((J,ne)=>i.jsx("p",{children:J},`${J}-${ne}`))}),i.jsx(Yk,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:q}),i.jsxs(cy,{loading:c,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),i.jsx("div",{className:"space-y-2",children:t.map(J=>i.jsx(t1,{skill:J,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>O(J.id),onDuplicate:()=>B(J.id),onToggle:()=>w(J.id)},J.id))})]}),n.length>0&&i.jsx(Kk,{children:i.jsx(P,{items:n})}),a.some(J=>["global-shared","selected","project-shared"].includes(J.source))&&i.jsxs("div",{className:"mt-4",children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Shared"}),i.jsx("div",{className:"space-y-2",children:i.jsx(P,{items:a.filter(J=>["global-shared","selected","project-shared"].includes(J.source))})})]}),r.length>0&&i.jsxs("div",{className:"mt-4",children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),i.jsx("div",{className:"space-y-2",children:i.jsx(P,{items:r})})]})]})]})}function qi(){const e=Vt(a=>a.settings),t=Vt(a=>a.loading),n=Vt(a=>a.getSetting),r=Vt(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function p3({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:a}=qi(),l=t[Ae.GLOBAL_INSTRUCTIONS]??"",u=n[Ae.GLOBAL_INSTRUCTIONS]??!1,[c,d]=N.useState(l),[h,p]=N.useState(!1),[m,x]=N.useState(!1);N.useEffect(()=>{e&&r(Ae.GLOBAL_INSTRUCTIONS)},[e,r]),N.useEffect(()=>{d(l),p(!1)},[l]);const y=async()=>{x(!0),await a(Ae.GLOBAL_INSTRUCTIONS,c),x(!1),p(!1)},S=()=>{d(l),p(!1)},C=u||m;return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),i.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),i.jsx("textarea",{value:c,onChange:v=>{d(v.target.value),p(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(mt,{variant:"secondary",onClick:S,disabled:!h,children:"Discard"}),i.jsx(mt,{variant:"primary",onClick:y,disabled:!h||C,children:m?"Saving...":"Save"})]})]})}function g3(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(t){const n=parseInt(t[1]??"0",16),r=parseInt(t[2]??"0",16),a=parseInt(t[3]??"0",16);return`${n} ${r} ${a}`}return e}function qd(e){const t=e.split(" ").map(n=>parseInt(n,10));return t.length===3&&t.every(n=>!isNaN(n))?`#${t.map(n=>(n??0).toString(16).padStart(2,"0")).join("")}`:e}function x3({isOpen:e,isNew:t,basePresetId:n,presetName:r,mode:a,initialTokens:l,onClose:u,onSave:c}){const[d,h]=N.useState(l),[p,m]=N.useState(r),[x,y]=N.useState(a);N.useEffect(()=>{h(l),m(r)},[l,r]);const S=(b,k)=>{const E=k.startsWith("#")?g3(k):k;h(T=>({...T,[b]:E}))},C=()=>{c(p.trim()||"Untitled",{...d},x)},v=Rk.reduce((b,k)=>{const E=k.category;return b[E]||(b[E]=[]),b[E].push(k),b},{}),w={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},_=Qn.find(b=>b.id===n);return i.jsx(Tt,{isOpen:e,onClose:u,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:i.jsxs("div",{className:"flex gap-2 justify-end",children:[i.jsx("button",{type:"button",onClick:u,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),i.jsx("button",{type:"button",onClick:C,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),i.jsx("input",{type:"text",value:p,onChange:b=>m(b.target.value),className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Mode"}),i.jsxs("div",{className:"flex rounded overflow-hidden border border-border",children:[i.jsx("button",{type:"button",onClick:()=>y("dark"),className:`px-3 py-2 text-xs font-medium transition-colors ${x==="dark"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Dark"}),i.jsx("button",{type:"button",onClick:()=>y("light"),className:`px-3 py-2 text-xs font-medium transition-colors ${x==="light"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Light"})]})]})]}),!t&&i.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",i.jsx("span",{className:"text-text-primary",children:_==null?void 0:_.name})]}),Object.entries(v).map(([b,k])=>i.jsxs("div",{className:"space-y-3",children:[i.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:w[b]??b}),i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:k.map(E=>i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:E.key,className:"text-xs text-text-muted",children:E.label}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"color",id:E.key,value:qd(d[E.key]??E.defaultValue),onChange:T=>S(E.key,T.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent flex-shrink-0"}),i.jsx("input",{type:"text",value:d[E.key]??E.defaultValue,onChange:T=>S(E.key,T.target.value),className:"flex-1 min-w-0 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]},E.key))})]},b))]})})}function n1({preset:e,isActive:t,isUnderlying:n,onClick:r,onNewFrom:a,onEdit:l,onDelete:u}){return i.jsxs("div",{className:"relative group",children:[i.jsxs("button",{type:"button",onClick:r,className:`flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors min-w-[80px] ${t?"border-accent-primary bg-bg-tertiary text-text-primary":n?"border-dashed border-accent-primary/50 bg-bg-tertiary/50 text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[i.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:e.id==="system"?"transparent":qd(e.tokens["color-bg-primary"]??"#000"),borderColor:qd(e.tokens["color-border"]??"#000")},children:e.id==="system"?i.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:"linear-gradient(135deg, #000 50%, #fff 50%)"}}):i.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:qd(e.tokens["color-text-primary"]??"#fff")}})}),i.jsx("span",{className:"text-xs",children:e.name})]}),a&&i.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),a()},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Create custom theme based on this",children:i.jsx("span",{className:"text-xs",children:"✎"})}),l&&i.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),l()},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Edit",children:i.jsx("span",{className:"text-xs",children:"✎"})}),u&&i.jsx("button",{type:"button",onClick:c=>u(c),className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-accent-error text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-20",children:i.jsx(ri,{className:"w-3 h-3"})})]})}function y3(){const[e,t]=N.useState(null),n=Ut(z=>z.currentPreset),r=Ut(z=>z.isCustom),a=Ut(z=>z.basePreset),l=Ut(z=>z.isSystem),u=Ut(z=>z.systemDarkPreset),c=Ut(z=>z.systemLightPreset),d=Ut(z=>z.applyPreset),h=Ut(z=>z.applyUserPreset),p=Ut(z=>z.deleteUserPreset),m=Ut(z=>z.saveTheme),x=Ut(z=>z.setSystemDarkPreset),y=Ut(z=>z.setSystemLightPreset),S=Ut(z=>z.activeUserPresetId),C=Ut(z=>z.userPresets),v=Qn.filter(z=>z.mode==="dark"),w=Qn.filter(z=>z.mode==="light"),_=z=>{var H;if(l){const I=C[z];if(!I)return;const U=I.mode??((H=Qn.find(V=>V.id===I.basePreset))==null?void 0:H.mode);U==="dark"?x(I.id):U==="light"&&y(I.id)}else h(z)},b=z=>{const H=Qn.find(I=>I.id===z);H&&t({type:"new",presetIndex:C.length,basePresetId:z,presetName:H.name+" Copy",mode:H.mode??"dark",tokens:{...H.tokens}})},k=z=>{const H=C[z];if(!H)return;const I=Qn.find(V=>V.id===H.basePreset),U=I?{...I.tokens,...H.tokens}:H.tokens;t({type:"edit",presetIndex:z,basePresetId:H.basePreset,presetName:H.name,mode:H.mode??"dark",tokens:U})},E=(z,H,I)=>{if(!e)return;const U=[...C];if(e.type==="new"){const V={id:"custom-"+Date.now(),name:z,basePreset:e.basePresetId,mode:I,tokens:H};U.push(V);const Z=U.length-1;Ut.setState({userPresets:U}),Ut.getState().saveUserPresets(),Ut.getState().applyUserPreset(Z)}else{const V=U[e.presetIndex];V&&(U[e.presetIndex]={...V,name:z,mode:I,tokens:H}),Ut.setState({userPresets:U}),Ut.getState().saveUserPresets(),Ut.getState().applyUserPreset(e.presetIndex)}t(null)},T=()=>{t(null)},D=(z,H)=>{z.stopPropagation(),p(H)},L=l?"system":r?a:n,R=()=>{l?(d(n),m(JSON.stringify({preset:n})).catch(()=>{})):(d("system"),m(JSON.stringify({preset:"system"})).catch(()=>{}))},M=z=>{if(l){const H=Qn.find(I=>I.id===z);(H==null?void 0:H.mode)==="dark"?x(z):(H==null?void 0:H.mode)==="light"&&y(z)}else d(z),m(JSON.stringify({preset:z})).catch(()=>{})},W=z=>{const H=Qn.find(I=>I.id===z.basePreset);return H?{...H.tokens,...z.tokens}:z.tokens};return i.jsxs("div",{className:"space-y-4",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),i.jsxs("label",{className:"flex items-center justify-between gap-3 cursor-pointer",children:[i.jsx("span",{className:"text-sm text-text-primary font-medium",children:"Follow system theme"}),i.jsx("button",{type:"button",onClick:R,className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${l?"bg-accent-primary":"bg-bg-tertiary"}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${l?"translate-x-6":"translate-x-1"}`})})]}),[{title:"Dark Themes",mode:"dark"},{title:"Light Themes",mode:"light"}].map(({title:z,mode:H})=>{const I=H==="dark"?v:w,U=C.filter(V=>{var ee;return(V.mode??((ee=Qn.find(F=>F.id===V.basePreset))==null?void 0:ee.mode))===H});return i.jsxs("div",{children:[i.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:z}),i.jsxs("div",{className:"flex flex-wrap gap-2",children:[I.map(V=>i.jsx(n1,{preset:V,isActive:V.id===L&&!r,isUnderlying:l&&(V.id===u||V.id===c),onClick:()=>M(V.id),onNewFrom:()=>b(V.id)},V.id)),U.map(V=>{const Z=C.indexOf(V),ee=W(V);return i.jsx(n1,{preset:{id:V.id,name:V.name,tokens:ee},isActive:S===V.id,isUnderlying:l&&(V.id===u||V.id===c),onClick:()=>_(Z),onEdit:()=>k(Z),onDelete:F=>D(F,Z)},V.id)})]})]},z)}),e&&i.jsx(x3,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,mode:e.mode,initialTokens:e.tokens,onClose:T,onSave:E})]})}const b3=["monospace","serif","sans-serif"],rj=["JetBrains Mono","Cascadia Mono","Menlo","Consolas","DejaVu Sans Mono","Liberation Mono"],Kd=`${rj.map(e=>`"${e}"`).join(", ")}, monospace`,v3=["Andale Mono","Anonymous Pro","Cascadia Code","Cascadia Mono","Consolas","Courier New","DejaVu Sans Mono","Fira Code","Fira Mono","Geist Mono","Hack","IBM Plex Mono","Inconsolata","Iosevka","JetBrains Mono","Liberation Mono","Menlo","Monaco","Noto Sans Mono","Roboto Mono","SF Mono","Source Code Pro","Space Mono","Ubuntu Mono","Victor Mono","CaskaydiaCove Nerd Font","CaskaydiaCove Nerd Font Mono","DejaVuSansMono Nerd Font","FiraCode Nerd Font","FiraCode Nerd Font Mono","Hack Nerd Font","Hack Nerd Font Mono","Iosevka Nerd Font","JetBrainsMono Nerd Font","JetBrainsMono Nerd Font Mono","MesloLGS NF","MesloLGS Nerd Font","SauceCodePro Nerd Font","SauceCodePro Nerd Font Mono","UbuntuMono Nerd Font"],_3="mmmmmmmmmmlliWWWW@0Oo",S3="72px";let rc;function w3(){if(rc!==void 0)return rc;try{rc=document.createElement("canvas").getContext("2d")}catch{rc=null}return rc}function uy(e){const t=w3();if(!t)throw new Error("Canvas 2D context unavailable");return t.font=`${S3} ${e}`,t.measureText(_3).width}function sj(e,t=uy){const n=e.trim();if(!n)return!1;try{return b3.some(r=>{const a=t(r);return t(`"${n}", ${r}`)!==a})}catch{return!1}}function C3(e=v3,t=uy){const n=new Set;for(const r of e)sj(r,t)&&n.add(r);return[...n].sort((r,a)=>r.localeCompare(a))}function k3(e=rj,t=uy){return e.find(n=>sj(n,t))??""}function j3(e){const t=e.trim();return t?`"${t}", monospace`:""}function E3(e){var n;return(((n=e.split(",")[0])==null?void 0:n.trim())??"").replace(/^['"]|['"]$/g,"")}function N3(){return i.jsx(y3,{})}function T3(){const{settings:e,loading:t,getSetting:n,setSetting:r}=qi(),a=t[Ae.DISPLAY_SHOW_THINKING]??!1,l=e[Ae.DISPLAY_MAX_VISIBLE_ITEMS]??"300",[u,c]=N.useState(l);N.useEffect(()=>{n(Ae.DISPLAY_MAX_VISIBLE_ITEMS)},[n]),N.useEffect(()=>{c(l)},[l]);const d=()=>{const S=parseInt(u,10),C=isNaN(S)||S<0?0:Math.min(S,9999);c(String(C)),r(Ae.DISPLAY_MAX_VISIBLE_ITEMS,String(C))},h=[{key:Ae.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:Ae.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:Ae.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:Ae.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:Ae.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"},{key:Ae.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but costly - applies to code blocks, diffs, and file previews"}],p=Object.fromEntries(h.map(S=>[S.key,e[S.key]??"true"])),[m,x]=N.useState(()=>Object.fromEntries(h.map(S=>[S.key,p[S.key]==="true"])));N.useEffect(()=>{h.forEach(S=>n(S.key))},[n]),N.useEffect(()=>{x(Object.fromEntries(h.map(S=>[S.key,p[S.key]==="true"])))},[JSON.stringify(p)]);const y=async S=>{const C=String(!m[S]);x(v=>({...v,[S]:!v[S]})),await r(S,C)};return a?i.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):i.jsxs("div",{className:"space-y-6",children:[i.jsx(N3,{}),i.jsxs("div",{className:"border-t border-border pt-4",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-2",children:"Custom CSS"}),i.jsx("p",{className:"text-xs text-text-muted mb-3",children:"Add global CSS overrides for any element."}),i.jsx(D3,{})]}),i.jsxs("div",{className:"border-t border-border pt-4",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),i.jsx("div",{className:"space-y-4",children:h.map(({key:S,label:C,description:v})=>i.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-text-primary font-medium",children:C}),i.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:v})]}),i.jsx("button",{type:"button",onClick:()=>y(S),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${m[S]?"bg-accent-primary":"bg-bg-tertiary"}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${m[S]?"translate-x-6":"translate-x-1"}`})})]},S))})]}),i.jsx("div",{className:"border-t border-border pt-4",children:i.jsxs("label",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-text-primary font-medium",children:"Max visible items"}),i.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Keep only the last N items in the feed. Set to 0 to show all."})]}),i.jsx("input",{type:"number",min:0,max:9999,value:u,onChange:S=>{const C=S.target.value.replace(/[^0-9]/g,"");c(C)},onBlur:d,onKeyDown:S=>{S.key==="Enter"&&d()},className:"w-20 px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded text-right"})]})}),i.jsxs("div",{className:"border-t border-border pt-4",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-2",children:"Terminal"}),i.jsx(L3,{})]})]})}const A3="~/project git status ✓ ✗ → 0123 iIlL1 |─┤";function L3(){const{settings:e,getSetting:t,setSetting:n}=qi(),r=e[Ae.DISPLAY_TERMINAL_FONT]??Kd,[a,l]=N.useState(r),u=N.useMemo(()=>C3(),[]),c=N.useMemo(()=>k3(),[]);N.useEffect(()=>{t(Ae.DISPLAY_TERMINAL_FONT)},[t]),N.useEffect(()=>{l(r)},[r]);const h=r===Kd?c:E3(r),p=h!==""&&!u.includes(h),m=y=>{const S=y.target.value;S&&n(Ae.DISPLAY_TERMINAL_FONT,j3(S))},x=()=>{n(Ae.DISPLAY_TERMINAL_FONT,a.trim()||Kd)};return i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs text-text-muted",children:"Only monospace fonts detected on this machine are listed. If your shell theme uses icons or powerline glyphs, pick a Nerd Font."}),i.jsxs("select",{value:p?"":h,onChange:m,className:"w-full px-2 py-1.5 text-sm text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",children:[p&&i.jsx("option",{value:"",children:`Custom: ${h}`}),u.length===0&&i.jsx("option",{value:"",children:"No monospace font detected"}),u.map(y=>i.jsx("option",{value:y,style:{fontFamily:`"${y}", monospace`},children:y},y))]}),i.jsx(Ze,{horizontal:!0,className:"px-3 py-2 text-sm text-text-primary bg-bg-tertiary border border-border rounded whitespace-nowrap",style:{fontFamily:r},children:A3}),i.jsxs("div",{children:[i.jsx("div",{className:"text-xs text-text-muted mb-1",children:'Not listed? Enter a CSS font-family manually (e.g. "My Font", monospace)'}),i.jsx("input",{type:"text",value:a,onChange:y=>l(y.target.value),onBlur:x,onKeyDown:y=>{y.key==="Enter"&&x()},className:"w-full px-2 py-1 text-xs font-mono text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",spellCheck:!1})]})]})}function D3(){const{settings:e,getSetting:t,setSetting:n}=qi(),r=e[Ae.DISPLAY_CUSTOM_CSS]??"",[a,l]=N.useState(r);N.useEffect(()=>{t(Ae.DISPLAY_CUSTOM_CSS)},[t]),N.useEffect(()=>{l(r)},[r]);const u=()=>{n(Ae.DISPLAY_CUSTOM_CSS,a)};return i.jsx("div",{className:"space-y-2",children:i.jsx("textarea",{value:a,onChange:c=>l(c.target.value),onBlur:u,placeholder:"/* Paste your custom CSS here */",className:"w-full h-32 px-3 py-2 text-xs font-mono text-text-primary bg-bg-tertiary border border-border rounded resize-y focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",spellCheck:!1})})}function rx(){const[e,t]=N.useState("Test"),[n,r]=N.useState(""),[a,l]=N.useState(!1),u=N.useCallback(async c=>{t("Testing..."),r(""),l(!1);try{const d=await c();d.success?(t("Success"),l(!0),setTimeout(()=>{t("Test"),l(!1)},3e3)):(r(d.error??"Test failed"),t("Test"))}catch{r("Connection error"),t("Test")}},[]);return[e,n,a,u]}function R3(e){try{return new RegExp(e),!0}catch{return!1}}function O3({value:e,onChange:t}){const[n,r]=N.useState({}),a=(d,h)=>{const p=e.patterns.map((m,x)=>x===d?{...m,...h}:m);t({...e,patterns:p})},l=d=>{const h=e.patterns.filter((p,m)=>m!==d);t({...e,patterns:h})},u=()=>{const d={field:"content",pattern:"",action:"retry",active:!0};t({...e,patterns:[...e.patterns,d]})},c=(d,h)=>{r(p=>({...p,[d]:h.length>0&&!R3(h)})),a(d,{pattern:h})};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-text-primary",children:"Max Retries Per Turn"}),i.jsx("input",{type:"number",min:1,max:100,value:e.maxRetriesPerTurn,onChange:d=>{const h=parseInt(d.target.value,10),p=isNaN(h)?10:Math.max(1,Math.min(100,h));t({...e,maxRetriesPerTurn:p})},className:"mt-1 block w-24 px-2 py-1 text-sm bg-bg-secondary border border-border rounded"})]}),e.patterns.length===0?i.jsx("p",{className:"text-sm text-text-muted",children:"No retry patterns configured."}):i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-left text-text-muted border-b border-border",children:[i.jsx("th",{className:"pb-2 pr-2 w-12",children:"Active"}),i.jsx("th",{className:"pb-2 pr-2",children:"Field"}),i.jsx("th",{className:"pb-2 pr-2",children:"Pattern"}),i.jsx("th",{className:"pb-2 pr-2",children:"Action"}),i.jsx("th",{className:"pb-2 w-8"})]})}),i.jsx("tbody",{children:e.patterns.map((d,h)=>i.jsxs("tr",{className:"border-b border-border",children:[i.jsx("td",{className:"py-2 pr-2",children:i.jsx("input",{type:"checkbox",checked:d.active,onChange:()=>a(h,{active:!d.active}),className:"accent-accent-primary","aria-label":`Toggle pattern ${h+1}`})}),i.jsx("td",{className:"py-2 pr-2",children:i.jsxs("select",{value:d.field,onChange:p=>a(h,{field:p.target.value}),className:"px-2 py-1 bg-bg-secondary border border-border rounded text-sm",children:[i.jsx("option",{value:"content",children:"content"}),i.jsx("option",{value:"thinking",children:"thinking"}),i.jsx("option",{value:"both",children:"both"})]})}),i.jsx("td",{className:"py-2 pr-2",children:i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("input",{type:"text",value:d.pattern,onChange:p=>c(h,p.target.value),placeholder:"regex pattern",className:"flex-1 px-2 py-1 bg-bg-secondary border border-border rounded text-sm font-mono"}),d.pattern.length>0&&i.jsx("span",{className:`text-sm ${n[h]?"text-red-500":"text-green-500"}`,children:n[h]?"✗":"✓"})]})}),i.jsx("td",{className:"py-2 pr-2 text-text-muted",children:"retry"}),i.jsx("td",{className:"py-2",children:i.jsx("button",{onClick:()=>l(h),title:"Remove pattern",className:"text-text-muted hover:text-red-500 transition-colors",children:"×"})})]},h))})]}),i.jsx(mt,{variant:"secondary",onClick:u,children:"Add Pattern"})]})}function ij({isOpen:e,onClose:t,versionInfo:n}){const[r,a]=N.useState("ready"),[l,u]=N.useState(""),[c,d]=N.useState(n),[h,p]=N.useState(null),[m,x]=N.useState(null);N.useEffect(()=>{!e||n||fetch(ni("/api/auto-update/check")).then(w=>w.json()).then(w=>{d({current:w.current,latest:w.latest})}).catch(()=>{})},[e]),N.useEffect(()=>{if(!e||r!=="updating"&&r!=="restarting")return;const w=setInterval(()=>{u(_=>_.length>=3?"":_+".")},400);return()=>clearInterval(w)},[e,r]);const y=N.useCallback(async()=>{a("updating"),x(null);try{const _=await(await Ce("/api/auto-update",{method:"POST"})).json();if(_.success){const b=_.version??"unknown";p(b),localStorage.setItem("openfox_updated_to",b),localStorage.setItem("update_pending","true"),_.isService?(a("restarting"),await Ce("/api/auto-update/restart",{method:"POST"}).catch(()=>{}),setTimeout(()=>window.location.reload(),5e3)):a("complete")}else x(_.error??"Update failed"),a("failed")}catch(w){x(w instanceof Error?w.message:"Update request failed"),a("failed")}},[]);N.useEffect(()=>{e&&(a("ready"),u(""),p(null),x(null))},[e]);const S=r!=="updating"&&r!=="restarting",C=w=>w,v=r==="failed"?"Update Failed":r==="complete"||r==="restarting"?"Update Complete":"New OpenFox version available";return i.jsxs(Tt,{isOpen:e,onClose:S?t:void 0,title:v,size:"md",closeOnBackdropClick:S,showCloseButton:S,children:[i.jsxs("div",{className:"flex flex-col gap-4",children:[c&&i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-text-muted",children:"Current version"}),i.jsx("span",{className:"text-text-primary font-mono",children:C(c.current)})]}),c&&i.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[i.jsx("span",{className:"text-text-muted",children:"Latest version"}),i.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:c.latest})]}),(r==="updating"||r==="restarting")&&i.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[i.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),i.jsxs("p",{className:"text-xs text-text-muted text-center",children:[r==="restarting"?"Restarting":"Updating",l]})]}),r==="complete"&&i.jsx("div",{className:"flex flex-col gap-3 mt-2",children:i.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",h??(c==null?void 0:c.latest),"."," Please restart OpenFox to use the new version."]})}),r==="failed"&&i.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[i.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-danger/10 border border-accent-danger/30 rounded text-xs",children:[i.jsx("span",{children:"⚠️"}),i.jsx("p",{className:"text-text-secondary",children:m})]}),i.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:"openfox update"}),i.jsx("p",{className:"text-xs text-text-muted",children:"Run this command in your terminal to complete the update."})]})]}),r==="ready"&&i.jsx("button",{onClick:y,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Update OpenFox"}),(r==="complete"||r==="failed")&&i.jsx("button",{onClick:t,className:"w-full px-3 py-2 text-sm rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors text-text-primary font-medium mt-2",children:"Close"})]})}function I3(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const M3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,P3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,B3={};function r1(e,t){return(B3.jsx?P3:M3).test(e)}const $3=/[ \t\n\f\r]/g;function z3(e){return typeof e=="object"?e.type==="text"?s1(e.value):!1:s1(e)}function s1(e){return e.replace($3,"")===""}let qc=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};qc.prototype.normal={};qc.prototype.property={};qc.prototype.space=void 0;function aj(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new qc(n,r,t)}function sx(e){return e.toLowerCase()}let dr=class{constructor(t,n){this.attribute=n,this.property=t}};dr.prototype.attribute="";dr.prototype.booleanish=!1;dr.prototype.boolean=!1;dr.prototype.commaOrSpaceSeparated=!1;dr.prototype.commaSeparated=!1;dr.prototype.defined=!1;dr.prototype.mustUseProperty=!1;dr.prototype.number=!1;dr.prototype.overloadedBoolean=!1;dr.prototype.property="";dr.prototype.spaceSeparated=!1;dr.prototype.space=void 0;let H3=0;const xt=$a(),wn=$a(),ix=$a(),Ue=$a(),qt=$a(),La=$a(),_r=$a();function $a(){return 2**++H3}const ax=Object.freeze(Object.defineProperty({__proto__:null,boolean:xt,booleanish:wn,commaOrSpaceSeparated:_r,commaSeparated:La,number:Ue,overloadedBoolean:ix,spaceSeparated:qt},Symbol.toStringTag,{value:"Module"})),Yp=Object.keys(ax);let dy=class extends dr{constructor(t,n,r,a){let l=-1;if(super(t,n),i1(this,"space",a),typeof r=="number")for(;++l<Yp.length;){const u=Yp[l];i1(this,Yp[l],(r&ax[u])===ax[u])}}};dy.prototype.defined=!0;function i1(e,t,n){n&&(e[t]=n)}function rl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const l=new dy(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[sx(r)]=r,n[sx(l.attribute)]=r}return new qc(t,n,e.space)}const oj=rl({properties:{ariaActiveDescendant:null,ariaAtomic:wn,ariaAutoComplete:null,ariaBusy:wn,ariaChecked:wn,ariaColCount:Ue,ariaColIndex:Ue,ariaColSpan:Ue,ariaControls:qt,ariaCurrent:null,ariaDescribedBy:qt,ariaDetails:null,ariaDisabled:wn,ariaDropEffect:qt,ariaErrorMessage:null,ariaExpanded:wn,ariaFlowTo:qt,ariaGrabbed:wn,ariaHasPopup:null,ariaHidden:wn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:qt,ariaLevel:Ue,ariaLive:null,ariaModal:wn,ariaMultiLine:wn,ariaMultiSelectable:wn,ariaOrientation:null,ariaOwns:qt,ariaPlaceholder:null,ariaPosInSet:Ue,ariaPressed:wn,ariaReadOnly:wn,ariaRelevant:null,ariaRequired:wn,ariaRoleDescription:qt,ariaRowCount:Ue,ariaRowIndex:Ue,ariaRowSpan:Ue,ariaSelected:wn,ariaSetSize:Ue,ariaSort:null,ariaValueMax:Ue,ariaValueMin:Ue,ariaValueNow:Ue,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function lj(e,t){return t in e?e[t]:t}function cj(e,t){return lj(e,t.toLowerCase())}const F3=rl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:La,acceptCharset:qt,accessKey:qt,action:null,allow:null,allowFullScreen:xt,allowPaymentRequest:xt,allowUserMedia:xt,alpha:xt,alt:null,as:null,async:xt,autoCapitalize:null,autoComplete:qt,autoFocus:xt,autoPlay:xt,blocking:qt,capture:null,charSet:null,checked:xt,cite:null,className:qt,closedBy:null,colorSpace:null,cols:Ue,colSpan:Ue,command:null,commandFor:null,content:null,contentEditable:wn,controls:xt,controlsList:qt,coords:Ue|La,crossOrigin:null,data:null,dateTime:null,decoding:null,default:xt,defer:xt,dir:null,dirName:null,disabled:xt,download:ix,draggable:wn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:xt,formTarget:null,headers:qt,height:Ue,hidden:ix,high:Ue,href:null,hrefLang:null,htmlFor:qt,httpEquiv:qt,id:null,imageSizes:null,imageSrcSet:null,inert:xt,inputMode:null,integrity:null,is:null,isMap:xt,itemId:null,itemProp:qt,itemRef:qt,itemScope:xt,itemType:qt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:xt,low:Ue,manifest:null,max:null,maxLength:Ue,media:null,method:null,min:null,minLength:Ue,multiple:xt,muted:xt,name:null,nonce:null,noModule:xt,noValidate:xt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:xt,optimum:Ue,pattern:null,ping:qt,placeholder:null,playsInline:xt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:xt,referrerPolicy:null,rel:qt,required:xt,reversed:xt,rows:Ue,rowSpan:Ue,sandbox:qt,scope:null,scoped:xt,seamless:xt,selected:xt,shadowRootClonable:xt,shadowRootCustomElementRegistry:xt,shadowRootDelegatesFocus:xt,shadowRootMode:null,shadowRootSerializable:xt,shape:null,size:Ue,sizes:null,slot:null,span:Ue,spellCheck:wn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ue,step:null,style:null,tabIndex:Ue,target:null,title:null,translate:null,type:null,typeMustMatch:xt,useMap:null,value:wn,width:Ue,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:qt,axis:null,background:null,bgColor:null,border:Ue,borderColor:null,bottomMargin:Ue,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:xt,declare:xt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ue,leftMargin:Ue,link:null,longDesc:null,lowSrc:null,marginHeight:Ue,marginWidth:Ue,noResize:xt,noHref:xt,noShade:xt,noWrap:xt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ue,rules:null,scheme:null,scrolling:wn,standby:null,summary:null,text:null,topMargin:Ue,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ue,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:xt,disablePictureInPicture:xt,disableRemotePlayback:xt,exportParts:La,part:qt,prefix:null,property:null,results:Ue,security:null,unselectable:null},space:"html",transform:cj}),U3=rl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:_r,accentHeight:Ue,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ue,amplitude:Ue,arabicForm:null,ascent:Ue,attributeName:null,attributeType:null,azimuth:Ue,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ue,by:null,calcMode:null,capHeight:Ue,className:qt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ue,diffuseConstant:Ue,direction:null,display:null,dur:null,divisor:Ue,dominantBaseline:null,download:xt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ue,enableBackground:null,end:null,event:null,exponent:Ue,externalResourcesRequired:null,fill:null,fillOpacity:Ue,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:La,g2:La,glyphName:La,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ue,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ue,horizOriginX:Ue,horizOriginY:Ue,id:null,ideographic:Ue,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ue,k:Ue,k1:Ue,k2:Ue,k3:Ue,k4:Ue,kernelMatrix:_r,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ue,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ue,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ue,overlineThickness:Ue,paintOrder:null,panose1:null,path:null,pathLength:Ue,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:qt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ue,pointsAtY:Ue,pointsAtZ:Ue,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:_r,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:_r,rev:_r,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:_r,requiredFeatures:_r,requiredFonts:_r,requiredFormats:_r,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ue,specularExponent:Ue,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ue,strikethroughThickness:Ue,string:null,stroke:null,strokeDashArray:_r,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ue,strokeOpacity:Ue,strokeWidth:null,style:null,surfaceScale:Ue,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:_r,tabIndex:Ue,tableValues:null,target:null,targetX:Ue,targetY:Ue,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:_r,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ue,underlineThickness:Ue,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ue,values:null,vAlphabetic:Ue,vMathematical:Ue,vectorEffect:null,vHanging:Ue,vIdeographic:Ue,version:null,vertAdvY:Ue,vertOriginX:Ue,vertOriginY:Ue,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ue,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:lj}),uj=rl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),dj=rl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:cj}),hj=rl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),V3={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},W3=/[A-Z]/g,a1=/-[a-z]/g,G3=/^data[-\w.:]+$/i;function q3(e,t){const n=sx(t);let r=t,a=dr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&G3.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(a1,Y3);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!a1.test(l)){let u=l.replace(W3,K3);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=dy}return new a(r,t)}function K3(e){return"-"+e.toLowerCase()}function Y3(e){return e.charAt(1).toUpperCase()}const X3=aj([oj,F3,uj,dj,hj],"html"),hy=aj([oj,U3,uj,dj,hj],"svg");function Q3(e){return e.join(" ").trim()}var ko={},Xp,o1;function J3(){if(o1)return Xp;o1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,d=`
|
|
68
|
+
`,h="/",p="*",m="",x="comment",y="declaration";function S(v,w){if(typeof v!="string")throw new TypeError("First argument must be a string");if(!v)return[];w=w||{};var _=1,b=1;function k(I){var U=I.match(t);U&&(_+=U.length);var V=I.lastIndexOf(d);b=~V?I.length-V:b+I.length}function E(){var I={line:_,column:b};return function(U){return U.position=new T(I),R(),U}}function T(I){this.start=I,this.end={line:_,column:b},this.source=w.source}T.prototype.content=v;function D(I){var U=new Error(w.source+":"+_+":"+b+": "+I);if(U.reason=I,U.filename=w.source,U.line=_,U.column=b,U.source=v,!w.silent)throw U}function L(I){var U=I.exec(v);if(U){var V=U[0];return k(V),v=v.slice(V.length),U}}function R(){L(n)}function M(I){var U;for(I=I||[];U=W();)U!==!1&&I.push(U);return I}function W(){var I=E();if(!(h!=v.charAt(0)||p!=v.charAt(1))){for(var U=2;m!=v.charAt(U)&&(p!=v.charAt(U)||h!=v.charAt(U+1));)++U;if(U+=2,m===v.charAt(U-1))return D("End of comment missing");var V=v.slice(2,U-2);return b+=2,k(V),v=v.slice(U),b+=2,I({type:x,comment:V})}}function z(){var I=E(),U=L(r);if(U){if(W(),!L(a))return D("property missing ':'");var V=L(l),Z=I({type:y,property:C(U[0].replace(e,m)),value:V?C(V[0].replace(e,m)):m});return L(u),Z}}function H(){var I=[];M(I);for(var U;U=z();)U!==!1&&(I.push(U),M(I));return I}return R(),H()}function C(v){return v?v.replace(c,m):m}return Xp=S,Xp}var l1;function Z3(){if(l1)return ko;l1=1;var e=ko&&ko.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ko,"__esModule",{value:!0}),ko.default=n;const t=e(J3());function n(r,a){let l=null;if(!r||typeof r!="string")return l;const u=(0,t.default)(r),c=typeof a=="function";return u.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:p}=d;c?a(h,p,d):p&&(l=l||{},l[h]=p)}),l}return ko}var sc={},c1;function e5(){if(c1)return sc;c1=1,Object.defineProperty(sc,"__esModule",{value:!0}),sc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,l=function(h){return!h||n.test(h)||e.test(h)},u=function(h,p){return p.toUpperCase()},c=function(h,p){return"".concat(p,"-")},d=function(h,p){return p===void 0&&(p={}),l(h)?h:(h=h.toLowerCase(),p.reactCompat?h=h.replace(a,c):h=h.replace(r,c),h.replace(t,u))};return sc.camelCase=d,sc}var ic,u1;function t5(){if(u1)return ic;u1=1;var e=ic&&ic.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(Z3()),n=e5();function r(a,l){var u={};return!a||typeof a!="string"||(0,t.default)(a,function(c,d){c&&d&&(u[(0,n.camelCase)(c,l)]=d)}),u}return r.default=r,ic=r,ic}var n5=t5();const r5=Lh(n5),fj=mj("end"),fy=mj("start");function mj(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function s5(e){const t=fy(e),n=fj(e);if(t&&n)return{start:t,end:n}}function vc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?d1(e.position):"start"in e||"end"in e?d1(e):"line"in e||"column"in e?ox(e):""}function ox(e){return h1(e&&e.line)+":"+h1(e&&e.column)}function d1(e){return ox(e&&e.start)+"-"+ox(e&&e.end)}function h1(e){return e&&typeof e=="number"?e:1}class qn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",l={},u=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?a=t:!l.cause&&t&&(u=!0,a=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof r=="string"){const d=r.indexOf(":");d===-1?l.ruleId=r:(l.source=r.slice(0,d),l.ruleId=r.slice(d+1))}if(!l.place&&l.ancestors&&l.ancestors){const d=l.ancestors[l.ancestors.length-1];d&&(l.place=d.position)}const c=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=vc(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=u&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}qn.prototype.file="";qn.prototype.name="";qn.prototype.reason="";qn.prototype.message="";qn.prototype.stack="";qn.prototype.column=void 0;qn.prototype.line=void 0;qn.prototype.ancestors=void 0;qn.prototype.cause=void 0;qn.prototype.fatal=void 0;qn.prototype.place=void 0;qn.prototype.ruleId=void 0;qn.prototype.source=void 0;const my={}.hasOwnProperty,i5=new Map,a5=/[A-Z]/g,o5=new Set(["table","tbody","thead","tfoot","tr"]),l5=new Set(["td","th"]),pj="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function c5(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=x5(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=g5(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?hy:X3,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=gj(a,e,void 0);return l&&typeof l!="string"?l:a.create(e,a.Fragment,{children:l||void 0},void 0)}function gj(e,t,n){if(t.type==="element")return u5(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return d5(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return f5(e,t,n);if(t.type==="mdxjsEsm")return h5(e,t);if(t.type==="root")return m5(e,t,n);if(t.type==="text")return p5(e,t)}function u5(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=hy,e.schema=a),e.ancestors.push(t);const l=yj(e,t.tagName,!1),u=y5(e,t);let c=gy(e,t);return o5.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!z3(d):!0})),xj(e,u,l,t),py(u,c),e.ancestors.pop(),e.schema=r,e.create(t,l,u,n)}function d5(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Ic(e,t.position)}function h5(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ic(e,t.position)}function f5(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=hy,e.schema=a),e.ancestors.push(t);const l=t.name===null?e.Fragment:yj(e,t.name,!0),u=b5(e,t),c=gy(e,t);return xj(e,u,l,t),py(u,c),e.ancestors.pop(),e.schema=r,e.create(t,l,u,n)}function m5(e,t,n){const r={};return py(r,gy(e,t)),e.create(t,e.Fragment,r,n)}function p5(e,t){return t.value}function xj(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function py(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function g5(e,t,n){return r;function r(a,l,u,c){const h=Array.isArray(u.children)?n:t;return c?h(l,u,c):h(l,u)}}function x5(e,t){return n;function n(r,a,l,u){const c=Array.isArray(l.children),d=fy(r);return t(a,l,u,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function y5(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&my.call(t.properties,a)){const l=v5(e,a,t.properties[a]);if(l){const[u,c]=l;e.tableCellAlignToStyle&&u==="align"&&typeof c=="string"&&l5.has(t.tagName)?r=c:n[u]=c}}if(r){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function b5(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const l=r.data.estree.body[0];l.type;const u=l.expression;u.type;const c=u.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else Ic(e,t.position);else{const a=r.name;let l;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,l=e.evaluater.evaluateExpression(c.expression)}else Ic(e,t.position);else l=r.value===null?!0:r.value;n[a]=l}return n}function gy(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:i5;for(;++r<t.children.length;){const l=t.children[r];let u;if(e.passKeys){const d=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(d){const h=a.get(d)||0;u=d+"-"+h,a.set(d,h+1)}}const c=gj(e,l,u);c!==void 0&&n.push(c)}return n}function v5(e,t,n){const r=q3(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?I3(n):Q3(n)),r.property==="style"){let a=typeof n=="object"?n:_5(e,String(n));return e.stylePropertyNameCase==="css"&&(a=S5(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?V3[r.property]||r.property:r.attribute,n]}}function _5(e,t){try{return r5(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new qn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=pj+"#cannot-parse-style-attribute",a}}function yj(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let l=-1,u;for(;++l<a.length;){const c=r1(a[l])?{type:"Identifier",name:a[l]}:{type:"Literal",value:a[l]};u=u?{type:"MemberExpression",object:u,property:c,computed:!!(l&&c.type==="Literal"),optional:!1}:c}r=u}else r=r1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return my.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ic(e)}function Ic(e,t){const n=new qn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=pj+"#cannot-handle-mdx-estrees-without-createevaluater",n}function S5(e){const t={};let n;for(n in e)my.call(e,n)&&(t[w5(n)]=e[n]);return t}function w5(e){let t=e.replace(a5,C5);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function C5(e){return"-"+e.toLowerCase()}const Qp={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},k5={};function xy(e,t){const n=k5,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return bj(e,r,a)}function bj(e,t,n){if(j5(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return f1(e.children,t,n)}return Array.isArray(e)?f1(e,t,n):""}function f1(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=bj(e[a],t,n);return r.join("")}function j5(e){return!!(e&&typeof e=="object")}const m1=document.createElement("i");function yy(e){const t="&"+e+";";m1.innerHTML=t;const n=m1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function jr(e,t,n,r){const a=e.length;let l=0,u;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)u=Array.from(r),u.unshift(t,n),e.splice(...u);else for(n&&e.splice(t,n);l<r.length;)u=r.slice(l,l+1e4),u.unshift(t,0),e.splice(...u),l+=1e4,t+=1e4}function $r(e,t){return e.length>0?(jr(e,e.length,0,t),e):t}const p1={}.hasOwnProperty;function vj(e){const t={};let n=-1;for(;++n<e.length;)E5(t,e[n]);return t}function E5(e,t){let n;for(n in t){const a=(p1.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let u;if(l)for(u in l){p1.call(a,u)||(a[u]=[]);const c=l[u];N5(a[u],Array.isArray(c)?c:c?[c]:[])}}}function N5(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);jr(e,0,0,r)}function _j(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function rs(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Zn=Ki(/[A-Za-z]/),Wn=Ki(/[\dA-Za-z]/),T5=Ki(/[#-'*+\--9=?A-Z^-~]/);function ch(e){return e!==null&&(e<32||e===127)}const lx=Ki(/\d/),A5=Ki(/[\dA-Fa-f]/),L5=Ki(/[!-/:-@[-`{-~]/);function ht(e){return e!==null&&e<-2}function Yt(e){return e!==null&&(e<0||e===32)}function jt(e){return e===-2||e===-1||e===32}const Yh=Ki(new RegExp("\\p{P}|\\p{S}","u")),Ia=Ki(/\s/);function Ki(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function sl(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const l=e.charCodeAt(n);let u="";if(l===37&&Wn(e.charCodeAt(n+1))&&Wn(e.charCodeAt(n+2)))a=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(u=String.fromCharCode(l));else if(l>55295&&l<57344){const c=e.charCodeAt(n+1);l<56320&&c>56319&&c<57344?(u=String.fromCharCode(l,c),a=1):u="�"}else u=String.fromCharCode(l);u&&(t.push(e.slice(r,n),encodeURIComponent(u)),r=n+a+1,u=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function Dt(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let l=0;return u;function u(d){return jt(d)?(e.enter(n),c(d)):t(d)}function c(d){return jt(d)&&l++<a?(e.consume(d),c):(e.exit(n),t(d))}}const D5={tokenize:R5};function R5(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Dt(e,t,"linePrefix")}function a(c){return e.enter("paragraph"),l(c)}function l(c){const d=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,u(c)}function u(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return ht(c)?(e.consume(c),e.exit("chunkText"),l):(e.consume(c),u)}}const O5={tokenize:I5},g1={tokenize:M5};function I5(e){const t=this,n=[];let r=0,a,l,u;return c;function c(b){if(r<n.length){const k=n[r];return t.containerState=k[1],e.attempt(k[0].continuation,d,h)(b)}return h(b)}function d(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&_();const k=t.events.length;let E=k,T;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){T=t.events[E][1].end;break}w(r);let D=k;for(;D<t.events.length;)t.events[D][1].end={...T},D++;return jr(t.events,E+1,0,t.events.slice(k)),t.events.length=D,h(b)}return c(b)}function h(b){if(r===n.length){if(!a)return x(b);if(a.currentConstruct&&a.currentConstruct.concrete)return S(b);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(g1,p,m)(b)}function p(b){return a&&_(),w(r),x(b)}function m(b){return t.parser.lazy[t.now().line]=r!==n.length,u=t.now().offset,S(b)}function x(b){return t.containerState={},e.attempt(g1,y,S)(b)}function y(b){return r++,n.push([t.currentConstruct,t.containerState]),x(b)}function S(b){if(b===null){a&&_(),w(0),e.consume(b);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:l}),C(b)}function C(b){if(b===null){v(e.exit("chunkFlow"),!0),w(0),e.consume(b);return}return ht(b)?(e.consume(b),v(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(b),C)}function v(b,k){const E=t.sliceStream(b);if(k&&E.push(null),b.previous=l,l&&(l.next=b),l=b,a.defineSkip(b.start),a.write(E),t.parser.lazy[b.start.line]){let T=a.events.length;for(;T--;)if(a.events[T][1].start.offset<u&&(!a.events[T][1].end||a.events[T][1].end.offset>u))return;const D=t.events.length;let L=D,R,M;for(;L--;)if(t.events[L][0]==="exit"&&t.events[L][1].type==="chunkFlow"){if(R){M=t.events[L][1].end;break}R=!0}for(w(r),T=D;T<t.events.length;)t.events[T][1].end={...M},T++;jr(t.events,L+1,0,t.events.slice(D)),t.events.length=T}}function w(b){let k=n.length;for(;k-- >b;){const E=n[k];t.containerState=E[1],E[0].exit.call(t,e)}n.length=b}function _(){a.write([null]),l=void 0,a=void 0,t.containerState._closeFlow=void 0}}function M5(e,t,n){return Dt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ko(e){if(e===null||Yt(e)||Ia(e))return 1;if(Yh(e))return 2}function Xh(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const l=e[a].resolveAll;l&&!r.includes(l)&&(t=l(t,n),r.push(l))}return t}const cx={name:"attention",resolveAll:P5,tokenize:B5};function P5(e,t){let n=-1,r,a,l,u,c,d,h,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;d=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const m={...e[r][1].end},x={...e[n][1].start};x1(m,-d),x1(x,d),u={type:d>1?"strongSequence":"emphasisSequence",start:m,end:{...e[r][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:x},l={type:d>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:d>1?"strong":"emphasis",start:{...u.start},end:{...c.end}},e[r][1].end={...u.start},e[n][1].start={...c.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=$r(h,[["enter",e[r][1],t],["exit",e[r][1],t]])),h=$r(h,[["enter",a,t],["enter",u,t],["exit",u,t],["enter",l,t]]),h=$r(h,Xh(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),h=$r(h,[["exit",l,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,h=$r(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,jr(e,r-1,n-r+3,h),n=r+h.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function B5(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Ko(r);let l;return u;function u(d){return l=d,e.enter("attentionSequence"),c(d)}function c(d){if(d===l)return e.consume(d),c;const h=e.exit("attentionSequence"),p=Ko(d),m=!p||p===2&&a||n.includes(d),x=!a||a===2&&p||n.includes(r);return h._open=!!(l===42?m:m&&(a||!x)),h._close=!!(l===42?x:x&&(p||!m)),t(d)}}function x1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const $5={name:"autolink",tokenize:z5};function z5(e,t,n){let r=0;return a;function a(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(y){return Zn(y)?(e.consume(y),u):y===64?n(y):h(y)}function u(y){return y===43||y===45||y===46||Wn(y)?(r=1,c(y)):h(y)}function c(y){return y===58?(e.consume(y),r=0,d):(y===43||y===45||y===46||Wn(y))&&r++<32?(e.consume(y),c):(r=0,h(y))}function d(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):y===null||y===32||y===60||ch(y)?n(y):(e.consume(y),d)}function h(y){return y===64?(e.consume(y),p):T5(y)?(e.consume(y),h):n(y)}function p(y){return Wn(y)?m(y):n(y)}function m(y){return y===46?(e.consume(y),r=0,p):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):x(y)}function x(y){if((y===45||Wn(y))&&r++<63){const S=y===45?x:m;return e.consume(y),S}return n(y)}}const Kc={partial:!0,tokenize:H5};function H5(e,t,n){return r;function r(l){return jt(l)?Dt(e,a,"linePrefix")(l):a(l)}function a(l){return l===null||ht(l)?t(l):n(l)}}const Sj={continuation:{tokenize:U5},exit:V5,name:"blockQuote",tokenize:F5};function F5(e,t,n){const r=this;return a;function a(u){if(u===62){const c=r.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),l}return n(u)}function l(u){return jt(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function U5(e,t,n){const r=this;return a;function a(u){return jt(u)?Dt(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):l(u)}function l(u){return e.attempt(Sj,t,n)(u)}}function V5(e){e.exit("blockQuote")}const wj={name:"characterEscape",tokenize:W5};function W5(e,t,n){return r;function r(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),a}function a(l){return L5(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const Cj={name:"characterReference",tokenize:G5};function G5(e,t,n){const r=this;let a=0,l,u;return c;function c(m){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),d}function d(m){return m===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(m),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),l=31,u=Wn,p(m))}function h(m){return m===88||m===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(m),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,u=A5,p):(e.enter("characterReferenceValue"),l=7,u=lx,p(m))}function p(m){if(m===59&&a){const x=e.exit("characterReferenceValue");return u===Wn&&!yy(r.sliceSerialize(x))?n(m):(e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(m)&&a++<l?(e.consume(m),p):n(m)}}const y1={partial:!0,tokenize:K5},b1={concrete:!0,name:"codeFenced",tokenize:q5};function q5(e,t,n){const r=this,a={partial:!0,tokenize:E};let l=0,u=0,c;return d;function d(T){return h(T)}function h(T){const D=r.events[r.events.length-1];return l=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,c=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(T)}function p(T){return T===c?(u++,e.consume(T),p):u<3?n(T):(e.exit("codeFencedFenceSequence"),jt(T)?Dt(e,m,"whitespace")(T):m(T))}function m(T){return T===null||ht(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(y1,C,k)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(T))}function x(T){return T===null||ht(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),m(T)):jt(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Dt(e,y,"whitespace")(T)):T===96&&T===c?n(T):(e.consume(T),x)}function y(T){return T===null||ht(T)?m(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),S(T))}function S(T){return T===null||ht(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),m(T)):T===96&&T===c?n(T):(e.consume(T),S)}function C(T){return e.attempt(a,k,v)(T)}function v(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),w}function w(T){return l>0&&jt(T)?Dt(e,_,"linePrefix",l+1)(T):_(T)}function _(T){return T===null||ht(T)?e.check(y1,C,k)(T):(e.enter("codeFlowValue"),b(T))}function b(T){return T===null||ht(T)?(e.exit("codeFlowValue"),_(T)):(e.consume(T),b)}function k(T){return e.exit("codeFenced"),t(T)}function E(T,D,L){let R=0;return M;function M(U){return T.enter("lineEnding"),T.consume(U),T.exit("lineEnding"),W}function W(U){return T.enter("codeFencedFence"),jt(U)?Dt(T,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):z(U)}function z(U){return U===c?(T.enter("codeFencedFenceSequence"),H(U)):L(U)}function H(U){return U===c?(R++,T.consume(U),H):R>=u?(T.exit("codeFencedFenceSequence"),jt(U)?Dt(T,I,"whitespace")(U):I(U)):L(U)}function I(U){return U===null||ht(U)?(T.exit("codeFencedFence"),D(U)):L(U)}}}function K5(e,t,n){const r=this;return a;function a(u){return u===null?n(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l)}function l(u){return r.parser.lazy[r.now().line]?n(u):t(u)}}const Jp={name:"codeIndented",tokenize:X5},Y5={partial:!0,tokenize:Q5};function X5(e,t,n){const r=this;return a;function a(h){return e.enter("codeIndented"),Dt(e,l,"linePrefix",5)(h)}function l(h){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?u(h):n(h)}function u(h){return h===null?d(h):ht(h)?e.attempt(Y5,u,d)(h):(e.enter("codeFlowValue"),c(h))}function c(h){return h===null||ht(h)?(e.exit("codeFlowValue"),u(h)):(e.consume(h),c)}function d(h){return e.exit("codeIndented"),t(h)}}function Q5(e,t,n){const r=this;return a;function a(u){return r.parser.lazy[r.now().line]?n(u):ht(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),a):Dt(e,l,"linePrefix",5)(u)}function l(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):ht(u)?a(u):n(u)}}const J5={name:"codeText",previous:eO,resolve:Z5,tokenize:tO};function Z5(e){let t=e.length-4,n=3,r,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)a===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(a=r):(r===t||e[r][1].type==="lineEnding")&&(e[a][1].type="codeTextData",r!==a+2&&(e[a][1].end=e[r-1][1].end,e.splice(a+2,r-a-2),t-=r-a-2,r=a+2),a=void 0);return e}function eO(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function tO(e,t,n){let r=0,a,l;return u;function u(m){return e.enter("codeText"),e.enter("codeTextSequence"),c(m)}function c(m){return m===96?(e.consume(m),r++,c):(e.exit("codeTextSequence"),d(m))}function d(m){return m===null?n(m):m===32?(e.enter("space"),e.consume(m),e.exit("space"),d):m===96?(l=e.enter("codeTextSequence"),a=0,p(m)):ht(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),d):(e.enter("codeTextData"),h(m))}function h(m){return m===null||m===32||m===96||ht(m)?(e.exit("codeTextData"),d(m)):(e.consume(m),h)}function p(m){return m===96?(e.consume(m),a++,p):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(m)):(l.type="codeTextData",h(m))}}class nO{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const a=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&ac(this.left,r),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ac(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ac(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);ac(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ac(this.left,n.reverse())}}}function ac(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function kj(e){const t={};let n=-1,r,a,l,u,c,d,h;const p=new nO(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(d=r[1]._tokenizer.events,l=0,l<d.length&&d[l][1].type==="lineEndingBlank"&&(l+=2),l<d.length&&d[l][1].type==="content"))for(;++l<d.length&&d[l][1].type!=="content";)d[l][1].type==="chunkText"&&(d[l][1]._isInFirstContentOfListItem=!0,l++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,rO(p,n)),n=t[n],h=!0);else if(r[1]._container){for(l=n,a=void 0;l--;)if(u=p.get(l),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(a&&(p.get(a)[1].type="lineEndingBlank"),u[1].type="lineEnding",a=l);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;a&&(r[1].end={...p.get(a)[1].start},c=p.slice(a,n),c.unshift(r),p.splice(a,n-a+1,c))}}return jr(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!h}function rO(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const l=[];let u=n._tokenizer;u||(u=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const c=u.events,d=[],h={};let p,m,x=-1,y=n,S=0,C=0;const v=[C];for(;y;){for(;e.get(++a)[1]!==y;);l.push(a),y._tokenizer||(p=r.sliceStream(y),y.next||p.push(null),m&&u.defineSkip(y.start),y._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(p),y._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),m=y,y=y.next}for(y=n;++x<c.length;)c[x][0]==="exit"&&c[x-1][0]==="enter"&&c[x][1].type===c[x-1][1].type&&c[x][1].start.line!==c[x][1].end.line&&(C=x+1,v.push(C),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(u.events=[],y?(y._tokenizer=void 0,y.previous=void 0):v.pop(),x=v.length;x--;){const w=c.slice(v[x],v[x+1]),_=l.pop();d.push([_,_+w.length-1]),e.splice(_,2,w)}for(d.reverse(),x=-1;++x<d.length;)h[S+d[x][0]]=S+d[x][1],S+=d[x][1]-d[x][0]-1;return h}const sO={resolve:aO,tokenize:oO},iO={partial:!0,tokenize:lO};function aO(e){return kj(e),e}function oO(e,t){let n;return r;function r(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(c)}function a(c){return c===null?l(c):ht(c)?e.check(iO,u,l)(c):(e.consume(c),a)}function l(c){return e.exit("chunkContent"),e.exit("content"),t(c)}function u(c){return e.consume(c),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function lO(e,t,n){const r=this;return a;function a(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),Dt(e,l,"linePrefix")}function l(u){if(u===null||ht(u))return n(u);const c=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):e.interrupt(r.parser.constructs.flow,n,t)(u)}}function jj(e,t,n,r,a,l,u,c,d){const h=d||Number.POSITIVE_INFINITY;let p=0;return m;function m(w){return w===60?(e.enter(r),e.enter(a),e.enter(l),e.consume(w),e.exit(l),x):w===null||w===32||w===41||ch(w)?n(w):(e.enter(r),e.enter(u),e.enter(c),e.enter("chunkString",{contentType:"string"}),C(w))}function x(w){return w===62?(e.enter(l),e.consume(w),e.exit(l),e.exit(a),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),y(w))}function y(w){return w===62?(e.exit("chunkString"),e.exit(c),x(w)):w===null||w===60||ht(w)?n(w):(e.consume(w),w===92?S:y)}function S(w){return w===60||w===62||w===92?(e.consume(w),y):y(w)}function C(w){return!p&&(w===null||w===41||Yt(w))?(e.exit("chunkString"),e.exit(c),e.exit(u),e.exit(r),t(w)):p<h&&w===40?(e.consume(w),p++,C):w===41?(e.consume(w),p--,C):w===null||w===32||w===40||ch(w)?n(w):(e.consume(w),w===92?v:C)}function v(w){return w===40||w===41||w===92?(e.consume(w),C):C(w)}}function Ej(e,t,n,r,a,l){const u=this;let c=0,d;return h;function h(y){return e.enter(r),e.enter(a),e.consume(y),e.exit(a),e.enter(l),p}function p(y){return c>999||y===null||y===91||y===93&&!d||y===94&&!c&&"_hiddenFootnoteSupport"in u.parser.constructs?n(y):y===93?(e.exit(l),e.enter(a),e.consume(y),e.exit(a),e.exit(r),t):ht(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),m(y))}function m(y){return y===null||y===91||y===93||ht(y)||c++>999?(e.exit("chunkString"),p(y)):(e.consume(y),d||(d=!jt(y)),y===92?x:m)}function x(y){return y===91||y===92||y===93?(e.consume(y),c++,m):m(y)}}function Nj(e,t,n,r,a,l){let u;return c;function c(x){return x===34||x===39||x===40?(e.enter(r),e.enter(a),e.consume(x),e.exit(a),u=x===40?41:x,d):n(x)}function d(x){return x===u?(e.enter(a),e.consume(x),e.exit(a),e.exit(r),t):(e.enter(l),h(x))}function h(x){return x===u?(e.exit(l),d(u)):x===null?n(x):ht(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),Dt(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===u||x===null||ht(x)?(e.exit("chunkString"),h(x)):(e.consume(x),x===92?m:p)}function m(x){return x===u||x===92?(e.consume(x),p):p(x)}}function _c(e,t){let n;return r;function r(a){return ht(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):jt(a)?Dt(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const cO={name:"definition",tokenize:dO},uO={partial:!0,tokenize:hO};function dO(e,t,n){const r=this;let a;return l;function l(y){return e.enter("definition"),u(y)}function u(y){return Ej.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function c(y){return a=rs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),d):n(y)}function d(y){return Yt(y)?_c(e,h)(y):h(y)}function h(y){return jj(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(uO,m,m)(y)}function m(y){return jt(y)?Dt(e,x,"whitespace")(y):x(y)}function x(y){return y===null||ht(y)?(e.exit("definition"),r.parser.defined.push(a),t(y)):n(y)}}function hO(e,t,n){return r;function r(c){return Yt(c)?_c(e,a)(c):n(c)}function a(c){return Nj(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function l(c){return jt(c)?Dt(e,u,"whitespace")(c):u(c)}function u(c){return c===null||ht(c)?t(c):n(c)}}const fO={name:"hardBreakEscape",tokenize:mO};function mO(e,t,n){return r;function r(l){return e.enter("hardBreakEscape"),e.consume(l),a}function a(l){return ht(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const pO={name:"headingAtx",resolve:gO,tokenize:xO};function gO(e,t){let n=e.length-2,r=3,a,l;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},l={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},jr(e,r,n-r+1,[["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t]])),e}function xO(e,t,n){let r=0;return a;function a(p){return e.enter("atxHeading"),l(p)}function l(p){return e.enter("atxHeadingSequence"),u(p)}function u(p){return p===35&&r++<6?(e.consume(p),u):p===null||Yt(p)?(e.exit("atxHeadingSequence"),c(p)):n(p)}function c(p){return p===35?(e.enter("atxHeadingSequence"),d(p)):p===null||ht(p)?(e.exit("atxHeading"),t(p)):jt(p)?Dt(e,c,"whitespace")(p):(e.enter("atxHeadingText"),h(p))}function d(p){return p===35?(e.consume(p),d):(e.exit("atxHeadingSequence"),c(p))}function h(p){return p===null||p===35||Yt(p)?(e.exit("atxHeadingText"),c(p)):(e.consume(p),h)}}const yO=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],v1=["pre","script","style","textarea"],bO={concrete:!0,name:"htmlFlow",resolveTo:SO,tokenize:wO},vO={partial:!0,tokenize:kO},_O={partial:!0,tokenize:CO};function SO(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function wO(e,t,n){const r=this;let a,l,u,c,d;return h;function h($){return p($)}function p($){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume($),m}function m($){return $===33?(e.consume($),x):$===47?(e.consume($),l=!0,C):$===63?(e.consume($),a=3,r.interrupt?t:O):Zn($)?(e.consume($),u=String.fromCharCode($),v):n($)}function x($){return $===45?(e.consume($),a=2,y):$===91?(e.consume($),a=5,c=0,S):Zn($)?(e.consume($),a=4,r.interrupt?t:O):n($)}function y($){return $===45?(e.consume($),r.interrupt?t:O):n($)}function S($){const Y="CDATA[";return $===Y.charCodeAt(c++)?(e.consume($),c===Y.length?r.interrupt?t:z:S):n($)}function C($){return Zn($)?(e.consume($),u=String.fromCharCode($),v):n($)}function v($){if($===null||$===47||$===62||Yt($)){const Y=$===47,Q=u.toLowerCase();return!Y&&!l&&v1.includes(Q)?(a=1,r.interrupt?t($):z($)):yO.includes(u.toLowerCase())?(a=6,Y?(e.consume($),w):r.interrupt?t($):z($)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n($):l?_($):b($))}return $===45||Wn($)?(e.consume($),u+=String.fromCharCode($),v):n($)}function w($){return $===62?(e.consume($),r.interrupt?t:z):n($)}function _($){return jt($)?(e.consume($),_):M($)}function b($){return $===47?(e.consume($),M):$===58||$===95||Zn($)?(e.consume($),k):jt($)?(e.consume($),b):M($)}function k($){return $===45||$===46||$===58||$===95||Wn($)?(e.consume($),k):E($)}function E($){return $===61?(e.consume($),T):jt($)?(e.consume($),E):b($)}function T($){return $===null||$===60||$===61||$===62||$===96?n($):$===34||$===39?(e.consume($),d=$,D):jt($)?(e.consume($),T):L($)}function D($){return $===d?(e.consume($),d=null,R):$===null||ht($)?n($):(e.consume($),D)}function L($){return $===null||$===34||$===39||$===47||$===60||$===61||$===62||$===96||Yt($)?E($):(e.consume($),L)}function R($){return $===47||$===62||jt($)?b($):n($)}function M($){return $===62?(e.consume($),W):n($)}function W($){return $===null||ht($)?z($):jt($)?(e.consume($),W):n($)}function z($){return $===45&&a===2?(e.consume($),V):$===60&&a===1?(e.consume($),Z):$===62&&a===4?(e.consume($),B):$===63&&a===3?(e.consume($),O):$===93&&a===5?(e.consume($),F):ht($)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(vO,q,H)($)):$===null||ht($)?(e.exit("htmlFlowData"),H($)):(e.consume($),z)}function H($){return e.check(_O,I,q)($)}function I($){return e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),U}function U($){return $===null||ht($)?H($):(e.enter("htmlFlowData"),z($))}function V($){return $===45?(e.consume($),O):z($)}function Z($){return $===47?(e.consume($),u="",ee):z($)}function ee($){if($===62){const Y=u.toLowerCase();return v1.includes(Y)?(e.consume($),B):z($)}return Zn($)&&u.length<8?(e.consume($),u+=String.fromCharCode($),ee):z($)}function F($){return $===93?(e.consume($),O):z($)}function O($){return $===62?(e.consume($),B):$===45&&a===2?(e.consume($),O):z($)}function B($){return $===null||ht($)?(e.exit("htmlFlowData"),q($)):(e.consume($),B)}function q($){return e.exit("htmlFlow"),t($)}}function CO(e,t,n){const r=this;return a;function a(u){return ht(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l):n(u)}function l(u){return r.parser.lazy[r.now().line]?n(u):t(u)}}function kO(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Kc,t,n)}}const jO={name:"htmlText",tokenize:EO};function EO(e,t,n){const r=this;let a,l,u;return c;function c(O){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(O),d}function d(O){return O===33?(e.consume(O),h):O===47?(e.consume(O),E):O===63?(e.consume(O),b):Zn(O)?(e.consume(O),L):n(O)}function h(O){return O===45?(e.consume(O),p):O===91?(e.consume(O),l=0,S):Zn(O)?(e.consume(O),_):n(O)}function p(O){return O===45?(e.consume(O),y):n(O)}function m(O){return O===null?n(O):O===45?(e.consume(O),x):ht(O)?(u=m,Z(O)):(e.consume(O),m)}function x(O){return O===45?(e.consume(O),y):m(O)}function y(O){return O===62?V(O):O===45?x(O):m(O)}function S(O){const B="CDATA[";return O===B.charCodeAt(l++)?(e.consume(O),l===B.length?C:S):n(O)}function C(O){return O===null?n(O):O===93?(e.consume(O),v):ht(O)?(u=C,Z(O)):(e.consume(O),C)}function v(O){return O===93?(e.consume(O),w):C(O)}function w(O){return O===62?V(O):O===93?(e.consume(O),w):C(O)}function _(O){return O===null||O===62?V(O):ht(O)?(u=_,Z(O)):(e.consume(O),_)}function b(O){return O===null?n(O):O===63?(e.consume(O),k):ht(O)?(u=b,Z(O)):(e.consume(O),b)}function k(O){return O===62?V(O):b(O)}function E(O){return Zn(O)?(e.consume(O),T):n(O)}function T(O){return O===45||Wn(O)?(e.consume(O),T):D(O)}function D(O){return ht(O)?(u=D,Z(O)):jt(O)?(e.consume(O),D):V(O)}function L(O){return O===45||Wn(O)?(e.consume(O),L):O===47||O===62||Yt(O)?R(O):n(O)}function R(O){return O===47?(e.consume(O),V):O===58||O===95||Zn(O)?(e.consume(O),M):ht(O)?(u=R,Z(O)):jt(O)?(e.consume(O),R):V(O)}function M(O){return O===45||O===46||O===58||O===95||Wn(O)?(e.consume(O),M):W(O)}function W(O){return O===61?(e.consume(O),z):ht(O)?(u=W,Z(O)):jt(O)?(e.consume(O),W):R(O)}function z(O){return O===null||O===60||O===61||O===62||O===96?n(O):O===34||O===39?(e.consume(O),a=O,H):ht(O)?(u=z,Z(O)):jt(O)?(e.consume(O),z):(e.consume(O),I)}function H(O){return O===a?(e.consume(O),a=void 0,U):O===null?n(O):ht(O)?(u=H,Z(O)):(e.consume(O),H)}function I(O){return O===null||O===34||O===39||O===60||O===61||O===96?n(O):O===47||O===62||Yt(O)?R(O):(e.consume(O),I)}function U(O){return O===47||O===62||Yt(O)?R(O):n(O)}function V(O){return O===62?(e.consume(O),e.exit("htmlTextData"),e.exit("htmlText"),t):n(O)}function Z(O){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),ee}function ee(O){return jt(O)?Dt(e,F,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):F(O)}function F(O){return e.enter("htmlTextData"),u(O)}}const by={name:"labelEnd",resolveAll:LO,resolveTo:DO,tokenize:RO},NO={tokenize:OO},TO={tokenize:IO},AO={tokenize:MO};function LO(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&jr(e,0,e.length,n),e}function DO(e,t){let n=e.length,r=0,a,l,u,c;for(;n--;)if(a=e[n][1],l){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(u){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(l=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(u=n);const d={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[l][1].start},end:{...e[u][1].end}},p={type:"labelText",start:{...e[l+r+2][1].end},end:{...e[u-2][1].start}};return c=[["enter",d,t],["enter",h,t]],c=$r(c,e.slice(l+1,l+r+3)),c=$r(c,[["enter",p,t]]),c=$r(c,Xh(t.parser.constructs.insideSpan.null,e.slice(l+r+4,u-3),t)),c=$r(c,[["exit",p,t],e[u-2],e[u-1],["exit",h,t]]),c=$r(c,e.slice(u+1)),c=$r(c,[["exit",d,t]]),jr(e,l,e.length,c),e}function RO(e,t,n){const r=this;let a=r.events.length,l,u;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){l=r.events[a][1];break}return c;function c(x){return l?l._inactive?m(x):(u=r.parser.defined.includes(rs(r.sliceSerialize({start:l.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(x),e.exit("labelMarker"),e.exit("labelEnd"),d):n(x)}function d(x){return x===40?e.attempt(NO,p,u?p:m)(x):x===91?e.attempt(TO,p,u?h:m)(x):u?p(x):m(x)}function h(x){return e.attempt(AO,p,m)(x)}function p(x){return t(x)}function m(x){return l._balanced=!0,n(x)}}function OO(e,t,n){return r;function r(m){return e.enter("resource"),e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),a}function a(m){return Yt(m)?_c(e,l)(m):l(m)}function l(m){return m===41?p(m):jj(e,u,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function u(m){return Yt(m)?_c(e,d)(m):p(m)}function c(m){return n(m)}function d(m){return m===34||m===39||m===40?Nj(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):p(m)}function h(m){return Yt(m)?_c(e,p)(m):p(m)}function p(m){return m===41?(e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),e.exit("resource"),t):n(m)}}function IO(e,t,n){const r=this;return a;function a(c){return Ej.call(r,e,l,u,"reference","referenceMarker","referenceString")(c)}function l(c){return r.parser.defined.includes(rs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function u(c){return n(c)}}function MO(e,t,n){return r;function r(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),a}function a(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const PO={name:"labelStartImage",resolveAll:by.resolveAll,tokenize:BO};function BO(e,t,n){const r=this;return a;function a(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),l}function l(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),u):n(c)}function u(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const $O={name:"labelStartLink",resolveAll:by.resolveAll,tokenize:zO};function zO(e,t,n){const r=this;return a;function a(u){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelLink"),l}function l(u){return u===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):t(u)}}const Zp={name:"lineEnding",tokenize:HO};function HO(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Dt(e,t,"linePrefix")}}const Yd={name:"thematicBreak",tokenize:FO};function FO(e,t,n){let r=0,a;return l;function l(h){return e.enter("thematicBreak"),u(h)}function u(h){return a=h,c(h)}function c(h){return h===a?(e.enter("thematicBreakSequence"),d(h)):r>=3&&(h===null||ht(h))?(e.exit("thematicBreak"),t(h)):n(h)}function d(h){return h===a?(e.consume(h),r++,d):(e.exit("thematicBreakSequence"),jt(h)?Dt(e,c,"whitespace")(h):c(h))}}const ar={continuation:{tokenize:GO},exit:KO,name:"list",tokenize:WO},UO={partial:!0,tokenize:YO},VO={partial:!0,tokenize:qO};function WO(e,t,n){const r=this,a=r.events[r.events.length-1];let l=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,u=0;return c;function c(y){const S=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(S==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:lx(y)){if(r.containerState.type||(r.containerState.type=S,e.enter(S,{_container:!0})),S==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Yd,n,h)(y):h(y);if(!r.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(y)}return n(y)}function d(y){return lx(y)&&++u<10?(e.consume(y),d):(!r.interrupt||u<2)&&(r.containerState.marker?y===r.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),h(y)):n(y)}function h(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,e.check(Kc,r.interrupt?n:p,e.attempt(UO,x,m))}function p(y){return r.containerState.initialBlankLine=!0,l++,x(y)}function m(y){return jt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),x):n(y)}function x(y){return r.containerState.size=l+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function GO(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Kc,a,l);function a(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Dt(e,t,"listItemIndent",r.containerState.size+1)(c)}function l(c){return r.containerState.furtherBlankLines||!jt(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,u(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(VO,t,u)(c))}function u(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,Dt(e,e.attempt(ar,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function qO(e,t,n){const r=this;return Dt(e,a,"listItemIndent",r.containerState.size+1);function a(l){const u=r.events[r.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===r.containerState.size?t(l):n(l)}}function KO(e){e.exit(this.containerState.type)}function YO(e,t,n){const r=this;return Dt(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(l){const u=r.events[r.events.length-1];return!jt(l)&&u&&u[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const _1={name:"setextUnderline",resolveTo:XO,tokenize:QO};function XO(e,t){let n=e.length,r,a,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const u={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",l?(e.splice(a,0,["enter",u,t]),e.splice(l+1,0,["exit",e[r][1],t]),e[r][1].end={...e[l][1].end}):e[r][1]=u,e.push(["exit",u,t]),e}function QO(e,t,n){const r=this;let a;return l;function l(h){let p=r.events.length,m;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){m=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||m)?(e.enter("setextHeadingLine"),a=h,u(h)):n(h)}function u(h){return e.enter("setextHeadingLineSequence"),c(h)}function c(h){return h===a?(e.consume(h),c):(e.exit("setextHeadingLineSequence"),jt(h)?Dt(e,d,"lineSuffix")(h):d(h))}function d(h){return h===null||ht(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const JO={tokenize:ZO};function ZO(e){const t=this,n=e.attempt(Kc,r,e.attempt(this.parser.constructs.flowInitial,a,Dt(e,e.attempt(this.parser.constructs.flow,a,e.attempt(sO,a)),"linePrefix")));return n;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const eI={resolveAll:Aj()},tI=Tj("string"),nI=Tj("text");function Tj(e){return{resolveAll:Aj(e==="text"?rI:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],l=n.attempt(a,u,c);return u;function u(p){return h(p)?l(p):c(p)}function c(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),d}function d(p){return h(p)?(n.exit("data"),l(p)):(n.consume(p),d)}function h(p){if(p===null)return!0;const m=a[p];let x=-1;if(m)for(;++x<m.length;){const y=m[x];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function Aj(e){return t;function t(n,r){let a=-1,l;for(;++a<=n.length;)l===void 0?n[a]&&n[a][1].type==="data"&&(l=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==l+2&&(n[l][1].end=n[a-1][1].end,n.splice(l+2,a-l-2),a=l+2),l=void 0);return e?e(n,r):n}}function rI(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let l=a.length,u=-1,c=0,d;for(;l--;){const h=a[l];if(typeof h=="string"){for(u=h.length;h.charCodeAt(u-1)===32;)c++,u--;if(u)break;u=-1}else if(h===-2)d=!0,c++;else if(h!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const h={type:n===e.length||d||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?u:r.start._bufferIndex+u,_index:r.start._index+l,line:r.end.line,column:r.end.column-c,offset:r.end.offset-c},end:{...r.end}};r.end={...h.start},r.start.offset===r.end.offset?Object.assign(r,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const sI={42:ar,43:ar,45:ar,48:ar,49:ar,50:ar,51:ar,52:ar,53:ar,54:ar,55:ar,56:ar,57:ar,62:Sj},iI={91:cO},aI={[-2]:Jp,[-1]:Jp,32:Jp},oI={35:pO,42:Yd,45:[_1,Yd],60:bO,61:_1,95:Yd,96:b1,126:b1},lI={38:Cj,92:wj},cI={[-5]:Zp,[-4]:Zp,[-3]:Zp,33:PO,38:Cj,42:cx,60:[$5,jO],91:$O,92:[fO,wj],93:by,95:cx,96:J5},uI={null:[cx,eI]},dI={null:[42,95]},hI={null:[]},fI=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:dI,contentInitial:iI,disable:hI,document:sI,flow:oI,flowInitial:aI,insideSpan:uI,string:lI,text:cI},Symbol.toStringTag,{value:"Module"}));function mI(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},l=[];let u=[],c=[];const d={attempt:D(E),check:D(T),consume:_,enter:b,exit:k,interrupt:D(T,{interrupt:!0})},h={code:null,containerState:{},defineSkip:C,events:[],now:S,parser:e,previous:null,sliceSerialize:x,sliceStream:y,write:m};let p=t.tokenize.call(h,d);return t.resolveAll&&l.push(t),h;function m(W){return u=$r(u,W),v(),u[u.length-1]!==null?[]:(L(t,0),h.events=Xh(l,h.events,h),h.events)}function x(W,z){return gI(y(W),z)}function y(W){return pI(u,W)}function S(){const{_bufferIndex:W,_index:z,line:H,column:I,offset:U}=r;return{_bufferIndex:W,_index:z,line:H,column:I,offset:U}}function C(W){a[W.line]=W.column,M()}function v(){let W;for(;r._index<u.length;){const z=u[r._index];if(typeof z=="string")for(W=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===W&&r._bufferIndex<z.length;)w(z.charCodeAt(r._bufferIndex));else w(z)}}function w(W){p=p(W)}function _(W){ht(W)?(r.line++,r.column=1,r.offset+=W===-3?2:1,M()):W!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===u[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=W}function b(W,z){const H=z||{};return H.type=W,H.start=S(),h.events.push(["enter",H,h]),c.push(H),H}function k(W){const z=c.pop();return z.end=S(),h.events.push(["exit",z,h]),z}function E(W,z){L(W,z.from)}function T(W,z){z.restore()}function D(W,z){return H;function H(I,U,V){let Z,ee,F,O;return Array.isArray(I)?q(I):"tokenize"in I?q([I]):B(I);function B(X){return K;function K(P){const J=P!==null&&X[P],ne=P!==null&&X.null,ce=[...Array.isArray(J)?J:J?[J]:[],...Array.isArray(ne)?ne:ne?[ne]:[]];return q(ce)(P)}}function q(X){return Z=X,ee=0,X.length===0?V:$(X[ee])}function $(X){return K;function K(P){return O=R(),F=X,X.partial||(h.currentConstruct=X),X.name&&h.parser.constructs.disable.null.includes(X.name)?Q():X.tokenize.call(z?Object.assign(Object.create(h),z):h,d,Y,Q)(P)}}function Y(X){return W(F,O),U}function Q(X){return O.restore(),++ee<Z.length?$(Z[ee]):V}}}function L(W,z){W.resolveAll&&!l.includes(W)&&l.push(W),W.resolve&&jr(h.events,z,h.events.length-z,W.resolve(h.events.slice(z),h)),W.resolveTo&&(h.events=W.resolveTo(h.events,h))}function R(){const W=S(),z=h.previous,H=h.currentConstruct,I=h.events.length,U=Array.from(c);return{from:I,restore:V};function V(){r=W,h.previous=z,h.currentConstruct=H,h.events.length=I,c=U,M()}}function M(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function pI(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,l=t.end._bufferIndex;let u;if(n===a)u=[e[n].slice(r,l)];else{if(u=e.slice(n,a),r>-1){const c=u[0];typeof c=="string"?u[0]=c.slice(r):u.shift()}l>0&&u.push(e[a].slice(0,l))}return u}function gI(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const l=e[n];let u;if(typeof l=="string")u=l;else switch(l){case-5:{u="\r";break}case-4:{u=`
|
|
69
|
+
`;break}case-3:{u=`\r
|
|
70
|
+
`;break}case-2:{u=t?" ":" ";break}case-1:{if(!t&&a)continue;u=" ";break}default:u=String.fromCharCode(l)}a=l===-2,r.push(u)}return r.join("")}function xI(e){const r={constructs:vj([fI,...(e||{}).extensions||[]]),content:a(D5),defined:[],document:a(O5),flow:a(JO),lazy:{},string:a(tI),text:a(nI)};return r;function a(l){return u;function u(c){return mI(r,l,c)}}}function yI(e){for(;!kj(e););return e}const S1=/[\0\t\n\r]/g;function bI(){let e=1,t="",n=!0,r;return a;function a(l,u,c){const d=[];let h,p,m,x,y;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(u||void 0).decode(l)),m=0,t="",n&&(l.charCodeAt(0)===65279&&m++,n=void 0);m<l.length;){if(S1.lastIndex=m,h=S1.exec(l),x=h&&h.index!==void 0?h.index:l.length,y=l.charCodeAt(x),!h){t=l.slice(m);break}if(y===10&&m===x&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),m<x&&(d.push(l.slice(m,x)),e+=x-m),y){case 0:{d.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,d.push(-2);e++<p;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:r=!0,e=1}m=x+1}return c&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const vI=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function _I(e){return e.replace(vI,SI)}function SI(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),l=a===120||a===88;return _j(n.slice(l?2:1),l?16:10)}return yy(n)||e}const Lj={}.hasOwnProperty;function wI(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),CI(n)(yI(xI(n).document().write(bI()(e,t,!0))))}function CI(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Xe),autolinkProtocol:R,autolinkEmail:R,atxHeading:l(Le),blockQuote:l(ne),characterEscape:R,characterReference:R,codeFenced:l(ce),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:l(ce,u),codeText:l(ae,u),codeTextData:R,data:R,codeFlowValue:R,definition:l(Ee),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:l(ve),hardBreakEscape:l(Me),hardBreakTrailing:l(Me),htmlFlow:l(ke,u),htmlFlowData:R,htmlText:l(ke,u),htmlTextData:R,image:l(Ge),label:u,link:l(Xe),listItem:l(Ie),listItemValue:x,listOrdered:l(Se,m),listUnordered:l(Se),paragraph:l(it),reference:$,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:l(Le),strong:l(ge),thematicBreak:l(He)},exit:{atxHeading:d(),atxHeadingSequence:E,autolink:d(),autolinkEmail:J,autolinkProtocol:P,blockQuote:d(),characterEscapeValue:M,characterReferenceMarkerHexadecimal:Q,characterReferenceMarkerNumeric:Q,characterReferenceValue:X,characterReference:K,codeFenced:d(v),codeFencedFence:C,codeFencedFenceInfo:y,codeFencedFenceMeta:S,codeFlowValue:M,codeIndented:d(w),codeText:d(U),codeTextData:M,data:M,definition:d(),definitionDestinationString:k,definitionLabelString:_,definitionTitleString:b,emphasis:d(),hardBreakEscape:d(z),hardBreakTrailing:d(z),htmlFlow:d(H),htmlFlowData:M,htmlText:d(I),htmlTextData:M,image:d(Z),label:F,labelText:ee,lineEnding:W,link:d(V),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:Y,resourceDestinationString:O,resourceTitleString:B,resource:q,setextHeading:d(L),setextHeadingLineSequence:D,setextHeadingText:T,strong:d(),thematicBreak:d()}};Dj(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ie){let xe={type:"root",children:[]};const se={stack:[xe],tokenStack:[],config:t,enter:c,exit:h,buffer:u,resume:p,data:n},he=[];let Pe=-1;for(;++Pe<ie.length;)if(ie[Pe][1].type==="listOrdered"||ie[Pe][1].type==="listUnordered")if(ie[Pe][0]==="enter")he.push(Pe);else{const qe=he.pop();Pe=a(ie,qe,Pe)}for(Pe=-1;++Pe<ie.length;){const qe=t[ie[Pe][0]];Lj.call(qe,ie[Pe][1].type)&&qe[ie[Pe][1].type].call(Object.assign({sliceSerialize:ie[Pe][2].sliceSerialize},se),ie[Pe][1])}if(se.tokenStack.length>0){const qe=se.tokenStack[se.tokenStack.length-1];(qe[1]||w1).call(se,void 0,qe[0])}for(xe.position={start:Ti(ie.length>0?ie[0][1].start:{line:1,column:1,offset:0}),end:Ti(ie.length>0?ie[ie.length-2][1].end:{line:1,column:1,offset:0})},Pe=-1;++Pe<t.transforms.length;)xe=t.transforms[Pe](xe)||xe;return xe}function a(ie,xe,se){let he=xe-1,Pe=-1,qe=!1,Ke,et,ot,ue;for(;++he<=se;){const $e=ie[he];switch($e[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{$e[0]==="enter"?Pe++:Pe--,ue=void 0;break}case"lineEndingBlank":{$e[0]==="enter"&&(Ke&&!ue&&!Pe&&!ot&&(ot=he),ue=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ue=void 0}if(!Pe&&$e[0]==="enter"&&$e[1].type==="listItemPrefix"||Pe===-1&&$e[0]==="exit"&&($e[1].type==="listUnordered"||$e[1].type==="listOrdered")){if(Ke){let ut=he;for(et=void 0;ut--;){const ct=ie[ut];if(ct[1].type==="lineEnding"||ct[1].type==="lineEndingBlank"){if(ct[0]==="exit")continue;et&&(ie[et][1].type="lineEndingBlank",qe=!0),ct[1].type="lineEnding",et=ut}else if(!(ct[1].type==="linePrefix"||ct[1].type==="blockQuotePrefix"||ct[1].type==="blockQuotePrefixWhitespace"||ct[1].type==="blockQuoteMarker"||ct[1].type==="listItemIndent"))break}ot&&(!et||ot<et)&&(Ke._spread=!0),Ke.end=Object.assign({},et?ie[et][1].start:$e[1].end),ie.splice(et||he,0,["exit",Ke,$e[2]]),he++,se++}if($e[1].type==="listItemPrefix"){const ut={type:"listItem",_spread:!1,start:Object.assign({},$e[1].start),end:void 0};Ke=ut,ie.splice(he,0,["enter",ut,$e[2]]),he++,se++,ot=void 0,ue=!0}}}return ie[xe][1]._spread=qe,se}function l(ie,xe){return se;function se(he){c.call(this,ie(he),he),xe&&xe.call(this,he)}}function u(){this.stack.push({type:"fragment",children:[]})}function c(ie,xe,se){this.stack[this.stack.length-1].children.push(ie),this.stack.push(ie),this.tokenStack.push([xe,se||void 0]),ie.position={start:Ti(xe.start),end:void 0}}function d(ie){return xe;function xe(se){ie&&ie.call(this,se),h.call(this,se)}}function h(ie,xe){const se=this.stack.pop(),he=this.tokenStack.pop();if(he)he[0].type!==ie.type&&(xe?xe.call(this,ie,he[0]):(he[1]||w1).call(this,ie,he[0]));else throw new Error("Cannot close `"+ie.type+"` ("+vc({start:ie.start,end:ie.end})+"): it’s not open");se.position.end=Ti(ie.end)}function p(){return xy(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function x(ie){if(this.data.expectingFirstListItemValue){const xe=this.stack[this.stack.length-2];xe.start=Number.parseInt(this.sliceSerialize(ie),10),this.data.expectingFirstListItemValue=void 0}}function y(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.lang=ie}function S(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.meta=ie}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ie.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function w(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ie.replace(/(\r?\n|\r)$/g,"")}function _(ie){const xe=this.resume(),se=this.stack[this.stack.length-1];se.label=xe,se.identifier=rs(this.sliceSerialize(ie)).toLowerCase()}function b(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.title=ie}function k(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.url=ie}function E(ie){const xe=this.stack[this.stack.length-1];if(!xe.depth){const se=this.sliceSerialize(ie).length;xe.depth=se}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function D(ie){const xe=this.stack[this.stack.length-1];xe.depth=this.sliceSerialize(ie).codePointAt(0)===61?1:2}function L(){this.data.setextHeadingSlurpLineEnding=void 0}function R(ie){const se=this.stack[this.stack.length-1].children;let he=se[se.length-1];(!he||he.type!=="text")&&(he=Fe(),he.position={start:Ti(ie.start),end:void 0},se.push(he)),this.stack.push(he)}function M(ie){const xe=this.stack.pop();xe.value+=this.sliceSerialize(ie),xe.position.end=Ti(ie.end)}function W(ie){const xe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const se=xe.children[xe.children.length-1];se.position.end=Ti(ie.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(xe.type)&&(R.call(this,ie),M.call(this,ie))}function z(){this.data.atHardBreak=!0}function H(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ie}function I(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ie}function U(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ie}function V(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=xe,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function Z(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=xe,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function ee(ie){const xe=this.sliceSerialize(ie),se=this.stack[this.stack.length-2];se.label=_I(xe),se.identifier=rs(xe).toLowerCase()}function F(){const ie=this.stack[this.stack.length-1],xe=this.resume(),se=this.stack[this.stack.length-1];if(this.data.inReference=!0,se.type==="link"){const he=ie.children;se.children=he}else se.alt=xe}function O(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.url=ie}function B(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.title=ie}function q(){this.data.inReference=void 0}function $(){this.data.referenceType="collapsed"}function Y(ie){const xe=this.resume(),se=this.stack[this.stack.length-1];se.label=xe,se.identifier=rs(this.sliceSerialize(ie)).toLowerCase(),this.data.referenceType="full"}function Q(ie){this.data.characterReferenceType=ie.type}function X(ie){const xe=this.sliceSerialize(ie),se=this.data.characterReferenceType;let he;se?(he=_j(xe,se==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):he=yy(xe);const Pe=this.stack[this.stack.length-1];Pe.value+=he}function K(ie){const xe=this.stack.pop();xe.position.end=Ti(ie.end)}function P(ie){M.call(this,ie);const xe=this.stack[this.stack.length-1];xe.url=this.sliceSerialize(ie)}function J(ie){M.call(this,ie);const xe=this.stack[this.stack.length-1];xe.url="mailto:"+this.sliceSerialize(ie)}function ne(){return{type:"blockquote",children:[]}}function ce(){return{type:"code",lang:null,meta:null,value:""}}function ae(){return{type:"inlineCode",value:""}}function Ee(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ve(){return{type:"emphasis",children:[]}}function Le(){return{type:"heading",depth:0,children:[]}}function Me(){return{type:"break"}}function ke(){return{type:"html",value:""}}function Ge(){return{type:"image",title:null,url:"",alt:null}}function Xe(){return{type:"link",title:null,url:"",children:[]}}function Se(ie){return{type:"list",ordered:ie.type==="listOrdered",start:null,spread:ie._spread,children:[]}}function Ie(ie){return{type:"listItem",spread:ie._spread,checked:null,children:[]}}function it(){return{type:"paragraph",children:[]}}function ge(){return{type:"strong",children:[]}}function Fe(){return{type:"text",value:""}}function He(){return{type:"thematicBreak"}}}function Ti(e){return{line:e.line,column:e.column,offset:e.offset}}function Dj(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Dj(e,r):kI(e,r)}}function kI(e,t){let n;for(n in t)if(Lj.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function w1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+vc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+vc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+vc({start:t.start,end:t.end})+") is still open")}function jI(e){const t=this;t.parser=n;function n(r){return wI(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function EI(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function NI(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
71
|
+
`}]}function TI(e,t){const n=t.value?t.value+`
|
|
72
|
+
`:"",r={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(r.className=["language-"+a[0]]);let l={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(l.data={meta:t.meta}),e.patch(t,l),l=e.applyData(t,l),l={type:"element",tagName:"pre",properties:{},children:[l]},e.patch(t,l),l}function AI(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function LI(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function DI(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=sl(r.toLowerCase()),l=e.footnoteOrder.indexOf(r);let u,c=e.footnoteCounts.get(r);c===void 0?(c=0,e.footnoteOrder.push(r),u=e.footnoteOrder.length):u=l+1,c+=1,e.footnoteCounts.set(r,c);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,d);const h={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,h),e.applyData(t,h)}function RI(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function OI(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Rj(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const a=e.all(t),l=a[0];l&&l.type==="text"?l.value="["+l.value:a.unshift({type:"text",value:"["});const u=a[a.length-1];return u&&u.type==="text"?u.value+=r:a.push({type:"text",value:r}),a}function II(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Rj(e,t);const a={src:sl(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(a.title=r.title);const l={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,l),e.applyData(t,l)}function MI(e,t){const n={src:sl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function PI(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function BI(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Rj(e,t);const a={href:sl(r.url||"")};r.title!==null&&r.title!==void 0&&(a.title=r.title);const l={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function $I(e,t){const n={href:sl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function zI(e,t,n){const r=e.all(t),a=n?HI(n):Oj(t),l={},u=[];if(typeof t.checked=="boolean"){const p=r[0];let m;p&&p.type==="element"&&p.tagName==="p"?m=p:(m={type:"element",tagName:"p",properties:{},children:[]},r.unshift(m)),m.children.length>0&&m.children.unshift({type:"text",value:" "}),m.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),l.className=["task-list-item"]}let c=-1;for(;++c<r.length;){const p=r[c];(a||c!==0||p.type!=="element"||p.tagName!=="p")&&u.push({type:"text",value:`
|
|
73
|
+
`}),p.type==="element"&&p.tagName==="p"&&!a?u.push(...p.children):u.push(p)}const d=r[r.length-1];d&&(a||d.type!=="element"||d.tagName!=="p")&&u.push({type:"text",value:`
|
|
74
|
+
`});const h={type:"element",tagName:"li",properties:l,children:u};return e.patch(t,h),e.applyData(t,h)}function HI(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=Oj(n[r])}return t}function Oj(e){const t=e.spread;return t??e.children.length>1}function FI(e,t){const n={},r=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a<r.length;){const u=r[a];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const l={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,l),e.applyData(t,l)}function UI(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function VI(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function WI(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function GI(e,t){const n=e.all(t),r=n.shift(),a=[];if(r){const u={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],u),a.push(u)}if(n.length>0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=fy(t.children[1]),d=fj(t.children[t.children.length-1]);c&&d&&(u.position={start:c,end:d}),a.push(u)}const l={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,l),e.applyData(t,l)}function qI(e,t,n){const r=n?n.children:void 0,l=(r?r.indexOf(t):1)===0?"th":"td",u=n&&n.type==="table"?n.align:void 0,c=u?u.length:t.children.length;let d=-1;const h=[];for(;++d<c;){const m=t.children[d],x={},y=u?u[d]:void 0;y&&(x.align=y);let S={type:"element",tagName:l,properties:x,children:[]};m&&(S.children=e.all(m),e.patch(m,S),S=e.applyData(m,S)),h.push(S)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,p),e.applyData(t,p)}function KI(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const C1=9,k1=32;function YI(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const l=[];for(;r;)l.push(j1(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return l.push(j1(t.slice(a),a>0,!1)),l.join("")}function j1(e,t,n){let r=0,a=e.length;if(t){let l=e.codePointAt(r);for(;l===C1||l===k1;)r++,l=e.codePointAt(r)}if(n){let l=e.codePointAt(a-1);for(;l===C1||l===k1;)a--,l=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}function XI(e,t){const n={type:"text",value:YI(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function QI(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const JI={blockquote:EI,break:NI,code:TI,delete:AI,emphasis:LI,footnoteReference:DI,heading:RI,html:OI,imageReference:II,image:MI,inlineCode:PI,linkReference:BI,link:$I,listItem:zI,list:FI,paragraph:UI,root:VI,strong:WI,table:GI,tableCell:KI,tableRow:qI,text:XI,thematicBreak:QI,toml:bd,yaml:bd,definition:bd,footnoteDefinition:bd};function bd(){}const Ij=-1,Qh=0,Sc=1,uh=2,vy=3,_y=4,Sy=5,wy=6,Mj=7,Pj=8,Bj=typeof self=="object"?self:globalThis,E1=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new Bj[e](t)},ZI=(e,t)=>{const n=(a,l)=>(e.set(l,a),a),r=a=>{if(e.has(a))return e.get(a);const[l,u]=t[a];switch(l){case Qh:case Ij:return n(u,a);case Sc:{const c=n([],a);for(const d of u)c.push(r(d));return c}case uh:{const c=n({},a);for(const[d,h]of u)c[r(d)]=r(h);return c}case vy:return n(new Date(u),a);case _y:{const{source:c,flags:d}=u;return n(new RegExp(c,d),a)}case Sy:{const c=n(new Map,a);for(const[d,h]of u)c.set(r(d),r(h));return c}case wy:{const c=n(new Set,a);for(const d of u)c.add(r(d));return c}case Mj:{const{name:c,message:d}=u;return n(typeof Bj[c]=="function"?E1(c,d):new Error(d),a)}case Pj:return n(BigInt(u),a);case"BigInt":return n(Object(BigInt(u)),a);case"ArrayBuffer":return n(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:c}=new Uint8Array(u);return n(new DataView(c),u)}}return n(E1(l,u),a)};return r},N1=e=>ZI(new Map,e)(0),_a="",{toString:eM}={},{keys:tM}=Object,oc=e=>{const t=typeof e;if(t!=="object"||!e)return[Qh,t];const n=eM.call(e).slice(8,-1);switch(n){case"Array":return[Sc,_a];case"Object":return[uh,_a];case"Date":return[vy,_a];case"RegExp":return[_y,_a];case"Map":return[Sy,_a];case"Set":return[wy,_a];case"DataView":return[Sc,n]}return n.includes("Array")?[Sc,n]:e instanceof Error?[Mj,e.name||"Error"]:[uh,n]},vd=([e,t])=>e===Qh&&(t==="function"||t==="symbol"),nM=(e,t,n,r)=>{const a=(u,c)=>{const d=r.push(u)-1;return n.set(c,d),d},l=u=>{if(n.has(u))return n.get(u);let[c,d]=oc(u);switch(c){case Qh:{let p=u;switch(d){case"bigint":c=Pj,p=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return a([Ij],u)}return a([c,p],u)}case Sc:{if(d){let x=u;return d==="DataView"?x=new Uint8Array(u.buffer):d==="ArrayBuffer"&&(x=new Uint8Array(u)),a([d,[...x]],u)}const p=[],m=a([c,p],u);for(const x of u)p.push(l(x));return m}case uh:{if(d)switch(d){case"BigInt":return a([d,u.toString()],u);case"Boolean":case"Number":case"String":return a([d,u.valueOf()],u)}if(t&&"toJSON"in u)return l(u.toJSON());const p=[],m=a([c,p],u);for(const x of tM(u))(e||!vd(oc(u[x])))&&p.push([l(x),l(u[x])]);return m}case vy:return a([c,isNaN(u.getTime())?_a:u.toISOString()],u);case _y:{const{source:p,flags:m}=u;return a([c,{source:p,flags:m}],u)}case Sy:{const p=[],m=a([c,p],u);for(const[x,y]of u)(e||!(vd(oc(x))||vd(oc(y))))&&p.push([l(x),l(y)]);return m}case wy:{const p=[],m=a([c,p],u);for(const x of u)(e||!vd(oc(x)))&&p.push(l(x));return m}}const{message:h}=u;return a([c,{name:d,message:h}],u)};return l},T1=(e,{json:t,lossy:n}={})=>{const r=[];return nM(!(t||n),!!t,new Map,r)(e),r},dh=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?N1(T1(e,t)):structuredClone(e):(e,t)=>N1(T1(e,t));function rM(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function sM(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function iM(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||rM,r=e.options.footnoteBackLabel||sM,a=e.options.footnoteLabel||"Footnotes",l=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let d=-1;for(;++d<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[d]);if(!h)continue;const p=e.all(h),m=String(h.identifier).toUpperCase(),x=sl(m.toLowerCase());let y=0;const S=[],C=e.footnoteCounts.get(m);for(;C!==void 0&&++y<=C;){S.length>0&&S.push({type:"text",value:" "});let _=typeof n=="string"?n:n(d,y);typeof _=="string"&&(_={type:"text",value:_}),S.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+x+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(d,y),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const v=p[p.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const _=v.children[v.children.length-1];_&&_.type==="text"?_.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...S)}else p.push(...S);const w={type:"element",tagName:"li",properties:{id:t+"fn-"+x},children:e.wrap(p,!0)};e.patch(h,w),c.push(w)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:l,properties:{...dh(u),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
|
|
75
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:`
|
|
76
|
+
`}]}}const Jh=(function(e){if(e==null)return cM;if(typeof e=="function")return Zh(e);if(typeof e=="object")return Array.isArray(e)?aM(e):oM(e);if(typeof e=="string")return lM(e);throw new Error("Expected function, string, or object as test")});function aM(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Jh(e[n]);return Zh(r);function r(...a){let l=-1;for(;++l<t.length;)if(t[l].apply(this,a))return!0;return!1}}function oM(e){const t=e;return Zh(n);function n(r){const a=r;let l;for(l in e)if(a[l]!==t[l])return!1;return!0}}function lM(e){return Zh(t);function t(n){return n&&n.type===e}}function Zh(e){return t;function t(n,r,a){return!!(uM(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function cM(){return!0}function uM(e){return e!==null&&typeof e=="object"&&"type"in e}const $j=[],dM=!0,ux=!1,hM="skip";function zj(e,t,n,r){let a;typeof t=="function"&&typeof n!="function"?(r=n,n=t):a=t;const l=Jh(a),u=r?-1:1;c(e,void 0,[])();function c(d,h,p){const m=d&&typeof d=="object"?d:{};if(typeof m.type=="string"){const y=typeof m.tagName=="string"?m.tagName:typeof m.name=="string"?m.name:void 0;Object.defineProperty(x,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return x;function x(){let y=$j,S,C,v;if((!t||l(d,h,p[p.length-1]||void 0))&&(y=fM(n(d,p)),y[0]===ux))return y;if("children"in d&&d.children){const w=d;if(w.children&&y[0]!==hM)for(C=(r?w.children.length:-1)+u,v=p.concat(w);C>-1&&C<w.children.length;){const _=w.children[C];if(S=c(_,C,v)(),S[0]===ux)return S;C=typeof S[1]=="number"?S[1]:C+u}}return y}}}function fM(e){return Array.isArray(e)?e:typeof e=="number"?[dM,e]:e==null?$j:[e]}function Cy(e,t,n,r){let a,l,u;typeof t=="function"&&typeof n!="function"?(l=void 0,u=t,a=n):(l=t,u=n,a=r),zj(e,l,c,a);function c(d,h){const p=h[h.length-1],m=p?p.children.indexOf(d):void 0;return u(d,m,p)}}const dx={}.hasOwnProperty,mM={};function pM(e,t){const n=t||mM,r=new Map,a=new Map,l=new Map,u={...JI,...n.handlers},c={all:h,applyData:xM,definitionById:r,footnoteById:a,footnoteCounts:l,footnoteOrder:[],handlers:u,one:d,options:n,patch:gM,wrap:bM};return Cy(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const m=p.type==="definition"?r:a,x=String(p.identifier).toUpperCase();m.has(x)||m.set(x,p)}}),c;function d(p,m){const x=p.type,y=c.handlers[x];if(dx.call(c.handlers,x)&&y)return y(c,p,m);if(c.options.passThrough&&c.options.passThrough.includes(x)){if("children"in p){const{children:C,...v}=p,w=dh(v);return w.children=c.all(p),w}return dh(p)}return(c.options.unknownHandler||yM)(c,p,m)}function h(p){const m=[];if("children"in p){const x=p.children;let y=-1;for(;++y<x.length;){const S=c.one(x[y],p);if(S){if(y&&x[y-1].type==="break"&&(!Array.isArray(S)&&S.type==="text"&&(S.value=A1(S.value)),!Array.isArray(S)&&S.type==="element")){const C=S.children[0];C&&C.type==="text"&&(C.value=A1(C.value))}Array.isArray(S)?m.push(...S):m.push(S)}}}return m}}function gM(e,t){e.position&&(t.position=s5(e))}function xM(e,t){let n=t;if(e&&e.data){const r=e.data.hName,a=e.data.hChildren,l=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const u="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:u}}n.type==="element"&&l&&Object.assign(n.properties,dh(l)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function yM(e,t){const n=t.data||{},r="value"in t&&!(dx.call(n,"hProperties")||dx.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function bM(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
77
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
78
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
79
|
+
`}),n}function A1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function L1(e,t){const n=pM(e,t),r=n.one(e,void 0),a=iM(n),l=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&l.children.push({type:"text",value:`
|
|
80
|
+
`},a),l}function vM(e,t){return e&&"run"in e?async function(n,r){const a=L1(n,{file:r,...t});await e.run(a,r)}:function(n,r){return L1(n,{file:r,...e||t})}}function D1(e){if(e)throw e}var eg,R1;function _M(){if(R1)return eg;R1=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},l=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var p=e.call(h,"constructor"),m=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!p&&!m)return!1;var x;for(x in h);return typeof x>"u"||e.call(h,x)},u=function(h,p){n&&p.name==="__proto__"?n(h,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):h[p.name]=p.newValue},c=function(h,p){if(p==="__proto__")if(e.call(h,p)){if(r)return r(h,p).value}else return;return h[p]};return eg=function d(){var h,p,m,x,y,S,C=arguments[0],v=1,w=arguments.length,_=!1;for(typeof C=="boolean"&&(_=C,C=arguments[1]||{},v=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});v<w;++v)if(h=arguments[v],h!=null)for(p in h)m=c(C,p),x=c(h,p),C!==x&&(_&&x&&(l(x)||(y=a(x)))?(y?(y=!1,S=m&&a(m)?m:[]):S=m&&l(m)?m:{},u(C,{name:p,newValue:d(_,S,x)})):typeof x<"u"&&u(C,{name:p,newValue:x}));return C},eg}var SM=_M();const tg=Lh(SM);function hx(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function wM(){const e=[],t={run:n,use:r};return t;function n(...a){let l=-1;const u=a.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);c(null,...a);function c(d,...h){const p=e[++l];let m=-1;if(d){u(d);return}for(;++m<a.length;)(h[m]===null||h[m]===void 0)&&(h[m]=a[m]);a=h,p?CM(p,c)(...h):u(null,...h)}}function r(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function CM(e,t){let n;return r;function r(...u){const c=e.length>u.length;let d;c&&u.push(a);try{d=e.apply(this,u)}catch(h){const p=h;if(c&&n)throw p;return a(p)}c||(d&&d.then&&typeof d.then=="function"?d.then(l,a):d instanceof Error?a(d):l(d))}function a(u,...c){n||(n=!0,t(u,...c))}function l(u){a(null,u)}}const gs={basename:kM,dirname:jM,extname:EM,join:NM,sep:"/"};function kM(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Yc(e);let n=0,r=-1,a=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else r<0&&(l=!0,r=a+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let u=-1,c=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else u<0&&(l=!0,u=a+1),c>-1&&(e.codePointAt(a)===t.codePointAt(c--)?c<0&&(r=a):(c=-1,r=u));return n===r?r=u:r<0&&(r=e.length),e.slice(n,r)}function jM(e){if(Yc(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function EM(e){Yc(e);let t=e.length,n=-1,r=0,a=-1,l=0,u;for(;t--;){const c=e.codePointAt(t);if(c===47){if(u){r=t+1;break}continue}n<0&&(u=!0,n=t+1),c===46?a<0?a=t:l!==1&&(l=1):a>-1&&(l=-1)}return a<0||n<0||l===0||l===1&&a===n-1&&a===r+1?"":e.slice(a,n)}function NM(...e){let t=-1,n;for(;++t<e.length;)Yc(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":TM(n)}function TM(e){Yc(e);const t=e.codePointAt(0)===47;let n=AM(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function AM(e,t){let n="",r=0,a=-1,l=0,u=-1,c,d;for(;++u<=e.length;){if(u<e.length)c=e.codePointAt(u);else{if(c===47)break;c=47}if(c===47){if(!(a===u-1||l===1))if(a!==u-1&&l===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",r=0):(n=n.slice(0,d),r=n.length-1-n.lastIndexOf("/")),a=u,l=0;continue}}else if(n.length>0){n="",r=0,a=u,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(a+1,u):n=e.slice(a+1,u),r=u-a-1;a=u,l=0}else c===46&&l>-1?l++:l=-1}return n}function Yc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const LM={cwd:DM};function DM(){return"/"}function fx(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function RM(e){if(typeof e=="string")e=new URL(e);else if(!fx(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return OM(e)}function OM(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const ng=["history","path","basename","stem","extname","dirname"];class Hj{constructor(t){let n;t?fx(t)?n={path:t}:typeof t=="string"||IM(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":LM.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ng.length;){const l=ng[r];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let a;for(a in n)ng.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?gs.basename(this.path):void 0}set basename(t){sg(t,"basename"),rg(t,"basename"),this.path=gs.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?gs.dirname(this.path):void 0}set dirname(t){O1(this.basename,"dirname"),this.path=gs.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?gs.extname(this.path):void 0}set extname(t){if(rg(t,"extname"),O1(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=gs.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){fx(t)&&(t=RM(t)),sg(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?gs.basename(this.path,this.extname):void 0}set stem(t){sg(t,"stem"),rg(t,"stem"),this.path=gs.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const a=this.message(t,n,r);throw a.fatal=!0,a}info(t,n,r){const a=this.message(t,n,r);return a.fatal=void 0,a}message(t,n,r){const a=new qn(t,n,r);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function rg(e,t){if(e&&e.includes(gs.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+gs.sep+"`")}function sg(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function O1(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function IM(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const MM=(function(e){const r=this.constructor.prototype,a=r[e],l=function(){return a.apply(l,arguments)};return Object.setPrototypeOf(l,r),l}),PM={}.hasOwnProperty;class ky extends MM{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=wM()}copy(){const t=new ky;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(tg(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(og("data",this.frozen),this.namespace[t]=n,this):PM.call(this.namespace,t)&&this.namespace[t]||void 0:t?(og("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const a=n.call(t,...r);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=_d(t),r=this.parser||this.Parser;return ig("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),ig("process",this.parser||this.Parser),ag("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(l,u){const c=_d(t),d=r.parse(c);r.run(d,c,function(p,m,x){if(p||!m||!x)return h(p);const y=m,S=r.stringify(y,x);zM(S)?x.value=S:x.result=S,h(p,x)});function h(p,m){p||!m?u(p):l?l(m):n(void 0,m)}}}processSync(t){let n=!1,r;return this.freeze(),ig("processSync",this.parser||this.Parser),ag("processSync",this.compiler||this.Compiler),this.process(t,a),M1("processSync","process",n),r;function a(l,u){n=!0,D1(l),r=u}}run(t,n,r){I1(t),this.freeze();const a=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?l(void 0,r):new Promise(l);function l(u,c){const d=_d(n);a.run(t,d,h);function h(p,m,x){const y=m||t;p?c(p):u?u(y):r(void 0,y,x)}}}runSync(t,n){let r=!1,a;return this.run(t,n,l),M1("runSync","run",r),a;function l(u,c){D1(u),a=c,r=!0}}stringify(t,n){this.freeze();const r=_d(n),a=this.compiler||this.Compiler;return ag("stringify",a),I1(t),a(t,r)}use(t,...n){const r=this.attachers,a=this.namespace;if(og("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):u(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(h){if(typeof h=="function")d(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[p,...m]=h;d(p,m)}else u(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function u(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(h.plugins),h.settings&&(a.settings=tg(!0,a.settings,h.settings))}function c(h){let p=-1;if(h!=null)if(Array.isArray(h))for(;++p<h.length;){const m=h[p];l(m)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function d(h,p){let m=-1,x=-1;for(;++m<r.length;)if(r[m][0]===h){x=m;break}if(x===-1)r.push([h,...p]);else if(p.length>0){let[y,...S]=p;const C=r[x][1];hx(C)&&hx(y)&&(y=tg(!0,C,y)),r[x]=[h,y,...S]}}}}const BM=new ky().freeze();function ig(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ag(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function og(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function I1(e){if(!hx(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function M1(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function _d(e){return $M(e)?e:new Hj(e)}function $M(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function zM(e){return typeof e=="string"||HM(e)}function HM(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const FM="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",P1=[],B1={allowDangerousHtml:!0},UM=/^(https?|ircs?|mailto|xmpp)$/i,VM=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function WM(e){const t=GM(e),n=qM(e);return KM(t.runSync(t.parse(n),n),e)}function GM(e){const t=e.rehypePlugins||P1,n=e.remarkPlugins||P1,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...B1}:B1;return BM().use(jI).use(n).use(vM,r).use(t)}function qM(e){const t=e.children||"",n=new Hj;return typeof t=="string"&&(n.value=t),n}function KM(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,l=t.disallowedElements,u=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||YM;for(const p of VM)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+FM+p.id,void 0);return Cy(e,h),c5(e,{Fragment:i.Fragment,components:a,ignoreInvalidStyle:!0,jsx:i.jsx,jsxs:i.jsxs,passKeys:!0,passNode:!0});function h(p,m,x){if(p.type==="raw"&&x&&typeof m=="number")return u?x.children.splice(m,1):x.children[m]={type:"text",value:p.value},m;if(p.type==="element"){let y;for(y in Qp)if(Object.hasOwn(Qp,y)&&Object.hasOwn(p.properties,y)){const S=p.properties[y],C=Qp[y];(C===null||C.includes(p.tagName))&&(p.properties[y]=d(String(S||""),y,p))}}if(p.type==="element"){let y=n?!n.includes(p.tagName):l?l.includes(p.tagName):!1;if(!y&&r&&typeof m=="number"&&(y=!r(p,m,x)),y&&x&&typeof m=="number")return c&&p.children?x.children.splice(m,1,...p.children):x.children.splice(m,1),m}}}function YM(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||r!==-1&&t>r||UM.test(e.slice(0,t))?e:""}function $1(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;a!==-1;)r++,a=n.indexOf(t,a+t.length);return r}function XM(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function QM(e,t,n){const a=Jh((n||{}).ignore||[]),l=JM(t);let u=-1;for(;++u<l.length;)zj(e,"text",c);function c(h,p){let m=-1,x;for(;++m<p.length;){const y=p[m],S=x?x.children:void 0;if(a(y,S?S.indexOf(y):void 0,x))return;x=y}if(x)return d(h,p)}function d(h,p){const m=p[p.length-1],x=l[u][0],y=l[u][1];let S=0;const v=m.children.indexOf(h);let w=!1,_=[];x.lastIndex=0;let b=x.exec(h.value);for(;b;){const k=b.index,E={index:b.index,input:b.input,stack:[...p,h]};let T=y(...b,E);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?x.lastIndex=k+1:(S!==k&&_.push({type:"text",value:h.value.slice(S,k)}),Array.isArray(T)?_.push(...T):T&&_.push(T),S=k+b[0].length,w=!0),!x.global)break;b=x.exec(h.value)}return w?(S<h.value.length&&_.push({type:"text",value:h.value.slice(S)}),m.children.splice(v,1,..._)):_=[h],v+_.length}}function JM(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const a=n[r];t.push([ZM(a[0]),e4(a[1])])}return t}function ZM(e){return typeof e=="string"?new RegExp(XM(e),"g"):e}function e4(e){return typeof e=="function"?e:function(){return e}}const lg="phrasing",cg=["autolink","link","image","label"];function t4(){return{transforms:[l4],enter:{literalAutolink:r4,literalAutolinkEmail:ug,literalAutolinkHttp:ug,literalAutolinkWww:ug},exit:{literalAutolink:o4,literalAutolinkEmail:a4,literalAutolinkHttp:s4,literalAutolinkWww:i4}}}function n4(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:lg,notInConstruct:cg},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:lg,notInConstruct:cg},{character:":",before:"[ps]",after:"\\/",inConstruct:lg,notInConstruct:cg}]}}function r4(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ug(e){this.config.enter.autolinkProtocol.call(this,e)}function s4(e){this.config.exit.autolinkProtocol.call(this,e)}function i4(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function a4(e){this.config.exit.autolinkEmail.call(this,e)}function o4(e){this.exit(e)}function l4(e){QM(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,c4],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),u4]],{ignore:["link","linkReference"]})}function c4(e,t,n,r,a){let l="";if(!Fj(a)||(/^w/i.test(t)&&(n=t+n,t="",l="http://"),!d4(n)))return!1;const u=h4(n+r);if(!u[0])return!1;const c={type:"link",title:null,url:l+t+u[0],children:[{type:"text",value:t+u[0]}]};return u[1]?[c,{type:"text",value:u[1]}]:c}function u4(e,t,n,r){return!Fj(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function d4(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function h4(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const a=$1(e,"(");let l=$1(e,")");for(;r!==-1&&a>l;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),l++;return[e,n]}function Fj(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Ia(n)||Yh(n))&&(!t||n!==47)}Uj.peek=_4;function f4(){this.buffer()}function m4(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function p4(){this.buffer()}function g4(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function x4(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=rs(this.sliceSerialize(e)).toLowerCase(),n.label=t}function y4(e){this.exit(e)}function b4(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=rs(this.sliceSerialize(e)).toLowerCase(),n.label=t}function v4(e){this.exit(e)}function _4(){return"["}function Uj(e,t,n,r){const a=n.createTracker(r);let l=a.move("[^");const u=n.enter("footnoteReference"),c=n.enter("reference");return l+=a.move(n.safe(n.associationId(e),{after:"]",before:l})),c(),u(),l+=a.move("]"),l}function S4(){return{enter:{gfmFootnoteCallString:f4,gfmFootnoteCall:m4,gfmFootnoteDefinitionLabelString:p4,gfmFootnoteDefinition:g4},exit:{gfmFootnoteCallString:x4,gfmFootnoteCall:y4,gfmFootnoteDefinitionLabelString:b4,gfmFootnoteDefinition:v4}}}function w4(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Uj},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,a,l,u){const c=l.createTracker(u);let d=c.move("[^");const h=l.enter("footnoteDefinition"),p=l.enter("label");return d+=c.move(l.safe(l.associationId(r),{before:d,after:"]"})),p(),d+=c.move("]:"),r.children&&r.children.length>0&&(c.shift(4),d+=c.move((t?`
|
|
81
|
+
`:" ")+l.indentLines(l.containerFlow(r,c.current()),t?Vj:C4))),h(),d}}function C4(e,t,n){return t===0?e:Vj(e,t,n)}function Vj(e,t,n){return(n?"":" ")+e}const k4=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Wj.peek=A4;function j4(){return{canContainEols:["delete"],enter:{strikethrough:N4},exit:{strikethrough:T4}}}function E4(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:k4}],handlers:{delete:Wj}}}function N4(e){this.enter({type:"delete",children:[]},e)}function T4(e){this.exit(e)}function Wj(e,t,n,r){const a=n.createTracker(r),l=n.enter("strikethrough");let u=a.move("~~");return u+=n.containerPhrasing(e,{...a.current(),before:u,after:"~"}),u+=a.move("~~"),l(),u}function A4(){return"~"}function L4(e){return e.length}function D4(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||L4,l=[],u=[],c=[],d=[];let h=0,p=-1;for(;++p<e.length;){const C=[],v=[];let w=-1;for(e[p].length>h&&(h=e[p].length);++w<e[p].length;){const _=R4(e[p][w]);if(n.alignDelimiters!==!1){const b=a(_);v[w]=b,(d[w]===void 0||b>d[w])&&(d[w]=b)}C.push(_)}u[p]=C,c[p]=v}let m=-1;if(typeof r=="object"&&"length"in r)for(;++m<h;)l[m]=z1(r[m]);else{const C=z1(r);for(;++m<h;)l[m]=C}m=-1;const x=[],y=[];for(;++m<h;){const C=l[m];let v="",w="";C===99?(v=":",w=":"):C===108?v=":":C===114&&(w=":");let _=n.alignDelimiters===!1?1:Math.max(1,d[m]-v.length-w.length);const b=v+"-".repeat(_)+w;n.alignDelimiters!==!1&&(_=v.length+_+w.length,_>d[m]&&(d[m]=_),y[m]=_),x[m]=b}u.splice(1,0,x),c.splice(1,0,y),p=-1;const S=[];for(;++p<u.length;){const C=u[p],v=c[p];m=-1;const w=[];for(;++m<h;){const _=C[m]||"";let b="",k="";if(n.alignDelimiters!==!1){const E=d[m]-(v[m]||0),T=l[m];T===114?b=" ".repeat(E):T===99?E%2?(b=" ".repeat(E/2+.5),k=" ".repeat(E/2-.5)):(b=" ".repeat(E/2),k=b):k=" ".repeat(E)}n.delimiterStart!==!1&&!m&&w.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||m)&&w.push(" "),n.alignDelimiters!==!1&&w.push(b),w.push(_),n.alignDelimiters!==!1&&w.push(k),n.padding!==!1&&w.push(" "),(n.delimiterEnd!==!1||m!==h-1)&&w.push("|")}S.push(n.delimiterEnd===!1?w.join("").replace(/ +$/,""):w.join(""))}return S.join(`
|
|
82
|
+
`)}function R4(e){return e==null?"":String(e)}function z1(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function O4(e,t,n,r){const a=n.enter("blockquote"),l=n.createTracker(r);l.move("> "),l.shift(2);const u=n.indentLines(n.containerFlow(e,l.current()),I4);return a(),u}function I4(e,t,n){return">"+(n?"":" ")+e}function M4(e,t){return H1(e,t.inConstruct,!0)&&!H1(e,t.notInConstruct,!1)}function H1(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function F1(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
|
|
83
|
+
`&&M4(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
84
|
+
`}function P4(e,t){const n=String(e);let r=n.indexOf(t),a=r,l=0,u=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===a?++l>u&&(u=l):l=1,a=r+t.length,r=n.indexOf(t,a);return u}function B4(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function $4(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function z4(e,t,n,r){const a=$4(n),l=e.value||"",u=a==="`"?"GraveAccent":"Tilde";if(B4(e,n)){const m=n.enter("codeIndented"),x=n.indentLines(l,H4);return m(),x}const c=n.createTracker(r),d=a.repeat(Math.max(P4(l,a)+1,3)),h=n.enter("codeFenced");let p=c.move(d);if(e.lang){const m=n.enter(`codeFencedLang${u}`);p+=c.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...c.current()})),m()}if(e.lang&&e.meta){const m=n.enter(`codeFencedMeta${u}`);p+=c.move(" "),p+=c.move(n.safe(e.meta,{before:p,after:`
|
|
85
|
+
`,encode:["`"],...c.current()})),m()}return p+=c.move(`
|
|
86
|
+
`),l&&(p+=c.move(l+`
|
|
87
|
+
`)),p+=c.move(d),h(),p}function H4(e,t,n){return(n?"":" ")+e}function jy(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function F4(e,t,n,r){const a=jy(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("definition");let c=n.enter("label");const d=n.createTracker(r);let h=d.move("[");return h+=d.move(n.safe(n.associationId(e),{before:h,after:"]",...d.current()})),h+=d.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(n.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=n.enter("destinationRaw"),h+=d.move(n.safe(e.url,{before:h,after:e.title?" ":`
|
|
88
|
+
`,...d.current()}))),c(),e.title&&(c=n.enter(`title${l}`),h+=d.move(" "+a),h+=d.move(n.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),u(),h}function U4(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Mc(e){return"&#x"+e.toString(16).toUpperCase()+";"}function hh(e,t,n){const r=Ko(e),a=Ko(t);return r===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Gj.peek=V4;function Gj(e,t,n,r){const a=U4(n),l=n.enter("emphasis"),u=n.createTracker(r),c=u.move(a);let d=u.move(n.containerPhrasing(e,{after:a,before:c,...u.current()}));const h=d.charCodeAt(0),p=hh(r.before.charCodeAt(r.before.length-1),h,a);p.inside&&(d=Mc(h)+d.slice(1));const m=d.charCodeAt(d.length-1),x=hh(r.after.charCodeAt(0),m,a);x.inside&&(d=d.slice(0,-1)+Mc(m));const y=u.move(a);return l(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},c+d+y}function V4(e,t,n){return n.options.emphasis||"*"}function W4(e,t){let n=!1;return Cy(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,ux}),!!((!e.depth||e.depth<3)&&xy(e)&&(t.options.setext||n))}function G4(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),l=n.createTracker(r);if(W4(e,n)){const p=n.enter("headingSetext"),m=n.enter("phrasing"),x=n.containerPhrasing(e,{...l.current(),before:`
|
|
89
|
+
`,after:`
|
|
90
|
+
`});return m(),p(),x+`
|
|
91
|
+
`+(a===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(`
|
|
92
|
+
`))+1))}const u="#".repeat(a),c=n.enter("headingAtx"),d=n.enter("phrasing");l.move(u+" ");let h=n.containerPhrasing(e,{before:"# ",after:`
|
|
93
|
+
`,...l.current()});return/^[\t ]/.test(h)&&(h=Mc(h.charCodeAt(0))+h.slice(1)),h=h?u+" "+h:u,n.options.closeAtx&&(h+=" "+u),d(),c(),h}qj.peek=q4;function qj(e){return e.value||""}function q4(){return"<"}Kj.peek=K4;function Kj(e,t,n,r){const a=jy(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("image");let c=n.enter("label");const d=n.createTracker(r);let h=d.move("![");return h+=d.move(n.safe(e.alt,{before:h,after:"]",...d.current()})),h+=d.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(n.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=n.enter("destinationRaw"),h+=d.move(n.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),c(),e.title&&(c=n.enter(`title${l}`),h+=d.move(" "+a),h+=d.move(n.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),h+=d.move(")"),u(),h}function K4(){return"!"}Yj.peek=Y4;function Yj(e,t,n,r){const a=e.referenceType,l=n.enter("imageReference");let u=n.enter("label");const c=n.createTracker(r);let d=c.move("![");const h=n.safe(e.alt,{before:d,after:"]",...c.current()});d+=c.move(h+"]["),u();const p=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...c.current()});return u(),n.stack=p,l(),a==="full"||!h||h!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function Y4(){return"!"}Xj.peek=X4;function Xj(e,t,n){let r=e.value||"",a="`",l=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++l<n.unsafe.length;){const u=n.unsafe[l],c=n.compilePattern(u);let d;if(u.atBreak)for(;d=c.exec(r);){let h=d.index;r.charCodeAt(h)===10&&r.charCodeAt(h-1)===13&&h--,r=r.slice(0,h)+" "+r.slice(d.index+1)}}return a+r+a}function X4(){return"`"}function Qj(e,t){const n=xy(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Jj.peek=Q4;function Jj(e,t,n,r){const a=jy(n),l=a==='"'?"Quote":"Apostrophe",u=n.createTracker(r);let c,d;if(Qj(e,n)){const p=n.stack;n.stack=[],c=n.enter("autolink");let m=u.move("<");return m+=u.move(n.containerPhrasing(e,{before:m,after:">",...u.current()})),m+=u.move(">"),c(),n.stack=p,m}c=n.enter("link"),d=n.enter("label");let h=u.move("[");return h+=u.move(n.containerPhrasing(e,{before:h,after:"](",...u.current()})),h+=u.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(n.safe(e.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(d=n.enter("destinationRaw"),h+=u.move(n.safe(e.url,{before:h,after:e.title?" ":")",...u.current()}))),d(),e.title&&(d=n.enter(`title${l}`),h+=u.move(" "+a),h+=u.move(n.safe(e.title,{before:h,after:a,...u.current()})),h+=u.move(a),d()),h+=u.move(")"),c(),h}function Q4(e,t,n){return Qj(e,n)?"<":"["}Zj.peek=J4;function Zj(e,t,n,r){const a=e.referenceType,l=n.enter("linkReference");let u=n.enter("label");const c=n.createTracker(r);let d=c.move("[");const h=n.containerPhrasing(e,{before:d,after:"]",...c.current()});d+=c.move(h+"]["),u();const p=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...c.current()});return u(),n.stack=p,l(),a==="full"||!h||h!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function J4(){return"["}function Ey(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Z4(e){const t=Ey(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function eP(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function eE(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function tP(e,t,n,r){const a=n.enter("list"),l=n.bulletCurrent;let u=e.ordered?eP(n):Ey(n);const c=e.ordered?u==="."?")":".":Z4(n);let d=t&&n.bulletLastUsed?u===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(d=!0),eE(n)===u&&p){let m=-1;for(;++m<e.children.length;){const x=e.children[m];if(x&&x.type==="listItem"&&x.children&&x.children[0]&&x.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(u=c),n.bulletCurrent=u;const h=n.containerFlow(e,r);return n.bulletLastUsed=u,n.bulletCurrent=l,a(),h}function nP(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function rP(e,t,n,r){const a=nP(n);let l=n.bulletCurrent||Ey(n);t&&t.type==="list"&&t.ordered&&(l=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+l);let u=l.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const c=n.createTracker(r);c.move(l+" ".repeat(u-l.length)),c.shift(u);const d=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,c.current()),p);return d(),h;function p(m,x,y){return x?(y?"":" ".repeat(u))+m:(y?l:l+" ".repeat(u-l.length))+m}}function sP(e,t,n,r){const a=n.enter("paragraph"),l=n.enter("phrasing"),u=n.containerPhrasing(e,r);return l(),a(),u}const iP=Jh(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function aP(e,t,n,r){return(e.children.some(function(u){return iP(u)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function oP(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}tE.peek=lP;function tE(e,t,n,r){const a=oP(n),l=n.enter("strong"),u=n.createTracker(r),c=u.move(a+a);let d=u.move(n.containerPhrasing(e,{after:a,before:c,...u.current()}));const h=d.charCodeAt(0),p=hh(r.before.charCodeAt(r.before.length-1),h,a);p.inside&&(d=Mc(h)+d.slice(1));const m=d.charCodeAt(d.length-1),x=hh(r.after.charCodeAt(0),m,a);x.inside&&(d=d.slice(0,-1)+Mc(m));const y=u.move(a+a);return l(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},c+d+y}function lP(e,t,n){return n.options.strong||"*"}function cP(e,t,n,r){return n.safe(e.value,r)}function uP(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function dP(e,t,n){const r=(eE(n)+(n.options.ruleSpaces?" ":"")).repeat(uP(n));return n.options.ruleSpaces?r.slice(0,-1):r}const nE={blockquote:O4,break:F1,code:z4,definition:F4,emphasis:Gj,hardBreak:F1,heading:G4,html:qj,image:Kj,imageReference:Yj,inlineCode:Xj,link:Jj,linkReference:Zj,list:tP,listItem:rP,paragraph:sP,root:aP,strong:tE,text:cP,thematicBreak:dP};function hP(){return{enter:{table:fP,tableData:U1,tableHeader:U1,tableRow:pP},exit:{codeText:gP,table:mP,tableData:dg,tableHeader:dg,tableRow:dg}}}function fP(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function mP(e){this.exit(e),this.data.inTable=void 0}function pP(e){this.enter({type:"tableRow",children:[]},e)}function dg(e){this.exit(e)}function U1(e){this.enter({type:"tableCell",children:[]},e)}function gP(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,xP));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function xP(e,t){return t==="|"?t:e}function yP(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,l=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
94
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:u,tableCell:d,tableRow:c}};function u(y,S,C,v){return h(p(y,C,v),y.align)}function c(y,S,C,v){const w=m(y,C,v),_=h([w]);return _.slice(0,_.indexOf(`
|
|
95
|
+
`))}function d(y,S,C,v){const w=C.enter("tableCell"),_=C.enter("phrasing"),b=C.containerPhrasing(y,{...v,before:l,after:l});return _(),w(),b}function h(y,S){return D4(y,{align:S,alignDelimiters:r,padding:n,stringLength:a})}function p(y,S,C){const v=y.children;let w=-1;const _=[],b=S.enter("table");for(;++w<v.length;)_[w]=m(v[w],S,C);return b(),_}function m(y,S,C){const v=y.children;let w=-1;const _=[],b=S.enter("tableRow");for(;++w<v.length;)_[w]=d(v[w],y,S,C);return b(),_}function x(y,S,C){let v=nE.inlineCode(y,S,C);return C.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function bP(){return{exit:{taskListCheckValueChecked:V1,taskListCheckValueUnchecked:V1,paragraph:_P}}}function vP(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:SP}}}function V1(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function _P(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let l=-1,u;for(;++l<a.length;){const c=a[l];if(c.type==="paragraph"){u=c;break}}u===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function SP(e,t,n,r){const a=e.children[0],l=typeof e.checked=="boolean"&&a&&a.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",c=n.createTracker(r);l&&c.move(u);let d=nE.listItem(e,t,n,{...r,...c.current()});return l&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),d;function h(p){return p+u}}function wP(){return[t4(),S4(),j4(),hP(),bP()]}function CP(e){return{extensions:[n4(),w4(e),E4(),yP(e),vP()]}}const kP={tokenize:LP,partial:!0},rE={tokenize:DP,partial:!0},sE={tokenize:RP,partial:!0},iE={tokenize:OP,partial:!0},jP={tokenize:IP,partial:!0},aE={name:"wwwAutolink",tokenize:TP,previous:lE},oE={name:"protocolAutolink",tokenize:AP,previous:cE},ii={name:"emailAutolink",tokenize:NP,previous:uE},ks={};function EP(){return{text:ks}}let ma=48;for(;ma<123;)ks[ma]=ii,ma++,ma===58?ma=65:ma===91&&(ma=97);ks[43]=ii;ks[45]=ii;ks[46]=ii;ks[95]=ii;ks[72]=[ii,oE];ks[104]=[ii,oE];ks[87]=[ii,aE];ks[119]=[ii,aE];function NP(e,t,n){const r=this;let a,l;return u;function u(m){return!mx(m)||!uE.call(r,r.previous)||Ny(r.events)?n(m):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(m))}function c(m){return mx(m)?(e.consume(m),c):m===64?(e.consume(m),d):n(m)}function d(m){return m===46?e.check(jP,p,h)(m):m===45||m===95||Wn(m)?(l=!0,e.consume(m),d):p(m)}function h(m){return e.consume(m),a=!0,d}function p(m){return l&&a&&Zn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function TP(e,t,n){const r=this;return a;function a(u){return u!==87&&u!==119||!lE.call(r,r.previous)||Ny(r.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(kP,e.attempt(rE,e.attempt(sE,l),n),n)(u))}function l(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function AP(e,t,n){const r=this;let a="",l=!1;return u;function u(m){return(m===72||m===104)&&cE.call(r,r.previous)&&!Ny(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),e.consume(m),c):n(m)}function c(m){if(Zn(m)&&a.length<5)return a+=String.fromCodePoint(m),e.consume(m),c;if(m===58){const x=a.toLowerCase();if(x==="http"||x==="https")return e.consume(m),d}return n(m)}function d(m){return m===47?(e.consume(m),l?h:(l=!0,d)):n(m)}function h(m){return m===null||ch(m)||Yt(m)||Ia(m)||Yh(m)?n(m):e.attempt(rE,e.attempt(sE,p),n)(m)}function p(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function LP(e,t,n){let r=0;return a;function a(u){return(u===87||u===119)&&r<3?(r++,e.consume(u),a):u===46&&r===3?(e.consume(u),l):n(u)}function l(u){return u===null?n(u):t(u)}}function DP(e,t,n){let r,a,l;return u;function u(h){return h===46||h===95?e.check(iE,d,c)(h):h===null||Yt(h)||Ia(h)||h!==45&&Yh(h)?d(h):(l=!0,e.consume(h),u)}function c(h){return h===95?r=!0:(a=r,r=void 0),e.consume(h),u}function d(h){return a||r||!l?n(h):t(h)}}function RP(e,t){let n=0,r=0;return a;function a(u){return u===40?(n++,e.consume(u),a):u===41&&r<n?l(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(iE,t,l)(u):u===null||Yt(u)||Ia(u)?t(u):(e.consume(u),a)}function l(u){return u===41&&r++,e.consume(u),a}}function OP(e,t,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),r):c===38?(e.consume(c),l):c===93?(e.consume(c),a):c===60||c===null||Yt(c)||Ia(c)?t(c):n(c)}function a(c){return c===null||c===40||c===91||Yt(c)||Ia(c)?t(c):r(c)}function l(c){return Zn(c)?u(c):n(c)}function u(c){return c===59?(e.consume(c),r):Zn(c)?(e.consume(c),u):n(c)}}function IP(e,t,n){return r;function r(l){return e.consume(l),a}function a(l){return Wn(l)?n(l):t(l)}}function lE(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Yt(e)}function cE(e){return!Zn(e)}function uE(e){return!(e===47||mx(e))}function mx(e){return e===43||e===45||e===46||e===95||Wn(e)}function Ny(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const MP={tokenize:VP,partial:!0};function PP(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:HP,continuation:{tokenize:FP},exit:UP}},text:{91:{name:"gfmFootnoteCall",tokenize:zP},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:BP,resolveTo:$P}}}}function BP(e,t,n){const r=this;let a=r.events.length;const l=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let u;for(;a--;){const d=r.events[a][1];if(d.type==="labelImage"){u=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!u||!u._balanced)return n(d);const h=rs(r.sliceSerialize({start:u.end,end:r.now()}));return h.codePointAt(0)!==94||!l.includes(h.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function $P(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const l={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},c=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",l,t],["enter",u,t],["exit",u,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...c),e}function zP(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l=0,u;return c;function c(m){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),d}function d(m){return m!==94?n(m):(e.enter("gfmFootnoteCallMarker"),e.consume(m),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(m){if(l>999||m===93&&!u||m===null||m===91||Yt(m))return n(m);if(m===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return a.includes(rs(r.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return Yt(m)||(u=!0),l++,e.consume(m),m===92?p:h}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,h):h(m)}}function HP(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l,u=0,c;return d;function d(S){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(S),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(S){return S===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(S),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(S)}function p(S){if(u>999||S===93&&!c||S===null||S===91||Yt(S))return n(S);if(S===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return l=rs(r.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(S),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return Yt(S)||(c=!0),u++,e.consume(S),S===92?m:p}function m(S){return S===91||S===92||S===93?(e.consume(S),u++,p):p(S)}function x(S){return S===58?(e.enter("definitionMarker"),e.consume(S),e.exit("definitionMarker"),a.includes(l)||a.push(l),Dt(e,y,"gfmFootnoteDefinitionWhitespace")):n(S)}function y(S){return t(S)}}function FP(e,t,n){return e.check(Kc,t,e.attempt(MP,t,n))}function UP(e){e.exit("gfmFootnoteDefinition")}function VP(e,t,n){const r=this;return Dt(e,a,"gfmFootnoteDefinitionIndent",5);function a(l){const u=r.events[r.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(l):n(l)}}function WP(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:l,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(u,c){let d=-1;for(;++d<u.length;)if(u[d][0]==="enter"&&u[d][1].type==="strikethroughSequenceTemporary"&&u[d][1]._close){let h=d;for(;h--;)if(u[h][0]==="exit"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._open&&u[d][1].end.offset-u[d][1].start.offset===u[h][1].end.offset-u[h][1].start.offset){u[d][1].type="strikethroughSequence",u[h][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},u[h][1].start),end:Object.assign({},u[d][1].end)},m={type:"strikethroughText",start:Object.assign({},u[h][1].end),end:Object.assign({},u[d][1].start)},x=[["enter",p,c],["enter",u[h][1],c],["exit",u[h][1],c],["enter",m,c]],y=c.parser.constructs.insideSpan.null;y&&jr(x,x.length,0,Xh(y,u.slice(h+1,d),c)),jr(x,x.length,0,[["exit",m,c],["enter",u[d][1],c],["exit",u[d][1],c],["exit",p,c]]),jr(u,h-1,d-h+3,x),d=h+x.length-2;break}}for(d=-1;++d<u.length;)u[d][1].type==="strikethroughSequenceTemporary"&&(u[d][1].type="data");return u}function l(u,c,d){const h=this.previous,p=this.events;let m=0;return x;function x(S){return h===126&&p[p.length-1][1].type!=="characterEscape"?d(S):(u.enter("strikethroughSequenceTemporary"),y(S))}function y(S){const C=Ko(h);if(S===126)return m>1?d(S):(u.consume(S),m++,y);if(m<2&&!n)return d(S);const v=u.exit("strikethroughSequenceTemporary"),w=Ko(S);return v._open=!w||w===2&&!!C,v._close=!C||C===2&&!!w,c(S)}}}class GP{constructor(){this.map=[]}add(t,n,r){qP(this,t,n,r)}consume(t){if(this.map.sort(function(l,u){return l[0]-u[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let a=r.pop();for(;a;){for(const l of a)t.push(l);a=r.pop()}this.map.length=0}}function qP(e,t,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...r);return}a+=1}e.map.push([t,n,r])}}function KP(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const l=r.length-1;r[l]=r[l]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function YP(){return{flow:{null:{name:"table",tokenize:XP,resolveAll:QP}}}}function XP(e,t,n){const r=this;let a=0,l=0,u;return c;function c(M){let W=r.events.length-1;for(;W>-1;){const I=r.events[W][1].type;if(I==="lineEnding"||I==="linePrefix")W--;else break}const z=W>-1?r.events[W][1].type:null,H=z==="tableHead"||z==="tableRow"?T:d;return H===T&&r.parser.lazy[r.now().line]?n(M):H(M)}function d(M){return e.enter("tableHead"),e.enter("tableRow"),h(M)}function h(M){return M===124||(u=!0,l+=1),p(M)}function p(M){return M===null?n(M):ht(M)?l>1?(l=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),y):n(M):jt(M)?Dt(e,p,"whitespace")(M):(l+=1,u&&(u=!1,a+=1),M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),u=!0,p):(e.enter("data"),m(M)))}function m(M){return M===null||M===124||Yt(M)?(e.exit("data"),p(M)):(e.consume(M),M===92?x:m)}function x(M){return M===92||M===124?(e.consume(M),m):m(M)}function y(M){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(M):(e.enter("tableDelimiterRow"),u=!1,jt(M)?Dt(e,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):S(M))}function S(M){return M===45||M===58?v(M):M===124?(u=!0,e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),C):E(M)}function C(M){return jt(M)?Dt(e,v,"whitespace")(M):v(M)}function v(M){return M===58?(l+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(M),e.exit("tableDelimiterMarker"),w):M===45?(l+=1,w(M)):M===null||ht(M)?k(M):E(M)}function w(M){return M===45?(e.enter("tableDelimiterFiller"),_(M)):E(M)}function _(M){return M===45?(e.consume(M),_):M===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(M),e.exit("tableDelimiterMarker"),b):(e.exit("tableDelimiterFiller"),b(M))}function b(M){return jt(M)?Dt(e,k,"whitespace")(M):k(M)}function k(M){return M===124?S(M):M===null||ht(M)?!u||a!==l?E(M):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(M)):E(M)}function E(M){return n(M)}function T(M){return e.enter("tableRow"),D(M)}function D(M){return M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),D):M===null||ht(M)?(e.exit("tableRow"),t(M)):jt(M)?Dt(e,D,"whitespace")(M):(e.enter("data"),L(M))}function L(M){return M===null||M===124||Yt(M)?(e.exit("data"),D(M)):(e.consume(M),M===92?R:L)}function R(M){return M===92||M===124?(e.consume(M),L):L(M)}}function QP(e,t){let n=-1,r=!0,a=0,l=[0,0,0,0],u=[0,0,0,0],c=!1,d=0,h,p,m;const x=new GP;for(;++n<e.length;){const y=e[n],S=y[1];y[0]==="enter"?S.type==="tableHead"?(c=!1,d!==0&&(W1(x,t,d,h,p),p=void 0,d=0),h={type:"table",start:Object.assign({},S.start),end:Object.assign({},S.end)},x.add(n,0,[["enter",h,t]])):S.type==="tableRow"||S.type==="tableDelimiterRow"?(r=!0,m=void 0,l=[0,0,0,0],u=[0,n+1,0,0],c&&(c=!1,p={type:"tableBody",start:Object.assign({},S.start),end:Object.assign({},S.end)},x.add(n,0,[["enter",p,t]])),a=S.type==="tableDelimiterRow"?2:p?3:1):a&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")?(r=!1,u[2]===0&&(l[1]!==0&&(u[0]=u[1],m=Sd(x,t,l,a,void 0,m),l=[0,0,0,0]),u[2]=n)):S.type==="tableCellDivider"&&(r?r=!1:(l[1]!==0&&(u[0]=u[1],m=Sd(x,t,l,a,void 0,m)),l=u,u=[l[1],n,0,0])):S.type==="tableHead"?(c=!0,d=n):S.type==="tableRow"||S.type==="tableDelimiterRow"?(d=n,l[1]!==0?(u[0]=u[1],m=Sd(x,t,l,a,n,m)):u[1]!==0&&(m=Sd(x,t,u,a,n,m)),a=0):a&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")&&(u[3]=n)}for(d!==0&&W1(x,t,d,h,p),x.consume(t.events),n=-1;++n<t.events.length;){const y=t.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=KP(t.events,n))}return e}function Sd(e,t,n,r,a,l){const u=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(l.end=Object.assign({},Do(t.events,n[0])),e.add(n[0],0,[["exit",l,t]]));const d=Do(t.events,n[1]);if(l={type:u,start:Object.assign({},d),end:Object.assign({},d)},e.add(n[1],0,[["enter",l,t]]),n[2]!==0){const h=Do(t.events,n[2]),p=Do(t.events,n[3]),m={type:c,start:Object.assign({},h),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",m,t]]),r!==2){const x=t.events[n[2]],y=t.events[n[3]];if(x[1].end=Object.assign({},y[1].end),x[1].type="chunkText",x[1].contentType="text",n[3]>n[2]+1){const S=n[2]+1,C=n[3]-n[2]-1;e.add(S,C,[])}}e.add(n[3]+1,0,[["exit",m,t]])}return a!==void 0&&(l.end=Object.assign({},Do(t.events,a)),e.add(a,0,[["exit",l,t]]),l=void 0),l}function W1(e,t,n,r,a){const l=[],u=Do(t.events,n);a&&(a.end=Object.assign({},u),l.push(["exit",a,t])),r.end=Object.assign({},u),l.push(["exit",r,t]),e.add(n+1,0,l)}function Do(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const JP={name:"tasklistCheck",tokenize:e6};function ZP(){return{text:{91:JP}}}function e6(e,t,n){const r=this;return a;function a(d){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),l)}function l(d){return Yt(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),u):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),u):n(d)}function u(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(d)}function c(d){return ht(d)?t(d):jt(d)?e.check({tokenize:t6},t,n)(d):n(d)}}function t6(e,t,n){return Dt(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function n6(e){return vj([EP(),PP(),WP(e),YP(),ZP()])}const r6={};function s6(e){const t=this,n=e||r6,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),l=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),u=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(n6(n)),l.push(wP()),u.push(CP(n))}var px=Object.defineProperty,i6=Object.getOwnPropertyDescriptor,a6=Object.getOwnPropertyNames,o6=Object.prototype.hasOwnProperty,Ty=(e,t)=>{let n={};for(var r in e)px(n,r,{get:e[r],enumerable:!0});return px(n,Symbol.toStringTag,{value:"Module"}),n},l6=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=a6(t),l=0,u=a.length,c;l<u;l++)c=a[l],!o6.call(e,c)&&c!==n&&px(e,c,{get:(d=>t[d]).bind(null,c),enumerable:!(r=i6(t,c))||r.enumerable});return e},dE=(e,t,n)=>(l6(e,t,"default"),n);const ef=[{id:"abap",name:"ABAP",import:(()=>re(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>re(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>re(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>re(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>re(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>re(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>re(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>re(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>re(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>re(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>re(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>re(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>re(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>re(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>re(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>re(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>re(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>re(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>re(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>re(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>re(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>re(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>re(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>re(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>re(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>re(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>re(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>re(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>re(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>re(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>re(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>re(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>re(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>re(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>re(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>re(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>re(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>re(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>re(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>re(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>re(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>re(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>re(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>re(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>re(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>re(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>re(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>re(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>re(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>re(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>re(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>re(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>re(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>re(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>re(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>re(()=>import("./erb-Dm6A9KJ5.js"),__vite__mapDeps([32,1,2,3,33,34,7,8,16,35,11,36,13,23,24,25,26,28,37,38])))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>re(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>re(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>re(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>re(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>re(()=>import("./fortran-fixed-form-CkoXwp7k.js"),__vite__mapDeps([41,42])))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>re(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>re(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>re(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>re(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>re(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>re(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>re(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>re(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>re(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>re(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>re(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>re(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>re(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>re(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>re(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>re(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>re(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>re(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>re(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>re(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>re(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>re(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>re(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>re(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>re(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>re(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>re(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>re(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>re(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>re(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>re(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>re(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>re(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>re(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>re(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>re(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>re(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>re(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>re(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>re(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>re(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>re(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>re(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>re(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>re(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>re(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>re(()=>import("./just-CUsbIsdP.js"),__vite__mapDeps([63,28,2,11,64,1,3,7,8,16,20,33,34,35,36,13,23,24,25,26,37,38])))},{id:"kdl",name:"KDL",import:(()=>re(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>re(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>re(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>re(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>re(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>re(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>re(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>re(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>re(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>re(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>re(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>re(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>re(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>re(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>re(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>re(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>re(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>re(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>re(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>re(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>re(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>re(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>re(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>re(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>re(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>re(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>re(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>re(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>re(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>re(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>re(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>re(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>re(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>re(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>re(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>re(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>re(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>re(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>re(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>re(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>re(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>re(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>re(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>re(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>re(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>re(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>re(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>re(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>re(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>re(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>re(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>re(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>re(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>re(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>re(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>re(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>re(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>re(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>re(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>re(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>re(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>re(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>re(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>re(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>re(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>re(()=>import("./rst-CpCqk9r5.js"),__vite__mapDeps([80,15,1,2,3,23,24,25,26,16,20,28,38,81,33,34,7,8,35,11,36,13,37])))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>re(()=>import("./ruby-DyJCeAvU.js"),__vite__mapDeps([33,1,2,3,34,7,8,16,35,11,36,13,23,24,25,26,28,37,38])))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>re(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>re(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>re(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>re(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>re(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>re(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>re(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>re(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>re(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>re(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>re(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>re(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>re(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>re(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>re(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>re(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>re(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>re(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>re(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>re(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>re(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>re(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>re(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>re(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>re(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>re(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>re(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>re(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>re(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>re(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>re(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>re(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>re(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>re(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>re(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>re(()=>import("./twig-CW1WmMYd.js"),__vite__mapDeps([95,3,2,5,75,1,7,8,16,9,20,33,34,35,11,36,13,23,24,25,26,28,37,38])))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>re(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>re(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>re(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>re(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>re(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>re(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>re(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>re(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>re(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>re(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>re(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>re(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>re(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>re(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>re(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>re(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>re(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>re(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>re(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>re(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>re(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>re(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>re(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>re(()=>import("./zig-VOosw3JB.js"),[]))}],Ay=Object.fromEntries(ef.map(e=>[e.id,e.import])),Ly=Object.fromEntries(ef.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),tf={...Ay,...Ly},Dy=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>re(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>re(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>re(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>re(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>re(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>re(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>re(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>re(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>re(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>re(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>re(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>re(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>re(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>re(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>re(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>re(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>re(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>re(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>re(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>re(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>re(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>re(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>re(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>re(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>re(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>re(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>re(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>re(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>re(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>re(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>re(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>re(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>re(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>re(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>re(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>re(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>re(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>re(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>re(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>re(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>re(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>re(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>re(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>re(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>re(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>re(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>re(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>re(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>re(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>re(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>re(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>re(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>re(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>re(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>re(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>re(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>re(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>re(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>re(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>re(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>re(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>re(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>re(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>re(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>re(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],Ry=Object.fromEntries(Dy.map(e=>[e.id,e.import]));var Oy=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function c6(){return 2147483648}function u6(){return typeof performance<"u"?performance.now():Date.now()}const d6=(e,t)=>e+(t-e%t)%t;async function h6(e){let t,n;const r={};function a(y){n=y,r.HEAPU8=new Uint8Array(y),r.HEAPU32=new Uint32Array(y)}function l(y,S,C){r.HEAPU8.copyWithin(y,S,S+C)}function u(y){try{return t.grow(y-n.byteLength+65535>>>16),a(t.buffer),1}catch{}}function c(y){const S=r.HEAPU8.length;y=y>>>0;const C=c6();if(y>C)return!1;for(let v=1;v<=4;v*=2){let w=S*(1+.2/v);w=Math.min(w,y+100663296);const _=Math.min(C,d6(Math.max(y,w),65536));if(u(_))return!0}return!1}const d=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function h(y,S,C=1024){const v=S+C;let w=S;for(;y[w]&&!(w>=v);)++w;if(w-S>16&&y.buffer&&d)return d.decode(y.subarray(S,w));let _="";for(;S<w;){let b=y[S++];if(!(b&128)){_+=String.fromCharCode(b);continue}const k=y[S++]&63;if((b&224)===192){_+=String.fromCharCode((b&31)<<6|k);continue}const E=y[S++]&63;if((b&240)===224?b=(b&15)<<12|k<<6|E:b=(b&7)<<18|k<<12|E<<6|y[S++]&63,b<65536)_+=String.fromCharCode(b);else{const T=b-65536;_+=String.fromCharCode(55296|T>>10,56320|T&1023)}}return _}function p(y,S){return y?h(r.HEAPU8,y,S):""}const m={emscripten_get_now:u6,emscripten_memcpy_big:l,emscripten_resize_heap:c,fd_write:()=>0};async function x(){const S=await e({env:m,wasi_snapshot_preview1:m});t=S.memory,a(t.buffer),Object.assign(r,S),r.UTF8ToString=p}return await x(),r}var f6=Object.defineProperty,m6=(e,t,n)=>t in e?f6(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,En=(e,t,n)=>m6(e,typeof t!="symbol"?t+"":t,n);let Dn=null;function p6(e){throw new Oy(e.UTF8ToString(e.getLastOnigError()))}class nf{constructor(t){En(this,"utf16Length"),En(this,"utf8Length"),En(this,"utf16Value"),En(this,"utf8Value"),En(this,"utf16OffsetToUtf8"),En(this,"utf8OffsetToUtf16");const n=t.length,r=nf._utf8ByteLength(t),a=r!==n,l=a?new Uint32Array(n+1):null;a&&(l[n]=r);const u=a?new Uint32Array(r+1):null;a&&(u[r]=n);const c=new Uint8Array(r);let d=0;for(let h=0;h<n;h++){const p=t.charCodeAt(h);let m=p,x=!1;if(p>=55296&&p<=56319&&h+1<n){const y=t.charCodeAt(h+1);y>=56320&&y<=57343&&(m=(p-55296<<10)+65536|y-56320,x=!0)}a&&(l[h]=d,x&&(l[h+1]=d),m<=127?u[d+0]=h:m<=2047?(u[d+0]=h,u[d+1]=h):m<=65535?(u[d+0]=h,u[d+1]=h,u[d+2]=h):(u[d+0]=h,u[d+1]=h,u[d+2]=h,u[d+3]=h)),m<=127?c[d++]=m:m<=2047?(c[d++]=192|(m&1984)>>>6,c[d++]=128|(m&63)>>>0):m<=65535?(c[d++]=224|(m&61440)>>>12,c[d++]=128|(m&4032)>>>6,c[d++]=128|(m&63)>>>0):(c[d++]=240|(m&1835008)>>>18,c[d++]=128|(m&258048)>>>12,c[d++]=128|(m&4032)>>>6,c[d++]=128|(m&63)>>>0),x&&h++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=c,this.utf16OffsetToUtf8=l,this.utf8OffsetToUtf16=u}static _utf8ByteLength(t){let n=0;for(let r=0,a=t.length;r<a;r++){const l=t.charCodeAt(r);let u=l,c=!1;if(l>=55296&&l<=56319&&r+1<a){const d=t.charCodeAt(r+1);d>=56320&&d<=57343&&(u=(l-55296<<10)+65536|d-56320,c=!0)}u<=127?n+=1:u<=2047?n+=2:u<=65535?n+=3:n+=4,c&&r++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const rf=class ms{constructor(t){if(En(this,"id",++ms.LAST_ID),En(this,"_onigBinding"),En(this,"content"),En(this,"utf16Length"),En(this,"utf8Length"),En(this,"utf16OffsetToUtf8"),En(this,"utf8OffsetToUtf16"),En(this,"ptr"),!Dn)throw new Oy("Must invoke loadWasm first.");this._onigBinding=Dn,this.content=t;const n=new nf(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!ms._sharedPtrInUse?(ms._sharedPtr||(ms._sharedPtr=Dn.omalloc(1e4)),ms._sharedPtrInUse=!0,Dn.HEAPU8.set(n.utf8Value,ms._sharedPtr),this.ptr=ms._sharedPtr):this.ptr=n.createString(Dn)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===ms._sharedPtr?ms._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};En(rf,"LAST_ID",0);En(rf,"_sharedPtr",0);En(rf,"_sharedPtrInUse",!1);let hE=rf;class g6{constructor(t){if(En(this,"_onigBinding"),En(this,"_ptr"),!Dn)throw new Oy("Must invoke loadWasm first.");const n=[],r=[];for(let c=0,d=t.length;c<d;c++){const h=new nf(t[c]);n[c]=h.createString(Dn),r[c]=h.utf8Length}const a=Dn.omalloc(4*t.length);Dn.HEAPU32.set(n,a/4);const l=Dn.omalloc(4*t.length);Dn.HEAPU32.set(r,l/4);const u=Dn.createOnigScanner(a,l,t.length);for(let c=0,d=t.length;c<d;c++)Dn.ofree(n[c]);Dn.ofree(l),Dn.ofree(a),u===0&&p6(Dn),this._onigBinding=Dn,this._ptr=u}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let a=0;if(typeof r=="number"&&(a=r),typeof t=="string"){t=new hE(t);const l=this._findNextMatchSync(t,n,!1,a);return t.dispose(),l}return this._findNextMatchSync(t,n,!1,a)}_findNextMatchSync(t,n,r,a){const l=this._onigBinding,u=l.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),a);if(u===0)return null;const c=l.HEAPU32;let d=u/4;const h=c[d++],p=c[d++],m=[];for(let x=0;x<p;x++){const y=t.convertUtf8OffsetToUtf16(c[d++]),S=t.convertUtf8OffsetToUtf16(c[d++]);m[x]={start:y,end:S,length:S-y}}return{index:h,captureIndices:m}}}function x6(e){return typeof e.instantiator=="function"}function y6(e){return typeof e.default=="function"}function b6(e){return typeof e.data<"u"}function v6(e){return typeof Response<"u"&&e instanceof Response}function _6(e){var t;return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&((t=Buffer.isBuffer)==null?void 0:t.call(Buffer,e))||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}let wd;function Iy(e){if(wd)return wd;async function t(){Dn=await h6(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),x6(r)?r=await r.instantiator(n):y6(r)?r=await r.default(n):(b6(r)&&(r=r.data),v6(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await S6(r)(n):r=await w6(r)(n):_6(r)?r=await hg(r)(n):r instanceof WebAssembly.Module?r=await hg(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await hg(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return wd=t(),wd}function hg(e){return t=>WebAssembly.instantiate(e,t)}function S6(e){return t=>WebAssembly.instantiateStreaming(e,t)}function w6(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let fE;function C6(e){fE=e}function k6(){return fE}async function mE(e){return e&&await Iy(e),{createScanner(t){return new g6(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new hE(t)}}}const j6=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:mE,getDefaultWasmLoader:k6,loadWasm:Iy,setDefaultWasmLoader:C6},Symbol.toStringTag,{value:"Module"}));var pE=Ty({});dE(pE,j6);var Qt=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function E6(e){return My(e)}function My(e){return Array.isArray(e)?N6(e):e instanceof RegExp?e:typeof e=="object"?T6(e):e}function N6(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=My(e[n]);return t}function T6(e){let t={};for(let n in e)t[n]=My(e[n]);return t}function gE(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function xE(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?xE(e.substring(0,e.length-1)):e.substr(~t+1)}var fg=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Cd=class{static hasCaptures(e){return e===null?!1:(fg.lastIndex=0,fg.test(e))}static replaceCaptures(e,t,n){return e.replace(fg,(r,a,l,u)=>{let c=n[parseInt(a||l,10)];if(c){let d=t.substring(c.start,c.end);for(;d[0]===".";)d=d.substring(1);switch(u){case"downcase":return d.toLowerCase();case"upcase":return d.toUpperCase();default:return d}}else return r})}};function yE(e,t){return e<t?-1:e>t?1:0}function bE(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let a=0;a<n;a++){let l=yE(e[a],t[a]);if(l!==0)return l}return 0}return n-r}function G1(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function vE(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var _E=class{constructor(e){Ne(this,"cache",new Map);this.fn=e}get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},fh=class{constructor(e,t,n){Ne(this,"_cachedMatchRoot",new _E(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(D6(e),t)}static createFromParsedTheme(e,t){return O6(e,t)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,r=this._cachedMatchRoot.get(t).find(a=>A6(e.parent,a.parentScopes));return r?new SE(r.fontStyle,r.foreground,r.background):null}},mg=class Xd{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new Xd(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Xd(n,t[r]);return n}push(t){return new Xd(this,t)}getSegments(){let t=this;const n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function A6(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],a=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],a=!0}for(;e&&!L6(e.scopeName,r);){if(a)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function L6(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var SE=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function D6(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let a=0,l=t.length;a<l;a++){let u=t[a];if(!u.settings)continue;let c;if(typeof u.scope=="string"){let m=u.scope;m=m.replace(/^[,]+/,""),m=m.replace(/[,]+$/,""),c=m.split(",")}else Array.isArray(u.scope)?c=u.scope:c=[""];let d=-1;if(typeof u.settings.fontStyle=="string"){d=0;let m=u.settings.fontStyle.split(" ");for(let x=0,y=m.length;x<y;x++)switch(m[x]){case"italic":d=d|1;break;case"bold":d=d|2;break;case"underline":d=d|4;break;case"strikethrough":d=d|8;break}}let h=null;typeof u.settings.foreground=="string"&&G1(u.settings.foreground)&&(h=u.settings.foreground);let p=null;typeof u.settings.background=="string"&&G1(u.settings.background)&&(p=u.settings.background);for(let m=0,x=c.length;m<x;m++){let S=c[m].trim().split(" "),C=S[S.length-1],v=null;S.length>1&&(v=S.slice(0,S.length-1),v.reverse()),n[r++]=new R6(C,v,a,d,h,p)}}return n}var R6=class{constructor(e,t,n,r,a,l){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=a,this.background=l}},Vn=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(Vn||{});function O6(e,t){e.sort((d,h)=>{let p=yE(d.scope,h.scope);return p!==0||(p=bE(d.parentScopes,h.parentScopes),p!==0)?p:d.index-h.index});let n=0,r="#000000",a="#ffffff";for(;e.length>=1&&e[0].scope==="";){let d=e.shift();d.fontStyle!==-1&&(n=d.fontStyle),d.foreground!==null&&(r=d.foreground),d.background!==null&&(a=d.background)}let l=new I6(t),u=new SE(n,l.getId(r),l.getId(a)),c=new P6(new gx(0,null,-1,0,0),[]);for(let d=0,h=e.length;d<h;d++){let p=e[d];c.insert(0,p.scope,p.parentScopes,p.fontStyle,l.getId(p.foreground),l.getId(p.background))}return new fh(l,u,c)}var I6=class{constructor(e){Ne(this,"_isFrozen");Ne(this,"_lastColorId");Ne(this,"_id2color");Ne(this,"_color2id");if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},M6=Object.freeze([]),gx=class wE{constructor(t,n,r,a,l){Ne(this,"scopeDepth");Ne(this,"parentScopes");Ne(this,"fontStyle");Ne(this,"foreground");Ne(this,"background");this.scopeDepth=t,this.parentScopes=n||M6,this.fontStyle=r,this.foreground=a,this.background=l}clone(){return new wE(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,a=t.length;r<a;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,a){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),a!==0&&(this.background=a)}},P6=class xx{constructor(t,n=[],r={}){Ne(this,"_rulesWithParentScopes");this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,a=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[a]===">"&&a++,!(r>=t.parentScopes.length||a>=n.parentScopes.length);){const l=n.parentScopes[a].length-t.parentScopes[r].length;if(l!==0)return l;r++,a++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),a,l;if(r===-1?(a=t,l=""):(a=t.substring(0,r),l=t.substring(r+1)),this._children.hasOwnProperty(a))return this._children[a].match(l)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(xx._cmpBySpecificity),n}insert(t,n,r,a,l,u){if(n===""){this._doInsertHere(t,r,a,l,u);return}let c=n.indexOf("."),d,h;c===-1?(d=n,h=""):(d=n.substring(0,c),h=n.substring(c+1));let p;this._children.hasOwnProperty(d)?p=this._children[d]:(p=new xx(this._mainRule.clone(),gx.cloneArr(this._rulesWithParentScopes)),this._children[d]=p),p.insert(t+1,h,r,a,l,u)}_doInsertHere(t,n,r,a,l){if(n===null){this._mainRule.acceptOverwrite(t,r,a,l);return}for(let u=0,c=this._rulesWithParentScopes.length;u<c;u++){let d=this._rulesWithParentScopes[u];if(bE(d.parentScopes,n)===0){d.acceptOverwrite(t,r,a,l);return}}r===-1&&(r=this._mainRule.fontStyle),a===0&&(a=this._mainRule.foreground),l===0&&(l=this._mainRule.background),this._rulesWithParentScopes.push(new gx(t,n,r,a,l))}},Da=class Br{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=Br.getLanguageId(t),r=Br.getTokenType(t),a=Br.getFontStyle(t),l=Br.getForeground(t),u=Br.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:a,foreground:l,background:u})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,a,l,u,c){let d=Br.getLanguageId(t),h=Br.getTokenType(t),p=Br.containsBalancedBrackets(t)?1:0,m=Br.getFontStyle(t),x=Br.getForeground(t),y=Br.getBackground(t);return n!==0&&(d=n),r!==8&&(h=r),a!==null&&(p=a?1:0),l!==-1&&(m=l),u!==0&&(x=u),c!==0&&(y=c),(d<<0|h<<8|p<<10|m<<11|x<<15|y<<24)>>>0}};function mh(e,t){const n=[],r=B6(e);let a=r.next();for(;a!==null;){let d=0;if(a.length===2&&a.charAt(1)===":"){switch(a.charAt(0)){case"R":d=1;break;case"L":d=-1;break;default:console.log(`Unknown priority ${a} in scope selector`)}a=r.next()}let h=u();if(n.push({matcher:h,priority:d}),a!==",")break;a=r.next()}return n;function l(){if(a==="-"){a=r.next();const d=l();return h=>!!d&&!d(h)}if(a==="("){a=r.next();const d=c();return a===")"&&(a=r.next()),d}if(q1(a)){const d=[];do d.push(a),a=r.next();while(q1(a));return h=>t(d,h)}return null}function u(){const d=[];let h=l();for(;h;)d.push(h),h=l();return p=>d.every(m=>m(p))}function c(){const d=[];let h=u();for(;h&&(d.push(h),a==="|"||a===",");){do a=r.next();while(a==="|"||a===",");h=u()}return p=>d.some(m=>m(p))}}function q1(e){return!!e&&!!e.match(/[\w\.:]+/)}function B6(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}function CE(e){typeof e.dispose=="function"&&e.dispose()}var Pc=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},$6=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},z6=class{constructor(){Ne(this,"_references",[]);Ne(this,"_seenReferenceKeys",new Set);Ne(this,"visitedRule",new Set)}get references(){return this._references}add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},H6=class{constructor(e,t){Ne(this,"seenFullScopeRequests",new Set);Ne(this,"seenPartialScopeRequests",new Set);Ne(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Pc(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new z6;for(const n of e)F6(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof Pc){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function F6(e,t,n,r){const a=n.lookup(e.scopeName);if(!a){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const l=n.lookup(t);e instanceof Pc?Qd({baseGrammar:l,selfGrammar:a},r):yx(e.ruleName,{baseGrammar:l,selfGrammar:a,repository:a.repository},r);const u=n.injections(e.scopeName);if(u)for(const c of u)r.add(new Pc(c))}function yx(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];ph([r],t,n)}}function Qd(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&ph(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&ph(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function ph(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const a=r.repository?gE({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&ph(r.patterns,{...t,repository:a},n);const l=r.include;if(!l)continue;const u=kE(l);switch(u.kind){case 0:Qd({...t,selfGrammar:t.baseGrammar},n);break;case 1:Qd(t,n);break;case 2:yx(u.ruleName,{...t,repository:a},n);break;case 3:case 4:const c=u.scopeName===t.selfGrammar.scopeName?t.selfGrammar:u.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(c){const d={baseGrammar:t.baseGrammar,selfGrammar:c,repository:a};u.kind===4?yx(u.ruleName,d,n):Qd(d,n)}else u.kind===4?n.add(new $6(u.scopeName,u.ruleName)):n.add(new Pc(u.scopeName));break}}}var U6=class{constructor(){Ne(this,"kind",0)}},V6=class{constructor(){Ne(this,"kind",1)}},W6=class{constructor(e){Ne(this,"kind",2);this.ruleName=e}},G6=class{constructor(e){Ne(this,"kind",3);this.scopeName=e}},q6=class{constructor(e,t){Ne(this,"kind",4);this.scopeName=e,this.ruleName=t}};function kE(e){if(e==="$base")return new U6;if(e==="$self")return new V6;const t=e.indexOf("#");if(t===-1)return new G6(e);if(t===0)return new W6(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new q6(n,r)}}var K6=/\\(\d+)/,K1=/\\(\d+)/g,Y6=-1,jE=-2;var Xc=class{constructor(e,t,n,r){Ne(this,"$location");Ne(this,"id");Ne(this,"_nameIsCapturing");Ne(this,"_name");Ne(this,"_contentNameIsCapturing");Ne(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Cd.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Cd.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${xE(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Cd.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Cd.replaceCaptures(this._contentName,e,t)}},X6=class extends Xc{constructor(t,n,r,a,l){super(t,n,r,a);Ne(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=l}dispose(){}collectPatterns(t,n){throw new Error("Not supported!")}compile(t,n){throw new Error("Not supported!")}compileAG(t,n,r,a){throw new Error("Not supported!")}},Q6=class extends Xc{constructor(t,n,r,a,l){super(t,n,r,null);Ne(this,"_match");Ne(this,"captures");Ne(this,"_cachedCompiledPatterns");this._match=new Bc(a,this.id),this.captures=l,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,n){n.push(this._match)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new $c,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Y1=class extends Xc{constructor(t,n,r,a,l){super(t,n,r,a);Ne(this,"hasMissingPatterns");Ne(this,"patterns");Ne(this,"_cachedCompiledPatterns");this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,n){for(const r of this.patterns)t.getRule(r).collectPatterns(t,n)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new $c,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},bx=class extends Xc{constructor(t,n,r,a,l,u,c,d,h,p){super(t,n,r,a);Ne(this,"_begin");Ne(this,"beginCaptures");Ne(this,"_end");Ne(this,"endHasBackReferences");Ne(this,"endCaptures");Ne(this,"applyEndPatternLast");Ne(this,"hasMissingPatterns");Ne(this,"patterns");Ne(this,"_cachedCompiledPatterns");this._begin=new Bc(l,this.id),this.beginCaptures=u,this._end=new Bc(c||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=d,this.applyEndPatternLast=h||!1,this.patterns=p.patterns,this.hasMissingPatterns=p.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,n){return this._end.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t,n).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t,n).compileAG(t,r,a)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new $c;for(const r of this.patterns)t.getRule(r).collectPatterns(t,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,n):this._cachedCompiledPatterns.setSource(0,n)),this._cachedCompiledPatterns}},gh=class extends Xc{constructor(t,n,r,a,l,u,c,d,h){super(t,n,r,a);Ne(this,"_begin");Ne(this,"beginCaptures");Ne(this,"whileCaptures");Ne(this,"_while");Ne(this,"whileHasBackReferences");Ne(this,"hasMissingPatterns");Ne(this,"patterns");Ne(this,"_cachedCompiledPatterns");Ne(this,"_cachedCompiledWhilePatterns");this._begin=new Bc(l,this.id),this.beginCaptures=u,this.whileCaptures=d,this._while=new Bc(c,jE),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=h.patterns,this.hasMissingPatterns=h.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,n){return this._while.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new $c;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,n){return this._getCachedCompiledWhilePatterns(t,n).compile(t)}compileWhileAG(t,n,r,a){return this._getCachedCompiledWhilePatterns(t,n).compileAG(t,r,a)}_getCachedCompiledWhilePatterns(t,n){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new $c,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||""),this._cachedCompiledWhilePatterns}},EE=class Fn{static createCaptureRule(t,n,r,a,l){return t.registerRule(u=>new X6(n,u,r,a,l))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(a=>{if(t.id=a,t.match)return new Q6(t.$vscodeTextmateLocation,t.id,t.name,t.match,Fn._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=gE({},r,t.repository));let l=t.patterns;return typeof l>"u"&&t.include&&(l=[{include:t.include}]),new Y1(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Fn._compilePatterns(l,n,r))}return t.while?new gh(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Fn._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,Fn._compileCaptures(t.whileCaptures||t.captures,n,r),Fn._compilePatterns(t.patterns,n,r)):new bx(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Fn._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,Fn._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,Fn._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let a=[];if(t){let l=0;for(const u in t){if(u==="$vscodeTextmateLocation")continue;const c=parseInt(u,10);c>l&&(l=c)}for(let u=0;u<=l;u++)a[u]=null;for(const u in t){if(u==="$vscodeTextmateLocation")continue;const c=parseInt(u,10);let d=0;t[u].patterns&&(d=Fn.getCompiledRuleId(t[u],n,r)),a[c]=Fn.createCaptureRule(n,t[u].$vscodeTextmateLocation,t[u].name,t[u].contentName,d)}}return a}static _compilePatterns(t,n,r){let a=[];if(t)for(let l=0,u=t.length;l<u;l++){const c=t[l];let d=-1;if(c.include){const h=kE(c.include);switch(h.kind){case 0:case 1:d=Fn.getCompiledRuleId(r[c.include],n,r);break;case 2:let p=r[h.ruleName];p&&(d=Fn.getCompiledRuleId(p,n,r));break;case 3:case 4:const m=h.scopeName,x=h.kind===4?h.ruleName:null,y=n.getExternalGrammar(m,r);if(y)if(x){let S=y.repository[x];S&&(d=Fn.getCompiledRuleId(S,n,y.repository))}else d=Fn.getCompiledRuleId(y.repository.$self,n,y.repository);break}}else d=Fn.getCompiledRuleId(c,n,r);if(d!==-1){const h=n.getRule(d);let p=!1;if((h instanceof Y1||h instanceof bx||h instanceof gh)&&h.hasMissingPatterns&&h.patterns.length===0&&(p=!0),p)continue;a.push(d)}}return{patterns:a,hasMissingPatterns:(t?t.length:0)!==a.length}}},Bc=class NE{constructor(t,n){Ne(this,"source");Ne(this,"ruleId");Ne(this,"hasAnchor");Ne(this,"hasBackReferences");Ne(this,"_anchorCache");if(t&&typeof t=="string"){const r=t.length;let a=0,l=[],u=!1;for(let c=0;c<r;c++)if(t.charAt(c)==="\\"&&c+1<r){const h=t.charAt(c+1);h==="z"?(l.push(t.substring(a,c)),l.push("$(?!\\n)(?<!\\n)"),a=c+2):(h==="A"||h==="G")&&(u=!0),c++}this.hasAnchor=u,a===0?this.source=t:(l.push(t.substring(a,r)),this.source=l.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=K6.test(this.source):this.hasBackReferences=!1}clone(){return new NE(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(a=>t.substring(a.start,a.end));return K1.lastIndex=0,this.source.replace(K1,(a,l)=>vE(r[parseInt(l,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],a=[],l,u,c,d;for(l=0,u=this.source.length;l<u;l++)c=this.source.charAt(l),t[l]=c,n[l]=c,r[l]=c,a[l]=c,c==="\\"&&l+1<u&&(d=this.source.charAt(l+1),d==="A"?(t[l+1]="",n[l+1]="",r[l+1]="A",a[l+1]="A"):d==="G"?(t[l+1]="",n[l+1]="G",r[l+1]="",a[l+1]="G"):(t[l+1]=d,n[l+1]=d,r[l+1]=d,a[l+1]=d),l++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:a.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},$c=class{constructor(){Ne(this,"_items");Ne(this,"_hasAnchors");Ne(this,"_cached");Ne(this,"_anchorCache");this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new X1(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(a=>a.resolveAnchors(t,n));return new X1(e,r,this._items.map(a=>a.ruleId))}},X1=class{constructor(e,t,n){Ne(this,"scanner");this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
|
|
96
|
+
`)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},pg=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Js,J6=(Js=class{constructor(t,n){Ne(this,"_defaultAttributes");Ne(this,"_embeddedLanguagesMatcher");Ne(this,"_getBasicScopeAttributes",new _E(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new pg(n,r)}));this._defaultAttributes=new pg(t,8),this._embeddedLanguagesMatcher=new Z6(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Js._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(Js.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}},Ne(Js,"_NULL_SCOPE_METADATA",new pg(0,0)),Ne(Js,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),Js),Z6=class{constructor(e){Ne(this,"values");Ne(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>vE(n));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;const t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},Q1=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function TE(e,t,n,r,a,l,u,c){const d=t.content.length;let h=!1,p=-1;if(u){const y=eB(e,t,n,r,a,l);a=y.stack,r=y.linePos,n=y.isFirstLine,p=y.anchorPosition}const m=Date.now();for(;!h;){if(c!==0&&Date.now()-m>c)return new Q1(a,!0);x()}return new Q1(a,!1);function x(){const y=tB(e,t,n,r,a,p);if(!y){l.produce(a,d),h=!0;return}const S=y.captureIndices,C=y.matchedRuleId,v=S&&S.length>0?S[0].end>r:!1;if(C===Y6){const w=a.getRule(e);l.produce(a,S[0].start),a=a.withContentNameScopesList(a.nameScopesList),xc(e,t,n,a,l,w.endCaptures,S),l.produce(a,S[0].end);const _=a;if(a=a.parent,p=_.getAnchorPos(),!v&&_.getEnterPos()===r){a=_,l.produce(a,d),h=!0;return}}else{const w=e.getRule(C);l.produce(a,S[0].start);const _=a,b=w.getName(t.content,S),k=a.contentNameScopesList.pushAttributed(b,e);if(a=a.push(C,r,p,S[0].end===d,null,k,k),w instanceof bx){const E=w;xc(e,t,n,a,l,E.beginCaptures,S),l.produce(a,S[0].end),p=S[0].end;const T=E.getContentName(t.content,S),D=k.pushAttributed(T,e);if(a=a.withContentNameScopesList(D),E.endHasBackReferences&&(a=a.withEndRule(E.getEndWithResolvedBackReferences(t.content,S))),!v&&_.hasSameRuleAs(a)){a=a.pop(),l.produce(a,d),h=!0;return}}else if(w instanceof gh){const E=w;xc(e,t,n,a,l,E.beginCaptures,S),l.produce(a,S[0].end),p=S[0].end;const T=E.getContentName(t.content,S),D=k.pushAttributed(T,e);if(a=a.withContentNameScopesList(D),E.whileHasBackReferences&&(a=a.withEndRule(E.getWhileWithResolvedBackReferences(t.content,S))),!v&&_.hasSameRuleAs(a)){a=a.pop(),l.produce(a,d),h=!0;return}}else if(xc(e,t,n,a,l,w.captures,S),l.produce(a,S[0].end),a=a.pop(),!v){a=a.safePop(),l.produce(a,d),h=!0;return}}S[0].end>r&&(r=S[0].end,n=!1)}}function eB(e,t,n,r,a,l){let u=a.beginRuleCapturedEOL?0:-1;const c=[];for(let d=a;d;d=d.pop()){const h=d.getRule(e);h instanceof gh&&c.push({rule:h,stack:d})}for(let d=c.pop();d;d=c.pop()){const{ruleScanner:h,findOptions:p}=sB(d.rule,e,d.stack.endRule,n,r===u),m=h.findNextMatchSync(t,r,p);if(m){if(m.ruleId!==jE){a=d.stack.pop();break}m.captureIndices&&m.captureIndices.length&&(l.produce(d.stack,m.captureIndices[0].start),xc(e,t,n,d.stack,l,d.rule.whileCaptures,m.captureIndices),l.produce(d.stack,m.captureIndices[0].end),u=m.captureIndices[0].end,m.captureIndices[0].end>r&&(r=m.captureIndices[0].end,n=!1))}else{a=d.stack.pop();break}}return{stack:a,linePos:r,anchorPosition:u,isFirstLine:n}}function tB(e,t,n,r,a,l){const u=nB(e,t,n,r,a,l),c=e.getInjections();if(c.length===0)return u;const d=rB(c,e,t,n,r,a,l);if(!d)return u;if(!u)return d;const h=u.captureIndices[0].start,p=d.captureIndices[0].start;return p<h||d.priorityMatch&&p===h?d:u}function nB(e,t,n,r,a,l){const u=a.getRule(e),{ruleScanner:c,findOptions:d}=AE(u,e,a.endRule,n,r===l),h=c.findNextMatchSync(t,r,d);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function rB(e,t,n,r,a,l,u){let c=Number.MAX_VALUE,d=null,h,p=0;const m=l.contentNameScopesList.getScopeNames();for(let x=0,y=e.length;x<y;x++){const S=e[x];if(!S.matcher(m))continue;const C=t.getRule(S.ruleId),{ruleScanner:v,findOptions:w}=AE(C,t,null,r,a===u),_=v.findNextMatchSync(n,a,w);if(!_)continue;const b=_.captureIndices[0].start;if(!(b>=c)&&(c=b,d=_.captureIndices,h=_.ruleId,p=S.priority,c===a))break}return d?{priorityMatch:p===-1,captureIndices:d,matchedRuleId:h}:null}function AE(e,t,n,r,a){return{ruleScanner:e.compileAG(t,n,r,a),findOptions:0}}function sB(e,t,n,r,a){return{ruleScanner:e.compileWhileAG(t,n,r,a),findOptions:0}}function xc(e,t,n,r,a,l,u){if(l.length===0)return;const c=t.content,d=Math.min(l.length,u.length),h=[],p=u[0].end;for(let m=0;m<d;m++){const x=l[m];if(x===null)continue;const y=u[m];if(y.length===0)continue;if(y.start>p)break;for(;h.length>0&&h[h.length-1].endPos<=y.start;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop();if(h.length>0?a.produceFromScopes(h[h.length-1].scopes,y.start):a.produce(r,y.start),x.retokenizeCapturedWithRuleId){const C=x.getName(c,u),v=r.contentNameScopesList.pushAttributed(C,e),w=x.getContentName(c,u),_=v.pushAttributed(w,e),b=r.push(x.retokenizeCapturedWithRuleId,y.start,-1,!1,null,v,_),k=e.createOnigString(c.substring(0,y.end));TE(e,k,n&&y.start===0,y.start,b,a,!1,0),CE(k);continue}const S=x.getName(c,u);if(S!==null){const v=(h.length>0?h[h.length-1].scopes:r.contentNameScopesList).pushAttributed(S,e);h.push(new iB(v,y.end))}}for(;h.length>0;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var iB=class{constructor(e,t){Ne(this,"scopes");Ne(this,"endPos");this.scopes=e,this.endPos=t}};function aB(e,t,n,r,a,l,u,c){return new lB(e,t,n,r,a,l,u,c)}function J1(e,t,n,r,a){const l=mh(t,xh),u=EE.getCompiledRuleId(n,r,a.repository);for(const c of l)e.push({debugSelector:t,matcher:c.matcher,ruleId:u,grammar:a,priority:c.priority})}function xh(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let a=n;a<t.length;a++)if(oB(t[a],r))return n=a+1,!0;return!1})}function oB(e,t){if(!e)return!1;if(e===t)return!0;const n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]==="."}var lB=class{constructor(e,t,n,r,a,l,u,c){Ne(this,"_rootId");Ne(this,"_lastRuleId");Ne(this,"_ruleId2desc");Ne(this,"_includedGrammars");Ne(this,"_grammarRepository");Ne(this,"_grammar");Ne(this,"_injections");Ne(this,"_basicScopeAttributesProvider");Ne(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=l,this._onigLib=c,this._basicScopeAttributesProvider=new J6(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=u,this._grammar=Z1(t,null),this._injections=null,this._tokenTypeMatchers=[],a)for(const d of Object.keys(a)){const h=mh(d,xh);for(const p of h)this._tokenTypeMatchers.push({matcher:p.matcher,type:a[d]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:a=>a===this._rootScopeName?this._grammar:this.getExternalGrammar(a),injections:a=>this._grammarRepository.injections(a)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const a=r.injections;if(a)for(let u in a)J1(t,u,a[u],this,r);const l=this._grammarRepository.injections(n);l&&l.forEach(u=>{const c=this.getExternalGrammar(u);if(c){const d=c.injectionSelector;d&&J1(t,d,c,this,c)}})}return t.sort((a,l)=>a.priority-l.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=Z1(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){const r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){const r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=EE.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let a;if(!t||t===vx.NULL){a=!0;const h=this._basicScopeAttributesProvider.getDefaultAttributes(),p=this.themeProvider.getDefaults(),m=Da.set(0,h.languageId,h.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),x=this.getRule(this._rootId).getName(null,null);let y;x?y=wc.createRootAndLookUpScopeName(x,m,this):y=wc.createRoot("unknown",m),t=new vx(null,this._rootId,-1,-1,!1,null,y,y)}else a=!1,t.reset();e=e+`
|
|
97
|
+
`;const l=this.createOnigString(e),u=l.content.length,c=new uB(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),d=TE(this,l,a,0,t,c,!0,r);return CE(l),{lineLength:u,lineTokens:c,ruleStack:d.stack,stoppedEarly:d.stoppedEarly}}};function Z1(e,t){return e=E6(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var wc=class ps{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,a=(t==null?void 0:t.scopePath)??null;for(const l of n)a=mg.push(a,l.scopeNames),r=new ps(r,a,l.encodedTokenAttributes);return r}static createRoot(t,n){return new ps(null,new mg(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const a=r.getMetadataForScope(t),l=new mg(null,t),u=r.themeProvider.themeMatch(l),c=ps.mergeAttributes(n,a,u);return new ps(null,l,c)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return ps.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let a=-1,l=0,u=0;return r!==null&&(a=r.fontStyle,l=r.foregroundId,u=r.backgroundId),Da.set(t,n.languageId,n.tokenType,null,a,l,u)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return ps._pushAttributed(this,t,n);const r=t.split(/ /g);let a=this;for(const l of r)a=ps._pushAttributed(a,l,n);return a}static _pushAttributed(t,n,r){const a=r.getMetadataForScope(n),l=t.scopePath.push(n),u=r.themeProvider.themeMatch(l),c=ps.mergeAttributes(t.tokenAttributes,a,u);return new ps(t,l,c)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){var a;const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(((a=r.parent)==null?void 0:a.scopePath)??null)}),r=r.parent;return r===t?n.reverse():void 0}},zr,vx=(zr=class{constructor(t,n,r,a,l,u,c,d){Ne(this,"_stackElementBrand");Ne(this,"_enterPos");Ne(this,"_anchorPos");Ne(this,"depth");this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=l,this.endRule=u,this.nameScopesList=c,this.contentNameScopesList=d,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=a}equals(t){return t===null?!1:zr._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?wc.equals(t.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.depth!==n.depth||t.ruleId!==n.ruleId||t.endRule!==n.endRule)return!1;t=t.parent,n=n.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){zr._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,a,l,u,c){return new zr(this,t,n,r,a,l,u,c)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){var r,a;return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${(r=this.nameScopesList)==null?void 0:r.toString()}, ${(a=this.contentNameScopesList)==null?void 0:a.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new zr(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let n=this;for(;n&&n._enterPos===t._enterPos;){if(n.ruleId===t.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){var t,n,r;return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:((n=this.nameScopesList)==null?void 0:n.getExtensionIfDefined(((t=this.parent)==null?void 0:t.nameScopesList)??null))??[],contentNameScopesList:((r=this.contentNameScopesList)==null?void 0:r.getExtensionIfDefined(this.nameScopesList))??[]}}static pushFrame(t,n){const r=wc.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new zr(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,wc.fromExtension(r,n.contentNameScopesList))}},Ne(zr,"NULL",new zr(null,0,0,0,!1,null,null,null)),zr),cB=class{constructor(e,t){Ne(this,"balancedBracketScopes");Ne(this,"unbalancedBracketScopes");Ne(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):mh(n,xh).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>mh(n,xh).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(const t of this.unbalancedBracketScopes)if(t(e))return!1;for(const t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},uB=class{constructor(e,t,n,r){Ne(this,"_emitBinaryTokens");Ne(this,"_lineText");Ne(this,"_tokens");Ne(this,"_binaryTokens");Ne(this,"_lastTokenEndIndex");Ne(this,"_tokenTypeOverrides");this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){var r;if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let a=(e==null?void 0:e.tokenAttributes)??0,l=!1;if((r=this.balancedBracketSelectors)!=null&&r.matchesAlways&&(l=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const u=(e==null?void 0:e.getScopeNames())??[];for(const c of this._tokenTypeOverrides)c.matcher(u)&&(a=Da.set(a,0,c.type,null,-1,0,0));this.balancedBracketSelectors&&(l=this.balancedBracketSelectors.match(u))}if(l&&(a=Da.set(a,0,8,l,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===a){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(a),this._lastTokenEndIndex=t;return}const n=(e==null?void 0:e.getScopeNames())??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,a=this._binaryTokens.length;r<a;r++)n[r]=this._binaryTokens[r];return n}},dB=class{constructor(e,t){Ne(this,"_grammars",new Map);Ne(this,"_rawGrammars",new Map);Ne(this,"_injectionGrammars",new Map);Ne(this,"_theme");this._onigLib=t,this._theme=e}dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,a){if(!this._grammars.has(e)){let l=this._rawGrammars.get(e);if(!l)return null;this._grammars.set(e,aB(e,l,t,n,r,a,this,this._onigLib))}return this._grammars.get(e)}},hB=class{constructor(t){Ne(this,"_options");Ne(this,"_syncRegistry");Ne(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new dB(fh.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(fh.createFromRawTheme(t,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(t,n,r){return this.loadGrammarWithConfiguration(t,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(t,n,r){return this._loadGrammar(t,n,r.embeddedLanguages,r.tokenTypes,new cB(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,a,l){const u=new H6(this._syncRegistry,t);for(;u.Q.length>0;)u.Q.map(c=>this._loadSingleGrammar(c.scopeName)),u.processQueue();return this._grammarForScopeName(t,n,r,a,l)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(t,n=[],r=0,a=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,a)}_grammarForScopeName(t,n=0,r=null,a=null,l=null){return this._syncRegistry.grammarForScopeName(t,n,r,a,l)}},_x=vx.NULL;function yh(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[a,l]of Object.entries((t==null?void 0:t.colorReplacements)||{}))typeof l=="string"?n[a]=l:a===r&&Object.assign(n,l);return n}function Hi(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function fB(e){return Array.isArray(e)?e:[e]}async function LE(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function sf(e){return!e||["plaintext","txt","text","plain"].includes(e)}function DE(e){return e==="ansi"||sf(e)}function af(e){return e==="none"}function RE(e){return af(e)}const mB=/(\r?\n)/g;function of(e,t=!1){var l;if(e.length===0)return[["",0]];const n=e.split(mB);let r=0;const a=[];for(let u=0;u<n.length;u+=2){const c=t?n[u]+(n[u+1]||""):n[u];a.push([c,r]),r+=n[u].length,r+=((l=n[u+1])==null?void 0:l.length)||0}return a}const ew={light:"#333333",dark:"#bbbbbb"},tw={light:"#fffffe",dark:"#1e1e1e"},nw="__shiki_resolved";function Py(e){var c,d,h,p,m;if(e!=null&&e[nw])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||(t.type="dark"),t.colorReplacements={...t.colorReplacements},t.settings||(t.settings=[]);let{bg:n,fg:r}=t;if(!n||!r){const x=t.settings?t.settings.find(y=>!y.name&&!y.scope):void 0;(c=x==null?void 0:x.settings)!=null&&c.foreground&&(r=x.settings.foreground),(d=x==null?void 0:x.settings)!=null&&d.background&&(n=x.settings.background),!r&&((h=t==null?void 0:t.colors)!=null&&h["editor.foreground"])&&(r=t.colors["editor.foreground"]),!n&&((p=t==null?void 0:t.colors)!=null&&p["editor.background"])&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?ew.light:ew.dark),n||(n=t.type==="light"?tw.light:tw.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let a=0;const l=new Map;function u(x){var S;if(l.has(x))return l.get(x);a+=1;const y=`#${a.toString(16).padStart(8,"0").toLowerCase()}`;return(S=t.colorReplacements)!=null&&S[`#${y}`]?u(x):(l.set(x,y),y)}t.settings=t.settings.map(x=>{var v,w;const y=((v=x.settings)==null?void 0:v.foreground)&&!x.settings.foreground.startsWith("#"),S=((w=x.settings)==null?void 0:w.background)&&!x.settings.background.startsWith("#");if(!y&&!S)return x;const C={...x,settings:{...x.settings}};if(y){const _=u(x.settings.foreground);t.colorReplacements[_]=x.settings.foreground,C.settings.foreground=_}if(S){const _=u(x.settings.background);t.colorReplacements[_]=x.settings.background,C.settings.background=_}return C});for(const x of Object.keys(t.colors||{}))if((x==="editor.foreground"||x==="editor.background"||x.startsWith("terminal.ansi"))&&!((m=t.colors[x])!=null&&m.startsWith("#"))){const y=u(t.colors[x]);t.colorReplacements[y]=t.colors[x],t.colors[x]=y}return Object.defineProperty(t,nw,{enumerable:!1,writable:!1,value:!0}),t}async function OE(e){return[...new Set((await Promise.all(e.filter(t=>!DE(t)).map(async t=>await LE(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function IE(e){return(await Promise.all(e.map(async t=>RE(t)?null:Py(await LE(t))))).filter(t=>!!t)}function ME(e,t){if(!t)return e;if(t[e]){const n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new Qt(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var pB=class extends hB{constructor(t,n,r,a={}){super(t);Ne(this,"_resolver");Ne(this,"_themes");Ne(this,"_langs");Ne(this,"_alias");Ne(this,"_resolvedThemes",new Map);Ne(this,"_resolvedGrammars",new Map);Ne(this,"_langMap",new Map);Ne(this,"_langGraph",new Map);Ne(this,"_textmateThemeCache",new WeakMap);Ne(this,"_loadedThemesCache",null);Ne(this,"_loadedLanguagesCache",null);this._resolver=t,this._themes=n,this._langs=r,this._alias=a,this._themes.map(l=>this.loadTheme(l)),this.loadLanguages(this._langs)}getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const n=Py(t);return n.name&&(this._resolvedThemes.set(n.name,n),this._loadedThemesCache=null),n}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let n=this._textmateThemeCache.get(t);n||(n=fh.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=ME(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){var l,u,c,d;if(this.getGrammar(t.name))return;const n=new Set([...this._langMap.values()].filter(h=>{var p;return(p=h.embeddedLangsLazy)==null?void 0:p.includes(t.name)}));this._resolver.addLanguage(t);const r={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const a=this.loadGrammarWithConfiguration(t.scopeName,1,r);if(a.name=t.name,this._resolvedGrammars.set(t.name,a),t.aliases&&t.aliases.forEach(h=>{this._alias[h]=t.name}),this._loadedLanguagesCache=null,n.size)for(const h of n)this._resolvedGrammars.delete(h.name),this._loadedLanguagesCache=null,(u=(l=this._syncRegistry)==null?void 0:l._injectionGrammars)==null||u.delete(h.scopeName),(d=(c=this._syncRegistry)==null?void 0:c._grammars)==null||d.delete(h.scopeName),this.loadLanguage(this._langMap.get(h.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(const a of t)this.resolveEmbeddedLanguages(a);const n=[...this._langGraph.entries()],r=n.filter(([a,l])=>!l);if(r.length){const a=n.filter(([l,u])=>{var c;return u?(c=u.embeddedLanguages||u.embeddedLangs)==null?void 0:c.some(d=>r.map(([h])=>h).includes(d)):!1}).filter(l=>!r.includes(l));throw new Qt(`Missing languages ${r.map(([l])=>`\`${l}\``).join(", ")}, required by ${a.map(([l])=>`\`${l}\``).join(", ")}`)}for(const[a,l]of n)this._resolver.addLanguage(l);for(const[a,l]of n)this.loadLanguage(l)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);const n=t.embeddedLanguages??t.embeddedLangs;if(n)for(const r of n)this._langGraph.set(r,this._langMap.get(r))}},gB=class{constructor(e,t){Ne(this,"_langs",new Map);Ne(this,"_scopeToLang",new Map);Ne(this,"_injections",new Map);Ne(this,"_onigLib");this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let n=[];for(let r=1;r<=t.length;r++){const a=t.slice(0,r).join(".");n=[...n,...this._injections.get(a)||[]]}return n}};let lc=0;function xB(e){lc+=1,e.warnings!==!1&&lc>=10&&lc%10===0&&console.warn(`[Shiki] ${lc} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Qt("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Py),a=new pB(new gB(e.engine,n),r,n,e.langAlias);let l;function u(_){return ME(_,e.langAlias)}function c(_){v();const b=a.getGrammar(typeof _=="string"?_:_.name);if(!b)throw new Qt(`Language \`${_}\` not found, you may need to load it first`);return b}function d(_){if(_==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};v();const b=a.getTheme(_);if(!b)throw new Qt(`Theme \`${_}\` not found, you may need to load it first`);return b}function h(_){v();const b=d(_);return l!==_&&(a.setTheme(b),l=_),{theme:b,colorMap:a.getColorMap()}}function p(){return v(),a.getLoadedThemes()}function m(){return v(),a.getLoadedLanguages()}function x(..._){v(),a.loadLanguages(_.flat(1))}async function y(..._){return x(await OE(_))}function S(..._){v();for(const b of _.flat(1))a.loadTheme(b)}async function C(..._){return v(),S(await IE(_))}function v(){if(t)throw new Qt("Shiki instance has been disposed")}function w(){t||(t=!0,a.dispose(),lc-=1)}return{setTheme:h,getTheme:d,getLanguage:c,getLoadedThemes:p,getLoadedLanguages:m,resolveLangAlias:u,loadLanguage:y,loadLanguageSync:x,loadTheme:C,loadThemeSync:S,dispose:w,[Symbol.dispose]:w}}async function yB(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([IE(e.themes||[]),OE(e.langs||[]),e.engine]);return xB({...e,themes:t,langs:n,engine:r})}const PE=new WeakMap;function lf(e,t){PE.set(e,t)}function zc(e){return PE.get(e)}var cf=class BE{constructor(...t){Ne(this,"_stacks",{});Ne(this,"lang");if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,a]=t;this.lang=r,this._stacks={[a]:n}}}get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new BE(Object.fromEntries(fB(n).map(r=>[r,_x])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return bB(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function bB(e){const t=[],n=new Set;function r(a){var u;if(n.has(a))return;n.add(a);const l=(u=a==null?void 0:a.nameScopesList)==null?void 0:u.scopeName;l&&t.push(l),a.parent&&r(a.parent)}return r(e),t}function vB(e,t){if(!(e instanceof cf))throw new Qt("Invalid grammar state");return e.getInternalStack(t)}const _B=/,/,SB=/ /;function $E(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(sf(e.resolveLangAlias(n.lang||"text"))||af(r))return of(t).map(c=>[{content:c[0],offset:c[1]}]);const{theme:a,colorMap:l}=e.setTheme(r),u=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==u.name)throw new Qt(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${u.name}"`);if(!n.grammarState.themes.includes(a.name))throw new Qt(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return CB(t,u,a,l,n)}function wB(...e){if(e.length===2)return zc(e[1]);const[t,n,r={}]=e,{lang:a="text",theme:l=t.getLoadedThemes()[0]}=r;if(sf(a)||af(l))throw new Qt("Plain language does not have grammar state");if(a==="ansi")throw new Qt("ANSI language does not have grammar state");const{theme:u,colorMap:c}=t.setTheme(l),d=t.getLanguage(a);return new cf(By(n,d,u,c,r).stateStack,d.name,u.name)}function CB(e,t,n,r,a){const l=By(e,t,n,r,a),u=new cf(l.stateStack,t.name,n.name);return lf(l.tokens,u),l.tokens}function By(e,t,n,r,a){const l=yh(n,a),{tokenizeMaxLineLength:u=0,tokenizeTimeLimit:c=500,includeExplanation:d=!1}=a,h=of(e);let p=a.grammarState?vB(a.grammarState,n.name)??_x:a.grammarContextCode!=null?By(a.grammarContextCode,t,n,r,{...a,grammarState:void 0,grammarContextCode:void 0}).stateStack:_x,m=[];const x=[];for(let y=0,S=h.length;y<S;y++){const[C,v]=h[y];if(C===""){m=[],x.push([]);continue}if(u>0&&C.length>=u){m=[],x.push([{content:C,offset:v,color:"",fontStyle:0}]);continue}let w,_,b;d&&d!=="tokenType"&&(w=t.tokenizeLine(C,p,c),_=w.tokens,b=0);const k=t.tokenizeLine2(C,p,c),E=k.tokens.length/2;for(let T=0;T<E;T++){const D=k.tokens[2*T],L=T+1<E?k.tokens[2*T+2]:C.length;if(D===L)continue;const R=k.tokens[2*T+1],M=Hi(r[Da.getForeground(R)],l),W=Da.getFontStyle(R),z={content:C.substring(D,L),offset:v+D,color:M,fontStyle:W};if(d==="tokenType")z.type=Da.getTokenType(R);else if(d){const H=[];if(d!=="scopeName")for(const U of n.settings){let V;switch(typeof U.scope){case"string":V=U.scope.split(_B).map(Z=>Z.trim());break;case"object":V=U.scope;break;default:continue}H.push({settings:U,selectors:V.map(Z=>Z.split(SB))})}z.explanation=[];let I=0;for(;D+I<L;){const U=_[b],V=C.substring(U.startIndex,U.endIndex);I+=V.length,z.explanation.push({content:V,scopes:d==="scopeName"?kB(U.scopes):jB(H,U.scopes)}),b+=1}}m.push(z)}x.push(m),m=[],p=k.ruleStack}return{tokens:x,stateStack:p}}function kB(e){return e.map(t=>({scopeName:t}))}function jB(e,t){const n=[];for(let r=0,a=t.length;r<a;r++){const l=t[r];n[r]={scopeName:l,themeMatches:NB(e,l,t.slice(0,r))}}return n}function rw(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function EB(e,t,n){if(!rw(e.at(-1),t))return!1;let r=e.length-2,a=n.length-1;for(;r>=0&&a>=0;)rw(e[r],n[a])&&(r-=1),a-=1;return r===-1}function NB(e,t,n){const r=[];for(const{selectors:a,settings:l}of e)for(const u of a)if(EB(u,t,n)){r.push(l);break}return r}function zE(e,t,n,r=$E){const a=Object.entries(n.themes).filter(h=>h[1]).map(h=>({color:h[0],theme:h[1]})),l=a.map(h=>{const p=r(e,t,{...n,theme:h.theme});return{tokens:p,state:zc(p),theme:typeof h.theme=="string"?h.theme:h.theme.name}}),u=TB(...l.map(h=>h.tokens)),c=u[0].map((h,p)=>h.map((m,x)=>{const y={content:m.content,variants:{},offset:m.offset};return"includeExplanation"in n&&n.includeExplanation&&(y.explanation=m.explanation),u.forEach((S,C)=>{const{content:v,explanation:w,offset:_,...b}=S[p][x];y.variants[a[C].color]=b}),y})),d=l[0].state?new cf(Object.fromEntries(l.map(h=>{var p;return[h.theme,(p=h.state)==null?void 0:p.getInternalStack(h.theme)]})),l[0].state.lang):void 0;return d&&lf(c,d),c}function TB(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const a=e.map(d=>d[r]),l=t.map(()=>[]);t.forEach((d,h)=>d.push(l[h]));const u=a.map(()=>0),c=a.map(d=>d[0]);for(;c.every(d=>d);){const d=Math.min(...c.map(h=>h.content.length));for(let h=0;h<n;h++){const p=c[h];p.content.length===d?(l[h].push(p),u[h]+=1,c[h]=a[h][u[h]]):(l[h].push({...p,content:p.content.slice(0,d)}),c[h]={...p,content:p.content.slice(d),offset:p.offset+d})}}}return t}const AB=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Qc{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Qc.prototype.normal={};Qc.prototype.property={};Qc.prototype.space=void 0;function HE(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Qc(n,r,t)}function Sx(e){return e.toLowerCase()}class hr{constructor(t,n){this.attribute=n,this.property=t}}hr.prototype.attribute="";hr.prototype.booleanish=!1;hr.prototype.boolean=!1;hr.prototype.commaOrSpaceSeparated=!1;hr.prototype.commaSeparated=!1;hr.prototype.defined=!1;hr.prototype.mustUseProperty=!1;hr.prototype.number=!1;hr.prototype.overloadedBoolean=!1;hr.prototype.property="";hr.prototype.spaceSeparated=!1;hr.prototype.space=void 0;let LB=0;const yt=za(),Cn=za(),wx=za(),Ve=za(),Kt=za(),Ra=za(),Sr=za();function za(){return 2**++LB}const Cx=Object.freeze(Object.defineProperty({__proto__:null,boolean:yt,booleanish:Cn,commaOrSpaceSeparated:Sr,commaSeparated:Ra,number:Ve,overloadedBoolean:wx,spaceSeparated:Kt},Symbol.toStringTag,{value:"Module"})),gg=Object.keys(Cx);class $y extends hr{constructor(t,n,r,a){let l=-1;if(super(t,n),sw(this,"space",a),typeof r=="number")for(;++l<gg.length;){const u=gg[l];sw(this,gg[l],(r&Cx[u])===Cx[u])}}}$y.prototype.defined=!0;function sw(e,t,n){n&&(e[t]=n)}function il(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const l=new $y(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[Sx(r)]=r,n[Sx(l.attribute)]=r}return new Qc(t,n,e.space)}const FE=il({properties:{ariaActiveDescendant:null,ariaAtomic:Cn,ariaAutoComplete:null,ariaBusy:Cn,ariaChecked:Cn,ariaColCount:Ve,ariaColIndex:Ve,ariaColSpan:Ve,ariaControls:Kt,ariaCurrent:null,ariaDescribedBy:Kt,ariaDetails:null,ariaDisabled:Cn,ariaDropEffect:Kt,ariaErrorMessage:null,ariaExpanded:Cn,ariaFlowTo:Kt,ariaGrabbed:Cn,ariaHasPopup:null,ariaHidden:Cn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Kt,ariaLevel:Ve,ariaLive:null,ariaModal:Cn,ariaMultiLine:Cn,ariaMultiSelectable:Cn,ariaOrientation:null,ariaOwns:Kt,ariaPlaceholder:null,ariaPosInSet:Ve,ariaPressed:Cn,ariaReadOnly:Cn,ariaRelevant:null,ariaRequired:Cn,ariaRoleDescription:Kt,ariaRowCount:Ve,ariaRowIndex:Ve,ariaRowSpan:Ve,ariaSelected:Cn,ariaSetSize:Ve,ariaSort:null,ariaValueMax:Ve,ariaValueMin:Ve,ariaValueNow:Ve,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function UE(e,t){return t in e?e[t]:t}function VE(e,t){return UE(e,t.toLowerCase())}const DB=il({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ra,acceptCharset:Kt,accessKey:Kt,action:null,allow:null,allowFullScreen:yt,allowPaymentRequest:yt,allowUserMedia:yt,alpha:yt,alt:null,as:null,async:yt,autoCapitalize:null,autoComplete:Kt,autoFocus:yt,autoPlay:yt,blocking:Kt,capture:null,charSet:null,checked:yt,cite:null,className:Kt,closedBy:null,colorSpace:null,cols:Ve,colSpan:Ve,command:null,commandFor:null,content:null,contentEditable:Cn,controls:yt,controlsList:Kt,coords:Ve|Ra,crossOrigin:null,data:null,dateTime:null,decoding:null,default:yt,defer:yt,dir:null,dirName:null,disabled:yt,download:wx,draggable:Cn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:yt,formTarget:null,headers:Kt,height:Ve,hidden:wx,high:Ve,href:null,hrefLang:null,htmlFor:Kt,httpEquiv:Kt,id:null,imageSizes:null,imageSrcSet:null,inert:yt,inputMode:null,integrity:null,is:null,isMap:yt,itemId:null,itemProp:Kt,itemRef:Kt,itemScope:yt,itemType:Kt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:yt,low:Ve,manifest:null,max:null,maxLength:Ve,media:null,method:null,min:null,minLength:Ve,multiple:yt,muted:yt,name:null,nonce:null,noModule:yt,noValidate:yt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:yt,optimum:Ve,pattern:null,ping:Kt,placeholder:null,playsInline:yt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:yt,referrerPolicy:null,rel:Kt,required:yt,reversed:yt,rows:Ve,rowSpan:Ve,sandbox:Kt,scope:null,scoped:yt,seamless:yt,selected:yt,shadowRootClonable:yt,shadowRootCustomElementRegistry:yt,shadowRootDelegatesFocus:yt,shadowRootMode:null,shadowRootSerializable:yt,shape:null,size:Ve,sizes:null,slot:null,span:Ve,spellCheck:Cn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ve,step:null,style:null,tabIndex:Ve,target:null,title:null,translate:null,type:null,typeMustMatch:yt,useMap:null,value:Cn,width:Ve,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Kt,axis:null,background:null,bgColor:null,border:Ve,borderColor:null,bottomMargin:Ve,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:yt,declare:yt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ve,leftMargin:Ve,link:null,longDesc:null,lowSrc:null,marginHeight:Ve,marginWidth:Ve,noResize:yt,noHref:yt,noShade:yt,noWrap:yt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ve,rules:null,scheme:null,scrolling:Cn,standby:null,summary:null,text:null,topMargin:Ve,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ve,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:yt,disablePictureInPicture:yt,disableRemotePlayback:yt,exportParts:Ra,part:Kt,prefix:null,property:null,results:Ve,security:null,unselectable:null},space:"html",transform:VE}),RB=il({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Sr,accentHeight:Ve,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ve,amplitude:Ve,arabicForm:null,ascent:Ve,attributeName:null,attributeType:null,azimuth:Ve,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ve,by:null,calcMode:null,capHeight:Ve,className:Kt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ve,diffuseConstant:Ve,direction:null,display:null,dur:null,divisor:Ve,dominantBaseline:null,download:yt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ve,enableBackground:null,end:null,event:null,exponent:Ve,externalResourcesRequired:null,fill:null,fillOpacity:Ve,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Ra,g2:Ra,glyphName:Ra,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ve,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ve,horizOriginX:Ve,horizOriginY:Ve,id:null,ideographic:Ve,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ve,k:Ve,k1:Ve,k2:Ve,k3:Ve,k4:Ve,kernelMatrix:Sr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ve,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ve,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ve,overlineThickness:Ve,paintOrder:null,panose1:null,path:null,pathLength:Ve,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Kt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ve,pointsAtY:Ve,pointsAtZ:Ve,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Sr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Sr,rev:Sr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Sr,requiredFeatures:Sr,requiredFonts:Sr,requiredFormats:Sr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ve,specularExponent:Ve,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ve,strikethroughThickness:Ve,string:null,stroke:null,strokeDashArray:Sr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ve,strokeOpacity:Ve,strokeWidth:null,style:null,surfaceScale:Ve,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Sr,tabIndex:Ve,tableValues:null,target:null,targetX:Ve,targetY:Ve,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Sr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ve,underlineThickness:Ve,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ve,values:null,vAlphabetic:Ve,vMathematical:Ve,vectorEffect:null,vHanging:Ve,vIdeographic:Ve,version:null,vertAdvY:Ve,vertOriginX:Ve,vertOriginY:Ve,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ve,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:UE}),WE=il({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),GE=il({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:VE}),qE=il({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),OB=/[A-Z]/g,iw=/-[a-z]/g,IB=/^data[-\w.:]+$/i;function MB(e,t){const n=Sx(t);let r=t,a=hr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&IB.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(iw,BB);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!iw.test(l)){let u=l.replace(OB,PB);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=$y}return new a(r,t)}function PB(e){return"-"+e.toLowerCase()}function BB(e){return e.charAt(1).toUpperCase()}const $B=HE([FE,DB,WE,GE,qE],"html"),KE=HE([FE,RB,WE,GE,qE],"svg"),aw={}.hasOwnProperty;function zB(e,t){const n=t||{};function r(a,...l){let u=r.invalid;const c=r.handlers;if(a&&aw.call(a,e)){const d=String(a[e]);u=aw.call(c,d)?c[d]:r.unknown}if(u)return u.call(this,a,...l)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const HB=/["&'<>`]/g,FB=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,UB=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,VB=/[|\\{}()[\]^$+*?.]/g,ow=new WeakMap;function WB(e,t){if(e=e.replace(t.subset?GB(t.subset):HB,r),t.subset||t.escapeOnly)return e;return e.replace(FB,n).replace(UB,r);function n(a,l,u){return t.format((a.charCodeAt(0)-55296)*1024+a.charCodeAt(1)-56320+65536,u.charCodeAt(l+2),t)}function r(a,l,u){return t.format(a.charCodeAt(0),u.charCodeAt(l+1),t)}}function GB(e){let t=ow.get(e);return t||(t=qB(e),ow.set(e,t)),t}function qB(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(VB,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const KB=/[\dA-Fa-f]/;function YB(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!KB.test(String.fromCharCode(t))?r:r+";"}const XB=/\d/;function QB(e,t,n){const r="&#"+String(e);return n&&t&&!XB.test(String.fromCharCode(t))?r:r+";"}const JB=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],xg={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},ZB=["cent","copy","divide","gt","lt","not","para","times"],YE={}.hasOwnProperty,kx={};let kd;for(kd in xg)YE.call(xg,kd)&&(kx[xg[kd]]=kd);const e8=/[^\dA-Za-z]/;function t8(e,t,n,r){const a=String.fromCharCode(e);if(YE.call(kx,a)){const l=kx[a],u="&"+l;return n&&JB.includes(l)&&!ZB.includes(l)&&(!r||t&&t!==61&&e8.test(String.fromCharCode(t)))?u:u+";"}return""}function n8(e,t,n){let r=YB(e,t,n.omitOptionalSemicolons),a;if((n.useNamedReferences||n.useShortestReferences)&&(a=t8(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!a)&&n.useShortestReferences){const l=QB(e,t,n.omitOptionalSemicolons);l.length<r.length&&(r=l)}return a&&(!n.useShortestReferences||a.length<r.length)?a:r}function Uo(e,t){return WB(e,Object.assign({format:n8},t))}const r8=/^>|^->|<!--|-->|--!>|<!-$/g,s8=[">"],i8=["<",">"];function a8(e,t,n,r){return r.settings.bogusComments?"<?"+Uo(e.value,Object.assign({},r.settings.characterReferences,{subset:s8}))+">":"<!--"+e.value.replace(r8,a)+"-->";function a(l){return Uo(l,Object.assign({},r.settings.characterReferences,{subset:i8}))}}function o8(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function lw(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;a!==-1;)r++,a=n.indexOf(t,a+t.length);return r}function l8(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function c8(e){return e.join(" ").trim()}const u8=/[ \t\n\f\r]/g;function zy(e){return typeof e=="object"?e.type==="text"?cw(e.value):!1:cw(e)}function cw(e){return e.replace(u8,"")===""}const Tn=QE(1),XE=QE(-1),d8=[];function QE(e){return t;function t(n,r,a){const l=n?n.children:d8;let u=(r||0)+e,c=l[u];if(!a)for(;c&&zy(c);)u+=e,c=l[u];return c}}const h8={}.hasOwnProperty;function JE(e){return t;function t(n,r,a){return h8.call(e,n.tagName)&&e[n.tagName](n,r,a)}}const Hy=JE({body:m8,caption:yg,colgroup:yg,dd:y8,dt:x8,head:yg,html:f8,li:g8,optgroup:b8,option:v8,p:p8,rp:uw,rt:uw,tbody:S8,td:dw,tfoot:w8,th:dw,thead:_8,tr:C8});function yg(e,t,n){const r=Tn(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&zy(r.value.charAt(0)))}function f8(e,t,n){const r=Tn(n,t);return!r||r.type!=="comment"}function m8(e,t,n){const r=Tn(n,t);return!r||r.type!=="comment"}function p8(e,t,n){const r=Tn(n,t);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function g8(e,t,n){const r=Tn(n,t);return!r||r.type==="element"&&r.tagName==="li"}function x8(e,t,n){const r=Tn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function y8(e,t,n){const r=Tn(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function uw(e,t,n){const r=Tn(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function b8(e,t,n){const r=Tn(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function v8(e,t,n){const r=Tn(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function _8(e,t,n){const r=Tn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function S8(e,t,n){const r=Tn(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function w8(e,t,n){return!Tn(n,t)}function C8(e,t,n){const r=Tn(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function dw(e,t,n){const r=Tn(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const k8=JE({body:N8,colgroup:T8,head:E8,html:j8,tbody:A8});function j8(e){const t=Tn(e,-1);return!t||t.type!=="comment"}function E8(e){const t=new Set;for(const r of e.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(t.has(r.tagName))return!1;t.add(r.tagName)}const n=e.children[0];return!n||n.type==="element"}function N8(e){const t=Tn(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&zy(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function T8(e,t,n){const r=XE(n,t),a=Tn(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Hy(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="col")}function A8(e,t,n){const r=XE(n,t),a=Tn(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Hy(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="tr")}const jd={name:[[`
|
|
98
|
+
\f\r &/=>`.split(""),`
|
|
99
|
+
\f\r "&'/=>\``.split("")],[`\0
|
|
100
|
+
\f\r "&'/<=>`.split(""),`\0
|
|
101
|
+
\f\r "&'/<=>\``.split("")]],unquoted:[[`
|
|
102
|
+
\f\r &>`.split(""),`\0
|
|
103
|
+
\f\r "&'<=>\``.split("")],[`\0
|
|
104
|
+
\f\r "&'<=>\``.split(""),`\0
|
|
105
|
+
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function L8(e,t,n,r){const a=r.schema,l=a.space==="svg"?!1:r.settings.omitOptionalTags;let u=a.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const c=[];let d;a.space==="html"&&e.tagName==="svg"&&(r.schema=KE);const h=D8(r,e.properties),p=r.all(a.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=a,p&&(u=!1),(h||!l||!k8(e,t,n))&&(c.push("<",e.tagName,h?" "+h:""),u&&(a.space==="svg"||r.settings.closeSelfClosing)&&(d=h.charAt(h.length-1),(!r.settings.tightSelfClosing||d==="/"||d&&d!=='"'&&d!=="'")&&c.push(" "),c.push("/")),c.push(">")),c.push(p),!u&&(!l||!Hy(e,t,n))&&c.push("</"+e.tagName+">"),c.join("")}function D8(e,t){const n=[];let r=-1,a;if(t){for(a in t)if(t[a]!==null&&t[a]!==void 0){const l=R8(e,a,t[a]);l&&n.push(l)}}for(;++r<n.length;){const l=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&l!=='"'&&l!=="'"&&(n[r]+=" ")}return n.join("")}function R8(e,t,n){const r=MB(e.schema,t),a=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,l=e.settings.allowDangerousCharacters?0:1;let u=e.quote,c;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const d=Uo(r.attribute,Object.assign({},e.settings.characterReferences,{subset:jd.name[a][l]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?l8:c8)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?d:(e.settings.preferUnquoted&&(c=Uo(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:jd.unquoted[a][l]}))),c!==n&&(e.settings.quoteSmart&&lw(n,u)>lw(n,e.alternative)&&(u=e.alternative),c=u+Uo(n,Object.assign({},e.settings.characterReferences,{subset:(u==="'"?jd.single:jd.double)[a][l],attribute:!0}))+u),d+(c&&"="+c))}const O8=["<","&"];function ZE(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Uo(e.value,Object.assign({},r.settings.characterReferences,{subset:O8}))}function I8(e,t,n,r){return r.settings.allowDangerousHtml?e.value:ZE(e,t,n,r)}function M8(e,t,n,r){return r.all(e)}const P8=zB("type",{invalid:B8,unknown:$8,handlers:{comment:a8,doctype:o8,element:L8,raw:I8,root:M8,text:ZE}});function B8(e){throw new Error("Expected node, not `"+e+"`")}function $8(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const z8={},H8={},F8=[];function U8(e,t){const n=t||z8,r=n.quote||'"',a=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:V8,all:W8,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||AB,characterReferences:n.characterReferences||H8,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?KE:$B,quote:r,alternative:a}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function V8(e,t,n){return P8(e,t,n,this)}function W8(e){const t=[],n=e&&e.children||F8;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}const hw=/\s+/g;function e2(e,t){var r;if(!t)return e;e.properties||(e.properties={}),(r=e.properties).class||(r.class=[]),typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(hw)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(hw);for(const a of n)a&&!e.properties.class.includes(a)&&e.properties.class.push(a);return e}const G8=/:?lang=["']([^"']+)["']/g,q8=/(?:```|~~~)([\w-]+)/g,K8=/\\begin\{([\w-]+)\}/g,Y8=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function X8(e){const t=of(e,!0).map(([a])=>a);function n(a){if(a===e.length)return{line:t.length-1,character:t.at(-1).length};let l=a,u=0;for(const c of t){if(l<c.length)break;l-=c.length,u++}return{line:u,character:l}}function r(a,l){let u=0;for(let c=0;c<a;c++)u+=t[c].length;return u+=l,u}return{lines:t,indexToPos:n,posToIndex:r}}function Q8(e,t,n){const r=new Set;for(const l of e.matchAll(G8)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(q8)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(K8)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(Y8)){const u=l[1].toLowerCase().trim(),c=u.includes("/")?u.split("/").pop():u;c&&r.add(c)}if(!n)return[...r];const a=n.getBundledLanguages();return[...r].filter(l=>l&&a[l])}const J8=["color","background-color"];function Z8(e,t){let n=0;const r=[];for(const a of t)a>n&&r.push({...e,content:e.content.slice(n,a),offset:e.offset+n}),n=a;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function e$(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((r,a)=>r-a);return n.length?e.map(r=>r.flatMap(a=>{const l=n.filter(u=>a.offset<u&&u<a.offset+a.content.length).map(u=>u-a.offset).sort((u,c)=>u-c);return l.length?Z8(a,l):a})):e}function t$(e,t,n,r,a="css-vars"){const l={content:e.content,explanation:e.explanation,offset:e.offset},u=t.map(p=>bh(e.variants[p])),c=new Set(u.flatMap(p=>Object.keys(p))),d={},h=(p,m)=>{const x=m==="color"?"":m==="background-color"?"-bg":`-${m}`;return n+t[p]+(m==="color"?"":x)};return u.forEach((p,m)=>{for(const x of c){const y=p[x]||"inherit";if(m===0&&r&&J8.includes(x))if(r==="light-dark()"&&u.length>1){const S=t.findIndex(v=>v==="light"),C=t.findIndex(v=>v==="dark");if(S===-1||C===-1)throw new Qt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');d[x]=`light-dark(${u[S][x]||"inherit"}, ${u[C][x]||"inherit"})`,a==="css-vars"&&(d[h(m,x)]=y)}else d[x]=y;else a==="css-vars"&&(d[h(m,x)]=y)}}),l.htmlStyle=d,l}function bh(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&Vn.Italic&&(t["font-style"]="italic"),e.fontStyle&Vn.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&Vn.Underline&&n.push("underline"),e.fontStyle&Vn.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function jx(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function n$(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let l=function(c){if(typeof c=="number"){if(c<0||c>n.source.length)throw new Qt(`Invalid decoration offset: ${c}. Code length: ${n.source.length}`);return{...a.indexToPos(c),offset:c}}else{const d=a.lines[c.line];if(d===void 0)throw new Qt(`Invalid decoration position ${JSON.stringify(c)}. Lines length: ${a.lines.length}`);let h=c.character;if(h<0&&(h=d.length+h),h<0||h>d.length)throw new Qt(`Invalid decoration position ${JSON.stringify(c)}. Line ${c.line} length: ${d.length}`);return{...c,character:h,offset:a.posToIndex(c.line,h)}}};var r=l;const a=X8(n.source),u=(n.options.decorations||[]).map(c=>({...c,start:l(c.start),end:l(c.end)}));r$(u),e.set(n.meta,{decorations:u,converter:a,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){var r;if((r=this.options.decorations)!=null&&r.length)return e$(n,t(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]))},code(n){var p;if(!((p=this.options.decorations)!=null&&p.length))return;const r=t(this),a=[...n.children].filter(m=>m.type==="element"&&m.tagName==="span");if(a.length!==r.converter.lines.length)throw new Qt(`Number of lines in code element (${a.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function l(m,x,y,S){const C=a[m];let v="",w=-1,_=-1;if(x===0&&(w=0),y===0&&(_=0),y===Number.POSITIVE_INFINITY&&(_=C.children.length),w===-1||_===-1)for(let k=0;k<C.children.length;k++)v+=t2(C.children[k]),w===-1&&v.length===x&&(w=k+1),_===-1&&v.length===y&&(_=k+1);if(w===-1)throw new Qt(`Failed to find start index for decoration ${JSON.stringify(S.start)}`);if(_===-1)throw new Qt(`Failed to find end index for decoration ${JSON.stringify(S.end)}`);const b=C.children.slice(w,_);if(!S.alwaysWrap&&b.length===C.children.length)c(C,S,"line");else if(!S.alwaysWrap&&b.length===1&&b[0].type==="element")c(b[0],S,"token");else{const k={type:"element",tagName:"span",properties:{},children:b};c(k,S,"wrapper"),C.children.splice(w,b.length,k)}}function u(m,x){a[m]=c(a[m],x,"line")}function c(m,x,y){var v;const S=x.properties||{},C=x.transform||(w=>w);return m.tagName=x.tagName||"span",m.properties={...m.properties,...S,class:m.properties.class},(v=x.properties)!=null&&v.class&&e2(m,x.properties.class),m=C(m,y)||m,m}const d=[],h=r.decorations.sort((m,x)=>x.start.offset-m.start.offset||m.end.offset-x.end.offset);for(const m of h){const{start:x,end:y}=m;if(x.line===y.line)l(x.line,x.character,y.character,m);else if(x.line<y.line){l(x.line,x.character,Number.POSITIVE_INFINITY,m);for(let S=x.line+1;S<y.line;S++)d.unshift(()=>u(S,m));l(y.line,0,y.character,m)}}d.forEach(m=>m())}}}function r$(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new Qt(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const a=e[r],l=n.start.offset<=a.start.offset&&a.start.offset<n.end.offset,u=n.start.offset<a.end.offset&&a.end.offset<=n.end.offset,c=a.start.offset<=n.start.offset&&n.start.offset<a.end.offset,d=a.start.offset<n.end.offset&&n.end.offset<=a.end.offset;if(l||u||c||d){if(l&&u||c&&d||c&&n.start.offset===n.end.offset||u&&a.start.offset===a.end.offset)continue;throw new Qt(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(a.start)} intersect.`)}}}}function t2(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(t2).join(""):""}const s$=[n$()];function vh(e){const t=i$(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...s$]}function i$(e){const t=[],n=[],r=[];for(const a of e)switch(a.enforce){case"pre":t.push(a);break;case"post":n.push(a);break;default:r.push(a)}return{pre:t,post:n,normal:r}}var Ca=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],bg={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function a$(e,t){const n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){const r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function fw(e){const t=e.shift();if(t==="2"){const n=e.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){const n=e.shift();if(n)return{type:"table",index:Number(n)}}}function o$(e){const t=[];for(;e.length>0;){const n=e.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)bg[r]&&t.push({type:"setDecoration",value:bg[r]});else if(r<=29){const a=bg[r-20];a&&(t.push({type:"resetDecoration",value:a}),a==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:Ca[r-30]}});else if(r===38){const a=fw(e);a&&t.push({type:"setForegroundColor",value:a})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:Ca[r-40]}});else if(r===48){const a=fw(e);a&&t.push({type:"setBackgroundColor",value:a})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:Ca[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Ca[r-100+8]}})}return t}function l$(){let e=null,t=null,n=new Set;return{parse(r){const a=[];let l=0;do{const u=a$(r,l),c=u.sequence?r.substring(l,u.startPosition):r.substring(l);if(c.length>0&&a.push({value:c,foreground:e,background:t,decorations:new Set(n)}),u.sequence){const d=o$(u.sequence);for(const h of d)h.type==="resetAll"?(e=null,t=null,n.clear()):h.type==="resetForegroundColor"?e=null:h.type==="resetBackgroundColor"?t=null:h.type==="resetDecoration"&&n.delete(h.value);for(const h of d)h.type==="setForegroundColor"?e=h.value:h.type==="setBackgroundColor"?t=h.value:h.type==="setDecoration"&&n.add(h.value)}l=u.position}while(l<r.length);return a}}}var c$={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function u$(e=c$){function t(c){return e[c]}function n(c){return`#${c.map(d=>Math.max(0,Math.min(d,255)).toString(16).padStart(2,"0")).join("")}`}let r;function a(){if(r)return r;r=[];for(let h=0;h<Ca.length;h++)r.push(t(Ca[h]));let c=[0,95,135,175,215,255];for(let h=0;h<6;h++)for(let p=0;p<6;p++)for(let m=0;m<6;m++)r.push(n([c[h],c[p],c[m]]));let d=8;for(let h=0;h<24;h++,d+=10)r.push(n([d,d,d]));return r}function l(c){return a()[c]}function u(c){switch(c.type){case"named":return t(c.name);case"rgb":return n(c.rgb);case"table":return l(c.index)}}return{value:u}}const d$=/#([0-9a-f]{3,8})/i,h$=/var\((--[\w-]+-ansi-[\w-]+)\)/,f$={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function m$(e,t,n){const r=yh(e,n),a=of(t),l=u$(Object.fromEntries(Ca.map(c=>{var h;const d=`terminal.ansi${c[0].toUpperCase()}${c.substring(1)}`;return[c,((h=e.colors)==null?void 0:h[d])||f$[c]]}))),u=l$();return a.map(c=>u.parse(c[0]).map(d=>{let h,p;d.decorations.has("reverse")?(h=d.background?l.value(d.background):e.bg,p=d.foreground?l.value(d.foreground):e.fg):(h=d.foreground?l.value(d.foreground):e.fg,p=d.background?l.value(d.background):void 0),h=Hi(h,r),p=Hi(p,r),d.decorations.has("dim")&&(h=p$(h));let m=Vn.None;return d.decorations.has("bold")&&(m|=Vn.Bold),d.decorations.has("italic")&&(m|=Vn.Italic),d.decorations.has("underline")&&(m|=Vn.Underline),d.decorations.has("strikethrough")&&(m|=Vn.Strikethrough),{content:d.value,offset:c[1],color:h,bgColor:p,fontStyle:m}}))}function p$(e){const t=e.match(d$);if(t){const r=t[1];if(r.length===8){const a=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${a}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const a=r[0],l=r[1],u=r[2],c=r[3];return`#${a}${a}${l}${l}${u}${u}${Math.round(Number.parseInt(`${c}${c}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const a=r[0],l=r[1],u=r[2];return`#${a}${a}${l}${l}${u}${u}80`}}}const n=e.match(h$);return n?`var(${n[1]}-dim)`:e}function Ex(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:a=e.getLoadedThemes()[0]}=n;if(!sf(r)&&!af(a)&&r==="ansi"){const{theme:l}=e.setTheme(a);return m$(l,t,n)}return $E(e,t,n)}function _h(e,t,n){let r,a,l,u,c,d;if("themes"in n){const{defaultColor:h="light",cssVariablePrefix:p="--shiki-",colorsRendering:m="css-vars"}=n,x=Object.entries(n.themes).filter(w=>w[1]).map(w=>({color:w[0],theme:w[1]})).sort((w,_)=>w.color===h?-1:_.color===h?1:0);if(x.length===0)throw new Qt("`themes` option must not be empty");const y=zE(e,t,n,Ex);if(d=zc(y),h&&h!=="light-dark()"&&!x.some(w=>w.color===h))throw new Qt(`\`themes\` option must contain the defaultColor key \`${h}\``);const S=x.map(w=>e.getTheme(w.theme)),C=x.map(w=>w.color);l=y.map(w=>w.map(_=>t$(_,C,p,h,m))),d&&lf(l,d);const v=x.map(w=>yh(w.theme,n));a=mw(x,S,v,p,h,"fg",m),r=mw(x,S,v,p,h,"bg",m),u=`shiki-themes ${S.map(w=>w.name).join(" ")}`,c=h?void 0:[a,r].join(";")}else if("theme"in n){const h=yh(n.theme,n);l=Ex(e,t,n);const p=e.getTheme(n.theme);r=Hi(p.bg,h),a=Hi(p.fg,h),u=p.name,d=zc(l)}else throw new Qt("Invalid options, either `theme` or `themes` must be provided");return{tokens:l,fg:a,bg:r,themeName:u,rootStyle:c,grammarState:d}}function mw(e,t,n,r,a,l,u){return e.map((c,d)=>{const h=Hi(t[d][l],n[d])||"inherit",p=`${r+c.color}${l==="bg"?"-bg":""}:${h}`;if(d===0&&a){if(a==="light-dark()"&&e.length>1){const m=e.findIndex(y=>y.color==="light"),x=e.findIndex(y=>y.color==="dark");if(m===-1||x===-1)throw new Qt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Hi(t[m][l],n[m])||"inherit"}, ${Hi(t[x][l],n[x])||"inherit"});${p}`}return h}return u==="css-vars"?p:null}).filter(c=>!!c).join(";")}const n2=/^\s+$/,g$=/^(\s*)(.*?)(\s*)$/;function Sh(e,t,n,r={meta:{},options:n,codeToHast:(a,l)=>Sh(e,a,l),codeToTokens:(a,l)=>_h(e,a,l)}){var S,C;let a=t;for(const v of vh(n))a=((S=v.preprocess)==null?void 0:S.call(r,a,n))||a;let{tokens:l,fg:u,bg:c,themeName:d,rootStyle:h,grammarState:p}=_h(e,a,n);const{mergeWhitespaces:m=!0,mergeSameStyleTokens:x=!1}=n;m===!0?l=y$(l):m==="never"&&(l=b$(l)),x&&(l=v$(l));const y={...r,get source(){return a}};for(const v of vh(n))l=((C=v.tokens)==null?void 0:C.call(y,l))||l;return x$(l,{...n,fg:u,bg:c,themeName:d,rootStyle:n.rootStyle===!1?!1:n.rootStyle??h},y,p)}function x$(e,t,n,r=zc(e)){var C,v,w,_;const a=vh(t),l=[],u={type:"root",children:[]},{structure:c="classic",tabindex:d="0"}=t,h={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?h.style=t.rootStyle:h.style=`background-color:${t.bg};color:${t.fg}`),d!==!1&&d!=null&&(h.tabindex=d.toString());for(const[b,k]of Object.entries(t.meta||{}))b.startsWith("_")||(h[b]=k);let p={type:"element",tagName:"pre",properties:h,children:[],data:t.data},m={type:"element",tagName:"code",properties:{},children:l};const x=[],y={...n,structure:c,addClassToHast:e2,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return u},get pre(){return p},get code(){return m},get lines(){return x}};if(e.forEach((b,k)=>{var D,L;k&&(c==="inline"?u.children.push({type:"element",tagName:"br",properties:{},children:[]}):c==="classic"&&l.push({type:"text",value:`
|
|
106
|
+
`}));let E={type:"element",tagName:"span",properties:{class:"line"},children:[]},T=0;for(const R of b){let M={type:"element",tagName:"span",properties:{...R.htmlAttrs},children:[{type:"text",value:R.content}]};const W=jx(R.htmlStyle||bh(R));W&&(M.properties.style=W);for(const z of a)M=((D=z==null?void 0:z.span)==null?void 0:D.call(y,M,k+1,T,E,R))||M;c==="inline"?u.children.push(M):c==="classic"&&E.children.push(M),T+=R.content.length}if(c==="classic"){for(const R of a)E=((L=R==null?void 0:R.line)==null?void 0:L.call(y,E,k+1))||E;x.push(E),l.push(E)}else c==="inline"&&x.push(E)}),c==="classic"){for(const b of a)m=((C=b==null?void 0:b.code)==null?void 0:C.call(y,m))||m;p.children.push(m);for(const b of a)p=((v=b==null?void 0:b.pre)==null?void 0:v.call(y,p))||p;u.children.push(p)}else if(c==="inline"){const b=[];let k={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const T of u.children)T.type==="element"&&T.tagName==="br"?(b.push(k),k={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(T.type==="element"||T.type==="text")&&k.children.push(T);b.push(k);let E={type:"element",tagName:"code",properties:{},children:b};for(const T of a)E=((w=T==null?void 0:T.code)==null?void 0:w.call(y,E))||E;u.children=[];for(let T=0;T<E.children.length;T++){T>0&&u.children.push({type:"element",tagName:"br",properties:{},children:[]});const D=E.children[T];D.type==="element"&&u.children.push(...D.children)}}let S=u;for(const b of a)S=((_=b==null?void 0:b.root)==null?void 0:_.call(y,S))||S;return r&&lf(S,r),S}function y$(e){return e.map(t=>{const n=[];let r="",a;return t.forEach((l,u)=>{const c=!(l.fontStyle&&(l.fontStyle&Vn.Underline||l.fontStyle&Vn.Strikethrough));c&&n2.test(l.content)&&t[u+1]?(a===void 0&&(a=l.offset),r+=l.content):r?(c?n.push({...l,offset:a,content:r+l.content}):n.push({content:r,offset:a},l),a=void 0,r=""):n.push(l)}),n})}function b$(e){return e.map(t=>t.flatMap(n=>{if(n2.test(n.content))return n;const r=n.content.match(g$);if(!r)return n;const[,a,l,u]=r;if(!a&&!u)return n;const c=[{...n,offset:n.offset+a.length,content:l}];return a&&c.unshift({content:a,offset:n.offset}),u&&c.push({content:u,offset:n.offset+a.length+l.length}),c}))}function v$(e){return e.map(t=>{const n=[];for(const r of t){if(n.length===0){n.push({...r});continue}const a=n.at(-1),l=jx(a.htmlStyle||bh(a)),u=jx(r.htmlStyle||bh(r)),c=a.fontStyle&&(a.fontStyle&Vn.Underline||a.fontStyle&Vn.Strikethrough),d=r.fontStyle&&(r.fontStyle&Vn.Underline||r.fontStyle&Vn.Strikethrough);!c&&!d&&l===u?a.content+=r.content:n.push({...r})}return n})}const _$=U8;function S$(e,t,n){var l;const r={meta:{},options:n,codeToHast:(u,c)=>Sh(e,u,c),codeToTokens:(u,c)=>_h(e,u,c)};let a=_$(Sh(e,t,n,r));for(const u of vh(n))a=((l=u.postprocess)==null?void 0:l.call(r,a,n))||a;return a}async function w$(e){const t=await yB(e);return{getLastGrammarState:(...n)=>wB(t,...n),codeToTokensBase:(n,r)=>Ex(t,n,r),codeToTokensWithThemes:(n,r)=>zE(t,n,r),codeToTokens:(n,r)=>_h(t,n,r),codeToHast:(n,r)=>Sh(t,n,r),codeToHtml:(n,r)=>S$(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function C$(e){const t=e.langs,n=e.themes,r=e.engine;async function a(l){function u(m){var x;if(typeof m=="string"){if(m=((x=l.langAlias)==null?void 0:x[m])||m,DE(m))return[];const y=t[m];if(!y)throw new Qt(`Language \`${m}\` is not included in this bundle. You may want to load it from external source.`);return y}return m}function c(m){if(RE(m))return"none";if(typeof m=="string"){const x=n[m];if(!x)throw new Qt(`Theme \`${m}\` is not included in this bundle. You may want to load it from external source.`);return x}return m}const d=(l.themes??[]).map(m=>c(m)),h=(l.langs??[]).map(m=>u(m)),p=await w$({engine:l.engine??r(),...l,themes:d,langs:h});return{...p,loadLanguage(...m){return p.loadLanguage(...m.map(u))},loadTheme(...m){return p.loadTheme(...m.map(c))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return a}function k$(e){let t;async function n(r={}){if(t){const a=await t;return await Promise.all([a.loadTheme(...r.themes||[]),a.loadLanguage(...r.langs||[])]),a}else{t=e({...r,themes:[],langs:[]});const a=await t;return await Promise.all([a.loadTheme(...r.themes||[]),a.loadLanguage(...r.langs||[])]),a}}return n}function j$(e,t){const n=k$(e);async function r(a,l){var d;const u=await n({langs:[l.lang],themes:"theme"in l?[l.theme]:Object.values(l.themes)}),c=await((d=t==null?void 0:t.guessEmbeddedLanguages)==null?void 0:d.call(t,a,l.lang,u));return c&&await u.loadLanguage(...c),u}return{getSingletonHighlighter(a){return n(a)},async codeToHtml(a,l){return(await r(a,l)).codeToHtml(a,l)},async codeToHast(a,l){return(await r(a,l)).codeToHast(a,l)},async codeToTokens(a,l){return(await r(a,l)).codeToTokens(a,l)},async codeToTokensBase(a,l){return(await r(a,l)).codeToTokensBase(a,l)},async codeToTokensWithThemes(a,l){return(await r(a,l)).codeToTokensWithThemes(a,l)},async getLastGrammarState(a,l){return(await n({langs:[l.lang],themes:[l.theme]})).getLastGrammarState(a,l)}}}var E$=Ty({bundledLanguages:()=>tf,bundledLanguagesAlias:()=>Ly,bundledLanguagesBase:()=>Ay,bundledLanguagesInfo:()=>ef,bundledThemes:()=>Ry,bundledThemesInfo:()=>Dy,codeToHast:()=>s2,codeToHtml:()=>r2,codeToTokens:()=>i2,codeToTokensBase:()=>a2,codeToTokensWithThemes:()=>o2,createHighlighter:()=>uf,getLastGrammarState:()=>c2,getSingletonHighlighter:()=>l2});const uf=C$({langs:tf,themes:Ry,engine:()=>(0,pE.createOnigurumaEngine)(re(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:r2,codeToHast:s2,codeToTokens:i2,codeToTokensBase:a2,codeToTokensWithThemes:o2,getSingletonHighlighter:l2,getLastGrammarState:c2}=j$(uf,{guessEmbeddedLanguages:Q8}),pw=4294967295;var N$=class{constructor(e,t={}){Ne(this,"patterns");Ne(this,"options");Ne(this,"regexps");this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:a}=t;if(!a)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(l=>{if(typeof l!="string")return l;const u=r==null?void 0:r.get(l);if(u){if(u instanceof RegExp)return u;if(n)return null;throw u}try{const c=a(l);return r==null||r.set(l,c),c}catch(c){if(r==null||r.set(l,c),n)return null;throw c}})}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,a=[];function l(u,c,d=0){return{index:u,captureIndices:c.indices.map(h=>h==null?{start:pw,end:pw,length:0}:{start:h[0]+d,end:h[1]+d,length:h[1]-h[0]})}}for(let u=0;u<this.regexps.length;u++){const c=this.regexps[u];if(c)try{c.lastIndex=t;const d=c.exec(r);if(!d)continue;if(d.index===t)return l(u,d,0);a.push([u,d,0])}catch(d){if(this.options.forgiving)continue;throw d}}if(a.length){const u=Math.min(...a.map(c=>c[1].index));for(const[c,d,h]of a)if(d.index===u)return l(c,d,h)}return null}};function al(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function T$(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const Fy=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),Rn=String.raw;function ol(e,t){if(e==null)throw new Error(t??"Value expected");return e}const u2=Rn`\[\^?`,d2=`c.? | C(?:-.?)?|${Rn`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${Rn`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${Rn`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${Rn`o\{[^\}]*\}?`}|${Rn`\d{1,3}`}`,Uy=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Ed=new RegExp(Rn`
|
|
107
|
+
\\ (?:
|
|
108
|
+
${d2}
|
|
109
|
+
| [gk]<[^>]*>?
|
|
110
|
+
| [gk]'[^']*'?
|
|
111
|
+
| .
|
|
112
|
+
)
|
|
113
|
+
| \( (?:
|
|
114
|
+
\? (?:
|
|
115
|
+
[:=!>({]
|
|
116
|
+
| <[=!]
|
|
117
|
+
| <[^>]*>
|
|
118
|
+
| '[^']*'
|
|
119
|
+
| ~\|?
|
|
120
|
+
| #(?:[^)\\]|\\.?)*
|
|
121
|
+
| [^:)]*[:)]
|
|
122
|
+
)?
|
|
123
|
+
| \*[^\)]*\)?
|
|
124
|
+
)?
|
|
125
|
+
| (?:${Uy.source})+
|
|
126
|
+
| ${u2}
|
|
127
|
+
| .
|
|
128
|
+
`.replace(/\s+/g,""),"gsu"),vg=new RegExp(Rn`
|
|
129
|
+
\\ (?:
|
|
130
|
+
${d2}
|
|
131
|
+
| .
|
|
132
|
+
)
|
|
133
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
134
|
+
| ${u2}
|
|
135
|
+
| &&
|
|
136
|
+
| .
|
|
137
|
+
`.replace(/\s+/g,""),"gsu");function A$(e,t={}){const n={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!="string")throw new Error("String expected as pattern");const r=Y$(n.flags),a=[r.extended],l={captureGroup:n.rules.captureGroup,getCurrentModX(){return a.at(-1)},numOpenGroups:0,popModX(){a.pop()},pushModX(m){a.push(m)},replaceCurrentModX(m){a[a.length-1]=m},singleline:n.rules.singleline};let u=[],c;for(Ed.lastIndex=0;c=Ed.exec(e);){const m=L$(l,e,c[0],Ed.lastIndex);m.tokens?u.push(...m.tokens):m.token&&u.push(m.token),m.lastIndex!==void 0&&(Ed.lastIndex=m.lastIndex)}const d=[];let h=0;u.filter(m=>m.type==="GroupOpen").forEach(m=>{m.kind==="capturing"?m.number=++h:m.raw==="("&&d.push(m)}),h||d.forEach((m,x)=>{m.kind="capturing",m.number=x+1});const p=h||d.length;return{tokens:u.map(m=>m.type==="EscapedNumber"?Q$(m,p):m).flat(),flags:r}}function L$(e,t,n,r){const[a,l]=n;if(n==="["||n==="[^"){const u=D$(t,n,r);return{tokens:u.tokens,lastIndex:u.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(l))return{token:gw(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:F$(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:f2(n)}}if(l==="K")return{token:m2("keep",n)};if(l==="N"||l==="R")return{token:ka("newline",n,{negate:l==="N"})};if(l==="O")return{token:ka("any",n)};if(l==="X")return{token:ka("text_segment",n)};const u=h2(n,{inCharClass:!1});return Array.isArray(u)?{tokens:u}:{token:u}}if(a==="("){if(l==="*")return{token:G$(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(t[r]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:W$(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Ro("group",n)};if(n==="(?>")return{token:Ro("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Ro(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Ro("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Ro("absence_repeater",n)}}throw n==="(?("?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:$$(n)}}if(e.getCurrentModX()){if(n==="#"){const u=t.indexOf(`
|
|
138
|
+
`,r);return{lastIndex:u===-1?t.length:u}}if(/^\s$/.test(n)){const u=/\s+/y;return u.lastIndex=r,{lastIndex:u.exec(t)?u.lastIndex:r}}}if(n===".")return{token:ka("dot",n)};if(n==="^"||n==="$"){const u=e.singleline?{"^":Rn`\A`,$:Rn`\Z`}[n]:n;return{token:gw(u,n)}}return n==="|"?{token:O$(n)}:Uy.test(n)?{tokens:J$(n)}:{token:Zs(al(n),n)}}function D$(e,t,n){const r=[xw(t[1]==="^",t)];let a=1,l;for(vg.lastIndex=n;l=vg.exec(e);){const u=l[0];if(u[0]==="["&&u[1]!==":")a++,r.push(xw(u[1]==="^",u));else if(u==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(Zs(93,u));else if(a--,r.push(I$(u)),!a)break}else{const c=R$(u);Array.isArray(c)?r.push(...c):r.push(c)}}return{tokens:r,lastIndex:vg.lastIndex||e.length}}function R$(e){if(e[0]==="\\")return h2(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Fy.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return ka("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?M$(e):e==="&&"?P$(e):Zs(al(e),e)}function h2(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return V$(e);if("dDhHsSwW".includes(n))return q$(e);if(e.startsWith(Rn`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return K$(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const r=e.split(/\\x/).slice(1).map(u=>parseInt(u,16)),a=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),l=new TextEncoder;return[...a].map(u=>{const c=[...l.encode(u)].map(d=>`\\x${d.toString(16)}`).join("");return Zs(al(u),c)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return Zs(X$(e),e);if(yw.has(n))return Zs(yw.get(n),e);if(/\d/.test(n))return B$(t,e);if(e==="\\")throw new Error(Rn`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return Zs(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function O$(e){return{type:"Alternator",raw:e}}function gw(e,t){return{type:"Assertion",kind:e,raw:t}}function f2(e){return{type:"Backreference",raw:e}}function Zs(e,t){return{type:"Character",value:e,raw:t}}function I$(e){return{type:"CharacterClassClose",raw:e}}function M$(e){return{type:"CharacterClassHyphen",raw:e}}function P$(e){return{type:"CharacterClassIntersector",raw:e}}function xw(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function ka(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function m2(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:ol(n.flags),raw:t}}function B$(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function $$(e){return{type:"GroupClose",raw:e}}function Ro(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function z$(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function H$(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function F$(e){return{type:"Subroutine",raw:e}}const U$=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),yw=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function V$(e){const t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return Zs(al(t.toUpperCase())-64,e)}function W$(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??(r="");const a=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),l=vw(n),u=vw(r),c={};if(l&&(c.enable=l),u&&(c.disable=u),e.endsWith(")"))return t.replaceCurrentModX(a),m2("flags",e,{flags:c});if(e.endsWith(":"))return t.pushModX(a),t.numOpenGroups++,Ro("group",e,{...(l||u)&&{flags:c}});throw new Error(`Unexpected flag modifier "${e}"`)}function G$(e){const t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:n,tag:r,args:a}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const l=a?a.split(",").filter(p=>p!=="").map(p=>/^[+-]?\d+$/.test(p)?+p:p):[],[u,c,d]=l,h=U$.has(n)?n.toLowerCase():"custom";switch(h){case"fail":case"mismatch":case"skip":if(l.length>0)throw new Error(`Named callout arguments not allowed "${l}"`);break;case"error":if(l.length>1)throw new Error(`Named callout allows only one argument "${l}"`);if(typeof u=="string")throw new Error(`Named callout argument must be a number "${u}"`);break;case"max":if(!l.length||l.length>2)throw new Error(`Named callout must have one or two arguments "${l}"`);if(typeof u=="string"&&!/^[A-Za-z_]\w*$/.test(u))throw new Error(`Named callout argument one must be a tag or number "${u}"`);if(l.length===2&&(typeof c=="number"||!/^[<>X]$/.test(c)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${c}"`);break;case"count":case"total_count":if(l.length>1)throw new Error(`Named callout allows only one argument "${l}"`);if(l.length===1&&(typeof u=="number"||!/^[<>X]$/.test(u)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${u}"`);break;case"cmp":if(l.length!==3)throw new Error(`Named callout must have three arguments "${l}"`);if(typeof u=="string"&&!/^[A-Za-z_]\w*$/.test(u))throw new Error(`Named callout argument one must be a tag or number "${u}"`);if(typeof c=="number"||!/^(?:[<>!=]=|[<>])$/.test(c))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${c}"`);if(typeof d=="string"&&!/^[A-Za-z_]\w*$/.test(d))throw new Error(`Named callout argument three must be a tag or number "${d}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${h}"`)}return z$(h,r??null,(a==null?void 0:a.split(","))??null,e)}function bw(e){let t=null,n,r;if(e[0]==="{"){const{minStr:a,maxStr:l}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,u=1e5;if(+a>u||l&&+l>u)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+a,r=l===void 0?+a:l===""?1/0:+l,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return H$(t,n,r,e)}function q$(e){const t=e[1].toLowerCase();return ka({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function K$(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return ka("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function vw(e){const t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function Y$(e){const t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){const r=e[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if(r==="y"){if(!/^y{[gw]}/.test(e.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[n+2]==="g"?"grapheme":"word",n+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0}return t}function X$(e){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const t=e[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function Q$(e,t){const{raw:n,inCharClass:r}=e,a=n.slice(1);if(!r&&(a!=="0"&&a.length===1||a[0]!=="0"&&+a<=t))return[f2(n)];const l=[],u=a.match(/^[0-7]+|\d/g);for(let c=0;c<u.length;c++){const d=u[c];let h;if(c===0&&d!=="8"&&d!=="9"){if(h=parseInt(d,8),h>127)throw new Error(Rn`Octal encoded byte above 177 unsupported "${n}"`)}else h=al(d);l.push(Zs(h,(c===0?"\\":"")+d))}return l}function J$(e){const t=[],n=new RegExp(Uy,"gy");let r;for(;r=n.exec(e);){const a=r[0];if(a[0]==="{"){const l=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(a);if(l){const{min:u,max:c}=l.groups;if(+u>+c&&a.endsWith("?")){n.lastIndex--,t.push(bw(a.slice(0,-1)));continue}}}t.push(bw(a))}return t}function p2(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;const n=e.body[0];return!t||Object.keys(t).every(r=>t[r]===n[r])}function Z$(e){return ez.has(e.type)}const ez=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function g2(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=A$(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),a=(x,y)=>{const S=r.tokens[l.nextIndex];switch(l.parent=x,l.nextIndex++,S.type){case"Alternator":return Ma();case"Assertion":return tz(S);case"Backreference":return nz(S,l);case"Character":return df(S.value,{useLastValid:!!y.isCheckingRangeEnd});case"CharacterClassHyphen":return rz(S,l,y);case"CharacterClassOpen":return sz(S,l,y);case"CharacterSet":return iz(S,l);case"Directive":return dz(S.kind,{flags:S.flags});case"GroupOpen":return az(S,l,y);case"NamedCallout":return fz(S.kind,S.tag,S.arguments);case"Quantifier":return oz(S,l);case"Subroutine":return lz(S,l);default:throw new Error(`Unexpected token type "${S.type}"`)}},l={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:a},u=pz(hz(r.flags));let c=u.body[0];for(;l.nextIndex<r.tokens.length;){const x=a(c,{});x.type==="Alternative"?(u.body.push(x),c=x):c.body.push(x)}const{capturingGroups:d,hasNumberedRef:h,namedGroupsByName:p,subroutines:m}=l;if(h&&p.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:x}of m)if(typeof x=="number"){if(x>d.length)throw new Error("Subroutine uses a group number that's not defined");x&&(d[x-1].isSubroutined=!0)}else if(p.has(x)){if(p.get(x).length>1)throw new Error(Rn`Subroutine uses a duplicate group name "\g<${x}>"`);p.get(x)[0].isSubroutined=!0}else throw new Error(Rn`Subroutine uses a group name that's not defined "\g<${x}>"`);return u}function tz({kind:e}){return Nx(ol({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===Rn`\B`||e===Rn`\Y`})}function nz({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),a=(l,u=!1)=>{const c=t.capturingGroups.length;let d=!1;if(l>c)if(t.skipBackrefValidation)d=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Tx(u?c+1-l:l,{orphan:d})};if(n){const l=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(l)return a(+l.groups.num,!!l.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return Tx(r)}return a(+r)}function rz(e,t,n){const{tokens:r,walk:a}=t,l=t.parent,u=l.body.at(-1),c=r[t.nextIndex];if(!n.isCheckingRangeEnd&&u&&u.type!=="CharacterClass"&&u.type!=="CharacterClassRange"&&c&&c.type!=="CharacterClassOpen"&&c.type!=="CharacterClassClose"&&c.type!=="CharacterClassIntersector"){const d=a(l,{...n,isCheckingRangeEnd:!0});if(u.type==="Character"&&d.type==="Character")return l.body.pop(),uz(u,d);throw new Error("Invalid character class range")}return df(al("-"))}function sz({negate:e},t,n){const{tokens:r,walk:a}=t,l=[Jd()],u=r[t.nextIndex];let c=ww(u);for(;c.type!=="CharacterClassClose";){if(c.type==="CharacterClassIntersector")l.push(Jd()),t.nextIndex++;else{const h=l.at(-1);h.body.push(a(h,n))}c=ww(r[t.nextIndex],u)}const d=Jd({negate:e});return l.length===1?d.body=l[0].body:(d.kind="intersection",d.body=l.map(h=>h.body.length===1?h.body[0]:h)),t.nextIndex++,d}function iz({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u}=r;if(e==="property"){const c=hf(n);if(Fy.has(c)&&!(u!=null&&u.has(c)))e="posix",n=c;else return Oo(n,{negate:t,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u})}return e==="posix"?mz(n,{negate:t}):Ax(e,{negate:t})}function az(e,t,n){const{tokens:r,capturingGroups:a,namedGroupsByName:l,skipLookbehindValidation:u,walk:c}=t,d=gz(e),h=d.type==="AbsenceFunction",p=Sw(d),m=p&&d.negate;if(d.type==="CapturingGroup"&&(a.push(d),d.name&&T$(l,d.name,[]).push(d)),h&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let x=Cw(r[t.nextIndex]);for(;x.type!=="GroupClose";){if(x.type==="Alternator")d.body.push(Ma()),t.nextIndex++;else{const y=d.body.at(-1),S=c(y,{...n,isInAbsenceFunction:n.isInAbsenceFunction||h,isInLookbehind:n.isInLookbehind||p,isInNegLookbehind:n.isInNegLookbehind||m});if(y.body.push(S),(p||n.isInLookbehind)&&!u){const C="Lookbehind includes a pattern not allowed by Oniguruma";if(m||n.isInNegLookbehind){if(_w(S)||S.type==="CapturingGroup")throw new Error(C)}else if(_w(S)||Sw(S)&&S.negate)throw new Error(C)}}x=Cw(r[t.nextIndex])}return t.nextIndex++,d}function oz({kind:e,min:t,max:n},r){const a=r.parent,l=a.body.at(-1);if(!l||!Z$(l))throw new Error("Quantifier requires a repeatable token");const u=y2(e,t,n,l);return a.body.pop(),u}function lz({raw:e},t){const{capturingGroups:n,subroutines:r}=t;let a=e.slice(3,-1);const l=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(a);if(l){const c=+l.groups.num,d=n.length;if(t.hasNumberedRef=!0,a={"":c,"+":d+c,"-":d+1-c}[l.groups.sign],a<1)throw new Error("Invalid subroutine number")}else a==="0"&&(a=0);const u=b2(a);return r.push(u),u}function cz(e,t){return{type:"AbsenceFunction",kind:e,body:Jc(t==null?void 0:t.body)}}function Ma(e){return{type:"Alternative",body:v2(e==null?void 0:e.body)}}function Nx(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function Tx(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function x2(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!xz(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:Jc(t==null?void 0:t.body)}}function df(e,t){const n={useLastValid:!1,...t};if(e>1114111){const r=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${r}}"`):new Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:e}}function Jd(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:v2(e==null?void 0:e.body)}}function uz(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Ax(e,t){const n=!!(t!=null&&t.negate),r={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(r.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(r.variableLength=!0),r}function dz(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:ol(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function hz(e){return{type:"Flags",...e}}function es(e){const t=e==null?void 0:e.atomic,n=e==null?void 0:e.flags;if(t&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...n&&{flags:n},body:Jc(e==null?void 0:e.body)}}function wa(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:Jc(e==null?void 0:e.body)}}function fz(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function mz(e,t){const n=!!(t!=null&&t.negate);if(!Fy.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function y2(e,t,n,r){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:r}}function pz(e,t){return{type:"Regex",body:Jc(t==null?void 0:t.body),flags:e}}function b2(e){return{type:"Subroutine",ref:e}}function Oo(e,t){var a;const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let r=(a=n.unicodePropertyMap)==null?void 0:a.get(hf(e));if(!r){if(n.normalizeUnknownPropertyNames)r=yz(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(Rn`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function gz({flags:e,kind:t,name:n,negate:r,number:a}){switch(t){case"absence_repeater":return cz("repeater");case"atomic":return es({atomic:!0});case"capturing":return x2(a,{name:n});case"group":return es({flags:e});case"lookahead":case"lookbehind":return wa({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function Jc(e){if(e===void 0)e=[Ma()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function v2(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(t=>!!t.type))throw new Error("Invalid body; expected array of nodes");return e}function _w(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function Sw(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function xz(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function yz(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,t=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function hf(e){return e.replace(/[- _]+/g,"").toLowerCase()}function ww(e,t){const n=t;return ol(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function Cw(e){return ol(e,"Unclosed group")}function Cc(e,t,n=null){function r(l,u){for(let c=0;c<l.length;c++){const d=a(l[c],u,c,l);c=Math.max(-1,c+d)}}function a(l,u=null,c=null,d=null){var w,_;let h=0,p=!1;const m={node:l,parent:u,key:c,container:d,root:e,remove(){Nd(d).splice(Math.max(0,jo(c)+h),1),h--,p=!0},removeAllNextSiblings(){return Nd(d).splice(jo(c)+1)},removeAllPrevSiblings(){const b=jo(c)+h;return h-=b,Nd(d).splice(0,Math.max(0,b))},replaceWith(b,k={}){const E=!!k.traverse;d?d[Math.max(0,jo(c)+h)]=b:ol(u,"Can't replace root node")[c]=b,E&&a(b,u,c,d),p=!0},replaceWithMultiple(b,k={}){const E=!!k.traverse;if(Nd(d).splice(Math.max(0,jo(c)+h),1,...b),h+=b.length-1,E){let T=0;for(let D=0;D<b.length;D++)T+=a(b[D],u,jo(c)+D+T,d)}p=!0},skip(){p=!0}},{type:x}=l,y=t["*"],S=t[x],C=typeof y=="function"?y:y==null?void 0:y.enter,v=typeof S=="function"?S:S==null?void 0:S.enter;if(C==null||C(m,n),v==null||v(m,n),!p)switch(x){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(l.body,l);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":a(l.min,l,"min"),a(l.max,l,"max");break;case"Quantifier":a(l.body,l,"body");break;case"Regex":r(l.body,l),a(l.flags,l,"flags");break;default:throw new Error(`Unexpected node type "${x}"`)}return(w=S==null?void 0:S.exit)==null||w.call(S,m,n),(_=y==null?void 0:y.exit)==null||_.call(y,m,n),h}return a(e),e}function Nd(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function jo(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const bz=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function vz(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function _z(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const Ur=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Vy(e,t,n,r){const a=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),l=[!1];let u=0,c="";for(const d of e.matchAll(a)){const{0:h,groups:{$skip:p}}=d;if(!p&&(!r||r===Ur.DEFAULT==!u)){n instanceof Function?c+=n(d,{context:u?Ur.CHAR_CLASS:Ur.DEFAULT,negated:l[l.length-1]}):c+=n;continue}h[0]==="["?(u++,l.push(h[1]==="^")):h==="]"&&u&&(u--,l.pop()),c+=h}return c}function _2(e,t,n,r){Vy(e,t,n,r)}function Sz(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;const a=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");a.lastIndex=n;let l=0,u;for(;u=a.exec(e);){const{0:c,groups:{$skip:d}}=u;if(!d&&(!r||r===Ur.DEFAULT==!l))return u;c==="["?l++:c==="]"&&l&&l--,a.lastIndex==u.index&&a.lastIndex++}return null}function Td(e,t,n){return!!Sz(e,t,0,n)}function wz(e,t){const n=/\\?./gsu;n.lastIndex=t;let r=e.length,a=0,l=1,u;for(;u=n.exec(e);){const[c]=u;if(c==="[")a++;else if(a)c==="]"&&a--;else if(c==="(")l++;else if(c===")"&&(l--,!l)){r=u.index;break}}return e.slice(t,r)}const kw=new RegExp(String.raw`(?<noncapturingStart>${bz})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function Cz(e,t){const n=(t==null?void 0:t.hiddenCaptures)??[];let r=(t==null?void 0:t.captureTransfers)??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};const a="(?>",l="(?:(?=(",u=[0],c=[];let d=0,h=0,p=NaN,m;do{m=!1;let x=0,y=0,S=!1,C;for(kw.lastIndex=Number.isNaN(p)?0:p+l.length;C=kw.exec(e);){const{0:v,index:w,groups:{capturingStart:_,noncapturingStart:b}}=C;if(v==="[")x++;else if(x)v==="]"&&x--;else if(v===a&&!S)p=w,S=!0;else if(S&&b)y++;else if(_)S?y++:(d++,u.push(d+h));else if(v===")"&&S){if(!y){h++;const k=d+h;if(e=`${e.slice(0,p)}${l}${e.slice(p+a.length,w)}))<$$${k}>)${e.slice(w+1)}`,m=!0,c.push(k),vz(n,k),r.size){const E=new Map;r.forEach((T,D)=>{E.set(D>=k?D+1:D,T.map(L=>L>=k?L+1:L))}),r=E}break}y--}}}while(m);return n.push(...c),e=Vy(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:x,groups:{backrefNum:y,wrappedBackrefNum:S}})=>{if(y){const C=+y;if(C>u.length-1)throw new Error(`Backref "${x}" greater than number of captures`);return`\\${u[C]}`}return`\\${S}`},Ur.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const S2=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,_g=new RegExp(String.raw`
|
|
139
|
+
\\(?: \d+
|
|
140
|
+
| c[A-Za-z]
|
|
141
|
+
| [gk]<[^>]+>
|
|
142
|
+
| [pPu]\{[^\}]+\}
|
|
143
|
+
| u[A-Fa-f\d]{4}
|
|
144
|
+
| x[A-Fa-f\d]{2}
|
|
145
|
+
)
|
|
146
|
+
| \((?: \? (?: [:=!>]
|
|
147
|
+
| <(?:[=!]|[^>]+>)
|
|
148
|
+
| [A-Za-z\-]+:
|
|
149
|
+
| \(DEFINE\)
|
|
150
|
+
))?
|
|
151
|
+
| (?<qBase>${S2})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
152
|
+
| \\?.
|
|
153
|
+
`.replace(/\s+/g,""),"gsu");function kz(e){if(!new RegExp(`${S2}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,a="",l=0,u;for(_g.lastIndex=0;u=_g.exec(e);){const{0:c,index:d,groups:{qBase:h,qMod:p,invalidQ:m}}=u;if(c==="[")l||(r=d),l++;else if(c==="]")l?l--:r=null;else if(!l)if(p==="+"&&a&&!a.startsWith("(")){if(m)throw new Error(`Invalid quantifier "${c}"`);let x=-1;if(/^\{\d+\}$/.test(h))e=_z(e,d+h.length,p,"");else{if(a===")"||a==="]"){const y=a===")"?n:r;if(y===null)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,y)}(?>${e.slice(y,d)}${h})${e.slice(d+c.length)}`}else e=`${e.slice(0,d-a.length)}(?>${a}${h})${e.slice(d+c.length)}`;x+=4}_g.lastIndex+=x}else c[0]==="("?t.push(d):c===")"&&(n=t.length?t.pop():null);a=c}return{pattern:e}}const Hr=String.raw,jz=Hr`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Lx=Hr`\(\?R=(?<rDepth>[^\)]+)\)|${jz}`,ff=Hr`\(\?<(?![=!])(?<captureName>[^>]+)>`,w2=Hr`${ff}|(?<unnamed>\()(?!\?)`,pa=new RegExp(Hr`${ff}|${Lx}|\(\?|\\?.`,"gsu"),Sg="Cannot use multiple overlapping recursions";function Ez(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let a=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(Lx,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if(r==="plugin"&&Td(e,Hr`\(\?\(DEFINE\)`,Ur.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const l=[],u=Td(e,Hr`\\[1-9]`,Ur.DEFAULT),c=new Map,d=[];let h=!1,p=0,m=0,x;for(pa.lastIndex=0;x=pa.exec(e);){const{0:y,groups:{captureName:S,rDepth:C,gRNameOrNum:v,gRDepth:w}}=x;if(y==="[")p++;else if(p)y==="]"&&p--;else if(C){if(jw(C),h)throw new Error(Sg);if(u)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const _=e.slice(0,x.index),b=e.slice(pa.lastIndex);if(Td(b,Lx,Ur.DEFAULT))throw new Error(Sg);const k=+C-1;e=Ew(_,b,k,!1,n,l,m),a=Tw(a,_,k,l.length,0,m);break}else if(v){jw(w);let _=!1;for(const z of d)if(z.name===v||z.num===+v){if(_=!0,z.hasRecursedWithin)throw new Error(Sg);break}if(!_)throw new Error(Hr`Recursive \g cannot be used outside the referenced group "${r==="external"?v:Hr`\g<${v}&R=${w}>`}"`);const b=c.get(v),k=wz(e,b);if(u&&Td(k,Hr`${ff}|\((?!\?)`,Ur.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const E=e.slice(b,x.index),T=k.slice(E.length+y.length),D=l.length,L=+w-1,R=Ew(E,T,L,!0,n,l,m);a=Tw(a,E,L,l.length-D,D,m);const M=e.slice(0,b),W=e.slice(b+k.length);e=`${M}${R}${W}`,pa.lastIndex+=R.length-y.length-E.length-T.length,d.forEach(z=>z.hasRecursedWithin=!0),h=!0}else if(S)m++,c.set(String(m),pa.lastIndex),c.set(S,pa.lastIndex),d.push({num:m,name:S});else if(y[0]==="("){const _=y==="(";_&&(m++,c.set(String(m),pa.lastIndex)),d.push(_?{num:m}:{})}else y===")"&&d.pop()}return n.push(...l),{pattern:e,captureTransfers:a,hiddenCaptures:n}}function jw(e){const t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function Ew(e,t,n,r,a,l,u){const c=new Set;r&&_2(e+t,ff,({groups:{captureName:h}})=>{c.add(h)},Ur.DEFAULT);const d=[n,r?c:null,a,l,u];return`${e}${Nw(`(?:${e}`,"forward",...d)}(?:)${Nw(`${t})`,"backward",...d)}${t}`}function Nw(e,t,n,r,a,l,u){const d=p=>t==="forward"?p+2:n-p+2-1;let h="";for(let p=0;p<n;p++){const m=d(p);h+=Vy(e,Hr`${w2}|\\k<(?<backref>[^>]+)>`,({0:x,groups:{captureName:y,unnamed:S,backref:C}})=>{if(C&&r&&!r.has(C))return x;const v=`_$${m}`;if(S||y){const w=u+l.length+1;return l.push(w),Nz(a,w),S?x:`(?<${y}${v}>`}return Hr`\k<${C}${v}>`},Ur.DEFAULT)}return h}function Nz(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Tw(e,t,n,r,a,l){if(e.size&&r){let u=0;_2(t,w2,()=>u++,Ur.DEFAULT);const c=l-u+a,d=new Map;return e.forEach((h,p)=>{const m=(r-u*n)/n,x=u*n,y=p>c+u?p+r:p,S=[];for(const C of h)if(C<=c)S.push(C);else if(C>c+u+m)S.push(C+r);else if(C<=c+u)for(let v=0;v<=n;v++)S.push(C+u*v);else for(let v=0;v<=n;v++)S.push(C+x+m*v);d.set(y,S)}),d}return e}var Nn=String.fromCodePoint,vt=String.raw,ss={},mf=globalThis.RegExp;ss.flagGroups=(()=>{try{new mf("(?i:)")}catch{return!1}return!0})();ss.unicodeSets=(()=>{try{new mf("[[]]","v")}catch{return!1}return!0})();ss.bugFlagVLiteralHyphenIsRange=ss.unicodeSets?(()=>{try{new mf(vt`[\d\-a]`,"v")}catch{return!0}return!1})():!1;ss.bugNestedClassIgnoresNegation=ss.unicodeSets&&new mf("[[^a]]","v").test("a");function wh(e,{enable:t,disable:n}){return{dotAll:!(n!=null&&n.dotAll)&&!!(t!=null&&t.dotAll||e.dotAll),ignoreCase:!(n!=null&&n.ignoreCase)&&!!(t!=null&&t.ignoreCase||e.ignoreCase)}}function Hc(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function Dx(e,t){return Aw[e]>=Aw[t]}function Tz(e,t){if(e==null)throw new Error(t??"Value expected");return e}var Aw={ES2025:2025,ES2024:2024,ES2018:2018},Az={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function C2(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!Az[e.target])throw new Error(`Unexpected target "${e.target}"`);const t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target==="auto"&&(t.target=ss.flagGroups?"ES2025":ss.unicodeSets?"ES2024":"ES2018"),t}var Lz="[ -\r ]",Dz=new Set([Nn(304),Nn(305)]),Vs=vt`[\p{L}\p{M}\p{N}\p{Pc}]`;function k2(e){if(Dz.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),a=Iz.get(n),l=Rz.get(n),u=Oz.get(n);return[...r].length===1&&t.add(r),u&&t.add(u),a&&t.add(a),t.add(n),l&&t.add(l),[...t]}var Wy=new Map(`C Other
|
|
154
|
+
Cc Control cntrl
|
|
155
|
+
Cf Format
|
|
156
|
+
Cn Unassigned
|
|
157
|
+
Co Private_Use
|
|
158
|
+
Cs Surrogate
|
|
159
|
+
L Letter
|
|
160
|
+
LC Cased_Letter
|
|
161
|
+
Ll Lowercase_Letter
|
|
162
|
+
Lm Modifier_Letter
|
|
163
|
+
Lo Other_Letter
|
|
164
|
+
Lt Titlecase_Letter
|
|
165
|
+
Lu Uppercase_Letter
|
|
166
|
+
M Mark Combining_Mark
|
|
167
|
+
Mc Spacing_Mark
|
|
168
|
+
Me Enclosing_Mark
|
|
169
|
+
Mn Nonspacing_Mark
|
|
170
|
+
N Number
|
|
171
|
+
Nd Decimal_Number digit
|
|
172
|
+
Nl Letter_Number
|
|
173
|
+
No Other_Number
|
|
174
|
+
P Punctuation punct
|
|
175
|
+
Pc Connector_Punctuation
|
|
176
|
+
Pd Dash_Punctuation
|
|
177
|
+
Pe Close_Punctuation
|
|
178
|
+
Pf Final_Punctuation
|
|
179
|
+
Pi Initial_Punctuation
|
|
180
|
+
Po Other_Punctuation
|
|
181
|
+
Ps Open_Punctuation
|
|
182
|
+
S Symbol
|
|
183
|
+
Sc Currency_Symbol
|
|
184
|
+
Sk Modifier_Symbol
|
|
185
|
+
Sm Math_Symbol
|
|
186
|
+
So Other_Symbol
|
|
187
|
+
Z Separator
|
|
188
|
+
Zl Line_Separator
|
|
189
|
+
Zp Paragraph_Separator
|
|
190
|
+
Zs Space_Separator
|
|
191
|
+
ASCII
|
|
192
|
+
ASCII_Hex_Digit AHex
|
|
193
|
+
Alphabetic Alpha
|
|
194
|
+
Any
|
|
195
|
+
Assigned
|
|
196
|
+
Bidi_Control Bidi_C
|
|
197
|
+
Bidi_Mirrored Bidi_M
|
|
198
|
+
Case_Ignorable CI
|
|
199
|
+
Cased
|
|
200
|
+
Changes_When_Casefolded CWCF
|
|
201
|
+
Changes_When_Casemapped CWCM
|
|
202
|
+
Changes_When_Lowercased CWL
|
|
203
|
+
Changes_When_NFKC_Casefolded CWKCF
|
|
204
|
+
Changes_When_Titlecased CWT
|
|
205
|
+
Changes_When_Uppercased CWU
|
|
206
|
+
Dash
|
|
207
|
+
Default_Ignorable_Code_Point DI
|
|
208
|
+
Deprecated Dep
|
|
209
|
+
Diacritic Dia
|
|
210
|
+
Emoji
|
|
211
|
+
Emoji_Component EComp
|
|
212
|
+
Emoji_Modifier EMod
|
|
213
|
+
Emoji_Modifier_Base EBase
|
|
214
|
+
Emoji_Presentation EPres
|
|
215
|
+
Extended_Pictographic ExtPict
|
|
216
|
+
Extender Ext
|
|
217
|
+
Grapheme_Base Gr_Base
|
|
218
|
+
Grapheme_Extend Gr_Ext
|
|
219
|
+
Hex_Digit Hex
|
|
220
|
+
IDS_Binary_Operator IDSB
|
|
221
|
+
IDS_Trinary_Operator IDST
|
|
222
|
+
ID_Continue IDC
|
|
223
|
+
ID_Start IDS
|
|
224
|
+
Ideographic Ideo
|
|
225
|
+
Join_Control Join_C
|
|
226
|
+
Logical_Order_Exception LOE
|
|
227
|
+
Lowercase Lower
|
|
228
|
+
Math
|
|
229
|
+
Noncharacter_Code_Point NChar
|
|
230
|
+
Pattern_Syntax Pat_Syn
|
|
231
|
+
Pattern_White_Space Pat_WS
|
|
232
|
+
Quotation_Mark QMark
|
|
233
|
+
Radical
|
|
234
|
+
Regional_Indicator RI
|
|
235
|
+
Sentence_Terminal STerm
|
|
236
|
+
Soft_Dotted SD
|
|
237
|
+
Terminal_Punctuation Term
|
|
238
|
+
Unified_Ideograph UIdeo
|
|
239
|
+
Uppercase Upper
|
|
240
|
+
Variation_Selector VS
|
|
241
|
+
White_Space space
|
|
242
|
+
XID_Continue XIDC
|
|
243
|
+
XID_Start XIDS`.split(/\s/).map(e=>[hf(e),e])),Rz=new Map([["s",Nn(383)],[Nn(383),"s"]]),Oz=new Map([[Nn(223),Nn(7838)],[Nn(107),Nn(8490)],[Nn(229),Nn(8491)],[Nn(969),Nn(8486)]]),Iz=new Map([Li(453),Li(456),Li(459),Li(498),...wg(8072,8079),...wg(8088,8095),...wg(8104,8111),Li(8124),Li(8140),Li(8188)]),Mz=new Map([["alnum",vt`[\p{Alpha}\p{Nd}]`],["alpha",vt`\p{Alpha}`],["ascii",vt`\p{ASCII}`],["blank",vt`[\p{Zs}\t]`],["cntrl",vt`\p{Cc}`],["digit",vt`\p{Nd}`],["graph",vt`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",vt`\p{Lower}`],["print",vt`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",vt`[\p{P}\p{S}]`],["space",vt`\p{space}`],["upper",vt`\p{Upper}`],["word",vt`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",vt`\p{AHex}`]]);function Pz(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Li(e){const t=Nn(e);return[t.toLowerCase(),t]}function wg(e,t){return Pz(e,t).map(n=>Li(n))}var j2=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function Bz(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};E2(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Dx(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Cc(e,$z,r);const a={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},l={currentFlags:a,prevFlags:null,globalFlags:a,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};Cc(e,zz,l);const u={groupsByName:l.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:l.reffedNodesByReferencer};return Cc(e,Hz,u),e._originMap=l.groupOriginByCopy,e._strategy=r.strategy,e}var $z={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:a}=e;if(a==="repeater"){const l=es();l.body[0].body.push(wa({negate:!0,body:r}),Oo("Any"));const u=es();u.body[0].body.push(y2("greedy",0,1/0,l)),n(xn(u,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){const a=e.body.filter(l=>l.kind==="flags");for(let l=n+1;l<t.body.length;l++){const u=t.body[l];Hc(r,u,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const r=T2(t.get(e));if(r){const a=es({flags:r});a.body[0].body=e.body,e.body=[xn(a,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:a,remove:l,replaceWith:u},c){const{kind:d,negate:h}=e,{asciiWordBoundaries:p,avoidSubclass:m,supportedGNodes:x,wordIsAscii:y}=c;if(d==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${h?"Y":"y"}"`);if(d==="line_end")u(xn(wa({body:[Ma({body:[Nx("string_end")]}),Ma({body:[df(10)]})]}),t));else if(d==="line_start")u(xn(Ws(vt`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(d==="search_start")if(x.has(e))a.flags.sticky=!0,l();else{const S=r[n-1];if(S&&qz(S))u(xn(wa({negate:!0}),t));else{if(m)throw new Error(vt`Uses "\G" in a way that requires a subclass`);u(Di(Nx("string_start"),t)),c.strategy="clip_search"}}else if(!(d==="string_end"||d==="string_start"))if(d==="string_end_newline")u(xn(Ws(vt`(?=\n?\z)`),t));else if(d==="word_boundary"){if(!y&&!p){const S=`(?:(?<=${Vs})(?!${Vs})|(?<!${Vs})(?=${Vs}))`,C=`(?:(?<=${Vs})(?=${Vs})|(?<!${Vs})(?!${Vs}))`;u(xn(Ws(h?C:S),t))}}else throw new Error(`Unexpected assertion kind "${d}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!kg(n)&&(n=Cg(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!kg(r)&&(r=Cg(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if(t.kind==="intersection"){const r=Jd({body:[e]});n(xn(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:a,digitIsAscii:l,spaceIsAscii:u,wordIsAscii:c}){const{kind:d,negate:h,value:p}=e;if(l&&(d==="digit"||p==="digit")){n(Di(Ax("digit",{negate:h}),t));return}if(u&&(d==="space"||p==="space")){n(xn(jg(Ws(Lz),h),t));return}if(c&&(d==="word"||p==="word")){n(Di(Ax("word",{negate:h}),t));return}if(d==="any")n(Di(Oo("Any"),t));else if(d==="digit")n(Di(Oo("Nd",{negate:h}),t));else if(d!=="dot")if(d==="text_segment"){if(r==="strict")throw new Error(vt`Use of "\X" requires non-strict accuracy`);const m="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",x=vt`\p{RI}{2}|${m}(?:\u200D${m})*`;n(xn(Ws(vt`(?>\r\n|${a?vt`\p{RGI_Emoji}`:x}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(d==="hex")n(Di(Oo("AHex",{negate:h}),t));else if(d==="newline")n(xn(Ws(h?`[^
|
|
244
|
+
]`:`(?>\r
|
|
245
|
+
?|[
|
|
246
|
+
\v\f
\u2028\u2029])`),t));else if(d==="posix")if(!a&&(p==="graph"||p==="print")){if(r==="strict")throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);let m={graph:"!-~",print:" -~"}[p];h&&(m=`\0-${Nn(m.codePointAt(0)-1)}${Nn(m.codePointAt(2)+1)}-`),n(xn(Ws(`[${m}]`),t))}else n(xn(jg(Ws(Mz.get(p)),h),t));else if(d==="property")Wy.has(hf(p))||(e.key="sc");else if(d==="space")n(Di(Oo("space",{negate:h}),t));else if(d==="word")n(xn(jg(Ws(Vs),h),t));else throw new Error(`Unexpected character set kind "${d}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:a,removeAllPrevSiblings:l,removeAllNextSiblings:u}){const{kind:c,flags:d}=e;if(c==="flags")if(!d.enable&&!d.disable)r();else{const h=es({flags:d});h.body[0].body=u(),a(xn(h,t),{traverse:!0})}else if(c==="keep"){const h=n.body[0],m=n.body.length===1&&p2(h,{type:"Group"})&&h.body[0].body.length===1?h.body[0]:n;if(t.parent!==m||m.body.length>1)throw new Error(vt`Uses "\K" in a way that's unsupported`);const x=wa({behind:!0});x.body[0].body=l(),a(xn(x,t))}else throw new Error(`Unexpected directive kind "${c}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t!=null&&t.extended&&delete t.extended,n!=null&&n.extended&&delete n.extended,t!=null&&t.dotAll&&(n!=null&&n.dotAll)&&delete t.dotAll,t!=null&&t.ignoreCase&&(n!=null&&n.ignoreCase)&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:r}=e;if(r==="fail")n(xn(wa({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=es();t.body[0].body.push(e.body),e.body=xn(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,a=!1;for(const l of e.body)if(l.body.length===1&&l.body[0].kind==="search_start")l.body.pop();else{const u=L2(l.body);u?(r=!0,Array.isArray(u)?n.push(...u):n.push(u)):a=!0}r&&!a&&n.forEach(l=>t.add(l))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(vt`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!kg(n)&&(n=Cg(n,t),e.ref=n)}},zz={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:a}=e;r||n.set(e,[...t.get(a).map(({node:l})=>l)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:a,groupsByName:l,multiplexCapturesToLeftByRef:u,openRefs:c,reffedNodesByReferencer:d}){const h=a.get(e);if(h&&c.has(e.number)){const m=Di(Lw(e.number),t);d.set(m,c.get(e.number)),n(m);return}c.set(e.number,e),u.set(e.number,[]),e.name&&Hc(u,e.name,[]);const p=u.get(e.name??e.number);for(let m=0;m<p.length;m++){const x=p[m];if(h===x.node||h&&h===x.origin||e===x.origin){p.splice(m,1);break}}if(u.get(e.number).push({node:e,origin:h}),e.name&&u.get(e.name).push({node:e,origin:h}),e.name){const m=Hc(l,e.name,new Map);let x=!1;if(h)x=!0;else for(const y of m.values())if(!y.hasDuplicateNameToRemove){x=!0;break}l.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:x})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=wh(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:a,ref:l}=e;if(a){let p=t;for(;(p=p.parent)&&!(p.type==="CapturingGroup"&&(p.name===l||p.number===l)););r.reffedNodesByReferencer.set(e,p);return}const u=r.subroutineRefMap.get(l),c=l===0,d=c?Lw(0):N2(u,r.groupOriginByCopy,null);let h=d;if(!c){const p=T2(Vz(u,x=>x.type==="Group"&&!!x.flags)),m=p?wh(r.globalFlags,p):r.globalFlags;Fz(m,r.currentFlags)||(h=es({flags:Wz(m)}),h.body[0].body.push(d))}n(xn(h,t),{traverse:!c})}},Hz={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const l=r.reffedNodesByReferencer.get(e).filter(u=>Uz(u,e));if(!l.length)n(xn(wa({negate:!0}),t));else if(l.length>1){const u=es({atomic:!0,body:l.reverse().map(c=>Ma({body:[Tx(c.number)]}))});n(xn(u,t))}else e.ref=l[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){const a=x2();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function E2(e){Cc(e,{"*"({node:t,parent:n}){t.parent=n}})}function Fz(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Uz(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=A2(n.parent);for(const a of r){if(a===n)break;if(a===e||D2(a,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function N2(e,t,n,r){const a=Array.isArray(e)?[]:{};for(const[l,u]of Object.entries(e))l==="parent"?a.parent=Array.isArray(n)?r:n:u&&typeof u=="object"?a[l]=N2(u,t,a,n):(l==="type"&&u==="CapturingGroup"&&t.set(a,t.get(e)??e),a[l]=u);return a}function Lw(e){const t=b2(e);return t.isRecursive=!0,t}function Vz(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Cg(e,t){if(t.has(e))return t.get(e);const n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function T2(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(a=>{var l,u;(l=r.enable)!=null&&l[a]&&(delete n.disable[a],n.enable[a]=!0),(u=r.disable)!=null&&u[a]&&(n.disable[a]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Wz({dotAll:e,ignoreCase:t}){const n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function A2(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function L2(e){const t=e.find(n=>n.kind==="search_start"||Kz(n,{negate:!1})||!Gz(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){const n=[];for(const r of t.body){const a=L2(r.body);if(!a)return null;Array.isArray(a)?n.push(...a):n.push(a)}return n}return null}function D2(e,t){const n=A2(e)??[];for(const r of n)if(r===t||D2(r,t))return!0;return!1}function Gz({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function qz(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function Kz(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&p2(e.body[0],{type:"Assertion",kind:"search_start"})}function kg(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Ws(e,t){const r=g2(e,{...t,unicodePropertyMap:Wy}).body;return r.length>1||r[0].body.length>1?es({body:r}):r[0].body[0]}function jg(e,t){return e.negate=t,e}function Di(e,t){return e.parent=t,e}function xn(e,t){return E2(e),e.parent=t,e}function Yz(e,t){const n=C2(t),r=Dx(n.target,"ES2024"),a=Dx(n.target,"ES2025"),l=n.rules.recursionLimit;if(!Number.isInteger(l)||l<2||l>20)throw new Error("Invalid recursionLimit; use 2-20");let u=null,c=null;if(!a){const y=[e.flags.ignoreCase];Cc(e,Xz,{getCurrentModI:()=>y.at(-1),popModI(){y.pop()},pushModI(S){y.push(S)},setHasCasedChar(){y.at(-1)?u=!0:c=!0}})}const d={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||u)&&!c)};let h=e;const p={accuracy:n.accuracy,appliedGlobalFlags:d,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:h,originMap:e._originMap,recursionLimit:l,useAppliedIgnoreCase:!!(!a&&u&&c),useFlagMods:a,useFlagV:r,verbose:n.verbose};function m(y){return p.lastNode=h,h=y,Tz(Qz[y.type],`Unexpected node type "${y.type}"`)(y,p,m)}const x={pattern:e.body.map(m).join("|"),flags:m(e.flags),options:{...e.options}};return r||(delete x.options.force.v,x.options.disable.v=!0,x.options.unicodeSetsPlugin=null),x._captureTransfers=new Map,x._hiddenCaptures=[],p.captureMap.forEach((y,S)=>{y.hidden&&x._hiddenCaptures.push(S),y.transferTo&&Hc(x._captureTransfers,y.transferTo,[]).push(S)}),x}var Xz={"*":{enter({node:e},t){if(Rw(e)){const n=t.getCurrentModI();t.pushModI(e.flags?wh({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){Rw(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Gy(Nn(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),R2(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&j2.has(e.value)&&t.setHasCasedChar()}},Qz={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?vt`\B`:vt`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:r,name:a,number:l}=e,u={ignoreCase:t.currentFlags.ignoreCase},c=t.originMap.get(e);return c&&(u.hidden=!0,l>c.number&&(u.transferTo=c.number)),t.captureMap.set(l,u),`(${a?`?<${a}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=Nn(e),r=Eo(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Gy(n)){const a=k2(n);return t.inCharClass?a.join(""):a.length>1?`[${a.join("")}]`:a[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:a,parent:l}=e;let{body:u}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");ss.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&u.some(Ow)&&(u=[df(45),...u.filter(h=>!Ow(h))]);const c=()=>`[${a?"^":""}${u.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||ss.bugNestedClassIgnoresNegation)&&!a){const p=u.filter(m=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(p.length){const m=es(),x=m.body[0];return m.parent=l,x.parent=m,u=u.filter(y=>!p.includes(y)),e.body=u,u.length?(e.parent=x,x.body.push(e)):m.body.pop(),p.forEach(y=>{const S=Ma({body:[y]});y.parent=S,S.parent=m,m.body.push(S)}),n(m)}}t.inCharClass=!0;const h=c();return t.inCharClass=!1,h}const d=u[0];if(r==="union"&&!a&&d&&((!t.useFlagV||!t.verbose)&&l.kind==="union"&&!(ss.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&l.kind==="intersection"&&u.length===1&&d.type!=="CharacterClassRange"))return u.map(n).join("");if(!t.useFlagV&&l.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return c()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,a={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},l=Eo(n,a),u=Eo(r,a),c=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const d=R2(e);nH(d).forEach(p=>{c.add(Array.isArray(p)?`${Eo(p[0],a)}-${Eo(p[1],a)}`:Eo(p,a))})}return`${l}-${u}${[...c].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},a){if(e==="dot")return a.currentFlags.dotAll?a.appliedGlobalFlags.dotAll||a.useFlagMods?".":"[^]":vt`[^\n]`;if(e==="digit")return t?vt`\D`:vt`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&j2.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?vt`\P`:vt`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?vt`\W`:vt`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},a,l){const u=a.currentFlags;n&&(a.currentFlags=wh(u,n));const c=t.map(l).join("|"),d=!a.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!a.useFlagMods||!n)?c:`(?${rH(e,n,a.useFlagMods)}${c})`;return a.currentFlags=u,d},LookaroundAssertion({body:e,kind:t,negate:n},r,a){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(a).join("|")})`},Quantifier(e,t,n){return n(e.body)+sH(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=n.recursionLimit;return t===0?`(?R=${r})`:vt`\g<${t}&R=${r}>`}},Jz=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Zz=new Set(["-","\\","]","^","["]),eH=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Dw=new Map([[9,vt`\t`],[10,vt`\n`],[11,vt`\v`],[12,vt`\f`],[13,vt`\r`],[8232,vt`\u2028`],[8233,vt`\u2029`],[65279,vt`\uFEFF`]]),tH=new RegExp("^\\p{Cased}$","u");function Gy(e){return tH.test(e)}function R2(e,t){const n=!!(t!=null&&t.firstOnly),r=e.min.value,a=e.max.value,l=[];if(r<65&&(a===65535||a>=131071)||r===65536&&a>=131071)return l;for(let u=r;u<=a;u++){const c=Nn(u);if(!Gy(c))continue;const d=k2(c).filter(h=>{const p=h.codePointAt(0);return p<r||p>a});if(d.length&&(l.push(...d),n))break}return l}function Eo(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Dw.has(e))return Dw.get(e);if(e<32||e>126&&e<160||e>262143||t&&iH(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=n?r?eH:Zz:Jz,l=Nn(e);return(a.has(l)?"\\":"")+l}function nH(e){const t=e.map(a=>a.codePointAt(0)).sort((a,l)=>a-l),n=[];let r=null;for(let a=0;a<t.length;a++)t[a+1]===t[a]+1?r??(r=t[a]):r===null?n.push(t[a]):(n.push([r,t[a]]),r=null);return n}function rH(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:a,disable:l}=t;r=(a!=null&&a.ignoreCase?"i":"")+(a!=null&&a.dotAll?"s":"")+(l?"-":"")+(l!=null&&l.ignoreCase?"i":"")+(l!=null&&l.dotAll?"s":"")}return`${r}:`}function sH({kind:e,max:t,min:n}){let r;return!n&&t===1?r="?":!n&&t===1/0?r="*":n===1&&t===1/0?r="+":n===t?r=`{${n}}`:r=`{${n},${t===1/0?"":t}}`,r+{greedy:"",lazy:"?",possessive:"+"}[e]}function Rw({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function iH(e){return e>47&&e<58}function Ow({type:e,value:t}){return e==="Character"&&t===45}var Ri,Xs,ja,Oi,Ea,Uc,Rx,Fi,aH=(Fi=class extends RegExp{constructor(n,r,a){var t=(...qV)=>(super(...qV),ha(this,Uc),ha(this,Ri,new Map),ha(this,Xs,null),ha(this,ja),ha(this,Oi,null),ha(this,Ea,null),Ne(this,"rawOptions",{}),this);const l=!!(a!=null&&a.lazyCompile);if(n instanceof RegExp){if(a)throw new Error("Cannot provide options when copying a regexp");const u=n;t(u,r),Yr(this,ja,u.source),u instanceof Fi&&(Yr(this,Ri,Xn(u,Ri)),Yr(this,Oi,Xn(u,Oi)),Yr(this,Ea,Xn(u,Ea)),this.rawOptions=u.rawOptions)}else{const u={hiddenCaptures:[],strategy:null,transfers:[],...a};t(l?"":n,r),Yr(this,ja,n),Yr(this,Ri,lH(u.hiddenCaptures,u.transfers)),Yr(this,Ea,u.strategy),this.rawOptions=a??{}}l||Yr(this,Xs,this)}get source(){return Xn(this,ja)||"(?:)"}exec(n){if(!Xn(this,Xs)){const{lazyCompile:l,...u}=this.rawOptions;Yr(this,Xs,new Fi(Xn(this,ja),this.flags,u))}const r=this.global||this.sticky,a=this.lastIndex;if(Xn(this,Ea)==="clip_search"&&r&&a){this.lastIndex=0;const l=Np(this,Uc,Rx).call(this,n.slice(a));return l&&(oH(l,a,n,this.hasIndices),this.lastIndex+=a),l}return Np(this,Uc,Rx).call(this,n)}},Ri=new WeakMap,Xs=new WeakMap,ja=new WeakMap,Oi=new WeakMap,Ea=new WeakMap,Uc=new WeakSet,Rx=function(n){Xn(this,Xs).lastIndex=this.lastIndex;const r=J0(Fi.prototype,this,"exec").call(Xn(this,Xs),n);if(this.lastIndex=Xn(this,Xs).lastIndex,!r||!Xn(this,Ri).size)return r;const a=[...r];r.length=1;let l;this.hasIndices&&(l=[...r.indices],r.indices.length=1);const u=[0];for(let c=1;c<a.length;c++){const{hidden:d,transferTo:h}=Xn(this,Ri).get(c)??{};if(d?u.push(null):(u.push(r.length),r.push(a[c]),this.hasIndices&&r.indices.push(l[c])),h&&a[c]!==void 0){const p=u[h];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(r[p]=a[c],this.hasIndices&&(r.indices[p]=l[c]),r.groups){Xn(this,Oi)||Yr(this,Oi,cH(this.source));const m=Xn(this,Oi).get(h);m&&(r.groups[m]=a[c],this.hasIndices&&(r.indices.groups[m]=l[c]))}}}return r},Fi);function oH(e,t,n,r){if(e.index+=t,e.input=n,r){const a=e.indices;for(let u=0;u<a.length;u++){const c=a[u];c&&(a[u]=[c[0]+t,c[1]+t])}const l=a.groups;l&&Object.keys(l).forEach(u=>{const c=l[u];c&&(l[u]=[c[0]+t,c[1]+t])})}}function lH(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,a]of t)for(const l of a)Hc(n,l,{}).transferTo=r;return n}function cH(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,a=0,l;for(;l=t.exec(e);){const{0:u,groups:{capture:c,name:d}}=l;u==="["?r++:r?u==="]"&&r--:c&&(a++,d&&n.set(a,d))}return n}function uH(e,t){const n=dH(e,t);return n.options?new aH(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function dH(e,t){const n=C2(t),r=g2(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Wy}),a=Bz(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),l=Yz(a,n),u=Ez(l.pattern,{captureTransfers:l._captureTransfers,hiddenCaptures:l._hiddenCaptures,mode:"external"}),c=kz(u.pattern),d=Cz(c.pattern,{captureTransfers:u.captureTransfers,hiddenCaptures:u.hiddenCaptures}),h={pattern:d.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${l.flags}${l.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const p=d.hiddenCaptures.sort((S,C)=>S-C),m=Array.from(d.captureTransfers),x=a._strategy,y=h.pattern.length>=n.lazyCompileLength;(p.length||m.length||x||y)&&(h.options={...p.length&&{hiddenCaptures:p},...m.length&&{transfers:m},...x&&{strategy:x},...y&&{lazyCompile:y}})}return h}function O2(e,t){return uH(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function hH(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>O2(n,{target:t.target})),{createScanner(n){return new N$(n,t)},createString(n){return{content:n}}}}dE(Ty({bundledLanguages:()=>tf,bundledLanguagesAlias:()=>Ly,bundledLanguagesBase:()=>Ay,bundledLanguagesInfo:()=>ef,bundledThemes:()=>Ry,bundledThemesInfo:()=>Dy,codeToHast:()=>s2,codeToHtml:()=>r2,codeToTokens:()=>i2,codeToTokensBase:()=>a2,codeToTokensWithThemes:()=>o2,createHighlighter:()=>uf,createJavaScriptRegexEngine:()=>hH,createOnigurumaEngine:()=>mE,defaultJavaScriptRegexConstructor:()=>O2,getLastGrammarState:()=>c2,getSingletonHighlighter:()=>l2,loadWasm:()=>Iy}),E$);let Eg=null;const kc=new Set,Ad=new Map,Iw=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],fH=["github-dark-default","vitesse-light","monokai","dracula","nord","everforest-light","rose-pine-dawn","synthwave-84","one-dark-pro","night-owl","catppuccin-mocha","rose-pine","kanagawa-wave","light-plus"],Ng={dark:"github-dark-default",light:"vitesse-light",monokai:"monokai",dracula:"dracula",nord:"nord","rose-pine-dawn":"rose-pine-dawn","everforest-light":"everforest-light","synthwave-84":"synthwave-84","one-dark-pro":"one-dark-pro","night-owl":"night-owl","catppuccin-mocha":"catppuccin-mocha","rose-pine":"rose-pine","kanagawa-wave":"kanagawa-wave","light-plus":"light-plus"};function mH(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function I2(){return Eg||(Eg=uf({themes:fH,langs:Iw}).then(e=>(Iw.forEach(t=>kc.add(t)),e))),Eg}async function pH(e){if(kc.has(e))return;if(Ad.has(e))return Ad.get(e);const t=(async()=>{const n=await I2(),r=tf[e];if(r){await n.loadLanguage(r),kc.add(e);return}try{const a=await re(()=>import(`shiki/langs/${e}.mjs`),[]);a.default&&(await n.loadLanguage(a.default),kc.add(e))}catch(a){console.warn(`Failed to load language ${e}:`,a)}})();Ad.set(e,t),await t,Ad.delete(e)}const cc=new Map,gH=50;function xH(e,t,n){return`${e}|${t}|${n}`}async function M2(e,t,n="github-dark-default"){t!=="text"&&!kc.has(t)&&await pH(t);const r=xH(e,t,n),a=cc.get(r);if(a)return a;const u=(await I2()).codeToHtml(e,{lang:t,theme:n,transformers:[mH()]});if(cc.size>=gH){const c=cc.keys().next().value;c&&cc.delete(c)}return cc.set(r,u),u}const yH={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",rs:"rust",go:"go",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",markdown:"markdown",toml:"toml",ini:"ini",conf:"ini",dockerfile:"docker",makefile:"makefile",cmake:"cmake",graphql:"graphql",gql:"graphql",vue:"vue",svelte:"svelte"};function pf(e){var a;if(!e)return"text";const t=e.split("/").pop()??"",n=t.toLowerCase();if(n==="dockerfile")return"docker";if(n==="makefile")return"makefile";if(n==="cmakelists.txt")return"cmake";const r=(a=t.split(".").pop())==null?void 0:a.toLowerCase();return r?yH[r]??"text":"text"}function P2(){const e=Ut(r=>r.currentPreset),t=Ut(r=>r.isCustom),n=Ut(r=>r.basePreset);return bH(e,t,n)}function bH(e,t,n){return t?n&&n!=="system"&&Ng[n]?Ng[n]??"github-dark-default":"github-dark-default":Ng[e]??"github-dark-default"}function B2(e=2e3){const[t,n]=N.useState(!1),r=N.useCallback(async a=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(a);else{const l=document.createElement("textarea");l.value=a,l.style.position="fixed",l.style.left="-9999px",document.body.appendChild(l),l.select(),document.execCommand("copy"),document.body.removeChild(l)}n(!0),setTimeout(()=>n(!1),e)}catch(l){console.error("Failed to copy:",l)}},[e]);return{copied:t,copy:r}}const vH=N.memo(function({language:t,codeString:n,showSyntaxHighlighting:r}){const{copied:a,copy:l}=B2(),[u,c]=N.useState(null),d=P2(),h=N.useRef(n);return N.useEffect(()=>{r&&(h.current=n,M2(n,t,d).then(p=>{h.current===n&&c(p)}))},[n,t,d,r]),i.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[i.jsxs("div",{className:"absolute bottom-0 right-0 flex items-center gap-2 px-2 py-1 text-xs text-text-muted/70 bg-bg-tertiary/60 rounded-tl rounded-tr z-10",children:[i.jsx("span",{children:t}),i.jsx("button",{type:"button",onClick:p=>{p.preventDefault(),p.stopPropagation(),l(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:a?i.jsx(is,{}):i.jsx(Lc,{})})]}),r&&u?i.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:u}}):i.jsx(Ze,{horizontal:!0,children:i.jsx("pre",{className:"my-0 px-4 py-3 font-mono text-sm whitespace-pre-wrap break-word",children:i.jsx("code",{className:`language-${t}`,children:n})})})]})});function _H(e,t){const n=e?"text-text-muted":"text-text-heading",r=e?"text-text-secondary":"text-text-bold";return{code({className:a,children:l,...u}){const c=/language-(\w+)/.exec(a||"");if(!c&&!String(l).includes(`
|
|
247
|
+
`)){const m=e?"text-text-muted":"text-text-code";return i.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${m} font-mono text-xs`,...u,children:l})}const h=(c==null?void 0:c[1])||"text",p=String(l).replace(/\n$/,"");return i.jsx(vH,{language:h,codeString:p,showSyntaxHighlighting:t})},p({children:a}){const l=e?"text-text-muted":"text-text-primary";return i.jsx("p",{className:`${l} mb-1.5 last:mb-0 leading-tight break-words`,children:a})},ul({children:a}){return i.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:a})},ol({children:a}){return i.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:a})},li({children:a}){const l=e?"text-text-muted":"text-text-primary";return i.jsx("li",{className:`${l} text-sm list-item`,children:a})},h1({children:a}){return i.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:a})},h2({children:a}){return i.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:a})},h3({children:a}){return i.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:a})},h4({children:a}){return i.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:a})},strong({children:a}){return i.jsx("strong",{className:`font-bold ${r}`,children:a})},em({children:a}){return i.jsx("em",{className:e?"italic text-text-secondary":"italic",children:a})},a({href:a,children:l}){return i.jsx("a",{href:a,className:"text-text-link hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:l})},blockquote({children:a}){const l=e?"text-text-muted":"text-text-secondary";return i.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${l} italic text-sm`,children:a})},table({children:a}){return i.jsx(Ze,{horizontal:!0,className:"my-1.5",children:i.jsx("table",{className:"min-w-full border border-border",children:a})})},th({children:a}){return i.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:a})},td({children:a}){return i.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:a})},hr(){return i.jsx("hr",{className:"border-border my-2"})},input({checked:a,...l}){return i.jsx("input",{type:"checkbox",checked:a,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...l})}}}const Jn=N.memo(function({content:t,className:n="",muted:r=!1}){const{showSyntaxHighlighting:a}=Pa(),l=N.useMemo(()=>{let c=SH(t);return c=wH(c),c},[t]),u=N.useMemo(()=>_H(r,a),[r,a]);return i.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:i.jsx(WM,{remarkPlugins:[s6],components:u,children:l})})});function SH(e){let t=e.replace(/^(\s*)•\s/gm,"$1- ");return t=t.replace(/^(\d+)\.\s*\n(?=\S)/gm,"$1. "),t=t.replace(/^\|\s*$/gm,""),t=t.replace(/^\d+\|/gm,""),t}function wH(e){const t=/```/g,n=e.match(t);if(((n==null?void 0:n.length)??0)%2===1){const a=e.lastIndexOf("```");return e.slice(a+3).includes(`
|
|
248
|
+
`),e+"\n```"}return e}function $2({isOpen:e,onClose:t}){const[n,r]=N.useState(null),[a,l]=N.useState(!1),{settings:u,getSetting:c,setSetting:d}=qi(),h=u[Ae.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]!=="false";N.useEffect(()=>{e&&c(Ae.DISPLAY_SHOW_CHANGELOG_ON_UPDATE)},[e,c]),N.useEffect(()=>{e&&(l(!0),Ce("/api/changelog").then(m=>m.json()).then(m=>{r(m.content)}).catch(()=>{r(`# Changelog
|
|
249
|
+
|
|
250
|
+
Failed to load changelog.`)}).finally(()=>l(!1)))},[e]);const p=N.useCallback(()=>{const m=h?"false":"true";d(Ae.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,m)},[h,d]);return i.jsx(Tt,{isOpen:e,onClose:t,title:"What's New in OpenFox",size:"xl",closeOnBackdropClick:!0,showCloseButton:!0,footer:i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[i.jsx(ns,{enabled:h,onClick:p}),i.jsx("span",{className:"text-sm text-text-muted",children:"Show changelog on future updates"})]}),children:i.jsx("div",{className:"flex flex-col gap-4 min-h-0",children:a?i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx("div",{className:"w-5 h-5 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"})}):i.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:i.jsx(Jn,{content:n??""})})})})}const CH="#6b7280";function Yo(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??CH}const gt=Gn(e=>{const t=async()=>{e({loading:!0});try{const r=await(await Ce("/api/agents")).json();e({defaults:r.defaults??[],userItems:r.userItems??[],projectItems:r.projectItems??[],modelOverrides:r.modelOverrides??{},loading:!1})}catch{e({loading:!1})}};return{defaults:[],userItems:[],projectItems:[],modelOverrides:{},loading:!1,fetchAgents:t,fetchAgent:async n=>{try{const r=await Ce(`/api/agents/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await Ce(`/api/agents/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createAgent:async(n,r)=>{const a=await Ui("POST","/api/agents",{...n,destination:r});return a.success&&await t(),a},updateAgent:async(n,r)=>{const a=await Ui("PUT",`/api/agents/${n}`,r);return a.success&&await t(),a},deleteAgent:async n=>{try{const r=await Ce(`/api/agents/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n),projectItems:l.projectItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateAgent:async(n,r)=>Uh(`/api/agents/${n}/duplicate`,t,r)}});function kH({onClose:e}){const[,t]=zn(),{settings:n,getSetting:r,setSetting:a}=qi(),l=n[Ae.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",u=n[Ae.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",c=n[Ae.CACHE_WARMING]==="true",[d,h]=N.useState({openInEditor:l,dynamicPrompt:u,cacheWarming:c}),[p,m]=N.useState({patterns:[],maxRetriesPerTurn:10}),[x,y]=N.useState(""),[S,C]=N.useState(""),[v,w]=N.useState(!1),[_,b,k,E]=rx(),[T,D]=N.useState(!1),[L,R]=N.useState(!1),M=nn(P=>P.version),W=ei(P=>P.status),z=ei(P=>P.latest),H=ei(P=>P.check),I=M&&z?{current:M,latest:z}:null,[U,V]=N.useState(!1),Z=gt(P=>P.defaults),ee=gt(P=>P.userItems),F=gt(P=>P.fetchAgents),O=[...Z,...ee].filter(P=>!P.subagent);N.useEffect(()=>{h({openInEditor:l,dynamicPrompt:u,cacheWarming:c})},[l,u,c]),N.useEffect(()=>{r(Ae.DISPLAY_SHOW_OPEN_IN_EDITOR),r(Ae.LLM_DYNAMIC_SYSTEM_PROMPT),r(Ae.CACHE_WARMING),r(Ae.RETRY_PATTERNS),r(Ae.PROXY_URL)},[r]),N.useEffect(()=>{const P=n[Ae.RETRY_PATTERNS];if(P)try{m(JSON.parse(P))}catch{}},[n]),N.useEffect(()=>{const P=n[Ae.PROXY_URL];P!==void 0&&y(P)},[n]),N.useEffect(()=>{F().catch(()=>{})},[F]),N.useEffect(()=>{r(Ae.DEFAULT_AGENT)},[r]),N.useEffect(()=>{const P=n[Ae.DEFAULT_AGENT];P!==void 0&&(C(P),w(!0))},[n]);const B=N.useCallback(P=>{m(P),a(Ae.RETRY_PATTERNS,JSON.stringify(P))},[a]),q=P=>{y(P),a(Ae.PROXY_URL,P)};function $(){E(async()=>(await Ce("/api/proxy/test",{method:"POST"})).json())}const Y=()=>{const P=!d.openInEditor;h(J=>({...J,openInEditor:P})),a(Ae.DISPLAY_SHOW_OPEN_IN_EDITOR,String(P))},Q=()=>{const P=!d.dynamicPrompt;h(J=>({...J,dynamicPrompt:P})),a(Ae.LLM_DYNAMIC_SYSTEM_PROMPT,String(P))},X=()=>{const P=!d.cacheWarming;h(J=>({...J,cacheWarming:P})),a(Ae.CACHE_WARMING,String(P))};function K(){e(),t("/onboarding")}return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{children:[i.jsxs("h3",{className:"text-sm font-medium text-text-primary mb-1",children:[W==="available"&&i.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent-primary mr-1.5 align-middle"}),"Updates"]}),i.jsx("p",{className:"text-sm text-text-muted mb-4",children:M?i.jsxs(i.Fragment,{children:["Current version: ",i.jsxs("span",{className:"font-mono",children:["v",M]})]}):"Check for a new OpenFox version."}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(mt,{variant:"secondary",onClick:()=>{V(!0),H()},disabled:W==="checking",children:W==="checking"?"Checking…":"Check for Updates"}),U&&W==="upToDate"&&i.jsx("span",{className:"text-sm text-text-muted",children:"Up to date"}),W==="error"&&i.jsx("span",{className:"text-sm text-text-muted",children:"Update check failed"}),W==="available"&&i.jsxs("button",{onClick:()=>D(!0),className:"text-sm text-accent-primary hover:underline",children:["Update to v",z," →"]})]})]}),i.jsx(ij,{isOpen:T,onClose:()=>D(!1),versionInfo:I}),i.jsxs("div",{className:"flex items-center justify-between pt-2",children:[i.jsx("button",{onClick:()=>R(!0),className:"text-sm text-accent-primary hover:underline",children:"View Changelog →"}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("span",{className:"text-xs text-text-muted",children:"Show on update"}),i.jsx(ns,{enabled:(n[Ae.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true",onClick:()=>{const J=(n[Ae.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true"?"false":"true";a(Ae.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,J)}})]})]}),i.jsx($2,{isOpen:L,onClose:()=>R(!1)}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Default Agent"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Choose which agent is used by default for new sessions. The stock Planner is read-only; custom agents can have broader capabilities."}),i.jsxs("select",{value:v?S:"",onChange:P=>{const J=P.target.value;C(J),a(Ae.DEFAULT_AGENT,J)},className:"w-full px-3 py-2 text-sm bg-bg-primary border border-border rounded-lg text-text-primary focus:outline-none focus:ring-2 focus:ring-accent-primary",children:[!v&&i.jsx("option",{value:"",children:"Loading…"}),v&&i.jsx("option",{value:"",children:"System default (planner)"}),O.map(P=>i.jsx("option",{value:P.id,children:P.name},P.id))]}),O.length===0&&v&&i.jsx("p",{className:"text-xs text-text-muted mt-1",children:"No agents available. Create one in the Agents modal."})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),i.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Manage providers, workdir and vision fallback."}),i.jsx(mt,{variant:"secondary",onClick:K,children:"Launch Onboarding"})]}),i.jsx("hr",{className:"border-border"}),i.jsx("div",{children:i.jsx(Tg,{title:'Show "Open in VSCode" links',description:"Display a link on file reads to open the file directly in VS Code.",enabled:d.openInEditor,onToggle:Y})}),i.jsx("hr",{className:"border-border"}),i.jsx(Tg,{title:"Speculative Cache Warming",description:"On first keystroke in an empty session, prefill the LLM KV cache to reduce time-to-first-token.",enabled:d.cacheWarming,onToggle:X,boldTitle:!0}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Network"}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"HTTP Proxy"}),i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(zi,{type:"text",value:x,onChange:P=>q(P.target.value),placeholder:"http://proxy:8080",className:"flex-1"}),i.jsx(mt,{variant:"secondary",onClick:$,style:k?{color:"rgb(63, 185, 80)"}:void 0,children:_})]}),b&&i.jsx("p",{className:"text-xs text-red-500 mt-1",children:b}),i.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Proxy server all OpenFox network requests (AI, model fetching, web search, terminal). Leave empty for direct connection."})]})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Auto-Retry Patterns"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:'Define regex patterns that, when matched against LLM responses mid-stream, trigger an automatic retry with a "continue" prompt. The content that triggered the match is preserved in the chat feed.'}),i.jsx(O3,{value:p,onChange:B})]}),i.jsx("hr",{className:"border-border"}),i.jsx(Tg,{title:"Dynamic System Prompt",description:"Rebuild the system prompt on every turn. Recommended value: off.",enabled:d.dynamicPrompt,onToggle:Q,boldTitle:!0})]})}function Tg({title:e,description:t,enabled:n,onToggle:r,boldTitle:a}){return i.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:`text-sm ${a?"font-medium":""} text-text-primary`,children:e}),i.jsx("div",{className:"text-sm text-text-muted mt-0.5",children:t})]}),i.jsx("div",{className:"flex-shrink-0",children:i.jsx(ns,{enabled:n,onClick:r})})]})}function jH(e,t){return e===null&&t===null?!0:e===null||t===null?!1:JSON.stringify(e)===JSON.stringify(t)}function EH({label:e,binding:t,defaultBinding:n,isRecording:r,onStartRecording:a,onBindingRecorded:l,onClear:u,onReset:c,onCancelRecording:d}){const h=N.useRef(null),p=N.useRef(0),m=N.useRef("");return N.useEffect(()=>{if(!r)return;const x=new Set(["Control","Shift","Alt","Meta"]);let y=[];const S=v=>{if(v.preventDefault(),v.stopPropagation(),v.key==="Escape"){d();return}if(x.has(v.key)){const b=Date.now();if(v.key===m.current&&b-p.current<400){l({type:"double-press",key:v.key,threshold:300});return}p.current=b,m.current=v.key,v.ctrlKey&&!y.includes("ctrl")&&y.push("ctrl"),v.metaKey&&!y.includes("meta")&&y.push("meta"),v.altKey&&!y.includes("alt")&&y.push("alt"),v.shiftKey&&!y.includes("shift")&&y.push("shift");return}if(y.length>0||v.ctrlKey||v.metaKey||v.altKey||v.shiftKey){const b=[...y];v.ctrlKey&&!b.includes("ctrl")&&b.push("ctrl"),v.metaKey&&!b.includes("meta")&&b.push("meta"),v.altKey&&!b.includes("alt")&&b.push("alt"),v.shiftKey&&!b.includes("shift")&&b.push("shift"),l({type:"chord",key:QS(v),modifiers:b});return}const w=Date.now(),_=QS(v);if(_===m.current&&w-p.current<400){l({type:"double-press",key:_,threshold:300});return}p.current=w,m.current=_},C=v=>{v.key==="Control"&&(y=y.filter(w=>w!=="ctrl")),v.key==="Shift"&&(y=y.filter(w=>w!=="shift")),v.key==="Alt"&&(y=y.filter(w=>w!=="alt")),v.key==="Meta"&&(y=y.filter(w=>w!=="meta"))};return window.addEventListener("keydown",S,!0),window.addEventListener("keyup",C,!0),()=>{window.removeEventListener("keydown",S,!0),window.removeEventListener("keyup",C,!0)}},[r,l,d]),i.jsxs("div",{ref:h,className:`flex items-center justify-between px-3 py-2 rounded transition-colors ${r?"bg-accent-primary/10 ring-1 ring-accent-primary":"hover:bg-bg-tertiary"}`,children:[i.jsx("span",{className:"text-sm text-text-primary",children:e}),i.jsx("div",{className:"flex items-center gap-2",children:r?i.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",onClick:a,className:"px-2 py-0.5 text-xs font-mono bg-bg-tertiary text-text-secondary rounded border border-border hover:border-accent-primary hover:text-accent-primary transition-colors",children:t?ah(t):"None"}),t&&i.jsx("button",{type:"button",onClick:u,title:"Remove shortcut","aria-label":`Remove shortcut for ${e}`,className:"p-1 text-text-muted rounded hover:text-accent-error hover:bg-bg-tertiary transition-colors",children:i.jsx(oy,{className:"w-3.5 h-3.5"})}),!jH(t,n)&&i.jsx("button",{type:"button",onClick:c,title:"Reset to default","aria-label":`Reset ${e} to default`,className:"p-1 text-text-muted rounded hover:text-accent-primary hover:bg-bg-tertiary transition-colors",children:i.jsx(Wh,{className:"w-3.5 h-3.5"})})]})})]})}function NH(){const{settings:e,loading:t,setSetting:n}=qi(),r=e[Ae.KEYBINDINGS],a=t[Ae.KEYBINDINGS]??!1,l=nx(r),[u,c]=N.useState(null),d=[{id:"terminalToggle",label:"Toggle Terminal",binding:l.terminalToggle,defaultBinding:xs.terminalToggle},{id:"quickAction",label:"Quick Action",binding:l.quickAction,defaultBinding:xs.quickAction},{id:"modelSelector",label:"Select Model",binding:l.modelSelector,defaultBinding:xs.modelSelector},{id:"sessionSearch",label:"Search Sessions",binding:l.sessionSearch,defaultBinding:xs.sessionSearch},{id:"criteriaSidebar",label:"Toggle Criteria Sidebar",binding:l.criteriaSidebar,defaultBinding:xs.criteriaSidebar},...l.agentSwitching.map((y,S)=>({id:`agentSwitching.${S}`,label:`Switch to Agent ${S+1}`,binding:y,defaultBinding:xs.agentSwitching[S]??null}))],h=y=>{c(y)},p=N.useCallback((y,S)=>{const C=nx(r);if(y.startsWith("agentSwitching.")){const v=parseInt(y.split(".")[1],10);C.agentSwitching[v]=S}else y==="terminalToggle"?C.terminalToggle=S:y==="quickAction"?C.quickAction=S:y==="modelSelector"?C.modelSelector=S:y==="sessionSearch"?C.sessionSearch=S:y==="criteriaSidebar"&&(C.criteriaSidebar=S);n(Ae.KEYBINDINGS,JSON.stringify(C))},[r,n]),m=N.useCallback(y=>{u&&(c(null),p(u,y))},[u,p]),x=()=>{n(Ae.KEYBINDINGS,JSON.stringify(xs))};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),i.jsx("button",{type:"button",onClick:x,disabled:a,className:"text-xs text-text-muted hover:text-text-primary px-2 py-1 rounded hover:bg-bg-tertiary transition-colors disabled:opacity-30",children:"Reset to defaults"})]}),a?i.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):i.jsx("div",{className:"space-y-1",children:d.map(y=>i.jsx(EH,{label:y.label,binding:y.binding,defaultBinding:y.defaultBinding,isRecording:u===y.id,onStartRecording:()=>h(y.id),onBindingRecorded:m,onClear:()=>p(y.id,null),onReset:()=>p(y.id,y.defaultBinding),onCancelRecording:()=>c(null)},y.id))})]})}function qy(e){switch(e){case"connected":return"text-accent-success";case"error":return"text-accent-error";case"disabled":return"text-text-muted";default:return"text-text-muted"}}function Ky(e){switch(e){case"connected":return"●";case"error":return"✕";default:return"○"}}function Ch(e){return e>=1e3?`~${(e/1e3).toFixed(1)}K`:`~${e}`}function z2({server:e,expanded:t,onToggleExpand:n,serverToggleEnabled:r,onServerToggle:a,tools:l,onToolToggle:u,statusDot:c,statusColor:d,actions:h}){var y;const[p,m]=N.useState(new Set),x=e.name;return i.jsxs("div",{className:"rounded border border-border bg-bg-tertiary overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-bg-primary/50 transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 cursor-pointer",onClick:()=>n(x),children:[i.jsx("span",{className:`text-sm ${d}`,children:c}),i.jsx("span",{className:"text-sm font-medium text-text-primary",children:x}),i.jsx("span",{className:"text-xs text-text-muted",children:e.config.transport}),i.jsxs("span",{className:"text-xs text-text-muted",children:["(",l.length," tools)"]}),i.jsxs("span",{className:"text-xs text-text-muted",children:[Ch(e.estimatedTokens)," tokens"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ns,{enabled:r,onClick:a}),h,i.jsx("span",{className:"text-xs text-text-muted",children:t?"▲":"▼"})]})]}),t&&i.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5",children:[e.config.command&&i.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[e.config.command," ",((y=e.config.args)==null?void 0:y.join(" "))??""]}),e.config.url&&i.jsx("div",{className:"text-xs text-text-muted font-mono",children:e.config.url}),l.length===0?i.jsx("div",{className:"text-xs text-text-muted",children:"No tools available"}):i.jsx("div",{className:"space-y-1",children:l.map(S=>i.jsxs("div",{className:"py-1",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"min-w-0 flex-1 mr-2",children:[i.jsx("span",{className:"text-xs text-text-primary font-mono",children:S.name}),S.description&&S.description.length>80?i.jsxs("button",{onClick:()=>{const C=S.name;m(v=>{const w=new Set(v);return w.has(C)?w.delete(C):w.add(C),w})},className:"inline-flex items-center gap-0.5 text-xs text-text-muted hover:text-text-primary transition-colors ml-2",children:[i.jsx("span",{className:"truncate max-w-[300px]",children:S.description}),i.jsx(yn,{rotate:p.has(S.name)?180:0,className:"w-3 h-3 flex-shrink-0"})]}):S.description?i.jsx("span",{className:"text-xs text-text-muted ml-2",children:S.description}):null]}),i.jsx("span",{className:"text-xs text-text-muted mr-2 flex-shrink-0",children:Ch(S.estimatedTokens)}),i.jsx(ns,{enabled:S.enabled,onClick:()=>u(S.name)})]}),S.description&&S.description.length>80&&p.has(S.name)&&i.jsx("div",{className:"text-xs text-text-muted mt-1 ml-1",children:S.description})]},S.name))})]})]},x)}function Mw(e){const t={};return e.split(`
|
|
251
|
+
`).filter(Boolean).forEach(n=>{const r=n.indexOf("=");r>0&&(t[n.slice(0,r).trim()]=n.slice(r+1).trim())}),t}function Pw({formData:e,onChange:t}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Transport"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{onClick:()=>t({...e,transport:"stdio"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${e.transport==="stdio"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"Stdio"}),i.jsx("button",{onClick:()=>t({...e,transport:"http"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${e.transport==="http"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"HTTP"})]})]}),e.transport==="stdio"?i.jsxs(i.Fragment,{children:[i.jsx(Fr,{label:"Command",value:e.command,onChange:n=>t({...e,command:n}),placeholder:"e.g. npx"}),i.jsx(Fr,{label:"Arguments",value:e.args,onChange:n=>t({...e,args:n}),placeholder:"space-separated args"}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Environment variables ",i.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),i.jsx("textarea",{value:e.env,onChange:n=>t({...e,env:n.target.value}),placeholder:"API_KEY=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]})]}):i.jsxs(i.Fragment,{children:[i.jsx(Fr,{label:"URL",value:e.url,onChange:n=>t({...e,url:n}),placeholder:"e.g. https://mcp.example.com/mcp"}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Headers ",i.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),i.jsx("textarea",{value:e.headers,onChange:n=>t({...e,headers:n.target.value}),placeholder:"X-API-Key=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]})]}),i.jsx(Fr,{label:"Timeout (seconds)",value:e.timeout,onChange:n=>t({...e,timeout:n}),placeholder:"optional, e.g. 30"})]})}function Ag(e,t,n,r=250){const a=N.useRef(!0);N.useEffect(()=>{if(a.current){a.current=!1;return}const l=setTimeout(()=>{n(t,e)},r);return()=>clearTimeout(l)},[e,t,r,n])}function Bw({saving:e,saveLabel:t,savingLabel:n,onCancel:r,onSave:a}){return i.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[i.jsx(mt,{variant:"secondary",onClick:r,disabled:e,children:"Cancel"}),i.jsx(mt,{variant:"primary",onClick:a,disabled:e,children:e?n:t})]})}function TH(){const{settings:e,getSetting:t,setSetting:n}=qi(),[r,a]=N.useState(""),[l,u]=N.useState(""),[c,d]=N.useState(""),[h,p]=N.useState("");Ag(l,Ae.SEARCH_TAVILY_API_KEY,n),Ag(c,Ae.SEARCH_SEARXNG_URL,n),Ag(h,Ae.SEARCH_SEARXNG_API_KEY,n);const[m,x,y,S]=rx(),[C,v,w,_]=rx();N.useEffect(()=>{t(Ae.SEARCH_ENGINE),t(Ae.SEARCH_TAVILY_API_KEY),t(Ae.SEARCH_SEARXNG_URL),t(Ae.SEARCH_SEARXNG_API_KEY),t(Ae.TOOLS_USE_RTK),t(Ae.CONFIRM_ON_WORKSPACE_ACTIONS)},[t]),N.useEffect(()=>{e[Ae.SEARCH_ENGINE]!==void 0&&(a(e[Ae.SEARCH_ENGINE]??""),u(e[Ae.SEARCH_TAVILY_API_KEY]??""),d(e[Ae.SEARCH_SEARXNG_URL]??""),p(e[Ae.SEARCH_SEARXNG_API_KEY]??""))},[e]);function b(ge){a(ge),n(Ae.SEARCH_ENGINE,ge)}function k(){S(async()=>(await Ce("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"tavily",tavilyApiKey:l||void 0})})).json())}function E(){_(async()=>(await Ce("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"searxng",searxngUrl:c||void 0,searxngApiKey:h||void 0})})).json())}const[T,D]=N.useState("checking");N.useEffect(()=>{Ce("/api/tools/rtk-check").then(ge=>ge.json()).then(ge=>D(ge.available?"available":"unavailable")).catch(()=>D("unavailable"))},[]);const[L,R]=N.useState([]);N.useEffect(()=>{t(Ae.TOOLS_SHELL),Ce("/api/tools/shells").then(ge=>ge.json()).then(ge=>R(ge.shells??[])).catch(()=>R([]))},[t]);const M=e[Ae.TOOLS_SHELL]||"cmd",[W,z]=N.useState([]),[H,I]=N.useState(!0),[U,V]=N.useState(!1),[Z,ee]=N.useState(null),[F,O]=N.useState(new Set),[B,q]=N.useState({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",timeout:""}),[$,Y]=N.useState(""),[Q,X]=N.useState(""),[K,P]=N.useState(!1),{requestDelete:J,clearConfirm:ne,isConfirming:ce}=Gc(),ae=N.useCallback(async()=>{try{const He=((await(await Ce("/api/mcp/servers")).json()).servers??[]).sort((ie,xe)=>ie.name.localeCompare(xe.name));z(He)}catch{}I(!1)},[]);N.useEffect(()=>{ae()},[ae]),N.useEffect(()=>{const ge=()=>ae();return window.addEventListener("mcp-servers-changed",ge),()=>window.removeEventListener("mcp-servers-changed",ge)},[ae]);const Ee=ge=>{O(Fe=>{const He=new Set(Fe);return He.has(ge)?(He.delete(ge),He):(He.add(ge),He)})};function ve(){if(B.transport==="stdio"&&!B.command)return"Command is required for stdio transport";if(B.transport==="http"&&!B.url)return"URL is required for HTTP transport";if(B.timeout){const ge=parseFloat(B.timeout);if(isNaN(ge)||ge<=0)return"Timeout must be a positive number"}return null}function Le(ge){const Fe=ge?{name:B.name,transport:B.transport}:{transport:B.transport};if(B.transport==="stdio"?(Fe.command=B.command,Fe.args=B.args?B.args.split(" ").filter(Boolean):[],Fe.env=Mw(B.env)):(Fe.url=B.url,Fe.headers=Mw(B.headers)),B.timeout){const He=parseFloat(B.timeout);!isNaN(He)&&He>0&&(Fe.timeout=He)}return Fe}const Me={name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",timeout:""},ke=async()=>{if(Y(""),!B.name){Y("Name is required");return}const ge=ve();if(ge){Y(ge);return}P(!0);try{const Fe=Le(!0),He=await Ce("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Fe)});if(!He.ok){const ie=await He.json();throw new Error(ie.error??"Failed to add server")}V(!1),q(Me),await ae()}catch(Fe){Y(Fe instanceof Error?Fe.message:String(Fe))}finally{P(!1)}},Ge=ge=>{var Fe;q({name:ge.name,transport:ge.config.transport,command:ge.config.command??"",args:((Fe=ge.config.args)==null?void 0:Fe.join(" "))??"",env:ge.config.env?Object.entries(ge.config.env).map(([He,ie])=>`${He}=${ie}`).join(`
|
|
252
|
+
`):"",url:ge.config.url??"",headers:ge.config.headers?Object.entries(ge.config.headers).map(([He,ie])=>`${He}=${ie}`).join(`
|
|
253
|
+
`):"",timeout:ge.config.timeout!==void 0?String(ge.config.timeout):""}),Y(""),ee(ge.name)},Xe=async()=>{Y("");const ge=ve();if(ge){Y(ge);return}P(!0);try{const Fe=Le(!1),He=await Ce(`/api/mcp/servers/${encodeURIComponent(Z)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Fe)});if(!He.ok){const ie=await He.json();throw new Error(ie.error??"Failed to update server")}ee(null),q(Me),await ae()}catch(Fe){Y(Fe instanceof Error?Fe.message:String(Fe))}finally{P(!1)}},Se=async ge=>{try{const Fe=await Ce(`/api/mcp/servers/${encodeURIComponent(ge)}`,{method:"DELETE"});if(!Fe.ok){const He=await Fe.json().catch(()=>({}));throw new Error(He.error??"Failed to remove server")}ne(),X(""),await ae()}catch(Fe){X(Fe instanceof Error?Fe.message:String(Fe))}},Ie=async(ge,Fe,He)=>{try{const ie=await Ce(`/api/mcp/servers/${encodeURIComponent(ge)}/tools/${encodeURIComponent(Fe)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:He})});if(!ie.ok){const xe=await ie.json().catch(()=>({}));throw new Error(xe.error??"Failed to toggle tool")}X(""),await ae()}catch(ie){X(ie instanceof Error?ie.message:String(ie))}},it=async(ge,Fe)=>{try{const He=await Ce(`/api/mcp/servers/${encodeURIComponent(ge)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:Fe})});if(!He.ok){const ie=await He.json().catch(()=>({}));throw new Error(ie.error??"Failed to toggle server")}X(""),await ae()}catch(He){X(He instanceof Error?He.message:String(He))}};return i.jsxs("div",{className:"space-y-8",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Search Engine"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Configure a web search engine for the web_search tool."}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Engine"}),i.jsx("div",{className:"flex gap-2",children:["","tavily","searxng"].map(ge=>i.jsx("button",{onClick:()=>b(ge),className:`px-3 py-1.5 rounded text-sm border transition-colors ${r===ge?"bg-accent-primary/10 border-accent-primary text-accent-primary":"border-border text-text-muted hover:text-text-primary"}`,children:ge||"Off"},ge))})]}),r==="tavily"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Tavily API Key"}),i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(zi,{type:"password",value:l,onChange:ge=>u(ge.target.value),placeholder:"tvly-...",className:"flex-1"}),i.jsx(mt,{variant:"secondary",onClick:k,style:y?{color:"rgb(63, 185, 80)"}:void 0,children:m})]}),x&&i.jsx("p",{className:"text-xs text-red-500 mt-1",children:x}),i.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Get a free API key at"," ",i.jsx("a",{href:"https://app.tavily.com",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"tavily.com"})]})]}),r==="searxng"&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"SearXNG URL"}),i.jsx(zi,{type:"url",value:c,onChange:ge=>d(ge.target.value),placeholder:"http://localhost:4000",className:"w-full"})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs font-medium text-text-primary mb-1",children:["API Key ",i.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),i.jsx(zi,{type:"password",value:h,onChange:ge=>p(ge.target.value),placeholder:"Optional API key",className:"w-full"})]}),i.jsx(mt,{variant:"secondary",onClick:E,style:w?{color:"rgb(63, 185, 80)"}:void 0,children:C}),v&&i.jsx("p",{className:"text-xs text-red-500",children:v})]})]})]}),L.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Shell"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Shell used to run agent commands and integrated terminals. Git Bash gives the agent a Unix-like toolset (grep, sed, ls…) and usually works better than cmd.exe."}),i.jsx("div",{className:"flex gap-2",children:L.map(ge=>i.jsxs("button",{onClick:()=>n(Ae.TOOLS_SHELL,ge.id),disabled:!ge.available,title:ge.available?void 0:"Not found on this machine",className:`px-3 py-1.5 rounded text-sm border transition-colors ${M===ge.id?"bg-accent-primary/10 border-accent-primary text-accent-primary":ge.available?"border-border text-text-muted hover:text-text-primary":"border-border text-text-muted opacity-50 cursor-not-allowed"}`,children:[ge.label,!ge.available&&" (not found)"]},ge.id))}),i.jsx("p",{className:"text-xs text-text-muted mt-2",children:"Applies to new commands and newly opened terminals. Running terminals keep their current shell."})]})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Token Optimization"}),i.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Reduce token consumption by filtering command output through RTK. See the"," ",i.jsx("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"README"})," ","for installation."]}),i.jsxs("div",{className:"flex items-center justify-between py-2",children:[i.jsx("div",{className:"flex-1",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-text-primary",children:"Enable RTK auto-rewrite"}),T==="checking"&&i.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"checking…"}),T==="available"&&i.jsx("span",{className:"text-xs text-accent-success",children:"● installed"}),T==="unavailable"&&i.jsx("span",{className:"text-xs text-accent-error",children:"○ not found"})]})}),i.jsx(ns,{enabled:e[Ae.TOOLS_USE_RTK]==="true",onClick:()=>n(Ae.TOOLS_USE_RTK,e[Ae.TOOLS_USE_RTK]==="true"?"false":"true")})]})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Agent Confirmations"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Require confirmation for workspace changes and git mutations. When disabled, the agent proceeds without interruption."}),i.jsxs("div",{className:"flex items-center justify-between py-2",children:[i.jsx("div",{className:"flex-1",children:i.jsx("span",{className:"text-sm text-text-primary",children:"Confirm on workspace & git actions"})}),i.jsx(ns,{enabled:e[Ae.CONFIRM_ON_WORKSPACE_ACTIONS]==="true",onClick:()=>n(Ae.CONFIRM_ON_WORKSPACE_ACTIONS,e[Ae.CONFIRM_ON_WORKSPACE_ACTIONS]==="true"?"false":"true")})]})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary","data-testid":"mcp-servers-heading",children:"MCP Servers"}),i.jsx(mt,{variant:"primary",size:"sm",onClick:()=>V(!0),children:"+ Add Server"})]}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"MCP servers provide external tools that extend OpenFox's capabilities."}),i.jsxs("div",{className:"flex items-center justify-between py-2",children:[i.jsx("div",{className:"flex-1",children:i.jsx("span",{className:"text-sm text-text-primary",children:"Show per-conversation MCP toggle in chat bar"})}),i.jsx(ns,{enabled:e[Ae.FEATURES_PER_SESSION_MCP]==="true",onClick:()=>n(Ae.FEATURES_PER_SESSION_MCP,e[Ae.FEATURES_PER_SESSION_MCP]==="true"?"false":"true")})]}),Q&&i.jsx(Fo,{message:Q}),i.jsx(cy,{loading:H,hasItems:W.length>0,loadingLabel:"Loading MCP servers...",emptyLabel:"No MCP servers configured.",children:W.map(ge=>{const Fe=F.has(ge.name)?ce(ge.name,"delete")?i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:ie=>{ie.stopPropagation(),Se(ge.name)},className:"px-2 py-1 rounded text-xs font-medium hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),i.jsx("button",{onClick:ie=>{ie.stopPropagation(),ne()},className:"px-2 py-1 rounded text-xs text-text-muted hover:bg-bg-primary transition-colors",children:"Cancel"})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:ie=>{ie.stopPropagation(),Ge(ge)},className:"px-2 py-1 rounded text-xs font-medium text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",children:"Edit"}),i.jsx("button",{onClick:ie=>{ie.stopPropagation(),J(ge.name)},className:"px-2 py-1 rounded text-xs font-medium text-accent-error/80 hover:text-accent-error hover:bg-accent-error/10 transition-colors",children:"Remove"})]}):null,He=ge.status==="error"&&ge.error?i.jsx("span",{className:"text-xs text-accent-error truncate max-w-[200px]",title:ge.error,children:ge.error}):null;return i.jsx(z2,{server:ge,expanded:F.has(ge.name),onToggleExpand:Ee,serverToggleEnabled:!ge.config.disabled,onServerToggle:()=>it(ge.name,!ge.config.disabled),tools:ge.tools,onToolToggle:ie=>{var xe;return Ie(ge.name,ie,!((xe=ge.tools.find(se=>se.name===ie))!=null&&xe.enabled))},statusDot:Ky(ge.status),statusColor:qy(ge.status),actions:i.jsxs(i.Fragment,{children:[He,Fe]})},ge.name)})}),U&&i.jsx(Tt,{isOpen:U,onClose:()=>{V(!1),Y("")},title:"Add MCP Server",size:"sm",children:i.jsxs("div",{className:"space-y-3",children:[i.jsx(Fr,{label:"Name",value:B.name,onChange:ge=>q({...B,name:ge}),placeholder:"e.g. filesystem"}),i.jsx(Pw,{formData:B,onChange:q}),$&&i.jsx(Fo,{message:$}),i.jsx(Bw,{saving:K,saveLabel:"Add",savingLabel:"Adding...",onCancel:()=>{V(!1),Y(""),P(!1),q(Me)},onSave:ke})]})}),Z!==null&&i.jsx(Tt,{isOpen:!0,onClose:()=>{ee(null),Y("")},title:`Edit MCP Server: ${Z}`,size:"sm",children:i.jsxs("div",{className:"space-y-3",children:[i.jsx(Pw,{formData:B,onChange:q}),$&&i.jsx(Fo,{message:$}),i.jsx(Bw,{saving:K,saveLabel:"Save",savingLabel:"Saving...",onCancel:()=>{ee(null),Y(""),P(!1),q(Me)},onSave:Xe})]})})]})]})}const H2="openfox_user_plugins";function AH(e){const t=e.match(/github\.com\/([^/]+)\/([^/]+?)(?:\/|$)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,"")}:null}async function Lg(e){const t=AH(e);if(!t)return null;try{const n=await fetch(`https://api.github.com/repos/${t.owner}/${t.repo}/releases/latest`,{signal:AbortSignal.timeout(5e3)});return n.ok?(await n.json()).tag_name??null:null}catch{return null}}function Ld(){try{return JSON.parse(localStorage.getItem(H2)??"[]")}catch{return[]}}function $w(e){localStorage.setItem(H2,JSON.stringify(e))}function LH({onAdd:e}){const[t,n]=N.useState(""),[r,a]=N.useState(""),[l,u]=N.useState(!1),c=d=>{d.preventDefault(),!(!t.trim()||!r.trim())&&(e({name:t.trim(),displayName:t.trim(),description:"User-added plugin",githubUrl:r.trim()}),n(""),a(""),u(!0),setTimeout(()=>u(!1),2e3))};return i.jsxs("form",{onSubmit:c,className:"flex gap-2 items-end",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),i.jsx("input",{type:"text",value:t,onChange:d=>n(d.target.value),placeholder:"my-plugin",className:"w-full px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded"})]}),i.jsxs("div",{className:"flex-[2]",children:[i.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"GitHub URL"}),i.jsx("input",{type:"text",value:r,onChange:d=>a(d.target.value),placeholder:"https://github.com/user/repo",className:"w-full px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded"})]}),i.jsx(mt,{type:"submit",variant:"primary",size:"sm",children:l?"Added":"Add"})]})}function DH({plugin:e,initiallyInstalled:t,installedVersion:n,onRemove:r,onOpenFolder:a}){const[l,u]=N.useState(t?"installed":"idle"),[c,d]=N.useState(!1),[h,p]=N.useState(""),[m,x]=N.useState(n),[y,S]=N.useState(!1),[C,v]=N.useState(!1);N.useEffect(()=>{x(n)},[n]);const w=N.useCallback(async()=>{const M=await Ce("/api/plugins/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({githubUrl:e.githubUrl})}),W=await M.json();if(M.ok)u("installed"),e.latestVersion&&x(e.latestVersion),W.loaded||p(W.loadError??"Plugin installed but failed to load");else throw new Error(W.error??"Install failed")},[e.githubUrl,e.name]),_=async()=>{u("installing"),p("");try{await w()}catch(M){u("error"),p(M instanceof Error?M.message:"Connection error")}},b=()=>{S(!0)},k=async()=>{v(!0);try{(await Ce(`/api/plugins/${e.name}`,{method:"DELETE"})).ok&&(u("idle"),r(e.name))}catch{}v(!1),S(!1)},E=async()=>{d(!0),p("");try{await w()}catch(M){p(M instanceof Error?M.message:"Update failed")}d(!1)},T=m??n,D=e.latestVersion&&T&&T!=="unknown"&&e.latestVersion!==T,L=l==="installing"?"Installing…":c?"Updating…":l==="installed"?"Installed ✓":"Install",R=l==="installing"||l==="installed"||c;return i.jsxs("div",{className:"border border-border rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-start justify-between gap-4",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:e.displayName}),i.jsxs("span",{className:"text-xs text-text-muted",children:["(",e.name,")"]})]}),i.jsx("p",{className:"text-xs text-text-muted mt-1",children:e.description}),i.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs",children:[e.githubUrl&&i.jsx("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer",className:"text-accent-primary hover:underline",children:"GitHub"}),e.versionLoading?i.jsx("span",{className:"text-text-muted",children:"Loading version…"}):e.latestVersion?i.jsxs("span",{className:"text-text-muted",children:["v",e.latestVersion]}):null,T&&T!=="unknown"&&i.jsxs("span",{className:"text-text-muted",children:["installed: v",T]})]}),l==="error"&&h&&i.jsx("p",{className:"text-xs text-accent-error mt-1",children:h})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1",children:[i.jsxs("div",{className:"flex gap-1",children:[e.githubUrl&&i.jsx(mt,{variant:l==="installed"?"secondary":"primary",size:"sm",onClick:_,disabled:R,children:L}),D&&i.jsx(mt,{variant:"primary",size:"sm",onClick:E,children:"Update"}),l==="installed"&&i.jsx(mt,{variant:"danger",size:"sm",onClick:b,children:"Remove"})]}),l==="installed"&&i.jsx("button",{onClick:()=>a(e.name),className:"text-xs text-accent-primary hover:underline",children:"Open folder"})]})]}),i.jsx(Oc,{isOpen:y,onClose:()=>S(!1),onConfirm:k,title:`Remove "${e.displayName}"?`,message:`Remove the "${e.displayName}" plugin from your installation.`,confirmLabel:"Remove",confirmVariant:"danger",disabled:C})]})}function RH(){const[e,t]=N.useState([]),[n,r]=N.useState([]),[a,l]=N.useState({}),[u,c]=N.useState(!0),[d,h]=N.useState(""),[p,m]=N.useState("");N.useEffect(()=>{let w=!1;Promise.all([Ce("/api/plugins/registry").then(b=>{if(!b.ok)throw new Error(`HTTP ${b.status}`);return b.json()}),Ce("/api/plugins/installed").then(b=>b.ok?b.json():{installed:[]})]).then(([b,k])=>{if(w)return;const E={},T=k.installed;for(const W of T)E[W.name]=W.version;l(E);const D=b.plugins.map(W=>({...W,latestVersion:null,versionLoading:!0}));t(D),D.forEach(W=>{Lg(W.githubUrl).then(z=>{w||t(H=>H.map(I=>I.name===W.name?{...I,latestVersion:z,versionLoading:!1}:I))})});const L=new Set(D.map(W=>W.name)),R=Ld(),M=[];for(const W of T)!L.has(W.name)&&!R.some(z=>z.name===W.name)&&M.push({name:W.name,displayName:W.name,description:"Found on disk",githubUrl:"",latestVersion:null,versionLoading:!1});M.length>0&&r(W=>[...W,...M])}).catch(b=>{w||h(b instanceof Error?b.message:"Failed to load plugins")}).finally(()=>{w||c(!1)});const _=Ld();return _.length>0&&(r(_.map(b=>({...b,latestVersion:null,versionLoading:!0}))),_.forEach(b=>{Lg(b.githubUrl).then(k=>{w||r(E=>E.map(T=>T.name===b.name?{...T,latestVersion:k,versionLoading:!1}:T))})})),()=>{w=!0}},[]);const x=async w=>{try{w?await Ce(`/api/plugins/${w}/open-folder`):await Ce("/api/plugins/open-folder")}catch{}},y=N.useCallback(w=>{l(k=>{const E={...k};return delete E[w],E});const _=Ld(),b=_.filter(k=>k.name!==w);b.length!==_.length&&$w(b),r(k=>k.filter(E=>E.name!==w))},[]),S=N.useCallback(w=>{if(new Set(e.map(k=>k.name)).has(w.name)){m(`"${w.displayName}" is already listed in the registry and won't be added again.`);return}const b=Ld();$w([...b,w]),r(k=>[...k,{...w,latestVersion:null,versionLoading:!0}]),Lg(w.githubUrl).then(k=>{r(E=>E.map(T=>T.name===w.name?{...T,latestVersion:k,versionLoading:!1}:T))})},[e]),C=new Set,v=[...e,...n].filter(w=>C.has(w.name)?!1:(C.add(w.name),!0));return u?i.jsx("div",{className:"text-sm text-text-muted",children:"Loading plugins..."}):i.jsxs("div",{className:"space-y-4",children:[d&&i.jsxs("div",{className:"text-sm text-accent-error bg-accent-error/10 border border-accent-error/30 rounded-lg p-3",children:["Failed to load plugin registry: ",d]}),p&&i.jsxs("div",{className:"text-sm text-accent-warning bg-accent-warning/10 border border-accent-warning/30 rounded-lg p-3 flex justify-between items-center",children:[i.jsx("span",{children:p}),i.jsx("button",{onClick:()=>m(""),className:"text-text-muted hover:text-text-primary ml-2",children:"×"})]}),i.jsxs("div",{className:"border border-border rounded-lg p-4",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Add Plugin"}),i.jsx(LH,{onAdd:S})]}),v.length===0&&!d&&i.jsx("div",{className:"text-sm text-text-muted",children:"No plugins found."}),v.map(w=>i.jsx(DH,{plugin:w,initiallyInstalled:w.name in a,installedVersion:a[w.name]??null,onRemove:y,onOpenFolder:x},w.name))]})}function OH({isOpen:e,onClose:t}){const[n,r]=N.useState("instructions"),a=ei(u=>u.status==="available"),l=()=>{try{Pt.send("context.checkDynamic",{})}catch{}t()};return i.jsx(Tt,{isOpen:e,onClose:l,title:"Settings",size:"xl",scrollable:!1,children:i.jsxs("div",{"data-global-settings":!0,className:"flex flex-col h-full min-h-0 -m-4",children:[i.jsxs(Ze,{horizontal:!0,options:{scrollbars:{visibility:"hidden"}},className:"flex border-b border-border mb-4 flex-shrink-0 px-4 pt-4",children:[i.jsx(Ai,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),i.jsx(Ai,{label:"Tools",active:n==="tools",onClick:()=>r("tools")}),i.jsx(Ai,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),i.jsx(Ai,{label:"Plugins",active:n==="plugins",onClick:()=>r("plugins")}),i.jsx(Ai,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),i.jsx(Ai,{label:"Display",active:n==="display",onClick:()=>r("display")}),i.jsx(Ai,{label:"Keybindings",active:n==="keybindings",onClick:()=>r("keybindings")}),i.jsx(Ai,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced"),showDot:a})]}),i.jsxs(Ze,{className:"flex-1 min-h-0 px-4 pb-4",children:[n==="instructions"&&i.jsx(p3,{isOpen:e}),n==="skills"&&i.jsx(m3,{isOpen:e}),n==="plugins"&&i.jsx(RH,{}),n==="notifications"&&i.jsx(s3,{}),n==="display"&&i.jsx(T3,{}),n==="keybindings"&&i.jsx(NH,{}),n==="tools"&&i.jsx(TH,{}),n==="advanced"&&i.jsx(kH,{onClose:t})]})]})})}function Ai({label:e,active:t,onClick:n,showDot:r}){return i.jsxs("button",{onClick:n,className:`relative px-4 py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${t?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:[e,r&&i.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]})}var Dg={exports:{}},zw;function IH(){return zw||(zw=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(u,c,d){var h=this&&this.__decorate||function(_,b,k,E){var T,D=arguments.length,L=D<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(_,b,k,E);else for(var R=_.length-1;R>=0;R--)(T=_[R])&&(L=(D<3?T(L):D>3?T(b,k,L):T(b,k))||L);return D>3&&L&&Object.defineProperty(b,k,L),L},p=this&&this.__param||function(_,b){return function(k,E){b(k,E,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.AccessibilityManager=void 0;const m=d(9042),x=d(9924),y=d(844),S=d(4725),C=d(2585),v=d(3656);let w=c.AccessibilityManager=class extends y.Disposable{constructor(_,b,k,E){super(),this._terminal=_,this._coreBrowserService=k,this._renderService=E,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let T=0;T<this._terminal.rows;T++)this._rowElements[T]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[T]);if(this._topBoundaryFocusListener=T=>this._handleBoundaryFocus(T,0),this._bottomBoundaryFocusListener=T=>this._handleBoundaryFocus(T,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((T=>this._handleResize(T.rows)))),this.register(this._terminal.onRender((T=>this._refreshRows(T.start,T.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((T=>this._handleChar(T)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
254
|
+
`)))),this.register(this._terminal.onA11yTab((T=>this._handleTab(T)))),this.register(this._terminal.onKey((T=>this._handleKey(T.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,v.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(_){for(let b=0;b<_;b++)this._handleChar(" ")}_handleChar(_){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==_&&(this._charsToAnnounce+=_):this._charsToAnnounce+=_,_===`
|
|
255
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=m.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(_){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(_)||this._charsToConsume.push(_)}_refreshRows(_,b){this._liveRegionDebouncer.refresh(_,b,this._terminal.rows)}_renderRows(_,b){const k=this._terminal.buffer,E=k.lines.length.toString();for(let T=_;T<=b;T++){const D=k.lines.get(k.ydisp+T),L=[],R=(D==null?void 0:D.translateToString(!0,void 0,void 0,L))||"",M=(k.ydisp+T+1).toString(),W=this._rowElements[T];W&&(R.length===0?(W.innerText=" ",this._rowColumns.set(W,[0,1])):(W.textContent=R,this._rowColumns.set(W,L)),W.setAttribute("aria-posinset",M),W.setAttribute("aria-setsize",E))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(_,b){const k=_.target,E=this._rowElements[b===0?1:this._rowElements.length-2];if(k.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||_.relatedTarget!==E)return;let T,D;if(b===0?(T=k,D=this._rowElements.pop(),this._rowContainer.removeChild(D)):(T=this._rowElements.shift(),D=k,this._rowContainer.removeChild(T)),T.removeEventListener("focus",this._topBoundaryFocusListener),D.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const L=this._createAccessibilityTreeNode();this._rowElements.unshift(L),this._rowContainer.insertAdjacentElement("afterbegin",L)}else{const L=this._createAccessibilityTreeNode();this._rowElements.push(L),this._rowContainer.appendChild(L)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(b===0?-1:1),this._rowElements[b===0?1:this._rowElements.length-2].focus(),_.preventDefault(),_.stopImmediatePropagation()}_handleSelectionChange(){var R;if(this._rowElements.length===0)return;const _=document.getSelection();if(!_)return;if(_.isCollapsed)return void(this._rowContainer.contains(_.anchorNode)&&this._terminal.clearSelection());if(!_.anchorNode||!_.focusNode)return void console.error("anchorNode and/or focusNode are null");let b={node:_.anchorNode,offset:_.anchorOffset},k={node:_.focusNode,offset:_.focusOffset};if((b.node.compareDocumentPosition(k.node)&Node.DOCUMENT_POSITION_PRECEDING||b.node===k.node&&b.offset>k.offset)&&([b,k]=[k,b]),b.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(b={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(b.node))return;const E=this._rowElements.slice(-1)[0];if(k.node.compareDocumentPosition(E)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(k={node:E,offset:((R=E.textContent)==null?void 0:R.length)??0}),!this._rowContainer.contains(k.node))return;const T=({node:M,offset:W})=>{const z=M instanceof Text?M.parentNode:M;let H=parseInt(z==null?void 0:z.getAttribute("aria-posinset"),10)-1;if(isNaN(H))return console.warn("row is invalid. Race condition?"),null;const I=this._rowColumns.get(z);if(!I)return console.warn("columns is null. Race condition?"),null;let U=W<I.length?I[W]:I.slice(-1)[0]+1;return U>=this._terminal.cols&&(++H,U=0),{row:H,column:U}},D=T(b),L=T(k);if(D&&L){if(D.row>L.row||D.row===L.row&&D.column>=L.column)throw new Error("invalid range");this._terminal.select(D.column,D.row,(L.row-D.row)*this._terminal.cols-D.column+L.column)}}_handleResize(_){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let b=this._rowContainer.children.length;b<this._terminal.rows;b++)this._rowElements[b]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[b]);for(;this._rowElements.length>_;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const _=this._coreBrowserService.mainDocument.createElement("div");return _.setAttribute("role","listitem"),_.tabIndex=-1,this._refreshRowDimensions(_),_}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let _=0;_<this._terminal.rows;_++)this._refreshRowDimensions(this._rowElements[_])}}_refreshRowDimensions(_){_.style.height=`${this._renderService.dimensions.css.cell.height}px`}};c.AccessibilityManager=w=h([p(1,C.IInstantiationService),p(2,S.ICoreBrowserService),p(3,S.IRenderService)],w)},3614:(u,c)=>{function d(x){return x.replace(/\r?\n/g,"\r")}function h(x,y){return y?"\x1B[200~"+x+"\x1B[201~":x}function p(x,y,S,C){x=h(x=d(x),S.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),S.triggerDataEvent(x,!0),y.value=""}function m(x,y,S){const C=S.getBoundingClientRect(),v=x.clientX-C.left-10,w=x.clientY-C.top-10;y.style.width="20px",y.style.height="20px",y.style.left=`${v}px`,y.style.top=`${w}px`,y.style.zIndex="1000",y.focus()}Object.defineProperty(c,"__esModule",{value:!0}),c.rightClickHandler=c.moveTextAreaUnderMouseCursor=c.paste=c.handlePasteEvent=c.copyHandler=c.bracketTextForPaste=c.prepareTextForTerminal=void 0,c.prepareTextForTerminal=d,c.bracketTextForPaste=h,c.copyHandler=function(x,y){x.clipboardData&&x.clipboardData.setData("text/plain",y.selectionText),x.preventDefault()},c.handlePasteEvent=function(x,y,S,C){x.stopPropagation(),x.clipboardData&&p(x.clipboardData.getData("text/plain"),y,S,C)},c.paste=p,c.moveTextAreaUnderMouseCursor=m,c.rightClickHandler=function(x,y,S,C,v){m(x,y,S),v&&C.rightClickSelect(x),y.value=C.selectionText,y.select()}},7239:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorContrastCache=void 0;const h=d(1505);c.ColorContrastCache=class{constructor(){this._color=new h.TwoKeyMap,this._css=new h.TwoKeyMap}setCss(p,m,x){this._css.set(p,m,x)}getCss(p,m){return this._css.get(p,m)}setColor(p,m,x){this._color.set(p,m,x)}getColor(p,m){return this._color.get(p,m)}clear(){this._color.clear(),this._css.clear()}}},3656:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.addDisposableDomListener=void 0,c.addDisposableDomListener=function(d,h,p,m){d.addEventListener(h,p,m);let x=!1;return{dispose:()=>{x||(x=!0,d.removeEventListener(h,p,m))}}}},3551:function(u,c,d){var h=this&&this.__decorate||function(w,_,b,k){var E,T=arguments.length,D=T<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,b):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(w,_,b,k);else for(var L=w.length-1;L>=0;L--)(E=w[L])&&(D=(T<3?E(D):T>3?E(_,b,D):E(_,b))||D);return T>3&&D&&Object.defineProperty(_,b,D),D},p=this&&this.__param||function(w,_){return function(b,k){_(b,k,w)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Linkifier=void 0;const m=d(3656),x=d(8460),y=d(844),S=d(2585),C=d(4725);let v=c.Linkifier=class extends y.Disposable{get currentLink(){return this._currentLink}constructor(w,_,b,k,E){super(),this._element=w,this._mouseService=_,this._renderService=b,this._bufferService=k,this._linkProviderService=E,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new x.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new x.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,y.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,y.toDisposable)((()=>{var T;this._lastMouseEvent=void 0,(T=this._activeProviderReplies)==null||T.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,m.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,m.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(w){this._lastMouseEvent=w;const _=this._positionFromMouseEvent(w,this._element,this._mouseService);if(!_)return;this._isMouseOut=!1;const b=w.composedPath();for(let k=0;k<b.length;k++){const E=b[k];if(E.classList.contains("xterm"))break;if(E.classList.contains("xterm-hover"))return}this._lastBufferCell&&_.x===this._lastBufferCell.x&&_.y===this._lastBufferCell.y||(this._handleHover(_),this._lastBufferCell=_)}_handleHover(w){if(this._activeLine!==w.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(w,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,w)||(this._clearCurrentLink(),this._askForLink(w,!0))}_askForLink(w,_){var k,E;this._activeProviderReplies&&_||((k=this._activeProviderReplies)==null||k.forEach((T=>{T==null||T.forEach((D=>{D.link.dispose&&D.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=w.y);let b=!1;for(const[T,D]of this._linkProviderService.linkProviders.entries())_?(E=this._activeProviderReplies)!=null&&E.get(T)&&(b=this._checkLinkProviderResult(T,w,b)):D.provideLinks(w.y,(L=>{var M,W;if(this._isMouseOut)return;const R=L==null?void 0:L.map((z=>({link:z})));(M=this._activeProviderReplies)==null||M.set(T,R),b=this._checkLinkProviderResult(T,w,b),((W=this._activeProviderReplies)==null?void 0:W.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(w.y,this._activeProviderReplies)}))}_removeIntersectingLinks(w,_){const b=new Set;for(let k=0;k<_.size;k++){const E=_.get(k);if(E)for(let T=0;T<E.length;T++){const D=E[T],L=D.link.range.start.y<w?0:D.link.range.start.x,R=D.link.range.end.y>w?this._bufferService.cols:D.link.range.end.x;for(let M=L;M<=R;M++){if(b.has(M)){E.splice(T--,1);break}b.add(M)}}}}_checkLinkProviderResult(w,_,b){var T;if(!this._activeProviderReplies)return b;const k=this._activeProviderReplies.get(w);let E=!1;for(let D=0;D<w;D++)this._activeProviderReplies.has(D)&&!this._activeProviderReplies.get(D)||(E=!0);if(!E&&k){const D=k.find((L=>this._linkAtPosition(L.link,_)));D&&(b=!0,this._handleNewLink(D))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!b)for(let D=0;D<this._activeProviderReplies.size;D++){const L=(T=this._activeProviderReplies.get(D))==null?void 0:T.find((R=>this._linkAtPosition(R.link,_)));if(L){b=!0,this._handleNewLink(L);break}}return b}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(w){if(!this._currentLink)return;const _=this._positionFromMouseEvent(w,this._element,this._mouseService);_&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,_)&&this._currentLink.link.activate(w,this._currentLink.link.text)}_clearCurrentLink(w,_){this._currentLink&&this._lastMouseEvent&&(!w||!_||this._currentLink.link.range.start.y>=w&&this._currentLink.link.range.end.y<=_)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,y.disposeArray)(this._linkCacheDisposables))}_handleNewLink(w){if(!this._lastMouseEvent)return;const _=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);_&&this._linkAtPosition(w.link,_)&&(this._currentLink=w,this._currentLink.state={decorations:{underline:w.link.decorations===void 0||w.link.decorations.underline,pointerCursor:w.link.decorations===void 0||w.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,w.link,this._lastMouseEvent),w.link.decorations={},Object.defineProperties(w.link.decorations,{pointerCursor:{get:()=>{var b,k;return(k=(b=this._currentLink)==null?void 0:b.state)==null?void 0:k.decorations.pointerCursor},set:b=>{var k;(k=this._currentLink)!=null&&k.state&&this._currentLink.state.decorations.pointerCursor!==b&&(this._currentLink.state.decorations.pointerCursor=b,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",b))}},underline:{get:()=>{var b,k;return(k=(b=this._currentLink)==null?void 0:b.state)==null?void 0:k.decorations.underline},set:b=>{var k,E,T;(k=this._currentLink)!=null&&k.state&&((T=(E=this._currentLink)==null?void 0:E.state)==null?void 0:T.decorations.underline)!==b&&(this._currentLink.state.decorations.underline=b,this._currentLink.state.isHovered&&this._fireUnderlineEvent(w.link,b))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((b=>{if(!this._currentLink)return;const k=b.start===0?0:b.start+1+this._bufferService.buffer.ydisp,E=this._bufferService.buffer.ydisp+1+b.end;if(this._currentLink.link.range.start.y>=k&&this._currentLink.link.range.end.y<=E&&(this._clearCurrentLink(k,E),this._lastMouseEvent)){const T=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);T&&this._askForLink(T,!1)}}))))}_linkHover(w,_,b){var k;(k=this._currentLink)!=null&&k.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(_,!0),this._currentLink.state.decorations.pointerCursor&&w.classList.add("xterm-cursor-pointer")),_.hover&&_.hover(b,_.text)}_fireUnderlineEvent(w,_){const b=w.range,k=this._bufferService.buffer.ydisp,E=this._createLinkUnderlineEvent(b.start.x-1,b.start.y-k-1,b.end.x,b.end.y-k-1,void 0);(_?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(E)}_linkLeave(w,_,b){var k;(k=this._currentLink)!=null&&k.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(_,!1),this._currentLink.state.decorations.pointerCursor&&w.classList.remove("xterm-cursor-pointer")),_.leave&&_.leave(b,_.text)}_linkAtPosition(w,_){const b=w.range.start.y*this._bufferService.cols+w.range.start.x,k=w.range.end.y*this._bufferService.cols+w.range.end.x,E=_.y*this._bufferService.cols+_.x;return b<=E&&E<=k}_positionFromMouseEvent(w,_,b){const k=b.getCoords(w,_,this._bufferService.cols,this._bufferService.rows);if(k)return{x:k[0],y:k[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(w,_,b,k,E){return{x1:w,y1:_,x2:b,y2:k,cols:this._bufferService.cols,fg:E}}};c.Linkifier=v=h([p(1,C.IMouseService),p(2,C.IRenderService),p(3,S.IBufferService),p(4,C.ILinkProviderService)],v)},9042:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.tooMuchOutput=c.promptLabel=void 0,c.promptLabel="Terminal input",c.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(u,c,d){var h=this&&this.__decorate||function(C,v,w,_){var b,k=arguments.length,E=k<3?v:_===null?_=Object.getOwnPropertyDescriptor(v,w):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,v,w,_);else for(var T=C.length-1;T>=0;T--)(b=C[T])&&(E=(k<3?b(E):k>3?b(v,w,E):b(v,w))||E);return k>3&&E&&Object.defineProperty(v,w,E),E},p=this&&this.__param||function(C,v){return function(w,_){v(w,_,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkProvider=void 0;const m=d(511),x=d(2585);let y=c.OscLinkProvider=class{constructor(C,v,w){this._bufferService=C,this._optionsService=v,this._oscLinkService=w}provideLinks(C,v){var R;const w=this._bufferService.buffer.lines.get(C-1);if(!w)return void v(void 0);const _=[],b=this._optionsService.rawOptions.linkHandler,k=new m.CellData,E=w.getTrimmedLength();let T=-1,D=-1,L=!1;for(let M=0;M<E;M++)if(D!==-1||w.hasContent(M)){if(w.loadCell(M,k),k.hasExtendedAttrs()&&k.extended.urlId){if(D===-1){D=M,T=k.extended.urlId;continue}L=k.extended.urlId!==T}else D!==-1&&(L=!0);if(L||D!==-1&&M===E-1){const W=(R=this._oscLinkService.getLinkData(T))==null?void 0:R.uri;if(W){const z={start:{x:D+1,y:C},end:{x:M+(L||M!==E-1?0:1),y:C}};let H=!1;if(!(b!=null&&b.allowNonHttpProtocols))try{const I=new URL(W);["http:","https:"].includes(I.protocol)||(H=!0)}catch{H=!0}H||_.push({text:W,range:z,activate:(I,U)=>b?b.activate(I,U,z):S(0,U),hover:(I,U)=>{var V;return(V=b==null?void 0:b.hover)==null?void 0:V.call(b,I,U,z)},leave:(I,U)=>{var V;return(V=b==null?void 0:b.leave)==null?void 0:V.call(b,I,U,z)}})}L=!1,k.hasExtendedAttrs()&&k.extended.urlId?(D=M,T=k.extended.urlId):(D=-1,T=-1)}}v(_)}};function S(C,v){if(confirm(`Do you want to navigate to ${v}?
|
|
256
|
+
|
|
257
|
+
WARNING: This link could potentially be dangerous`)){const w=window.open();if(w){try{w.opener=null}catch{}w.location.href=v}else console.warn("Opening link blocked as opener could not be cleared")}}c.OscLinkProvider=y=h([p(0,x.IBufferService),p(1,x.IOptionsService),p(2,x.IOscLinkService)],y)},6193:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.RenderDebouncer=void 0,c.RenderDebouncer=class{constructor(d,h){this._renderCallback=d,this._coreBrowserService=h,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(d){return this._refreshCallbacks.push(d),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(d,h,p){this._rowCount=p,d=d!==void 0?d:0,h=h!==void 0?h:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,d):d,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,h):h,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)return void this._runRefreshCallbacks();const d=Math.max(this._rowStart,0),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,h),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const d of this._refreshCallbacks)d(0);this._refreshCallbacks=[]}}},3236:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Terminal=void 0;const h=d(3614),p=d(3656),m=d(3551),x=d(9042),y=d(3730),S=d(1680),C=d(3107),v=d(5744),w=d(2950),_=d(1296),b=d(428),k=d(4269),E=d(5114),T=d(8934),D=d(3230),L=d(9312),R=d(4725),M=d(6731),W=d(8055),z=d(8969),H=d(8460),I=d(844),U=d(6114),V=d(8437),Z=d(2584),ee=d(7399),F=d(5941),O=d(9074),B=d(2585),q=d(5435),$=d(4567),Y=d(779);class Q extends z.CoreTerminal{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}constructor(K={}){super(K),this.browser=U,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new I.MutableDisposable),this._onCursorMove=this.register(new H.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new H.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new H.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new H.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new H.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new H.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new H.EventEmitter),this._onBlur=this.register(new H.EventEmitter),this._onA11yCharEmitter=this.register(new H.EventEmitter),this._onA11yTabEmitter=this.register(new H.EventEmitter),this._onWillOpen=this.register(new H.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(O.DecorationService),this._instantiationService.setService(B.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Y.LinkProviderService),this._instantiationService.setService(R.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(y.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((P,J)=>this.refresh(P,J)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((P=>this._reportWindowsOptions(P)))),this.register(this._inputHandler.onColor((P=>this._handleColorEvent(P)))),this.register((0,H.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,H.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,H.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,H.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((P=>this._afterResize(P.cols,P.rows)))),this.register((0,I.toDisposable)((()=>{var P,J;this._customKeyEventHandler=void 0,(J=(P=this.element)==null?void 0:P.parentNode)==null||J.removeChild(this.element)})))}_handleColorEvent(K){if(this._themeService)for(const P of K){let J,ne="";switch(P.index){case 256:J="foreground",ne="10";break;case 257:J="background",ne="11";break;case 258:J="cursor",ne="12";break;default:J="ansi",ne="4;"+P.index}switch(P.type){case 0:const ce=W.color.toColorRGB(J==="ansi"?this._themeService.colors.ansi[P.index]:this._themeService.colors[J]);this.coreService.triggerDataEvent(`${Z.C0.ESC}]${ne};${(0,F.toRgbString)(ce)}${Z.C1_ESCAPED.ST}`);break;case 1:if(J==="ansi")this._themeService.modifyColors((ae=>ae.ansi[P.index]=W.channels.toColor(...P.color)));else{const ae=J;this._themeService.modifyColors((Ee=>Ee[ae]=W.channels.toColor(...P.color)))}break;case 2:this._themeService.restoreColor(P.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(K){K?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance($.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(K){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Z.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var K;return(K=this.textarea)==null?void 0:K.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Z.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const K=this.buffer.ybase+this.buffer.y,P=this.buffer.lines.get(K);if(!P)return;const J=Math.min(this.buffer.x,this.cols-1),ne=this._renderService.dimensions.css.cell.height,ce=P.getWidth(J),ae=this._renderService.dimensions.css.cell.width*ce,Ee=this.buffer.y*this._renderService.dimensions.css.cell.height,ve=J*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ve+"px",this.textarea.style.top=Ee+"px",this.textarea.style.width=ae+"px",this.textarea.style.height=ne+"px",this.textarea.style.lineHeight=ne+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,p.addDisposableDomListener)(this.element,"copy",(P=>{this.hasSelection()&&(0,h.copyHandler)(P,this._selectionService)})));const K=P=>(0,h.handlePasteEvent)(P,this.textarea,this.coreService,this.optionsService);this.register((0,p.addDisposableDomListener)(this.textarea,"paste",K)),this.register((0,p.addDisposableDomListener)(this.element,"paste",K)),U.isFirefox?this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(P=>{P.button===2&&(0,h.rightClickHandler)(P,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,p.addDisposableDomListener)(this.element,"contextmenu",(P=>{(0,h.rightClickHandler)(P,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),U.isLinux&&this.register((0,p.addDisposableDomListener)(this.element,"auxclick",(P=>{P.button===1&&(0,h.moveTextAreaUnderMouseCursor)(P,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,p.addDisposableDomListener)(this.textarea,"keyup",(K=>this._keyUp(K)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keydown",(K=>this._keyDown(K)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keypress",(K=>this._keyPress(K)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionupdate",(K=>this._compositionHelper.compositionupdate(K)))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,p.addDisposableDomListener)(this.textarea,"input",(K=>this._inputEvent(K)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(K){var J;if(!K)throw new Error("Terminal requires a parent element.");if(K.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((J=this.element)==null?void 0:J.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=K.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"),K.appendChild(this.element);const P=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),P.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,p.addDisposableDomListener)(this.screenElement,"mousemove",(ne=>this.updateCursorStyle(ne)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),P.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",x.promptLabel),U.isChromeOS||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._coreBrowserService=this.register(this._instantiationService.createInstance(E.CoreBrowserService,this.textarea,K.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(R.ICoreBrowserService,this._coreBrowserService),this.register((0,p.addDisposableDomListener)(this.textarea,"focus",(ne=>this._handleTextAreaFocus(ne)))),this.register((0,p.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(b.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(R.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(M.ThemeService),this._instantiationService.setService(R.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(k.CharacterJoinerService),this._instantiationService.setService(R.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(D.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(R.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((ne=>this._onRender.fire(ne)))),this.onResize((ne=>this._renderService.resize(ne.cols,ne.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(w.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(T.MouseService),this._instantiationService.setService(R.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(m.Linkifier,this.screenElement)),this.element.appendChild(P);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(S.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((ne=>this.scrollLines(ne.amount,ne.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),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.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(L.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(R.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((ne=>this.scrollLines(ne.amount,ne.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((ne=>this._renderService.handleSelectionChanged(ne.start,ne.end,ne.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((ne=>{this.textarea.value=ne,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((ne=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,p.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(C.BufferDecorationRenderer,this.screenElement)),this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(ne=>this._selectionService.handleMouseDown(ne)))),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($.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(ne=>this._handleScreenReaderModeOptionChange(ne)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(v.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(ne=>{!this._overviewRulerRenderer&&ne&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(v.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(_.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const K=this,P=this.element;function J(ae){const Ee=K._mouseService.getMouseReportCoords(ae,K.screenElement);if(!Ee)return!1;let ve,Le;switch(ae.overrideType||ae.type){case"mousemove":Le=32,ae.buttons===void 0?(ve=3,ae.button!==void 0&&(ve=ae.button<3?ae.button:3)):ve=1&ae.buttons?0:4&ae.buttons?1:2&ae.buttons?2:3;break;case"mouseup":Le=0,ve=ae.button<3?ae.button:3;break;case"mousedown":Le=1,ve=ae.button<3?ae.button:3;break;case"wheel":if(K._customWheelEventHandler&&K._customWheelEventHandler(ae)===!1||K.viewport.getLinesScrolled(ae)===0)return!1;Le=ae.deltaY<0?0:1,ve=4;break;default:return!1}return!(Le===void 0||ve===void 0||ve>4)&&K.coreMouseService.triggerMouseEvent({col:Ee.col,row:Ee.row,x:Ee.x,y:Ee.y,button:ve,action:Le,ctrl:ae.ctrlKey,alt:ae.altKey,shift:ae.shiftKey})}const ne={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ce={mouseup:ae=>(J(ae),ae.buttons||(this._document.removeEventListener("mouseup",ne.mouseup),ne.mousedrag&&this._document.removeEventListener("mousemove",ne.mousedrag)),this.cancel(ae)),wheel:ae=>(J(ae),this.cancel(ae,!0)),mousedrag:ae=>{ae.buttons&&J(ae)},mousemove:ae=>{ae.buttons||J(ae)}};this.register(this.coreMouseService.onProtocolChange((ae=>{ae?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(ae)),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()),8&ae?ne.mousemove||(P.addEventListener("mousemove",ce.mousemove),ne.mousemove=ce.mousemove):(P.removeEventListener("mousemove",ne.mousemove),ne.mousemove=null),16&ae?ne.wheel||(P.addEventListener("wheel",ce.wheel,{passive:!1}),ne.wheel=ce.wheel):(P.removeEventListener("wheel",ne.wheel),ne.wheel=null),2&ae?ne.mouseup||(ne.mouseup=ce.mouseup):(this._document.removeEventListener("mouseup",ne.mouseup),ne.mouseup=null),4&ae?ne.mousedrag||(ne.mousedrag=ce.mousedrag):(this._document.removeEventListener("mousemove",ne.mousedrag),ne.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,p.addDisposableDomListener)(P,"mousedown",(ae=>{if(ae.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(ae))return J(ae),ne.mouseup&&this._document.addEventListener("mouseup",ne.mouseup),ne.mousedrag&&this._document.addEventListener("mousemove",ne.mousedrag),this.cancel(ae)}))),this.register((0,p.addDisposableDomListener)(P,"wheel",(ae=>{if(!ne.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(ae)===!1)return!1;if(!this.buffer.hasScrollback){const Ee=this.viewport.getLinesScrolled(ae);if(Ee===0)return;const ve=Z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(ae.deltaY<0?"A":"B");let Le="";for(let Me=0;Me<Math.abs(Ee);Me++)Le+=ve;return this.coreService.triggerDataEvent(Le,!0),this.cancel(ae,!0)}return this.viewport.handleWheel(ae)?this.cancel(ae):void 0}}),{passive:!1})),this.register((0,p.addDisposableDomListener)(P,"touchstart",(ae=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(ae),this.cancel(ae)}),{passive:!0})),this.register((0,p.addDisposableDomListener)(P,"touchmove",(ae=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(ae)?void 0:this.cancel(ae)}),{passive:!1}))}refresh(K,P){var J;(J=this._renderService)==null||J.refreshRows(K,P)}updateCursorStyle(K){var P;(P=this._selectionService)!=null&&P.shouldColumnSelect(K)?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(K,P,J=0){var ne;J===1?(super.scrollLines(K,P,J),this.refresh(0,this.rows-1)):(ne=this.viewport)==null||ne.scrollLines(K)}paste(K){(0,h.paste)(K,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(K){this._customKeyEventHandler=K}attachCustomWheelEventHandler(K){this._customWheelEventHandler=K}registerLinkProvider(K){return this._linkProviderService.registerLinkProvider(K)}registerCharacterJoiner(K){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const P=this._characterJoinerService.register(K);return this.refresh(0,this.rows-1),P}deregisterCharacterJoiner(K){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(K)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(K){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+K)}registerDecoration(K){return this._decorationService.registerDecoration(K)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(K,P,J){this._selectionService.setSelection(K,P,J)}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(){var K;(K=this._selectionService)==null||K.clearSelection()}selectAll(){var K;(K=this._selectionService)==null||K.selectAll()}selectLines(K,P){var J;(J=this._selectionService)==null||J.selectLines(K,P)}_keyDown(K){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1)return!1;const P=this.browser.isMac&&this.options.macOptionIsMeta&&K.altKey;if(!P&&!this._compositionHelper.keydown(K))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;P||K.key!=="Dead"&&K.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const J=(0,ee.evaluateKeyboardEvent)(K,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(K),J.type===3||J.type===2){const ne=this.rows-1;return this.scrollLines(J.type===2?-ne:ne),this.cancel(K,!0)}return J.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,K)||(J.cancel&&this.cancel(K,!0),!J.key||!!(K.key&&!K.ctrlKey&&!K.altKey&&!K.metaKey&&K.key.length===1&&K.key.charCodeAt(0)>=65&&K.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(J.key!==Z.C0.ETX&&J.key!==Z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:J.key,domEvent:K}),this._showCursor(),this.coreService.triggerDataEvent(J.key,!0),!this.optionsService.rawOptions.screenReaderMode||K.altKey||K.ctrlKey?this.cancel(K,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(K,P){const J=K.isMac&&!this.options.macOptionIsMeta&&P.altKey&&!P.ctrlKey&&!P.metaKey||K.isWindows&&P.altKey&&P.ctrlKey&&!P.metaKey||K.isWindows&&P.getModifierState("AltGraph");return P.type==="keypress"?J:J&&(!P.keyCode||P.keyCode>47)}_keyUp(K){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1||((function(P){return P.keyCode===16||P.keyCode===17||P.keyCode===18})(K)||this.focus(),this.updateCursorStyle(K),this._keyPressHandled=!1)}_keyPress(K){let P;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1)return!1;if(this.cancel(K),K.charCode)P=K.charCode;else if(K.which===null||K.which===void 0)P=K.keyCode;else{if(K.which===0||K.charCode===0)return!1;P=K.which}return!(!P||(K.altKey||K.ctrlKey||K.metaKey)&&!this._isThirdLevelShift(this.browser,K)||(P=String.fromCharCode(P),this._onKey.fire({key:P,domEvent:K}),this._showCursor(),this.coreService.triggerDataEvent(P,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(K){if(K.data&&K.inputType==="insertText"&&(!K.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const P=K.data;return this.coreService.triggerDataEvent(P,!0),this.cancel(K),!0}return!1}resize(K,P){K!==this.cols||P!==this.rows?super.resize(K,P):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(K,P){var J,ne;(J=this._charSizeService)==null||J.measure(),(ne=this.viewport)==null||ne.syncScrollArea(!0)}clear(){var K;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 P=1;P<this.rows;P++)this.buffer.lines.push(this.buffer.getBlankLine(V.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(K=this.viewport)==null||K.reset(),this.refresh(0,this.rows-1)}}reset(){var P,J;this.options.rows=this.rows,this.options.cols=this.cols;const K=this._customKeyEventHandler;this._setup(),super.reset(),(P=this._selectionService)==null||P.reset(),this._decorationService.reset(),(J=this.viewport)==null||J.reset(),this._customKeyEventHandler=K,this.refresh(0,this.rows-1)}clearTextureAtlas(){var K;(K=this._renderService)==null||K.clearTextureAtlas()}_reportFocus(){var K;(K=this.element)!=null&&K.classList.contains("focus")?this.coreService.triggerDataEvent(Z.C0.ESC+"[I"):this.coreService.triggerDataEvent(Z.C0.ESC+"[O")}_reportWindowsOptions(K){if(this._renderService)switch(K){case q.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const P=this._renderService.dimensions.css.canvas.width.toFixed(0),J=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Z.C0.ESC}[4;${J};${P}t`);break;case q.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const ne=this._renderService.dimensions.css.cell.width.toFixed(0),ce=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Z.C0.ESC}[6;${ce};${ne}t`)}}cancel(K,P){if(this.options.cancelEvents||P)return K.preventDefault(),K.stopPropagation(),!1}}c.Terminal=Q},9924:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TimeBasedDebouncer=void 0,c.TimeBasedDebouncer=class{constructor(d,h=1e3){this._renderCallback=d,this._debounceThresholdMS=h,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(d,h,p){this._rowCount=p,d=d!==void 0?d:0,h=h!==void 0?h:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,d):d,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,h):h;const m=Date.now();if(m-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=m,this._innerRefresh();else if(!this._additionalRefreshRequested){const x=m-this._lastRefreshMs,y=this._debounceThresholdMS-x;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),y)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const d=Math.max(this._rowStart,0),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,h)}}},1680:function(u,c,d){var h=this&&this.__decorate||function(w,_,b,k){var E,T=arguments.length,D=T<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,b):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(w,_,b,k);else for(var L=w.length-1;L>=0;L--)(E=w[L])&&(D=(T<3?E(D):T>3?E(_,b,D):E(_,b))||D);return T>3&&D&&Object.defineProperty(_,b,D),D},p=this&&this.__param||function(w,_){return function(b,k){_(b,k,w)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Viewport=void 0;const m=d(3656),x=d(4725),y=d(8460),S=d(844),C=d(2585);let v=c.Viewport=class extends S.Disposable{constructor(w,_,b,k,E,T,D,L){super(),this._viewportElement=w,this._scrollArea=_,this._bufferService=b,this._optionsService=k,this._charSizeService=E,this._renderService=T,this._coreBrowserService=D,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new y.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,m.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((R=>this._activeBuffer=R.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((R=>this._renderDimensions=R))),this._handleThemeChange(L.colors),this.register(L.onChangeColors((R=>this._handleThemeChange(R)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(w){this._viewportElement.style.backgroundColor=w.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(w){if(w)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const _=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==_&&(this._lastRecordedBufferHeight=_,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const w=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==w&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=w),this._refreshAnimationFrame=null}syncScrollArea(w=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(w);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(w)}_handleScroll(w){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const _=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:_,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const w=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(w*(this._smoothScrollState.target-this._smoothScrollState.origin)),w<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(w,_){const b=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(_<0&&this._viewportElement.scrollTop!==0||_>0&&b<this._lastRecordedBufferHeight)||(w.cancelable&&w.preventDefault(),!1)}handleWheel(w){const _=this._getPixelsScrolled(w);return _!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+_:this._smoothScrollState.target+=_,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=_,this._bubbleScroll(w,_))}scrollLines(w){if(w!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const _=w*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+_,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:w,suppressScrollEvent:!1})}_getPixelsScrolled(w){if(w.deltaY===0||w.shiftKey)return 0;let _=this._applyScrollModifier(w.deltaY,w);return w.deltaMode===WheelEvent.DOM_DELTA_LINE?_*=this._currentRowHeight:w.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(_*=this._currentRowHeight*this._bufferService.rows),_}getBufferElements(w,_){var L;let b,k="";const E=[],T=_??this._bufferService.buffer.lines.length,D=this._bufferService.buffer.lines;for(let R=w;R<T;R++){const M=D.get(R);if(!M)continue;const W=(L=D.get(R+1))==null?void 0:L.isWrapped;if(k+=M.translateToString(!W),!W||R===D.length-1){const z=document.createElement("div");z.textContent=k,E.push(z),k.length>0&&(b=z),k=""}}return{bufferElements:E,cursorElement:b}}getLinesScrolled(w){if(w.deltaY===0||w.shiftKey)return 0;let _=this._applyScrollModifier(w.deltaY,w);return w.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(_/=this._currentRowHeight+0,this._wheelPartialScroll+=_,_=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):w.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(_*=this._bufferService.rows),_}_applyScrollModifier(w,_){const b=this._optionsService.rawOptions.fastScrollModifier;return b==="alt"&&_.altKey||b==="ctrl"&&_.ctrlKey||b==="shift"&&_.shiftKey?w*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:w*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(w){this._lastTouchY=w.touches[0].pageY}handleTouchMove(w){const _=this._lastTouchY-w.touches[0].pageY;return this._lastTouchY=w.touches[0].pageY,_!==0&&(this._viewportElement.scrollTop+=_,this._bubbleScroll(w,_))}};c.Viewport=v=h([p(2,C.IBufferService),p(3,C.IOptionsService),p(4,x.ICharSizeService),p(5,x.IRenderService),p(6,x.ICoreBrowserService),p(7,x.IThemeService)],v)},3107:function(u,c,d){var h=this&&this.__decorate||function(C,v,w,_){var b,k=arguments.length,E=k<3?v:_===null?_=Object.getOwnPropertyDescriptor(v,w):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,v,w,_);else for(var T=C.length-1;T>=0;T--)(b=C[T])&&(E=(k<3?b(E):k>3?b(v,w,E):b(v,w))||E);return k>3&&E&&Object.defineProperty(v,w,E),E},p=this&&this.__param||function(C,v){return function(w,_){v(w,_,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferDecorationRenderer=void 0;const m=d(4725),x=d(844),y=d(2585);let S=c.BufferDecorationRenderer=class extends x.Disposable{constructor(C,v,w,_,b){super(),this._screenElement=C,this._bufferService=v,this._coreBrowserService=w,this._decorationService=_,this._renderService=b,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((k=>this._removeDecoration(k)))),this.register((0,x.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const C of this._decorationService.decorations)this._renderDecoration(C);this._dimensionsChanged=!1}_renderDecoration(C){this._refreshStyle(C),this._dimensionsChanged&&this._refreshXPosition(C)}_createElement(C){var _;const v=this._coreBrowserService.mainDocument.createElement("div");v.classList.add("xterm-decoration"),v.classList.toggle("xterm-decoration-top-layer",((_=C==null?void 0:C.options)==null?void 0:_.layer)==="top"),v.style.width=`${Math.round((C.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,v.style.height=(C.options.height||1)*this._renderService.dimensions.css.cell.height+"px",v.style.top=(C.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",v.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const w=C.options.x??0;return w&&w>this._bufferService.cols&&(v.style.display="none"),this._refreshXPosition(C,v),v}_refreshStyle(C){const v=C.marker.line-this._bufferService.buffers.active.ydisp;if(v<0||v>=this._bufferService.rows)C.element&&(C.element.style.display="none",C.onRenderEmitter.fire(C.element));else{let w=this._decorationElements.get(C);w||(w=this._createElement(C),C.element=w,this._decorationElements.set(C,w),this._container.appendChild(w),C.onDispose((()=>{this._decorationElements.delete(C),w.remove()}))),w.style.top=v*this._renderService.dimensions.css.cell.height+"px",w.style.display=this._altBufferIsActive?"none":"block",C.onRenderEmitter.fire(w)}}_refreshXPosition(C,v=C.element){if(!v)return;const w=C.options.x??0;(C.options.anchor||"left")==="right"?v.style.right=w?w*this._renderService.dimensions.css.cell.width+"px":"":v.style.left=w?w*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(C){var v;(v=this._decorationElements.get(C))==null||v.remove(),this._decorationElements.delete(C),C.dispose()}};c.BufferDecorationRenderer=S=h([p(1,y.IBufferService),p(2,m.ICoreBrowserService),p(3,y.IDecorationService),p(4,m.IRenderService)],S)},5871:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorZoneStore=void 0,c.ColorZoneStore=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(d){if(d.options.overviewRulerOptions){for(const h of this._zones)if(h.color===d.options.overviewRulerOptions.color&&h.position===d.options.overviewRulerOptions.position){if(this._lineIntersectsZone(h,d.marker.line))return;if(this._lineAdjacentToZone(h,d.marker.line,d.options.overviewRulerOptions.position))return void this._addLineToZone(h,d.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=d.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=d.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=d.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=d.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:d.options.overviewRulerOptions.color,position:d.options.overviewRulerOptions.position,startBufferLine:d.marker.line,endBufferLine:d.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(d){this._linePadding=d}_lineIntersectsZone(d,h){return h>=d.startBufferLine&&h<=d.endBufferLine}_lineAdjacentToZone(d,h,p){return h>=d.startBufferLine-this._linePadding[p||"full"]&&h<=d.endBufferLine+this._linePadding[p||"full"]}_addLineToZone(d,h){d.startBufferLine=Math.min(d.startBufferLine,h),d.endBufferLine=Math.max(d.endBufferLine,h)}}},5744:function(u,c,d){var h=this&&this.__decorate||function(b,k,E,T){var D,L=arguments.length,R=L<3?k:T===null?T=Object.getOwnPropertyDescriptor(k,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,k,E,T);else for(var M=b.length-1;M>=0;M--)(D=b[M])&&(R=(L<3?D(R):L>3?D(k,E,R):D(k,E))||R);return L>3&&R&&Object.defineProperty(k,E,R),R},p=this&&this.__param||function(b,k){return function(E,T){k(E,T,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OverviewRulerRenderer=void 0;const m=d(5871),x=d(4725),y=d(844),S=d(2585),C={full:0,left:0,center:0,right:0},v={full:0,left:0,center:0,right:0},w={full:0,left:0,center:0,right:0};let _=c.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,k,E,T,D,L,R){var W;super(),this._viewportElement=b,this._screenElement=k,this._bufferService=E,this._decorationService=T,this._renderService=D,this._optionsService=L,this._coreBrowserService=R,this._colorZoneStore=new m.ColorZoneStore,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(),(W=this._viewportElement.parentElement)==null||W.insertBefore(this._canvas,this._viewportElement);const M=this._canvas.getContext("2d");if(!M)throw new Error("Ctx cannot be null");this._ctx=M,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var z;(z=this._canvas)==null||z.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){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())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const b=Math.floor(this._canvas.width/3),k=Math.ceil(this._canvas.width/3);v.full=this._canvas.width,v.left=b,v.center=k,v.right=b,this._refreshDrawHeightConstants(),w.full=0,w.left=0,w.center=v.left,w.right=v.left+v.center}_refreshDrawHeightConstants(){C.full=Math.round(2*this._coreBrowserService.dpr);const b=this._canvas.height/this._bufferService.buffer.lines.length,k=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowserService.dpr);C.left=k,C.center=k,C.right=k}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.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(const k of this._decorationService.decorations)this._colorZoneStore.addDecoration(k);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const k of b)k.position!=="full"&&this._renderColorZone(k);for(const k of b)k.position==="full"&&this._renderColorZone(k);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(b){this._ctx.fillStyle=b.color,this._ctx.fillRect(w[b.position||"full"],Math.round((this._canvas.height-1)*(b.startBufferLine/this._bufferService.buffers.active.lines.length)-C[b.position||"full"]/2),v[b.position||"full"],Math.round((this._canvas.height-1)*((b.endBufferLine-b.startBufferLine)/this._bufferService.buffers.active.lines.length)+C[b.position||"full"]))}_queueRefresh(b,k){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=k||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};c.OverviewRulerRenderer=_=h([p(2,S.IBufferService),p(3,S.IDecorationService),p(4,x.IRenderService),p(5,S.IOptionsService),p(6,x.ICoreBrowserService)],_)},2950:function(u,c,d){var h=this&&this.__decorate||function(C,v,w,_){var b,k=arguments.length,E=k<3?v:_===null?_=Object.getOwnPropertyDescriptor(v,w):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,v,w,_);else for(var T=C.length-1;T>=0;T--)(b=C[T])&&(E=(k<3?b(E):k>3?b(v,w,E):b(v,w))||E);return k>3&&E&&Object.defineProperty(v,w,E),E},p=this&&this.__param||function(C,v){return function(w,_){v(w,_,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CompositionHelper=void 0;const m=d(4725),x=d(2585),y=d(2584);let S=c.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(C,v,w,_,b,k){this._textarea=C,this._compositionView=v,this._bufferService=w,this._optionsService=_,this._coreService=b,this._renderService=k,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(C){this._compositionView.textContent=C.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(C){if(this._isComposing||this._isSendingComposition){if(C.keyCode===229||C.keyCode===16||C.keyCode===17||C.keyCode===18)return!1;this._finalizeComposition(!1)}return C.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(C){if(this._compositionView.classList.remove("active"),this._isComposing=!1,C){const v={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let w;this._isSendingComposition=!1,v.start+=this._dataAlreadySent.length,w=this._isComposing?this._textarea.value.substring(v.start,v.end):this._textarea.value.substring(v.start),w.length>0&&this._coreService.triggerDataEvent(w,!0)}}),0)}else{this._isSendingComposition=!1;const v=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(v,!0)}}_handleAnyTextareaChanges(){const C=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const v=this._textarea.value,w=v.replace(C,"");this._dataAlreadySent=w,v.length>C.length?this._coreService.triggerDataEvent(w,!0):v.length<C.length?this._coreService.triggerDataEvent(`${y.C0.DEL}`,!0):v.length===C.length&&v!==C&&this._coreService.triggerDataEvent(v,!0)}}),0)}updateCompositionElements(C){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const v=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),w=this._renderService.dimensions.css.cell.height,_=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,b=v*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=b+"px",this._compositionView.style.top=_+"px",this._compositionView.style.height=w+"px",this._compositionView.style.lineHeight=w+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const k=this._compositionView.getBoundingClientRect();this._textarea.style.left=b+"px",this._textarea.style.top=_+"px",this._textarea.style.width=Math.max(k.width,1)+"px",this._textarea.style.height=Math.max(k.height,1)+"px",this._textarea.style.lineHeight=k.height+"px"}C||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};c.CompositionHelper=S=h([p(2,x.IBufferService),p(3,x.IOptionsService),p(4,x.ICoreService),p(5,m.IRenderService)],S)},9806:(u,c)=>{function d(h,p,m){const x=m.getBoundingClientRect(),y=h.getComputedStyle(m),S=parseInt(y.getPropertyValue("padding-left")),C=parseInt(y.getPropertyValue("padding-top"));return[p.clientX-x.left-S,p.clientY-x.top-C]}Object.defineProperty(c,"__esModule",{value:!0}),c.getCoords=c.getCoordsRelativeToElement=void 0,c.getCoordsRelativeToElement=d,c.getCoords=function(h,p,m,x,y,S,C,v,w){if(!S)return;const _=d(h,p,m);return _?(_[0]=Math.ceil((_[0]+(w?C/2:0))/C),_[1]=Math.ceil(_[1]/v),_[0]=Math.min(Math.max(_[0],1),x+(w?1:0)),_[1]=Math.min(Math.max(_[1],1),y),_):void 0}},9504:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.moveToCellSequence=void 0;const h=d(2584);function p(v,w,_,b){const k=v-m(v,_),E=w-m(w,_),T=Math.abs(k-E)-(function(D,L,R){let M=0;const W=D-m(D,R),z=L-m(L,R);for(let H=0;H<Math.abs(W-z);H++){const I=x(D,L)==="A"?-1:1,U=R.buffer.lines.get(W+I*H);U!=null&&U.isWrapped&&M++}return M})(v,w,_);return C(T,S(x(v,w),b))}function m(v,w){let _=0,b=w.buffer.lines.get(v),k=b==null?void 0:b.isWrapped;for(;k&&v>=0&&v<w.rows;)_++,b=w.buffer.lines.get(--v),k=b==null?void 0:b.isWrapped;return _}function x(v,w){return v>w?"A":"B"}function y(v,w,_,b,k,E){let T=v,D=w,L="";for(;T!==_||D!==b;)T+=k?1:-1,k&&T>E.cols-1?(L+=E.buffer.translateBufferLineToString(D,!1,v,T),T=0,v=0,D++):!k&&T<0&&(L+=E.buffer.translateBufferLineToString(D,!1,0,v+1),T=E.cols-1,v=T,D--);return L+E.buffer.translateBufferLineToString(D,!1,v,T)}function S(v,w){const _=w?"O":"[";return h.C0.ESC+_+v}function C(v,w){v=Math.floor(v);let _="";for(let b=0;b<v;b++)_+=w;return _}c.moveToCellSequence=function(v,w,_,b){const k=_.buffer.x,E=_.buffer.y;if(!_.buffer.hasScrollback)return(function(L,R,M,W,z,H){return p(R,W,z,H).length===0?"":C(y(L,R,L,R-m(R,z),!1,z).length,S("D",H))})(k,E,0,w,_,b)+p(E,w,_,b)+(function(L,R,M,W,z,H){let I;I=p(R,W,z,H).length>0?W-m(W,z):R;const U=W,V=(function(Z,ee,F,O,B,q){let $;return $=p(F,O,B,q).length>0?O-m(O,B):ee,Z<F&&$<=O||Z>=F&&$<O?"C":"D"})(L,R,M,W,z,H);return C(y(L,I,M,U,V==="C",z).length,S(V,H))})(k,E,v,w,_,b);let T;if(E===w)return T=k>v?"D":"C",C(Math.abs(k-v),S(T,b));T=E>w?"D":"C";const D=Math.abs(E-w);return C((function(L,R){return R.cols-L})(E>w?v:k,_)+(D-1)*_.cols+1+((E>w?k:v)-1),S(T,b))}},1296:function(u,c,d){var h=this&&this.__decorate||function(H,I,U,V){var Z,ee=arguments.length,F=ee<3?I:V===null?V=Object.getOwnPropertyDescriptor(I,U):V;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(H,I,U,V);else for(var O=H.length-1;O>=0;O--)(Z=H[O])&&(F=(ee<3?Z(F):ee>3?Z(I,U,F):Z(I,U))||F);return ee>3&&F&&Object.defineProperty(I,U,F),F},p=this&&this.__param||function(H,I){return function(U,V){I(U,V,H)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRenderer=void 0;const m=d(3787),x=d(2550),y=d(2223),S=d(6171),C=d(6052),v=d(4725),w=d(8055),_=d(8460),b=d(844),k=d(2585),E="xterm-dom-renderer-owner-",T="xterm-rows",D="xterm-fg-",L="xterm-bg-",R="xterm-focus",M="xterm-selection";let W=1,z=c.DomRenderer=class extends b.Disposable{constructor(H,I,U,V,Z,ee,F,O,B,q,$,Y,Q){super(),this._terminal=H,this._document=I,this._element=U,this._screenElement=V,this._viewportElement=Z,this._helperContainer=ee,this._linkifier2=F,this._charSizeService=B,this._optionsService=q,this._bufferService=$,this._coreBrowserService=Y,this._themeService=Q,this._terminalClass=W++,this._rowElements=[],this._selectionRenderModel=(0,C.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new _.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(T),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(M),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,S.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((X=>this._injectCss(X)))),this._injectCss(this._themeService.colors),this._rowFactory=O.createInstance(m.DomRendererRowFactory,document),this._element.classList.add(E+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((X=>this._handleLinkHover(X)))),this.register(this._linkifier2.onHideLinkUnderline((X=>this._handleLinkLeave(X)))),this.register((0,b.toDisposable)((()=>{this._element.classList.remove(E+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new x.WidthCache(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(){const H=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*H,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*H),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/H),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/H),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(const U of this._rowElements)U.style.width=`${this.dimensions.css.canvas.width}px`,U.style.height=`${this.dimensions.css.cell.height}px`,U.style.lineHeight=`${this.dimensions.css.cell.height}px`,U.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const I=`${this._terminalSelector} .${T} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=I,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(H){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let I=`${this._terminalSelector} .${T} { color: ${H.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;I+=`${this._terminalSelector} .${T} .xterm-dim { color: ${w.color.multiplyOpacity(H.foreground,.5).css};}`,I+=`${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;}`;const U=`blink_underline_${this._terminalClass}`,V=`blink_bar_${this._terminalClass}`,Z=`blink_block_${this._terminalClass}`;I+=`@keyframes ${U} { 50% { border-bottom-style: hidden; }}`,I+=`@keyframes ${V} { 50% { box-shadow: none; }}`,I+=`@keyframes ${Z} { 0% { background-color: ${H.cursor.css}; color: ${H.cursorAccent.css}; } 50% { background-color: inherit; color: ${H.cursor.css}; }}`,I+=`${this._terminalSelector} .${T}.${R} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${U} 1s step-end infinite;}${this._terminalSelector} .${T}.${R} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${V} 1s step-end infinite;}${this._terminalSelector} .${T}.${R} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${Z} 1s step-end infinite;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block { background-color: ${H.cursor.css}; color: ${H.cursorAccent.css};}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${H.cursor.css} !important; color: ${H.cursorAccent.css} !important;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${H.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${H.cursor.css} inset;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${H.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,I+=`${this._terminalSelector} .${M} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${M} div { position: absolute; background-color: ${H.selectionBackgroundOpaque.css};}${this._terminalSelector} .${M} div { position: absolute; background-color: ${H.selectionInactiveBackgroundOpaque.css};}`;for(const[ee,F]of H.ansi.entries())I+=`${this._terminalSelector} .${D}${ee} { color: ${F.css}; }${this._terminalSelector} .${D}${ee}.xterm-dim { color: ${w.color.multiplyOpacity(F,.5).css}; }${this._terminalSelector} .${L}${ee} { background-color: ${F.css}; }`;I+=`${this._terminalSelector} .${D}${y.INVERTED_DEFAULT_COLOR} { color: ${w.color.opaque(H.background).css}; }${this._terminalSelector} .${D}${y.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${w.color.multiplyOpacity(w.color.opaque(H.background),.5).css}; }${this._terminalSelector} .${L}${y.INVERTED_DEFAULT_COLOR} { background-color: ${H.foreground.css}; }`,this._themeStyleElement.textContent=I}_setDefaultSpacing(){const H=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${H}px`,this._rowFactory.defaultSpacing=H}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(H,I){for(let U=this._rowElements.length;U<=I;U++){const V=this._document.createElement("div");this._rowContainer.appendChild(V),this._rowElements.push(V)}for(;this._rowElements.length>I;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(H,I){this._refreshRowElements(H,I),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(R),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(R),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(H,I,U){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(H,I,U),this.renderRows(0,this._bufferService.rows-1),!H||!I)return;this._selectionRenderModel.update(this._terminal,H,I,U);const V=this._selectionRenderModel.viewportStartRow,Z=this._selectionRenderModel.viewportEndRow,ee=this._selectionRenderModel.viewportCappedStartRow,F=this._selectionRenderModel.viewportCappedEndRow;if(ee>=this._bufferService.rows||F<0)return;const O=this._document.createDocumentFragment();if(U){const B=H[0]>I[0];O.appendChild(this._createSelectionElement(ee,B?I[0]:H[0],B?H[0]:I[0],F-ee+1))}else{const B=V===ee?H[0]:0,q=ee===Z?I[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(ee,B,q));const $=F-ee-1;if(O.appendChild(this._createSelectionElement(ee+1,0,this._bufferService.cols,$)),ee!==F){const Y=Z===F?I[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(F,0,Y))}}this._selectionContainer.appendChild(O)}_createSelectionElement(H,I,U,V=1){const Z=this._document.createElement("div"),ee=I*this.dimensions.css.cell.width;let F=this.dimensions.css.cell.width*(U-I);return ee+F>this.dimensions.css.canvas.width&&(F=this.dimensions.css.canvas.width-ee),Z.style.height=V*this.dimensions.css.cell.height+"px",Z.style.top=H*this.dimensions.css.cell.height+"px",Z.style.left=`${ee}px`,Z.style.width=`${F}px`,Z}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(const H of this._rowElements)H.replaceChildren()}renderRows(H,I){const U=this._bufferService.buffer,V=U.ybase+U.y,Z=Math.min(U.x,this._bufferService.cols-1),ee=this._optionsService.rawOptions.cursorBlink,F=this._optionsService.rawOptions.cursorStyle,O=this._optionsService.rawOptions.cursorInactiveStyle;for(let B=H;B<=I;B++){const q=B+U.ydisp,$=this._rowElements[B],Y=U.lines.get(q);if(!$||!Y)break;$.replaceChildren(...this._rowFactory.createRow(Y,q,q===V,F,O,Z,ee,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${E}${this._terminalClass}`}_handleLinkHover(H){this._setCellUnderline(H.x1,H.x2,H.y1,H.y2,H.cols,!0)}_handleLinkLeave(H){this._setCellUnderline(H.x1,H.x2,H.y1,H.y2,H.cols,!1)}_setCellUnderline(H,I,U,V,Z,ee){U<0&&(H=0),V<0&&(I=0);const F=this._bufferService.rows-1;U=Math.max(Math.min(U,F),0),V=Math.max(Math.min(V,F),0),Z=Math.min(Z,this._bufferService.cols);const O=this._bufferService.buffer,B=O.ybase+O.y,q=Math.min(O.x,Z-1),$=this._optionsService.rawOptions.cursorBlink,Y=this._optionsService.rawOptions.cursorStyle,Q=this._optionsService.rawOptions.cursorInactiveStyle;for(let X=U;X<=V;++X){const K=X+O.ydisp,P=this._rowElements[X],J=O.lines.get(K);if(!P||!J)break;P.replaceChildren(...this._rowFactory.createRow(J,K,K===B,Y,Q,q,$,this.dimensions.css.cell.width,this._widthCache,ee?X===U?H:0:-1,ee?(X===V?I:Z)-1:-1))}}};c.DomRenderer=z=h([p(7,k.IInstantiationService),p(8,v.ICharSizeService),p(9,k.IOptionsService),p(10,k.IBufferService),p(11,v.ICoreBrowserService),p(12,v.IThemeService)],z)},3787:function(u,c,d){var h=this&&this.__decorate||function(T,D,L,R){var M,W=arguments.length,z=W<3?D:R===null?R=Object.getOwnPropertyDescriptor(D,L):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")z=Reflect.decorate(T,D,L,R);else for(var H=T.length-1;H>=0;H--)(M=T[H])&&(z=(W<3?M(z):W>3?M(D,L,z):M(D,L))||z);return W>3&&z&&Object.defineProperty(D,L,z),z},p=this&&this.__param||function(T,D){return function(L,R){D(L,R,T)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRendererRowFactory=void 0;const m=d(2223),x=d(643),y=d(511),S=d(2585),C=d(8055),v=d(4725),w=d(4269),_=d(6171),b=d(3734);let k=c.DomRendererRowFactory=class{constructor(T,D,L,R,M,W,z){this._document=T,this._characterJoinerService=D,this._optionsService=L,this._coreBrowserService=R,this._coreService=M,this._decorationService=W,this._themeService=z,this._workCell=new y.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(T,D,L){this._selectionStart=T,this._selectionEnd=D,this._columnSelectMode=L}createRow(T,D,L,R,M,W,z,H,I,U,V){const Z=[],ee=this._characterJoinerService.getJoinedCharacters(D),F=this._themeService.colors;let O,B=T.getNoBgTrimmedLength();L&&B<W+1&&(B=W+1);let q=0,$="",Y=0,Q=0,X=0,K=!1,P=0,J=!1,ne=0;const ce=[],ae=U!==-1&&V!==-1;for(let Ee=0;Ee<B;Ee++){T.loadCell(Ee,this._workCell);let ve=this._workCell.getWidth();if(ve===0)continue;let Le=!1,Me=Ee,ke=this._workCell;if(ee.length>0&&Ee===ee[0][0]){Le=!0;const Ke=ee.shift();ke=new w.JoinedCellData(this._workCell,T.translateToString(!0,Ke[0],Ke[1]),Ke[1]-Ke[0]),Me=Ke[1]-1,ve=ke.getWidth()}const Ge=this._isCellInSelection(Ee,D),Xe=L&&Ee===W,Se=ae&&Ee>=U&&Ee<=V;let Ie=!1;this._decorationService.forEachDecorationAtCell(Ee,D,void 0,(Ke=>{Ie=!0}));let it=ke.getChars()||x.WHITESPACE_CELL_CHAR;if(it===" "&&(ke.isUnderline()||ke.isOverline())&&(it=" "),ne=ve*H-I.get(it,ke.isBold(),ke.isItalic()),O){if(q&&(Ge&&J||!Ge&&!J&&ke.bg===Y)&&(Ge&&J&&F.selectionForeground||ke.fg===Q)&&ke.extended.ext===X&&Se===K&&ne===P&&!Xe&&!Le&&!Ie){ke.isInvisible()?$+=x.WHITESPACE_CELL_CHAR:$+=it,q++;continue}q&&(O.textContent=$),O=this._document.createElement("span"),q=0,$=""}else O=this._document.createElement("span");if(Y=ke.bg,Q=ke.fg,X=ke.extended.ext,K=Se,P=ne,J=Ge,Le&&W>=Ee&&W<=Me&&(W=Ee),!this._coreService.isCursorHidden&&Xe&&this._coreService.isCursorInitialized){if(ce.push("xterm-cursor"),this._coreBrowserService.isFocused)z&&ce.push("xterm-cursor-blink"),ce.push(R==="bar"?"xterm-cursor-bar":R==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(M)switch(M){case"outline":ce.push("xterm-cursor-outline");break;case"block":ce.push("xterm-cursor-block");break;case"bar":ce.push("xterm-cursor-bar");break;case"underline":ce.push("xterm-cursor-underline")}}if(ke.isBold()&&ce.push("xterm-bold"),ke.isItalic()&&ce.push("xterm-italic"),ke.isDim()&&ce.push("xterm-dim"),$=ke.isInvisible()?x.WHITESPACE_CELL_CHAR:ke.getChars()||x.WHITESPACE_CELL_CHAR,ke.isUnderline()&&(ce.push(`xterm-underline-${ke.extended.underlineStyle}`),$===" "&&($=" "),!ke.isUnderlineColorDefault()))if(ke.isUnderlineColorRGB())O.style.textDecorationColor=`rgb(${b.AttributeData.toColorRGB(ke.getUnderlineColor()).join(",")})`;else{let Ke=ke.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ke.isBold()&&Ke<8&&(Ke+=8),O.style.textDecorationColor=F.ansi[Ke].css}ke.isOverline()&&(ce.push("xterm-overline"),$===" "&&($=" ")),ke.isStrikethrough()&&ce.push("xterm-strikethrough"),Se&&(O.style.textDecoration="underline");let ge=ke.getFgColor(),Fe=ke.getFgColorMode(),He=ke.getBgColor(),ie=ke.getBgColorMode();const xe=!!ke.isInverse();if(xe){const Ke=ge;ge=He,He=Ke;const et=Fe;Fe=ie,ie=et}let se,he,Pe,qe=!1;switch(this._decorationService.forEachDecorationAtCell(Ee,D,void 0,(Ke=>{Ke.options.layer!=="top"&&qe||(Ke.backgroundColorRGB&&(ie=50331648,He=Ke.backgroundColorRGB.rgba>>8&16777215,se=Ke.backgroundColorRGB),Ke.foregroundColorRGB&&(Fe=50331648,ge=Ke.foregroundColorRGB.rgba>>8&16777215,he=Ke.foregroundColorRGB),qe=Ke.options.layer==="top")})),!qe&&Ge&&(se=this._coreBrowserService.isFocused?F.selectionBackgroundOpaque:F.selectionInactiveBackgroundOpaque,He=se.rgba>>8&16777215,ie=50331648,qe=!0,F.selectionForeground&&(Fe=50331648,ge=F.selectionForeground.rgba>>8&16777215,he=F.selectionForeground)),qe&&ce.push("xterm-decoration-top"),ie){case 16777216:case 33554432:Pe=F.ansi[He],ce.push(`xterm-bg-${He}`);break;case 50331648:Pe=C.channels.toColor(He>>16,He>>8&255,255&He),this._addStyle(O,`background-color:#${E((He>>>0).toString(16),"0",6)}`);break;default:xe?(Pe=F.foreground,ce.push(`xterm-bg-${m.INVERTED_DEFAULT_COLOR}`)):Pe=F.background}switch(se||ke.isDim()&&(se=C.color.multiplyOpacity(Pe,.5)),Fe){case 16777216:case 33554432:ke.isBold()&&ge<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ge+=8),this._applyMinimumContrast(O,Pe,F.ansi[ge],ke,se,void 0)||ce.push(`xterm-fg-${ge}`);break;case 50331648:const Ke=C.channels.toColor(ge>>16&255,ge>>8&255,255&ge);this._applyMinimumContrast(O,Pe,Ke,ke,se,he)||this._addStyle(O,`color:#${E(ge.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(O,Pe,F.foreground,ke,se,he)||xe&&ce.push(`xterm-fg-${m.INVERTED_DEFAULT_COLOR}`)}ce.length&&(O.className=ce.join(" "),ce.length=0),Xe||Le||Ie?O.textContent=$:q++,ne!==this.defaultSpacing&&(O.style.letterSpacing=`${ne}px`),Z.push(O),Ee=Me}return O&&q&&(O.textContent=$),Z}_applyMinimumContrast(T,D,L,R,M,W){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,_.treatGlyphAsBackgroundColor)(R.getCode()))return!1;const z=this._getContrastCache(R);let H;if(M||W||(H=z.getColor(D.rgba,L.rgba)),H===void 0){const I=this._optionsService.rawOptions.minimumContrastRatio/(R.isDim()?2:1);H=C.color.ensureContrastRatio(M||D,W||L,I),z.setColor((M||D).rgba,(W||L).rgba,H??null)}return!!H&&(this._addStyle(T,`color:${H.css}`),!0)}_getContrastCache(T){return T.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(T,D){T.setAttribute("style",`${T.getAttribute("style")||""}${D};`)}_isCellInSelection(T,D){const L=this._selectionStart,R=this._selectionEnd;return!(!L||!R)&&(this._columnSelectMode?L[0]<=R[0]?T>=L[0]&&D>=L[1]&&T<R[0]&&D<=R[1]:T<L[0]&&D>=L[1]&&T>=R[0]&&D<=R[1]:D>L[1]&&D<R[1]||L[1]===R[1]&&D===L[1]&&T>=L[0]&&T<R[0]||L[1]<R[1]&&D===R[1]&&T<R[0]||L[1]<R[1]&&D===L[1]&&T>=L[0])}};function E(T,D,L){for(;T.length<L;)T=D+T;return T}c.DomRendererRowFactory=k=h([p(1,v.ICharacterJoinerService),p(2,S.IOptionsService),p(3,v.ICoreBrowserService),p(4,S.ICoreService),p(5,S.IDecorationService),p(6,v.IThemeService)],k)},2550:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WidthCache=void 0,c.WidthCache=class{constructor(d,h){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=d.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";const p=d.createElement("span");p.classList.add("xterm-char-measure-element");const m=d.createElement("span");m.classList.add("xterm-char-measure-element"),m.style.fontWeight="bold";const x=d.createElement("span");x.classList.add("xterm-char-measure-element"),x.style.fontStyle="italic";const y=d.createElement("span");y.classList.add("xterm-char-measure-element"),y.style.fontWeight="bold",y.style.fontStyle="italic",this._measureElements=[p,m,x,y],this._container.appendChild(p),this._container.appendChild(m),this._container.appendChild(x),this._container.appendChild(y),h.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(d,h,p,m){d===this._font&&h===this._fontSize&&p===this._weight&&m===this._weightBold||(this._font=d,this._fontSize=h,this._weight=p,this._weightBold=m,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${p}`,this._measureElements[1].style.fontWeight=`${m}`,this._measureElements[2].style.fontWeight=`${p}`,this._measureElements[3].style.fontWeight=`${m}`,this.clear())}get(d,h,p){let m=0;if(!h&&!p&&d.length===1&&(m=d.charCodeAt(0))<256){if(this._flat[m]!==-9999)return this._flat[m];const S=this._measure(d,0);return S>0&&(this._flat[m]=S),S}let x=d;h&&(x+="B"),p&&(x+="I");let y=this._holey.get(x);if(y===void 0){let S=0;h&&(S|=1),p&&(S|=2),y=this._measure(d,S),y>0&&this._holey.set(x,y)}return y}_measure(d,h){const p=this._measureElements[h];return p.textContent=d.repeat(32),p.offsetWidth/32}}},2223:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TEXT_BASELINE=c.DIM_OPACITY=c.INVERTED_DEFAULT_COLOR=void 0;const h=d(6114);c.INVERTED_DEFAULT_COLOR=257,c.DIM_OPACITY=.5,c.TEXT_BASELINE=h.isFirefox||h.isLegacyEdge?"bottom":"ideographic"},6171:(u,c)=>{function d(p){return 57508<=p&&p<=57558}function h(p){return p>=128512&&p<=128591||p>=127744&&p<=128511||p>=128640&&p<=128767||p>=9728&&p<=9983||p>=9984&&p<=10175||p>=65024&&p<=65039||p>=129280&&p<=129535||p>=127462&&p<=127487}Object.defineProperty(c,"__esModule",{value:!0}),c.computeNextVariantOffset=c.createRenderDimensions=c.treatGlyphAsBackgroundColor=c.allowRescaling=c.isEmoji=c.isRestrictedPowerlineGlyph=c.isPowerlineGlyph=c.throwIfFalsy=void 0,c.throwIfFalsy=function(p){if(!p)throw new Error("value must not be falsy");return p},c.isPowerlineGlyph=d,c.isRestrictedPowerlineGlyph=function(p){return 57520<=p&&p<=57527},c.isEmoji=h,c.allowRescaling=function(p,m,x,y){return m===1&&x>Math.ceil(1.5*y)&&p!==void 0&&p>255&&!h(p)&&!d(p)&&!(function(S){return 57344<=S&&S<=63743})(p)},c.treatGlyphAsBackgroundColor=function(p){return d(p)||(function(m){return 9472<=m&&m<=9631})(p)},c.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},c.computeNextVariantOffset=function(p,m,x=0){return(p-(2*Math.round(m)-x))%(2*Math.round(m))}},6052:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createSelectionRenderModel=void 0;class d{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(p,m,x,y=!1){if(this.selectionStart=m,this.selectionEnd=x,!m||!x||m[0]===x[0]&&m[1]===x[1])return void this.clear();const S=p.buffers.active.ydisp,C=m[1]-S,v=x[1]-S,w=Math.max(C,0),_=Math.min(v,p.rows-1);w>=p.rows||_<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=y,this.viewportStartRow=C,this.viewportEndRow=v,this.viewportCappedStartRow=w,this.viewportCappedEndRow=_,this.startCol=m[0],this.endCol=x[0])}isCellSelected(p,m,x){return!!this.hasSelection&&(x-=p.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?m>=this.startCol&&x>=this.viewportCappedStartRow&&m<this.endCol&&x<=this.viewportCappedEndRow:m<this.startCol&&x>=this.viewportCappedStartRow&&m>=this.endCol&&x<=this.viewportCappedEndRow:x>this.viewportStartRow&&x<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&x===this.viewportStartRow&&m>=this.startCol&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&x===this.viewportEndRow&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&x===this.viewportStartRow&&m>=this.startCol)}}c.createSelectionRenderModel=function(){return new d}},456:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionModel=void 0,c.SelectionModel=class{constructor(d){this._bufferService=d,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.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()){const d=this.selectionStart[0]+this.selectionStartLength;return d>this._bufferService.cols?d%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)-1]:[d%this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)]:[d,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const d=this.selectionStart[0]+this.selectionStartLength;return d>this._bufferService.cols?[d%this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)]:[Math.max(d,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const d=this.selectionStart,h=this.selectionEnd;return!(!d||!h)&&(d[1]>h[1]||d[1]===h[1]&&d[0]>h[0])}handleTrim(d){return this.selectionStart&&(this.selectionStart[1]-=d),this.selectionEnd&&(this.selectionEnd[1]-=d),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(u,c,d){var h=this&&this.__decorate||function(_,b,k,E){var T,D=arguments.length,L=D<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(_,b,k,E);else for(var R=_.length-1;R>=0;R--)(T=_[R])&&(L=(D<3?T(L):D>3?T(b,k,L):T(b,k))||L);return D>3&&L&&Object.defineProperty(b,k,L),L},p=this&&this.__param||function(_,b){return function(k,E){b(k,E,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharSizeService=void 0;const m=d(2585),x=d(8460),y=d(844);let S=c.CharSizeService=class extends y.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(_,b,k){super(),this._optionsService=k,this.width=0,this.height=0,this._onCharSizeChange=this.register(new x.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new w(this._optionsService))}catch{this._measureStrategy=this.register(new v(_,b,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const _=this._measureStrategy.measure();_.width===this.width&&_.height===this.height||(this.width=_.width,this.height=_.height,this._onCharSizeChange.fire())}};c.CharSizeService=S=h([p(2,m.IOptionsService)],S);class C extends y.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(b,k){b!==void 0&&b>0&&k!==void 0&&k>0&&(this._result.width=b,this._result.height=k)}}class v extends C{constructor(b,k,E){super(),this._document=b,this._parentElement=k,this._optionsService=E,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}}class w extends C{constructor(b){super(),this._optionsService=b,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");const k=this._ctx.measureText("W");if(!("width"in k&&"fontBoundingBoxAscent"in k&&"fontBoundingBoxDescent"in k))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;const b=this._ctx.measureText("W");return this._validateAndSet(b.width,b.fontBoundingBoxAscent+b.fontBoundingBoxDescent),this._result}}},4269:function(u,c,d){var h=this&&this.__decorate||function(w,_,b,k){var E,T=arguments.length,D=T<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,b):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(w,_,b,k);else for(var L=w.length-1;L>=0;L--)(E=w[L])&&(D=(T<3?E(D):T>3?E(_,b,D):E(_,b))||D);return T>3&&D&&Object.defineProperty(_,b,D),D},p=this&&this.__param||function(w,_){return function(b,k){_(b,k,w)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharacterJoinerService=c.JoinedCellData=void 0;const m=d(3734),x=d(643),y=d(511),S=d(2585);class C extends m.AttributeData{constructor(_,b,k){super(),this.content=0,this.combinedData="",this.fg=_.fg,this.bg=_.bg,this.combinedData=b,this._width=k}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(_){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.JoinedCellData=C;let v=c.CharacterJoinerService=class F2{constructor(_){this._bufferService=_,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new y.CellData}register(_){const b={id:this._nextCharacterJoinerId++,handler:_};return this._characterJoiners.push(b),b.id}deregister(_){for(let b=0;b<this._characterJoiners.length;b++)if(this._characterJoiners[b].id===_)return this._characterJoiners.splice(b,1),!0;return!1}getJoinedCharacters(_){if(this._characterJoiners.length===0)return[];const b=this._bufferService.buffer.lines.get(_);if(!b||b.length===0)return[];const k=[],E=b.translateToString(!0);let T=0,D=0,L=0,R=b.getFg(0),M=b.getBg(0);for(let W=0;W<b.getTrimmedLength();W++)if(b.loadCell(W,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==R||this._workCell.bg!==M){if(W-T>1){const z=this._getJoinedRanges(E,L,D,b,T);for(let H=0;H<z.length;H++)k.push(z[H])}T=W,L=D,R=this._workCell.fg,M=this._workCell.bg}D+=this._workCell.getChars().length||x.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-T>1){const W=this._getJoinedRanges(E,L,D,b,T);for(let z=0;z<W.length;z++)k.push(W[z])}return k}_getJoinedRanges(_,b,k,E,T){const D=_.substring(b,k);let L=[];try{L=this._characterJoiners[0].handler(D)}catch(R){console.error(R)}for(let R=1;R<this._characterJoiners.length;R++)try{const M=this._characterJoiners[R].handler(D);for(let W=0;W<M.length;W++)F2._mergeRanges(L,M[W])}catch(M){console.error(M)}return this._stringRangesToCellRanges(L,E,T),L}_stringRangesToCellRanges(_,b,k){let E=0,T=!1,D=0,L=_[E];if(L){for(let R=k;R<this._bufferService.cols;R++){const M=b.getWidth(R),W=b.getString(R).length||x.WHITESPACE_CELL_CHAR.length;if(M!==0){if(!T&&L[0]<=D&&(L[0]=R,T=!0),L[1]<=D){if(L[1]=R,L=_[++E],!L)break;L[0]<=D?(L[0]=R,T=!0):T=!1}D+=W}}L&&(L[1]=this._bufferService.cols)}}static _mergeRanges(_,b){let k=!1;for(let E=0;E<_.length;E++){const T=_[E];if(k){if(b[1]<=T[0])return _[E-1][1]=b[1],_;if(b[1]<=T[1])return _[E-1][1]=Math.max(b[1],T[1]),_.splice(E,1),_;_.splice(E,1),E--}else{if(b[1]<=T[0])return _.splice(E,0,b),_;if(b[1]<=T[1])return T[0]=Math.min(b[0],T[0]),_;b[0]<T[1]&&(T[0]=Math.min(b[0],T[0]),k=!0)}}return k?_[_.length-1][1]=b[1]:_.push(b),_}};c.CharacterJoinerService=v=h([p(0,S.IBufferService)],v)},5114:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreBrowserService=void 0;const h=d(844),p=d(8460),m=d(3656);class x extends h.Disposable{constructor(C,v,w){super(),this._textarea=C,this._window=v,this.mainDocument=w,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new y(this._window),this._onDprChange=this.register(new p.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new p.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((_=>this._screenDprMonitor.setWindow(_)))),this.register((0,p.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(C){this._window!==C&&(this._window=C,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}}c.CoreBrowserService=x;class y extends h.Disposable{constructor(C){super(),this._parentWindow=C,this._windowResizeListener=this.register(new h.MutableDisposable),this._onDprChange=this.register(new p.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,h.toDisposable)((()=>this.clearListener())))}setWindow(C){this._parentWindow=C,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,m.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var C;this._outerListener&&((C=this._resolutionMediaMatchList)==null||C.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)}}},779:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.LinkProviderService=void 0;const h=d(844);class p extends h.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,h.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(x){return this.linkProviders.push(x),{dispose:()=>{const y=this.linkProviders.indexOf(x);y!==-1&&this.linkProviders.splice(y,1)}}}}c.LinkProviderService=p},8934:function(u,c,d){var h=this&&this.__decorate||function(S,C,v,w){var _,b=arguments.length,k=b<3?C:w===null?w=Object.getOwnPropertyDescriptor(C,v):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(S,C,v,w);else for(var E=S.length-1;E>=0;E--)(_=S[E])&&(k=(b<3?_(k):b>3?_(C,v,k):_(C,v))||k);return b>3&&k&&Object.defineProperty(C,v,k),k},p=this&&this.__param||function(S,C){return function(v,w){C(v,w,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.MouseService=void 0;const m=d(4725),x=d(9806);let y=c.MouseService=class{constructor(S,C){this._renderService=S,this._charSizeService=C}getCoords(S,C,v,w,_){return(0,x.getCoords)(window,S,C,v,w,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,_)}getMouseReportCoords(S,C){const v=(0,x.getCoordsRelativeToElement)(window,S,C);if(this._charSizeService.hasValidSize)return v[0]=Math.min(Math.max(v[0],0),this._renderService.dimensions.css.canvas.width-1),v[1]=Math.min(Math.max(v[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(v[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(v[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(v[0]),y:Math.floor(v[1])}}};c.MouseService=y=h([p(0,m.IRenderService),p(1,m.ICharSizeService)],y)},3230:function(u,c,d){var h=this&&this.__decorate||function(_,b,k,E){var T,D=arguments.length,L=D<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(_,b,k,E);else for(var R=_.length-1;R>=0;R--)(T=_[R])&&(L=(D<3?T(L):D>3?T(b,k,L):T(b,k))||L);return D>3&&L&&Object.defineProperty(b,k,L),L},p=this&&this.__param||function(_,b){return function(k,E){b(k,E,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.RenderService=void 0;const m=d(6193),x=d(4725),y=d(8460),S=d(844),C=d(7226),v=d(2585);let w=c.RenderService=class extends S.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(_,b,k,E,T,D,L,R){super(),this._rowCount=_,this._charSizeService=E,this._renderer=this.register(new S.MutableDisposable),this._pausedResizeTask=new C.DebouncedIdleTask,this._observerDisposable=this.register(new S.MutableDisposable),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 y.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new y.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new y.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new y.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new m.RenderDebouncer(((M,W)=>this._renderRows(M,W)),L),this.register(this._renderDebouncer),this.register(L.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(D.onResize((()=>this._fullRefresh()))),this.register(D.buffers.onBufferActivate((()=>{var M;return(M=this._renderer.value)==null?void 0:M.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(T.onDecorationRegistered((()=>this._fullRefresh()))),this.register(T.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(D.cols,D.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(D.buffer.y,D.buffer.y,!0)))),this.register(R.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(L.window,b),this.register(L.onWindowChange((M=>this._registerIntersectionObserver(M,b))))}_registerIntersectionObserver(_,b){if("IntersectionObserver"in _){const k=new _.IntersectionObserver((E=>this._handleIntersectionChange(E[E.length-1])),{threshold:0});k.observe(b),this._observerDisposable.value=(0,S.toDisposable)((()=>k.disconnect()))}}_handleIntersectionChange(_){this._isPaused=_.isIntersecting===void 0?_.intersectionRatio===0:!_.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(_,b,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(_,b,this._rowCount))}_renderRows(_,b){this._renderer.value&&(_=Math.min(_,this._rowCount-1),b=Math.min(b,this._rowCount-1),this._renderer.value.renderRows(_,b),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:_,end:b}),this._onRender.fire({start:_,end:b}),this._isNextRenderRedrawOnly=!0)}resize(_,b){this._rowCount=b,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(_){this._renderer.value=_,this._renderer.value&&(this._renderer.value.onRequestRedraw((b=>this.refreshRows(b.start,b.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(_){return this._renderDebouncer.addRefreshCallback(_)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var _,b;this._renderer.value&&((b=(_=this._renderer.value).clearTextureAtlas)==null||b.call(_),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(_,b){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>{var k;return(k=this._renderer.value)==null?void 0:k.handleResize(_,b)})):this._renderer.value.handleResize(_,b),this._fullRefresh())}handleCharSizeChanged(){var _;(_=this._renderer.value)==null||_.handleCharSizeChanged()}handleBlur(){var _;(_=this._renderer.value)==null||_.handleBlur()}handleFocus(){var _;(_=this._renderer.value)==null||_.handleFocus()}handleSelectionChanged(_,b,k){var E;this._selectionState.start=_,this._selectionState.end=b,this._selectionState.columnSelectMode=k,(E=this._renderer.value)==null||E.handleSelectionChanged(_,b,k)}handleCursorMove(){var _;(_=this._renderer.value)==null||_.handleCursorMove()}clear(){var _;(_=this._renderer.value)==null||_.clear()}};c.RenderService=w=h([p(2,v.IOptionsService),p(3,x.ICharSizeService),p(4,v.IDecorationService),p(5,v.IBufferService),p(6,x.ICoreBrowserService),p(7,x.IThemeService)],w)},9312:function(u,c,d){var h=this&&this.__decorate||function(L,R,M,W){var z,H=arguments.length,I=H<3?R:W===null?W=Object.getOwnPropertyDescriptor(R,M):W;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(L,R,M,W);else for(var U=L.length-1;U>=0;U--)(z=L[U])&&(I=(H<3?z(I):H>3?z(R,M,I):z(R,M))||I);return H>3&&I&&Object.defineProperty(R,M,I),I},p=this&&this.__param||function(L,R){return function(M,W){R(M,W,L)}};Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionService=void 0;const m=d(9806),x=d(9504),y=d(456),S=d(4725),C=d(8460),v=d(844),w=d(6114),_=d(4841),b=d(511),k=d(2585),E=" ",T=new RegExp(E,"g");let D=c.SelectionService=class extends v.Disposable{constructor(L,R,M,W,z,H,I,U,V){super(),this._element=L,this._screenElement=R,this._linkifier=M,this._bufferService=W,this._coreService=z,this._mouseService=H,this._optionsService=I,this._renderService=U,this._coreBrowserService=V,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new b.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new C.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new C.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new C.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=Z=>this._handleMouseMove(Z),this._mouseUpListener=Z=>this._handleMouseUp(Z),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((Z=>this._handleTrim(Z))),this.register(this._bufferService.buffers.onBufferActivate((Z=>this._handleBufferActivate(Z)))),this.enable(),this._model=new y.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,v.toDisposable)((()=>{this._removeMouseDownListeners()})))}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(){const L=this._model.finalSelectionStart,R=this._model.finalSelectionEnd;return!(!L||!R||L[0]===R[0]&&L[1]===R[1])}get selectionText(){const L=this._model.finalSelectionStart,R=this._model.finalSelectionEnd;if(!L||!R)return"";const M=this._bufferService.buffer,W=[];if(this._activeSelectionMode===3){if(L[0]===R[0])return"";const z=L[0]<R[0]?L[0]:R[0],H=L[0]<R[0]?R[0]:L[0];for(let I=L[1];I<=R[1];I++){const U=M.translateBufferLineToString(I,!0,z,H);W.push(U)}}else{const z=L[1]===R[1]?R[0]:void 0;W.push(M.translateBufferLineToString(L[1],!0,L[0],z));for(let H=L[1]+1;H<=R[1]-1;H++){const I=M.lines.get(H),U=M.translateBufferLineToString(H,!0);I!=null&&I.isWrapped?W[W.length-1]+=U:W.push(U)}if(L[1]!==R[1]){const H=M.lines.get(R[1]),I=M.translateBufferLineToString(R[1],!0,0,R[0]);H&&H.isWrapped?W[W.length-1]+=I:W.push(I)}}return W.map((z=>z.replace(T," "))).join(w.isWindows?`\r
|
|
258
|
+
`:`
|
|
259
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(L){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),w.isLinux&&L&&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(L){const R=this._getMouseBufferCoords(L),M=this._model.finalSelectionStart,W=this._model.finalSelectionEnd;return!!(M&&W&&R)&&this._areCoordsInSelection(R,M,W)}isCellInSelection(L,R){const M=this._model.finalSelectionStart,W=this._model.finalSelectionEnd;return!(!M||!W)&&this._areCoordsInSelection([L,R],M,W)}_areCoordsInSelection(L,R,M){return L[1]>R[1]&&L[1]<M[1]||R[1]===M[1]&&L[1]===R[1]&&L[0]>=R[0]&&L[0]<M[0]||R[1]<M[1]&&L[1]===M[1]&&L[0]<M[0]||R[1]<M[1]&&L[1]===R[1]&&L[0]>=R[0]}_selectWordAtCursor(L,R){var z,H;const M=(H=(z=this._linkifier.currentLink)==null?void 0:z.link)==null?void 0:H.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,_.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const W=this._getMouseBufferCoords(L);return!!W&&(this._selectWordAt(W,R),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(L,R){this._model.clearSelection(),L=Math.max(L,0),R=Math.min(R,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,L],this._model.selectionEnd=[this._bufferService.cols,R],this.refresh(),this._onSelectionChange.fire()}_handleTrim(L){this._model.handleTrim(L)&&this.refresh()}_getMouseBufferCoords(L){const R=this._mouseService.getCoords(L,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(R)return R[0]--,R[1]--,R[1]+=this._bufferService.buffer.ydisp,R}_getMouseEventScrollAmount(L){let R=(0,m.getCoordsRelativeToElement)(this._coreBrowserService.window,L,this._screenElement)[1];const M=this._renderService.dimensions.css.canvas.height;return R>=0&&R<=M?0:(R>M&&(R-=M),R=Math.min(Math.max(R,-50),50),R/=50,R/Math.abs(R)+Math.round(14*R))}shouldForceSelection(L){return w.isMac?L.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:L.shiftKey}handleMouseDown(L){if(this._mouseDownTimeStamp=L.timeStamp,(L.button!==2||!this.hasSelection)&&L.button===0){if(!this._enabled){if(!this.shouldForceSelection(L))return;L.stopPropagation()}L.preventDefault(),this._dragScrollAmount=0,this._enabled&&L.shiftKey?this._handleIncrementalClick(L):L.detail===1?this._handleSingleClick(L):L.detail===2?this._handleDoubleClick(L):L.detail===3&&this._handleTripleClick(L),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()),50)}_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(L){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(L))}_handleSingleClick(L){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(L)?3:0,this._model.selectionStart=this._getMouseBufferCoords(L),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const R=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);R&&R.length!==this._model.selectionStart[0]&&R.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(L){this._selectWordAtCursor(L,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(L){const R=this._getMouseBufferCoords(L);R&&(this._activeSelectionMode=2,this._selectLineAt(R[1]))}shouldColumnSelect(L){return L.altKey&&!(w.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(L){if(L.stopImmediatePropagation(),!this._model.selectionStart)return;const R=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(L),!this._model.selectionEnd)return void this.refresh(!0);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(L),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const M=this._bufferService.buffer;if(this._model.selectionEnd[1]<M.lines.length){const W=M.lines.get(this._model.selectionEnd[1]);W&&W.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}R&&R[0]===this._model.selectionEnd[0]&&R[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});const L=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(L.ydisp+this._bufferService.rows,L.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=L.ydisp),this.refresh()}}_handleMouseUp(L){const R=L.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&R<500&&L.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const M=this._mouseService.getCoords(L,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(M&&M[0]!==void 0&&M[1]!==void 0){const W=(0,x.moveToCellSequence)(M[0]-1,M[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(W,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const L=this._model.finalSelectionStart,R=this._model.finalSelectionEnd,M=!(!L||!R||L[0]===R[0]&&L[1]===R[1]);M?L&&R&&(this._oldSelectionStart&&this._oldSelectionEnd&&L[0]===this._oldSelectionStart[0]&&L[1]===this._oldSelectionStart[1]&&R[0]===this._oldSelectionEnd[0]&&R[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(L,R,M)):this._oldHasSelection&&this._fireOnSelectionChange(L,R,M)}_fireOnSelectionChange(L,R,M){this._oldSelectionStart=L,this._oldSelectionEnd=R,this._oldHasSelection=M,this._onSelectionChange.fire()}_handleBufferActivate(L){this.clearSelection(),this._trimListener.dispose(),this._trimListener=L.activeBuffer.lines.onTrim((R=>this._handleTrim(R)))}_convertViewportColToCharacterIndex(L,R){let M=R;for(let W=0;R>=W;W++){const z=L.loadCell(W,this._workCell).getChars().length;this._workCell.getWidth()===0?M--:z>1&&R!==W&&(M+=z-1)}return M}setSelection(L,R,M){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[L,R],this._model.selectionStartLength=M,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(L){this._isClickInSelection(L)||(this._selectWordAtCursor(L,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(L,R,M=!0,W=!0){if(L[0]>=this._bufferService.cols)return;const z=this._bufferService.buffer,H=z.lines.get(L[1]);if(!H)return;const I=z.translateBufferLineToString(L[1],!1);let U=this._convertViewportColToCharacterIndex(H,L[0]),V=U;const Z=L[0]-U;let ee=0,F=0,O=0,B=0;if(I.charAt(U)===" "){for(;U>0&&I.charAt(U-1)===" ";)U--;for(;V<I.length&&I.charAt(V+1)===" ";)V++}else{let Y=L[0],Q=L[0];H.getWidth(Y)===0&&(ee++,Y--),H.getWidth(Q)===2&&(F++,Q++);const X=H.getString(Q).length;for(X>1&&(B+=X-1,V+=X-1);Y>0&&U>0&&!this._isCharWordSeparator(H.loadCell(Y-1,this._workCell));){H.loadCell(Y-1,this._workCell);const K=this._workCell.getChars().length;this._workCell.getWidth()===0?(ee++,Y--):K>1&&(O+=K-1,U-=K-1),U--,Y--}for(;Q<H.length&&V+1<I.length&&!this._isCharWordSeparator(H.loadCell(Q+1,this._workCell));){H.loadCell(Q+1,this._workCell);const K=this._workCell.getChars().length;this._workCell.getWidth()===2?(F++,Q++):K>1&&(B+=K-1,V+=K-1),V++,Q++}}V++;let q=U+Z-ee+O,$=Math.min(this._bufferService.cols,V-U+ee+F-O-B);if(R||I.slice(U,V).trim()!==""){if(M&&q===0&&H.getCodePoint(0)!==32){const Y=z.lines.get(L[1]-1);if(Y&&H.isWrapped&&Y.getCodePoint(this._bufferService.cols-1)!==32){const Q=this._getWordAt([this._bufferService.cols-1,L[1]-1],!1,!0,!1);if(Q){const X=this._bufferService.cols-Q.start;q-=X,$+=X}}}if(W&&q+$===this._bufferService.cols&&H.getCodePoint(this._bufferService.cols-1)!==32){const Y=z.lines.get(L[1]+1);if(Y!=null&&Y.isWrapped&&Y.getCodePoint(0)!==32){const Q=this._getWordAt([0,L[1]+1],!1,!1,!0);Q&&($+=Q.length)}}return{start:q,length:$}}}_selectWordAt(L,R){const M=this._getWordAt(L,R);if(M){for(;M.start<0;)M.start+=this._bufferService.cols,L[1]--;this._model.selectionStart=[M.start,L[1]],this._model.selectionStartLength=M.length}}_selectToWordAt(L){const R=this._getWordAt(L,!0);if(R){let M=L[1];for(;R.start<0;)R.start+=this._bufferService.cols,M--;if(!this._model.areSelectionValuesReversed())for(;R.start+R.length>this._bufferService.cols;)R.length-=this._bufferService.cols,M++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?R.start:R.start+R.length,M]}}_isCharWordSeparator(L){return L.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(L.getChars())>=0}_selectLineAt(L){const R=this._bufferService.buffer.getWrappedRangeForLine(L),M={start:{x:0,y:R.first},end:{x:this._bufferService.cols-1,y:R.last}};this._model.selectionStart=[0,R.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,_.getRangeLength)(M,this._bufferService.cols)}};c.SelectionService=D=h([p(3,k.IBufferService),p(4,k.ICoreService),p(5,S.IMouseService),p(6,k.IOptionsService),p(7,S.IRenderService),p(8,S.ICoreBrowserService)],D)},4725:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ILinkProviderService=c.IThemeService=c.ICharacterJoinerService=c.ISelectionService=c.IRenderService=c.IMouseService=c.ICoreBrowserService=c.ICharSizeService=void 0;const h=d(8343);c.ICharSizeService=(0,h.createDecorator)("CharSizeService"),c.ICoreBrowserService=(0,h.createDecorator)("CoreBrowserService"),c.IMouseService=(0,h.createDecorator)("MouseService"),c.IRenderService=(0,h.createDecorator)("RenderService"),c.ISelectionService=(0,h.createDecorator)("SelectionService"),c.ICharacterJoinerService=(0,h.createDecorator)("CharacterJoinerService"),c.IThemeService=(0,h.createDecorator)("ThemeService"),c.ILinkProviderService=(0,h.createDecorator)("LinkProviderService")},6731:function(u,c,d){var h=this&&this.__decorate||function(D,L,R,M){var W,z=arguments.length,H=z<3?L:M===null?M=Object.getOwnPropertyDescriptor(L,R):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")H=Reflect.decorate(D,L,R,M);else for(var I=D.length-1;I>=0;I--)(W=D[I])&&(H=(z<3?W(H):z>3?W(L,R,H):W(L,R))||H);return z>3&&H&&Object.defineProperty(L,R,H),H},p=this&&this.__param||function(D,L){return function(R,M){L(R,M,D)}};Object.defineProperty(c,"__esModule",{value:!0}),c.ThemeService=c.DEFAULT_ANSI_COLORS=void 0;const m=d(7239),x=d(8055),y=d(8460),S=d(844),C=d(2585),v=x.css.toColor("#ffffff"),w=x.css.toColor("#000000"),_=x.css.toColor("#ffffff"),b=x.css.toColor("#000000"),k={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};c.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const D=[x.css.toColor("#2e3436"),x.css.toColor("#cc0000"),x.css.toColor("#4e9a06"),x.css.toColor("#c4a000"),x.css.toColor("#3465a4"),x.css.toColor("#75507b"),x.css.toColor("#06989a"),x.css.toColor("#d3d7cf"),x.css.toColor("#555753"),x.css.toColor("#ef2929"),x.css.toColor("#8ae234"),x.css.toColor("#fce94f"),x.css.toColor("#729fcf"),x.css.toColor("#ad7fa8"),x.css.toColor("#34e2e2"),x.css.toColor("#eeeeec")],L=[0,95,135,175,215,255];for(let R=0;R<216;R++){const M=L[R/36%6|0],W=L[R/6%6|0],z=L[R%6];D.push({css:x.channels.toCss(M,W,z),rgba:x.channels.toRgba(M,W,z)})}for(let R=0;R<24;R++){const M=8+10*R;D.push({css:x.channels.toCss(M,M,M),rgba:x.channels.toRgba(M,M,M)})}return D})());let E=c.ThemeService=class extends S.Disposable{get colors(){return this._colors}constructor(D){super(),this._optionsService=D,this._contrastCache=new m.ColorContrastCache,this._halfContrastCache=new m.ColorContrastCache,this._onChangeColors=this.register(new y.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:v,background:w,cursor:_,cursorAccent:b,selectionForeground:void 0,selectionBackgroundTransparent:k,selectionBackgroundOpaque:x.color.blend(w,k),selectionInactiveBackgroundTransparent:k,selectionInactiveBackgroundOpaque:x.color.blend(w,k),ansi:c.DEFAULT_ANSI_COLORS.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))))}_setTheme(D={}){const L=this._colors;if(L.foreground=T(D.foreground,v),L.background=T(D.background,w),L.cursor=T(D.cursor,_),L.cursorAccent=T(D.cursorAccent,b),L.selectionBackgroundTransparent=T(D.selectionBackground,k),L.selectionBackgroundOpaque=x.color.blend(L.background,L.selectionBackgroundTransparent),L.selectionInactiveBackgroundTransparent=T(D.selectionInactiveBackground,L.selectionBackgroundTransparent),L.selectionInactiveBackgroundOpaque=x.color.blend(L.background,L.selectionInactiveBackgroundTransparent),L.selectionForeground=D.selectionForeground?T(D.selectionForeground,x.NULL_COLOR):void 0,L.selectionForeground===x.NULL_COLOR&&(L.selectionForeground=void 0),x.color.isOpaque(L.selectionBackgroundTransparent)&&(L.selectionBackgroundTransparent=x.color.opacity(L.selectionBackgroundTransparent,.3)),x.color.isOpaque(L.selectionInactiveBackgroundTransparent)&&(L.selectionInactiveBackgroundTransparent=x.color.opacity(L.selectionInactiveBackgroundTransparent,.3)),L.ansi=c.DEFAULT_ANSI_COLORS.slice(),L.ansi[0]=T(D.black,c.DEFAULT_ANSI_COLORS[0]),L.ansi[1]=T(D.red,c.DEFAULT_ANSI_COLORS[1]),L.ansi[2]=T(D.green,c.DEFAULT_ANSI_COLORS[2]),L.ansi[3]=T(D.yellow,c.DEFAULT_ANSI_COLORS[3]),L.ansi[4]=T(D.blue,c.DEFAULT_ANSI_COLORS[4]),L.ansi[5]=T(D.magenta,c.DEFAULT_ANSI_COLORS[5]),L.ansi[6]=T(D.cyan,c.DEFAULT_ANSI_COLORS[6]),L.ansi[7]=T(D.white,c.DEFAULT_ANSI_COLORS[7]),L.ansi[8]=T(D.brightBlack,c.DEFAULT_ANSI_COLORS[8]),L.ansi[9]=T(D.brightRed,c.DEFAULT_ANSI_COLORS[9]),L.ansi[10]=T(D.brightGreen,c.DEFAULT_ANSI_COLORS[10]),L.ansi[11]=T(D.brightYellow,c.DEFAULT_ANSI_COLORS[11]),L.ansi[12]=T(D.brightBlue,c.DEFAULT_ANSI_COLORS[12]),L.ansi[13]=T(D.brightMagenta,c.DEFAULT_ANSI_COLORS[13]),L.ansi[14]=T(D.brightCyan,c.DEFAULT_ANSI_COLORS[14]),L.ansi[15]=T(D.brightWhite,c.DEFAULT_ANSI_COLORS[15]),D.extendedAnsi){const R=Math.min(L.ansi.length-16,D.extendedAnsi.length);for(let M=0;M<R;M++)L.ansi[M+16]=T(D.extendedAnsi[M],c.DEFAULT_ANSI_COLORS[M+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(D){this._restoreColor(D),this._onChangeColors.fire(this.colors)}_restoreColor(D){if(D!==void 0)switch(D){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[D]=this._restoreColors.ansi[D]}else for(let L=0;L<this._restoreColors.ansi.length;++L)this._colors.ansi[L]=this._restoreColors.ansi[L]}modifyColors(D){D(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()}}};function T(D,L){if(D!==void 0)try{return x.css.toColor(D)}catch{}return L}c.ThemeService=E=h([p(0,C.IOptionsService)],E)},6349:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CircularList=void 0;const h=d(8460),p=d(844);class m extends p.Disposable{constructor(y){super(),this._maxLength=y,this.onDeleteEmitter=this.register(new h.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new h.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new h.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(y){if(this._maxLength===y)return;const S=new Array(y);for(let C=0;C<Math.min(y,this.length);C++)S[C]=this._array[this._getCyclicIndex(C)];this._array=S,this._maxLength=y,this._startIndex=0}get length(){return this._length}set length(y){if(y>this._length)for(let S=this._length;S<y;S++)this._array[S]=void 0;this._length=y}get(y){return this._array[this._getCyclicIndex(y)]}set(y,S){this._array[this._getCyclicIndex(y)]=S}push(y){this._array[this._getCyclicIndex(this._length)]=y,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(y,S,...C){if(S){for(let v=y;v<this._length-S;v++)this._array[this._getCyclicIndex(v)]=this._array[this._getCyclicIndex(v+S)];this._length-=S,this.onDeleteEmitter.fire({index:y,amount:S})}for(let v=this._length-1;v>=y;v--)this._array[this._getCyclicIndex(v+C.length)]=this._array[this._getCyclicIndex(v)];for(let v=0;v<C.length;v++)this._array[this._getCyclicIndex(y+v)]=C[v];if(C.length&&this.onInsertEmitter.fire({index:y,amount:C.length}),this._length+C.length>this._maxLength){const v=this._length+C.length-this._maxLength;this._startIndex+=v,this._length=this._maxLength,this.onTrimEmitter.fire(v)}else this._length+=C.length}trimStart(y){y>this._length&&(y=this._length),this._startIndex+=y,this._length-=y,this.onTrimEmitter.fire(y)}shiftElements(y,S,C){if(!(S<=0)){if(y<0||y>=this._length)throw new Error("start argument out of range");if(y+C<0)throw new Error("Cannot shift elements in list beyond index 0");if(C>0){for(let w=S-1;w>=0;w--)this.set(y+w+C,this.get(y+w));const v=y+S+C-this._length;if(v>0)for(this._length+=v;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let v=0;v<S;v++)this.set(y+v+C,this.get(y+v))}}_getCyclicIndex(y){return(this._startIndex+y)%this._maxLength}}c.CircularList=m},1439:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.clone=void 0,c.clone=function d(h,p=5){if(typeof h!="object")return h;const m=Array.isArray(h)?[]:{};for(const x in h)m[x]=p<=1?h[x]:h[x]&&d(h[x],p-1);return m}},8055:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.contrastRatio=c.toPaddedHex=c.rgba=c.rgb=c.css=c.color=c.channels=c.NULL_COLOR=void 0;let d=0,h=0,p=0,m=0;var x,y,S,C,v;function w(b){const k=b.toString(16);return k.length<2?"0"+k:k}function _(b,k){return b<k?(k+.05)/(b+.05):(b+.05)/(k+.05)}c.NULL_COLOR={css:"#00000000",rgba:0},(function(b){b.toCss=function(k,E,T,D){return D!==void 0?`#${w(k)}${w(E)}${w(T)}${w(D)}`:`#${w(k)}${w(E)}${w(T)}`},b.toRgba=function(k,E,T,D=255){return(k<<24|E<<16|T<<8|D)>>>0},b.toColor=function(k,E,T,D){return{css:b.toCss(k,E,T,D),rgba:b.toRgba(k,E,T,D)}}})(x||(c.channels=x={})),(function(b){function k(E,T){return m=Math.round(255*T),[d,h,p]=v.toChannels(E.rgba),{css:x.toCss(d,h,p,m),rgba:x.toRgba(d,h,p,m)}}b.blend=function(E,T){if(m=(255&T.rgba)/255,m===1)return{css:T.css,rgba:T.rgba};const D=T.rgba>>24&255,L=T.rgba>>16&255,R=T.rgba>>8&255,M=E.rgba>>24&255,W=E.rgba>>16&255,z=E.rgba>>8&255;return d=M+Math.round((D-M)*m),h=W+Math.round((L-W)*m),p=z+Math.round((R-z)*m),{css:x.toCss(d,h,p),rgba:x.toRgba(d,h,p)}},b.isOpaque=function(E){return(255&E.rgba)==255},b.ensureContrastRatio=function(E,T,D){const L=v.ensureContrastRatio(E.rgba,T.rgba,D);if(L)return x.toColor(L>>24&255,L>>16&255,L>>8&255)},b.opaque=function(E){const T=(255|E.rgba)>>>0;return[d,h,p]=v.toChannels(T),{css:x.toCss(d,h,p),rgba:T}},b.opacity=k,b.multiplyOpacity=function(E,T){return m=255&E.rgba,k(E,m*T/255)},b.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(y||(c.color=y={})),(function(b){let k,E;try{const T=document.createElement("canvas");T.width=1,T.height=1;const D=T.getContext("2d",{willReadFrequently:!0});D&&(k=D,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}catch{}b.toColor=function(T){if(T.match(/#[\da-f]{3,8}/i))switch(T.length){case 4:return d=parseInt(T.slice(1,2).repeat(2),16),h=parseInt(T.slice(2,3).repeat(2),16),p=parseInt(T.slice(3,4).repeat(2),16),x.toColor(d,h,p);case 5:return d=parseInt(T.slice(1,2).repeat(2),16),h=parseInt(T.slice(2,3).repeat(2),16),p=parseInt(T.slice(3,4).repeat(2),16),m=parseInt(T.slice(4,5).repeat(2),16),x.toColor(d,h,p,m);case 7:return{css:T,rgba:(parseInt(T.slice(1),16)<<8|255)>>>0};case 9:return{css:T,rgba:parseInt(T.slice(1),16)>>>0}}const D=T.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(D)return d=parseInt(D[1]),h=parseInt(D[2]),p=parseInt(D[3]),m=Math.round(255*(D[5]===void 0?1:parseFloat(D[5]))),x.toColor(d,h,p,m);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=T,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[d,h,p,m]=k.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:x.toRgba(d,h,p,m),css:T}}})(S||(c.css=S={})),(function(b){function k(E,T,D){const L=E/255,R=T/255,M=D/255;return .2126*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.7152*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}b.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},b.relativeLuminance2=k})(C||(c.rgb=C={})),(function(b){function k(T,D,L){const R=T>>24&255,M=T>>16&255,W=T>>8&255;let z=D>>24&255,H=D>>16&255,I=D>>8&255,U=_(C.relativeLuminance2(z,H,I),C.relativeLuminance2(R,M,W));for(;U<L&&(z>0||H>0||I>0);)z-=Math.max(0,Math.ceil(.1*z)),H-=Math.max(0,Math.ceil(.1*H)),I-=Math.max(0,Math.ceil(.1*I)),U=_(C.relativeLuminance2(z,H,I),C.relativeLuminance2(R,M,W));return(z<<24|H<<16|I<<8|255)>>>0}function E(T,D,L){const R=T>>24&255,M=T>>16&255,W=T>>8&255;let z=D>>24&255,H=D>>16&255,I=D>>8&255,U=_(C.relativeLuminance2(z,H,I),C.relativeLuminance2(R,M,W));for(;U<L&&(z<255||H<255||I<255);)z=Math.min(255,z+Math.ceil(.1*(255-z))),H=Math.min(255,H+Math.ceil(.1*(255-H))),I=Math.min(255,I+Math.ceil(.1*(255-I))),U=_(C.relativeLuminance2(z,H,I),C.relativeLuminance2(R,M,W));return(z<<24|H<<16|I<<8|255)>>>0}b.blend=function(T,D){if(m=(255&D)/255,m===1)return D;const L=D>>24&255,R=D>>16&255,M=D>>8&255,W=T>>24&255,z=T>>16&255,H=T>>8&255;return d=W+Math.round((L-W)*m),h=z+Math.round((R-z)*m),p=H+Math.round((M-H)*m),x.toRgba(d,h,p)},b.ensureContrastRatio=function(T,D,L){const R=C.relativeLuminance(T>>8),M=C.relativeLuminance(D>>8);if(_(R,M)<L){if(M<R){const H=k(T,D,L),I=_(R,C.relativeLuminance(H>>8));if(I<L){const U=E(T,D,L);return I>_(R,C.relativeLuminance(U>>8))?H:U}return H}const W=E(T,D,L),z=_(R,C.relativeLuminance(W>>8));if(z<L){const H=k(T,D,L);return z>_(R,C.relativeLuminance(H>>8))?W:H}return W}},b.reduceLuminance=k,b.increaseLuminance=E,b.toChannels=function(T){return[T>>24&255,T>>16&255,T>>8&255,255&T]}})(v||(c.rgba=v={})),c.toPaddedHex=w,c.contrastRatio=_},8969:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreTerminal=void 0;const h=d(844),p=d(2585),m=d(4348),x=d(7866),y=d(744),S=d(7302),C=d(6975),v=d(8460),w=d(1753),_=d(1480),b=d(7994),k=d(9282),E=d(5435),T=d(5981),D=d(2660);let L=!1;class R extends h.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new v.EventEmitter),this._onScroll.event((W=>{var z;(z=this._onScrollApi)==null||z.fire(W.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(W){for(const z in W)this.optionsService.options[z]=W[z]}constructor(W){super(),this._windowsWrappingHeuristics=this.register(new h.MutableDisposable),this._onBinary=this.register(new v.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new v.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new v.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new v.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new v.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new v.EventEmitter),this._instantiationService=new m.InstantiationService,this.optionsService=this.register(new S.OptionsService(W)),this._instantiationService.setService(p.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(y.BufferService)),this._instantiationService.setService(p.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(x.LogService)),this._instantiationService.setService(p.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(C.CoreService)),this._instantiationService.setService(p.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(w.CoreMouseService)),this._instantiationService.setService(p.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(_.UnicodeService)),this._instantiationService.setService(p.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(b.CharsetService),this._instantiationService.setService(p.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(D.OscLinkService),this._instantiationService.setService(p.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new E.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,v.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,v.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,v.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,v.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((z=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((z=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new T.WriteBuffer(((z,H)=>this._inputHandler.parse(z,H)))),this.register((0,v.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(W,z){this._writeBuffer.write(W,z)}writeSync(W,z){this._logService.logLevel<=p.LogLevelEnum.WARN&&!L&&(this._logService.warn("writeSync is unreliable and will be removed soon."),L=!0),this._writeBuffer.writeSync(W,z)}input(W,z=!0){this.coreService.triggerDataEvent(W,z)}resize(W,z){isNaN(W)||isNaN(z)||(W=Math.max(W,y.MINIMUM_COLS),z=Math.max(z,y.MINIMUM_ROWS),this._bufferService.resize(W,z))}scroll(W,z=!1){this._bufferService.scroll(W,z)}scrollLines(W,z,H){this._bufferService.scrollLines(W,z,H)}scrollPages(W){this.scrollLines(W*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(W){const z=W-this._bufferService.buffer.ydisp;z!==0&&this.scrollLines(z)}registerEscHandler(W,z){return this._inputHandler.registerEscHandler(W,z)}registerDcsHandler(W,z){return this._inputHandler.registerDcsHandler(W,z)}registerCsiHandler(W,z){return this._inputHandler.registerCsiHandler(W,z)}registerOscHandler(W,z){return this._inputHandler.registerOscHandler(W,z)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let W=!1;const z=this.optionsService.rawOptions.windowsPty;z&&z.buildNumber!==void 0&&z.buildNumber!==void 0?W=z.backend==="conpty"&&z.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(W=!0),W?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const W=[];W.push(this.onLineFeed(k.updateWindowsModeWrappedState.bind(null,this._bufferService))),W.push(this.registerCsiHandler({final:"H"},(()=>((0,k.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,h.toDisposable)((()=>{for(const z of W)z.dispose()}))}}}c.CoreTerminal=R},8460:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.runAndSubscribe=c.forwardEvent=c.EventEmitter=void 0,c.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=d=>(this._listeners.push(d),{dispose:()=>{if(!this._disposed){for(let h=0;h<this._listeners.length;h++)if(this._listeners[h]===d)return void this._listeners.splice(h,1)}}})),this._event}fire(d,h){const p=[];for(let m=0;m<this._listeners.length;m++)p.push(this._listeners[m]);for(let m=0;m<p.length;m++)p[m].call(void 0,d,h)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},c.forwardEvent=function(d,h){return d((p=>h.fire(p)))},c.runAndSubscribe=function(d,h){return h(void 0),d((p=>h(p)))}},5435:function(u,c,d){var h=this&&this.__decorate||function(ee,F,O,B){var q,$=arguments.length,Y=$<3?F:B===null?B=Object.getOwnPropertyDescriptor(F,O):B;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Y=Reflect.decorate(ee,F,O,B);else for(var Q=ee.length-1;Q>=0;Q--)(q=ee[Q])&&(Y=($<3?q(Y):$>3?q(F,O,Y):q(F,O))||Y);return $>3&&Y&&Object.defineProperty(F,O,Y),Y},p=this&&this.__param||function(ee,F){return function(O,B){F(O,B,ee)}};Object.defineProperty(c,"__esModule",{value:!0}),c.InputHandler=c.WindowsOptionsReportType=void 0;const m=d(2584),x=d(7116),y=d(2015),S=d(844),C=d(482),v=d(8437),w=d(8460),_=d(643),b=d(511),k=d(3734),E=d(2585),T=d(1480),D=d(6242),L=d(6351),R=d(5941),M={"(":0,")":1,"*":2,"+":3,"-":1,".":2},W=131072;function z(ee,F){if(ee>24)return F.setWinLines||!1;switch(ee){case 1:return!!F.restoreWin;case 2:return!!F.minimizeWin;case 3:return!!F.setWinPosition;case 4:return!!F.setWinSizePixels;case 5:return!!F.raiseWin;case 6:return!!F.lowerWin;case 7:return!!F.refreshWin;case 8:return!!F.setWinSizeChars;case 9:return!!F.maximizeWin;case 10:return!!F.fullscreenWin;case 11:return!!F.getWinState;case 13:return!!F.getWinPosition;case 14:return!!F.getWinSizePixels;case 15:return!!F.getScreenSizePixels;case 16:return!!F.getCellSizePixels;case 18:return!!F.getWinSizeChars;case 19:return!!F.getScreenSizeChars;case 20:return!!F.getIconTitle;case 21:return!!F.getWinTitle;case 22:return!!F.pushTitle;case 23:return!!F.popTitle;case 24:return!!F.setWinLines}return!1}var H;(function(ee){ee[ee.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",ee[ee.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(H||(c.WindowsOptionsReportType=H={}));let I=0;class U extends S.Disposable{getAttrData(){return this._curAttrData}constructor(F,O,B,q,$,Y,Q,X,K=new y.EscapeSequenceParser){super(),this._bufferService=F,this._charsetService=O,this._coreService=B,this._logService=q,this._optionsService=$,this._oscLinkService=Y,this._coreMouseService=Q,this._unicodeService=X,this._parser=K,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new C.StringToUtf32,this._utf8Decoder=new C.Utf8ToUtf32,this._workCell=new b.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=v.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=v.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new w.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new w.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new w.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new w.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new w.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new w.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new w.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new w.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new w.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new w.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new w.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new w.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new w.EventEmitter),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 V(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((P=>this._activeBuffer=P.activeBuffer))),this._parser.setCsiHandlerFallback(((P,J)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(P),params:J.toArray()})})),this._parser.setEscHandlerFallback((P=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(P)})})),this._parser.setExecuteHandlerFallback((P=>{this._logService.debug("Unknown EXECUTE code: ",{code:P})})),this._parser.setOscHandlerFallback(((P,J,ne)=>{this._logService.debug("Unknown OSC code: ",{identifier:P,action:J,data:ne})})),this._parser.setDcsHandlerFallback(((P,J,ne)=>{J==="HOOK"&&(ne=ne.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(P),action:J,payload:ne})})),this._parser.setPrintHandler(((P,J,ne)=>this.print(P,J,ne))),this._parser.registerCsiHandler({final:"@"},(P=>this.insertChars(P))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(P=>this.scrollLeft(P))),this._parser.registerCsiHandler({final:"A"},(P=>this.cursorUp(P))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(P=>this.scrollRight(P))),this._parser.registerCsiHandler({final:"B"},(P=>this.cursorDown(P))),this._parser.registerCsiHandler({final:"C"},(P=>this.cursorForward(P))),this._parser.registerCsiHandler({final:"D"},(P=>this.cursorBackward(P))),this._parser.registerCsiHandler({final:"E"},(P=>this.cursorNextLine(P))),this._parser.registerCsiHandler({final:"F"},(P=>this.cursorPrecedingLine(P))),this._parser.registerCsiHandler({final:"G"},(P=>this.cursorCharAbsolute(P))),this._parser.registerCsiHandler({final:"H"},(P=>this.cursorPosition(P))),this._parser.registerCsiHandler({final:"I"},(P=>this.cursorForwardTab(P))),this._parser.registerCsiHandler({final:"J"},(P=>this.eraseInDisplay(P,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(P=>this.eraseInDisplay(P,!0))),this._parser.registerCsiHandler({final:"K"},(P=>this.eraseInLine(P,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(P=>this.eraseInLine(P,!0))),this._parser.registerCsiHandler({final:"L"},(P=>this.insertLines(P))),this._parser.registerCsiHandler({final:"M"},(P=>this.deleteLines(P))),this._parser.registerCsiHandler({final:"P"},(P=>this.deleteChars(P))),this._parser.registerCsiHandler({final:"S"},(P=>this.scrollUp(P))),this._parser.registerCsiHandler({final:"T"},(P=>this.scrollDown(P))),this._parser.registerCsiHandler({final:"X"},(P=>this.eraseChars(P))),this._parser.registerCsiHandler({final:"Z"},(P=>this.cursorBackwardTab(P))),this._parser.registerCsiHandler({final:"`"},(P=>this.charPosAbsolute(P))),this._parser.registerCsiHandler({final:"a"},(P=>this.hPositionRelative(P))),this._parser.registerCsiHandler({final:"b"},(P=>this.repeatPrecedingCharacter(P))),this._parser.registerCsiHandler({final:"c"},(P=>this.sendDeviceAttributesPrimary(P))),this._parser.registerCsiHandler({prefix:">",final:"c"},(P=>this.sendDeviceAttributesSecondary(P))),this._parser.registerCsiHandler({final:"d"},(P=>this.linePosAbsolute(P))),this._parser.registerCsiHandler({final:"e"},(P=>this.vPositionRelative(P))),this._parser.registerCsiHandler({final:"f"},(P=>this.hVPosition(P))),this._parser.registerCsiHandler({final:"g"},(P=>this.tabClear(P))),this._parser.registerCsiHandler({final:"h"},(P=>this.setMode(P))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(P=>this.setModePrivate(P))),this._parser.registerCsiHandler({final:"l"},(P=>this.resetMode(P))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(P=>this.resetModePrivate(P))),this._parser.registerCsiHandler({final:"m"},(P=>this.charAttributes(P))),this._parser.registerCsiHandler({final:"n"},(P=>this.deviceStatus(P))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(P=>this.deviceStatusPrivate(P))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(P=>this.softReset(P))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(P=>this.setCursorStyle(P))),this._parser.registerCsiHandler({final:"r"},(P=>this.setScrollRegion(P))),this._parser.registerCsiHandler({final:"s"},(P=>this.saveCursor(P))),this._parser.registerCsiHandler({final:"t"},(P=>this.windowOptions(P))),this._parser.registerCsiHandler({final:"u"},(P=>this.restoreCursor(P))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(P=>this.insertColumns(P))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(P=>this.deleteColumns(P))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(P=>this.selectProtected(P))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(P=>this.requestMode(P,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(P=>this.requestMode(P,!1))),this._parser.setExecuteHandler(m.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(m.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(m.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(m.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(m.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(m.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(m.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(m.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(m.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new D.OscHandler((P=>(this.setTitle(P),this.setIconName(P),!0)))),this._parser.registerOscHandler(1,new D.OscHandler((P=>this.setIconName(P)))),this._parser.registerOscHandler(2,new D.OscHandler((P=>this.setTitle(P)))),this._parser.registerOscHandler(4,new D.OscHandler((P=>this.setOrReportIndexedColor(P)))),this._parser.registerOscHandler(8,new D.OscHandler((P=>this.setHyperlink(P)))),this._parser.registerOscHandler(10,new D.OscHandler((P=>this.setOrReportFgColor(P)))),this._parser.registerOscHandler(11,new D.OscHandler((P=>this.setOrReportBgColor(P)))),this._parser.registerOscHandler(12,new D.OscHandler((P=>this.setOrReportCursorColor(P)))),this._parser.registerOscHandler(104,new D.OscHandler((P=>this.restoreIndexedColor(P)))),this._parser.registerOscHandler(110,new D.OscHandler((P=>this.restoreFgColor(P)))),this._parser.registerOscHandler(111,new D.OscHandler((P=>this.restoreBgColor(P)))),this._parser.registerOscHandler(112,new D.OscHandler((P=>this.restoreCursorColor(P)))),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(const P in x.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:P},(()=>this.selectCharset("("+P))),this._parser.registerEscHandler({intermediates:")",final:P},(()=>this.selectCharset(")"+P))),this._parser.registerEscHandler({intermediates:"*",final:P},(()=>this.selectCharset("*"+P))),this._parser.registerEscHandler({intermediates:"+",final:P},(()=>this.selectCharset("+"+P))),this._parser.registerEscHandler({intermediates:"-",final:P},(()=>this.selectCharset("-"+P))),this._parser.registerEscHandler({intermediates:".",final:P},(()=>this.selectCharset("."+P))),this._parser.registerEscHandler({intermediates:"/",final:P},(()=>this.selectCharset("/"+P)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((P=>(this._logService.error("Parsing error: ",P),P))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new L.DcsHandler(((P,J)=>this.requestStatusString(P,J))))}_preserveStack(F,O,B,q){this._parseStack.paused=!0,this._parseStack.cursorStartX=F,this._parseStack.cursorStartY=O,this._parseStack.decodedLength=B,this._parseStack.position=q}_logSlowResolvingAsync(F){this._logService.logLevel<=E.LogLevelEnum.WARN&&Promise.race([F,new Promise(((O,B)=>setTimeout((()=>B("#SLOW_TIMEOUT")),5e3)))]).catch((O=>{if(O!=="#SLOW_TIMEOUT")throw O;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(F,O){let B,q=this._activeBuffer.x,$=this._activeBuffer.y,Y=0;const Q=this._parseStack.paused;if(Q){if(B=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,O))return this._logSlowResolvingAsync(B),B;q=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,F.length>W&&(Y=this._parseStack.position+W)}if(this._logService.logLevel<=E.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof F=="string"?` "${F}"`:` "${Array.prototype.map.call(F,(P=>String.fromCharCode(P))).join("")}"`),typeof F=="string"?F.split("").map((P=>P.charCodeAt(0))):F),this._parseBuffer.length<F.length&&this._parseBuffer.length<W&&(this._parseBuffer=new Uint32Array(Math.min(F.length,W))),Q||this._dirtyRowTracker.clearRange(),F.length>W)for(let P=Y;P<F.length;P+=W){const J=P+W<F.length?P+W:F.length,ne=typeof F=="string"?this._stringDecoder.decode(F.substring(P,J),this._parseBuffer):this._utf8Decoder.decode(F.subarray(P,J),this._parseBuffer);if(B=this._parser.parse(this._parseBuffer,ne))return this._preserveStack(q,$,ne,P),this._logSlowResolvingAsync(B),B}else if(!Q){const P=typeof F=="string"?this._stringDecoder.decode(F,this._parseBuffer):this._utf8Decoder.decode(F,this._parseBuffer);if(B=this._parser.parse(this._parseBuffer,P))return this._preserveStack(q,$,P,0),this._logSlowResolvingAsync(B),B}this._activeBuffer.x===q&&this._activeBuffer.y===$||this._onCursorMove.fire();const X=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),K=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);K<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(K,this._bufferService.rows-1),Math.min(X,this._bufferService.rows-1))}print(F,O,B){let q,$;const Y=this._charsetService.charset,Q=this._optionsService.rawOptions.screenReaderMode,X=this._bufferService.cols,K=this._coreService.decPrivateModes.wraparound,P=this._coreService.modes.insertMode,J=this._curAttrData;let ne=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&B-O>0&&ne.getWidth(this._activeBuffer.x-1)===2&&ne.setCellFromCodepoint(this._activeBuffer.x-1,0,1,J);let ce=this._parser.precedingJoinState;for(let ae=O;ae<B;++ae){if(q=F[ae],q<127&&Y){const Me=Y[String.fromCharCode(q)];Me&&(q=Me.charCodeAt(0))}const Ee=this._unicodeService.charProperties(q,ce);$=T.UnicodeService.extractWidth(Ee);const ve=T.UnicodeService.extractShouldJoin(Ee),Le=ve?T.UnicodeService.extractWidth(ce):0;if(ce=Ee,Q&&this._onA11yChar.fire((0,C.stringFromCodePoint)(q)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+$-Le>X){if(K){const Me=ne;let ke=this._activeBuffer.x-Le;for(this._activeBuffer.x=Le,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),ne=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),Le>0&&ne instanceof v.BufferLine&&ne.copyCellsFrom(Me,ke,0,Le,!1);ke<X;)Me.setCellFromCodepoint(ke++,0,1,J)}else if(this._activeBuffer.x=X-1,$===2)continue}if(ve&&this._activeBuffer.x){const Me=ne.getWidth(this._activeBuffer.x-1)?1:2;ne.addCodepointToCell(this._activeBuffer.x-Me,q,$);for(let ke=$-Le;--ke>=0;)ne.setCellFromCodepoint(this._activeBuffer.x++,0,0,J)}else if(P&&(ne.insertCells(this._activeBuffer.x,$-Le,this._activeBuffer.getNullCell(J)),ne.getWidth(X-1)===2&&ne.setCellFromCodepoint(X-1,_.NULL_CELL_CODE,_.NULL_CELL_WIDTH,J)),ne.setCellFromCodepoint(this._activeBuffer.x++,q,$,J),$>0)for(;--$;)ne.setCellFromCodepoint(this._activeBuffer.x++,0,0,J)}this._parser.precedingJoinState=ce,this._activeBuffer.x<X&&B-O>0&&ne.getWidth(this._activeBuffer.x)===0&&!ne.hasContent(this._activeBuffer.x)&&ne.setCellFromCodepoint(this._activeBuffer.x,0,1,J),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(F,O){return F.final!=="t"||F.prefix||F.intermediates?this._parser.registerCsiHandler(F,O):this._parser.registerCsiHandler(F,(B=>!z(B.params[0],this._optionsService.rawOptions.windowOptions)||O(B)))}registerDcsHandler(F,O){return this._parser.registerDcsHandler(F,new L.DcsHandler(O))}registerEscHandler(F,O){return this._parser.registerEscHandler(F,O)}registerOscHandler(F,O){return this._parser.registerOscHandler(F,new D.OscHandler(O))}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(){var F;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&&((F=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&F.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);O.hasWidth(this._activeBuffer.x)&&!O.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const F=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-F),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(F=this._bufferService.cols-1){this._activeBuffer.x=Math.min(F,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(F,O){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=F,this._activeBuffer.y=this._activeBuffer.scrollTop+O):(this._activeBuffer.x=F,this._activeBuffer.y=O),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(F,O){this._restrictCursor(),this._setCursor(this._activeBuffer.x+F,this._activeBuffer.y+O)}cursorUp(F){const O=this._activeBuffer.y-this._activeBuffer.scrollTop;return O>=0?this._moveCursor(0,-Math.min(O,F.params[0]||1)):this._moveCursor(0,-(F.params[0]||1)),!0}cursorDown(F){const O=this._activeBuffer.scrollBottom-this._activeBuffer.y;return O>=0?this._moveCursor(0,Math.min(O,F.params[0]||1)):this._moveCursor(0,F.params[0]||1),!0}cursorForward(F){return this._moveCursor(F.params[0]||1,0),!0}cursorBackward(F){return this._moveCursor(-(F.params[0]||1),0),!0}cursorNextLine(F){return this.cursorDown(F),this._activeBuffer.x=0,!0}cursorPrecedingLine(F){return this.cursorUp(F),this._activeBuffer.x=0,!0}cursorCharAbsolute(F){return this._setCursor((F.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(F){return this._setCursor(F.length>=2?(F.params[1]||1)-1:0,(F.params[0]||1)-1),!0}charPosAbsolute(F){return this._setCursor((F.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(F){return this._moveCursor(F.params[0]||1,0),!0}linePosAbsolute(F){return this._setCursor(this._activeBuffer.x,(F.params[0]||1)-1),!0}vPositionRelative(F){return this._moveCursor(0,F.params[0]||1),!0}hVPosition(F){return this.cursorPosition(F),!0}tabClear(F){const O=F.params[0];return O===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:O===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(F){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=F.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(F){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=F.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(F){const O=F.params[0];return O===1&&(this._curAttrData.bg|=536870912),O!==2&&O!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(F,O,B,q=!1,$=!1){const Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+F);Y.replaceCells(O,B,this._activeBuffer.getNullCell(this._eraseAttrData()),$),q&&(Y.isWrapped=!1)}_resetBufferLine(F,O=!1){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+F);B&&(B.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),O),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+F),B.isWrapped=!1)}eraseInDisplay(F,O=!1){let B;switch(this._restrictCursor(this._bufferService.cols),F.params[0]){case 0:for(B=this._activeBuffer.y,this._dirtyRowTracker.markDirty(B),this._eraseInBufferLine(B++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);B<this._bufferService.rows;B++)this._resetBufferLine(B,O);this._dirtyRowTracker.markDirty(B);break;case 1:for(B=this._activeBuffer.y,this._dirtyRowTracker.markDirty(B),this._eraseInBufferLine(B,0,this._activeBuffer.x+1,!0,O),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(B+1).isWrapped=!1);B--;)this._resetBufferLine(B,O);this._dirtyRowTracker.markDirty(0);break;case 2:for(B=this._bufferService.rows,this._dirtyRowTracker.markDirty(B-1);B--;)this._resetBufferLine(B,O);this._dirtyRowTracker.markDirty(0);break;case 3:const q=this._activeBuffer.lines.length-this._bufferService.rows;q>0&&(this._activeBuffer.lines.trimStart(q),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-q,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-q,0),this._onScroll.fire(0))}return!0}eraseInLine(F,O=!1){switch(this._restrictCursor(this._bufferService.cols),F.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,O);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,O)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(F){this._restrictCursor();let O=F.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const B=this._activeBuffer.ybase+this._activeBuffer.y,q=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-q+1;for(;O--;)this._activeBuffer.lines.splice($-1,1),this._activeBuffer.lines.splice(B,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(F){this._restrictCursor();let O=F.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const B=this._activeBuffer.ybase+this._activeBuffer.y;let q;for(q=this._bufferService.rows-1-this._activeBuffer.scrollBottom,q=this._bufferService.rows-1+this._activeBuffer.ybase-q;O--;)this._activeBuffer.lines.splice(B,1),this._activeBuffer.lines.splice(q,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(F){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.insertCells(this._activeBuffer.x,F.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(F){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.deleteCells(this._activeBuffer.x,F.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(F){let O=F.params[0]||1;for(;O--;)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(F){let O=F.params[0]||1;for(;O--;)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(v.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(F){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=F.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);q.deleteCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(F){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=F.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);q.insertCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(F){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=F.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);q.insertCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(F){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=F.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);q.deleteCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(F){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(F.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(F){const O=this._parser.precedingJoinState;if(!O)return!0;const B=F.params[0]||1,q=T.UnicodeService.extractWidth(O),$=this._activeBuffer.x-q,Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString($),Q=new Uint32Array(Y.length*B);let X=0;for(let P=0;P<Y.length;){const J=Y.codePointAt(P)||0;Q[X++]=J,P+=J>65535?2:1}let K=X;for(let P=1;P<B;++P)Q.copyWithin(K,0,X),K+=X;return this.print(Q,0,K),!0}sendDeviceAttributesPrimary(F){return F.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(m.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(m.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(F){return F.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(m.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(m.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(F.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(m.C0.ESC+"[>83;40003;0c")),!0}_is(F){return(this._optionsService.rawOptions.termName+"").indexOf(F)===0}setMode(F){for(let O=0;O<F.length;O++)switch(F.params[O]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(F){for(let O=0;O<F.length;O++)switch(F.params[O]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,x.DEFAULT_CHARSET),this._charsetService.setgCharset(1,x.DEFAULT_CHARSET),this._charsetService.setgCharset(2,x.DEFAULT_CHARSET),this._charsetService.setgCharset(3,x.DEFAULT_CHARSET);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(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(F){for(let O=0;O<F.length;O++)switch(F.params[O]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(F){for(let O=0;O<F.length;O++)switch(F.params[O]){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:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),F.params[O]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(F,O){const B=this._coreService.decPrivateModes,{activeProtocol:q,activeEncoding:$}=this._coreMouseService,Y=this._coreService,{buffers:Q,cols:X}=this._bufferService,{active:K,alt:P}=Q,J=this._optionsService.rawOptions,ne=ve=>ve?1:2,ce=F.params[0];return ae=ce,Ee=O?ce===2?4:ce===4?ne(Y.modes.insertMode):ce===12?3:ce===20?ne(J.convertEol):0:ce===1?ne(B.applicationCursorKeys):ce===3?J.windowOptions.setWinLines?X===80?2:X===132?1:0:0:ce===6?ne(B.origin):ce===7?ne(B.wraparound):ce===8?3:ce===9?ne(q==="X10"):ce===12?ne(J.cursorBlink):ce===25?ne(!Y.isCursorHidden):ce===45?ne(B.reverseWraparound):ce===66?ne(B.applicationKeypad):ce===67?4:ce===1e3?ne(q==="VT200"):ce===1002?ne(q==="DRAG"):ce===1003?ne(q==="ANY"):ce===1004?ne(B.sendFocus):ce===1005?4:ce===1006?ne($==="SGR"):ce===1015?4:ce===1016?ne($==="SGR_PIXELS"):ce===1048?1:ce===47||ce===1047||ce===1049?ne(K===P):ce===2004?ne(B.bracketedPasteMode):0,Y.triggerDataEvent(`${m.C0.ESC}[${O?"":"?"}${ae};${Ee}$y`),!0;var ae,Ee}_updateAttrColor(F,O,B,q,$){return O===2?(F|=50331648,F&=-16777216,F|=k.AttributeData.fromColorRGB([B,q,$])):O===5&&(F&=-50331904,F|=33554432|255&B),F}_extractColor(F,O,B){const q=[0,0,-1,0,0,0];let $=0,Y=0;do{if(q[Y+$]=F.params[O+Y],F.hasSubParams(O+Y)){const Q=F.getSubParams(O+Y);let X=0;do q[1]===5&&($=1),q[Y+X+1+$]=Q[X];while(++X<Q.length&&X+Y+1+$<q.length);break}if(q[1]===5&&Y+$>=2||q[1]===2&&Y+$>=5)break;q[1]&&($=1)}while(++Y+O<F.length&&Y+$<q.length);for(let Q=2;Q<q.length;++Q)q[Q]===-1&&(q[Q]=0);switch(q[0]){case 38:B.fg=this._updateAttrColor(B.fg,q[1],q[3],q[4],q[5]);break;case 48:B.bg=this._updateAttrColor(B.bg,q[1],q[3],q[4],q[5]);break;case 58:B.extended=B.extended.clone(),B.extended.underlineColor=this._updateAttrColor(B.extended.underlineColor,q[1],q[3],q[4],q[5])}return Y}_processUnderline(F,O){O.extended=O.extended.clone(),(!~F||F>5)&&(F=1),O.extended.underlineStyle=F,O.fg|=268435456,F===0&&(O.fg&=-268435457),O.updateExtended()}_processSGR0(F){F.fg=v.DEFAULT_ATTR_DATA.fg,F.bg=v.DEFAULT_ATTR_DATA.bg,F.extended=F.extended.clone(),F.extended.underlineStyle=0,F.extended.underlineColor&=-67108864,F.updateExtended()}charAttributes(F){if(F.length===1&&F.params[0]===0)return this._processSGR0(this._curAttrData),!0;const O=F.length;let B;const q=this._curAttrData;for(let $=0;$<O;$++)B=F.params[$],B>=30&&B<=37?(q.fg&=-50331904,q.fg|=16777216|B-30):B>=40&&B<=47?(q.bg&=-50331904,q.bg|=16777216|B-40):B>=90&&B<=97?(q.fg&=-50331904,q.fg|=16777224|B-90):B>=100&&B<=107?(q.bg&=-50331904,q.bg|=16777224|B-100):B===0?this._processSGR0(q):B===1?q.fg|=134217728:B===3?q.bg|=67108864:B===4?(q.fg|=268435456,this._processUnderline(F.hasSubParams($)?F.getSubParams($)[0]:1,q)):B===5?q.fg|=536870912:B===7?q.fg|=67108864:B===8?q.fg|=1073741824:B===9?q.fg|=2147483648:B===2?q.bg|=134217728:B===21?this._processUnderline(2,q):B===22?(q.fg&=-134217729,q.bg&=-134217729):B===23?q.bg&=-67108865:B===24?(q.fg&=-268435457,this._processUnderline(0,q)):B===25?q.fg&=-536870913:B===27?q.fg&=-67108865:B===28?q.fg&=-1073741825:B===29?q.fg&=2147483647:B===39?(q.fg&=-67108864,q.fg|=16777215&v.DEFAULT_ATTR_DATA.fg):B===49?(q.bg&=-67108864,q.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):B===38||B===48||B===58?$+=this._extractColor(F,$,q):B===53?q.bg|=1073741824:B===55?q.bg&=-1073741825:B===59?(q.extended=q.extended.clone(),q.extended.underlineColor=-1,q.updateExtended()):B===100?(q.fg&=-67108864,q.fg|=16777215&v.DEFAULT_ATTR_DATA.fg,q.bg&=-67108864,q.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",B);return!0}deviceStatus(F){switch(F.params[0]){case 5:this._coreService.triggerDataEvent(`${m.C0.ESC}[0n`);break;case 6:const O=this._activeBuffer.y+1,B=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[${O};${B}R`)}return!0}deviceStatusPrivate(F){if(F.params[0]===6){const O=this._activeBuffer.y+1,B=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[?${O};${B}R`)}return!0}softReset(F){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=v.DEFAULT_ATTR_DATA.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(F){const O=F.params[0]||1;switch(O){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const B=O%2==1;return this._optionsService.options.cursorBlink=B,!0}setScrollRegion(F){const O=F.params[0]||1;let B;return(F.length<2||(B=F.params[1])>this._bufferService.rows||B===0)&&(B=this._bufferService.rows),B>O&&(this._activeBuffer.scrollTop=O-1,this._activeBuffer.scrollBottom=B-1,this._setCursor(0,0)),!0}windowOptions(F){if(!z(F.params[0],this._optionsService.rawOptions.windowOptions))return!0;const O=F.length>1?F.params[1]:0;switch(F.params[0]){case 14:O!==2&&this._onRequestWindowsOptionsReport.fire(H.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(H.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${m.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:O!==0&&O!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),O!==0&&O!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:O!==0&&O!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),O!==0&&O!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(F){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(F){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(F){return this._windowTitle=F,this._onTitleChange.fire(F),!0}setIconName(F){return this._iconName=F,!0}setOrReportIndexedColor(F){const O=[],B=F.split(";");for(;B.length>1;){const q=B.shift(),$=B.shift();if(/^\d+$/.exec(q)){const Y=parseInt(q);if(Z(Y))if($==="?")O.push({type:0,index:Y});else{const Q=(0,R.parseColor)($);Q&&O.push({type:1,index:Y,color:Q})}}}return O.length&&this._onColor.fire(O),!0}setHyperlink(F){const O=F.split(";");return!(O.length<2)&&(O[1]?this._createHyperlink(O[0],O[1]):!O[0]&&this._finishHyperlink())}_createHyperlink(F,O){this._getCurrentLinkId()&&this._finishHyperlink();const B=F.split(":");let q;const $=B.findIndex((Y=>Y.startsWith("id=")));return $!==-1&&(q=B[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:q,uri:O}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(F,O){const B=F.split(";");for(let q=0;q<B.length&&!(O>=this._specialColors.length);++q,++O)if(B[q]==="?")this._onColor.fire([{type:0,index:this._specialColors[O]}]);else{const $=(0,R.parseColor)(B[q]);$&&this._onColor.fire([{type:1,index:this._specialColors[O],color:$}])}return!0}setOrReportFgColor(F){return this._setOrReportSpecialColor(F,0)}setOrReportBgColor(F){return this._setOrReportSpecialColor(F,1)}setOrReportCursorColor(F){return this._setOrReportSpecialColor(F,2)}restoreIndexedColor(F){if(!F)return this._onColor.fire([{type:2}]),!0;const O=[],B=F.split(";");for(let q=0;q<B.length;++q)if(/^\d+$/.exec(B[q])){const $=parseInt(B[q]);Z($)&&O.push({type:2,index:$})}return O.length&&this._onColor.fire(O),!0}restoreFgColor(F){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(F){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(F){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,x.DEFAULT_CHARSET),!0}selectCharset(F){return F.length!==2?(this.selectDefaultCharset(),!0):(F[0]==="/"||this._charsetService.setgCharset(M[F[0]],x.CHARSETS[F[1]]||x.DEFAULT_CHARSET),!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){const F=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,F,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=v.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=v.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(F){return this._charsetService.setgLevel(F),!0}screenAlignmentPattern(){const F=new b.CellData;F.content=4194373,F.fg=this._curAttrData.fg,F.bg=this._curAttrData.bg,this._setCursor(0,0);for(let O=0;O<this._bufferService.rows;++O){const B=this._activeBuffer.ybase+this._activeBuffer.y+O,q=this._activeBuffer.lines.get(B);q&&(q.fill(F),q.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(F,O){const B=this._bufferService.buffer,q=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${m.C0.ESC}${$}${m.C0.ESC}\\`),!0))(F==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:F==='"p'?'P1$r61;1"p':F==="r"?`P1$r${B.scrollTop+1};${B.scrollBottom+1}r`:F==="m"?"P1$r0m":F===" q"?`P1$r${{block:2,underline:4,bar:6}[q.cursorStyle]-(q.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(F,O){this._dirtyRowTracker.markRangeDirty(F,O)}}c.InputHandler=U;let V=class{constructor(ee){this._bufferService=ee,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(ee){ee<this.start?this.start=ee:ee>this.end&&(this.end=ee)}markRangeDirty(ee,F){ee>F&&(I=ee,ee=F,F=I),ee<this.start&&(this.start=ee),F>this.end&&(this.end=F)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Z(ee){return 0<=ee&&ee<256}V=h([p(0,E.IBufferService)],V)},844:(u,c)=>{function d(h){for(const p of h)p.dispose();h.length=0}Object.defineProperty(c,"__esModule",{value:!0}),c.getDisposeArrayDisposable=c.disposeArray=c.toDisposable=c.MutableDisposable=c.Disposable=void 0,c.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const h of this._disposables)h.dispose();this._disposables.length=0}register(h){return this._disposables.push(h),h}unregister(h){const p=this._disposables.indexOf(h);p!==-1&&this._disposables.splice(p,1)}},c.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(h){var p;this._isDisposed||h===this._value||((p=this._value)==null||p.dispose(),this._value=h)}clear(){this.value=void 0}dispose(){var h;this._isDisposed=!0,(h=this._value)==null||h.dispose(),this._value=void 0}},c.toDisposable=function(h){return{dispose:h}},c.disposeArray=d,c.getDisposeArrayDisposable=function(h){return{dispose:()=>d(h)}}},1505:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.FourKeyMap=c.TwoKeyMap=void 0;class d{constructor(){this._data={}}set(p,m,x){this._data[p]||(this._data[p]={}),this._data[p][m]=x}get(p,m){return this._data[p]?this._data[p][m]:void 0}clear(){this._data={}}}c.TwoKeyMap=d,c.FourKeyMap=class{constructor(){this._data=new d}set(h,p,m,x,y){this._data.get(h,p)||this._data.set(h,p,new d),this._data.get(h,p).set(m,x,y)}get(h,p,m,x){var y;return(y=this._data.get(h,p))==null?void 0:y.get(m,x)}clear(){this._data.clear()}}},6114:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.isChromeOS=c.isLinux=c.isWindows=c.isIphone=c.isIpad=c.isMac=c.getSafariVersion=c.isSafari=c.isLegacyEdge=c.isFirefox=c.isNode=void 0,c.isNode=typeof process<"u"&&"title"in process;const d=c.isNode?"node":navigator.userAgent,h=c.isNode?"node":navigator.platform;c.isFirefox=d.includes("Firefox"),c.isLegacyEdge=d.includes("Edge"),c.isSafari=/^((?!chrome|android).)*safari/i.test(d),c.getSafariVersion=function(){if(!c.isSafari)return 0;const p=d.match(/Version\/(\d+)/);return p===null||p.length<2?0:parseInt(p[1])},c.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(h),c.isIpad=h==="iPad",c.isIphone=h==="iPhone",c.isWindows=["Windows","Win16","Win32","WinCE"].includes(h),c.isLinux=h.indexOf("Linux")>=0,c.isChromeOS=/\bCrOS\b/.test(d)},6106:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.SortedList=void 0;let d=0;c.SortedList=class{constructor(h){this._getKey=h,this._array=[]}clear(){this._array.length=0}insert(h){this._array.length!==0?(d=this._search(this._getKey(h)),this._array.splice(d,0,h)):this._array.push(h)}delete(h){if(this._array.length===0)return!1;const p=this._getKey(h);if(p===void 0||(d=this._search(p),d===-1)||this._getKey(this._array[d])!==p)return!1;do if(this._array[d]===h)return this._array.splice(d,1),!0;while(++d<this._array.length&&this._getKey(this._array[d])===p);return!1}*getKeyIterator(h){if(this._array.length!==0&&(d=this._search(h),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===h))do yield this._array[d];while(++d<this._array.length&&this._getKey(this._array[d])===h)}forEachByKey(h,p){if(this._array.length!==0&&(d=this._search(h),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===h))do p(this._array[d]);while(++d<this._array.length&&this._getKey(this._array[d])===h)}values(){return[...this._array].values()}_search(h){let p=0,m=this._array.length-1;for(;m>=p;){let x=p+m>>1;const y=this._getKey(this._array[x]);if(y>h)m=x-1;else{if(!(y<h)){for(;x>0&&this._getKey(this._array[x-1])===h;)x--;return x}p=x+1}}return p}}},7226:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DebouncedIdleTask=c.IdleTaskQueue=c.PriorityTaskQueue=void 0;const h=d(6114);class p{constructor(){this._tasks=[],this._i=0}enqueue(y){this._tasks.push(y),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(y){this._idleCallback=void 0;let S=0,C=0,v=y.timeRemaining(),w=0;for(;this._i<this._tasks.length;){if(S=Date.now(),this._tasks[this._i]()||this._i++,S=Math.max(1,Date.now()-S),C=Math.max(S,C),w=y.timeRemaining(),1.5*C>w)return v-S<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(v-S))}ms`),void this._start();v=w}this.clear()}}class m extends p{_requestCallback(y){return setTimeout((()=>y(this._createDeadline(16))))}_cancelCallback(y){clearTimeout(y)}_createDeadline(y){const S=Date.now()+y;return{timeRemaining:()=>Math.max(0,S-Date.now())}}}c.PriorityTaskQueue=m,c.IdleTaskQueue=!h.isNode&&"requestIdleCallback"in window?class extends p{_requestCallback(x){return requestIdleCallback(x)}_cancelCallback(x){cancelIdleCallback(x)}}:m,c.DebouncedIdleTask=class{constructor(){this._queue=new c.IdleTaskQueue}set(x){this._queue.clear(),this._queue.enqueue(x)}flush(){this._queue.flush()}}},9282:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.updateWindowsModeWrappedState=void 0;const h=d(643);c.updateWindowsModeWrappedState=function(p){const m=p.buffer.lines.get(p.buffer.ybase+p.buffer.y-1),x=m==null?void 0:m.get(p.cols-1),y=p.buffer.lines.get(p.buffer.ybase+p.buffer.y);y&&x&&(y.isWrapped=x[h.CHAR_DATA_CODE_INDEX]!==h.NULL_CELL_CODE&&x[h.CHAR_DATA_CODE_INDEX]!==h.WHITESPACE_CELL_CODE)}},3734:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ExtendedAttrs=c.AttributeData=void 0;class d{constructor(){this.fg=0,this.bg=0,this.extended=new h}static toColorRGB(m){return[m>>>16&255,m>>>8&255,255&m]}static fromColorRGB(m){return(255&m[0])<<16|(255&m[1])<<8|255&m[2]}clone(){const m=new d;return m.fg=this.fg,m.bg=this.bg,m.extended=this.extended.clone(),m}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}c.AttributeData=d;class h{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(m){this._ext=m}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(m){this._ext&=-469762049,this._ext|=m<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(m){this._ext&=-67108864,this._ext|=67108863&m}get urlId(){return this._urlId}set urlId(m){this._urlId=m}get underlineVariantOffset(){const m=(3758096384&this._ext)>>29;return m<0?4294967288^m:m}set underlineVariantOffset(m){this._ext&=536870911,this._ext|=m<<29&3758096384}constructor(m=0,x=0){this._ext=0,this._urlId=0,this._ext=m,this._urlId=x}clone(){return new h(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}c.ExtendedAttrs=h},9092:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Buffer=c.MAX_BUFFER_SIZE=void 0;const h=d(6349),p=d(7226),m=d(3734),x=d(8437),y=d(4634),S=d(511),C=d(643),v=d(4863),w=d(7116);c.MAX_BUFFER_SIZE=4294967295,c.Buffer=class{constructor(_,b,k){this._hasScrollback=_,this._optionsService=b,this._bufferService=k,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=x.DEFAULT_ATTR_DATA.clone(),this.savedCharset=w.DEFAULT_CHARSET,this.markers=[],this._nullCell=S.CellData.fromCharData([0,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),this._whitespaceCell=S.CellData.fromCharData([0,C.WHITESPACE_CELL_CHAR,C.WHITESPACE_CELL_WIDTH,C.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new p.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(_){return _?(this._nullCell.fg=_.fg,this._nullCell.bg=_.bg,this._nullCell.extended=_.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new m.ExtendedAttrs),this._nullCell}getWhitespaceCell(_){return _?(this._whitespaceCell.fg=_.fg,this._whitespaceCell.bg=_.bg,this._whitespaceCell.extended=_.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new m.ExtendedAttrs),this._whitespaceCell}getBlankLine(_,b){return new x.BufferLine(this._bufferService.cols,this.getNullCell(_),b)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const _=this.ybase+this.y-this.ydisp;return _>=0&&_<this._rows}_getCorrectBufferLength(_){if(!this._hasScrollback)return _;const b=_+this._optionsService.rawOptions.scrollback;return b>c.MAX_BUFFER_SIZE?c.MAX_BUFFER_SIZE:b}fillViewportRows(_){if(this.lines.length===0){_===void 0&&(_=x.DEFAULT_ATTR_DATA);let b=this._rows;for(;b--;)this.lines.push(this.getBlankLine(_))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(_,b){const k=this.getNullCell(x.DEFAULT_ATTR_DATA);let E=0;const T=this._getCorrectBufferLength(b);if(T>this.lines.maxLength&&(this.lines.maxLength=T),this.lines.length>0){if(this._cols<_)for(let L=0;L<this.lines.length;L++)E+=+this.lines.get(L).resize(_,k);let D=0;if(this._rows<b)for(let L=this._rows;L<b;L++)this.lines.length<b+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new x.BufferLine(_,k)):this.ybase>0&&this.lines.length<=this.ybase+this.y+D+1?(this.ybase--,D++,this.ydisp>0&&this.ydisp--):this.lines.push(new x.BufferLine(_,k)));else for(let L=this._rows;L>b;L--)this.lines.length>b+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(T<this.lines.maxLength){const L=this.lines.length-T;L>0&&(this.lines.trimStart(L),this.ybase=Math.max(this.ybase-L,0),this.ydisp=Math.max(this.ydisp-L,0),this.savedY=Math.max(this.savedY-L,0)),this.lines.maxLength=T}this.x=Math.min(this.x,_-1),this.y=Math.min(this.y,b-1),D&&(this.y+=D),this.savedX=Math.min(this.savedX,_-1),this.scrollTop=0}if(this.scrollBottom=b-1,this._isReflowEnabled&&(this._reflow(_,b),this._cols>_))for(let D=0;D<this.lines.length;D++)E+=+this.lines.get(D).resize(_,k);this._cols=_,this._rows=b,this._memoryCleanupQueue.clear(),E>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let _=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,_=!1);let b=0;for(;this._memoryCleanupPosition<this.lines.length;)if(b+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),b>100)return!0;return _}get _isReflowEnabled(){const _=this._optionsService.rawOptions.windowsPty;return _&&_.buildNumber?this._hasScrollback&&_.backend==="conpty"&&_.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(_,b){this._cols!==_&&(_>this._cols?this._reflowLarger(_,b):this._reflowSmaller(_,b))}_reflowLarger(_,b){const k=(0,y.reflowLargerGetLinesToRemove)(this.lines,this._cols,_,this.ybase+this.y,this.getNullCell(x.DEFAULT_ATTR_DATA));if(k.length>0){const E=(0,y.reflowLargerCreateNewLayout)(this.lines,k);(0,y.reflowLargerApplyNewLayout)(this.lines,E.layout),this._reflowLargerAdjustViewport(_,b,E.countRemoved)}}_reflowLargerAdjustViewport(_,b,k){const E=this.getNullCell(x.DEFAULT_ATTR_DATA);let T=k;for(;T-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<b&&this.lines.push(new x.BufferLine(_,E))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-k,0)}_reflowSmaller(_,b){const k=this.getNullCell(x.DEFAULT_ATTR_DATA),E=[];let T=0;for(let D=this.lines.length-1;D>=0;D--){let L=this.lines.get(D);if(!L||!L.isWrapped&&L.getTrimmedLength()<=_)continue;const R=[L];for(;L.isWrapped&&D>0;)L=this.lines.get(--D),R.unshift(L);const M=this.ybase+this.y;if(M>=D&&M<D+R.length)continue;const W=R[R.length-1].getTrimmedLength(),z=(0,y.reflowSmallerGetNewLineLengths)(R,this._cols,_),H=z.length-R.length;let I;I=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+H):Math.max(0,this.lines.length-this.lines.maxLength+H);const U=[];for(let B=0;B<H;B++){const q=this.getBlankLine(x.DEFAULT_ATTR_DATA,!0);U.push(q)}U.length>0&&(E.push({start:D+R.length+T,newLines:U}),T+=U.length),R.push(...U);let V=z.length-1,Z=z[V];Z===0&&(V--,Z=z[V]);let ee=R.length-H-1,F=W;for(;ee>=0;){const B=Math.min(F,Z);if(R[V]===void 0)break;if(R[V].copyCellsFrom(R[ee],F-B,Z-B,B,!0),Z-=B,Z===0&&(V--,Z=z[V]),F-=B,F===0){ee--;const q=Math.max(ee,0);F=(0,y.getWrappedLineTrimmedLength)(R,q,this._cols)}}for(let B=0;B<R.length;B++)z[B]<_&&R[B].setCell(z[B],k);let O=H-I;for(;O-- >0;)this.ybase===0?this.y<b-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+T)-b&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+H,this.ybase+b-1)}if(E.length>0){const D=[],L=[];for(let V=0;V<this.lines.length;V++)L.push(this.lines.get(V));const R=this.lines.length;let M=R-1,W=0,z=E[W];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+T);let H=0;for(let V=Math.min(this.lines.maxLength-1,R+T-1);V>=0;V--)if(z&&z.start>M+H){for(let Z=z.newLines.length-1;Z>=0;Z--)this.lines.set(V--,z.newLines[Z]);V++,D.push({index:M+1,amount:z.newLines.length}),H+=z.newLines.length,z=E[++W]}else this.lines.set(V,L[M--]);let I=0;for(let V=D.length-1;V>=0;V--)D[V].index+=I,this.lines.onInsertEmitter.fire(D[V]),I+=D[V].amount;const U=Math.max(0,R+T-this.lines.maxLength);U>0&&this.lines.onTrimEmitter.fire(U)}}translateBufferLineToString(_,b,k=0,E){const T=this.lines.get(_);return T?T.translateToString(b,k,E):""}getWrappedRangeForLine(_){let b=_,k=_;for(;b>0&&this.lines.get(b).isWrapped;)b--;for(;k+1<this.lines.length&&this.lines.get(k+1).isWrapped;)k++;return{first:b,last:k}}setupTabStops(_){for(_!=null?this.tabs[_]||(_=this.prevStop(_)):(this.tabs={},_=0);_<this._cols;_+=this._optionsService.rawOptions.tabStopWidth)this.tabs[_]=!0}prevStop(_){for(_==null&&(_=this.x);!this.tabs[--_]&&_>0;);return _>=this._cols?this._cols-1:_<0?0:_}nextStop(_){for(_==null&&(_=this.x);!this.tabs[++_]&&_<this._cols;);return _>=this._cols?this._cols-1:_<0?0:_}clearMarkers(_){this._isClearing=!0;for(let b=0;b<this.markers.length;b++)this.markers[b].line===_&&(this.markers[b].dispose(),this.markers.splice(b--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let _=0;_<this.markers.length;_++)this.markers[_].dispose(),this.markers.splice(_--,1);this._isClearing=!1}addMarker(_){const b=new v.Marker(_);return this.markers.push(b),b.register(this.lines.onTrim((k=>{b.line-=k,b.line<0&&b.dispose()}))),b.register(this.lines.onInsert((k=>{b.line>=k.index&&(b.line+=k.amount)}))),b.register(this.lines.onDelete((k=>{b.line>=k.index&&b.line<k.index+k.amount&&b.dispose(),b.line>k.index&&(b.line-=k.amount)}))),b.register(b.onDispose((()=>this._removeMarker(b)))),b}_removeMarker(_){this._isClearing||this.markers.splice(this.markers.indexOf(_),1)}}},8437:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLine=c.DEFAULT_ATTR_DATA=void 0;const h=d(3734),p=d(511),m=d(643),x=d(482);c.DEFAULT_ATTR_DATA=Object.freeze(new h.AttributeData);let y=0;class S{constructor(v,w,_=!1){this.isWrapped=_,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*v);const b=w||p.CellData.fromCharData([0,m.NULL_CELL_CHAR,m.NULL_CELL_WIDTH,m.NULL_CELL_CODE]);for(let k=0;k<v;++k)this.setCell(k,b);this.length=v}get(v){const w=this._data[3*v+0],_=2097151&w;return[this._data[3*v+1],2097152&w?this._combined[v]:_?(0,x.stringFromCodePoint)(_):"",w>>22,2097152&w?this._combined[v].charCodeAt(this._combined[v].length-1):_]}set(v,w){this._data[3*v+1]=w[m.CHAR_DATA_ATTR_INDEX],w[m.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[v]=w[1],this._data[3*v+0]=2097152|v|w[m.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*v+0]=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[m.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(v){return this._data[3*v+0]>>22}hasWidth(v){return 12582912&this._data[3*v+0]}getFg(v){return this._data[3*v+1]}getBg(v){return this._data[3*v+2]}hasContent(v){return 4194303&this._data[3*v+0]}getCodePoint(v){const w=this._data[3*v+0];return 2097152&w?this._combined[v].charCodeAt(this._combined[v].length-1):2097151&w}isCombined(v){return 2097152&this._data[3*v+0]}getString(v){const w=this._data[3*v+0];return 2097152&w?this._combined[v]:2097151&w?(0,x.stringFromCodePoint)(2097151&w):""}isProtected(v){return 536870912&this._data[3*v+2]}loadCell(v,w){return y=3*v,w.content=this._data[y+0],w.fg=this._data[y+1],w.bg=this._data[y+2],2097152&w.content&&(w.combinedData=this._combined[v]),268435456&w.bg&&(w.extended=this._extendedAttrs[v]),w}setCell(v,w){2097152&w.content&&(this._combined[v]=w.combinedData),268435456&w.bg&&(this._extendedAttrs[v]=w.extended),this._data[3*v+0]=w.content,this._data[3*v+1]=w.fg,this._data[3*v+2]=w.bg}setCellFromCodepoint(v,w,_,b){268435456&b.bg&&(this._extendedAttrs[v]=b.extended),this._data[3*v+0]=w|_<<22,this._data[3*v+1]=b.fg,this._data[3*v+2]=b.bg}addCodepointToCell(v,w,_){let b=this._data[3*v+0];2097152&b?this._combined[v]+=(0,x.stringFromCodePoint)(w):2097151&b?(this._combined[v]=(0,x.stringFromCodePoint)(2097151&b)+(0,x.stringFromCodePoint)(w),b&=-2097152,b|=2097152):b=w|4194304,_&&(b&=-12582913,b|=_<<22),this._data[3*v+0]=b}insertCells(v,w,_){if((v%=this.length)&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,_),w<this.length-v){const b=new p.CellData;for(let k=this.length-v-w-1;k>=0;--k)this.setCell(v+w+k,this.loadCell(v+k,b));for(let k=0;k<w;++k)this.setCell(v+k,_)}else for(let b=v;b<this.length;++b)this.setCell(b,_);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,_)}deleteCells(v,w,_){if(v%=this.length,w<this.length-v){const b=new p.CellData;for(let k=0;k<this.length-v-w;++k)this.setCell(v+k,this.loadCell(v+w+k,b));for(let k=this.length-w;k<this.length;++k)this.setCell(k,_)}else for(let b=v;b<this.length;++b)this.setCell(b,_);v&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,_),this.getWidth(v)!==0||this.hasContent(v)||this.setCellFromCodepoint(v,0,1,_)}replaceCells(v,w,_,b=!1){if(b)for(v&&this.getWidth(v-1)===2&&!this.isProtected(v-1)&&this.setCellFromCodepoint(v-1,0,1,_),w<this.length&&this.getWidth(w-1)===2&&!this.isProtected(w)&&this.setCellFromCodepoint(w,0,1,_);v<w&&v<this.length;)this.isProtected(v)||this.setCell(v,_),v++;else for(v&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,_),w<this.length&&this.getWidth(w-1)===2&&this.setCellFromCodepoint(w,0,1,_);v<w&&v<this.length;)this.setCell(v++,_)}resize(v,w){if(v===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const _=3*v;if(v>this.length){if(this._data.buffer.byteLength>=4*_)this._data=new Uint32Array(this._data.buffer,0,_);else{const b=new Uint32Array(_);b.set(this._data),this._data=b}for(let b=this.length;b<v;++b)this.setCell(b,w)}else{this._data=this._data.subarray(0,_);const b=Object.keys(this._combined);for(let E=0;E<b.length;E++){const T=parseInt(b[E],10);T>=v&&delete this._combined[T]}const k=Object.keys(this._extendedAttrs);for(let E=0;E<k.length;E++){const T=parseInt(k[E],10);T>=v&&delete this._extendedAttrs[T]}}return this.length=v,4*_*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const v=new Uint32Array(this._data.length);return v.set(this._data),this._data=v,1}return 0}fill(v,w=!1){if(w)for(let _=0;_<this.length;++_)this.isProtected(_)||this.setCell(_,v);else{this._combined={},this._extendedAttrs={};for(let _=0;_<this.length;++_)this.setCell(_,v)}}copyFrom(v){this.length!==v.length?this._data=new Uint32Array(v._data):this._data.set(v._data),this.length=v.length,this._combined={};for(const w in v._combined)this._combined[w]=v._combined[w];this._extendedAttrs={};for(const w in v._extendedAttrs)this._extendedAttrs[w]=v._extendedAttrs[w];this.isWrapped=v.isWrapped}clone(){const v=new S(0);v._data=new Uint32Array(this._data),v.length=this.length;for(const w in this._combined)v._combined[w]=this._combined[w];for(const w in this._extendedAttrs)v._extendedAttrs[w]=this._extendedAttrs[w];return v.isWrapped=this.isWrapped,v}getTrimmedLength(){for(let v=this.length-1;v>=0;--v)if(4194303&this._data[3*v+0])return v+(this._data[3*v+0]>>22);return 0}getNoBgTrimmedLength(){for(let v=this.length-1;v>=0;--v)if(4194303&this._data[3*v+0]||50331648&this._data[3*v+2])return v+(this._data[3*v+0]>>22);return 0}copyCellsFrom(v,w,_,b,k){const E=v._data;if(k)for(let D=b-1;D>=0;D--){for(let L=0;L<3;L++)this._data[3*(_+D)+L]=E[3*(w+D)+L];268435456&E[3*(w+D)+2]&&(this._extendedAttrs[_+D]=v._extendedAttrs[w+D])}else for(let D=0;D<b;D++){for(let L=0;L<3;L++)this._data[3*(_+D)+L]=E[3*(w+D)+L];268435456&E[3*(w+D)+2]&&(this._extendedAttrs[_+D]=v._extendedAttrs[w+D])}const T=Object.keys(v._combined);for(let D=0;D<T.length;D++){const L=parseInt(T[D],10);L>=w&&(this._combined[L-w+_]=v._combined[L])}}translateToString(v,w,_,b){w=w??0,_=_??this.length,v&&(_=Math.min(_,this.getTrimmedLength())),b&&(b.length=0);let k="";for(;w<_;){const E=this._data[3*w+0],T=2097151&E,D=2097152&E?this._combined[w]:T?(0,x.stringFromCodePoint)(T):m.WHITESPACE_CELL_CHAR;if(k+=D,b)for(let L=0;L<D.length;++L)b.push(w);w+=E>>22||1}return b&&b.push(w),k}}c.BufferLine=S},4841:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.getRangeLength=void 0,c.getRangeLength=function(d,h){if(d.start.y>d.end.y)throw new Error(`Buffer range end (${d.end.x}, ${d.end.y}) cannot be before start (${d.start.x}, ${d.start.y})`);return h*(d.end.y-d.start.y)+(d.end.x-d.start.x+1)}},4634:(u,c)=>{function d(h,p,m){if(p===h.length-1)return h[p].getTrimmedLength();const x=!h[p].hasContent(m-1)&&h[p].getWidth(m-1)===1,y=h[p+1].getWidth(0)===2;return x&&y?m-1:m}Object.defineProperty(c,"__esModule",{value:!0}),c.getWrappedLineTrimmedLength=c.reflowSmallerGetNewLineLengths=c.reflowLargerApplyNewLayout=c.reflowLargerCreateNewLayout=c.reflowLargerGetLinesToRemove=void 0,c.reflowLargerGetLinesToRemove=function(h,p,m,x,y){const S=[];for(let C=0;C<h.length-1;C++){let v=C,w=h.get(++v);if(!w.isWrapped)continue;const _=[h.get(C)];for(;v<h.length&&w.isWrapped;)_.push(w),w=h.get(++v);if(x>=C&&x<v){C+=_.length-1;continue}let b=0,k=d(_,b,p),E=1,T=0;for(;E<_.length;){const L=d(_,E,p),R=L-T,M=m-k,W=Math.min(R,M);_[b].copyCellsFrom(_[E],T,k,W,!1),k+=W,k===m&&(b++,k=0),T+=W,T===L&&(E++,T=0),k===0&&b!==0&&_[b-1].getWidth(m-1)===2&&(_[b].copyCellsFrom(_[b-1],m-1,k++,1,!1),_[b-1].setCell(m-1,y))}_[b].replaceCells(k,m,y);let D=0;for(let L=_.length-1;L>0&&(L>b||_[L].getTrimmedLength()===0);L--)D++;D>0&&(S.push(C+_.length-D),S.push(D)),C+=_.length-1}return S},c.reflowLargerCreateNewLayout=function(h,p){const m=[];let x=0,y=p[x],S=0;for(let C=0;C<h.length;C++)if(y===C){const v=p[++x];h.onDeleteEmitter.fire({index:C-S,amount:v}),C+=v-1,S+=v,y=p[++x]}else m.push(C);return{layout:m,countRemoved:S}},c.reflowLargerApplyNewLayout=function(h,p){const m=[];for(let x=0;x<p.length;x++)m.push(h.get(p[x]));for(let x=0;x<m.length;x++)h.set(x,m[x]);h.length=p.length},c.reflowSmallerGetNewLineLengths=function(h,p,m){const x=[],y=h.map(((w,_)=>d(h,_,p))).reduce(((w,_)=>w+_));let S=0,C=0,v=0;for(;v<y;){if(y-v<m){x.push(y-v);break}S+=m;const w=d(h,C,p);S>w&&(S-=w,C++);const _=h[C].getWidth(S-1)===2;_&&S--;const b=_?m-1:m;x.push(b),v+=b}return x},c.getWrappedLineTrimmedLength=d},5295:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferSet=void 0;const h=d(8460),p=d(844),m=d(9092);class x extends p.Disposable{constructor(S,C){super(),this._optionsService=S,this._bufferService=C,this._onBufferActivate=this.register(new h.EventEmitter),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 m.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new m.Buffer(!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(S){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(S),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(S,C){this._normal.resize(S,C),this._alt.resize(S,C),this.setupTabStops(S)}setupTabStops(S){this._normal.setupTabStops(S),this._alt.setupTabStops(S)}}c.BufferSet=x},511:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CellData=void 0;const h=d(482),p=d(643),m=d(3734);class x extends m.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new m.ExtendedAttrs,this.combinedData=""}static fromCharData(S){const C=new x;return C.setFromCharData(S),C}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,h.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(S){this.fg=S[p.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(S[p.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(S[p.CHAR_DATA_CHAR_INDEX].length===2){const v=S[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=v&&v<=56319){const w=S[p.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=w&&w<=57343?this.content=1024*(v-55296)+w-56320+65536|S[p.CHAR_DATA_WIDTH_INDEX]<<22:C=!0}else C=!0}else this.content=S[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[p.CHAR_DATA_WIDTH_INDEX]<<22;C&&(this.combinedData=S[p.CHAR_DATA_CHAR_INDEX],this.content=2097152|S[p.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.CellData=x},643:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WHITESPACE_CELL_CODE=c.WHITESPACE_CELL_WIDTH=c.WHITESPACE_CELL_CHAR=c.NULL_CELL_CODE=c.NULL_CELL_WIDTH=c.NULL_CELL_CHAR=c.CHAR_DATA_CODE_INDEX=c.CHAR_DATA_WIDTH_INDEX=c.CHAR_DATA_CHAR_INDEX=c.CHAR_DATA_ATTR_INDEX=c.DEFAULT_EXT=c.DEFAULT_ATTR=c.DEFAULT_COLOR=void 0,c.DEFAULT_COLOR=0,c.DEFAULT_ATTR=256|c.DEFAULT_COLOR<<9,c.DEFAULT_EXT=0,c.CHAR_DATA_ATTR_INDEX=0,c.CHAR_DATA_CHAR_INDEX=1,c.CHAR_DATA_WIDTH_INDEX=2,c.CHAR_DATA_CODE_INDEX=3,c.NULL_CELL_CHAR="",c.NULL_CELL_WIDTH=1,c.NULL_CELL_CODE=0,c.WHITESPACE_CELL_CHAR=" ",c.WHITESPACE_CELL_WIDTH=1,c.WHITESPACE_CELL_CODE=32},4863:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Marker=void 0;const h=d(8460),p=d(844);class m{get id(){return this._id}constructor(y){this.line=y,this.isDisposed=!1,this._disposables=[],this._id=m._nextId++,this._onDispose=this.register(new h.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,p.disposeArray)(this._disposables),this._disposables.length=0)}register(y){return this._disposables.push(y),y}}c.Marker=m,m._nextId=1},7116:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DEFAULT_CHARSET=c.CHARSETS=void 0,c.CHARSETS={},c.DEFAULT_CHARSET=c.CHARSETS.B,c.CHARSETS[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:"≥","{":"π","|":"≠","}":"£","~":"·"},c.CHARSETS.A={"#":"£"},c.CHARSETS.B=void 0,c.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},c.CHARSETS.C=c.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},c.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},c.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},c.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},c.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},c.CHARSETS.E=c.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},c.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},c.CHARSETS.H=c.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},c.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(u,c)=>{var d,h,p;Object.defineProperty(c,"__esModule",{value:!0}),c.C1_ESCAPED=c.C1=c.C0=void 0,(function(m){m.NUL="\0",m.SOH="",m.STX="",m.ETX="",m.EOT="",m.ENQ="",m.ACK="",m.BEL="\x07",m.BS="\b",m.HT=" ",m.LF=`
|
|
260
|
+
`,m.VT="\v",m.FF="\f",m.CR="\r",m.SO="",m.SI="",m.DLE="",m.DC1="",m.DC2="",m.DC3="",m.DC4="",m.NAK="",m.SYN="",m.ETB="",m.CAN="",m.EM="",m.SUB="",m.ESC="\x1B",m.FS="",m.GS="",m.RS="",m.US="",m.SP=" ",m.DEL=""})(d||(c.C0=d={})),(function(m){m.PAD="",m.HOP="",m.BPH="",m.NBH="",m.IND="",m.NEL="
",m.SSA="",m.ESA="",m.HTS="",m.HTJ="",m.VTS="",m.PLD="",m.PLU="",m.RI="",m.SS2="",m.SS3="",m.DCS="",m.PU1="",m.PU2="",m.STS="",m.CCH="",m.MW="",m.SPA="",m.EPA="",m.SOS="",m.SGCI="",m.SCI="",m.CSI="",m.ST="",m.OSC="",m.PM="",m.APC=""})(h||(c.C1=h={})),(function(m){m.ST=`${d.ESC}\\`})(p||(c.C1_ESCAPED=p={}))},7399:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.evaluateKeyboardEvent=void 0;const h=d(2584),p={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:["'",'"']};c.evaluateKeyboardEvent=function(m,x,y,S){const C={type:0,cancel:!1,key:void 0},v=(m.shiftKey?1:0)|(m.altKey?2:0)|(m.ctrlKey?4:0)|(m.metaKey?8:0);switch(m.keyCode){case 0:m.key==="UIKeyInputUpArrow"?C.key=x?h.C0.ESC+"OA":h.C0.ESC+"[A":m.key==="UIKeyInputLeftArrow"?C.key=x?h.C0.ESC+"OD":h.C0.ESC+"[D":m.key==="UIKeyInputRightArrow"?C.key=x?h.C0.ESC+"OC":h.C0.ESC+"[C":m.key==="UIKeyInputDownArrow"&&(C.key=x?h.C0.ESC+"OB":h.C0.ESC+"[B");break;case 8:C.key=m.ctrlKey?"\b":h.C0.DEL,m.altKey&&(C.key=h.C0.ESC+C.key);break;case 9:if(m.shiftKey){C.key=h.C0.ESC+"[Z";break}C.key=h.C0.HT,C.cancel=!0;break;case 13:C.key=m.altKey?h.C0.ESC+h.C0.CR:h.C0.CR,C.cancel=!0;break;case 27:C.key=h.C0.ESC,m.altKey&&(C.key=h.C0.ESC+h.C0.ESC),C.cancel=!0;break;case 37:if(m.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"D",C.key===h.C0.ESC+"[1;3D"&&(C.key=h.C0.ESC+(y?"b":"[1;5D"))):C.key=x?h.C0.ESC+"OD":h.C0.ESC+"[D";break;case 39:if(m.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"C",C.key===h.C0.ESC+"[1;3C"&&(C.key=h.C0.ESC+(y?"f":"[1;5C"))):C.key=x?h.C0.ESC+"OC":h.C0.ESC+"[C";break;case 38:if(m.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"A",y||C.key!==h.C0.ESC+"[1;3A"||(C.key=h.C0.ESC+"[1;5A")):C.key=x?h.C0.ESC+"OA":h.C0.ESC+"[A";break;case 40:if(m.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"B",y||C.key!==h.C0.ESC+"[1;3B"||(C.key=h.C0.ESC+"[1;5B")):C.key=x?h.C0.ESC+"OB":h.C0.ESC+"[B";break;case 45:m.shiftKey||m.ctrlKey||(C.key=h.C0.ESC+"[2~");break;case 46:C.key=v?h.C0.ESC+"[3;"+(v+1)+"~":h.C0.ESC+"[3~";break;case 36:C.key=v?h.C0.ESC+"[1;"+(v+1)+"H":x?h.C0.ESC+"OH":h.C0.ESC+"[H";break;case 35:C.key=v?h.C0.ESC+"[1;"+(v+1)+"F":x?h.C0.ESC+"OF":h.C0.ESC+"[F";break;case 33:m.shiftKey?C.type=2:m.ctrlKey?C.key=h.C0.ESC+"[5;"+(v+1)+"~":C.key=h.C0.ESC+"[5~";break;case 34:m.shiftKey?C.type=3:m.ctrlKey?C.key=h.C0.ESC+"[6;"+(v+1)+"~":C.key=h.C0.ESC+"[6~";break;case 112:C.key=v?h.C0.ESC+"[1;"+(v+1)+"P":h.C0.ESC+"OP";break;case 113:C.key=v?h.C0.ESC+"[1;"+(v+1)+"Q":h.C0.ESC+"OQ";break;case 114:C.key=v?h.C0.ESC+"[1;"+(v+1)+"R":h.C0.ESC+"OR";break;case 115:C.key=v?h.C0.ESC+"[1;"+(v+1)+"S":h.C0.ESC+"OS";break;case 116:C.key=v?h.C0.ESC+"[15;"+(v+1)+"~":h.C0.ESC+"[15~";break;case 117:C.key=v?h.C0.ESC+"[17;"+(v+1)+"~":h.C0.ESC+"[17~";break;case 118:C.key=v?h.C0.ESC+"[18;"+(v+1)+"~":h.C0.ESC+"[18~";break;case 119:C.key=v?h.C0.ESC+"[19;"+(v+1)+"~":h.C0.ESC+"[19~";break;case 120:C.key=v?h.C0.ESC+"[20;"+(v+1)+"~":h.C0.ESC+"[20~";break;case 121:C.key=v?h.C0.ESC+"[21;"+(v+1)+"~":h.C0.ESC+"[21~";break;case 122:C.key=v?h.C0.ESC+"[23;"+(v+1)+"~":h.C0.ESC+"[23~";break;case 123:C.key=v?h.C0.ESC+"[24;"+(v+1)+"~":h.C0.ESC+"[24~";break;default:if(!m.ctrlKey||m.shiftKey||m.altKey||m.metaKey)if(y&&!S||!m.altKey||m.metaKey)!y||m.altKey||m.ctrlKey||m.shiftKey||!m.metaKey?m.key&&!m.ctrlKey&&!m.altKey&&!m.metaKey&&m.keyCode>=48&&m.key.length===1?C.key=m.key:m.key&&m.ctrlKey&&(m.key==="_"&&(C.key=h.C0.US),m.key==="@"&&(C.key=h.C0.NUL)):m.keyCode===65&&(C.type=1);else{const w=p[m.keyCode],_=w==null?void 0:w[m.shiftKey?1:0];if(_)C.key=h.C0.ESC+_;else if(m.keyCode>=65&&m.keyCode<=90){const b=m.ctrlKey?m.keyCode-64:m.keyCode+32;let k=String.fromCharCode(b);m.shiftKey&&(k=k.toUpperCase()),C.key=h.C0.ESC+k}else if(m.keyCode===32)C.key=h.C0.ESC+(m.ctrlKey?h.C0.NUL:" ");else if(m.key==="Dead"&&m.code.startsWith("Key")){let b=m.code.slice(3,4);m.shiftKey||(b=b.toLowerCase()),C.key=h.C0.ESC+b,C.cancel=!0}}else m.keyCode>=65&&m.keyCode<=90?C.key=String.fromCharCode(m.keyCode-64):m.keyCode===32?C.key=h.C0.NUL:m.keyCode>=51&&m.keyCode<=55?C.key=String.fromCharCode(m.keyCode-51+27):m.keyCode===56?C.key=h.C0.DEL:m.keyCode===219?C.key=h.C0.ESC:m.keyCode===220?C.key=h.C0.FS:m.keyCode===221&&(C.key=h.C0.GS)}return C}},482:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Utf8ToUtf32=c.StringToUtf32=c.utf32ToString=c.stringFromCodePoint=void 0,c.stringFromCodePoint=function(d){return d>65535?(d-=65536,String.fromCharCode(55296+(d>>10))+String.fromCharCode(d%1024+56320)):String.fromCharCode(d)},c.utf32ToString=function(d,h=0,p=d.length){let m="";for(let x=h;x<p;++x){let y=d[x];y>65535?(y-=65536,m+=String.fromCharCode(55296+(y>>10))+String.fromCharCode(y%1024+56320)):m+=String.fromCharCode(y)}return m},c.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(d,h){const p=d.length;if(!p)return 0;let m=0,x=0;if(this._interim){const y=d.charCodeAt(x++);56320<=y&&y<=57343?h[m++]=1024*(this._interim-55296)+y-56320+65536:(h[m++]=this._interim,h[m++]=y),this._interim=0}for(let y=x;y<p;++y){const S=d.charCodeAt(y);if(55296<=S&&S<=56319){if(++y>=p)return this._interim=S,m;const C=d.charCodeAt(y);56320<=C&&C<=57343?h[m++]=1024*(S-55296)+C-56320+65536:(h[m++]=S,h[m++]=C)}else S!==65279&&(h[m++]=S)}return m}},c.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(d,h){const p=d.length;if(!p)return 0;let m,x,y,S,C=0,v=0,w=0;if(this.interim[0]){let k=!1,E=this.interim[0];E&=(224&E)==192?31:(240&E)==224?15:7;let T,D=0;for(;(T=63&this.interim[++D])&&D<4;)E<<=6,E|=T;const L=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,R=L-D;for(;w<R;){if(w>=p)return 0;if(T=d[w++],(192&T)!=128){w--,k=!0;break}this.interim[D++]=T,E<<=6,E|=63&T}k||(L===2?E<128?w--:h[C++]=E:L===3?E<2048||E>=55296&&E<=57343||E===65279||(h[C++]=E):E<65536||E>1114111||(h[C++]=E)),this.interim.fill(0)}const _=p-4;let b=w;for(;b<p;){for(;!(!(b<_)||128&(m=d[b])||128&(x=d[b+1])||128&(y=d[b+2])||128&(S=d[b+3]));)h[C++]=m,h[C++]=x,h[C++]=y,h[C++]=S,b+=4;if(m=d[b++],m<128)h[C++]=m;else if((224&m)==192){if(b>=p)return this.interim[0]=m,C;if(x=d[b++],(192&x)!=128){b--;continue}if(v=(31&m)<<6|63&x,v<128){b--;continue}h[C++]=v}else if((240&m)==224){if(b>=p)return this.interim[0]=m,C;if(x=d[b++],(192&x)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=x,C;if(y=d[b++],(192&y)!=128){b--;continue}if(v=(15&m)<<12|(63&x)<<6|63&y,v<2048||v>=55296&&v<=57343||v===65279)continue;h[C++]=v}else if((248&m)==240){if(b>=p)return this.interim[0]=m,C;if(x=d[b++],(192&x)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=x,C;if(y=d[b++],(192&y)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=x,this.interim[2]=y,C;if(S=d[b++],(192&S)!=128){b--;continue}if(v=(7&m)<<18|(63&x)<<12|(63&y)<<6|63&S,v<65536||v>1114111)continue;h[C++]=v}}return C}}},225:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeV6=void 0;const h=d(1480),p=[[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]],m=[[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]];let x;c.UnicodeV6=class{constructor(){if(this.version="6",!x){x=new Uint8Array(65536),x.fill(1),x[0]=0,x.fill(0,1,32),x.fill(0,127,160),x.fill(2,4352,4448),x[9001]=2,x[9002]=2,x.fill(2,11904,42192),x[12351]=1,x.fill(2,44032,55204),x.fill(2,63744,64256),x.fill(2,65040,65050),x.fill(2,65072,65136),x.fill(2,65280,65377),x.fill(2,65504,65511);for(let y=0;y<p.length;++y)x.fill(0,p[y][0],p[y][1]+1)}}wcwidth(y){return y<32?0:y<127?1:y<65536?x[y]:(function(S,C){let v,w=0,_=C.length-1;if(S<C[0][0]||S>C[_][1])return!1;for(;_>=w;)if(v=w+_>>1,S>C[v][1])w=v+1;else{if(!(S<C[v][0]))return!0;_=v-1}return!1})(y,m)?0:y>=131072&&y<=196605||y>=196608&&y<=262141?2:1}charProperties(y,S){let C=this.wcwidth(y),v=C===0&&S!==0;if(v){const w=h.UnicodeService.extractWidth(S);w===0?v=!1:w>C&&(C=w)}return h.UnicodeService.createPropertyValue(0,C,v)}}},5981:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WriteBuffer=void 0;const h=d(8460),p=d(844);class m extends p.Disposable{constructor(y){super(),this._action=y,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new h.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(y,S){if(S!==void 0&&this._syncCalls>S)return void(this._syncCalls=0);if(this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let C;for(this._isSyncWriting=!0;C=this._writeBuffer.shift();){this._action(C);const v=this._callbacks.shift();v&&v()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(y,S){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(S),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(S)}_innerWrite(y=0,S=!0){const C=y||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const v=this._writeBuffer[this._bufferOffset],w=this._action(v,S);if(w){const b=k=>Date.now()-C>=12?setTimeout((()=>this._innerWrite(0,k))):this._innerWrite(C,k);return void w.catch((k=>(queueMicrotask((()=>{throw k})),Promise.resolve(!1)))).then(b)}const _=this._callbacks[this._bufferOffset];if(_&&_(),this._bufferOffset++,this._pendingData-=v.length,Date.now()-C>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(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()}}c.WriteBuffer=m},5941:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.toRgbString=c.parseColor=void 0;const d=/^([\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})$/,h=/^[\da-f]+$/;function p(m,x){const y=m.toString(16),S=y.length<2?"0"+y:y;switch(x){case 4:return y[0];case 8:return S;case 12:return(S+S).slice(0,3);default:return S+S}}c.parseColor=function(m){if(!m)return;let x=m.toLowerCase();if(x.indexOf("rgb:")===0){x=x.slice(4);const y=d.exec(x);if(y){const S=y[1]?15:y[4]?255:y[7]?4095:65535;return[Math.round(parseInt(y[1]||y[4]||y[7]||y[10],16)/S*255),Math.round(parseInt(y[2]||y[5]||y[8]||y[11],16)/S*255),Math.round(parseInt(y[3]||y[6]||y[9]||y[12],16)/S*255)]}}else if(x.indexOf("#")===0&&(x=x.slice(1),h.exec(x)&&[3,6,9,12].includes(x.length))){const y=x.length/3,S=[0,0,0];for(let C=0;C<3;++C){const v=parseInt(x.slice(y*C,y*C+y),16);S[C]=y===1?v<<4:y===2?v:y===3?v>>4:v>>8}return S}},c.toRgbString=function(m,x=16){const[y,S,C]=m;return`rgb:${p(y,x)}/${p(S,x)}/${p(C,x)}`}},5770:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.PAYLOAD_LIMIT=void 0,c.PAYLOAD_LIMIT=1e7},6351:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DcsHandler=c.DcsParser=void 0;const h=d(482),p=d(8742),m=d(5770),x=[];c.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=x,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=x}registerHandler(S,C){this._handlers[S]===void 0&&(this._handlers[S]=[]);const v=this._handlers[S];return v.push(C),{dispose:()=>{const w=v.indexOf(C);w!==-1&&v.splice(w,1)}}}clearHandler(S){this._handlers[S]&&delete this._handlers[S]}setHandlerFallback(S){this._handlerFb=S}reset(){if(this._active.length)for(let S=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;S>=0;--S)this._active[S].unhook(!1);this._stack.paused=!1,this._active=x,this._ident=0}hook(S,C){if(this.reset(),this._ident=S,this._active=this._handlers[S]||x,this._active.length)for(let v=this._active.length-1;v>=0;v--)this._active[v].hook(C);else this._handlerFb(this._ident,"HOOK",C)}put(S,C,v){if(this._active.length)for(let w=this._active.length-1;w>=0;w--)this._active[w].put(S,C,v);else this._handlerFb(this._ident,"PUT",(0,h.utf32ToString)(S,C,v))}unhook(S,C=!0){if(this._active.length){let v=!1,w=this._active.length-1,_=!1;if(this._stack.paused&&(w=this._stack.loopPosition-1,v=C,_=this._stack.fallThrough,this._stack.paused=!1),!_&&v===!1){for(;w>=0&&(v=this._active[w].unhook(S),v!==!0);w--)if(v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!1,v;w--}for(;w>=0;w--)if(v=this._active[w].unhook(!1),v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!0,v}else this._handlerFb(this._ident,"UNHOOK",S);this._active=x,this._ident=0}};const y=new p.Params;y.addParam(0),c.DcsHandler=class{constructor(S){this._handler=S,this._data="",this._params=y,this._hitLimit=!1}hook(S){this._params=S.length>1||S.params[0]?S.clone():y,this._data="",this._hitLimit=!1}put(S,C,v){this._hitLimit||(this._data+=(0,h.utf32ToString)(S,C,v),this._data.length>m.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(S){let C=!1;if(this._hitLimit)C=!1;else if(S&&(C=this._handler(this._data,this._params),C instanceof Promise))return C.then((v=>(this._params=y,this._data="",this._hitLimit=!1,v)));return this._params=y,this._data="",this._hitLimit=!1,C}}},2015:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.EscapeSequenceParser=c.VT500_TRANSITION_TABLE=c.TransitionTable=void 0;const h=d(844),p=d(8742),m=d(6242),x=d(6351);class y{constructor(w){this.table=new Uint8Array(w)}setDefault(w,_){this.table.fill(w<<4|_)}add(w,_,b,k){this.table[_<<8|w]=b<<4|k}addMany(w,_,b,k){for(let E=0;E<w.length;E++)this.table[_<<8|w[E]]=b<<4|k}}c.TransitionTable=y;const S=160;c.VT500_TRANSITION_TABLE=(function(){const v=new y(4095),w=Array.apply(null,Array(256)).map(((D,L)=>L)),_=(D,L)=>w.slice(D,L),b=_(32,127),k=_(0,24);k.push(25),k.push.apply(k,_(28,32));const E=_(0,14);let T;for(T in v.setDefault(1,0),v.addMany(b,0,2,0),E)v.addMany([24,26,153,154],T,3,0),v.addMany(_(128,144),T,3,0),v.addMany(_(144,152),T,3,0),v.add(156,T,0,0),v.add(27,T,11,1),v.add(157,T,4,8),v.addMany([152,158,159],T,0,7),v.add(155,T,11,3),v.add(144,T,11,9);return v.addMany(k,0,3,0),v.addMany(k,1,3,1),v.add(127,1,0,1),v.addMany(k,8,0,8),v.addMany(k,3,3,3),v.add(127,3,0,3),v.addMany(k,4,3,4),v.add(127,4,0,4),v.addMany(k,6,3,6),v.addMany(k,5,3,5),v.add(127,5,0,5),v.addMany(k,2,3,2),v.add(127,2,0,2),v.add(93,1,4,8),v.addMany(b,8,5,8),v.add(127,8,5,8),v.addMany([156,27,24,26,7],8,6,0),v.addMany(_(28,32),8,0,8),v.addMany([88,94,95],1,0,7),v.addMany(b,7,0,7),v.addMany(k,7,0,7),v.add(156,7,0,0),v.add(127,7,0,7),v.add(91,1,11,3),v.addMany(_(64,127),3,7,0),v.addMany(_(48,60),3,8,4),v.addMany([60,61,62,63],3,9,4),v.addMany(_(48,60),4,8,4),v.addMany(_(64,127),4,7,0),v.addMany([60,61,62,63],4,0,6),v.addMany(_(32,64),6,0,6),v.add(127,6,0,6),v.addMany(_(64,127),6,0,0),v.addMany(_(32,48),3,9,5),v.addMany(_(32,48),5,9,5),v.addMany(_(48,64),5,0,6),v.addMany(_(64,127),5,7,0),v.addMany(_(32,48),4,9,5),v.addMany(_(32,48),1,9,2),v.addMany(_(32,48),2,9,2),v.addMany(_(48,127),2,10,0),v.addMany(_(48,80),1,10,0),v.addMany(_(81,88),1,10,0),v.addMany([89,90,92],1,10,0),v.addMany(_(96,127),1,10,0),v.add(80,1,11,9),v.addMany(k,9,0,9),v.add(127,9,0,9),v.addMany(_(28,32),9,0,9),v.addMany(_(32,48),9,9,12),v.addMany(_(48,60),9,8,10),v.addMany([60,61,62,63],9,9,10),v.addMany(k,11,0,11),v.addMany(_(32,128),11,0,11),v.addMany(_(28,32),11,0,11),v.addMany(k,10,0,10),v.add(127,10,0,10),v.addMany(_(28,32),10,0,10),v.addMany(_(48,60),10,8,10),v.addMany([60,61,62,63],10,0,11),v.addMany(_(32,48),10,9,12),v.addMany(k,12,0,12),v.add(127,12,0,12),v.addMany(_(28,32),12,0,12),v.addMany(_(32,48),12,9,12),v.addMany(_(48,64),12,0,11),v.addMany(_(64,127),12,12,13),v.addMany(_(64,127),10,12,13),v.addMany(_(64,127),9,12,13),v.addMany(k,13,13,13),v.addMany(b,13,13,13),v.add(127,13,0,13),v.addMany([27,156,24,26],13,14,0),v.add(S,0,2,0),v.add(S,8,5,8),v.add(S,6,0,6),v.add(S,11,0,11),v.add(S,13,13,13),v})();class C extends h.Disposable{constructor(w=c.VT500_TRANSITION_TABLE){super(),this._transitions=w,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new p.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(_,b,k)=>{},this._executeHandlerFb=_=>{},this._csiHandlerFb=(_,b)=>{},this._escHandlerFb=_=>{},this._errorHandlerFb=_=>_,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,h.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new m.OscParser),this._dcsParser=this.register(new x.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(w,_=[64,126]){let b=0;if(w.prefix){if(w.prefix.length>1)throw new Error("only one byte as prefix supported");if(b=w.prefix.charCodeAt(0),b&&60>b||b>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(w.intermediates){if(w.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let E=0;E<w.intermediates.length;++E){const T=w.intermediates.charCodeAt(E);if(32>T||T>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");b<<=8,b|=T}}if(w.final.length!==1)throw new Error("final must be a single byte");const k=w.final.charCodeAt(0);if(_[0]>k||k>_[1])throw new Error(`final must be in range ${_[0]} .. ${_[1]}`);return b<<=8,b|=k,b}identToString(w){const _=[];for(;w;)_.push(String.fromCharCode(255&w)),w>>=8;return _.reverse().join("")}setPrintHandler(w){this._printHandler=w}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(w,_){const b=this._identifier(w,[48,126]);this._escHandlers[b]===void 0&&(this._escHandlers[b]=[]);const k=this._escHandlers[b];return k.push(_),{dispose:()=>{const E=k.indexOf(_);E!==-1&&k.splice(E,1)}}}clearEscHandler(w){this._escHandlers[this._identifier(w,[48,126])]&&delete this._escHandlers[this._identifier(w,[48,126])]}setEscHandlerFallback(w){this._escHandlerFb=w}setExecuteHandler(w,_){this._executeHandlers[w.charCodeAt(0)]=_}clearExecuteHandler(w){this._executeHandlers[w.charCodeAt(0)]&&delete this._executeHandlers[w.charCodeAt(0)]}setExecuteHandlerFallback(w){this._executeHandlerFb=w}registerCsiHandler(w,_){const b=this._identifier(w);this._csiHandlers[b]===void 0&&(this._csiHandlers[b]=[]);const k=this._csiHandlers[b];return k.push(_),{dispose:()=>{const E=k.indexOf(_);E!==-1&&k.splice(E,1)}}}clearCsiHandler(w){this._csiHandlers[this._identifier(w)]&&delete this._csiHandlers[this._identifier(w)]}setCsiHandlerFallback(w){this._csiHandlerFb=w}registerDcsHandler(w,_){return this._dcsParser.registerHandler(this._identifier(w),_)}clearDcsHandler(w){this._dcsParser.clearHandler(this._identifier(w))}setDcsHandlerFallback(w){this._dcsParser.setHandlerFallback(w)}registerOscHandler(w,_){return this._oscParser.registerHandler(w,_)}clearOscHandler(w){this._oscParser.clearHandler(w)}setOscHandlerFallback(w){this._oscParser.setHandlerFallback(w)}setErrorHandler(w){this._errorHandler=w}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(w,_,b,k,E){this._parseStack.state=w,this._parseStack.handlers=_,this._parseStack.handlerPos=b,this._parseStack.transition=k,this._parseStack.chunkPos=E}parse(w,_,b){let k,E=0,T=0,D=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,D=this._parseStack.chunkPos+1;else{if(b===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const L=this._parseStack.handlers;let R=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(b===!1&&R>-1){for(;R>=0&&(k=L[R](this._params),k!==!0);R--)if(k instanceof Promise)return this._parseStack.handlerPos=R,k}this._parseStack.handlers=[];break;case 4:if(b===!1&&R>-1){for(;R>=0&&(k=L[R](),k!==!0);R--)if(k instanceof Promise)return this._parseStack.handlerPos=R,k}this._parseStack.handlers=[];break;case 6:if(E=w[this._parseStack.chunkPos],k=this._dcsParser.unhook(E!==24&&E!==26,b),k)return k;E===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(E=w[this._parseStack.chunkPos],k=this._oscParser.end(E!==24&&E!==26,b),k)return k;E===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,D=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let L=D;L<_;++L){switch(E=w[L],T=this._transitions.table[this.currentState<<8|(E<160?E:S)],T>>4){case 2:for(let H=L+1;;++H){if(H>=_||(E=w[H])<32||E>126&&E<S){this._printHandler(w,L,H),L=H-1;break}if(++H>=_||(E=w[H])<32||E>126&&E<S){this._printHandler(w,L,H),L=H-1;break}if(++H>=_||(E=w[H])<32||E>126&&E<S){this._printHandler(w,L,H),L=H-1;break}if(++H>=_||(E=w[H])<32||E>126&&E<S){this._printHandler(w,L,H),L=H-1;break}}break;case 3:this._executeHandlers[E]?this._executeHandlers[E]():this._executeHandlerFb(E),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:L,code:E,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const R=this._csiHandlers[this._collect<<8|E];let M=R?R.length-1:-1;for(;M>=0&&(k=R[M](this._params),k!==!0);M--)if(k instanceof Promise)return this._preserveStack(3,R,M,T,L),k;M<0&&this._csiHandlerFb(this._collect<<8|E,this._params),this.precedingJoinState=0;break;case 8:do switch(E){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(E-48)}while(++L<_&&(E=w[L])>47&&E<60);L--;break;case 9:this._collect<<=8,this._collect|=E;break;case 10:const W=this._escHandlers[this._collect<<8|E];let z=W?W.length-1:-1;for(;z>=0&&(k=W[z](),k!==!0);z--)if(k instanceof Promise)return this._preserveStack(4,W,z,T,L),k;z<0&&this._escHandlerFb(this._collect<<8|E),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|E,this._params);break;case 13:for(let H=L+1;;++H)if(H>=_||(E=w[H])===24||E===26||E===27||E>127&&E<S){this._dcsParser.put(w,L,H),L=H-1;break}break;case 14:if(k=this._dcsParser.unhook(E!==24&&E!==26),k)return this._preserveStack(6,[],0,T,L),k;E===27&&(T|=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 H=L+1;;H++)if(H>=_||(E=w[H])<32||E>127&&E<S){this._oscParser.put(w,L,H),L=H-1;break}break;case 6:if(k=this._oscParser.end(E!==24&&E!==26),k)return this._preserveStack(5,[],0,T,L),k;E===27&&(T|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&T}}}c.EscapeSequenceParser=C},6242:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OscHandler=c.OscParser=void 0;const h=d(5770),p=d(482),m=[];c.OscParser=class{constructor(){this._state=0,this._active=m,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(x,y){this._handlers[x]===void 0&&(this._handlers[x]=[]);const S=this._handlers[x];return S.push(y),{dispose:()=>{const C=S.indexOf(y);C!==-1&&S.splice(C,1)}}}clearHandler(x){this._handlers[x]&&delete this._handlers[x]}setHandlerFallback(x){this._handlerFb=x}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}reset(){if(this._state===2)for(let x=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;x>=0;--x)this._active[x].end(!1);this._stack.paused=!1,this._active=m,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||m,this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].start();else this._handlerFb(this._id,"START")}_put(x,y,S){if(this._active.length)for(let C=this._active.length-1;C>=0;C--)this._active[C].put(x,y,S);else this._handlerFb(this._id,"PUT",(0,p.utf32ToString)(x,y,S))}start(){this.reset(),this._state=1}put(x,y,S){if(this._state!==3){if(this._state===1)for(;y<S;){const C=x[y++];if(C===59){this._state=2,this._start();break}if(C<48||57<C)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+C-48}this._state===2&&S-y>0&&this._put(x,y,S)}}end(x,y=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let S=!1,C=this._active.length-1,v=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,S=y,v=this._stack.fallThrough,this._stack.paused=!1),!v&&S===!1){for(;C>=0&&(S=this._active[C].end(x),S!==!0);C--)if(S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!1,S;C--}for(;C>=0;C--)if(S=this._active[C].end(!1),S instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!0,S}else this._handlerFb(this._id,"END",x);this._active=m,this._id=-1,this._state=0}}},c.OscHandler=class{constructor(x){this._handler=x,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(x,y,S){this._hitLimit||(this._data+=(0,p.utf32ToString)(x,y,S),this._data.length>h.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(x){let y=!1;if(this._hitLimit)y=!1;else if(x&&(y=this._handler(this._data),y instanceof Promise))return y.then((S=>(this._data="",this._hitLimit=!1,S)));return this._data="",this._hitLimit=!1,y}}},8742:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Params=void 0;const d=2147483647;class h{static fromArray(m){const x=new h;if(!m.length)return x;for(let y=Array.isArray(m[0])?1:0;y<m.length;++y){const S=m[y];if(Array.isArray(S))for(let C=0;C<S.length;++C)x.addSubParam(S[C]);else x.addParam(S)}return x}constructor(m=32,x=32){if(this.maxLength=m,this.maxSubParamsLength=x,x>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(m),this.length=0,this._subParams=new Int32Array(x),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(m),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const m=new h(this.maxLength,this.maxSubParamsLength);return m.params.set(this.params),m.length=this.length,m._subParams.set(this._subParams),m._subParamsLength=this._subParamsLength,m._subParamsIdx.set(this._subParamsIdx),m._rejectDigits=this._rejectDigits,m._rejectSubDigits=this._rejectSubDigits,m._digitIsSub=this._digitIsSub,m}toArray(){const m=[];for(let x=0;x<this.length;++x){m.push(this.params[x]);const y=this._subParamsIdx[x]>>8,S=255&this._subParamsIdx[x];S-y>0&&m.push(Array.prototype.slice.call(this._subParams,y,S))}return m}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(m){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(m<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=m>d?d:m}}addSubParam(m){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(m<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=m>d?d:m,this._subParamsIdx[this.length-1]++}}hasSubParams(m){return(255&this._subParamsIdx[m])-(this._subParamsIdx[m]>>8)>0}getSubParams(m){const x=this._subParamsIdx[m]>>8,y=255&this._subParamsIdx[m];return y-x>0?this._subParams.subarray(x,y):null}getSubParamsAll(){const m={};for(let x=0;x<this.length;++x){const y=this._subParamsIdx[x]>>8,S=255&this._subParamsIdx[x];S-y>0&&(m[x]=this._subParams.slice(y,S))}return m}addDigit(m){let x;if(this._rejectDigits||!(x=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const y=this._digitIsSub?this._subParams:this.params,S=y[x-1];y[x-1]=~S?Math.min(10*S+m,d):m}}c.Params=h},5741:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.AddonManager=void 0,c.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let d=this._addons.length-1;d>=0;d--)this._addons[d].instance.dispose()}loadAddon(d,h){const p={instance:h,dispose:h.dispose,isDisposed:!1};this._addons.push(p),h.dispose=()=>this._wrappedAddonDispose(p),h.activate(d)}_wrappedAddonDispose(d){if(d.isDisposed)return;let h=-1;for(let p=0;p<this._addons.length;p++)if(this._addons[p]===d){h=p;break}if(h===-1)throw new Error("Could not dispose an addon that has not been loaded");d.isDisposed=!0,d.dispose.apply(d.instance),this._addons.splice(h,1)}}},8771:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferApiView=void 0;const h=d(3785),p=d(511);c.BufferApiView=class{constructor(m,x){this._buffer=m,this.type=x}init(m){return this._buffer=m,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(m){const x=this._buffer.lines.get(m);if(x)return new h.BufferLineApiView(x)}getNullCell(){return new p.CellData}}},3785:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLineApiView=void 0;const h=d(511);c.BufferLineApiView=class{constructor(p){this._line=p}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(p,m){if(!(p<0||p>=this._line.length))return m?(this._line.loadCell(p,m),m):this._line.loadCell(p,new h.CellData)}translateToString(p,m,x){return this._line.translateToString(p,m,x)}}},8285:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferNamespaceApi=void 0;const h=d(8771),p=d(8460),m=d(844);class x extends m.Disposable{constructor(S){super(),this._core=S,this._onBufferChange=this.register(new p.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new h.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new h.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}c.BufferNamespaceApi=x},7975:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ParserApi=void 0,c.ParserApi=class{constructor(d){this._core=d}registerCsiHandler(d,h){return this._core.registerCsiHandler(d,(p=>h(p.toArray())))}addCsiHandler(d,h){return this.registerCsiHandler(d,h)}registerDcsHandler(d,h){return this._core.registerDcsHandler(d,((p,m)=>h(p,m.toArray())))}addDcsHandler(d,h){return this.registerDcsHandler(d,h)}registerEscHandler(d,h){return this._core.registerEscHandler(d,h)}addEscHandler(d,h){return this.registerEscHandler(d,h)}registerOscHandler(d,h){return this._core.registerOscHandler(d,h)}addOscHandler(d,h){return this.registerOscHandler(d,h)}}},7090:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeApi=void 0,c.UnicodeApi=class{constructor(d){this._core=d}register(d){this._core.unicodeService.register(d)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(d){this._core.unicodeService.activeVersion=d}}},744:function(u,c,d){var h=this&&this.__decorate||function(v,w,_,b){var k,E=arguments.length,T=E<3?w:b===null?b=Object.getOwnPropertyDescriptor(w,_):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(v,w,_,b);else for(var D=v.length-1;D>=0;D--)(k=v[D])&&(T=(E<3?k(T):E>3?k(w,_,T):k(w,_))||T);return E>3&&T&&Object.defineProperty(w,_,T),T},p=this&&this.__param||function(v,w){return function(_,b){w(_,b,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferService=c.MINIMUM_ROWS=c.MINIMUM_COLS=void 0;const m=d(8460),x=d(844),y=d(5295),S=d(2585);c.MINIMUM_COLS=2,c.MINIMUM_ROWS=1;let C=c.BufferService=class extends x.Disposable{get buffer(){return this.buffers.active}constructor(v){super(),this.isUserScrolling=!1,this._onResize=this.register(new m.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new m.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(v.rawOptions.cols||0,c.MINIMUM_COLS),this.rows=Math.max(v.rawOptions.rows||0,c.MINIMUM_ROWS),this.buffers=this.register(new y.BufferSet(v,this))}resize(v,w){this.cols=v,this.rows=w,this.buffers.resize(v,w),this._onResize.fire({cols:v,rows:w})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(v,w=!1){const _=this.buffer;let b;b=this._cachedBlankLine,b&&b.length===this.cols&&b.getFg(0)===v.fg&&b.getBg(0)===v.bg||(b=_.getBlankLine(v,w),this._cachedBlankLine=b),b.isWrapped=w;const k=_.ybase+_.scrollTop,E=_.ybase+_.scrollBottom;if(_.scrollTop===0){const T=_.lines.isFull;E===_.lines.length-1?T?_.lines.recycle().copyFrom(b):_.lines.push(b.clone()):_.lines.splice(E+1,0,b.clone()),T?this.isUserScrolling&&(_.ydisp=Math.max(_.ydisp-1,0)):(_.ybase++,this.isUserScrolling||_.ydisp++)}else{const T=E-k+1;_.lines.shiftElements(k+1,T-1,-1),_.lines.set(E,b.clone())}this.isUserScrolling||(_.ydisp=_.ybase),this._onScroll.fire(_.ydisp)}scrollLines(v,w,_){const b=this.buffer;if(v<0){if(b.ydisp===0)return;this.isUserScrolling=!0}else v+b.ydisp>=b.ybase&&(this.isUserScrolling=!1);const k=b.ydisp;b.ydisp=Math.max(Math.min(b.ydisp+v,b.ybase),0),k!==b.ydisp&&(w||this._onScroll.fire(b.ydisp))}};c.BufferService=C=h([p(0,S.IOptionsService)],C)},7994:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CharsetService=void 0,c.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(d){this.glevel=d,this.charset=this._charsets[d]}setgCharset(d,h){this._charsets[d]=h,this.glevel===d&&(this.charset=h)}}},1753:function(u,c,d){var h=this&&this.__decorate||function(b,k,E,T){var D,L=arguments.length,R=L<3?k:T===null?T=Object.getOwnPropertyDescriptor(k,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,k,E,T);else for(var M=b.length-1;M>=0;M--)(D=b[M])&&(R=(L<3?D(R):L>3?D(k,E,R):D(k,E))||R);return L>3&&R&&Object.defineProperty(k,E,R),R},p=this&&this.__param||function(b,k){return function(E,T){k(E,T,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreMouseService=void 0;const m=d(2585),x=d(8460),y=d(844),S={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:b=>b.button!==4&&b.action===1&&(b.ctrl=!1,b.alt=!1,b.shift=!1,!0)},VT200:{events:19,restrict:b=>b.action!==32},DRAG:{events:23,restrict:b=>b.action!==32||b.button!==3},ANY:{events:31,restrict:b=>!0}};function C(b,k){let E=(b.ctrl?16:0)|(b.shift?4:0)|(b.alt?8:0);return b.button===4?(E|=64,E|=b.action):(E|=3&b.button,4&b.button&&(E|=64),8&b.button&&(E|=128),b.action===32?E|=32:b.action!==0||k||(E|=3)),E}const v=String.fromCharCode,w={DEFAULT:b=>{const k=[C(b,!1)+32,b.col+32,b.row+32];return k[0]>255||k[1]>255||k[2]>255?"":`\x1B[M${v(k[0])}${v(k[1])}${v(k[2])}`},SGR:b=>{const k=b.action===0&&b.button!==4?"m":"M";return`\x1B[<${C(b,!0)};${b.col};${b.row}${k}`},SGR_PIXELS:b=>{const k=b.action===0&&b.button!==4?"m":"M";return`\x1B[<${C(b,!0)};${b.x};${b.y}${k}`}};let _=c.CoreMouseService=class extends y.Disposable{constructor(b,k){super(),this._bufferService=b,this._coreService=k,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new x.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const E of Object.keys(S))this.addProtocol(E,S[E]);for(const E of Object.keys(w))this.addEncoding(E,w[E]);this.reset()}addProtocol(b,k){this._protocols[b]=k}addEncoding(b,k){this._encodings[b]=k}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(b){if(!this._protocols[b])throw new Error(`unknown protocol "${b}"`);this._activeProtocol=b,this._onProtocolChange.fire(this._protocols[b].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(b){if(!this._encodings[b])throw new Error(`unknown encoding "${b}"`);this._activeEncoding=b}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(b){if(b.col<0||b.col>=this._bufferService.cols||b.row<0||b.row>=this._bufferService.rows||b.button===4&&b.action===32||b.button===3&&b.action!==32||b.button!==4&&(b.action===2||b.action===3)||(b.col++,b.row++,b.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,b,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(b))return!1;const k=this._encodings[this._activeEncoding](b);return k&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(k):this._coreService.triggerDataEvent(k,!0)),this._lastEvent=b,!0}explainEvents(b){return{down:!!(1&b),up:!!(2&b),drag:!!(4&b),move:!!(8&b),wheel:!!(16&b)}}_equalEvents(b,k,E){if(E){if(b.x!==k.x||b.y!==k.y)return!1}else if(b.col!==k.col||b.row!==k.row)return!1;return b.button===k.button&&b.action===k.action&&b.ctrl===k.ctrl&&b.alt===k.alt&&b.shift===k.shift}};c.CoreMouseService=_=h([p(0,m.IBufferService),p(1,m.ICoreService)],_)},6975:function(u,c,d){var h=this&&this.__decorate||function(_,b,k,E){var T,D=arguments.length,L=D<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(_,b,k,E);else for(var R=_.length-1;R>=0;R--)(T=_[R])&&(L=(D<3?T(L):D>3?T(b,k,L):T(b,k))||L);return D>3&&L&&Object.defineProperty(b,k,L),L},p=this&&this.__param||function(_,b){return function(k,E){b(k,E,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreService=void 0;const m=d(1439),x=d(8460),y=d(844),S=d(2585),C=Object.freeze({insertMode:!1}),v=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let w=c.CoreService=class extends y.Disposable{constructor(_,b,k){super(),this._bufferService=_,this._logService=b,this._optionsService=k,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new x.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new x.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new x.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new x.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,m.clone)(C),this.decPrivateModes=(0,m.clone)(v)}reset(){this.modes=(0,m.clone)(C),this.decPrivateModes=(0,m.clone)(v)}triggerDataEvent(_,b=!1){if(this._optionsService.rawOptions.disableStdin)return;const k=this._bufferService.buffer;b&&this._optionsService.rawOptions.scrollOnUserInput&&k.ybase!==k.ydisp&&this._onRequestScrollToBottom.fire(),b&&this._onUserInput.fire(),this._logService.debug(`sending data "${_}"`,(()=>_.split("").map((E=>E.charCodeAt(0))))),this._onData.fire(_)}triggerBinaryEvent(_){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${_}"`,(()=>_.split("").map((b=>b.charCodeAt(0))))),this._onBinary.fire(_))}};c.CoreService=w=h([p(0,S.IBufferService),p(1,S.ILogService),p(2,S.IOptionsService)],w)},9074:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DecorationService=void 0;const h=d(8055),p=d(8460),m=d(844),x=d(6106);let y=0,S=0;class C extends m.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new x.SortedList((_=>_==null?void 0:_.marker.line)),this._onDecorationRegistered=this.register(new p.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new p.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,m.toDisposable)((()=>this.reset())))}registerDecoration(_){if(_.marker.isDisposed)return;const b=new v(_);if(b){const k=b.marker.onDispose((()=>b.dispose()));b.onDispose((()=>{b&&(this._decorations.delete(b)&&this._onDecorationRemoved.fire(b),k.dispose())})),this._decorations.insert(b),this._onDecorationRegistered.fire(b)}return b}reset(){for(const _ of this._decorations.values())_.dispose();this._decorations.clear()}*getDecorationsAtCell(_,b,k){let E=0,T=0;for(const D of this._decorations.getKeyIterator(b))E=D.options.x??0,T=E+(D.options.width??1),_>=E&&_<T&&(!k||(D.options.layer??"bottom")===k)&&(yield D)}forEachDecorationAtCell(_,b,k,E){this._decorations.forEachByKey(b,(T=>{y=T.options.x??0,S=y+(T.options.width??1),_>=y&&_<S&&(!k||(T.options.layer??"bottom")===k)&&E(T)}))}}c.DecorationService=C;class v extends m.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=h.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=h.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(_){super(),this.options=_,this.onRenderEmitter=this.register(new p.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new p.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=_.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.InstantiationService=c.ServiceCollection=void 0;const h=d(2585),p=d(8343);class m{constructor(...y){this._entries=new Map;for(const[S,C]of y)this.set(S,C)}set(y,S){const C=this._entries.get(y);return this._entries.set(y,S),C}forEach(y){for(const[S,C]of this._entries.entries())y(S,C)}has(y){return this._entries.has(y)}get(y){return this._entries.get(y)}}c.ServiceCollection=m,c.InstantiationService=class{constructor(){this._services=new m,this._services.set(h.IInstantiationService,this)}setService(x,y){this._services.set(x,y)}getService(x){return this._services.get(x)}createInstance(x,...y){const S=(0,p.getServiceDependencies)(x).sort(((w,_)=>w.index-_.index)),C=[];for(const w of S){const _=this._services.get(w.id);if(!_)throw new Error(`[createInstance] ${x.name} depends on UNKNOWN service ${w.id}.`);C.push(_)}const v=S.length>0?S[0].index:y.length;if(y.length!==v)throw new Error(`[createInstance] First service dependency of ${x.name} at position ${v+1} conflicts with ${y.length} static arguments`);return new x(...y,...C)}}},7866:function(u,c,d){var h=this&&this.__decorate||function(v,w,_,b){var k,E=arguments.length,T=E<3?w:b===null?b=Object.getOwnPropertyDescriptor(w,_):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(v,w,_,b);else for(var D=v.length-1;D>=0;D--)(k=v[D])&&(T=(E<3?k(T):E>3?k(w,_,T):k(w,_))||T);return E>3&&T&&Object.defineProperty(w,_,T),T},p=this&&this.__param||function(v,w){return function(_,b){w(_,b,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.traceCall=c.setTraceLogger=c.LogService=void 0;const m=d(844),x=d(2585),y={trace:x.LogLevelEnum.TRACE,debug:x.LogLevelEnum.DEBUG,info:x.LogLevelEnum.INFO,warn:x.LogLevelEnum.WARN,error:x.LogLevelEnum.ERROR,off:x.LogLevelEnum.OFF};let S,C=c.LogService=class extends m.Disposable{get logLevel(){return this._logLevel}constructor(v){super(),this._optionsService=v,this._logLevel=x.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),S=this}_updateLogLevel(){this._logLevel=y[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(v){for(let w=0;w<v.length;w++)typeof v[w]=="function"&&(v[w]=v[w]())}_log(v,w,_){this._evalLazyOptionalParams(_),v.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+w,..._)}trace(v,...w){var _;this._logLevel<=x.LogLevelEnum.TRACE&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.trace.bind(this._optionsService.options.logger))??console.log,v,w)}debug(v,...w){var _;this._logLevel<=x.LogLevelEnum.DEBUG&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.debug.bind(this._optionsService.options.logger))??console.log,v,w)}info(v,...w){var _;this._logLevel<=x.LogLevelEnum.INFO&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.info.bind(this._optionsService.options.logger))??console.info,v,w)}warn(v,...w){var _;this._logLevel<=x.LogLevelEnum.WARN&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.warn.bind(this._optionsService.options.logger))??console.warn,v,w)}error(v,...w){var _;this._logLevel<=x.LogLevelEnum.ERROR&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.error.bind(this._optionsService.options.logger))??console.error,v,w)}};c.LogService=C=h([p(0,x.IOptionsService)],C),c.setTraceLogger=function(v){S=v},c.traceCall=function(v,w,_){if(typeof _.value!="function")throw new Error("not supported");const b=_.value;_.value=function(...k){if(S.logLevel!==x.LogLevelEnum.TRACE)return b.apply(this,k);S.trace(`GlyphRenderer#${b.name}(${k.map((T=>JSON.stringify(T))).join(", ")})`);const E=b.apply(this,k);return S.trace(`GlyphRenderer#${b.name} return`,E),E}}},7302:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OptionsService=c.DEFAULT_OPTIONS=void 0;const h=d(8460),p=d(844),m=d(6114);c.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:m.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const x=["normal","bold","100","200","300","400","500","600","700","800","900"];class y extends p.Disposable{constructor(C){super(),this._onOptionChange=this.register(new h.EventEmitter),this.onOptionChange=this._onOptionChange.event;const v={...c.DEFAULT_OPTIONS};for(const w in C)if(w in v)try{const _=C[w];v[w]=this._sanitizeAndValidateOption(w,_)}catch(_){console.error(_)}this.rawOptions=v,this.options={...v},this._setupOptions(),this.register((0,p.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(C,v){return this.onOptionChange((w=>{w===C&&v(this.rawOptions[C])}))}onMultipleOptionChange(C,v){return this.onOptionChange((w=>{C.indexOf(w)!==-1&&v()}))}_setupOptions(){const C=w=>{if(!(w in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${w}"`);return this.rawOptions[w]},v=(w,_)=>{if(!(w in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${w}"`);_=this._sanitizeAndValidateOption(w,_),this.rawOptions[w]!==_&&(this.rawOptions[w]=_,this._onOptionChange.fire(w))};for(const w in this.rawOptions){const _={get:C.bind(this,w),set:v.bind(this,w)};Object.defineProperty(this.options,w,_)}}_sanitizeAndValidateOption(C,v){switch(C){case"cursorStyle":if(v||(v=c.DEFAULT_OPTIONS[C]),!(function(w){return w==="block"||w==="underline"||w==="bar"})(v))throw new Error(`"${v}" is not a valid value for ${C}`);break;case"wordSeparator":v||(v=c.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof v=="number"&&1<=v&&v<=1e3)break;v=x.includes(v)?v:c.DEFAULT_OPTIONS[C];break;case"cursorWidth":v=Math.floor(v);case"lineHeight":case"tabStopWidth":if(v<1)throw new Error(`${C} cannot be less than 1, value: ${v}`);break;case"minimumContrastRatio":v=Math.max(1,Math.min(21,Math.round(10*v)/10));break;case"scrollback":if((v=Math.min(v,4294967295))<0)throw new Error(`${C} cannot be less than 0, value: ${v}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(v<=0)throw new Error(`${C} cannot be less than or equal to 0, value: ${v}`);break;case"rows":case"cols":if(!v&&v!==0)throw new Error(`${C} must be numeric, value: ${v}`);break;case"windowsPty":v=v??{}}return v}}c.OptionsService=y},2660:function(u,c,d){var h=this&&this.__decorate||function(y,S,C,v){var w,_=arguments.length,b=_<3?S:v===null?v=Object.getOwnPropertyDescriptor(S,C):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(y,S,C,v);else for(var k=y.length-1;k>=0;k--)(w=y[k])&&(b=(_<3?w(b):_>3?w(S,C,b):w(S,C))||b);return _>3&&b&&Object.defineProperty(S,C,b),b},p=this&&this.__param||function(y,S){return function(C,v){S(C,v,y)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkService=void 0;const m=d(2585);let x=c.OscLinkService=class{constructor(y){this._bufferService=y,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(y){const S=this._bufferService.buffer;if(y.id===void 0){const k=S.addMarker(S.ybase+S.y),E={data:y,id:this._nextId++,lines:[k]};return k.onDispose((()=>this._removeMarkerFromLink(E,k))),this._dataByLinkId.set(E.id,E),E.id}const C=y,v=this._getEntryIdKey(C),w=this._entriesWithId.get(v);if(w)return this.addLineToLink(w.id,S.ybase+S.y),w.id;const _=S.addMarker(S.ybase+S.y),b={id:this._nextId++,key:this._getEntryIdKey(C),data:C,lines:[_]};return _.onDispose((()=>this._removeMarkerFromLink(b,_))),this._entriesWithId.set(b.key,b),this._dataByLinkId.set(b.id,b),b.id}addLineToLink(y,S){const C=this._dataByLinkId.get(y);if(C&&C.lines.every((v=>v.line!==S))){const v=this._bufferService.buffer.addMarker(S);C.lines.push(v),v.onDispose((()=>this._removeMarkerFromLink(C,v)))}}getLinkData(y){var S;return(S=this._dataByLinkId.get(y))==null?void 0:S.data}_getEntryIdKey(y){return`${y.id};;${y.uri}`}_removeMarkerFromLink(y,S){const C=y.lines.indexOf(S);C!==-1&&(y.lines.splice(C,1),y.lines.length===0&&(y.data.id!==void 0&&this._entriesWithId.delete(y.key),this._dataByLinkId.delete(y.id)))}};c.OscLinkService=x=h([p(0,m.IBufferService)],x)},8343:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createDecorator=c.getServiceDependencies=c.serviceRegistry=void 0;const d="di$target",h="di$dependencies";c.serviceRegistry=new Map,c.getServiceDependencies=function(p){return p[h]||[]},c.createDecorator=function(p){if(c.serviceRegistry.has(p))return c.serviceRegistry.get(p);const m=function(x,y,S){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(C,v,w){v[d]===v?v[h].push({id:C,index:w}):(v[h]=[{id:C,index:w}],v[d]=v)})(m,x,S)};return m.toString=()=>p,c.serviceRegistry.set(p,m),m}},2585:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.IDecorationService=c.IUnicodeService=c.IOscLinkService=c.IOptionsService=c.ILogService=c.LogLevelEnum=c.IInstantiationService=c.ICharsetService=c.ICoreService=c.ICoreMouseService=c.IBufferService=void 0;const h=d(8343);var p;c.IBufferService=(0,h.createDecorator)("BufferService"),c.ICoreMouseService=(0,h.createDecorator)("CoreMouseService"),c.ICoreService=(0,h.createDecorator)("CoreService"),c.ICharsetService=(0,h.createDecorator)("CharsetService"),c.IInstantiationService=(0,h.createDecorator)("InstantiationService"),(function(m){m[m.TRACE=0]="TRACE",m[m.DEBUG=1]="DEBUG",m[m.INFO=2]="INFO",m[m.WARN=3]="WARN",m[m.ERROR=4]="ERROR",m[m.OFF=5]="OFF"})(p||(c.LogLevelEnum=p={})),c.ILogService=(0,h.createDecorator)("LogService"),c.IOptionsService=(0,h.createDecorator)("OptionsService"),c.IOscLinkService=(0,h.createDecorator)("OscLinkService"),c.IUnicodeService=(0,h.createDecorator)("UnicodeService"),c.IDecorationService=(0,h.createDecorator)("DecorationService")},1480:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeService=void 0;const h=d(8460),p=d(225);class m{static extractShouldJoin(y){return(1&y)!=0}static extractWidth(y){return y>>1&3}static extractCharKind(y){return y>>3}static createPropertyValue(y,S,C=!1){return(16777215&y)<<3|(3&S)<<1|(C?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new h.EventEmitter,this.onChange=this._onChange.event;const y=new p.UnicodeV6;this.register(y),this._active=y.version,this._activeProvider=y}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(y){if(!this._providers[y])throw new Error(`unknown Unicode version "${y}"`);this._active=y,this._activeProvider=this._providers[y],this._onChange.fire(y)}register(y){this._providers[y.version]=y}wcwidth(y){return this._activeProvider.wcwidth(y)}getStringCellWidth(y){let S=0,C=0;const v=y.length;for(let w=0;w<v;++w){let _=y.charCodeAt(w);if(55296<=_&&_<=56319){if(++w>=v)return S+this.wcwidth(_);const E=y.charCodeAt(w);56320<=E&&E<=57343?_=1024*(_-55296)+E-56320+65536:S+=this.wcwidth(E)}const b=this.charProperties(_,C);let k=m.extractWidth(b);m.extractShouldJoin(b)&&(k-=m.extractWidth(C)),S+=k,C=b}return S}charProperties(y,S){return this._activeProvider.charProperties(y,S)}}c.UnicodeService=m}},r={};function a(u){var c=r[u];if(c!==void 0)return c.exports;var d=r[u]={exports:{}};return n[u].call(d.exports,d,d.exports,a),d.exports}var l={};return(()=>{var u=l;Object.defineProperty(u,"__esModule",{value:!0}),u.Terminal=void 0;const c=a(9042),d=a(3236),h=a(844),p=a(5741),m=a(8285),x=a(7975),y=a(7090),S=["cols","rows"];class C extends h.Disposable{constructor(w){super(),this._core=this.register(new d.Terminal(w)),this._addonManager=this.register(new p.AddonManager),this._publicOptions={...this._core.options};const _=k=>this._core.options[k],b=(k,E)=>{this._checkReadonlyOptions(k),this._core.options[k]=E};for(const k in this._core.options){const E={get:_.bind(this,k),set:b.bind(this,k)};Object.defineProperty(this._publicOptions,k,E)}}_checkReadonlyOptions(w){if(S.includes(w))throw new Error(`Option "${w}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new x.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new y.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new m.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const w=this._core.coreService.decPrivateModes;let _="none";switch(this._core.coreMouseService.activeProtocol){case"X10":_="x10";break;case"VT200":_="vt200";break;case"DRAG":_="drag";break;case"ANY":_="any"}return{applicationCursorKeysMode:w.applicationCursorKeys,applicationKeypadMode:w.applicationKeypad,bracketedPasteMode:w.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:_,originMode:w.origin,reverseWraparoundMode:w.reverseWraparound,sendFocusMode:w.sendFocus,wraparoundMode:w.wraparound}}get options(){return this._publicOptions}set options(w){for(const _ in w)this._publicOptions[_]=w[_]}blur(){this._core.blur()}focus(){this._core.focus()}input(w,_=!0){this._core.input(w,_)}resize(w,_){this._verifyIntegers(w,_),this._core.resize(w,_)}open(w){this._core.open(w)}attachCustomKeyEventHandler(w){this._core.attachCustomKeyEventHandler(w)}attachCustomWheelEventHandler(w){this._core.attachCustomWheelEventHandler(w)}registerLinkProvider(w){return this._core.registerLinkProvider(w)}registerCharacterJoiner(w){return this._checkProposedApi(),this._core.registerCharacterJoiner(w)}deregisterCharacterJoiner(w){this._checkProposedApi(),this._core.deregisterCharacterJoiner(w)}registerMarker(w=0){return this._verifyIntegers(w),this._core.registerMarker(w)}registerDecoration(w){return this._checkProposedApi(),this._verifyPositiveIntegers(w.x??0,w.width??0,w.height??0),this._core.registerDecoration(w)}hasSelection(){return this._core.hasSelection()}select(w,_,b){this._verifyIntegers(w,_,b),this._core.select(w,_,b)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(w,_){this._verifyIntegers(w,_),this._core.selectLines(w,_)}dispose(){super.dispose()}scrollLines(w){this._verifyIntegers(w),this._core.scrollLines(w)}scrollPages(w){this._verifyIntegers(w),this._core.scrollPages(w)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(w){this._verifyIntegers(w),this._core.scrollToLine(w)}clear(){this._core.clear()}write(w,_){this._core.write(w,_)}writeln(w,_){this._core.write(w),this._core.write(`\r
|
|
261
|
+
`,_)}paste(w){this._core.paste(w)}refresh(w,_){this._verifyIntegers(w,_),this._core.refresh(w,_)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(w){this._addonManager.loadAddon(this,w)}static get strings(){return c}_verifyIntegers(...w){for(const _ of w)if(_===1/0||isNaN(_)||_%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...w){for(const _ of w)if(_&&(_===1/0||isNaN(_)||_%1!=0||_<0))throw new Error("This API only accepts positive integers")}}u.Terminal=C})(),l})()))})(Dg)),Dg.exports}var MH=IH();/**
|
|
262
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
263
|
+
* @license MIT
|
|
264
|
+
*
|
|
265
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
266
|
+
* @license MIT
|
|
267
|
+
*
|
|
268
|
+
* Originally forked from (with the author's permission):
|
|
269
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
270
|
+
* http://bellard.org/jslinux/
|
|
271
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
272
|
+
*/var PH=2,BH=1,$H=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(){var m;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:((m=this._terminal.options.overviewRuler)==null?void 0:m.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),u={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},c=u.top+u.bottom,d=u.right+u.left,h=r-c,p=a-d-t;return{cols:Math.max(PH,Math.floor(p/e.css.cell.width)),rows:Math.max(BH,Math.floor(h/e.css.cell.height))}}};function zH({sessionId:e,onClose:t,onEscape:n,autoFocus:r}){const a=N.useRef(null),l=N.useRef(e),u=N.useRef(null),c=N.useRef(null),d=Zr(m=>m.writeSession),h=Zr(m=>m.resizeSession),p=Vt(m=>m.settings[Ae.DISPLAY_TERMINAL_FONT]??Kd);return N.useEffect(()=>{l.current=e},[e]),N.useEffect(()=>{Vt.getState().getSetting(Ae.DISPLAY_TERMINAL_FONT)},[]),N.useEffect(()=>{if(!n)return;const m=x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),n())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[n]),N.useEffect(()=>{if(!a.current)return;const m=new MH.Terminal({fontFamily:p,fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),x=new $H;m.loadAddon(x),u.current={term:m,fitAddon:x},a.current.addEventListener("keydown",v=>{v.key==="Escape"&&n&&(v.preventDefault(),v.stopPropagation(),n())}),m.open(a.current);const y=a.current.querySelector(".xterm");y&&(y.style.padding="8px"),x.fit(),r&&setTimeout(()=>{m.focus()},150);const S=new ResizeObserver(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{requestAnimationFrame(()=>{var w;x.fit&&x.fit();const v=(w=u.current)==null?void 0:w.term;v&&v.cols>0&&v.rows>0&&h(l.current,v.cols,v.rows)})},100)});S.observe(a.current),m.onData(v=>{if(v==="\x1B"&&n){n();return}d(l.current,v)}),m.onKey(v=>{v.key==="\x1B"&&n&&(v.domEvent.stopPropagation(),n())});const C=Pt.subscribe(v=>{const w=v.payload;if(v.type==="terminal.output"&&(w==null?void 0:w.sessionId)===l.current){const _=w==null?void 0:w.data;_&&m.write(_)}});return()=>{C(),S.disconnect(),c.current&&clearTimeout(c.current),m.dispose(),u.current=null}},[e,d,h]),N.useEffect(()=>{const m=u.current;if(!m)return;m.term.options.fontFamily=p,m.fitAddon.fit();const{cols:x,rows:y}=m.term;x>0&&y>0&&h(l.current,x,y)},[p,h]),i.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[i.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[i.jsx("div",{}),i.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:i.jsx(oy,{})})]}),i.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:m=>{m.key==="Escape"&&n&&(m.preventDefault(),m.stopPropagation(),n())}})]})}const U2="openfox-chat-textarea";function Fc(e){const t=document.getElementById(U2);t&&(e===void 0?t.focus():t.focus({preventScroll:e}))}function HH(e){return e===1?"grid-cols-1":e===2?"grid-cols-1 lg:grid-cols-2":"grid-cols-1 lg:grid-cols-2 xl:grid-cols-3"}function FH({isOpen:e,onClose:t}){const n=Zr(C=>C.createSession),r=Zr(C=>C.killSession),a=Zr(C=>C.sessions),l=Zr(C=>C.setWorkdir),u=Zr(C=>C.fetchSessions),c=Jt(C=>C.currentProject),d=Re(C=>C.currentSession),[h,p]=N.useState(!0),m=N.useRef(null),x=N.useRef(!1),y=N.useRef(!1),S=N.useCallback(()=>{t()},[t]);return N.useEffect(()=>{const C=(d==null?void 0:d.workspace)??(c==null?void 0:c.workdir);C&&l(C)},[d==null?void 0:d.workspace,c==null?void 0:c.workdir,l]),N.useEffect(()=>{e?(p(!0),u(c==null?void 0:c.id).finally(()=>p(!1))):Fc()},[e,u,c==null?void 0:c.id]),N.useEffect(()=>{e&&a.length===0&&!h&&!y.current&&(y.current=!0,n(void 0,(d==null?void 0:d.projectId)??(c==null?void 0:c.id)))},[e,a.length,h,n,d==null?void 0:d.projectId,c==null?void 0:c.id]),N.useEffect(()=>{e?(x.current=!0,setTimeout(()=>{var C;(C=m.current)==null||C.focus(),setTimeout(()=>{x.current=!1},200)},100)):y.current=!1},[e]),N.useEffect(()=>{if(!e)return;const C=v=>{x.current||v.key==="Escape"&&(v.preventDefault(),t())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,t]),e?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:S}),i.jsxs("div",{ref:m,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:C=>C.stopPropagation(),onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),S())},children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[i.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>n(void 0,(d==null?void 0:d.projectId)??(c==null?void 0:c.id)),className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New terminal",children:i.jsx(FR,{})}),i.jsx("button",{onClick:t,className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Close (Esc)",children:i.jsx(ri,{})})]})]}),i.jsx(Ze,{className:"flex-1 min-h-0 p-2",children:h?i.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):a.length===0?i.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"mb-4",children:"No terminal sessions"}),i.jsx("button",{onClick:()=>n(void 0,(d==null?void 0:d.projectId)??(c==null?void 0:c.id)),className:"px-4 py-2 bg-accent-primary/25 text-text-primary rounded hover:bg-accent-primary/40 transition-colors",children:"Create Terminal"})]})}):i.jsx("div",{className:`grid ${HH(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(C=>i.jsx(zH,{sessionId:C.id,onClose:()=>r(C.id),onEscape:S,autoFocus:a.length===1},C.id))})})]})]}):null}function Zc({items:e,footerItems:t=[],trigger:n,minWidth:r="120px",isOpen:a,onOpenChange:l}){const[u,c]=N.useState(!1),d=a!==void 0,h=d?a:u,p=H=>{if(d){const I=typeof H=="function"?H(u):H;l==null||l(I)}else c(H)},[m,x]=N.useState(null),y=N.useRef(null),S=N.useRef(null),[C,v]=N.useState(0),w=N.useRef(0),_=N.useMemo(()=>[...e,...t],[e,t]),b=N.useRef(_),k=N.useCallback(()=>{if(!y.current)return;const H=y.current.getBoundingClientRect(),I=200,V=window.innerHeight-H.bottom<I;x({top:V?H.top-I-4:H.bottom+4,left:H.left,alignToTop:V})},[]);N.useEffect(()=>{b.current=_},[_]),N.useEffect(()=>{function H(I){if(S.current){const U=I.target;S.current.contains(U)||p(!1)}}return h&&document.addEventListener("mousedown",H),()=>{document.removeEventListener("mousedown",H)}},[h]),N.useEffect(()=>{h&&k()},[h,k]),N.useEffect(()=>{if(!h)return;setTimeout(()=>{var I;(I=S.current)==null||I.focus()},0);function H(I){const U=b.current,V=U.filter(ee=>!E(ee)),Z=T(w.current,U);switch(I.key){case"ArrowDown":if(I.preventDefault(),I.stopPropagation(),Z<V.length-1){const ee=D(w.current+1,U);w.current=ee,v(ee)}break;case"ArrowUp":if(I.preventDefault(),I.stopPropagation(),Z>0){const ee=L(w.current-1,U);w.current=ee,v(ee)}break;case"Enter":I.preventDefault(),I.stopPropagation(),R(w.current,U);break;case"Escape":I.preventDefault(),I.stopPropagation(),p(!1);break}}return window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)},[h,_]);function E(H){var V;const I=H.label;return I?String(((V=I.props)==null?void 0:V.className)??"").includes("cursor-default"):!1}function T(H,I){let U=0;for(let V=0;V<H;V++){const Z=I[V];Z&&!E(Z)&&U++}return U}function D(H,I){for(let U=H;U<I.length;U++){const V=I[U];if(V&&!E(V))return U}return H}function L(H,I){for(let U=H;U>=0;U--){const V=I[U];if(V&&!E(V))return U}return H}function R(H,I){var V;const U=I[H];!U||E(U)||((V=U.onClick)==null||V.call(U),U.href&&(window.history.pushState(null,"",U.href),window.dispatchEvent(new PopStateEvent("popstate"))),p(!1))}N.useEffect(()=>{h&&(v(_.findIndex(H=>!E(H))),w.current=_.findIndex(H=>!E(H)))},[h,_]);const M=H=>{H.stopPropagation(),h||k(),p(!h)};function W(H,I,U,V){const ee=!E(H)&&V===C,F=i.jsxs(i.Fragment,{children:[H.icon&&i.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:H.icon}),H.label]}),O=I!==U-1;return H.href?i.jsx(ur,{href:H.href,onClick:B=>{var q;(q=H.onClick)==null||q.call(H,B),p(!1)},onAuxClick:()=>p(!1),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${H.danger?"text-accent-error hover:bg-accent-error/10":ee?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${O?"border-b border-border":""}`,children:F},V):i.jsx("button",{onClick:B=>{var q;(q=H.onClick)==null||q.call(H,B),H.closeOnClick!==!1&&p(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${H.danger?"text-accent-error hover:bg-accent-error/10":ee?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${O?"border-b border-border":""}`,children:F},V)}const z=m&&i.jsxs("div",{ref:S,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${m.alignToTop?"mb-1":"mt-1"}`,style:{top:m.top,left:m.left,minWidth:r},tabIndex:-1,children:[i.jsx(Ze,{className:"max-h-[60vh]",children:e.map((H,I)=>W(H,I,e.length,I))}),t.length>0&&i.jsx("div",{className:"border-t border-border",children:t.map((H,I)=>W(H,I,t.length,e.length+I))})]});return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"relative",children:i.jsx("div",{ref:y,onClick:M,children:n})}),h&&si.createPortal(z,document.body)]})}function UH(e){return!e||e.trim()===""?{valid:!1,error:"Project name cannot be empty"}:/^[a-zA-Z0-9._-]+$/.test(e)?{valid:!0}:{valid:!1,error:"Project name can only contain letters, numbers, hyphens, underscores, and dots"}}function V2({isOpen:e,onClose:t,path:n,onRetry:r}){const[a,l]=N.useState(!1),[u,c]=N.useState(null),[d,h]=N.useState(null);N.useEffect(()=>{e&&p()},[e]);const p=async()=>{try{const k=await(await Ce("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();h({sudoAvailable:k.sudoAvailable,userInGroup:k.userInGroup,groupHasWrite:k.groupHasWrite,groupName:k.groupName||null})}catch{h({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},m=N.useCallback(async b=>{l(!0),c(null);try{const E=await(await Ce("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:b})})).json();E.success?(r(),t()):E.sudoAvailable?c("Failed to fix permissions: "+(E.error||"Unknown error")):c(`Passwordless sudo is not available. Please fix permissions manually:
|
|
273
|
+
|
|
274
|
+
`+(b==="group"?`sudo chmod g+w "${n}"`:"sudo usermod -aG <group> $USER"))}catch(k){c("Failed to fix permissions: "+(k instanceof Error?k.message:"Unknown error"))}finally{l(!1)}},[n,r,t]),x=(d==null?void 0:d.userInGroup)??!1,y=(d==null?void 0:d.groupHasWrite)??!1,S=(d==null?void 0:d.sudoAvailable)??!1,C=(d==null?void 0:d.groupName)??"",v=x&&!y,w=!x&&y,_=!x&&!y;return i.jsx(Tt,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"text-sm text-text-secondary",children:[i.jsx("p",{children:v?i.jsxs(i.Fragment,{children:["The group ",i.jsx("strong",{children:C})," doesn't have write access:"]}):w?i.jsxs(i.Fragment,{children:["You're not a member of group ",i.jsx("strong",{children:C}),":"]}):i.jsxs(i.Fragment,{children:["You're not a member of group ",i.jsx("strong",{children:C})," and it doesn't have write access:"]})}),i.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),u?i.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:u}):d?i.jsxs("div",{className:"flex flex-col gap-2",children:[v&&i.jsxs(i.Fragment,{children:[i.jsx(mt,{type:"button",variant:"primary",onClick:()=>m("group"),disabled:a||!S,className:"w-full",children:a?"Granting access...":"Extend group permissions"}),i.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),i.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),w&&i.jsxs(i.Fragment,{children:[i.jsx(mt,{type:"button",variant:"primary",onClick:()=>m("join_group"),disabled:a||!S,className:"w-full",children:a?"Joining group...":"Join group"}),i.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),i.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER"]})]}),_&&i.jsxs(i.Fragment,{children:[i.jsx(mt,{type:"button",variant:"primary",onClick:()=>m("join_group_and_group"),disabled:a||!S,className:"w-full",children:a?"Joining group...":"Join group & grant write permissions"}),i.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),i.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER",i.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!S&&!u&&i.jsxs("div",{className:"text-xs text-text-secondary",children:[i.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),i.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),i.jsx("div",{className:"flex justify-end",children:i.jsx(mt,{type:"button",variant:"secondary",onClick:t,disabled:a,children:"Cancel"})})]}):null]})})}function W2({isOpen:e,onClose:t}){const[,n]=zn(),r=Jt(E=>E.listProjects),[a,l]=N.useState(""),[u,c]=N.useState(null),[d,h]=N.useState(!1),[p,m]=N.useState(""),[x,y]=N.useState(null),S=N.useRef(null);N.useEffect(()=>{e&&(Ce("/api/config").then(E=>E.json()).then(E=>{E.workdir&&m(E.workdir)}),l(""),c(null),h(!1),y(null),setTimeout(()=>{var E;(E=S.current)==null||E.focus()},100))},[e]);const C=N.useCallback(async E=>{E.preventDefault();const T=UH(a);if(!T.valid){c(T.error);return}const D=`${p}/${a}`;await _(D)},[a,n,t,p]),v=N.useCallback(()=>{y(null)},[]),w=N.useCallback(async()=>{const E=`${p}/${a}`;await _(E)},[p,a,n,t,y,c,h]);async function _(E){h(!0),c(null),y(null);try{const T=await Ce("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,workdir:E})});if(!T.ok){const R=await T.json().catch(()=>({}));if(R.code==="EACCES"){y(E),h(!1);return}throw new Error(R.error||"Failed to create project")}const L=(await T.json()).project;t(),await r(),n(`/p/${L.id}`)}catch(T){c(T instanceof Error?T.message:"Failed to create project"),h(!1)}}const b=N.useCallback(()=>{l(""),c(null),t()},[t]),k=a?`${p}/${a}`:"";return i.jsxs(i.Fragment,{children:[i.jsx(Tt,{isOpen:e,onClose:b,title:"Create New Project",size:"sm",children:i.jsxs("form",{onSubmit:C,className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),i.jsx(zi,{ref:S,id:"project-name",value:a,onChange:E=>{l(E.target.value),c(null)},placeholder:"my-project",disabled:d,"data-testid":"create-project-name-input",className:"w-full"}),a&&i.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",i.jsx("span",{className:"font-mono",children:k})]}),u&&i.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:u})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(mt,{type:"button",variant:"secondary",onClick:b,disabled:d,children:"Cancel"}),i.jsx(mt,{type:"submit",variant:"primary",disabled:d||!a.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:d?i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(ws,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),x&&i.jsx(V2,{isOpen:!!x,onClose:v,path:x,onRetry:w})]})}function G2(){const[e,t]=N.useState(null);return N.useEffect(()=>{Ce("/api/config").then(n=>n.json()).then(n=>{n.workdir&&t(n.workdir)})},[]),e}function Hw({projects:e,currentProject:t}){const[,n]=zn(),r=Jt(v=>v.loadProject),a=Jt(v=>v.toggleStar),l=Jt(v=>v.createProject),u=Jt(v=>v.listProjects),[c,d]=N.useState(!1),[h,p]=N.useState(!1),m=G2(),x=N.useCallback(async v=>{const w=Jk(v),_=await l(w,v);return _&&"id"in _?(await u(),p(!1),n(`/p/${_.id}`),!0):!1},[l,u,n]),S=N.useMemo(()=>{const v=e.filter(_=>_.isStarred).sort((_,b)=>_.name.localeCompare(b.name)),w=e.filter(_=>!_.isStarred).sort((_,b)=>_.name.localeCompare(b.name));return[...v,...w]},[e]).map(v=>({label:i.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[i.jsx("span",{className:"truncate flex-1",children:v.name}),i.jsx("button",{onClick:w=>{w.stopPropagation(),w.preventDefault(),w.nativeEvent.stopImmediatePropagation(),a(v.id,!v.isStarred)},className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:v.isStarred?"Unstar project":"Star project",children:v.isStarred?i.jsx(Fk,{className:"w-3.5 h-3.5 text-yellow-500"}):i.jsx(Uk,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:v.id===(t==null?void 0:t.id)?i.jsx(is,{}):void 0,href:`/p/${v.id}`,closeOnClick:!0,onClick:()=>{r(v.id)}})),C=[{label:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Vr,{className:"w-4 h-4"}),i.jsx("span",{children:"Open Project"})]}),onClick:()=>p(!0)},{label:i.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[i.jsx(ws,{className:"w-4 h-4"}),i.jsx("span",{children:"New Project"})]}),onClick:()=>d(!0)}];return i.jsxs(i.Fragment,{children:[i.jsx(Zc,{items:S,footerItems:C,trigger:i.jsxs("button",{className:`text-text-secondary hover:text-text-primary text-sm truncate flex items-center gap-1 ${t?"hover:underline":""}`,title:(t==null?void 0:t.name)??"Select project",children:[(t==null?void 0:t.name)??i.jsx("span",{className:"text-text-muted",children:"Select project..."}),i.jsx(yn,{})]}),minWidth:"250px"}),c&&i.jsx(W2,{isOpen:c,onClose:()=>d(!1)}),h&&i.jsx(Kh,{initialPath:m??void 0,onSelect:x,onClose:()=>p(!1)})]})}function q2(e){const t=new Date(e),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.getDay()],a=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0");return`${r} ${a}/${l}/${u}`}function gf(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function VH(e){const t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=Math.floor((r.getTime()-a.getTime())/(1e3*60*60*24)),u=gf(e);if(l===0)return`today ${u}`;if(l===1)return`yesterday ${u}`;if(l<7)return`${l} days ago ${u}`;{const c=t.getFullYear(),d=String(t.getMonth()+1).padStart(2,"0"),h=String(t.getDate()).padStart(2,"0");return`${c}/${d}/${h} ${u}`}}function K2(e){const t=new Date(e);return{year:t.getFullYear(),month:String(t.getMonth()+1).padStart(2,"0"),day:String(t.getDate()).padStart(2,"0")}}function WH(e){const{year:t,month:n,day:r}=K2(e);return`${t}-${n}-${r}`}function Y2(e){const t=new Map;for(const a of e){const l=WH(a.updatedAt);t.has(l)||t.set(l,[]),t.get(l).push(a)}for(const[a,l]of t)l.sort((u,c)=>{const d=new Date(u.updatedAt).getTime();return new Date(c.updatedAt).getTime()-d});const n=Array.from(t.keys()).sort((a,l)=>l.localeCompare(a)),r=new Map;for(const a of n)r.set(a,t.get(a));return r}function GH(e){const{year:t,month:n,day:r}=K2(e);return`${t}/${n}/${r} ${gf(e)}`}function kh(e,t){return e.length<=t?e:e.substring(0,t)+"..."}function qH({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:a}){var x;const l=Re(y=>y.loadSession),u=50,c=e.filter(y=>y.projectId===t.id).slice(0,15),d=Y2(c),h=N.useMemo(()=>{const y=[];y.push({label:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ws,{className:"w-4 h-4 text-accent-primary"}),i.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});for(const[S,C]of d){const v=C[0];if(v){y.push({label:i.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:q2(v.updatedAt)}),onClick:()=>{}});for(const w of C)y.push({label:i.jsxs("div",{className:"min-w-[160px]",children:[i.jsx("div",{className:"truncate text-sm",children:kh(w.title??w.id.slice(0,8),u)}),i.jsx("div",{className:"text-text-muted text-xs",children:gf(w.updatedAt)})]}),icon:w.id===(n==null?void 0:n.id)?i.jsx(is,{}):void 0,href:`/p/${t.id}/s/${w.id}`,onClick:()=>{l(w.id)}})}}return y},[t.id,d,n==null?void 0:n.id]),p=((x=n==null?void 0:n.metadata)==null?void 0:x.title)??(n?n.id.slice(0,8):null),m=p?kh(p,u):"No session selected";return i.jsx(Zc,{items:h,isOpen:r,onOpenChange:a,trigger:i.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:p??"","data-testid":"header-session-dropdown",children:[m,i.jsx(yn,{})]}),minWidth:"280px"})}function KH({items:e,trigger:t,isActive:n=!1}){const[r,a]=N.useState(!1),l=N.useRef(null);return N.useEffect(()=>{function u(c){l.current&&!l.current.contains(c.target)&&a(!1)}if(r)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),i.jsxs("div",{className:"relative",ref:l,children:[i.jsxs("button",{type:"button",onClick:()=>a(!r),className:`flex items-center gap-1 px-1.5 py-0.5 rounded transition-colors ${n?"bg-bg-tertiary":"hover:bg-bg-tertiary"}`,children:[typeof t=="string"?i.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,i.jsx(yn,{className:"w-3 h-3 text-text-muted flex-shrink-0 transition-transform",rotate:r?180:0})]}),r&&e.length>0&&i.jsx("div",{className:"absolute top-full left-0 mt-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:e.map((u,c)=>{const d=u.label&&typeof u.label=="object"&&u.label.type===ur?u.label:null;if(d){const h=d.props.href||"";return i.jsxs(ur,{href:h,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,d.props.children]},c)}return u.href?i.jsxs("a",{href:u.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,u.label]},c):i.jsxs("button",{type:"button",onClick:()=>{var h;(h=u.onClick)==null||h.call(u),a(!1)},className:"flex items-center gap-2 px-3 py-2 text-sm w-full text-left border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,u.label]},c)})})]})}function YH({currentProject:e,sessions:t,currentSession:n,projectIdFromUrl:r}){if(!(e!=null&&e.id)||e.id!==r)return null;const a=t.filter(u=>u.projectId===e.id).sort((u,c)=>new Date(c.updatedAt).getTime()-new Date(u.updatedAt).getTime()).slice(0,5),l=[{label:i.jsxs(ur,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[i.jsx(ws,{className:"w-3 h-3 text-accent-primary"}),i.jsx("span",{className:"text-sm",children:"New Session"})]})},...a.map(u=>({label:i.jsx(ur,{href:`/p/${e.id}/s/${u.id}`,className:"flex items-center gap-2 truncate text-sm",children:i.jsx("span",{children:kh(u.title??u.id.slice(0,8),50)})}),icon:u.id===(n==null?void 0:n.id)?i.jsx(is,{className:"w-3 h-3"}):void 0})),{label:i.jsxs(ur,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[i.jsx(IR,{className:"w-3 h-3"}),i.jsx("span",{className:"text-sm",children:"Projects"})]})}];return i.jsx(KH,{items:l,trigger:i.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function XH({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=N.useState(!1),[a,l]=N.useState(!1),[u,c]=N.useState(!!document.fullscreenElement),[d,h]=zn();N.useEffect(()=>{const D=()=>c(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",D),()=>document.removeEventListener("fullscreenchange",D)},[]);const p=d.startsWith("/p/"),m=/^\/p\/[^/]+\/s\/[^/]+$/.test(d),x=Re(D=>D.currentSession),y=Re(D=>D.sessions),S=Jt(D=>D.currentProject),C=Jt(D=>D.projects),v=nn(D=>D.startAutoRefresh),w=nn(D=>D.stopAutoRefresh),_=Zr(D=>D.setOpen),b=Zr(D=>D.isOpen),k=ei(D=>D.status==="available"),E=ei(D=>D.check);N.useEffect(()=>{ei.getState().status==="idle"&&E()},[E]),N.useEffect(()=>{const D=()=>l(!0);return window.addEventListener("open-session-dropdown",D),()=>window.removeEventListener("open-session-dropdown",D)},[]);const T=Wc();return Dc(T.terminalToggle,()=>{Zr.getState().toggleOpen()},{capture:!0}),N.useEffect(()=>(v(),()=>w()),[v,w]),i.jsxs("header",{className:"h-8 bg-secondary border-b border-border flex items-center justify-between px-2",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&m&&i.jsx("button",{onClick:e,className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:T.sessionSearch?`Toggle session list (${ah(T.sessionSearch)})`:"Toggle session list",children:i.jsx(KS,{})}),i.jsx(ur,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),S&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),i.jsx("span",{className:"hidden md:inline",children:i.jsx(Hw,{projects:C,currentProject:S})}),i.jsx("span",{className:"md:hidden",children:i.jsx(YH,{currentProject:S,sessions:y,currentSession:x,projectIdFromUrl:p&&d.split("/")[2]||null},S==null?void 0:S.id)}),i.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),i.jsx("span",{className:"hidden md:inline",children:i.jsx(qH,{sessions:y,currentProject:S,currentSession:x,isOpen:a,onOpenChange:l})})]}),!S&&i.jsx("span",{className:"hidden md:inline",children:i.jsx(Hw,{projects:C})})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m&&i.jsx("button",{onClick:()=>{var D,L,R;document.fullscreenElement?(D=document.exitFullscreen)==null||D.call(document):(R=(L=document.documentElement).requestFullscreen)==null||R.call(L)},className:"max-sm:block hidden p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:u?"Exit fullscreen":"Enter fullscreen",children:u?i.jsx(BR,{}):i.jsx($R,{})}),p&&i.jsx("button",{onClick:()=>_(!b),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${b?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:i.jsx(WR,{})}),p&&S&&i.jsx("button",{onClick:()=>Ce(`/api/projects/${S.id}/open-folder`).catch(()=>{}),className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Open project folder",children:i.jsx(Vr,{className:"w-4 h-4"})}),i.jsxs("button",{onClick:()=>r(!0),className:"relative p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:k?"Settings — update available":"Settings",children:[i.jsx(Hk,{}),k&&i.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),i.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),h("/")},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:i.jsx(HR,{})}),t&&m&&i.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:T.criteriaSidebar?`Toggle criteria sidebar (${ah(T.criteriaSidebar)})`:"Toggle criteria sidebar",children:i.jsx(KS,{})})]}),i.jsx(OH,{isOpen:n,onClose:()=>r(!1)}),i.jsx(FH,{isOpen:b,onClose:()=>_(!1)})]})}function X2({onCancel:e,onSave:t,saving:n,saveDisabled:r,cancelLabel:a="Cancel",saveLabel:l=n?"Saving...":"Save"}){return i.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[i.jsx(mt,{variant:"secondary",onClick:e,children:a}),i.jsx(mt,{variant:"primary",onClick:t,disabled:r??n,children:l})]})}const Dd=Gn()(e=>({config:null,loading:!1,fetchConfig:async t=>{e({loading:!0});try{const r=await(await Ce(`/api/workspace/config?workdir=${encodeURIComponent(t)}`)).json();e({config:r.config??null,loading:!1})}catch{e({loading:!1})}},saveConfig:async(t,n)=>{const r=await Ce(`/api/workspace/config?workdir=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error("Failed to save workspace config");const a=await r.json();e({config:a.config??n})}})),QH=["/","/etc","/bin","/sbin","/lib","/lib64","/usr","/var","/opt","/root","/run","/tmp","/home","/mnt","/media"],JH=["/proc/","/sys/","/dev/","/boot/","/etc/","/lost+found/"];function ZH(e,t=QH,n=JH){if(!e)return null;const r=e.replace(/\/+$/,"")||"/";if(t.includes(r))return"exact";for(const a of n)if(r.startsWith(a))return"virtual_fs";return null}function e7({isOpen:e,onClose:t,project:n}){const r=Jt(ie=>ie.updateProject),a=Dd(ie=>ie.config),l=Dd(ie=>ie.loading),u=Dd(ie=>ie.fetchConfig),c=Dd(ie=>ie.saveConfig),d=()=>{try{Pt.send("context.checkDynamic",{})}catch{}t()},[h,p]=N.useState(n.customInstructions??""),[m,x]=N.useState(n.dangerLevel??""),[y,S]=N.useState(!1),[C,v]=N.useState(!1),[w,_]=N.useState(!1),[b,k]=N.useState(null),[E,T]=N.useState(""),[D,L]=N.useState(!1),[R,M]=N.useState(""),[W,z]=N.useState(!1),[H,I]=N.useState(""),[U,V]=N.useState(!1),[Z,ee]=N.useState(!1),[F,O]=N.useState([]),[B,q]=N.useState(""),[$,Y]=N.useState({}),[Q,X]=N.useState(!1),[K,P]=N.useState(new Set),J=y||C||D||W||Q;N.useEffect(()=>{e&&(p(n.customInstructions??""),x(n.dangerLevel??""),S(!1),v(!1),L(!1),z(!1),X(!1),P(new Set),u(n.workdir))},[e,n,u]),N.useEffect(()=>{a!=null&&a.setup&&a.setup.length>0?T(a.setup.join(" && ")):T(""),M((a==null?void 0:a.rootDir)??""),Y((a==null?void 0:a.mcpOverrides)??{})},[a]);const ne=Ac(ie=>ie.servers),ce=ie=>$[ie]??{},ae=ie=>{var he;const xe=ce(ie);if(xe.disabled!==void 0)return xe.disabled;const se=ne.find(Pe=>Pe.name===ie);return!!((he=se==null?void 0:se.config)!=null&&he.disabled)},Ee=(ie,xe)=>{var he;return((he=ce(ie).disabledTools)==null?void 0:he.includes(xe))??!1},ve=ie=>{Y(xe=>({...xe,[ie]:{...xe[ie],disabled:!ae(ie)}})),X(!0)},Le=(ie,xe)=>{Y(se=>{const he=se[ie]??{},Pe=he.disabledTools??[],qe=Pe.includes(xe)?Pe.filter(Ke=>Ke!==xe):[...Pe,xe];return{...se,[ie]:{...he,disabledTools:qe.length>0?qe:void 0}}}),X(!0)},Me=ie=>{P(xe=>{if(xe.has(ie)){const he=new Set(xe);return he.delete(ie),he}const se=new Set(xe);return se.add(ie),se})},ke=ie=>{p(ie.target.value),S(!0)},Ge=ie=>{x(ie),v(!0)},Xe=ie=>{T(ie.target.value),L(!0)},Se=ie=>{M(ie.target.value),z(!0)},Ie=N.useCallback(async()=>{const ie=m===""?null:m;await r(n.id,{customInstructions:h||null,dangerLevel:ie});const xe=E.trim()?E.split("&&").map(se=>se.trim()).filter(Boolean):[];await c(n.workdir,{...xe.length>0?{setup:xe}:{},rootDir:R.trim(),...Object.keys($).length>0?{mcpOverrides:$}:{mcpOverrides:void 0}}),S(!1),v(!1),L(!1),z(!1),X(!1),d()},[n.id,m,h,E,R,$,r,c,n.workdir,d]),it=async()=>{const ie=R.trim(),xe=(a==null?void 0:a.rootDir)??"";if(ie){const se=ZH(ie);if(se==="exact"){const he=ie.replace(/\/+$/,"")||"/";k(`Cannot use "${he}" directly as workspace root. Use a subdirectory like "${he}/${n.name}" instead.`);return}if(se==="virtual_fs"){k(`Cannot use paths under "${ie}" for workspaces.`);return}}if(!W||!ie||ie===xe){_(!0),k(null);try{await Ie()}catch(se){k(se instanceof Error?se.message:"Failed to save settings")}finally{_(!1)}return}I(ie),_(!0),k(null);try{const se=await Ce(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:ie,workdir:n.workdir,projectName:n.name})});if(!se.ok){const Pe=await se.json().catch(()=>({}));k((Pe==null?void 0:Pe.error)??"Failed to validate workspace root directory"),_(!1);return}const he=await se.json();if(!he.exists){q(he.resolvedPath),_(!1),V(!0);return}if(he.workspaces&&he.workspaces.length>0){O(he.workspaces),_(!1),ee(!0);return}k(null),await Ie()}catch(se){k(se instanceof Error?se.message:"Failed to validate settings"),_(!1)}},ge=async()=>{V(!1),_(!0);try{const ie=await Ce(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:H,workdir:n.workdir,projectName:n.name,createIfMissing:!0})});if(!ie.ok){const se=await ie.json().catch(()=>({}));k((se==null?void 0:se.error)??"Failed to create directory"),_(!1);return}const xe=await ie.json();if(xe.workspaces&&xe.workspaces.length>0){O(xe.workspaces),ee(!0),_(!1);return}await Ie()}catch(ie){k(ie instanceof Error?ie.message:"Failed to create directory")}finally{_(!1)}},Fe=async()=>{ee(!1),_(!0),k(null);try{await Ie()}catch(ie){k(ie instanceof Error?ie.message:"Failed to save settings")}finally{_(!1)}},He=()=>{V(!1),ee(!1),p(n.customInstructions??""),x(n.dangerLevel??""),S(!1),v(!1),L(!1),z(!1),d()};return i.jsxs(Tt,{isOpen:e,onClose:He,title:`${n.name} Settings`,size:"lg",footer:i.jsx(X2,{onCancel:He,onSave:it,saving:w,saveDisabled:!J||w}),children:[i.jsxs("div",{className:"flex flex-col gap-5 -mt-1",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Danger Level"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Default danger level for new sessions in this project. Existing sessions are not affected."}),i.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit",children:[i.jsx("button",{type:"button",onClick:()=>Ge(""),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m===""?"bg-bg-tertiary text-text-primary border border-border":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Use global default (Normal)",children:"Default"}),i.jsx("button",{type:"button",onClick:()=>Ge("normal"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m==="normal"?"bg-accent-success/20 text-accent-success border border-accent-success/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),i.jsx("button",{type:"button",onClick:()=>Ge("dangerous"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m==="dangerous"?"bg-red-500/20 text-red-400 border border-red-500/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),i.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),i.jsx("p",{className:"text-sm text-text-muted mb-3 flex-shrink-0",children:"These instructions are injected into prompts when working in this project. They are applied after global instructions but before AGENTS.md files."}),i.jsx("textarea",{value:h,onChange:ke,placeholder:"Enter project-specific instructions...",className:"w-full h-32 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:w})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Setup Command"}),i.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Command(s) to run after creating a workspace (shared clone). Use"," ",i.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"&&"})," to chain multiple commands. Example:"," ",i.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"npm install --prefer-offline"})]}),l&&i.jsx("div",{className:"text-xs text-text-muted mb-2",children:"Loading config..."}),i.jsx("input",{type:"text",value:E,onChange:Xe,placeholder:"npm install --prefer-offline",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:l||w})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Root Directory"}),i.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Override the default workspace location. Leave empty to use the global directory"," ",i.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"~/.local/share/openfox/workspaces/"}),". Supports absolute paths or paths relative to the project."]}),i.jsx("input",{type:"text",value:R,onChange:Se,placeholder:"/absolute/or/relative/path",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:l||w})]}),ne.length>0&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"MCP Servers"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Override MCP server availability for this project. These overrides apply to new conversations in this project and can be further overridden per conversation from the chat MCP selector."}),i.jsx("div",{className:"space-y-2",children:ne.map(ie=>{const xe=ae(ie.name);return i.jsx(z2,{server:ie,expanded:K.has(ie.name),onToggleExpand:Me,serverToggleEnabled:!xe,onServerToggle:()=>ve(ie.name),tools:ie.tools.map(se=>({...se,enabled:!Ee(ie.name,se.name)})),onToolToggle:se=>Le(ie.name,se),statusDot:Ky(xe?"disabled":ie.status),statusColor:qy(xe?"disabled":ie.status)},ie.name)})})]}),b&&i.jsx("div",{className:"text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded px-3 py-2",children:b})]}),U&&i.jsxs(Tt,{isOpen:U,onClose:()=>V(!1),title:"Directory not found",size:"md",footer:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:()=>V(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),i.jsx("button",{type:"button",onClick:ge,className:"px-4 py-2 text-sm font-medium rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:"Create"})]}),children:[i.jsxs("p",{className:"text-sm text-text-primary",children:["The directory ",i.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:B})," does not exist."]}),i.jsx("p",{className:"text-sm text-text-muted mt-2",children:"Would you like to create it?"})]}),Z&&i.jsxs(Tt,{isOpen:Z,onClose:()=>ee(!1),title:"Orphaned workspaces",size:"md",footer:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:()=>ee(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),i.jsx("button",{type:"button",onClick:Fe,className:"px-4 py-2 text-sm font-medium rounded bg-red-500 text-white hover:opacity-90 transition-colors",children:"Confirm change"})]}),children:[i.jsxs("p",{className:"text-sm text-text-primary",children:[F.length," existing workspace(s) will not be migrated and will become inaccessible:"]}),i.jsx("ul",{className:"mt-2 space-y-1",children:F.map(ie=>i.jsx("li",{className:"text-sm font-mono text-text-muted",children:ie.name},ie.name))}),i.jsx("p",{className:"text-sm text-text-muted mt-3",children:"Existing workspaces will remain in the old location but will no longer be accessible from this project."})]})]})}const t7={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},n7="M6 18L18 6M6 6l12 12";function eu({onClick:e,className:t="",size:n="md",variant:r="default"}){const a=r==="overlay"?"bg-accent-error text-white rounded-full flex items-center justify-center hover:bg-accent-error/80 transition-colors":r==="sidebar"?"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors":r==="modal"?"text-text-muted hover:text-text-primary transition-colors":"hover:text-white transition-colors";return i.jsx(Gh,{onClick:e,icon:n7,iconSize:t7[n],className:`${a} ${t}`,title:"Close"})}function ys(e,t){const n=new Set(t.map(r=>r.id));return[...e.filter(r=>!n.has(r.id)),...t]}function Ox(e,t){if(!t)return e;const n=e.toLowerCase(),r=t.toLowerCase(),a=new Array(e.length).fill(!1),l=n.indexOf(r);if(l>=0)for(let p=l;p<l+r.length;p++)a[p]=!0;else{let p=0;for(let m=0;m<e.length&&p<r.length;m++)n[m]===r[p]&&(a[m]=!0,p++)}const u=Array.from(e),c=[];let d="",h=a[0]??!1;for(let p=0;p<u.length;p++){const m=u[p]??"";a[p]===h?d+=m:(c.push(h?i.jsx("span",{className:"font-semibold text-accent-primary",children:d},c.length):d),d=m,h=a[p]??!1)}return c.push(h?i.jsx("span",{className:"font-semibold text-accent-primary",children:d},c.length):d),i.jsx(i.Fragment,{children:c})}function Pi(e,t){if(!t)return!0;const n=t.toLowerCase().split(/\s+/),r=e.toLowerCase().split(/\s+/);return n.every(a=>{for(const l of r){let u=0;for(let c=0;c<l.length&&u<a.length;c++)l[c]===a[u]&&u++;if(u===a.length)return!0}return!1})}function Q2(e,t,n,r,a){switch(e.key){case"ArrowDown":e.preventDefault(),n(l=>Math.min(l+1,t));break;case"ArrowUp":e.preventDefault(),n(l=>Math.max(l-1,0));break;case"Enter":e.preventDefault(),r();break;case"Escape":e.preventDefault(),a();break}}function J2({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=zn(),[a,l]=N.useState(!1),[u,c]=N.useState(null),[d,h]=N.useState(null),[p,m]=N.useState(""),[x,y]=N.useState(!1),S=Re(ae=>ae.sessions),C=Re(ae=>ae.currentSession),v=Re(ae=>ae.unreadSessionIds),w=Re(ae=>ae.deleteSession),_=Re(ae=>ae.deleteAllSessions),b=Re(ae=>ae.loadMoreSessions),k=Re(ae=>ae.sessionsHasMore),E=Re(ae=>ae.sessionsPaginationLoading),T=Re(ae=>ae.sessionsWithPendingConfirmations),D=Re(ae=>ae.pendingPathConfirmations),L=Jt(ae=>ae.currentProject),[R,M]=N.useState(""),[W,z]=N.useState(-1),H=N.useRef(null),I=N.useRef(null),U=N.useRef(!1),V=Wc();Dc(V.sessionSearch,()=>{var ae;if(t&&document.activeElement===H.current){n==null||n();return}t||(U.current=!0,n==null||n()),(ae=H.current)==null||ae.focus()});const Z=N.useRef(null),ee=N.useCallback(()=>{k&&!E&&L&&b(L.id)},[k,E,L,b]);N.useEffect(()=>{if(!Z.current||!k)return;const ae=new IntersectionObserver(Ee=>{const ve=Ee[0];ve&&ve.isIntersecting&&ee()},{threshold:.1});return ae.observe(Z.current),()=>ae.disconnect()},[k,ee]);const F=S.filter(ae=>ae.projectId===(L==null?void 0:L.id)),O=N.useMemo(()=>R?F.filter(ae=>{var Le;const Ee=ae.title??"",ve=(((Le=ae.recentUserPrompts)==null?void 0:Le.map(Me=>Me.content))??[]).join(" ");return Pi(Ee,R)||Pi(ve,R)}):F,[F,R]),B=R.length>0,q=B&&O.length===0;N.useEffect(()=>{z(O.length>0?0:-1)},[O.length]),N.useEffect(()=>{var Ee;if(W<0)return;const ae=(Ee=I.current)==null?void 0:Ee.querySelector(`[data-sidx="${W}"]`);ae==null||ae.scrollIntoView({block:"nearest"})},[W]);const $=(ae,Ee)=>{Ee==null||Ee.stopPropagation(),c(ae)},Y=()=>{u&&(w(u),(C==null?void 0:C.id)===u&&r(`/p/${e}`),c(null))},Q=(ae,Ee)=>{Ee==null||Ee.stopPropagation();const ve=S.find(Me=>Me.id===ae),Le=(ve==null?void 0:ve.title)??ae.slice(0,6);m(Le),h(ae)},X=()=>{if(!d||p.trim()==="")return;const ae=Re.getState().renameSession;ae(d,p.trim()),h(null),m("")},K=()=>{y(!0)},P=()=>{_(e),r(`/p/${e}`),y(!1)},J=ae=>{if(!U.current)return;ae.target.closest('a[href*="/s/"]')&&(U.current=!1,n==null||n())},ne=()=>{var ae;M(""),(ae=H.current)==null||ae.focus()},ce=ae=>{var Ee;switch(ae.key){case"Escape":M(""),(Ee=H.current)==null||Ee.blur();break;case"ArrowDown":ae.preventDefault(),z(ve=>ve<O.length-1?ve+1:ve);break;case"ArrowUp":ae.preventDefault(),z(ve=>ve>0?ve-1:0);break;case"Enter":{ae.preventDefault();const ve=O[W];ve&&(r(`/p/${e}/s/${ve.id}`),U.current&&(U.current=!1,n==null||n()));break}}};return i.jsxs(i.Fragment,{children:[t&&n&&i.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),(()=>{const ae=i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[i.jsx(ur,{href:`/p/${e}/new`,className:"flex-1 block text-center rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-1.5 text-sm","data-testid":"sidebar-new-session-button",children:"+ New Session"}),i.jsx(Zc,{items:[{label:"Edit project settings",onClick:()=>l(!0)},{label:"Delete all sessions",onClick:K,danger:!0}],trigger:i.jsx("button",{className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Options",children:i.jsx(Pk,{})})}),n&&i.jsx(eu,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),i.jsxs("div",{className:"px-4 py-2 border-b border-border",children:[i.jsxs("div",{className:"relative flex items-center",children:[i.jsx(Vi,{className:"absolute left-2.5 w-3.5 h-3.5 text-text-muted pointer-events-none"}),i.jsx("input",{ref:H,type:"text",value:R,onChange:Ee=>M(Ee.target.value),onKeyDown:ce,placeholder:"Search sessions...",className:"w-full bg-bg-tertiary border border-border rounded pl-8 pr-8 py-1.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-1 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),R&&i.jsx("button",{type:"button",onClick:ne,className:"absolute right-1.5 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:i.jsx(ri,{className:"w-3.5 h-3.5"})})]}),B&&!q&&i.jsxs("div",{className:"mt-1 text-xs text-text-muted px-1",children:[O.length," ",O.length===1?"match":"matches"]})]}),L&&i.jsx(e7,{isOpen:a,onClose:()=>l(!1),project:L}),i.jsx(Oc,{isOpen:u!==null,onClose:()=>c(null),onConfirm:Y,title:"Delete session?",message:"This session will be permanently deleted.",confirmLabel:"Delete session",confirmVariant:"danger"}),i.jsx(Oc,{isOpen:x,onClose:()=>y(!1),onConfirm:P,title:"Delete all sessions?",message:"Delete all sessions in this project? This cannot be undone.",confirmLabel:"Delete all",confirmVariant:"danger"}),i.jsx(Tt,{isOpen:d!==null,onClose:()=>{h(null),m("")},title:"Rename session",size:"sm",footer:i.jsx(X2,{onCancel:()=>{h(null),m("")},onSave:X,saving:!1,saveDisabled:p.trim()==="",saveLabel:"Rename"}),children:i.jsx("input",{type:"text",value:p,onChange:Ee=>m(Ee.target.value),onKeyDown:Ee=>{Ee.key==="Enter"&&X()},onFocus:Ee=>Ee.target.select(),className:"w-full px-3 py-2 text-sm text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-1 focus:ring-accent-primary",autoFocus:!0})}),i.jsx(Ze,{className:"flex-1",children:O.length===0?i.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:B?"No matching sessions":"No sessions"}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"divide-y divide-border",ref:I,onClick:J,children:r7(O,C,v,$,Q,e,T,D,R,W)}),E&&i.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),i.jsx("div",{ref:Z,className:"h-px"})]})})]});return i.jsx("aside",{className:`
|
|
275
|
+
${t?"md:w-[300px] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden md:border-r-0"}
|
|
276
|
+
md:relative md:h-auto md:translate-x-0
|
|
277
|
+
|
|
278
|
+
fixed z-50 h-[calc(100vh-32px)]
|
|
279
|
+
w-[300px] bg-secondary border-r border-border flex flex-col
|
|
280
|
+
transition-transform duration-300 ease-in-out
|
|
281
|
+
${t?"translate-x-0":"-translate-x-full"}
|
|
282
|
+
`,children:ae})})()]})}function r7(e,t,n,r,a,l,u,c,d,h){const p=Y2(e);let m=0;return Array.from(p).map(([x,y])=>{const S=y[0];return S?i.jsxs("div",{children:[i.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:q2(S.updatedAt)}),y.map(C=>{const v=m++,w=(t==null?void 0:t.id)===C.id,_=v===h,b=n.includes(C.id),k=C.isRunning,E=u.includes(C.id)||w&&c.length>0;return i.jsx("div",{"data-sidx":v,className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${w?"bg-bg-tertiary":""} ${_?"bg-accent-primary/10":""}`,children:i.jsxs(ur,{href:`/p/${l}/s/${C.id}`,className:`block ${w?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[i.jsxs("div",{className:"flex justify-between items-center mb-1",children:[i.jsx("span",{className:`font-medium truncate text-sm ${w?"text-accent-primary":"text-text-primary"}`,children:d?Ox(C.title??C.id.slice(0,6),d):C.title??C.id.slice(0,6)}),i.jsx(Zc,{items:[{label:"Rename session",onClick:T=>a(C.id,T)},{label:"Delete session",onClick:T=>r(C.id,T),danger:!0}],trigger:i.jsx("button",{onClick:T=>T.preventDefault(),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:i.jsx(Pk,{})})})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[E?i.jsx("span",{title:"Awaiting confirmation",children:i.jsx(ay,{className:"w-3 h-3 text-red-400 flex-shrink-0"})}):k?i.jsx(UR,{}):b&&!w?i.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,i.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:gf(C.updatedAt)}),i.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[C.messageCount," messages"]})]})]})},C.id)})]},x):null})}const Fw=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"];function s7(){var u;const e=Jt(c=>c.currentProject),t=Re(c=>c.currentSession),n=Vh(),r=N.useRef(0),a=N.useRef(null);N.useEffect(()=>(n?(a.current||(r.current=0),a.current=window.setInterval(()=>{r.current=(r.current+1)%Fw.length,l()},150),l()):(a.current&&(clearInterval(a.current),a.current=null),l()),()=>{a.current&&(clearInterval(a.current),a.current=null)}),[n,e,t]);const l=()=>{var p;const d=(p=t==null?void 0:t.metadata)==null?void 0:p.title,h=n?`${Fw[r.current]} `:"";e&&d?document.title=`${h}${e.name} - ${d} | OpenFox`:e?document.title=`${h}${e.name} | OpenFox`:document.title=`${h}OpenFox`};return typeof window<"u"&&((u=t==null?void 0:t.metadata)!=null&&u.title)&&window.document.documentElement.setAttribute("data-session-title",t.metadata.title),null}function Z2({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const a=()=>{r(),t()};return i.jsx(Oc,{isOpen:e,onClose:t,onConfirm:a,title:"Delete Project",confirmLabel:"Delete",confirmVariant:"danger",message:i.jsxs(i.Fragment,{children:["This will permanently delete the project"," ",i.jsx("span",{className:"font-semibold text-text-primary",children:n})," and all its sessions from OpenFox. The project files on disk will remain untouched."]})})}function i7({isOpen:e,onClose:t}){const[,n]=zn(),[r,a]=N.useState(!1),l=G2(),[u,c]=N.useState(!1),d=Jt(L=>L.projects),h=Jt(L=>L.createProject),p=Jt(L=>L.listProjects),m=Jt(L=>L.deleteProject),[x,y]=N.useState(null),[S,C]=N.useState(null);N.useEffect(()=>{e&&p()},[e,p]);const v=L=>{n(`/p/${L}`),t()},w=(L,R)=>{R.stopPropagation(),y(L)},_=()=>{x&&(m(x.id),y(null))},b=async L=>E(L);function k(L){return L!=null&&typeof L=="object"&&"error"in L&&L.error!=null&&typeof L.error=="object"&&"code"in L.error&&L.error.code==="EACCES"}async function E(L){const R=Jk(L),M=await h(R,L);return p(),k(M)?(C(M.error.path||L),!1):M&&"id"in M?(n(`/p/${M.id}`),t(),!0):!1}const T=N.useCallback(()=>{C(null)},[]),D=N.useCallback(async()=>{const L=S;C(null),L&&await E(L)},[S]);return e?i.jsxs(Tt,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:i.jsx("div",{className:"flex justify-end gap-2",children:i.jsx(mt,{variant:"secondary",onClick:t,children:"Close"})}),children:[i.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[i.jsxs("div",{className:"w-full sm:w-1/2 border-b sm:border-b-0 sm:border-r border-border flex flex-col max-h-[40vh] sm:max-h-[50vh]",children:[i.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:i.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),i.jsx(Ze,{className:"flex-1",children:d.length===0?i.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[i.jsx("p",{className:"mb-2",children:"No recent projects"}),i.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):i.jsx("div",{className:"divide-y divide-border",children:d.map(L=>i.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[i.jsxs("button",{onClick:()=>v(L.id),className:"flex-1 flex items-center gap-3 text-left",children:[i.jsx(Vr,{className:"w-5 h-5 text-accent-primary"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"font-medium truncate",children:L.name}),i.jsx("div",{className:"text-xs text-text-muted truncate",children:Zk(L.workdir,32)})]})]}),i.jsx("button",{onClick:R=>w(L,R),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:i.jsx(Ba,{className:"w-4 h-4"})})]},L.id))})})]}),i.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:i.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[i.jsx(mt,{variant:"primary",onClick:()=>c(!0),children:"Select existing project"}),i.jsx(mt,{variant:"secondary",onClick:()=>a(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),r&&i.jsx(W2,{isOpen:r,onClose:()=>a(!1)}),x&&i.jsx(Z2,{isOpen:!0,onClose:()=>y(null),projectName:x.name,onConfirm:_}),u&&i.jsx(Kh,{initialPath:l??void 0,onSelect:L=>{b(L)},onClose:()=>c(!1)}),S&&i.jsx(V2,{isOpen:!0,onClose:T,path:S,onRetry:D})]}):null}function a7(){const[e,t]=N.useState(!1),[n,r]=N.useState(null),[a,l]=N.useState(""),[u,c]=N.useState(""),d=N.useRef(null),h=Re(I=>I.sessions),p=Jt(I=>I.projects),m=Jt(I=>I.loading),x=Jt(I=>I.listProjects),y=Re(I=>I.listSessions),S=Jt(I=>I.deleteProject),C=Re(I=>I.connectionStatus);N.useEffect(()=>{C==="connected"&&(x(),y())},[C,x,y]),N.useEffect(()=>{const I=setTimeout(()=>c(a),150);return()=>clearTimeout(I)},[a]);const{matchCount:v,filteredSessionIds:w,relevanceScores:_,matchTypes:b,promptSnippets:k}=N.useMemo(()=>{if(!u)return{matchCount:0,filteredSessionIds:null,relevanceScores:null,matchTypes:null,promptSnippets:null};const I=new Map(p.map(F=>[F.id,F])),U=new Map,V=new Map,Z=new Map,ee=h.filter(F=>{var K;const O=I.get(F.projectId),B=(O==null?void 0:O.name)??"",q=F.title??"",$=((K=F.recentUserPrompts)==null?void 0:K.map(P=>P.content))??[],Y=$.join(" ");let Q=0,X="";if(Pi(q,u)&&(Q+=10,X="title"),Pi(Y,u)){Q+=3,X=X==="title"?"title":"prompts";const P=$.find(J=>Pi(J,u));if(P){const J=P.toLowerCase().indexOf(u.toLowerCase());if(J>=0){const ne=Math.max(0,J-30),ce=Math.min(P.length,J+u.length+30);Z.set(F.id,(ne>0?"…":"")+P.slice(ne,ce)+(ce<P.length?"…":""))}else Z.set(F.id,P.slice(0,80)+(P.length>80?"…":""))}}return Pi(B,u)&&(Q+=1,X=X||"project"),U.set(F.id,Q),V.set(F.id,X),Q>0});return{matchCount:ee.length,filteredSessionIds:new Set(ee.map(F=>F.id)),relevanceScores:U,matchTypes:V,promptSnippets:Z}},[h,u,p]),E=N.useMemo(()=>{const I=new Map;for(const U of h){const V=new Date(U.updatedAt).getTime(),Z=I.get(U.projectId)??0;V>Z&&I.set(U.projectId,V)}return I},[h]),T=N.useMemo(()=>{const I=new Map;for(const U of h){const V=I.get(U.projectId);V?V.push(U):I.set(U.projectId,[U])}for(const[,U]of I)U.sort((V,Z)=>new Date(Z.updatedAt).getTime()-new Date(V.updatedAt).getTime());return I},[h]),D=N.useMemo(()=>{let I=p;return u&&w&&(I=p.filter(U=>{const V=T.get(U.id);return V==null?void 0:V.some(Z=>w.has(Z.id))})),[...I].sort((U,V)=>{const Z=E.get(U.id)??new Date(U.updatedAt).getTime();return(E.get(V.id)??new Date(V.updatedAt).getTime())-Z})},[p,T,u,w,E]),L=N.useCallback(I=>{const U=T.get(I);return U?u&&w&&_?U.filter(V=>w.has(V.id)).sort((V,Z)=>{const ee=(_.get(Z.id)??0)-(_.get(V.id)??0);return ee!==0?ee:new Date(Z.updatedAt).getTime()-new Date(V.updatedAt).getTime()}):U.slice(0,5):[]},[T,u,w,_]),R=()=>{t(!0)},M=()=>{var I;l(""),c(""),(I=d.current)==null||I.focus()},W=I=>{var U;I.key==="Escape"&&(M(),(U=d.current)==null||U.blur())},z=u.length>0,H=z&&v===0;return i.jsxs(Ze,{className:"flex-1 flex flex-col bg-primary",children:[i.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[i.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),i.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),i.jsx(mt,{variant:"primary",onClick:R,children:"Open Project"})]}),h.length>0&&i.jsxs("div",{className:"mb-4 md:mb-6 relative",children:[i.jsxs("div",{className:"relative flex items-center",children:[i.jsx(Vi,{className:"absolute left-3 w-4 h-4 text-text-muted pointer-events-none"}),i.jsx("input",{ref:d,type:"text",value:a,onChange:I=>l(I.target.value),onKeyDown:W,placeholder:"Search sessions by title or keyword...",className:"w-full bg-bg-secondary border border-border rounded-lg pl-10 pr-10 py-2.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),a&&i.jsx("button",{type:"button",onClick:M,className:"absolute right-3 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:i.jsx(ri,{className:"w-4 h-4"})})]}),z&&!H&&i.jsxs("div",{className:"mt-1.5 text-xs text-text-muted px-1",children:[v," ",v===1?"match":"matches"]})]}),H?i.jsxs("div",{className:"text-center py-16 text-text-muted",children:[i.jsx(Vi,{className:"w-10 h-10 mx-auto mb-4 opacity-40"}),i.jsxs("p",{className:"text-lg",children:["No sessions matching ",i.jsxs("span",{className:"text-text-primary font-medium",children:["“",u,"”"]})]}),i.jsx("p",{className:"mt-2 text-sm",children:"Try a different keyword or clear the search"})]}):D.map(I=>{const U=L(I.id);return i.jsx("div",{className:"mb-6 md:mb-8",children:i.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[i.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[i.jsxs(ur,{href:`/p/${I.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[i.jsx(Vr,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),i.jsx("span",{className:"text-text-primary font-semibold",children:I.name})]}),i.jsx(ur,{href:`/p/${I.id}/new`,className:"rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-1.5 py-1 text-xs",children:"+ New Session"}),i.jsx("button",{type:"button",onClick:()=>r({id:I.id,name:I.name}),className:"p-1.5 rounded text-text-muted hover:text-accent-error hover:bg-accent-error/10 transition-colors",title:"Delete project",children:i.jsx(Ba,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"divide-y divide-border",children:U.length>0?U.map(V=>{const Z=p.find(B=>V.projectId===B.id),ee=Z?`/p/${Z.id}/s/${V.id}`:"#",F=V.title??V.id.slice(0,8),O=b==null?void 0:b.get(V.id);return i.jsx(ur,{href:ee,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-text-muted truncate",children:z&&O==="title"?Ox(F,u):F}),z&&O&&O!=="title"&&i.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1",children:[i.jsx("span",{className:"text-[10px] font-medium text-accent-primary border border-accent-primary/30 bg-accent-primary/8 rounded px-1 py-0.5 leading-none",children:O==="prompts"?"prompts":"project"}),O==="prompts"&&(k==null?void 0:k.get(V.id))&&i.jsx("span",{className:"text-[11px] text-text-muted truncate max-w-[250px]",children:Ox(k.get(V.id),u)})]})]})}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[i.jsx("span",{className:"text-text-muted text-xs",children:VH(V.updatedAt)}),i.jsxs("span",{className:"text-text-muted text-xs",children:[V.messageCount," msgs"]})]})]})},V.id)}):i.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},I.id)}),!z&&D.length===0&&!m&&i.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),m&&i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(Gi,{})})]}),e&&i.jsx(i7,{isOpen:e,onClose:()=>t(!1)}),n&&i.jsx(Z2,{isOpen:!0,onClose:()=>r(null),projectName:n.name,onConfirm:()=>S(n.id)})]})}function o7(){const[,e]=Zo("/p/:projectId/new"),[,t]=zn(),n=e==null?void 0:e.projectId,r=Re(u=>u.createSession),a=Re(u=>u.resetPendingSessionCreate),l=N.useCallback(async()=>{if(!n)return;const u=await r(n);u?(t(`/p/${n}/s/${u.id}`),a()):(t(`/p/${n}`),a())},[n,r,t,a]);return N.useEffect(()=>{l()},[l]),i.jsx("div",{className:"flex-1 flex items-center justify-center",children:i.jsx(Gi,{})})}function l7(){const e=Jt(t=>t.currentProject);return i.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:i.jsxs("div",{className:"max-w-md",children:[i.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),i.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),i.jsxs("div",{className:"flex flex-col gap-3",children:[e&&i.jsx(ur,{href:`/p/${e.id}/new`,"data-testid":"create-new-session-button",className:"block w-full rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-2 text-center",children:"Create New Session"}),i.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const uc=e=>Math.round(e*10)/10;function c7(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function Ix(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function u7(e){return`${e.providerId}::${e.model}`}function d7(e){return`${e.providerName} > ${e.model}`}function Uw(e){let t=0,n=0,r=0,a=0,l=0,u=0;const c=[],d=[];let h=0;for(const[x,y]of e.entries()){const S=y.stats,C=Ix(S);t+=S.totalTime,n+=S.toolTime,r+=S.prefillTokens,a+=S.generationTokens;const v=S.prefillSpeed>0?S.prefillTokens/S.prefillSpeed:0,w=S.generationSpeed>0?S.generationTokens/S.generationSpeed:0;l+=v,u+=w,c.push({messageId:y.id,timestamp:y.timestamp,...C,mode:S.mode,responseIndex:x+1,prefillTokens:S.prefillTokens,generationTokens:S.generationTokens,prefillSpeed:S.prefillSpeed,generationSpeed:S.generationSpeed,totalTime:S.totalTime,aiTime:S.totalTime-S.toolTime,toolTime:S.toolTime});const _=S.llmCalls??[];for(const b of _)h+=1,d.push({messageId:y.id,timestamp:b.timestamp??y.timestamp,providerId:b.providerId,providerName:b.providerName,backend:b.backend,model:b.model,mode:S.mode,responseIndex:x+1,sessionCallIndex:h,callIndex:b.callIndex,promptTokens:b.promptTokens,completionTokens:b.completionTokens,ttft:b.ttft,completionTime:b.completionTime,prefillSpeed:b.prefillSpeed,generationSpeed:b.generationSpeed,totalTime:b.totalTime,...b.temperature!==void 0&&{temperature:b.temperature},...b.topP!==void 0&&{topP:b.topP},...b.topK!==void 0&&{topK:b.topK},...b.maxTokens!==void 0&&{maxTokens:b.maxTokens}})}const p=l>0?uc(r/l):0,m=u>0?uc(a/u):0;return{totalTime:uc(t),aiTime:uc(t-n),toolTime:uc(n),prefillTokens:r,generationTokens:a,avgPrefillSpeed:p,avgGenerationSpeed:m,responseCount:e.length,llmCallCount:d.length,dataPoints:c,callDataPoints:d}}function h7(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null&&c7(a.stats)).sort((a,l)=>new Date(a.timestamp).getTime()-new Date(l.timestamp).getTime());if(t.length===0)return null;const n=new Map;for(const a of t){const l=u7(Ix(a.stats)),u=n.get(l)??[];n.set(l,[...u,a])}const r=Array.from(n.entries()).map(([a,l])=>{const u=Ix(l[0].stats),c=Uw(l);return{...u,key:a,label:d7(u),...c}});return{...Uw(t),modelGroups:r}}function f7(e){return N.useMemo(()=>h7(e),[e])}function Yy(){var a;const e=Re(l=>l.gitStatus),t=Re(l=>l.currentSession),[n,r]=N.useState(!0);return N.useEffect(()=>{t!=null&&t.workdir&&r(!1)},[t==null?void 0:t.workdir]),{branch:(e==null?void 0:e.branch)??null,diff:{files:((a=e==null?void 0:e.diff)==null?void 0:a.files)??[],loading:n,error:null}}}function Xo(e){return e.toLocaleString("en-US").replace(/,/g," ")}function Vw(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function _s(e){if(!Number.isFinite(e))return"0s";if(e<10)return`${e.toFixed(1)}s`;const t=Math.round(e);if(t<60)return`${t}s`;if(t<3600){const u=Math.floor(t/60),c=t%60;return`${u}m ${c}s`}const n=Math.floor(t/3600),r=t%3600,a=Math.floor(r/60),l=r%60;return`${n}h ${a}m ${l}s`}const Ww=Object.assign(Object.create(null),{criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"}),Gw=Object.assign(Object.create(null),{criteria:"criteria",review_findings:"review findings",todos:"tasks"});function Vo(e){return Object.hasOwn(Ww,e)?Ww[e]:e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function m7(e){return Object.hasOwn(Gw,e)?Gw[e]:e.replace(/_/g," ")}const qw=["▁","▂","▃","▄","▅","▆","▇","█"];function p7(e,t,n){if(n===t)return 4;const r=(e-t)/(n-t);return Math.min(7,Math.max(0,Math.round(r*7)))}function g7(e,t){if(e===t){const a=Math.max(Math.abs(e)*.05,1);return{minY:e-a,maxY:t+a}}const n=t-e,r=Math.max(n*.1,.1);return{minY:e-r,maxY:t+r}}function x7(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((x,y)=>x.x-y.x),r=n[0].x,a=n[n.length-1].x,l=Math.min(...n.map(x=>x.y)),u=Math.max(...n.map(x=>x.y)),{minY:c,maxY:d}=g7(l,u),h=Math.max(0,c),p=Array.from({length:t},()=>" "),m=new Map;for(const x of n){const y=a===r?0:Math.round((x.x-r)/(a-r)*(t-1)),S=m.get(y)??[];m.set(y,[...S,x.y])}for(const[x,y]of m){const S=Math.max(...y);p[x]=qw[p7(S,c,d)]??qw[0]}return{blocks:p.join(""),minX:r,maxX:a,minY:h,maxY:d}}function Kw(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function Yw({data:e,width:t=60,height:n=78,label:r,xLabel:a,yLabel:l,showAxes:u=!0,formatY:c=Kw,formatX:d=Kw}){const h=N.useMemo(()=>{const p=x7(e,t),m=Math.max(t*6,240),x=10,y=8,C=[...e].sort((b,k)=>b.x-k.x).map(b=>{const k=p.maxX===p.minX?m/2:x+(b.x-p.minX)/(p.maxX-p.minX)*(m-x*2),E=p.maxY===p.minY?n/2:y+(p.maxY-b.y)/(p.maxY-p.minY)*(n-y*2);return{...b,cx:k,cy:E,leftPercent:k/m*100,topPercent:E/n*100}}),v=C.map((b,k)=>`${k===0?"M":"L"} ${b.cx.toFixed(1)} ${b.cy.toFixed(1)}`).join(" "),_=[p.maxY,(p.maxY+p.minY)/2,p.minY].map(b=>({value:b,y:p.maxY===p.minY?n/2:y+(p.maxY-b)/(p.maxY-p.minY)*(n-y*2)}));return{...p,chartWidth:m,points:C,path:v,gridLines:_}},[e,n,t]);return e.length===0?i.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[r&&i.jsx("div",{className:"mb-1",children:r}),i.jsx("div",{children:"No data"})]}):i.jsxs("div",{className:"font-mono text-xs",children:[r&&i.jsx("div",{className:"text-text-secondary mb-2",children:r}),i.jsxs("div",{className:"flex gap-3",children:[u&&i.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:h.gridLines.map(p=>i.jsx("span",{children:c(p.value)},`${p.value}-${p.y}`))}),i.jsx("div",{className:"flex-1 min-w-0",children:i.jsxs("div",{className:"relative h-[78px]",children:[i.jsxs("svg",{viewBox:`0 0 ${h.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[h.gridLines.map(p=>i.jsx("line",{x1:"0",x2:h.chartWidth,y1:p.y,y2:p.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${p.y}`)),h.points.map(p=>i.jsx("line",{x1:p.cx,x2:p.cx,y1:n-4,y2:p.cy,stroke:"currentColor",className:"text-border/40"},`guide-${p.cx}-${p.cy}`)),h.points.length>1&&i.jsx("path",{d:h.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),h.points.map(p=>i.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${p.leftPercent}%`,top:`${p.topPercent}%`},title:`${d(p.x)} -> ${c(p.y)}`,children:i.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:i.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${p.x}-${p.y}`))]})})]}),u&&i.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[i.jsx("span",{className:"w-12"}),i.jsxs("span",{className:"flex-1 flex justify-between",children:[i.jsx("span",{children:d(h.minX)}),i.jsx("span",{children:a}),i.jsx("span",{children:d(h.maxX)})]})]}),l&&u&&i.jsx("div",{className:"text-text-muted mt-1 text-center",children:l})]})}function y7({data:e,prefillLabel:t="Prefill Speed (tok/s) by Response",generationLabel:n="Generation Speed (tok/s) by Response",xLabel:r="response",width:a=60}){const l=e.map(c=>({x:c.x,y:c.ppSpeed})),u=e.map(c=>({x:c.x,y:c.tgSpeed}));return i.jsxs("div",{className:"space-y-5",children:[i.jsx(Yw,{data:l,width:a,label:t,xLabel:r}),i.jsx(Yw,{data:u,width:a,label:n,xLabel:r})]})}function b7(e){const t=new Map;for(const n of e.callDataPoints){const r=t.get(n.messageId)??[];t.set(n.messageId,[...r,n])}return e.dataPoints.map(n=>{const r=[...t.get(n.messageId)??[]].sort((a,l)=>a.callIndex-l.callIndex);return{...n,callCount:r.length,calls:r,isExpandable:r.length>1}})}function v7(e){return{mode:"responses",xLabel:"response",prefillLabel:"Prefill Speed (tok/s) by Response",generationLabel:"Generation Speed (tok/s) by Response",points:e.dataPoints.map(t=>({x:t.responseIndex,ppSpeed:t.prefillSpeed,tgSpeed:t.generationSpeed}))}}function _7(e){return{mode:"calls",xLabel:"context",prefillLabel:"Prefill Speed (tok/s) vs Context",generationLabel:"Generation Speed (tok/s) vs Context",points:e.callDataPoints.map(t=>({x:t.promptTokens,ppSpeed:t.prefillSpeed,tgSpeed:t.generationSpeed}))}}function S7(e){return e.callDataPoints.length>0?_7(e):v7(e)}function Oa(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function yc(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function w7(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${Oa(t)} ctx`:`${Oa(t)}-${Oa(n)} ctx`}function jh(e){return`${yc(e)} t/s`}function eN(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function C7(e){return{exportedAt:new Date().toISOString(),providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model,label:e.label,summary:{totalTime:e.totalTime,aiTime:e.aiTime,toolTime:e.toolTime,prefillTokens:e.prefillTokens,generationTokens:e.generationTokens,avgPrefillSpeed:e.avgPrefillSpeed,avgGenerationSpeed:e.avgGenerationSpeed,responseCount:e.responseCount,llmCallCount:e.llmCallCount},responses:e.dataPoints.map(t=>({responseIndex:t.responseIndex,timestamp:t.timestamp,mode:t.mode,prefillTokens:t.prefillTokens,generationTokens:t.generationTokens,prefillSpeed:t.prefillSpeed,generationSpeed:t.generationSpeed,totalTime:t.totalTime,aiTime:t.aiTime,toolTime:t.toolTime})),llmCalls:e.callDataPoints.map(t=>({sessionCallIndex:t.sessionCallIndex,responseIndex:t.responseIndex,callIndex:t.callIndex,timestamp:t.timestamp,mode:t.mode,promptTokens:t.promptTokens,completionTokens:t.completionTokens,ttft:t.ttft,completionTime:t.completionTime,prefillSpeed:t.prefillSpeed,generationSpeed:t.generationSpeed,totalTime:t.totalTime}))}}function k7({isOpen:e,onClose:t,stats:n}){const r=N.useRef(null),[a,l]=N.useState({}),[u,c]=N.useState(()=>{var S;return((S=n.modelGroups[0])==null?void 0:S.key)??""});N.useEffect(()=>{var S;n.modelGroups.some(C=>C.key===u)||c(((S=n.modelGroups[0])==null?void 0:S.key)??"")},[u,n.modelGroups]);const d=N.useMemo(()=>n.modelGroups.find(S=>S.key===u)??n.modelGroups[0],[u,n.modelGroups]),h=N.useMemo(()=>d?b7(d):[],[d]),p=N.useMemo(()=>d?S7(d):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[d]),m=N.useCallback(S=>{l(C=>({...C,[S]:!C[S]}))},[]),x=N.useCallback(()=>{if(!d)return;const S=C7(d);navigator.clipboard.writeText(JSON.stringify(S,null,2)).catch(C=>console.error("Failed to copy:",C))},[d]),y=N.useCallback(async()=>{if(r.current)try{const S=(await re(async()=>{const{default:w}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:w}},[])).default,C=await S(r.current,{backgroundColor:"#1a1a1a",scale:2}),v=document.createElement("a");v.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,v.href=C.toDataURL("image/png"),v.click()}catch(S){console.error("Failed to export PNG:",S),x()}},[x]);return i.jsx(Tt,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:i.jsxs("div",{ref:r,className:"space-y-6",children:[i.jsx("section",{children:i.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(S=>i.jsx("button",{onClick:()=>c(S.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${S.key===(d==null?void 0:d.key)?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-primary hover:bg-bg-tertiary/40"}`,title:S.label,children:S.label},S.key))})}),d&&i.jsxs("section",{children:[i.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[i.jsx(Gs,{label:"AI Time",value:_s(d.aiTime)}),i.jsx(Gs,{label:"Total Time",value:_s(d.totalTime)}),i.jsx(Gs,{label:"Tool Time",value:_s(d.toolTime)}),i.jsx(Gs,{label:"Responses",value:d.responseCount.toString()}),i.jsx(Gs,{label:"LLM Calls",value:d.llmCallCount.toString()})]}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[i.jsx(Gs,{label:"Prefill Tokens",value:Oa(d.prefillTokens),subValue:`@ ${yc(d.avgPrefillSpeed)} tok/s`}),i.jsx(Gs,{label:"Gen Tokens",value:Oa(d.generationTokens),subValue:`@ ${yc(d.avgGenerationSpeed)} tok/s`}),i.jsx(Gs,{label:"Avg PP Speed",value:`${yc(d.avgPrefillSpeed)}`,subValue:"tok/s"}),i.jsx(Gs,{label:"Avg TG Speed",value:`${yc(d.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),d&&p.points.length>1&&i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:x,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),i.jsx("button",{onClick:y,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),i.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:i.jsx(y7,{data:p.points,width:50,prefillLabel:p.prefillLabel,generationLabel:p.generationLabel,xLabel:p.xLabel})})]}),d&&i.jsxs("section",{children:[i.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",d.responseCount," responses)"]}),i.jsx(Ze,{className:"bg-bg-tertiary/30 rounded",children:i.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[i.jsxs("colgroup",{children:[i.jsx("col",{className:"w-[7%]"}),i.jsx("col",{className:"w-[14%]"}),i.jsx("col",{className:"w-[10%]"}),i.jsx("col",{className:"w-[14%]"}),i.jsx("col",{className:"w-[14%]"}),i.jsx("col",{className:"w-[14%]"}),i.jsx("col",{className:"w-[11%]"}),i.jsx("col",{className:"w-[2%]"})]}),i.jsx("thead",{children:i.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[i.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),i.jsx("th",{className:"px-2 py-2"})]})}),i.jsx("tbody",{children:h.map((S,C)=>i.jsxs(N.Fragment,{children:[i.jsx(j7,{row:S,index:C,isExpanded:a[S.messageId]??!1,onToggle:S.isExpandable?()=>m(S.messageId):void 0}),(a[S.messageId]??!1)&&S.calls.map((v,w)=>i.jsx(E7,{dataPoint:v,index:w},`${v.messageId}-${v.callIndex}`))]},S.messageId))})]})})]})]})})}function Gs({label:e,value:t,subValue:n}){return i.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[i.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),i.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&i.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function j7({row:e,index:t,isExpanded:n,onToggle:r}){const a=e.calls.length>0?w7(e.calls.map(l=>l.promptTokens)):`${Oa(e.prefillTokens)} ctx`;return i.jsxs("tr",{onClick:r,className:`${t%2===0?"bg-bg-tertiary/20":""} ${r?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[i.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:eN(e.timestamp)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:_s(e.totalTime)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:a.replace(/ ctx$/,"")}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:jh(e.prefillSpeed)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:jh(e.generationSpeed)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function E7({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[i.jsxs("td",{className:"px-3 py-2 pl-6 text-center text-text-muted align-middle border-l border-border/60",children:["c",e.callIndex]}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:eN(e.timestamp)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:_s(e.totalTime)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Oa(e.promptTokens)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:jh(e.prefillSpeed)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:jh(e.generationSpeed)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),i.jsx("td",{className:"px-2 py-2"})]}),n&&i.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:i.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:i.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&i.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&i.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&i.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&i.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const N7={passed:{icon:"✓",color:"text-accent-success"},completed:{icon:"◉",color:"text-purple-400"},failed:{icon:"✗",color:"text-accent-error"},resolved:{icon:"✓",color:"text-accent-success"},dismissed:{icon:"–",color:"text-text-muted"},open:{icon:"○",color:"text-accent-warning"},pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"◌",color:"text-accent-warning"}},tN=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function T7(e){return N7[e]??{icon:"○",color:"text-text-muted"}}function Xy(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const ll=N.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:r,color:a}=T7(t);return i.jsx("span",{className:`${a} ${n}`,children:r})});function Eh({entries:e,title:t}){const n=N.useMemo(()=>e.reduce((r,a)=>(r[a.status]=(r[a.status]??0)+1,r),{}),[e]);return i.jsxs("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center justify-between",children:[i.jsx("span",{children:t}),Object.keys(n).length>0&&i.jsx("span",{className:"font-normal text-xs flex items-center gap-1.5",children:tN.map(r=>{const a=n[r];return a?i.jsxs("span",{className:"flex items-center gap-0.5",children:[i.jsx(ll,{status:r}),i.jsx("span",{children:a})]},r):null})})]})}const nN=N.memo(function({entries:t,title:n,onClearAll:r}){const[a,l]=N.useState(!1),u=N.useCallback(()=>{l(!1),r==null||r()},[r]);return t.length===0?null:i.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[n&&i.jsx("div",{className:"px-1.5 py-1 border-b border-border bg-secondary",children:i.jsx("span",{className:"text-xs font-medium text-text-muted",children:n})}),i.jsx("div",{className:"bg-primary",children:t.map((c,d)=>i.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${d>0?"border-t border-border":""}`,children:[i.jsx(ll,{status:c.status}),i.jsxs("div",{className:"flex-1 min-w-0 text-xs truncate",children:[i.jsxs("span",{className:"text-text-muted",children:["[",c.id,"]"]})," ",Xy(c.description)]})]},c.id??d))}),r&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:i.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all",children:[i.jsx(Ba,{className:"w-3 h-3"}),"Clear all"]})}),a&&i.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:i.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[i.jsx("span",{className:"text-xs text-accent-error",children:"Clear all?"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:u,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),i.jsx("button",{onClick:()=>l(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})})]})]})}),A7={criteria:["pending","completed","passed","failed"],todos:["pending","in_progress","completed"],review_findings:["open","resolved","dismissed"]},L7=["pending","completed","failed","dismissed"];function D7(e){return A7[e]??L7}function R7(e,t){const n=t.indexOf(e);return n===-1?t[0]??"pending":t[(n+1)%t.length]??"pending"}function rN({entries:e,sessionId:t,metadataKey:n,title:r,isOpen:a,onClose:l}){const[u,c]=N.useState(e),[d,h]=N.useState(null),[p,m]=N.useState(""),[x,y]=N.useState(!1),[S,C]=N.useState(""),v=N.useRef(null),w=N.useRef(null),_=N.useCallback(()=>{const z=w.current;z&&(z.style.height="auto",z.style.height=z.scrollHeight+"px")},[]);N.useEffect(()=>{c(e)},[e]),N.useEffect(()=>{var z;d&&(_(),(z=w.current)==null||z.focus())},[d,_]),N.useEffect(()=>{var z;x&&((z=v.current)==null||z.focus())},[x]);const b=N.useCallback(z=>{c(z),Ce(`/api/sessions/${t}/metadata/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:z})}).catch(H=>console.error(`Failed to sync ${n}:`,H))},[t,n]),k=N.useCallback(z=>{const H=D7(n),I=u.map(U=>U.id===z?{...U,status:R7(U.status,H)}:U);b(I)},[u,n,b]),E=N.useCallback((z,H)=>{h(z),m(H)},[]),T=N.useCallback((z,H,I)=>{var Z;const U=(H.trim()||((Z=I.find(ee=>ee.id===z))==null?void 0:Z.description))??"",V=I.map(ee=>ee.id===z?{...ee,description:U}:ee);b(V)},[b]),D=N.useCallback(()=>{d&&(T(d,p,u),h(null))},[d,p,u,T]),L=N.useCallback(z=>{z.key==="Enter"&&D(),z.key==="Escape"&&(z.stopPropagation(),h(null))},[D]),R=N.useCallback(z=>{b(u.filter(H=>H.id!==z))},[u,b]),M=N.useCallback(()=>{const z=S.trim();if(!z)return;const H=u.map(U=>Number(U.id)).filter(U=>Number.isInteger(U)&&U>=0),I=String(Math.max(-1,...H)+1);b([...u,{id:I,description:z,status:"pending"}]),C("")},[S,u,b]),W=N.useCallback(z=>{z.key==="Enter"&&(z.preventDefault(),M()),z.key==="Escape"&&(y(!1),C(""))},[M]);return i.jsxs(Tt,{isOpen:a,onClose:l,title:r,size:"full",showCloseButton:!0,closeOnEscape:!0,children:[i.jsxs("ul",{className:"space-y-1",children:[u.map((z,H)=>{const I=d===z.id,U=i.jsxs("button",{onClick:()=>E(z.id,z.description),className:"text-sm text-text-primary text-left hover:text-accent-primary transition-colors w-full cursor-pointer",title:"Click to edit",children:[i.jsxs("span",{className:"text-text-muted",children:["[",z.id,"]"]})," ",i.jsx("span",{children:Xy(z.description)})]}),V=I?i.jsx("textarea",{ref:w,value:p,onChange:Z=>{m(Z.target.value),_()},onBlur:D,onKeyDown:L,className:"w-full bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary resize-none",rows:1}):U;return i.jsxs("li",{className:`flex items-start gap-2 px-2 py-1.5 ${H>0?"border-t border-border":""}`,children:[i.jsx("button",{onClick:()=>k(z.id),className:"flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity mt-0.5",title:"Click to cycle status",children:i.jsx(ll,{status:z.status})}),i.jsx("div",{className:"flex-1 min-w-0",children:V}),i.jsx("button",{onClick:()=>R(z.id),className:"flex-shrink-0 text-text-muted hover:text-accent-error transition-colors cursor-pointer mt-0.5 ml-auto",title:"Delete entry",children:i.jsx("span",{className:"flex",children:i.jsx(ri,{className:"w-4 h-4"})})})]},z.id)}),u.length===0&&i.jsx("p",{className:"text-sm text-text-muted italic text-center py-4",children:"No entries yet."})]}),i.jsx("div",{className:"mt-4 pt-3 border-t border-border",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted text-sm leading-tight",children:"○"}),i.jsx("input",{ref:v,value:S,onChange:z=>C(z.target.value),onKeyDown:W,placeholder:"New entry...",className:"flex-1 bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"}),i.jsxs("button",{onClick:M,className:"flex items-center gap-1 text-sm text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add entry",children:[i.jsx(ws,{className:"w-4 h-4"}),"Add"]})]})})]})}const kt=Gn((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],fetchTemplateVariables:async()=>{try{const r=await(await Ce("/api/workflows/template-variables")).json();e({templateVariables:r.variables??[]})}catch{}},fetchWorkflows:async()=>{e({loading:!0});try{const r=await(await Ce("/api/workflows")).json();e({defaults:r.defaults??[],userItems:r.userItems??[],projectItems:r.projectItems??[],activeWorkflowId:r.activeWorkflowId??"default",loading:!1})}catch{e({loading:!1})}},fetchWorkflow:async n=>{try{const r=await Ce(`/api/workflows/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await Ce(`/api/workflows/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createWorkflow:async(n,r)=>{const a=await Ui("POST","/api/workflows",{...n,destination:r});return a.success&&await t().fetchWorkflows(),a},updateWorkflow:async(n,r)=>{const a=await Ui("PUT",`/api/workflows/${n}`,r);return a.success&&await t().fetchWorkflows(),a},deleteWorkflow:async n=>{try{const r=await Ce(`/api/workflows/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n),projectItems:l.projectItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateWorkflow:async(n,r)=>Uh(`/api/workflows/${n}/duplicate`,()=>t().fetchWorkflows(),r)})),O7={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function I7(e,t){await Ce(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function Rd({id:e,agents:t}){const n=Yo(t,e),r=t.find(a=>a.id===e);return i.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${n}20`,color:n},children:(r==null?void 0:r.name)??e})}function M7({id:e}){const t=kt(u=>u.defaults),n=kt(u=>u.userItems),a=N.useMemo(()=>[...t,...n],[t,n]).find(u=>u.id===e),l=(a==null?void 0:a.color)??"#3b82f6";return i.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${l}20`,color:l},children:(a==null?void 0:a.name)??e})}function sN({entries:e,sessionId:t}){const[n,r]=N.useState(e),[a,l]=N.useState(!1),[u,c]=N.useState(null),[d,h]=N.useState(""),[p,m]=N.useState(""),[x,y]=N.useState(!1),[S,C]=N.useState(!1),v=gt(ee=>ee.defaults),w=gt(ee=>ee.userItems),_=gt(ee=>ee.projectItems),b=N.useMemo(()=>[...v,...w,..._],[v,w,_]),k=N.useRef(null),E=N.useRef(null);N.useEffect(()=>{r(e)},[e]),N.useEffect(()=>{var ee;a&&((ee=k.current)==null||ee.focus())},[a]),N.useEffect(()=>{var ee;u&&((ee=E.current)==null||ee.focus())},[u]);const T=N.useCallback(ee=>{r(ee),I7(t,ee)},[t]),D=N.useCallback(ee=>{var $;const F=ee.map(Y=>Y.trim()).filter(Boolean);if(F.length===0)return;const O=n.map(Y=>Number(Y.id)).filter(Y=>Number.isInteger(Y)&&Y>=0),B=Math.max(-1,...O)+1,q=F.map((Y,Q)=>({id:String(B+Q),description:Y,status:"pending"}));T([...n,...q]),h(""),($=k.current)==null||$.focus()},[n,T]),L=N.useCallback(()=>{D([d])},[D,d]),R=N.useCallback(ee=>{const F=ee.clipboardData.getData("text/plain").split(/\r\n|\r|\n/);F.length<2||(ee.preventDefault(),D(F))},[D]),M=N.useCallback(()=>{l(!1),h("")},[]),W=N.useCallback((ee,F)=>{c(ee),m(F)},[]),z=N.useCallback(()=>{if(!u)return;const ee=p.trim(),F=n.map(O=>O.id===u?{...O,description:ee||O.description}:O);T(F),c(null)},[u,p,n,T]),H=N.useCallback(ee=>{const F=n.map(O=>O.id===ee?{...O,status:O7[O.status]??"pending"}:O);T(F)},[n,T]),I=N.useCallback(ee=>{T(n.filter(F=>F.id!==ee))},[n,T]),U=N.useCallback(()=>{T([]),y(!1)},[T]),V=N.useCallback(ee=>{ee.key==="Enter"&&(ee.preventDefault(),L()),ee.key==="Escape"&&M()},[L,M]),Z=N.useCallback(ee=>{ee.key==="Enter"&&z(),ee.key==="Escape"&&c(null)},[z]);return i.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[i.jsxs("div",{className:"bg-primary",children:[n.length===0&&!a&&i.jsxs("div",{className:"px-1.5 py-2 text-xs text-text-muted italic text-center",children:["No criteria yet."," ",i.jsx("button",{onClick:()=>C(!0),className:"text-accent-primary hover:underline not-italic cursor-pointer",children:"Learn more"})]}),n.map((ee,F)=>{const O=ee.status,B=u===ee.id;return i.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${F>0?"border-t border-border":""}`,children:[i.jsx("button",{onClick:()=>H(ee.id),className:"text-xs leading-tight flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",title:`Status: ${ee.status} (click to cycle)`,children:i.jsx(ll,{status:O})}),i.jsx("div",{className:"flex-1 min-w-0",children:B?i.jsx("input",{ref:E,value:p,onChange:q=>m(q.target.value),onBlur:z,onKeyDown:Z,className:"w-full bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary"}):i.jsxs("button",{onClick:()=>W(ee.id,ee.description),className:"text-xs text-text-primary text-left hover:text-accent-primary transition-colors w-full truncate cursor-pointer",title:"Click to edit",children:["[",ee.id,"] ",Xy(ee.description)]})}),i.jsx("button",{onClick:()=>I(ee.id),className:"flex-shrink-0 opacity-0 group-hover:opacity-100 text-text-muted hover:text-accent-error transition-all ml-0.5 cursor-pointer flex items-center self-center",title:"Delete criterion",children:i.jsx(ri,{className:"w-4 h-4"})})]},ee.id)})]}),a&&i.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"text-text-muted text-xs leading-tight flex-shrink-0",children:"○"}),i.jsx("input",{ref:k,value:d,onChange:ee=>h(ee.target.value),onKeyDown:V,onPaste:R,placeholder:"New criterion...",className:"flex-1 bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"})]})}),i.jsxs("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:[a?i.jsxs(i.Fragment,{children:[i.jsxs("button",{onClick:L,className:"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add criterion",children:[i.jsx(ws,{className:"w-3 h-3"}),"Add"]}),i.jsx("button",{onClick:M,className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Cancel",children:"Cancel"})]}):i.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"Add criterion",children:[i.jsx(ws,{className:"w-3 h-3"}),"Add"]}),n.length>0&&i.jsxs("button",{onClick:()=>y(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all criteria",children:[i.jsx(Ba,{className:"w-3 h-3"}),"Clear all"]}),i.jsx("button",{onClick:()=>C(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"About criteria",children:i.jsx(iy,{className:"w-3 h-3"})})]}),x&&i.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:i.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[i.jsx("span",{className:"text-xs text-accent-error",children:"Clear all criteria?"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:U,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),i.jsx("button",{onClick:()=>y(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})}),i.jsx(Tt,{isOpen:S,onClose:()=>C(!1),title:"About Acceptance Criteria",size:"md",children:i.jsxs("div",{className:"space-y-3 text-sm text-text-secondary",children:[i.jsx("p",{children:"Each criterion defines a specific requirement that needs to be met."}),i.jsxs("p",{children:["To use this feature, start in ",i.jsx(Rd,{id:"planner",agents:b})," mode and",i.jsxs("strong",{className:"text-text-primary",children:[" ","ask the agent to define acceptance criteria that matches your goal"]}),". Then launch the ",i.jsx(M7,{id:"default"})," builtin workflow to launch the automation part."]}),i.jsx("p",{children:"This workflow will automatically:"}),i.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[i.jsxs("li",{children:["Launch the ",i.jsx(Rd,{id:"builder",agents:b}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),i.jsxs("li",{children:["Then launch the ",i.jsx(Rd,{id:"verifier",agents:b})," subagent, that will verify each criterion. If every criterion is fulfilled, then it goes to the next step, otherwise, it gives feedback to the main agent until 100% of the criteria are met."]}),i.jsxs("li",{children:["Launch a ",i.jsx(Rd,{id:"code_reviewer",agents:b})," subagent, that will analyze the code to provide actionable feedback to the main agent."]})]}),i.jsx("div",{className:"bg-bg-tertiary rounded p-3 space-y-1.5",children:i.jsx("p",{children:"This lets smaller models follow complex plans to completion and improves the chances that nothing from your plan is missed."})})]})})]})}function iN({isOpen:e,onClose:t}){const n=Un(C=>C.config),r=Un(C=>C.saveConfig),[a,l]=N.useState(""),[u,c]=N.useState(""),[d,h]=N.useState(!1),[p,m]=N.useState(!1),[x,y]=N.useState(!1);N.useEffect(()=>{e&&(l((n==null?void 0:n.command)??""),c((n==null?void 0:n.url)??""),h((n==null?void 0:n.hotReload)??!1),m((n==null?void 0:n.disableInspect)??!1))},[e,n]);const S=async()=>{!a.trim()||!u.trim()||(y(!0),await r({command:a.trim(),url:u.trim(),hotReload:d,disableInspect:p}),y(!1),t())};return i.jsx(Tt,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),i.jsx("input",{className:"input w-full",type:"text",value:a,onChange:C=>l(C.target.value),placeholder:"npm run dev"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),i.jsx("input",{className:"input w-full",type:"text",value:u,onChange:C=>c(C.target.value),placeholder:"http://localhost:3000"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"hotReload",checked:d,onChange:C=>h(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),i.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"disableInspect",checked:p,onChange:C=>m(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),i.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),i.jsx("button",{className:"btn btn-primary",onClick:S,disabled:x||!a.trim()||!u.trim(),children:x?"Saving...":"Save"})]})]})})}const Xw={30:"text-black",31:"text-red-400",32:"text-accent-success",33:"text-accent-warning",34:"text-blue-400",35:"text-purple-400",36:"text-cyan-400",37:"text-gray-300",90:"text-gray-500",91:"text-red-500",92:"text-green-500",93:"text-yellow-400",94:"text-blue-500",95:"text-pink-400",96:"text-cyan-500",97:"text-white"},P7={40:"bg-black",41:"bg-red-900",42:"bg-green-900",43:"bg-yellow-900",44:"bg-blue-900",45:"bg-purple-900",46:"bg-cyan-900",47:"bg-gray-700"},Qw={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},B7="text-text-primary";function $7(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let r=0,a="text-text-primary",l;try{for(;(l=n.exec(e))!==null;){if(l.index>r){const h=e.slice(r,l.index);h&&t.push({text:h,className:a})}const u=l[1];if(!u)continue;const c=u.split(";").map(Number);if(c.length===0||c[0]===0){a="text-text-primary";continue}const d=[];for(const h of c)if(h>=30&&h<=37){const p=Xw[h];p&&d.push(p)}else if(h>=40&&h<=47){const p=P7[h];p&&d.push(p)}else if(h>=90&&h<=97){const p=Xw[h];p&&d.push(p)}else if(h in Qw){const p=Qw[h];p&&d.push(p)}else h===39?d.push(B7):h===49&&(a=a.split(" ").filter(p=>!p.startsWith("bg-")).join(" "));d.length>0&&(a=d.join(" ")),r=n.lastIndex}if(r<e.length){const u=e.slice(r);u&&t.push({text:u,className:a})}return t}catch(u){return console.warn("ANSI parsing failed, stripping codes:",u),[{text:z7(e),className:"text-text-primary"}]}}function z7(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function Nh(e){const t=$7(e),n=[];return t.forEach((r,a)=>{const l=r.text.split(`
|
|
283
|
+
`);l.forEach((u,c)=>{n.push(bs.createElement("span",{key:`${a}-${c}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},u)),c<l.length-1&&n.push(bs.createElement("br",{key:`${a}-${c}-br`}))})}),n.length===1?n[0]:n}function aN({logs:e,preRef:t,preClassName:n="text-sm font-mono",scrollAreaRef:r,onScrollbarGesture:a}){return i.jsx(Ze,{ref:r,options:{overflow:{x:"scroll",y:"scroll"}},className:n,onScrollbarGesture:a,children:i.jsx("pre",{ref:t,className:"contents",children:e.length===0?i.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((l,u)=>l.type==="marker"?i.jsx(N.Fragment,{children:i.jsx("hr",{className:"border-t border-border my-1"})},u):i.jsx("span",{className:l.stream==="stderr"?"text-accent-warning":"",children:Nh(l.content)},u))})})}function Qy({isActive:e,onToggle:t,className:n,style:r}){return i.jsxs("button",{type:"button",onClick:()=>t(!e),className:n,style:r,children:[e?i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):i.jsx(yn,{className:"w-3 h-3"}),e?"live":"scroll to bottom"]})}const H7=2,F7=100,U7=6,V7=1500,oN=(e,t)=>e==="down"?!1:t!==null&&t<=U7,xf=(e,t,n)=>{const r=N.useRef(!0),a=N.useRef(null),l=N.useRef(!1),u=N.useRef(0),[c,d]=N.useState(!0),h=N.useCallback(()=>{if(n)return n();const y=e.current;return y instanceof HTMLElement?y:null},[n,e]),p=N.useCallback(y=>{r.current=y,d(y)},[]),m=N.useCallback(()=>{const y=h();y&&(y.scrollTop=y.scrollHeight,u.current=Date.now())},[h]),x=N.useCallback((y,S)=>{y==="down"&&(l.current=!0);const C=oN(y,S);p(C),C&&(u.current=Date.now()),y==="up"&&(l.current=!1)},[p]);return N.useEffect(()=>{const y=h();if(!y)return;const S=()=>{y.scrollHeight-y.scrollTop-y.offsetHeight<F7&&(u.current=Date.now(),p(!0))},C=T=>{if(T.deltaY>0){requestAnimationFrame(()=>requestAnimationFrame(S));return}p(!1)},v=T=>{T.touches[0]&&(a.current=T.touches[0].clientY)},w=T=>{if(a.current===null)return;const D=T.touches[0];if(!D)return;if(D.clientY-a.current>0){p(!1);return}requestAnimationFrame(()=>requestAnimationFrame(S))},_=()=>{if(l.current)return;if(y.scrollHeight-y.scrollTop-y.offsetHeight<H7){u.current=Date.now(),p(!0);return}Date.now()-u.current<=V7||p(!1)},b=T=>{if(!(T.ctrlKey||T.metaKey||T.altKey)){if(T.key==="ArrowUp"||T.key==="PageUp"||T.key==="Home"){p(!1);return}(T.key==="ArrowDown"||T.key==="PageDown"||T.key==="End")&&requestAnimationFrame(()=>requestAnimationFrame(S))}},k=new MutationObserver(()=>{r.current&&requestAnimationFrame(m)}),E=setInterval(()=>{r.current&&m()},1e3);return y.addEventListener("wheel",C,{passive:!0}),y.addEventListener("touchstart",v,{passive:!0}),y.addEventListener("touchmove",w,{passive:!0}),y.addEventListener("scroll",_,{passive:!0}),y.addEventListener("keydown",b),y.tabIndex=-1,k.observe(y,{childList:!0,subtree:!0,characterData:!0}),()=>{y.removeEventListener("wheel",C),y.removeEventListener("touchstart",v),y.removeEventListener("touchmove",w),y.removeEventListener("scroll",_),y.removeEventListener("keydown",b),k.disconnect(),clearInterval(E)}},[t==null?void 0:t.id,h,m,p]),{force_scroll_to_bottom:()=>{p(!0),m()},isAutoScrollActive:c,setAutoScroll:y=>{p(y),y&&m()},handleScrollbarGesture:x}},lN=e=>N.useCallback(()=>{var t,n;return((n=(t=e.current)==null?void 0:t.osInstance())==null?void 0:n.elements().viewport)??null},[e]),Jy=N.memo(function({title:t,logs:n,onClose:r,onClear:a,onInsertMarker:l,preClassName:u}){const c=N.useRef(null),d=lN(c),{isAutoScrollActive:h,setAutoScroll:p,handleScrollbarGesture:m}=xf(c,null,d);return i.jsx(Tt,{isOpen:!0,onClose:r,title:t,size:"full",scrollable:!1,headerRight:i.jsx(Qy,{isActive:h,onToggle:p,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),footer:i.jsxs("div",{className:"flex items-center gap-2",children:[l&&i.jsxs("button",{onClick:l,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",title:"Insert marker",children:[i.jsx(ws,{className:"w-3.5 h-3.5"}),"Marker"]}),a&&i.jsxs("button",{onClick:a,className:"text-xs text-text-muted hover:text-accent-error flex items-center gap-1 px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",title:"Clear logs",children:[i.jsx(Ba,{className:"w-3.5 h-3.5"}),"Clear"]})]}),children:i.jsx(Ze,{ref:c,className:"flex-1 -m-4 p-4",onScrollbarGesture:m,children:i.jsx(aN,{logs:n,preClassName:u})})})}),W7=N.memo(function({logs:t,anchorRef:n,isHiding:r,isAutoScrollActive:a,onSetAutoScroll:l}){const[u,c]=N.useState(null),d=N.useRef(null),h=N.useRef(l);h.current=l;const p=N.useCallback((x,y)=>{l(oN(x,y))},[l]),m=N.useCallback(()=>{var x,y;return((y=(x=d.current)==null?void 0:x.osInstance())==null?void 0:y.elements().viewport)??null},[]);return N.useEffect(()=>{var y;const x=(y=n.current)==null?void 0:y.getBoundingClientRect();x&&c({bottom:window.innerHeight-x.bottom,right:window.innerWidth-x.right,width:x.width,height:x.height})},[n]),N.useEffect(()=>{const x=m();if(!x)return;const y=S=>{if(S.deltaY<0){h.current(!1);return}S.deltaY>0&&requestAnimationFrame(()=>requestAnimationFrame(()=>{x.scrollHeight-x.scrollTop-x.offsetHeight<100&&h.current(!0)}))};return x.addEventListener("wheel",y,{passive:!0}),()=>x.removeEventListener("wheel",y)},[m]),N.useEffect(()=>{const x=m();x&&a&&(x.scrollTop=x.scrollHeight)},[t,a,u,m]),i.jsx("div",{className:`relative ${u?"":"hidden"}`,children:i.jsx(Ze,{ref:d,className:"fixed z-40 text-sm font-mono text-text-primary bg-bg-primary p-2 rounded border border-border transition-all duration-150 ease-out select-text",onScrollbarGesture:p,style:u?{bottom:u.bottom,right:u.right,width:u.width*2,maxHeight:u.height*3,transformOrigin:"bottom right",transform:r?"scale(0.01)":"scale(1)",opacity:r?0:1}:void 0,children:i.jsx("pre",{className:"text-sm font-mono",children:t.map((x,y)=>i.jsx("span",{className:x.stream==="stderr"?"text-accent-warning":"",children:Nh(x.content)},y))})})})}),cN=N.memo(function({workdir:t,compact:n,onExpand:r,onConfigure:a}){const l=Un(B=>B.setWorkdir),u=Un(B=>B.status),c=Un(B=>B.config),d=Un(B=>B.logs),h=Un(B=>B.start),p=Un(B=>B.stop),m=Un(B=>B.fetchLogs),x=Un(B=>B.clearLogs),y=Un(B=>B.insertMarker),S=()=>{window.confirm("Clear all dev server logs?")&&x()},[C,v]=N.useState(!1),[w,_]=N.useState(!1),[b,k]=N.useState(!1),[E,T]=N.useState(!1),D=N.useRef(null),L=N.useRef(null),R=N.useCallback(()=>{var B,q;return((q=(B=L.current)==null?void 0:B.osInstance())==null?void 0:q.elements().viewport)??null},[]),{isAutoScrollActive:M,setAutoScroll:W,handleScrollbarGesture:z}=xf(L,null,R),H=N.useRef(null),I=N.useRef(null),U=N.useRef(null),V=()=>{const B=u==null?void 0:u.inspectProxyPort;if(!B){u!=null&&u.url&&window.open(u.url,"_blank");return}const q=`${window.location.protocol}//${window.location.hostname}:${B}`;window.open(q,"_blank")},Z=(u==null?void 0:u.state)??"off",ee=c!==null,F=Z==="running"||Z==="warning";N.useEffect(()=>{l(t??null)},[t,l]),N.useEffect(()=>{F&&m()},[F,m]);const O=()=>{F?p():h()};return i.jsxs("div",{className:`space-y-3 ${n?"":"mt-2 pt-3 border-t border-border"}`,children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${Z==="running"?"bg-accent-success":Z==="warning"?"bg-accent-warning":Z==="error"?"bg-accent-error":"bg-text-muted"}`}),i.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),i.jsx("button",{onClick:()=>{a?a():v(!0)},className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:i.jsx(zR,{})})]}),ee?i.jsx(i.Fragment,{children:Z==="running"||Z==="warning"?i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("button",{onClick:O,className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[i.jsx(ay,{}),"Stop"]}),(u==null?void 0:u.url)&&i.jsxs("button",{onClick:()=>V(),className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",title:u.url,children:[i.jsx($k,{}),"Open"]})]}):i.jsx("button",{onClick:O,className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",children:"Start"})}):i.jsx("button",{onClick:()=>{a?a():v(!0)},className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-muted hover:bg-border transition-colors",children:"Configure"}),i.jsxs("div",{ref:U,className:`relative ${ee&&F?"":"hidden"}`,onMouseEnter:()=>{!ee||!F||n||(I.current&&clearTimeout(I.current),H.current=setTimeout(()=>{k(!0),T(!1)},500))},onMouseLeave:()=>{H.current&&clearTimeout(H.current),T(!0),I.current=setTimeout(()=>k(!1),150)},children:[i.jsx(aN,{logs:d,preRef:D,preClassName:"text-sm bg-bg-primary p-2 rounded max-h-[200px] border border-border",scrollAreaRef:L,onScrollbarGesture:z}),ee&&F&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"absolute bottom-1 right-1 z-50 flex items-center gap-1",children:[!n&&(b||E)&&i.jsx(Qy,{isActive:M,onToggle:W,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),i.jsx("button",{onClick:()=>n?r==null?void 0:r():_(!0),className:"px-2 py-0.5 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors",children:"Expand"})]}),!n&&(b||E)&&U.current&&si.createPortal(i.jsx(W7,{logs:d,anchorRef:U,isHiding:E,isAutoScrollActive:M,onSetAutoScroll:W}),document.body)]})]}),!a&&i.jsx(iN,{isOpen:C,onClose:()=>v(!1)}),w&&i.jsx(Jy,{title:"Dev Server Logs",logs:d,onClose:()=>_(!1),onClear:S,onInsertMarker:y})]})}),G7=N.memo(function({sessionId:t}){var y;const n=bc(S=>S.processes),r=bc(S=>S.stopProcess),[a,l]=N.useState(null),[u,c]=N.useState([]),d=n.filter(S=>S.status!=="exited"),h=d.filter(S=>S.status==="running").length;if(n.length===0)return null;const p=S=>{switch(S){case"running":return"bg-accent-success";case"starting":return"bg-accent-warning";case"stopping":return"bg-accent-warning";case"exited":return"bg-text-muted";default:return"bg-text-muted"}},m=S=>{const C=bc.getState().logs[S]??[];c(C.map(v=>({content:v.content,stream:v.stream}))),l(S)},x=S=>{t&&r(S,t)};return i.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),i.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),i.jsxs("span",{className:"text-xs text-text-muted",children:["(",h," running)"]})]})}),i.jsx("div",{className:"space-y-2",children:d.map(S=>i.jsx("div",{className:"border border-border rounded p-2",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[i.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${p(S.status)}`}),i.jsx("span",{className:"text-sm text-text-primary truncate",title:S.name,children:S.name}),i.jsxs("span",{className:"text-xs text-text-muted",children:["[",S.status,"]"]})]}),i.jsxs("div",{className:"flex gap-1 ml-2",children:[i.jsx("button",{onClick:()=>m(S.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),i.jsx("button",{onClick:()=>x(S.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-accent-error/20 text-text-secondary hover:text-accent-error transition-colors",title:"Stop process",children:"Stop"})]})]})},S.id))}),a&&i.jsx(Jy,{title:((y=d.find(S=>S.id===a))==null?void 0:y.name)??"",logs:u,onClose:()=>{l(null),c([])}})]})});function uN(){return nn.getState().platform??null}function dN(e){const t=e.replace(/\\/g,"/");return encodeURI(t).replace(/#/g,"%23").replace(/\?/g,"%3F")}function hN(e,t,n){const r=uN(),a=e.startsWith("/")||e.match(/^[a-zA-Z]:[/\\]/)?e:n?`${n.replace(/\\/g,"/").replace(/\/$/,"")}/${e}`:e,l=dN(a);if(r!=null&&r.isWSL&&r.wslDistro)return`${`vscode://vscode-remote/wsl+${r.wslDistro}${l}`}:${t??1}`;const u=`vscode://file/${l}`;return t?`${u}:${t}`:u}function q7(e){const t=uN(),n=dN(e.replace(/\\/g,"/"));return t!=null&&t.isWSL&&t.wslDistro?`vscode://vscode-remote/wsl+${t.wslDistro}${n}`:`vscode://file/${n}`}function K7({file:e,showEditorLink:t,workdir:n}){const r=Zk(e.path,28),a=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",l=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"",u=t&&n?hN(e.path,void 0,n):void 0,c=i.jsxs(i.Fragment,{children:[i.jsx("span",{className:`truncate ${a}`,title:e.path,children:r}),l&&i.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:l})]});return u?i.jsx("a",{href:u,className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0 hover:bg-bg-tertiary rounded px-1 transition-colors no-underline",title:`Open ${e.path} in VSCode`,children:c}):i.jsx("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:c})}function Y7(){const{diff:e}=Yy(),t=Vt(a=>a.settings[Ae.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",n=Re(a=>a.currentSession),r=(n==null?void 0:n.workspace)??(n==null?void 0:n.workdir);return e.loading?i.jsx("div",{className:"mt-3",children:i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[i.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),i.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?i.jsx("div",{className:"mt-3",children:i.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):i.jsx(Ze,{className:"mt-3 max-h-[150px]",children:i.jsx("div",{className:"pr-1",children:e.files.map((a,l)=>i.jsx(K7,{file:a,showEditorLink:t,workdir:r},l))})})}function fN(e){const[t,n]=N.useState(!1),[r,a]=N.useState(null),[l,u]=N.useState(!1),[c,d]=N.useState(""),h=N.useCallback(()=>{t||e()},[t,e]),p=c.trim().length>0&&!t,m=N.useCallback(()=>{a(null),n(!1),d(""),u(!0)},[]);return{busy:t,setBusy:n,error:r,setError:a,loading:l,setLoading:u,newName:c,setNewName:d,handleClose:h,canCreate:p,resetState:m}}function mN({isOpen:e,onClose:t,title:n,busy:r,loading:a,children:l}){const u=i.jsx("div",{className:"flex gap-2 justify-end",children:i.jsx("button",{onClick:t,className:"px-4 py-2 text-sm rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Cancel"})});return i.jsx(Tt,{isOpen:e,onClose:t,title:n,size:"md",footer:u,children:a||r?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(Gi,{})}):l})}function pN({icon:e,title:t,placeholder:n,buttonLabel:r,value:a,onChange:l,onCreate:u,canCreate:c,busy:d}){return i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:t}),i.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded border border-border bg-bg-primary focus-within:border-accent-primary mb-3",children:[i.jsx("span",{className:"w-4 h-4 shrink-0 text-text-muted flex items-center",children:e}),i.jsx("input",{type:"text",value:a,onChange:h=>l(h.target.value),onKeyDown:h=>{h.key==="Enter"&&c&&u()},placeholder:n,className:"flex-1 bg-transparent text-sm text-text-primary outline-none font-mono placeholder-text-muted"})]}),i.jsx("button",{onClick:u,disabled:!c||d,className:"w-full px-4 py-2 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors disabled:opacity-50",children:r})]})}function gN({isOpen:e,onClose:t,projectId:n,sessionId:r,currentWorkspace:a,currentBranch:l}){const u=Re(H=>H.loadSession),{busy:c,setBusy:d,error:h,setError:p,loading:m,setLoading:x,newName:y,setNewName:S,handleClose:C,canCreate:v,resetState:w}=fN(t),[_,b]=N.useState([]),[k,E]=N.useState(null),[T,D]=N.useState(null),[L,R]=N.useState(!1);N.useEffect(()=>{e&&(w(),E(null),D(null),R(!1),Ce(`/api/projects/${n}/workspaces`).then(H=>H.json()).then(H=>{b(H.workspaces),x(!1)}).catch(()=>{b([]),x(!1)}))},[e,n,w,x]);const M=N.useCallback(async H=>{p(null),d(!0);try{const I=await Ce(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:H})});if(!I.ok){const U=await I.json().catch(()=>({error:"Failed to switch workspace"}));p(U.error),d(!1);return}await u(r),t()}catch(I){p(I instanceof Error?I.message:"Failed to switch workspace"),d(!1)}},[r,u,t,p,d]),W=N.useCallback(async(H,I)=>{p(null),D(null),R((I==null?void 0:I.force)===!0),d(!0);try{const U=await Ce(`/api/sessions/${r}/delete-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:H,force:(I==null?void 0:I.force)===!0})});if(!U.ok){const ee=await U.json().catch(()=>({error:"Failed to delete workspace"}));p(ee.error),ee.conflictingSessionIds&&D(ee.conflictingSessionIds),R(!1),d(!1);return}E(null),R(!1),await u(r);const Z=await(await Ce(`/api/projects/${n}/workspaces`)).json();b(Z.workspaces),d(!1),x(!1)}catch(U){p(U instanceof Error?U.message:"Failed to delete workspace"),R(!1),d(!1)}},[r,n,u,p,d]),z=N.useCallback(async()=>{p(null),d(!0);try{const H=await Ce(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:y.trim()})});if(!H.ok){const I=await H.json().catch(()=>({error:"Failed to create workspace"}));p(I.error),d(!1);return}await u(r),t()}catch(H){p(H instanceof Error?H.message:"Failed to create workspace"),d(!1)}},[y,r,u,t,p,d]);return i.jsx(mN,{isOpen:e,onClose:C,title:"Switch Workspace",busy:c,loading:m,children:i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Workspaces"}),i.jsxs(Ze,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2 mb-4",children:[i.jsxs("button",{onClick:()=>M("original"),disabled:c,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${a?"hover:bg-bg-tertiary text-text-secondary":"bg-accent-primary/10 text-accent-primary cursor-default"}`,children:[i.jsx(Vr,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{className:"font-mono truncate",children:"original"}),i.jsx("span",{className:"text-xs text-text-muted ml-auto",children:l??"unknown"}),!a&&i.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),_.slice().sort((H,I)=>H.name===a?-1:I.name===a?1:H.name.localeCompare(I.name)).map(H=>i.jsx("div",{className:"group relative",children:k===H.name?i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded bg-accent-error/10",children:[i.jsxs("span",{className:"text-xs text-accent-error",children:["Delete ",H.name,"?"]}),i.jsx("button",{onClick:()=>W(H.name),disabled:c,className:"ml-auto text-xs px-2 py-0.5 rounded bg-accent-error text-white hover:opacity-90",children:"Confirm"}),i.jsx("button",{onClick:()=>E(null),disabled:c,className:"text-xs px-2 py-0.5 rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary",children:"Cancel"})]}):i.jsxs("div",{className:"relative",children:[i.jsxs("button",{onClick:()=>{!c&&H.name!==a&&M(H.name)},disabled:c||H.name===a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${H.name===a?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"} ${c?"opacity-70":""}`,children:[i.jsx(Vr,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{className:"font-mono truncate",children:H.name}),i.jsx("span",{className:"text-xs text-text-muted ml-auto",children:H.branch??"unknown"}),H.name===a&&i.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),H.name!==a&&!c&&i.jsx("button",{onClick:I=>{I.stopPropagation(),p(null),D(null),E(H.name)},className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 text-xs text-text-muted hover:text-accent-error transition-opacity px-1 py-0.5 rounded",title:"Delete workspace",children:"✕"})]})},H.path))]}),i.jsx(pN,{icon:i.jsx(Vr,{}),title:"Create new workspace",placeholder:"workspace name",buttonLabel:"Create Workspace",value:y,onChange:S,onCreate:z,canCreate:v,busy:c}),h&&i.jsxs("div",{className:"mt-3 text-sm bg-accent-error/10 p-2 rounded",role:"alert",children:[i.jsx("p",{className:"text-accent-error",children:h}),T&&T.length>0&&i.jsxs("div",{className:"mt-2 space-y-1",children:[i.jsx("p",{className:"text-xs text-text-muted",children:"Conflicting sessions:"}),i.jsx("ul",{className:"space-y-0.5",children:T.map(H=>i.jsx("li",{children:i.jsx(ur,{href:`/p/${n}/s/${H}`,className:"text-xs font-mono text-accent-primary hover:underline break-all",children:H})},H))}),i.jsx("button",{onClick:()=>W(k??"",{force:!0}),disabled:c||!k,className:"mt-2 text-xs px-2 py-1 rounded bg-accent-warning text-black hover:opacity-90 disabled:opacity-50","aria-label":"Force delete workspace, switching other sessions to original",children:L?"Processing...":"Force Delete (switch other sessions to original)"})]})]})]})})}function xN({isOpen:e,onClose:t,sessionId:n}){const r=Re(D=>D.loadSession),{busy:a,setBusy:l,error:u,setError:c,loading:d,setLoading:h,newName:p,setNewName:m,handleClose:x,canCreate:y,resetState:S}=fN(t),[C,v]=N.useState([]),[w,_]=N.useState(""),[b,k]=N.useState("");N.useEffect(()=>{e&&(S(),_(""),v([]),k(""),Ce(`/api/sessions/${n}/branches`).then(D=>D.json()).then(D=>{v(D.branches),k(D.defaultBranch??""),h(!1)}).catch(()=>{v([]),h(!1)}))},[e,n,S,h]);const E=N.useCallback(async D=>{c(null),l(!0);try{const L=await Ce(`/api/sessions/${n}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:D})});if(!L.ok){const R=await L.json().catch(()=>({error:"Failed to switch branch"}));c(R.error),l(!1);return}await r(n),t()}catch(L){c(L instanceof Error?L.message:"Failed to switch branch"),l(!1)}},[n,r,t,c,l]),T=N.useCallback(async()=>{c(null),l(!0);try{const D={name:p.trim()};w&&(D.sourceBranch=w);const L=await Ce(`/api/sessions/${n}/checkout-new`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)});if(!L.ok){const R=await L.json().catch(()=>({error:"Failed to create branch"}));c(R.error),l(!1);return}await r(n),t()}catch(D){c(D instanceof Error?D.message:"Failed to create branch"),l(!1)}},[p,w,n,r,t,c,l]);return i.jsx(mN,{isOpen:e,onClose:x,title:"Switch Branch",busy:a,loading:d,children:i.jsxs("div",{children:[C.length>0&&i.jsxs("div",{className:"mb-4",children:[i.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Branches"}),i.jsx(Ze,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2",children:C.map(D=>i.jsxs("button",{onClick:()=>{D.current||E(D.name)},disabled:a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${D.current?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"}`,children:[i.jsx(Aa,{className:"w-3.5 h-3.5 shrink-0"}),i.jsx("span",{className:"font-mono truncate",children:D.name}),D.current&&i.jsx("span",{className:"ml-auto text-xs text-text-muted",children:"(current)"}),!D.current&&i.jsx("span",{className:"ml-auto text-xs text-accent-primary",children:"Switch"})]},D.name))})]}),i.jsx(pN,{icon:i.jsx(Aa,{}),title:"Create new branch",placeholder:"feature/my-branch",buttonLabel:"Create Branch",value:p,onChange:m,onCreate:T,canCreate:y,busy:a}),p.trim()&&i.jsxs("div",{className:"mt-2",children:[i.jsxs("label",{className:"text-xs text-text-muted mb-1 block",children:["From branch (optional — defaults to ",b||"project default",")"]}),i.jsxs("div",{className:"relative",children:[i.jsx(Aa,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-muted pointer-events-none"}),i.jsx("input",{type:"text",value:w,onChange:D=>_(D.target.value),placeholder:b||"main",className:"w-full text-sm bg-bg-primary border border-border-default rounded pl-8 pr-2 py-1.5 text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]}),u&&i.jsx("p",{className:"mt-3 text-sm text-accent-error bg-accent-error/10 p-2 rounded",children:u})]})})}function yN({workspaceName:e,branch:t,workdir:n,showEditorLink:r,sessionId:a,projectId:l,onEditWorkspace:u,onEditBranch:c}){const[d,h]=N.useState(!1),[p,m]=N.useState(!1);return t===null?null:i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r&&n?i.jsxs("a",{href:q7(n),className:"flex items-center gap-2 min-w-0 flex-1 no-underline group",title:"Open workspace in VSCode",children:[i.jsx(Vr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),i.jsx("span",{className:"truncate text-text-secondary group-hover:text-accent-primary transition-colors",children:e})]}):i.jsxs(i.Fragment,{children:[i.jsx(Vr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),i.jsx("span",{className:"truncate text-text-secondary",children:e})]}),i.jsx("button",{onClick:()=>{u?u():h(!0)},className:"ml-auto px-2 py-0.5 text-xs rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Edit"})]}),i.jsx("div",{className:"h-px bg-border"}),i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(Aa,{}),i.jsx("span",{className:"truncate text-text-secondary",children:t}),i.jsx("button",{onClick:()=>{c?c():m(!0)},className:"ml-auto px-2 py-0.5 text-xs rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Edit"})]})]}),i.jsx(Y7,{}),!u&&i.jsx(gN,{isOpen:d,onClose:()=>h(!1),projectId:l,sessionId:a,currentWorkspace:e,currentBranch:t}),!c&&i.jsx(xN,{isOpen:p,onClose:()=>m(!1),sessionId:a})]})}function X7(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function Q7(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function Zy({percent:e,dangerZone:t=!1,size:n="md",className:r=""}){const a=n==="sm"?"w-12":"w-20",l=n==="sm"?"h-1":"h-1.5";return i.jsx("div",{className:`${l} bg-bg-tertiary rounded-full overflow-hidden ${a} ${r}`,children:i.jsx("div",{className:`h-full transition-all duration-300 ${Q7(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function J7({dangerZone:e,size:t="md"}){return e?i.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function Z7({code:e,variant:t}){const n=t==="inline"?"span":t==="block-nowrap"?"div":"pre";return i.jsx(n,{className:"language-",children:i.jsx("code",{className:"language-",children:e})})}const Qo=N.memo(function({code:t,language:n,variant:r,showLineNumbers:a=!1,startLine:l=1}){const{showSyntaxHighlighting:u}=Pa(),[c,d]=N.useState(null),h=P2(),p=N.useRef(t);if(N.useEffect(()=>{u&&(p.current=t,M2(t,n,h).then(x=>{p.current===t&&d(x)}))},[t,n,h,u]),!u||!c)return i.jsx(Z7,{code:t,variant:r});if(r==="inline")return i.jsx("span",{dangerouslySetInnerHTML:{__html:c}});const m=a?"":"shiki-plain";return i.jsx("div",{className:m,style:{"--shiki-start":l},dangerouslySetInnerHTML:{__html:c}})});function bN({src:e,alt:t,isOpen:n,onClose:r}){return n?i.jsx(Tt,{isOpen:n,onClose:r,title:"",size:"full",children:i.jsx("div",{className:"flex items-center justify-center h-full",children:i.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})})}):null}const Th=N.memo(function({type:t,children:n}){const r=t==="removed"?"diff-removed-bg diff-removed-border":"diff-added-bg diff-added-border",a=t==="removed"?"line-through decoration-red-400/30":"";return i.jsx("div",{className:`border-l-[3px] ${r}`,children:i.jsx("div",{className:`min-w-0 py-3 ${a}`,children:i.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:n})})})}),e9=N.memo(function({oldString:t,newString:n,filePath:r}){const a=N.useMemo(()=>pf(r),[r]),l=t.length>0,u=n.length>0;return!l&&!u?i.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):i.jsxs("div",{className:"rounded overflow-hidden border border-border",children:[l&&i.jsx(Th,{type:"removed",children:i.jsx(Qo,{code:t,language:a,variant:"block",showLineNumbers:!0})}),u&&i.jsx(Th,{type:"added",children:i.jsx(Qo,{code:n,language:a,variant:"block",showLineNumbers:!0})})]})}),t9=N.memo(function({content:t,filePath:n}){const r=N.useMemo(()=>pf(n),[n]);return i.jsx(Ze,{className:"rounded border border-border max-h-[45vh]",children:i.jsx(Th,{type:"added",children:i.jsx(Qo,{code:t,language:r,variant:"block",showLineNumbers:!0})})})}),n9=N.memo(function({regions:t,filePath:n}){const r=N.useMemo(()=>pf(n),[n]);return t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):i.jsx("div",{className:"space-y-2",children:t.map((a,l)=>i.jsx(s9,{region:a,language:r},l))})});function r9(e){const t=[];function n(r,a,l){const u=t[t.length-1];u&&u.type===r&&u.startLine+u.lines.length===a?u.lines.push(l):t.push({type:r,startLine:a,lines:[l]})}for(const r of e.beforeContext)n("context",r.lineNumber,r.content);for(const r of e.edits){const a=r.oldContent.split(`
|
|
284
|
+
`);for(let u=0;u<a.length;u++)n("removed",r.startLine+u,a[u]);const l=r.newContent.split(`
|
|
285
|
+
`);for(let u=0;u<l.length;u++)n("added",r.startLine+u,l[u])}for(const r of e.afterContext)n("context",r.lineNumber,r.content);return t}const s9=N.memo(function({region:t,language:n}){const r=r9(t);return i.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((a,l)=>i.jsx(i9,{section:a,language:n},l))})}),i9=N.memo(function({section:t,language:n}){const r=t.lines.join(`
|
|
286
|
+
`);return t.type==="context"?i.jsx("div",{children:i.jsx("div",{className:"min-w-0 py-3",children:i.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:i.jsx(Qo,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):i.jsx(Th,{type:t.type,children:i.jsx(Qo,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function Jw(e){return e.split(`
|
|
287
|
+
`).filter(t=>!t.startsWith(`
|
|
288
|
+
[`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+\|/,"")).join(`
|
|
289
|
+
`)}const a9=N.memo(function({result:t,metadata:n,filePath:r}){const[a,l]=N.useState(!1),u=N.useMemo(()=>pf(r),[r]),c=n==null?void 0:n.mimeType,d=n==null?void 0:n.base64Data;if(c!=null&&c.startsWith("image/")&&d){const S=`data:${c};base64,${d}`;return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] flex items-center justify-center cursor-pointer hover:border-accent-primary transition-colors",onClick:()=>l(!0),children:i.jsx("img",{src:S,alt:r,className:"max-w-full max-h-[45vh] object-contain"})}),i.jsx(bN,{src:S,alt:r,isOpen:a,onClose:()=>l(!1)})]})}if(!t)return i.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});const h=t;if(u==="markdown"){const S=Jw(h);return i.jsx(Ze,{className:"rounded border border-border max-h-[45vh] p-2",children:i.jsx(Jn,{content:S})})}const p=Jw(h),m=h.split(`
|
|
290
|
+
`)[0],x=m==null?void 0:m.match(/^(\d+)\|/),y=x?parseInt(x[1],10):1;return i.jsx(Ze,{className:"rounded border border-border max-h-[45vh]",children:i.jsx(Qo,{code:p,language:u,variant:"block",showLineNumbers:!0,startLine:y})})});function o9({type:e,content:t}){const n=e==="added"?"diff-added-bg":e==="removed"?"diff-removed-bg":"bg-transparent",r=e==="added"?"+":e==="removed"?"-":" ";return i.jsxs("div",{className:`${n} px-2`,children:[i.jsx("span",{className:"select-none text-text-muted w-6 inline-block",children:r}),i.jsx("span",{className:"whitespace-pre-wrap break-words",children:t||" "})]})}function l9({diff:e}){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(!r||r.type==="unchanged"){n++;continue}if(r.type==="removed"){for(;n<e.length;){const a=e[n];if(!a||a.type!=="removed")break;t.push({type:"removed",content:a.content}),n++}for(;n<e.length;){const a=e[n];if(!a||a.type!=="added")break;t.push({type:"added",content:a.content}),n++}}else if(r.type==="added")for(;n<e.length;){const a=e[n];if(!a||a.type!=="added")break;t.push({type:"added",content:a.content}),n++}}return t.length===0?i.jsx("div",{className:"py-8 text-center text-text-muted",children:"No changes detected."}):i.jsxs("div",{children:[i.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Changes:"}),i.jsx("div",{className:"font-mono text-xs leading-5",children:t.map((r,a)=>i.jsx(o9,{type:r.type,content:r.content},a))})]})}function eb({isOpen:e,onClose:t,isRunning:n,onApply:r}){const[a,l]=N.useState(null),[u,c]=N.useState(!1),d=N.useRef(null),h=N.useCallback(()=>{c(!0);const p=Pt.send("context.applyDynamic.preview",{});d.current=p;const m=Pt.subscribe(x=>{if(x.id===p&&x.type==="context.preview"){const y=x.payload;l(y.diff??[]),c(!1),d.current=null,m()}});setTimeout(()=>{d.current===p&&(c(!1),d.current=null,m())},5e3)},[]);return N.useEffect(()=>{e&&(l(null),c(!0),h())},[e,h]),i.jsxs(Tt,{isOpen:e,onClose:t,title:"Update system prompt",size:"lg",children:[i.jsxs("p",{className:"text-sm text-text-secondary mb-4",children:["Applying the new system prompt will rebuild the cached prompt, which may cause the next response to take longer while the LLM reprocesses the prefix.",n&&i.jsxs(i.Fragment,{children:[" ","Since the session is currently running, the update will be queued and applied at the start of the next turn."]})]}),u?i.jsx("div",{className:"py-8 text-center text-text-muted",children:"Loading diff..."}):a&&a.length>0?i.jsx(Ze,{className:"max-h-[60vh] border border-border rounded-lg",children:i.jsx(l9,{diff:a})}):i.jsx("p",{className:"text-sm text-text-tertiary mb-4",children:"The system prompt hash has changed (e.g., due to tool or skill changes), but the actual prompt text appears identical. Applying the update will still rebuild the cached prompt to ensure consistency."}),i.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[i.jsx("button",{onClick:t,className:"px-3 py-1.5 text-sm rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),i.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:n?"Queue update":"Update"})]})]})}function vN({variant:e="popover",onUpdateSystemPrompt:t}){const n=Re(D=>D.contextState),r=Re(D=>D.currentSession),a=Re(D=>D.compactContext),l=Re(D=>D.queueUpdate),[u,c]=N.useState(!1),[d,h]=N.useState(!1);if(!n||!r)return null;const{currentTokens:p,maxTokens:m,compactionCount:x,dangerZone:y,dynamicContextChanged:S}=n,C=Math.round(p/m*100),v=r.isRunning,w=()=>{v?l():Pt.send("context.applyDynamic",{}),c(!1)},_=e==="sidebar",b=i.jsxs("span",{className:X7(C,y),children:[Xo(p)," / ",Xo(m)," (",C,"%)"]}),k=i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Zy,{percent:C,dangerZone:y,className:"flex-1"}),i.jsx(J7,{dangerZone:y}),x>0&&i.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[x,"x"]})]}),E=i.jsxs("div",{className:"relative",children:[i.jsx("button",{onClick:()=>h(!d),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:i.jsx(Bk,{})}),d&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>h(!1)}),i.jsxs("div",{className:"absolute right-0 top-full mt-1.5 z-50 bg-bg-secondary border border-border rounded-lg shadow-xl py-1 min-w-[160px]",children:[i.jsx("button",{onClick:()=>{v||a(),h(!1)},disabled:v,className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:v?"Cannot compact while running":"Compact context",children:i.jsx("span",{className:y?"text-accent-error":"",children:"Compact"})}),S&&i.jsx("button",{onClick:()=>{h(!1),t?t():c(!0)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors",title:"Preview and apply system prompt changes",children:i.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]})]})]}),T=t?null:i.jsx(eb,{isOpen:u,onClose:()=>c(!1),isRunning:v,onApply:w});return _?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-start gap-2 mb-4",children:[i.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[i.jsx("div",{className:"text-sm",children:b}),k]}),i.jsx("div",{className:"shrink-0 pt-0.5",children:E})]}),T]}):i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("div",{className:"flex items-center justify-between text-sm",children:b}),k]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("button",{onClick:()=>{v||a()},disabled:v,className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors disabled:opacity-40 disabled:cursor-not-allowed rounded",title:v?"Cannot compact while running":"Compact context",children:i.jsx("span",{className:y?"text-accent-error":"",children:"Compact"})}),S&&i.jsx("button",{onClick:()=>{t?t():c(!0)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors rounded",title:"Preview and apply system prompt changes",children:i.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]}),T]})}function Zw({messages:e,workdir:t}){var _,b,k;const[n,r]=N.useState(!1),[a,l]=N.useState(!1),[u,c]=N.useState(null),d=f7(e),{branch:h}=Yy(),p=nn(E=>E.version),m=Re(E=>E.currentSession),x=m!=null&&m.workspace?m.workspace.split("/").pop()??null:null,y=Vt(E=>E.settings[Ae.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",S=ei(E=>E.status),C=ei(E=>E.check),[v,w]=N.useState(!1);return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx(vN,{variant:"sidebar"}),d&&i.jsxs("div",{className:"mb-4",children:[i.jsx("button",{onClick:()=>r(!0),className:"w-full flex items-center justify-center px-3 py-2 rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors",title:"View detailed response and call-level stats",children:i.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[i.jsx("span",{className:"text-text-secondary",children:_s(d.aiTime)}),i.jsx("span",{className:"w-px h-3 bg-border"}),i.jsx("span",{className:"text-text-secondary",children:Vw(d.avgPrefillSpeed)}),i.jsx("span",{children:"pp"}),i.jsx("span",{className:"w-px h-3 bg-border"}),i.jsx("span",{className:"text-text-secondary",children:Vw(d.avgGenerationSpeed)}),i.jsx("span",{children:"tg"})]})}),i.jsx(k7,{isOpen:n,onClose:()=>r(!1),stats:d})]}),i.jsx(Ze,{className:"flex flex-col flex-1 px-4 -mx-4 pb-4",children:i.jsxs("div",{children:[i.jsx("button",{onClick:()=>c("criteria"),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:i.jsx(Eh,{entries:((_=m==null?void 0:m.metadataEntries)==null?void 0:_.criteria)??[],title:"Acceptance Criteria"})}),m&&i.jsx(sN,{entries:((b=m==null?void 0:m.metadataEntries)==null?void 0:b.criteria)??[],sessionId:m.id}),m&&(()=>{const E=["review_findings","todos"],T=m.metadataEntries??{},D=E.filter(R=>R in T),L=Object.keys(T).filter(R=>R!=="criteria"&&!E.includes(R)).sort();return[...D,...L].filter(R=>{var M;return(((M=T[R])==null?void 0:M.length)??0)>0}).map(R=>i.jsxs("div",{className:"mt-6",children:[i.jsx("button",{onClick:()=>c(R),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:i.jsx(Eh,{entries:T[R],title:Vo(R)})}),i.jsx(nN,{entries:T[R],onClearAll:async()=>{try{await Ce(`/api/sessions/${m.id}/metadata/${R}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:[]})})}catch(M){console.error(`Failed to clear ${R}:`,M)}}})]},R))})()]})}),i.jsx(yN,{workspaceName:x??"original",branch:h,workdir:t,showEditorLink:y,sessionId:(m==null?void 0:m.id)??"",projectId:(m==null?void 0:m.projectId)??""}),i.jsx(cN,{workdir:t}),i.jsx(G7,{sessionId:m==null?void 0:m.id}),p&&i.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[i.jsxs("div",{className:"flex items-center justify-center gap-1",children:[i.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",i.jsxs("span",{className:"font-mono",children:["v",p]}),i.jsx("button",{onClick:()=>{w(!0),C(!0)},disabled:S==="checking",className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors disabled:opacity-50",title:"Check for updates",children:i.jsx(Wh,{className:`w-3 h-3 ${S==="checking"?"animate-spin":""}`})})]}),S==="available"&&i.jsx("button",{onClick:()=>l(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"}),v&&S==="upToDate"&&i.jsx("div",{className:"mt-1",children:"Up to date"}),S==="error"&&i.jsx("div",{className:"mt-1",children:"Update check failed"})]}),i.jsx(ij,{isOpen:a,onClose:()=>l(!1),versionInfo:null}),i.jsx(rN,{isOpen:u!==null,onClose:()=>c(null),entries:((k=m==null?void 0:m.metadataEntries)==null?void 0:k[u??""])??[],sessionId:(m==null?void 0:m.id)??"",metadataKey:u??"",title:Vo(u??"")})]})}function c9({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r}){const a=Re(l=>l.currentSession);return i.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&i.jsx("div",{className:"fixed md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),i.jsxs("div",{className:"flex h-full",children:[i.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?i.jsx("aside",{className:"hidden md:block w-[320px] shrink-0 border-l border-border bg-secondary",children:i.jsx(Ze,{className:"h-full p-4",children:i.jsx(Zw,{messages:r,workdir:(a==null?void 0:a.workspace)??(a==null?void 0:a.workdir)})})}):i.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),i.jsx("aside",{className:`
|
|
291
|
+
md:hidden
|
|
292
|
+
bg-secondary
|
|
293
|
+
transition-all duration-300 ease-in-out
|
|
294
|
+
fixed right-0 top-[32px] h-[calc(100vh-32px)] z-50
|
|
295
|
+
${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
|
|
296
|
+
`,children:i.jsx("div",{className:"h-full p-4",children:i.jsx(Ze,{className:"h-full",children:i.jsx(Zw,{messages:r,workdir:(a==null?void 0:a.workspace)??(a==null?void 0:a.workdir)})})})})]})]})}function u9(){const e=Re(S=>S.contextState),t=Re(S=>S.currentSession),n=Re(S=>S.pendingUpdate),r=Re(S=>S.triggerPendingUpdate),a=Re(S=>S.queueUpdate),[l,u]=N.useState(!1),[c,d]=N.useState(!1),h=N.useRef(!1),p=N.useRef(!1);if(N.useEffect(()=>{e!=null&&e.dynamicContextChanged&&!h.current&&u(!1),h.current=(e==null?void 0:e.dynamicContextChanged)??!1},[e==null?void 0:e.dynamicContextChanged]),N.useEffect(()=>{const S=(t==null?void 0:t.isRunning)??!1;p.current&&!S&&n&&r(),p.current=S},[t==null?void 0:t.isRunning,n,r]),!e||!t)return null;const{dynamicContextChanged:m}=e,x=t.isRunning,y=()=>{x?a():Pt.send("context.applyDynamic",{}),u(!0),d(!1)};return i.jsxs(i.Fragment,{children:[m&&!l&&i.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent-warning/10 border-b border-accent-warning/30",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 text-sm text-text-secondary",children:[i.jsx("span",{children:"System prompt has changed —"}),i.jsx("button",{onClick:()=>d(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),i.jsx("button",{onClick:()=>u(!0),className:"flex-shrink-0 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Dismiss",children:i.jsx(ri,{})})]})}),i.jsx(eb,{isOpen:c,onClose:()=>d(!1),isRunning:x,onApply:y})]})}function d9({stats:e,onClose:t}){var c;const n=gt(d=>d.defaults),r=gt(d=>d.userItems),l=[...n,...r].find(d=>d.id===e.mode),u=(l==null?void 0:l.name)??e.mode;return i.jsx(Tt,{isOpen:!0,onClose:t,title:"Turn Stats",size:"md",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"flex items-center gap-3",children:i.jsxs("p",{className:"text-xs text-text-muted",children:[e.model," · ",u]})}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[i.jsx(Od,{label:"Total Time",value:_s(e.totalTime)}),i.jsx(Od,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),i.jsx(Od,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),i.jsx(Od,{label:"LLM Calls",value:String(((c=e.llmCalls)==null?void 0:c.length)??1)})]}),e.llmCalls&&e.llmCalls.length>0&&i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-text-secondary mb-2",children:"LLM Calls"}),e.llmCalls.map((d,h)=>i.jsxs("div",{className:"bg-bg-tertiary/30 rounded p-3 mb-2",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("span",{className:"text-xs text-text-muted",children:["Call ",h+1]}),i.jsxs("span",{className:"text-xs text-text-muted",children:[d.ttft.toFixed(2),"s TTFT · ",d.completionTime.toFixed(2),"s gen"]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-text-muted",children:"Tokens:"})," ",i.jsxs("span",{className:"text-text-primary",children:[d.promptTokens," → ",d.completionTokens]})]}),i.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[d.temperature!==void 0&&i.jsx(Id,{label:"temp",value:d.temperature.toFixed(2)}),d.topP!==void 0&&i.jsx(Id,{label:"topP",value:d.topP.toFixed(2)}),d.topK!==void 0&&i.jsx(Id,{label:"topK",value:String(d.topK)}),d.maxTokens!==void 0&&i.jsx(Id,{label:"maxTok",value:String(d.maxTokens)})]})]})]},h))]})]})})}function Od({label:e,value:t}){return i.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[i.jsx("div",{className:"text-xs text-text-muted",children:e}),i.jsx("div",{className:"text-lg font-semibold text-text-primary",children:t})]})}function Id({label:e,value:t}){return i.jsxs("span",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-primary",children:[i.jsxs("span",{className:"text-text-muted",children:[e,":"]})," ",t]})}const h9=N.memo(function({content:t,variant:n="default"}){return n==="labeled"?i.jsxs("div",{className:"text-text-muted text-sm italic feed-item",children:[i.jsx("span",{className:"text-text-thinking",children:"thinking:"}),i.jsx(Ze,{horizontal:!0,className:"ml-1.5 mt-0.5",children:i.jsx(Jn,{content:t})})]}):i.jsx(Ze,{horizontal:!0,className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item",children:i.jsx(Jn,{content:t,muted:!0})})});function _N({tool:e,className:t="w-4 h-4 text-text-muted flex-shrink-0"}){return e==="glob"||e==="grep"?i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}):e==="run_command"||e==="bash"?i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}):e==="workspace"?i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})}):i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}const f9={error:{icon:"✗",color:"text-accent-error",bg:"bg-red-500/10",border:"border-red-500/30"},warning:{icon:"⚠",color:"text-accent-warning",bg:"bg-yellow-500/10",border:"border-yellow-500/30"},info:{icon:"ℹ",color:"text-accent-info",bg:"bg-blue-500/10",border:"border-blue-500/30"},hint:{icon:"💡",color:"text-text-muted",bg:"bg-gray-500/10",border:"border-gray-500/30"}},eC=N.memo(function({diagnostics:t}){if(t.length===0)return null;const n=t.filter(l=>l.severity==="error"),r=t.filter(l=>l.severity==="warning"),a=t.filter(l=>l.severity==="info"||l.severity==="hint");return i.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[i.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[i.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&i.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),r.length>0&&i.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[r.length," warning",r.length!==1?"s":""]}),a.length>0&&i.jsxs("span",{className:"text-xs text-text-muted",children:[a.length," info"]})]}),i.jsx(Ze,{className:"max-h-48",children:t.map((l,u)=>{const c=f9[l.severity];return i.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${c.bg} border-b border-border last:border-b-0`,children:[i.jsx("span",{className:`${c.color} text-xs flex-shrink-0 w-4 text-center`,children:c.icon}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",l.range.start.line+1,":",l.range.start.character+1]}),l.code&&i.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",l.code,"]"]})]}),i.jsx("div",{className:"text-xs text-text-primary break-words",children:l.message})]})]},u)})})]})}),m9=N.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:a,status:l,result:u,error:c,durationMs:d}){const h=N.useRef(null),[p,m]=N.useState(0);N.useEffect(()=>{h.current&&l==="pending"&&(h.current.scrollTop=h.current.scrollHeight)},[a,l]),N.useEffect(()=>{if(l!=="pending"||!r)return;const C=setInterval(()=>{m(Date.now()-r)},100);return()=>clearInterval(C)},[l,r]);const x=n/1e3,y=l==="pending"?p/1e3:(d??0)/1e3,S=l==="pending"?(a==null?void 0:a.map(C=>C.content).join(""))??"":u??"";return i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[i.jsx("span",{className:"text-text-muted flex-shrink-0",children:"$"}),i.jsx("code",{className:"text-text-primary break-all",children:t})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted flex-shrink-0",children:[l==="pending"&&i.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),l==="interrupted"&&i.jsx("span",{className:"text-red-400",children:"interrupted"}),i.jsxs("span",{className:l==="pending"?"text-text-secondary":"text-text-muted",children:[y.toFixed(1),"s / ",x,"s"]})]})]}),l==="pending"&&i.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:i.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,p/n*100)}%`}})}),(S||l==="pending")&&i.jsx(Ze,{className:`text-xs bg-bg-primary p-2 rounded max-h-64 ${l==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:l==="pending"&&a?a.map((C,v)=>i.jsx("span",{className:C.stream==="stderr"?"text-accent-warning":"",children:Nh(C.content)},v)):Nh(S)}),l==="error"&&c&&i.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:c})]})}),dc=N.memo(function({className:t=""}){return i.jsx("div",{className:`text-[10px] text-accent-warning ${t}`,children:"Output truncated"})});function SN(e,t){try{return{success:!0,parsed:JSON.parse(e)}}catch{return console.warn(`${t}: failed to parse result JSON`,e.slice(0,200)),{success:!1,error:i.jsx(Ze,{horizontal:!0,className:"max-h-[60vh]",children:i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:e})})}}}const p9=N.memo(function({result:t,action:n}){const r=SN(t,"DevServerView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?g9(a):x9(a)});function g9(e){if(!e.logs)return i.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"});const t=e.logs.split(`
|
|
297
|
+
`);return i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ze,{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] break-words",children:t.map((n,r)=>{const a=n.startsWith("[stderr] ");return i.jsx("div",{className:a?"text-accent-warning":"",children:a?n.slice(9):n},r)})}),e.hasMore&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",e.limit," of ",e.total," lines"]})]})}function x9(e){const t=String(e.state??""),n=String(e.url??""),r=e.error?String(e.error):void 0,a=t==="running"?"text-accent-success":t==="stopped"?"text-text-muted":t==="error"?"text-accent-error":"text-text-muted";return i.jsxs("div",{className:"space-y-2 text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"State:"}),i.jsx("span",{className:`font-medium ${a}`,children:t})]}),n&&n!=="undefined"&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"URL:"}),i.jsx("a",{href:n,className:"text-accent-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:n})]}),r&&i.jsx("div",{className:"text-accent-error bg-accent-error/10 p-2 rounded",children:r})]})}const y9=N.memo(function({result:t,action:n}){const r=SN(t,"BackgroundProcessView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?b9(a):n==="list"?v9(a):n==="status"?_9(a):n==="start"||n==="stop"?S9(a):i.jsxs("div",{className:"space-y-2 text-xs",children:[i.jsxs("div",{className:"text-accent-warning",children:["Unknown action: ",n]}),i.jsx(Ze,{horizontal:!0,className:"max-h-[60vh]",children:i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})]})});function b9(e){const t=e.lines,n=e.hasMore,r=e.totalLines;return!t||t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"}):i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ze,{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] break-words",children:t.map((a,l)=>i.jsx("div",{className:a.stream==="stderr"?"text-accent-warning":"",children:a.content},l))}),n&&r!=null&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",t.length," of ",r," lines"]})]})}function v9(e){const t=e.processes,n=e.currentCount,r=e.maxPerSession;return!t||t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic",children:"No background processes"}):i.jsxs("div",{className:"space-y-2",children:[t.map(a=>i.jsx(wN,{process:a},a.id)),n!=null&&r!=null&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:[n," of ",r," slots used"]})]})}function _9(e){const t=e.process,n=e.uptime;return t?i.jsxs("div",{className:"space-y-2",children:[i.jsx(wN,{process:t}),n!=null&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:["Uptime: ",w9(n)]})]}):i.jsx("div",{className:"text-xs text-text-muted italic",children:"Process not found"})}function S9(e){const t=e.processId,n=e.name,r=e.pid,a=e.status,l=a==="running"?"text-accent-success":"text-text-muted";return i.jsxs("div",{className:"space-y-2 text-xs",children:[n&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"Name:"}),i.jsx("span",{className:"font-medium",children:n})]}),t&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"ID:"}),i.jsx("span",{className:"font-mono",children:t})]}),r!=null&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"PID:"}),i.jsx("span",{className:"font-mono",children:r})]}),a&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"Status:"}),i.jsx("span",{className:`font-medium ${l}`,children:a})]})]})}function wN({process:e}){const t=e.status==="running"?"text-accent-success":(e.status==="exited","text-text-muted");return i.jsxs("div",{className:"border border-border rounded p-2 space-y-1 text-xs",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"font-medium",children:e.name}),i.jsx("span",{className:`${t}`,children:e.status})]}),e.pid!=null&&i.jsxs("div",{className:"text-text-muted",children:["PID: ",i.jsx("span",{className:"font-mono",children:e.pid})]}),e.command&&i.jsx("div",{className:"text-text-muted font-mono truncate",children:e.command})]})}function w9(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return r>0?`${r}h ${n%60}m`:n>0?`${n}m ${t%60}s`:`${t}s`}const C9=N.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return i.jsx(Ze,{horizontal:!0,className:"max-h-[60vh]",children:i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})}switch(n){case"list":return k9(r);case"switch":case"delete":return j9(r);default:return i.jsx(Ze,{horizontal:!0,className:"max-h-[60vh]",children:i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})}});function k9(e){const t=e.workspaces??[];return t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic",children:"No workspaces found"}):i.jsxs("div",{className:"space-y-1 text-xs",children:[i.jsx("div",{className:"text-text-muted mb-1",children:"Workspaces:"}),t.map(n=>i.jsxs("div",{className:"flex items-center gap-2 font-mono",children:[i.jsx("span",{className:n.active?"text-accent-success":"text-text-muted",children:n.active?"●":"○"}),i.jsx("span",{className:n.active?"text-text-primary font-medium":"text-text-secondary",children:n.name}),n.branch&&i.jsxs("span",{className:"text-text-muted",children:["· ",n.branch]}),n.active&&i.jsx("span",{className:"text-[10px] text-accent-primary",children:"(current)"})]},n.name))]})}function Rg({label:e,value:t,mono:n}){return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"text-text-muted",children:[e,":"]}),i.jsx("span",{className:n?"font-mono text-accent-primary":"text-text-primary",children:t})]})}function j9(e){return i.jsxs("div",{className:"space-y-2 text-xs",children:[e.message&&i.jsx("div",{className:"text-text-primary",children:e.message}),e.workspace&&i.jsx(Rg,{label:"Name",value:e.workspace,mono:!0}),e.path&&i.jsx(Rg,{label:"Path",value:e.path,mono:!0}),e.branch&&i.jsx(Rg,{label:"Branch",value:e.branch,mono:!0})]})}function E9(e){switch(e){case"sensitive_file":return{title:"Sensitive File Access",description:"Accessing files that may contain secrets"};case"both":return{title:"Sensitive File Access",description:"Accessing sensitive files outside project"};case"dangerous_command":return{title:"Dangerous Command",description:"Running potentially dangerous command"};case"git_no_verify":return{title:"Git --no-verify",description:"Bypassing git hooks/pre-commit checks"};case"outside_workdir":default:return{title:"Path Access Request",description:"Accessing paths outside project directory"}}}function N9({confirmation:e}){const t=Re(m=>m.confirmPath),n=Re(m=>m.currentSession),r=Re(m=>m.switchDangerLevel),{title:a,description:l}=E9(e.reason),u=e.reason==="sensitive_file"||e.reason==="both",c=u?"border-red-500/50":"border-amber-500/50",d=u?"bg-red-500/10":"bg-amber-500/10",h=e.reason==="git_no_verify",p=()=>{n!=null&&n.id&&r("dangerous"),t(e.callId,!0,!1)};return i.jsxs("div",{className:`border ${c} ${d} rounded p-3 my-2`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(ex,{}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:`text-sm font-medium ${u?"text-red-400":"text-amber-400"}`,children:a}),i.jsx("div",{className:"text-xs text-text-muted",children:l})]})]}),i.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[i.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),i.jsx(Ze,{className:"bg-bg-primary rounded p-2 mb-3 max-h-24",children:i.jsx("ul",{className:"space-y-0.5",children:e.paths.map((m,x)=>i.jsx("li",{className:`text-xs font-mono ${u?"text-red-300":"text-amber-300"} break-all`,children:m},x))})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{onClick:()=>t(e.callId,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border transition-colors",children:"Deny"}),i.jsx("button",{onClick:()=>t(e.callId,!0,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-accent-primary hover:bg-accent-primary/80 text-text-primary transition-colors",children:"Allow"}),i.jsx("button",{onClick:p,className:`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors ${h?"hidden":"bg-red-600 hover:bg-red-700 text-white"}`,title:"Enable dangerous mode and allow this request",children:"Allow Everything"})]})]})}function T9(e,t){if(e==="read_file"){const r=String(t.path??""),a=t.offset,l=t.limit,u=[];return a!==void 0&&a!==1&&u.push(`offset=${a}`),l!==void 0&&u.push(`limit=${l}`),u.length>0?`${r} [${u.join(", ")}]`:r}if(e==="write_file"||e==="edit_file")return String(t.path??"");if(e==="run_command"||e==="bash")return String(t.command??"");if(e==="return_value"){const r=String(t.content??"");return r.length>60?r.slice(0,60)+"...":r}if(e==="call_sub_agent")return String(t.subAgentType??"");if(e==="load_skill")return String(t.skillId??"");if(e==="web_fetch")return String(t.url??"");if(e==="web_search"){const r=String(t.query??"");return r.length>60?r.slice(0,57)+"...":r}if(e==="dev_server")return String(t.action??"");if(e==="background_process"){const r=String(t.action??""),a=t.name?String(t.name):"";return a?`${r}: ${a}`:r}if(e==="mcp_config")return String(t.action??"");const n=JSON.stringify(t);return n.length>50?n.slice(0,50)+"...":n}function tC(e,t,n){var a;const r=T9(e,t);if(e==="read_file"&&n){const l=n.format,u=n.pageCount;if(l==="pdf"&&u!=null)return`${r} (PDF, ${u}p)`;if(l==="image")return`${r} (image)`}if(e==="web_fetch"&&n){const l=n.contentType;if(l){const u=((a=l.split(";")[0])==null?void 0:a.trim())??"";if(u&&u!=="text/html")return`${r} (${u})`}}return r}function A9(e){return JSON.stringify(e,null,2)}const L9={ssh:"SSH",scp:"SCP",sftp:"SFTP",mosh:"MOSH"},D9=new Set(["-C","--close-from","-D","--chdir","-g","--group","-h","--host","-p","--prompt","-R","--chroot","-T","--command-timeout","-u","--user"]),R9=new Set(["-C","--chdir","-S","--split-string","-u","--unset"]);function O9(e){return e.split(/[\\/]/).pop()??e}function I9(e){const t=[];let n=null,r=!1;for(let a=0;a<e.length;a+=1){const l=e[a];if(r){r=!1;continue}if(l==="\\"&&n!=="'"){r=!0;continue}if(l==="'"||l==='"'){n=n===l?null:n===null?l:n;continue}if(n)continue;if(l==="#"&&(a===0||/\s|[;&|(){}]/.test(e[a-1])))break;if(l!=="<"||e[a-1]==="<"||e[a+1]!=="<"||e[a+2]==="<")continue;let u=a+2;const c=e[u]==="-";for(c&&(u+=1);/\s/.test(e[u]??"");)u+=1;let d="",h=null,p=!1,m=!0;for(;u<e.length;){const x=e[u];if(!h&&/\s|[;&|(){}<>]/.test(x))break;if(x==="'"||x==='"'){m=!1,h===x?(h=null,p=!1):h===null&&(h=x),u+=1;continue}if(!h&&x==="$"&&e[u+1]==="'"){m=!1,p=!0,h="'",u+=2;continue}if(x==="\\"&&u+1<e.length){if(m=!1,p){const y=e.slice(u).match(/^\\(?:x([0-9A-Fa-f]{1,2})|([0-7]{1,3})|([abefnrtv\\'"?]))/);if(y){y[1]?d+=String.fromCharCode(Number.parseInt(y[1],16)):y[2]?d+=String.fromCharCode(Number.parseInt(y[2],8)):d+={a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
298
|
+
`,r:"\r",t:" ",v:"\v"}[y[3]]??y[3],u+=y[0].length;continue}}(h!=='"'||["$","`",'"',"\\",`
|
|
299
|
+
`].includes(e[u+1]))&&(u+=1)}d+=e[u],u+=1}d&&t.push({delimiter:d,stripTabs:c,expandable:m}),a=u}return t}function M9(e){const t=e.split(`
|
|
300
|
+
`),n=[],r=[],a=[];for(const l of t){if(a.length>0){const u=a[0],c=u.stripTabs?l.replace(/^\t+/,""):l;c===u.delimiter?a.shift():u.expandable&&r.push(c);continue}n.push(l),a.push(...I9(l))}return{command:n.join(`
|
|
301
|
+
`),expandableBodies:r}}function nC(e,t=!0){const n=[];let r=null,a=!1,l=!1,u=!1;for(let c=0;c<e.length;c+=1){const d=e[c];if(l){(d===`
|
|
302
|
+
`||d==="\r")&&(l=!1);continue}if(a){a=!1;continue}if(d==="\\"&&r!=="'"){u=!0,a=!0;continue}if(d==="'"){u=!0,r=r==="'"?null:r===null?"'":r;continue}if(d==='"'){u=!0,r=r==='"'?null:r===null?'"':r;continue}if(r!=="'"){if(!r&&/\s|[;&|(){}]/.test(d)?u=!1:d!=="#"&&(u=!0),t&&d==="#"&&!u){l=!0;continue}if(d==="`"){const h=e.indexOf("`",c+1);h!==-1&&(n.push(e.slice(c+1,h)),c=h);continue}if(d==="$"&&e[c+1]==="("&&e[c+2]!=="("){let h=1,p=null,m=!1;for(let x=c+2;x<e.length;x+=1){const y=e[x];if(m){m=!1;continue}if(y==="\\"&&p!=="'"){m=!0;continue}if(y==="'"||y==='"'){p=p===y?null:p===null?y:p;continue}if(!p&&(y==="("&&(h+=1),y===")"&&(h-=1),h===0)){n.push(e.slice(c+2,x)),c=x;break}}}}}return n}function P9(e){const t=[];let n="",r=!1,a=null,l=!1,u=!1;const c=()=>{r&&t.push(n),n="",r=!1};for(let d=0;d<e.length;d+=1){const h=e[d];if(u){(h===`
|
|
303
|
+
`||h==="\r")&&(u=!1,t.at(-1)!==";"&&t.push(";"));continue}if(l){r=!0,n+=h,l=!1;continue}if(h==="\\"&&a!=="'"){l=!0;continue}if(a){h===a?a=null:n+=h;continue}if(h==="'"||h==='"'){r=!0,a=h;continue}if(h==="$"&&e.slice(d,d+3)==="$(("){let p=1;const m=d;for(let x=d+3;x<e.length-1;x+=1)if(e.slice(x,x+2)==="(("&&(p+=1),e.slice(x,x+2)==="))"&&(p-=1),p===0){r=!0,n+=e.slice(m,x+2),d=x+1;break}continue}if(h==="#"&&!r){u=!0;continue}if(/\s/.test(h)){c(),(h===`
|
|
304
|
+
`||h==="\r")&&t.push(";");continue}if(h===";"||h==="|"||h==="&"||h==="("||h===")"||h==="{"||h==="}"){c(),e[d+1]===h&&(d+=1),t.push(h);continue}r=!0,n+=h}return l&&(n+="\\"),c(),t}function hc(e,t,n){for(;t<e.length;){const r=e[t];if(r==="--")return t+1;if(!r.startsWith("-")||r==="-")return t;t+=1,!r.includes("=")&&n.has(r)&&(t+=1)}return t}function Qr(e,t=0){if(t>8)return null;let n=0;for(;n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;const r=O9(e[n]??"").toLowerCase();if(r==="env"){for(let u=n+1;u<e.length;u+=1){const c=e[u];if(c==="-S"||c==="--split-string"){const h=e[u+1];return h?Wo(h,t+1):null}const d=c.match(/^--split-string=(.*)$/s);if(d)return Wo(d[1],t+1)}for(n=hc(e,n+1,R9);n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;return Qr(e.slice(n),t+1)}if(r==="sudo")return n=hc(e,n+1,D9),Qr(e.slice(n),t+1);const a=r,l=L9[a];if(l)return l;if(a==="command"){if(e.slice(n+1).some(c=>c==="-v"||c==="-V"))return null;const u=hc(e,n+1,new Set);return Qr(e.slice(u),t+1)}if(a==="setsid"||a==="nohup"){const u=hc(e,n+1,new Set);return Qr(e.slice(u),t+1)}if(a==="timeout"){const u=hc(e,n+1,new Set(["-k","--kill-after","-s","--signal"]));return Qr(e.slice(u+1),t+1)}if(a==="bash"||a==="sh"||a==="zsh"||a==="fish")for(let u=n+1;u<e.length;u+=1){const c=e[u];if(c!=="--"){if(/^-[^-]*n/.test(c))return null;if(/^-[^-]*c/.test(c)){const d=e[u+1]==="--"?2:1,h=e[u+d];return h?Wo(h,t+1):null}if(!c.startsWith("-"))break}}return null}function Wo(e,t=0){if(t>8)return null;const{command:n,expandableBodies:r}=M9(e),a=[...nC(n),...r.flatMap(m=>nC(m,!1))];for(const m of a){const x=Wo(m,t+1);if(x)return x}const l=P9(n);let u=[];const c=new Set([";","|","&","(",")","{","}"]),d=new Set(["then","do","else","elif","if","while","until"]);let h=!1,p=!1;for(const m of l){if(m==="for"||m==="select"){const x=Qr(u,t);if(x)return x;u=[],h=!0;continue}if(m==="case"){const x=Qr(u,t);if(x)return x;u=[],p=!0;continue}if(h){m==="do"&&(h=!1);continue}if(p&&m===")"){u=[];continue}if(c.has(m)){const x=Qr(u,t);if(x)return x;u=[]}else if(d.has(m)){const x=Qr(u,t);if(x)return x;u=[]}else if(m==="fi"||m==="done"||m==="esac"){const x=Qr(u,t);if(x)return x;u=[],m==="esac"&&(p=!1)}else u.push(m)}return Qr(u,t)}function B9(e,t){return e!=="run_command"||typeof t.command!="string"?null:Wo(t.command)}const $9={pending:{icon:"●",color:"text-accent-warning",animate:!0},success:{icon:"✓",color:"text-accent-success",animate:!1},error:{icon:"✗",color:"text-accent-error",animate:!1},interrupted:{icon:"✗",color:"text-text-tool-error",animate:!1}},z9=N.memo(function({tool:t,args:n,status:r,variant:a="compact",forceCompact:l,result:u,error:c,durationMs:d,diagnostics:h,editContext:p,startedAt:m,streamingOutput:x,metadata:y,truncated:S,callId:C}){var R;const v=!l,[w,_]=N.useState(v),b=$9[r],k=B9(t,n),E=Vt(M=>M.settings[Ae.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",T=t==="edit_file"?(R=p==null?void 0:p.regions[0])==null?void 0:R.startLine:t==="read_file"?(()=>{const M=u==null?void 0:u.split(`
|
|
305
|
+
`)[0],W=M==null?void 0:M.match(/^(\d+): /);return W?parseInt(W[1],10):void 0})():void 0,D=Re(M=>M.pendingPathConfirmations),L=C?D.find(M=>M.callId===C||M.callId.startsWith(C+"-"))??null:null;return t==="step_done"?i.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-secondary border border-border rounded px-2 py-1.5 my-1",children:[i.jsx("span",{className:`${b.color} ${b.animate?"animate-pulse":""}`,children:b.icon}),i.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t})]}):a==="compact"?i.jsxs("div",{className:`flex items-center gap-1.5 text-xs rounded px-2 py-1.5 border ${k?"border-text-thinking/60 bg-text-thinking/10":"border-transparent bg-secondary"}`,children:[i.jsx(_N,{tool:t}),i.jsx("span",{className:"text-accent-primary font-medium",children:t}),i.jsx("span",{className:"text-text-muted truncate flex-1",children:tC(t,n,y)}),i.jsx("span",{className:`${b.color} ${b.animate?"animate-pulse":""}`,children:r==="pending"?"...":"done"})]}):i.jsxs("div",{className:`border rounded overflow-hidden my-1 min-w-0 ${k?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:[i.jsxs("button",{className:`w-full flex items-center gap-1.5 p-2 text-left ${k?"bg-text-thinking/10 hover:bg-text-thinking/15":"bg-secondary hover:bg-secondary/80"}`,onClick:()=>_(!w),children:[i.jsx("span",{className:`${b.color} ${b.animate?"animate-pulse":""}`,children:b.icon}),i.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),i.jsx("span",{className:"text-text-muted text-xs flex-1 truncate",children:tC(t,n,y)}),i.jsx("span",{className:"text-text-muted text-xs",children:w?"▼":"▶"})]}),w&&i.jsxs("div",{className:`p-2 border-t space-y-2 min-w-0 ${k?"border-text-thinking/40 bg-text-thinking/5":"border-border bg-primary"}`,children:[t==="run_command"&&i.jsx(m9,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:m,streamingOutput:x,status:r,result:u,error:c,durationMs:d}),t==="edit_file"&&r==="success"&&i.jsxs(i.Fragment,{children:[p&&p.regions.length>0?i.jsx(n9,{regions:p.regions,filePath:String(n.path??"")}):i.jsx(e9,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),h&&h.length>0&&i.jsx(eC,{diagnostics:h})]}),t==="write_file"&&r==="success"&&i.jsxs(i.Fragment,{children:[i.jsx(t9,{content:String(n.content??""),filePath:String(n.path??"")}),h&&h.length>0&&i.jsx(eC,{diagnostics:h})]}),t==="read_file"&&r==="success"&&i.jsx(a9,{result:u,metadata:y,filePath:String(n.path??"")}),t==="return_value"&&(()=>{const M=(x==null?void 0:x.map(z=>z.content).join(""))??"",W=r==="pending"&&M?M:String(n.content??"");return i.jsxs("div",{children:[i.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:i.jsx(Jn,{content:W})})]})})(),t==="call_sub_agent"&&i.jsxs("div",{children:[i.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:[String(n.subAgentType??"Sub-Agent")," Prompt"]}),i.jsx(Ze,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:i.jsx(Jn,{content:String(n.prompt??"")})})]}),t==="web_search"&&r==="success"&&i.jsxs("div",{children:[i.jsx(Ze,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:i.jsx(Jn,{content:u??""})}),S&&i.jsx(dc,{className:"mt-1"})]}),t==="load_skill"&&r==="success"&&i.jsxs("div",{children:[i.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:["Skill: ",String(n.skillId??"")]}),i.jsx(Ze,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:i.jsx(Jn,{content:u??""})}),S&&i.jsx(dc,{className:"mt-1"})]}),t==="web_fetch"&&r==="success"&&i.jsxs("div",{className:"space-y-2",children:[!!(y!=null&&y.url)&&i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[i.jsx("span",{children:"Source:"}),i.jsx("a",{href:String(y.url),className:"text-accent-primary hover:underline truncate",target:"_blank",rel:"noopener noreferrer",children:String(y.url)}),!!(y!=null&&y.contentType)&&i.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["(",String(y.contentType),")"]}),(y==null?void 0:y.pageCount)!=null&&i.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["· ",String(y.pageCount)," pages"]})]}),i.jsx(Ze,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:i.jsx(Jn,{content:u??""})}),S&&i.jsx(dc,{})]}),t==="dev_server"&&r==="success"&&u&&i.jsx(p9,{result:u,action:String(n.action??"")}),t==="workspace"&&r==="success"&&u&&i.jsx(C9,{result:u,action:String(n.action??"")}),t==="background_process"&&r==="success"&&u&&i.jsx(y9,{result:u,action:String(n.action??"")}),t==="mcp_config"&&r==="success"&&i.jsxs("div",{children:[i.jsx(Ze,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:i.jsx(Jn,{content:u??""})}),S&&i.jsx(dc,{className:"mt-1"})]}),t==="step_done"&&null,t!=="edit_file"&&t!=="write_file"&&t!=="run_command"&&t!=="read_file"&&t!=="return_value"&&t!=="call_sub_agent"&&t!=="web_search"&&t!=="load_skill"&&t!=="web_fetch"&&t!=="dev_server"&&t!=="workspace"&&t!=="background_process"&&t!=="mcp_config"&&t!=="step_done"&&i.jsxs(i.Fragment,{children:[Object.keys(n).length>0&&i.jsxs("div",{children:[i.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),i.jsx(Ze,{horizontal:!0,children:i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:A9(n)})})]}),r==="success"&&u!==void 0&&i.jsxs("div",{children:[i.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",d!==void 0&&` (${d}ms)`,":"]}),i.jsx(Ze,{horizontal:!0,className:"max-h-[60vh]",children:i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:u||"No output"})}),S&&i.jsx(dc,{className:"mt-1"})]})]}),(k||r==="success"&&d!==void 0&&(t==="run_command"||t==="edit_file"||t==="write_file"||t==="read_file"))&&i.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-2",children:[r==="success"&&d!==void 0&&(t==="run_command"||t==="edit_file"||t==="write_file"||t==="read_file")&&i.jsxs("span",{children:["Completed in ",(d/1e3).toFixed(2),"s"]}),i.jsx("span",{className:"flex-1"}),E&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String((y==null?void 0:y.path)??n.path??"")&&i.jsx("a",{href:hN(String((y==null?void 0:y.path)??n.path),T),className:"text-accent-primary hover:underline",children:"Open in VSCode"}),k&&i.jsxs("span",{className:"shrink-0 rounded border border-text-thinking/50 bg-text-thinking/15 px-1.5 py-0.5 font-semibold tracking-wide text-text-thinking",children:["REMOTE · ",k]})]}),r==="error"&&c&&t!=="run_command"&&i.jsxs("div",{children:[i.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error break-words",children:c})]}),L&&i.jsx(N9,{confirmation:L})]})]})}),H9={read_file:"Reading file",write_file:"Writing file",edit_file:"Editing file",run_command:"Running command",glob:"Searching files",grep:"Searching content",ask_user:"Asking user",criterion:"Managing criterion",session_metadata:"Managing",todo_write:"Updating tasks"};function F9(e,t){const n=H9[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const a=JSON.parse(t).key;if(a){const l=m7(a);return`${n} ${l}`}}catch{}return n}function U9(e){try{const t=e.replace(/\s*\}\s*$/,""),n=JSON.parse(t);if(typeof n.command=="string")return n.command}catch{const t=e.match(/"command"\s*:\s*"([^"]*)/);if(t&&t[1])return t[1]}return null}const V9=N.memo(function({name:t,arguments:n}){let a=F9(t,n)+"...",l=null;if(t==="run_command"&&n){const u=U9(n);u&&(a=u,l=Wo(u))}return i.jsx("div",{className:`border rounded overflow-hidden my-1 min-w-0 animate-pulse ${l?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:i.jsxs("div",{className:`flex items-center gap-1.5 p-2 ${l?"bg-text-thinking/10":"bg-bg-tertiary"}`,children:[i.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),i.jsx(_N,{tool:t}),i.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),t==="run_command"&&n?i.jsx("code",{className:"text-text-muted text-xs flex-1 truncate",children:a}):i.jsx("span",{className:"text-text-muted text-xs flex-1",children:a})]})})}),W9={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},G9=N.memo(function({todos:t}){return Array.isArray(t)?t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic my-1",children:"No tasks"}):i.jsxs("div",{className:"my-1 rounded border border-border bg-bg-tertiary overflow-hidden",children:[i.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-bg-secondary",children:i.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Tasks"})}),i.jsx("div",{children:t.map((n,r)=>{const a=W9[n.status];return i.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${r>0?"border-t border-border":""}`,children:[i.jsx("span",{className:`${(a==null?void 0:a.color)??"text-text-muted"} ${a!=null&&a.animate?"animate-pulse":""} text-sm leading-tight`,children:(a==null?void 0:a.icon)??"○"}),i.jsx("span",{className:`text-sm leading-tight ${n.status==="completed"?"text-text-muted":"text-text-primary"}`,children:n.content})]},r)})})]}):i.jsx("div",{className:"text-xs text-accent-warning italic my-1",children:"⚠️ Invalid todos data"})});function q9({toolCall:e}){var k;const t=Re(E=>E.pendingQuestions),n=Re(E=>E.answerQuestion),[r,a]=N.useState(""),l=N.useRef(null),u=N.useRef(null),c=t.find(E=>E.callId===e.id),d=e.arguments.question??(c==null?void 0:c.question)??"",h=e.arguments.type??(c==null?void 0:c.type)??"text",p=e.arguments.options??(c==null?void 0:c.options)??void 0,m=e.result!==void 0,x=c!==void 0&&!m,y=((k=e.result)==null?void 0:k.output)??"",S=y==="[user skipped]";N.useEffect(()=>{x&&l.current&&l.current.focus()},[x]),N.useEffect(()=>{x&&u.current&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[x]);const C=N.useCallback(()=>{c&&n(c.callId,r)},[c,r,n]),v=N.useCallback(()=>{c&&n(c.callId,"",!0)},[c,n]),w=N.useCallback(E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),C()),E.key==="Escape"&&!E.shiftKey&&(E.preventDefault(),v())},[C,v]),_=N.useCallback(E=>{c&&n(c.callId,E)},[c,n]),b="px-3 py-1.5 text-xs font-medium rounded transition-colors";return i.jsxs("div",{ref:u,className:"my-1",children:[i.jsx("div",{className:"text-sm text-text-primary",children:d}),x&&i.jsx("div",{className:"mt-2 border border-border rounded overflow-hidden",children:i.jsx("div",{className:"p-3 bg-primary space-y-2",children:h==="confirm"?i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{onClick:()=>_("yes"),className:`${b} flex-1 bg-accent-success/20 hover:bg-accent-success/30 text-accent-success border border-accent-success/30`,children:"Yes"}),i.jsx("button",{onClick:()=>_("no"),className:`${b} flex-1 bg-accent-error/20 hover:bg-accent-error/30 text-accent-error border border-accent-error/30`,children:"No"}),i.jsx("button",{onClick:v,className:`${b} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]}):h==="choice"&&Array.isArray(p)&&p.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-col gap-1.5",children:p.map(E=>i.jsx("button",{onClick:()=>_(E),className:`${b} text-left w-full bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary border border-border hover:border-accent-primary/50`,children:E},E))}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("textarea",{ref:l,value:r,onChange:E=>a(E.target.value),onKeyDown:w,placeholder:"Or type your own answer... (Enter to submit)",className:"flex-1 min-h-[36px] max-h-[80px] px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",rows:1}),i.jsx("button",{onClick:C,disabled:!r.trim(),className:`${b} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send"}),i.jsx("button",{onClick:v,className:`${b} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("textarea",{ref:l,value:r,onChange:E=>a(E.target.value),onKeyDown:w,placeholder:"Type your answer here... (Enter to submit, Shift+Enter for new line)",className:"w-full min-h-[80px] px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",autoFocus:!0}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{onClick:v,className:`${b} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"}),i.jsx("button",{onClick:C,disabled:!r.trim(),className:`${b} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send Answer"})]})]})})}),m&&i.jsx("div",{className:"mt-1 flex items-center gap-2",children:i.jsx("span",{className:`text-xs ${S?"text-amber-400":"text-accent-success"}`,children:S?"Skipped":`Answered: ${y}`})})]})}const rC={add:{icon:"○",color:"text-text-muted"},update:{icon:"○",color:"text-text-muted"},remove:{icon:"○",color:"text-text-muted"},complete:{icon:"◉",color:"text-purple-400"},pass:{icon:"✓",color:"text-accent-success"},fail:{icon:"✗",color:"text-accent-error"},get:{icon:"○",color:"text-text-muted"},list:{icon:"○",color:"text-text-muted"},schema:{icon:"○",color:"text-text-muted"}},K9=N.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const r=new Map((n==null?void 0:n.map(c=>[c.id,c]))??[]),a=t.find(c=>{var d,h;return c.arguments.action==="get"&&((d=c.result)==null?void 0:d.success)&&((h=c.result)==null?void 0:h.output)}),l=t.some(c=>c.name==="session_metadata"),u=(()=>{if(!l)return"Acceptance Criteria";const c=new Set(t.map(d=>d.arguments.key).filter(Boolean));if(c.size===1){const d=c.values().next().value;return d?Vo(d):"Session Data"}return"Session Data"})();return i.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[i.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-secondary",children:i.jsx("span",{className:"text-xs font-medium text-text-muted",children:u})}),i.jsx("div",{className:"bg-primary",children:a?(()=>{const c=a.result.output;if(c==="No criteria defined yet.")return i.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5",children:[i.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),i.jsx("div",{className:"flex-1 min-w-0 text-text-muted text-sm",children:"No criteria defined yet."})]});try{return JSON.parse(c).map((h,p)=>i.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${p>0?"border-t border-border":""}`,children:[i.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),i.jsx("div",{className:"flex-1 min-w-0",children:i.jsx(Jn,{content:`[${h.id}] ${h.description}`})})]},h.id??p))}catch{return t.map((d,h)=>i.jsx(sC,{tc:d,index:h,criteriaMap:r},d.id??h))}})():t.map((c,d)=>i.jsx(sC,{tc:c,index:d,criteriaMap:r},c.id??d))})]})});function sC({tc:e,index:t,criteriaMap:n}){const r=e.arguments.action,a=e.arguments,l=e.name==="session_metadata",u=r==="remove",c=a.id,d=a.description,h=c?n.get(c):void 0,p=d??(h==null?void 0:h.description)??(u&&c?`[${c}]`:"Criterion updated"),m=a.reason,x=r==="fail";return i.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${t>0?"border-t border-border":""}`,children:[l?i.jsx(ll,{status:a.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const y=r&&rC[r]?rC[r]:{icon:"○",color:"text-text-muted"};return i.jsx("span",{className:`${y.color} text-sm leading-tight flex-shrink-0`,children:y.icon})})(),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:u?"line-through text-text-muted":"",children:i.jsx(Jn,{content:p})}),m&&i.jsxs("div",{className:`mt-1 text-sm ${x?"text-accent-error":"text-text-muted"}`,children:[i.jsx("span",{className:"text-text-muted",children:"└ "}),'"',m,'"']})]})]})}function Y9(e){return e==="criterion"||e==="session_metadata"}async function CN(e){if(navigator.clipboard){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function X9({items:e,position:t,onClose:n}){const r=N.useRef(null),[a,l]=N.useState(-1);if(N.useEffect(()=>{t&&l(-1)},[t]),N.useEffect(()=>{var p;if(!t)return;function d(m){r.current&&!r.current.contains(m.target)&&n()}function h(m){var x;switch(m.key){case"Escape":m.preventDefault(),n();break;case"ArrowDown":m.preventDefault(),l(y=>y<e.length-1?y+1:0);break;case"ArrowUp":m.preventDefault(),l(y=>y>0?y-1:e.length-1);break;case"Enter":m.preventDefault(),(x=e[a])==null||x.onClick(),n();break}}return document.addEventListener("mousedown",d),window.addEventListener("keydown",h,!0),window.addEventListener("blur",n),(p=r.current)==null||p.focus(),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",h,!0),window.removeEventListener("blur",n)}},[t,e,a,n]),!t)return null;let u=Math.min(t.x,window.innerWidth-190),c=Math.min(t.y,window.innerHeight-100);return u=Math.max(8,u),c=Math.max(8,c),si.createPortal(i.jsx("div",{ref:r,tabIndex:-1,className:"fixed bg-bg-secondary border border-border rounded shadow-lg z-50 min-w-[160px] outline-none",style:{left:u,top:c},children:i.jsx(Ze,{className:"max-h-[60vh]",onMouseLeave:()=>l(-1),children:e.map((d,h)=>i.jsxs("button",{onClick:()=>{d.onClick(),n()},onMouseEnter:()=>l(h),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${h<e.length-1?"border-b border-border":""} ${d.danger?"text-accent-error hover:bg-accent-error/10":h===a?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"}`,children:[d.icon&&i.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:d.icon}),d.label]},h))})}),document.body)}function kN(){const[e,t]=N.useState(null);return{onContextMenu:N.useCallback((a,l)=>{var u;l&&((u=window.getSelection())!=null&&u.toString()||(a.preventDefault(),t({x:a.clientX,y:a.clientY})))},[]),contextMenu:a=>i.jsx(X9,{position:e,onClose:()=>t(null),items:a})}}function Q9(e){const t=[];let n=[];const r=()=>{n.length>0&&(t.push({type:"criteria_group",toolCalls:n}),n=[])};for(const a of e)a.type==="tool_call"&&Y9(a.toolCall.name)?n.push(a.toolCall):(r(),t.push(a));return r(),t}function J9(e,t){if(e.segments&&e.segments.length>0)return Z9(e.segments,e.toolCalls??[],e.preparingToolCalls??[],e.stats,t);const n=[];if(e.thinkingContent&&n.push({type:"thinking",content:e.thinkingContent}),e.content&&n.push({type:"text",content:e.content}),e.toolCalls)for(const r of e.toolCalls)n.push({type:"tool_call",toolCall:r});if(e.preparingToolCalls)for(const r of e.preparingToolCalls)n.push({type:"preparing_tool_call",preparing:r});return t&&e.stats&&n.push({type:"stats",stats:e.stats}),n}function Z9(e,t,n,r,a){const l=[],u=new Map(t.map(c=>[c.id,c]));for(const c of e)switch(c.type){case"text":l.push({type:"text",content:c.content});break;case"thinking":c.content&&c.content.trim().length>0&&l.push({type:"thinking",content:c.content});break;case"tool_call":{const d=u.get(c.toolCallId);d&&l.push({type:"tool_call",toolCall:d});break}}for(const c of n)l.push({type:"preparing_tool_call",preparing:c});return a&&r&&l.push({type:"stats",stats:r}),l}const tb=N.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:a=!0,sessionId:l}){const u=Re(T=>{var D,L;return(L=(D=T.currentSession)==null?void 0:D.metadataEntries)==null?void 0:L.criteria}),c=gt(T=>T.defaults),d=gt(T=>T.userItems),h=[...c,...d],p=J9(t,n),m=r?p:p.filter(T=>T.type!=="thinking"),x=Q9(m),[y,S]=N.useState(!1),[C,v]=N.useState(null),[,w]=zn(),{onContextMenu:_,contextMenu:b}=kN();if(x.length===0)return null;const k=()=>{CN(t.content)},E=async()=>{if(!l||y)return;S(!0),v(null);const T=await kk(l,t.id);S(!1),T!=null&&T.session?w(`/p/${T.session.projectId}/s/${T.session.id}`):v("Failed to fork session")};return i.jsxs("div",{className:"feed-item",onContextMenu:T=>_(T,!!l),children:[i.jsxs("div",{className:"min-w-0",children:[C&&i.jsx("p",{className:"text-xs text-accent-error mb-1 ml-0.5",children:C}),x.map((T,D)=>{var L;switch(T.type){case"thinking":return i.jsx(h9,{content:T.content},D);case"text":return i.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:i.jsx(Jn,{content:T.content})},D);case"preparing_tool_call":return i.jsx(V9,{name:T.preparing.name,arguments:T.preparing.arguments},`preparing-${T.preparing.index}`);case"tool_call":{const R=T.toolCall,M=R.result;if(R.name==="ask_user")return i.jsx(q9,{toolCall:R},D);if(R.name==="todo_write"){const H=R.arguments.todos,I=Array.isArray(H)?H:[];return i.jsx(G9,{todos:I},D)}const W=(L=M==null?void 0:M.output)==null?void 0:L.includes("[interrupted by user]"),z=M?W?"interrupted":M.success?"success":"error":"pending";return i.jsx(z9,{tool:R.name,args:R.arguments,status:z,variant:"expandable",forceCompact:!a,result:M==null?void 0:M.output,error:M==null?void 0:M.error,durationMs:M==null?void 0:M.durationMs,diagnostics:M==null?void 0:M.diagnostics,editContext:M==null?void 0:M.editContext,startedAt:R.startedAt,streamingOutput:R.streamingOutput,metadata:M==null?void 0:M.metadata,truncated:(M==null?void 0:M.truncated)??!1,callId:R.id},D)}case"criteria_group":return i.jsx(K9,{toolCalls:T.toolCalls,criteria:u},D);case"stats":{const R=T.stats;if(!R||"error"in R)return null;const M=R.model.split("/").pop()??R.model,W=Yo(h,R.mode),z=h.find(V=>V.id===R.mode),H=(z==null?void 0:z.name)??R.mode,I=V=>V>=1e3?`${(V/1e3).toFixed(1)}k`:V.toString(),U=V=>V>=1e3?`${(V/1e3).toFixed(1)}k`:V.toFixed(1);return i.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted mt-3",children:[i.jsx("span",{className:"flex-1 h-px bg-border"}),i.jsx("span",{className:"text-text-secondary",children:M}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsx("span",{style:{color:W},children:H}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsx("span",{children:_s(R.totalTime)}),R.toolTime>0&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsxs("span",{children:[_s(R.toolTime)," tools"]})]}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsxs("span",{children:[I(R.prefillTokens)," @ ",U(R.prefillSpeed)," pp"]}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsxs("span",{children:[I(R.generationTokens)," @ ",U(R.generationSpeed)," tg"]}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsx("button",{type:"button",className:"text-text-muted hover:text-text-secondary transition-colors",title:"View detailed stats",onClick:()=>{const V=new CustomEvent("open-turn-stats",{detail:{stats:R}});window.dispatchEvent(V)},children:i.jsx(iy,{className:"w-3 h-3"})}),i.jsx("span",{className:"flex-1 h-px bg-border"})]},D)}}}),t.partial&&i.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[i.jsx(ex,{}),i.jsx("span",{children:"Aborted"})]}),t.completeReason==="truncated"&&i.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-text-truncated mt-1",children:[i.jsx(ex,{}),i.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]}),b([{label:"Copy",icon:i.jsx(Lc,{className:"w-4 h-4"}),onClick:()=>k()},{label:"Fork session from here",icon:i.jsx(Aa,{className:"w-4 h-4"}),onClick:()=>void E()}])]})});function Ah(e,t){const n=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16);return`rgba(${n},${r},${a},${t})`}function eF(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const tF=N.memo(function({data:t}){var u;const n=kt(c=>c.defaults),r=kt(c=>c.userItems),l=((u=[...n,...r].find(c=>c.id===t.workflowId))==null?void 0:u.color)??t.workflowColor??"#8b949e";return i.jsxs("div",{"data-testid":"task-completed-card",className:"feed-item rounded p-3 border",style:{borderColor:Ah(l,.3),backgroundColor:Ah(l,.08)},children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(VR,{color:l}),i.jsx("span",{className:"text-sm font-medium",style:{color:l},children:t.workflowName??"Task Completed"})]}),i.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-2",children:[i.jsx(fc,{label:"Iterations",value:String(t.iterations)}),i.jsx(fc,{label:"Total time",value:_s(t.totalTimeSeconds)}),i.jsx(fc,{label:"Tool calls",value:String(t.totalToolCalls)}),i.jsx(fc,{label:"Tokens",value:eF(t.totalTokensGenerated)}),i.jsx(fc,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function fc({label:e,value:t}){return i.jsxs("div",{className:"bg-bg-primary/50 rounded px-2 py-1",children:[i.jsx("div",{className:"text-sm text-text-muted",children:e}),i.jsx("div",{className:"text-sm text-text-primary font-medium",children:t})]})}const nF=N.memo(function({data:t}){var u;const n=kt(c=>c.defaults),r=kt(c=>c.userItems),l=((u=[...n,...r].find(c=>c.id===t.workflowId))==null?void 0:u.color)??t.workflowColor??"#6b7280";return i.jsxs("div",{className:"feed-item flex items-center gap-2 px-3 py-2 rounded border",style:{borderColor:Ah(l,.3),backgroundColor:Ah(l,.08)},children:[i.jsx(zk,{className:"w-3 h-3 shrink-0",color:l}),i.jsx("span",{className:"text-sm font-medium",style:{color:l},children:t.workflowName}),i.jsx("span",{className:"text-text-muted text-sm",children:"started"})]})}),rF=["text/"],sF=["application/json","application/xml","application/yaml","application/x-yaml","application/javascript","application/xhtml+xml","application/x-sh","image/svg+xml"];function Zd(e){return e.startsWith("image/")}function jN(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function nb(e){return sF.includes(e)||rF.some(t=>e.startsWith(t))}function $o(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function EN(e){const t=e.lastIndexOf(".");return t<=0||t>=e.length-1?"FILE":e.slice(t+1).toUpperCase()}const iF={"text/plain":"txt","text/csv":"csv","text/html":"html","text/markdown":"md","text/javascript":"js","text/xml":"xml","text/x-yaml":"yaml","text/x-sh":"sh","text/tab-separated-values":"tsv","text/x-python":"py","text/x-java-source":"java","text/x-json":"json","text/x-typescript":"ts","text/css":"css","application/json":"json","application/xml":"xml","application/yaml":"yaml","application/x-yaml":"yaml","application/javascript":"js","application/xhtml+xml":"xhtml","application/x-sh":"sh","application/pdf":"pdf","image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/bmp":"bmp","image/svg+xml":"svg"};function aF(e){var t;return iF[e]||((t=e.split("/")[1])==null?void 0:t.split("+")[0])||"file"}function oF(e){return Zd(e)||nb(e)||e==="application/pdf"}function lF({attachments:e,messageId:t}){const[n,r]=N.useState(null),a=Re(p=>p.visionFallbackByMessage),l=Re(p=>p.messages),u=N.useMemo(()=>{const p=l.findIndex(m=>m.id===t);if(p===-1)return null;for(let m=p+1;m<l.length;m++){const x=l[m];if(x&&x.role==="assistant")return x.id}return null},[l,t]),c=p=>{r(p)},d=()=>{r(null)},h=p=>{const m=`${t}-${p}`;if(a[m])return a[m];if(u){const x=`${u}-${p}`;return a[x]}return null};return e.length===0?null:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(p=>{const m=h(p.id);return jN(p.mimeType)?i.jsxs("div",{className:"relative inline-block",children:[i.jsxs("button",{onClick:()=>c(p.data),className:"group relative inline-block",title:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,disabled:(m==null?void 0:m.type)==="start",children:[i.jsx("img",{src:p.data,alt:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(m==null?void 0:m.type)==="start"&&i.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:i.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(m==null?void 0:m.type)==="done"&&m.description&&i.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[m.description.slice(0,200),m.description.length>200?"...":""]})]},p.id):i.jsxs("div",{className:"inline-flex items-start gap-3 p-3 bg-bg-tertiary rounded-lg border border-border max-w-[300px]",children:[i.jsx("div",{className:"w-10 h-10 flex items-center justify-center rounded-md bg-bg-secondary text-sm font-bold text-text-muted shrink-0",children:EN(p.filename)}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-xs text-text-primary truncate font-medium",title:p.filename,children:p.filename}),i.jsx("div",{className:"text-[10px] text-text-muted",children:$o(p.size)}),nb(p.mimeType)&&p.data&&i.jsxs("div",{className:"mt-1.5 text-[10px] text-text-muted leading-relaxed line-clamp-3 font-mono break-all",children:[p.data.slice(0,200),p.data.length>200?"...":""]})]})]},p.id)})}),n&&i.jsx(bN,{src:n,alt:"Attached image",isOpen:!0,onClose:d})]})}function cF({message:e}){const[t,n]=N.useState(!1);if(e.messageKind!=="auto-prompt")return null;const r=e.metadata,a=(r==null?void 0:r.color)??"#6b7280",l=(r==null?void 0:r.type)??"agent",u=l==="workspace"?"Workspace":(r==null?void 0:r.name)??"Agent",d={agent:(r==null?void 0:r.kind)==="reminder"?"reminder":"definition injected",workflow:"instructions",compaction:"prompt injected",subagent:"instructions",workspace:`${(r==null?void 0:r.workspaceName)??""} · ${(r==null?void 0:r.branchName)??""}`,branch:`🌿 ${(r==null?void 0:r.branchName)??""}`}[l]??"injected",h=l==="workflow"||l==="subagent";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[i.jsx("span",{className:"flex-1 h-px bg-border"}),i.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h?"":"cursor-pointer"}`,style:{backgroundColor:a},onClick:()=>!h&&n(!0)}),i.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:a},onClick:()=>!h&&n(!0),children:u}),i.jsx("span",{children:"·"}),i.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",onClick:()=>!h&&n(!0),children:d}),i.jsx("span",{className:"flex-1 h-px bg-border"})]}),h&&i.jsx("div",{className:"flex justify-center feed-item mb-4",children:i.jsx(Ze,{horizontal:!0,className:"max-w-[75%] rounded p-3 bg-bg-tertiary/50 text-text-secondary text-sm",style:{borderLeft:`3px solid ${a}`},children:i.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:e.content})})}),i.jsx(Tt,{isOpen:t,onClose:()=>n(!1),title:`${u} Prompt`,size:"lg",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:a}}),i.jsx("span",{className:"text-sm text-text-primary font-medium",children:u}),i.jsxs("span",{className:"text-xs text-text-muted",children:["(",l,")"]})]}),i.jsx("div",{className:"h-full min-h-96",children:i.jsx(Ze,{horizontal:!0,className:"h-full min-h-96",children:i.jsx("pre",{className:"text-sm text-text-secondary whitespace-pre-wrap break-words bg-bg-tertiary rounded p-4 h-full min-h-96 font-mono",children:e.content})})})]})})]})}function uF({message:e,messageId:t,sessionId:n}){const r=e.messageKind==="auto-prompt",a=e.messageKind==="command",l=e.isSystemGenerated,u=Re(F=>F.loadSession),[,c]=zn(),[d,h]=N.useState(!1),[p,m]=N.useState(!1),[x,y]=N.useState(!1),[S,C]=N.useState(e.content),[v,w]=N.useState(!1),[_,b]=N.useState(!1),[k,E]=N.useState(null),[T,D]=N.useState(null),L=N.useRef(null),{onContextMenu:R,contextMenu:M}=kN(),W=N.useCallback(()=>{const F=L.current;F&&(F.style.height="auto",F.style.height=`${F.scrollHeight}px`)},[]),z=async()=>{try{await CN(e.content),m(!0),window.setTimeout(()=>m(!1),1500)}catch{}},H=async()=>{if(!n||!t||_)return;b(!0),E(null);const F=await kk(n,t);if(b(!1),F!=null&&F.session){const O=F.session.projectId;c(`/p/${O}/s/${F.session.id}`)}else E("Failed to fork session")},I=async()=>{if(!n||!t||v)return;w(!0),D(null);const F=await MS(n,t);w(!1),F?u(n):D("Failed to replay")},U=async()=>{if(!n||!t||!S.trim()||v)return;w(!0),D(null);const F=await MS(n,t,S);w(!1),F?(u(n),y(!1)):D("Failed to send")},V=()=>{C(e.content),y(!1),D(null)},ee=`flex items-center gap-0.5 self-end transition-[visibility,opacity] focus-within:visible focus-within:opacity-100 ${d&&!x&&!v?"visible opacity-100":"invisible opacity-0"}`;return i.jsxs("div",{className:"flex justify-end items-start gap-1.5 feed-item",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onContextMenu:F=>R(F,!!n&&!!t),children:[!l&&i.jsxs("div",{className:ee,children:[i.jsx("button",{onClick:()=>{z()},title:"Copy",disabled:v,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:p?i.jsx(is,{className:"w-3.5 h-3.5 text-accent-success"}):i.jsx(Lc,{className:"w-3.5 h-3.5"})}),n&&t&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>{D(null),C(e.content),y(!0)},title:"Edit & resend",disabled:v,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:i.jsx(Mk,{className:"w-3.5 h-3.5"})}),i.jsx("button",{onClick:()=>{I()},title:"Replay",disabled:v,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:i.jsx(Wh,{className:"w-3.5 h-3.5"})})]})]}),i.jsxs("div",{className:`max-w-[75%] ${x?"w-full":""} rounded p-2 ${l?"bg-bg-system border border-border-system":"bg-accent-primary/15 text-text-primary"}`,children:[l&&i.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:a?"Command":r?"Auto":"System"}),x?i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("textarea",{ref:F=>{L.current=F,F&&(F.style.height="auto",F.style.height=`${F.scrollHeight}px`)},className:"w-full bg-bg-primary border border-border rounded p-1.5 text-sm text-text-primary resize-none focus:outline-none focus:border-accent-primary min-h-[60px] overflow-hidden disabled:opacity-50",value:S,onChange:F=>{C(F.target.value),W()},onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),U()),F.key==="Escape"&&V()},disabled:v,autoFocus:!0}),T&&i.jsx("p",{className:"text-xs text-accent-error",children:T}),i.jsxs("div",{className:"flex justify-end gap-1",children:[i.jsx("button",{onClick:V,disabled:v,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",title:"Cancel",children:i.jsx(ri,{className:"w-3.5 h-3.5"})}),i.jsx("button",{onClick:()=>{U()},disabled:v||!S.trim(),className:"p-1 rounded hover:bg-bg-tertiary text-accent-primary hover:text-accent-primary disabled:opacity-50",title:"Confirm (Ctrl+Enter)",children:i.jsx(is,{className:"w-3.5 h-3.5"})})]})]}):i.jsxs(i.Fragment,{children:[(T||k)&&i.jsx("p",{className:"text-xs text-accent-error mb-1",children:T??k}),i.jsx("div",{className:`whitespace-pre-wrap break-words text-sm ${l?"text-text-system":""}`,children:e.content}),e.attachments&&e.attachments.length>0&&i.jsx(lF,{attachments:e.attachments,messageId:e.id})]})]}),M([{label:"Copy",icon:i.jsx(Lc,{className:"w-4 h-4"}),onClick:()=>void z()},{label:"Fork session from here",icon:i.jsx(Aa,{className:"w-4 h-4"}),onClick:()=>void H()}])]})}const NN=N.memo(function({message:t,isLastAssistantMessage:n=!1,messageId:r,sessionId:a}){const l=t.role==="user",u=t.role==="assistant",c=t.role==="system",d=t.role==="tool";if(u)return i.jsx(tb,{message:t,showStats:n});if(c&&t.isCompacted)return i.jsxs("div",{className:"feed-item bg-bg-tertiary/50 border border-border rounded p-2",children:[i.jsx("div",{className:"text-text-muted text-xs mb-0.5",children:"[Compacted]"}),i.jsx("div",{className:"text-text-secondary text-xs whitespace-pre-wrap",children:t.content.replace(`[COMPACTED HISTORY]
|
|
306
|
+
`,"")})]});if(d)return i.jsxs("div",{className:"feed-item bg-bg-tertiary/30 border-l-2 border-accent-primary rounded-r p-2",children:[i.jsxs("div",{className:"text-accent-primary text-xs mb-0.5",children:["Tool: ",t.toolName]}),i.jsx(Ze,{horizontal:!0,className:"max-h-32",children:i.jsxs("pre",{className:"text-text-secondary text-xs whitespace-pre-wrap break-words",children:[t.content.slice(0,500),t.content.length>500&&"..."]})})]});if(t.messageKind==="workflow-started")try{const h=JSON.parse(t.content);return i.jsx(nF,{data:h})}catch{}if(t.messageKind==="task-completed")try{const h=JSON.parse(t.content);return i.jsx(tF,{data:h})}catch{}return t.messageKind==="context-reset"?i.jsxs("div",{className:"flex items-center gap-4 mb-6 text-text-muted text-xs uppercase tracking-wide",children:[i.jsx("div",{className:"flex-1 border-t border-border"}),i.jsx("span",{children:t.content}),i.jsx("div",{className:"flex-1 border-t border-border"})]}):t.messageKind==="auto-prompt"&&t.isSystemGenerated?i.jsx(cF,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?i.jsx("div",{className:"flex justify-end feed-item",children:i.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-bg-system border border-border-system",children:[i.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:"System"}),i.jsx("div",{className:"whitespace-pre-wrap break-words text-sm text-text-system italic",children:t.content})]})}):l?i.jsx(uF,{message:t,messageId:r,sessionId:a}):i.jsx("div",{className:"flex justify-start feed-item",children:i.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:i.jsx(Jn,{content:t.content})})})}),dF={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function hF(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function iC(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function fF({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:r,dangerZone:a}=e,l=Math.round(t/n*100);return i.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[i.jsxs("span",{className:iC(l,a),children:[Xo(t),"/",Xo(n)]}),i.jsxs("span",{className:iC(l,a),children:["(",l,"%)"]}),i.jsx(Zy,{percent:l,dangerZone:a,size:"sm"}),a&&i.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),r>0&&i.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[r,"x"]})]})}const mF=N.memo(function({messages:t,subAgentType:n,subAgentId:r,isStreaming:a}){const l=N.useRef(null),u=N.useRef(null),[c,d]=N.useState(!1),h=gt(R=>R.defaults),p=gt(R=>R.userItems),m=[...h,...p],x=Re(R=>R.subAgentContextStates[r]),{showThinking:y,showVerboseToolOutput:S}=Pa(),C=lN(u),{isAutoScrollActive:v,setAutoScroll:w,handleScrollbarGesture:_}=xf(u,null,C),b=N.useCallback(()=>{const R=!c;d(R),R&&setTimeout(()=>{var M;(M=l.current)==null||M.scrollIntoView({block:"start",behavior:"smooth"})},220)},[c]),k=m.find(R=>R.id===n),E=(k==null?void 0:k.name)??dF[n]??n,T=Yo(m,n),D=hF(T),L=t.filter(R=>R.role!=="tool");return i.jsxs("div",{ref:l,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[i.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:D,children:[i.jsx("span",{className:"text-xs font-medium",children:E}),i.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:x&&i.jsx(fF,{contextState:x})}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5",onClick:()=>w(!v),children:[i.jsx("span",{className:`w-1 h-1 rounded-full ${v?"bg-accent-success":"border border-text-muted"}`}),"live"]}),i.jsxs("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary",onClick:b,children:[c?"▼":"▶"," Expand"]})]})]}),i.jsx(Ze,{ref:u,className:`${c?"max-h-[calc(100vh-10rem)]":"max-h-80"} p-2 transition-[max-height] duration-200`,onScrollbarGesture:_,children:L.map(R=>R.role==="assistant"?i.jsx(tb,{message:R,showStats:!0,showThinking:y,showVerboseToolOutput:S},R.id):i.jsx(NN,{message:R,isLastAssistantMessage:!1},R.id))})]})}),Og={contentVisibility:"auto",containIntrinsicSize:"auto 200px"};function Md(e){var t;return e.type==="context-divider"?`ctx-${e.windowSequence}`:e.type==="subagent"?((t=e.messages[0])==null?void 0:t.id)??e.subAgentId:e.message.id}const TN=N.memo(function({displayItems:t,highlightedMessageId:n=null,sessionId:r,showThinking:a=!0,showVerboseToolOutput:l=!0,showStats:u=!0,showAgentDefinitions:c=!0,showWorkflowBars:d=!0}){return i.jsx(i.Fragment,{children:t.map((h,p)=>{if(h.type==="context-divider")return i.jsxs("div",{"data-item-index":p,className:"flex items-center gap-2 feed-item px-2 md:px-4",children:[i.jsx("div",{className:"flex-1 border-t border-border"}),i.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),i.jsx("div",{className:"flex-1 border-t border-border"})]},Md(h));if(h.type==="subagent"){const S=h.messages.some(C=>C.isStreaming);return i.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",style:Og,children:i.jsx(mF,{messages:h.messages,subAgentType:h.subAgentType,subAgentId:h.subAgentId,isStreaming:S})},Md(h))}const m=h.message;if(m.role==="assistant")return i.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",style:Og,children:i.jsx(tb,{message:m,showStats:u,showThinking:a,showVerboseToolOutput:l,sessionId:r??void 0})},Md(h));const x=!c&&m.messageKind==="auto-prompt",y=!d&&(m.messageKind==="workflow-started"||m.messageKind==="task-completed");return x||y?null:i.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",style:Og,children:i.jsx("div",{"data-message-id":m.id,className:n===m.id?"rounded animate-highlight-fade":void 0,children:i.jsx(NN,{message:m,messageId:m.id,sessionId:r??void 0,isLastAssistantMessage:!1})})},Md(h))})})});function yf(e,t,n=!0){N.useEffect(()=>{if(!n)return;const r=a=>{var l;(l=e.current)!=null&&l.contains(a.target)||t()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t,n])}const pF=[],gF=N.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r,onLaunchWorkflow:a,onScrollToTop:l,hiddenCount:u=0,onScrollbarGesture:c}){const d=Re(X=>{var K,P;return((P=(K=X.currentSession)==null?void 0:K.metadataEntries)==null?void 0:P.criteria)??pF}),h=Re(X=>{var K;return(K=X.currentSession)==null?void 0:K.id}),p=Re(X=>{var K;return(K=X.currentSession)==null?void 0:K.phase}),m=Re(X=>X.error),x=Re(X=>X.clearError),y=Vh(),S=Re(X=>X.activeWorkflowExecution),C=Re(X=>X.continueWorkflow),{showThinking:v,showVerboseToolOutput:w,showStats:_,showAgentDefinitions:b,showWorkflowBars:k}=Pa(),E=kt(X=>X.defaults),T=kt(X=>X.userItems),D=[...E,...T],L=d.some(X=>X.status==="pending"),R=p==="done",M=t.some(X=>X.type==="message"&&X.message.role==="assistant"),W=L&&!y&&M&&!R,z=(S==null?void 0:S.status)==="waiting"&&!y,H=Re(X=>{var K;return(K=X.currentSession)==null?void 0:K.projectId}),[I,U]=N.useState(!1),[V,Z]=N.useState(!1),[ee,F]=N.useState(!1),O=N.useCallback(()=>{var X,K;return((K=(X=n.current)==null?void 0:X.osInstance())==null?void 0:K.elements().viewport)??null},[n]);N.useLayoutEffect(()=>{const X=O();X&&Z(X.scrollHeight>X.clientHeight+1)},[O,t]),N.useEffect(()=>{const X=O();if(!X)return;const K=()=>F(X.scrollTop>4);return K(),X.addEventListener("scroll",K,{passive:!0}),()=>X.removeEventListener("scroll",K)},[O]);const B=()=>{if(!H||!h)return;U(!1),window.open(`/p/${H}/s/${h}/readonly`,"_blank")||U(!0)},[q,$]=N.useState(!1),Y=N.useCallback(()=>{q||($(!0),C(),setTimeout(()=>$(!1),5e3))},[q,C]),Q=N.useCallback(()=>{var X;l==null||l(),(X=O())==null||X.scrollTo({top:0,behavior:"smooth"})},[O,l]);return i.jsxs("div",{className:"relative flex-1 min-w-0 group",children:[i.jsxs(Ze,{ref:n,"data-testid":"chat-scroll-container",className:"absolute inset-0 bg-primary",onScrollbarGesture:c,children:[i.jsxs("div",{className:"pt-4",children:[u>0&&i.jsxs("div",{className:"px-2 md:px-4 pb-2 space-y-1",children:[i.jsxs("button",{onClick:B,className:"w-full text-sm text-text-muted hover:text-text-primary bg-bg-tertiary/50 hover:bg-bg-tertiary border border-border rounded px-3 py-2 transition-colors text-center",children:[u," older item",u!==1?"s":""," hidden — View full history"]}),I&&i.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Popup blocked."," ",i.jsx("a",{href:H&&h?`/p/${H}/s/${h}/readonly`:"#",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-text-primary",children:"Open manually"})]})]}),i.jsx(TN,{displayItems:t,highlightedMessageId:r,sessionId:h,showThinking:v,showVerboseToolOutput:w,showStats:_,showAgentDefinitions:b,showWorkflowBars:k})]}),i.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[m&&i.jsx("div",{className:"feed-item bg-text-tool-error/10 border border-text-tool-error/50 rounded p-2",children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-text-tool-error text-sm font-medium",children:m.code}),i.jsx("div",{className:"text-text-tool-error/80 text-xs mt-0.5",children:m.message})]}),i.jsx(eu,{onClick:x,className:"text-text-tool-error hover:text-text-tool-error/80 p-0.5",size:"sm"})]})}),z&&S&&i.jsx("div",{className:"flex justify-center gap-2 feed-item",children:i.jsx("button",{onClick:Y,disabled:q,className:"px-4 py-1.5 text-sm font-medium rounded bg-accent-primary/15 text-accent-primary border border-accent-primary/25 hover:bg-accent-primary/25 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:q?"⏳ Continuing...":`▶ Continue ${S.workflowName} (${S.currentStepName??"..."})`})}),W&&i.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:D.map(X=>{const K=X.color??"#3b82f6",P=parseInt(K.slice(1,3),16),J=parseInt(K.slice(3,5),16),ne=parseInt(K.slice(5,7),16),ce=`rgba(${P},${J},${ne},0.12)`,ae=`rgba(${P},${J},${ne},0.22)`,Ee=`rgba(${P},${J},${ne},0.25)`;return i.jsx(xF,{workflowName:X.name,color:K,bg:ce,bgHover:ae,border:Ee,subGroups:X.subGroups,onLaunch:ve=>a(X.id,ve)},X.id)})})]})]}),V&&ee&&i.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-10 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:i.jsxs("button",{type:"button",onClick:Q,className:"pointer-events-auto text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors backdrop-blur-sm bg-bg-secondary/60",children:[i.jsx(MR,{className:"w-3 h-3"}),"scroll to top"]})})]})});function xF({workflowName:e,color:t,bg:n,bgHover:r,border:a,subGroups:l,onLaunch:u}){const[c,d]=N.useState(!1),h=N.useRef(null);yf(h,()=>d(!1),c);const p=l&&l.length>0;return i.jsxs("div",{className:"relative flex",children:[i.jsxs("button",{onClick:()=>u(),"data-testid":"workflow-run-button",className:`px-4 py-1.5 text-sm font-medium transition-colors ${p?"rounded-l":"rounded"}`,style:{backgroundColor:n,color:t,border:`1px solid ${a}`,...p?{borderRight:"none"}:{}},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=r},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=n},children:["▶ ",e]}),p&&i.jsxs("div",{ref:h,className:"relative",children:[i.jsx("button",{onClick:()=>d(!c),className:"px-2.5 py-1.5 rounded-r text-sm font-medium transition-colors",style:{backgroundColor:n,color:t,border:`1px solid ${a}`},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=r},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=n},children:"⋮"}),c&&i.jsxs("div",{className:"absolute top-full right-0 mt-1 w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[i.jsx("button",{onClick:()=>{u(),d(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Full workflow"}),i.jsx("div",{className:"border-t border-border/50"}),l.map(m=>i.jsx("button",{onClick:()=>{u(m),d(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:m},m))]})]})]})}function yF(){const e=Re(r=>r.connectionStatus),t=Re(r=>r.reconnect);if(e==="connected")return null;const n=e==="reconnecting";return i.jsxs("div",{className:`
|
|
307
|
+
flex items-center justify-between px-4 py-2
|
|
308
|
+
text-sm font-medium
|
|
309
|
+
${n?"bg-amber-500/15 border-b border-amber-500/30 text-amber-300":"bg-red-500/15 border-b border-red-500/30 text-red-300"}
|
|
310
|
+
`,children:[i.jsx("div",{className:"flex items-center gap-2",children:n?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"flex gap-1",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"150ms"}}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"300ms"}})]}),i.jsx("span",{children:"Reconnecting to server..."})]}):i.jsxs(i.Fragment,{children:[i.jsx(GR,{}),i.jsx("span",{children:"Connection lost"})]})}),i.jsx("button",{onClick:()=>t(),disabled:n,className:`
|
|
311
|
+
px-3 py-1 rounded text-xs font-medium
|
|
312
|
+
transition-colors
|
|
313
|
+
${n?"bg-amber-500/20 text-amber-400 cursor-not-allowed opacity-50":"bg-red-500/20 text-red-300 hover:bg-red-500/30 hover:text-red-200"}
|
|
314
|
+
`,children:n?"Reconnecting...":"Reconnect"})]})}async function bF(e,t,n){t({loading:!0});try{const a=await(await Ce(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const on=Gn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async()=>{await bF("/api/commands",e,!0)},fetchCommand:async n=>{try{const r=await Ce(`/api/commands/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await Ce(`/api/commands/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createCommand:async(n,r)=>{const a=await Ui("POST","/api/commands",{...n,destination:r});return a.success&&await t().fetchCommands(),a},updateCommand:async(n,r)=>{const a=await Ui("PUT",`/api/commands/${n}`,r);return a.success&&await t().fetchCommands(),a},deleteCommand:async n=>{try{const r=await Ce(`/api/commands/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateCommand:async(n,r)=>Uh(`/api/commands/${n}/duplicate`,()=>t().fetchCommands(),r)}));function vF(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function _F({onClick:e}){return i.jsx("button",{type:"button",onClick:e,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:i.jsx(sy,{})})}function AN({isOpen:e,onClose:t,initialEditId:n}){const r=on(Se=>Se.defaults),a=on(Se=>Se.userItems),l=on(Se=>Se.projectItems),u=on(Se=>Se.loading),c=on(Se=>Se.fetchCommands),d=on(Se=>Se.fetchCommand),h=on(Se=>Se.fetchDefaultContent),p=on(Se=>Se.createCommand),m=on(Se=>Se.updateCommand),x=on(Se=>Se.deleteCommand),[y,S]=N.useState(null),[C,v]=N.useState(null),{view:w,editingId:_,formError:b,saving:k,formData:E,setView:T,setEditingId:D,setFormError:L,setFormData:R,setSaving:M}=Qk(),{requestDelete:W,clearConfirm:z,isConfirming:H}=Gc(),I=N.useRef(!1),U=gt(Se=>Se.defaults),V=gt(Se=>Se.userItems),Z=gt(Se=>Se.fetchAgents),F=[...U,...V].filter(Se=>!Se.subagent),O=N.useRef(c),B=N.useRef(Z),q=N.useRef(d),$=N.useRef(h),Y=N.useRef(n),Q=N.useRef(T),X=N.useRef(D),K=N.useRef(L),P=N.useRef(z);N.useEffect(()=>{O.current=c,B.current=Z,q.current=d,$.current=h,Y.current=n,Q.current=T,X.current=D,K.current=L,P.current=z}),N.useEffect(()=>{if(e)if(O.current(),B.current(),I.current||(P.current(),I.current=!0),Y.current){const Se=r.some(Ie=>Ie.id===Y.current);Q.current("edit"),X.current(Y.current),K.current(""),Se?$.current(Y.current).then(Ie=>{Ie&&R({name:Ie.metadata.name+" (copy)",id:`${Y.current}-copy-${Date.now()}`,prompt:Ie.prompt,agentMode:Ie.metadata.agentMode??"",isDefault:!0,destination:"user"})}):q.current(Y.current).then(Ie=>{Ie&&R({name:Ie.metadata.name,id:Ie.metadata.id,prompt:Ie.prompt,agentMode:Ie.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else Q.current("list"),X.current(null);else I.current=!1},[e]);const J=async Se=>{S(Se);const Ie=await h(Se);v((Ie==null?void 0:Ie.prompt)??null)},ne=async Se=>{if(r.some(it=>it.id===Se)){const it=await h(Se);it&&(D(null),R({name:`${it.metadata.name} (copy)`,id:`${Se}-copy-${Date.now()}`,prompt:it.prompt,agentMode:it.metadata.agentMode??"",isDefault:!0,destination:"user"}),L(""),T("edit"))}else{const it=await d(Se);it&&(D(null),R({name:`${it.metadata.name} (copy)`,id:`${Se}-copy-${Date.now()}`,prompt:it.prompt,agentMode:it.metadata.agentMode??"",isDefault:!1,destination:"user"}),L(""),T("edit"))}},ce=()=>{R({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),D(null),T("edit")},ae=async Se=>{const Ie=await d(Se);Ie&&(D(Se),R({name:Ie.metadata.name,id:Ie.metadata.id,prompt:Ie.prompt,agentMode:Ie.metadata.agentMode??"",isDefault:!1,destination:"user"}),L(""),T("edit"))},Ee=async Se=>{await x(Se),z()},ve=async()=>{const Se=_??E.id;if(!Se||!E.name||!E.prompt){L("Name and message are required.");return}M(!0),L("");const Ie={metadata:{id:Se,name:E.name,...E.agentMode?{agentMode:E.agentMode}:{}},prompt:E.prompt},it=_?await m(_,Ie):await p(Ie,E.destination);if(M(!1),!it.success){L(it.error??"Failed to save command.");return}n?t():T("list")},Le=()=>{n?t():(T("list"),S(null),v(null))},Me=Se=>{R(Ie=>({...Ie,name:Se})),(!_||E.isDefault)&&R(Ie=>({...Ie,id:vF(Se)}))},ke=()=>{S(null),v(null),T("list")},Ge=()=>{y&&(S(null),T("edit"),D(y),h(y).then(Se=>{Se&&R({name:`${Se.metadata.name} (copy)`,id:`${y}-copy-${Date.now()}`,prompt:Se.prompt,agentMode:Se.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(y){const Se=r.find(Ie=>Ie.id===y);return i.jsx(Tt,{isOpen:e,onClose:ke,title:`Default: ${(Se==null?void 0:Se.name)??y}`,size:"xl",children:i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"space-y-3 mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[i.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),i.jsx("span",{className:"font-mono",children:y})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),i.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:Se==null?void 0:Se.name})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Agent Mode"}),i.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-muted",children:(Se==null?void 0:Se.agentMode)||"None"})]})]}),i.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),i.jsx("textarea",{value:C??"",readOnly:!0,placeholder:"...",className:"flex-1 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none opacity-60"})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[i.jsx(mt,{variant:"secondary",onClick:ke,children:"Close"}),i.jsx(mt,{variant:"primary",onClick:Ge,children:"Duplicate & Customize"})]})]})})}if(w==="edit")return i.jsx(Tt,{isOpen:e,onClose:Le,title:_?"Edit Command":"New Command",size:"xl",footer:i.jsx(Gk,{onCancel:Le,onSave:ve,saving:k,saveDisabled:!E.name||!E.prompt}),children:i.jsxs("div",{className:"flex flex-col h-full",children:[b&&i.jsx(Fo,{message:b}),i.jsxs("div",{className:"space-y-3 mb-3",children:[i.jsx(Xk,{name:E.name,id:E.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!_&&!E.isDefault,onNameChange:Me,onIdChange:Se=>R(Ie=>({...Ie,id:Se}))}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",i.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),i.jsxs("select",{value:E.agentMode,onChange:Se=>R(Ie=>({...Ie,agentMode:Se.target.value})),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[i.jsx("option",{value:"",children:"None (keep current mode)"}),F.map(Se=>i.jsx("option",{value:Se.id,children:Se.name},Se.id))]})]}),!_&&i.jsx(qh,{value:E.destination,onChange:Se=>R(Ie=>({...Ie,destination:Se}))})]}),i.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),i.jsx("textarea",{value:E.prompt,onChange:Se=>R(Ie=>({...Ie,prompt:Se.target.value})),placeholder:"The message that will be sent when this command is triggered...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]})});const Xe=Se=>Se.map(Ie=>i.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[i.jsx("div",{className:"min-w-0 flex-1 mr-3",children:i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("span",{className:"text-text-primary text-sm font-medium",children:Ie.name})})}),i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[i.jsx(ti,{onClick:()=>ae(Ie.id)}),i.jsx(Rc,{onClick:()=>ne(Ie.id)}),H(Ie.id,"delete")?i.jsx(oh,{onConfirm:()=>Ee(Ie.id),onCancel:z}):i.jsx(lh,{onClick:()=>W(Ie.id)})]})]},Ie.id));return i.jsxs(Tt,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[i.jsx(Yk,{description:"Commands are pre-defined messages you can send with a single click.",onNew:ce}),i.jsxs(cy,{loading:u,hasItems:r.length>0||a.length>0||l.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[r.length>0&&i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),i.jsx("div",{className:"space-y-2",children:r.map(Se=>i.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[i.jsx("div",{className:"min-w-0 flex-1 mr-3",children:i.jsx("span",{className:"text-text-primary text-sm font-medium",children:Se.name})}),i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[i.jsx(_F,{onClick:()=>J(Se.id)}),i.jsx(Rc,{onClick:()=>ne(Se.id)})]})]},Se.id))})]}),a.length>0&&i.jsx(Kk,{children:Xe(a)}),l.length>0&&i.jsxs("div",{className:"mt-4",children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),i.jsx("div",{className:"space-y-2",children:Xe(l)})]})]})]})}function SF({title:e,defaultOpen:t=!1,children:n,className:r=""}){return i.jsxs("details",{className:`group ${r}`,open:t,children:[i.jsxs("summary",{className:"text-[11px] text-text-secondary uppercase tracking-wider font-medium cursor-pointer select-none hover:text-text-primary transition-colors list-none flex items-center gap-1",children:[i.jsx(yn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),e]}),i.jsx("div",{className:"mt-2 space-y-2",children:n})]})}const ga=150,qs=54,Pd=80,Xr=30,No=70,aC=100,xa=50,Bd=50,oC=4,LN={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},DN=[{value:"step_result",label:"Step result is..."},{value:"metadata_all_match",label:"Metadata all match (key=value)"},{value:"metadata_all_in",label:"Metadata all in list"},{value:"always",label:"Always (fallback)"}],wF=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"},{value:"user",label:"User (pause)"}];function rb(e,t){if(e.type==="agent"){const n=t.find(r=>r.id===e.agentId);return{name:(n==null?void 0:n.name)??(e.agentId||"Agent"),color:(n==null?void 0:n.color)||"#3b82f6"}}if(e.type==="sub_agent"){const n=t.find(r=>r.id===e.subAgentType);return{name:(n==null?void 0:n.name)??(e.subAgentType||"Sub-Agent"),color:(n==null?void 0:n.color)||"#a855f7"}}return e.type==="user"?{name:"User",color:"#f59e0b"}:{name:"Shell",color:"#22c55e"}}function CF(e,t,n,r){const a=Bd+xa+ga+aC+ga+xa+Bd,l=a/2,u=Bd+xa+ga/2,c=Bd+xa+ga+aC+ga/2,d=[],h=[],p=new Map,m=e.filter(U=>U.type==="agent"||U.type==="shell"||U.type==="user"),x=e.filter(U=>U.type==="sub_agent"),y=x.length>0,S=y?u:l,C=m.length>0?c:l,v=xa+Xr/2;d.push({id:"$start",type:"terminal",label:"Start",cx:S,cy:v,w:Pd,h:Xr}),p.set("$start",{cx:S,cy:v,w:Pd,h:Xr});const w=U=>{d.push({id:"$done",type:"terminal",label:"Done",cx:S,cy:U,w:Pd,h:Xr}),p.set("$done",{cx:S,cy:U,w:Pd,h:Xr})};if(e.length===0){const U=v+Xr/2+No*2+Xr/2;return w(U),{nodes:d,edges:h,width:a,height:U+Xr/2+xa,posMap:p}}const _=v+Xr/2+No,b=(U,V)=>{U.forEach((Z,ee)=>{const F=_+ee*(qs+No)+qs/2,{name:O,color:B}=rb(Z,r);d.push({id:Z.id,type:"step",label:O,color:B,cx:V,cy:F,w:ga,h:qs}),p.set(Z.id,{cx:V,cy:F,w:ga,h:qs})})};b(m,S),b(x,C);const k=m.length>0?_+(m.length-1)*(qs+No)+qs/2:v,E=y?_+(x.length-1)*(qs+No)+qs/2:v,T=Math.max(k,E)+qs/2+No+Xr/2;w(T);const D=[];t&&p.has(t)&&D.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let L=0;for(const U of e)U.transitions.forEach((V,Z)=>{var $;if(!V.goto||!p.has(V.goto))return;const ee=p.get(U.id),F=p.get(V.goto),O=V.when.type==="step_result"?`${V.when.result}`:V.when.type==="metadata_all_match"?`${V.when.key??"?"}=${V.when.value??"?"}`:V.when.type==="metadata_all_in"?`${V.when.key??"?"} in [${(($=V.when.values)==null?void 0:$.join(","))??"?"}]`:LN[V.when.type]??V.when.type,B=U.id===V.goto;let q;B?q="back":F.cy>ee.cy+1?q="down":F.cy<ee.cy-1?q="back":q="same",D.push({from:U.id,to:V.goto,label:O,edgeKey:`${U.id}:${Z}`,direction:q,backEdgeIndex:q==="back"?L++:0})});const R=new Map,M=new Map,W=new Map,z=new Map;for(const U of D)U.direction==="down"&&(R.set(U.from,(R.get(U.from)??0)+1),M.set(U.to,(M.get(U.to)??0)+1));const H=new Map,I=new Map;for(const U of D){if(U.direction!=="same")continue;const V=[U.from,U.to].sort().join("|");H.set(V,(H.get(V)??0)+1)}for(const U of D){if(U.direction==="back"||U.direction==="same"){let q=0;if(U.direction==="same"){const $=[U.from,U.to].sort().join("|");q=I.get($)??0,I.set($,q+1)}h.push({...U,fromPort:0,toPort:0,sameEdgeIndex:q});continue}const V=R.get(U.from)??1,Z=M.get(U.to)??1,ee=W.get(U.from)??0,F=z.get(U.to)??0;W.set(U.from,ee+1),z.set(U.to,F+1);const O=V===1?0:-.6+1.2*ee/(V-1),B=Z===1?0:-.6+1.2*F/(Z-1);h.push({...U,fromPort:O,toPort:B,sameEdgeIndex:0})}return{nodes:d,edges:h,width:a,height:T+Xr/2+xa,posMap:p}}function kF({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:a,agentTypes:l,isReadOnly:u,onSelectNode:c,onSelectEdge:d,onRemoveStep:h,onCreateTransition:p,onReconnectTo:m,onReconnectFrom:x,onDeleteTransition:y}){const S=N.useRef(null),C=N.useRef(!1),[v,w]=N.useState(null),[_,b]=N.useState(null),[k,E]=N.useState(null),{nodes:T,edges:D,width:L,height:R,posMap:M}=N.useMemo(()=>CF(e,t,a,l),[e,t,a,l]),W=N.useCallback(Q=>{var ne;const X=S.current;if(!X)return{x:0,y:0};const K=X.createSVGPoint();K.x=Q.clientX,K.y=Q.clientY;const P=(ne=X.getScreenCTM())==null?void 0:ne.inverse();if(!P)return{x:0,y:0};const J=K.matrixTransform(P);return{x:J.x,y:J.y}},[]),z=N.useCallback(Q=>!Q||!_||Q==="$start"?!1:_.type==="reconnect-from"?Q!=="$done":!0,[_]),H=N.useCallback((Q,X)=>{if(u)return;Q.stopPropagation(),Q.preventDefault();const K=W(Q);b({type:"new",fromNodeId:X,mouseX:K.x,mouseY:K.y})},[W,u]),I=N.useCallback((Q,X)=>{if(u)return;Q.stopPropagation(),Q.preventDefault();const K=W(Q);b({type:"reconnect-to",fromNodeId:X.from,edgeKey:X.edgeKey,mouseX:K.x,mouseY:K.y})},[W,u]),U=N.useCallback((Q,X)=>{if(u)return;Q.stopPropagation(),Q.preventDefault();const K=W(Q);b({type:"reconnect-from",fromNodeId:X.from,fixedTargetId:X.to,edgeKey:X.edgeKey,mouseX:K.x,mouseY:K.y})},[W,u]),V=N.useCallback(Q=>{if(!_)return;const X=W(Q);b(K=>K?{...K,mouseX:X.x,mouseY:X.y}:null)},[_,W]),Z=N.useCallback(()=>{_&&(C.current=!0,k&&z(k)&&(_.type==="new"?p(_.fromNodeId,k):_.type==="reconnect-to"?m(_.edgeKey,k):_.type==="reconnect-from"&&x(_.edgeKey,k)),b(null),E(null))},[_,k,z,p,m,x]),ee=N.useCallback(()=>{if(C.current){C.current=!1;return}c(null),d(null)},[c,d]);N.useEffect(()=>{if(u)return;const Q=X=>{X.target instanceof HTMLInputElement||X.target instanceof HTMLTextAreaElement||X.target instanceof HTMLSelectElement||(X.key==="Delete"||X.key==="Backspace")&&r&&r!=="start"&&(X.preventDefault(),y(r),d(null))};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[u,r,y,d]);const F=Q=>{const X=M.get(Q.from),K=M.get(Q.to);if(!X||!K)return null;let P,J,ne,ce="middle",ae,Ee;if(Q.direction==="down"){const ve=X.cx+Q.fromPort*(X.w/2-10),Le=X.cy+X.h/2,Me=K.cx+Q.toPort*(K.w/2-10),ke=K.cy-K.h/2,Ge=ke-Le,Xe=Me-ve;P=`M ${ve} ${Le} C ${ve} ${Le+Ge*.4}, ${Me-Xe*.2} ${ke-Ge*.1}, ${Me} ${ke}`,J=ve+(Me-ve)*.5,ne=Le+Ge*.6,ae={x:ve,y:Le},Ee={x:Me,y:ke}}else if(Q.direction==="back"){const ve=Q.from===Q.to,Le=X.cx>=L/2,Me=Q.backEdgeIndex*16,ke=Le?L-20-Me:20+Me;if(ve){const Ge=X.cx>=L/2,Xe=30+Q.backEdgeIndex*14,Se=X.cy-X.h/2,Ie=Ge?X.cx+X.w/2:X.cx-X.w/2,it=Ge?Ie+Xe:Ie-Xe,ge=X.cx+(Ge?X.w/4:-X.w/4),Fe=Se-20-Q.backEdgeIndex*10;P=`M ${Ie} ${X.cy} C ${it} ${X.cy}, ${it} ${Fe}, ${ge} ${Se}`,J=it+10,ne=Fe+4,ce="middle",ae={x:Ie,y:X.cy},Ee={x:ge,y:Se}}else{const Ge=Le?X.cx+X.w/2:X.cx-X.w/2,Xe=K.cx+(Le?K.w/4:-K.w/4),Se=Math.min(X.cy,K.cy)-K.h/2-18-Q.backEdgeIndex*14;P=`M ${Ge} ${X.cy} L ${ke} ${X.cy} L ${ke} ${Se} L ${Xe} ${Se} L ${Xe} ${K.cy-K.h/2}`,J=ke,ne=(X.cy+Se)/2,ce=Le?"start":"end",ae={x:Ge,y:X.cy},Ee={x:Xe,y:K.cy-K.h/2}}}else{const ve=K.cx>X.cx,Le=Q.sameEdgeIndex===0?-12:12,Me=ve?X.cx+X.w/2:X.cx-X.w/2,ke=ve?K.cx-K.w/2:K.cx+K.w/2,Ge=X.cy+Le,Xe=K.cy+Le,Se=(Me+ke)/2;P=`M ${Me} ${Ge} C ${Se} ${Ge}, ${Se} ${Xe}, ${ke} ${Xe}`,J=Se,ne=(Ge+Xe)/2-6,ae={x:Me,y:Ge},Ee={x:ke,y:Xe}}return{path:P,labelX:J,labelY:ne,labelAnchor:ce,fromPt:ae,toPt:Ee}},O=(Q,X)=>{const K=F(Q);if(!K)return null;const{path:P,labelX:J,labelY:ne,labelAnchor:ce}=K,ae=r===Q.edgeKey,Ee=Q.label&&Q.label!=="otherwise";return i.jsxs("g",{children:[i.jsx("path",{d:P,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:ve=>{ve.stopPropagation(),u||d(ae?null:Q.edgeKey)}}),i.jsx("path",{d:P,fill:"none",stroke:ae?"#58a6ff":"#484f58",strokeWidth:ae?2.2:1.2,markerEnd:ae?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),Ee&&i.jsx("text",{x:J+(ce==="start"?5:ce==="end"?-5:0),y:ne+3,textAnchor:ce,className:"text-[8px]",fill:ae?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:Q.label})]},X)},B=()=>{if(!r||_)return null;const Q=D.find(ne=>ne.edgeKey===r);if(!Q)return null;const X=F(Q);if(!X)return null;const{fromPt:K,toPt:P}=X,J=6;return i.jsxs(i.Fragment,{children:[Q.edgeKey!=="start"&&i.jsx("circle",{cx:K.x,cy:K.y,r:J,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ne=>U(ne,Q)}),i.jsx("circle",{cx:P.x,cy:P.y,r:J,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ne=>I(ne,Q)})]})},q=()=>{if(!_)return null;let Q,X,K,P;if(_.type==="reconnect-from"){const ce=M.get(_.fixedTargetId);if(!ce)return null;Q=_.mouseX,X=_.mouseY,K=ce.cx,P=ce.cy-ce.h/2}else{const ce=M.get(_.fromNodeId);if(!ce)return null;Q=ce.cx,X=ce.cy+ce.h/2,K=_.mouseX,P=_.mouseY}const J=P-X,ne=Math.abs(J)>10?`M ${Q} ${X} C ${Q} ${X+J*.4}, ${K} ${P-J*.4}, ${K} ${P}`:`M ${Q} ${X} L ${K} ${P}`;return i.jsx("path",{d:ne,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},$=Q=>{const X=Q.cy+Q.h/2,K=(_==null?void 0:_.fromNodeId)===Q.id;return i.jsx("circle",{cx:Q.cx,cy:X,r:oC,fill:K?"#58a6ff":"#1c2128",stroke:K?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:K?1:.5,className:"cursor-crosshair",onMouseDown:P=>H(P,Q.id)})},Y=Q=>{const X=Q.cy-Q.h/2,K=_&&k===Q.id&&z(Q.id);return i.jsx("circle",{cx:Q.cx,cy:X,r:oC,fill:K?"#3fb950":"#1c2128",stroke:K?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:K?1:.5})};return i.jsxs("svg",{ref:S,viewBox:`0 0 ${L} ${R}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:V,onMouseUp:Z,onClick:ee,children:[i.jsxs("defs",{children:[i.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:i.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),i.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:i.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),D.map((Q,X)=>O(Q,X)),T.map(Q=>{const X=n===Q.id,K=Q.cx-Q.w/2,P=Q.cy-Q.h/2,J=v===Q.id,ne=_&&k===Q.id&&z(Q.id);if(Q.type==="terminal"){const ae=Q.id==="$start",Ee=ae?"#58a6ff":"#3fb950",ve=ae,Le=!ae;return i.jsxs("g",{onClick:Me=>{Me.stopPropagation(),ae&&!u&&d("start")},className:ae&&!u?"cursor-pointer":void 0,children:[ne&&i.jsx("rect",{x:K-3,y:P-3,width:Q.w+6,height:Q.h+6,rx:Q.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),ae&&r==="start"&&i.jsx("rect",{x:K-3,y:P-3,width:Q.w+6,height:Q.h+6,rx:Q.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),i.jsx("rect",{x:K,y:P,width:Q.w,height:Q.h,rx:Q.h/2,fill:Ee,fillOpacity:.08,stroke:Ee,strokeOpacity:.4,strokeWidth:1.5}),i.jsx("text",{x:Q.cx,y:Q.cy+4,textAnchor:"middle",fill:Ee,className:"text-[10px] font-medium",pointerEvents:"none",children:Q.label}),ve&&$(Q),Le&&Y(Q)]},Q.id)}const ce=Q.color??"#6b7280";return i.jsxs("g",{onClick:ae=>{ae.stopPropagation(),u||c(X?null:Q.id)},onMouseEnter:()=>w(Q.id),onMouseLeave:()=>w(null),className:u?void 0:"cursor-pointer",children:[ne&&i.jsx("rect",{x:K-3,y:P-3,width:Q.w+6,height:Q.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),X&&i.jsx("rect",{x:K-3,y:P-3,width:Q.w+6,height:Q.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),i.jsx("rect",{x:K,y:P,width:Q.w,height:Q.h,rx:10,fill:ce,fillOpacity:.08,stroke:ce,strokeOpacity:.6,strokeWidth:X?2:1.5}),i.jsx("text",{x:Q.cx,y:Q.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:Q.label}),!u&&$(Q),!u&&Y(Q),J&&!_&&!u&&i.jsxs("g",{onClick:ae=>{ae.stopPropagation(),h(Q.id)},className:"cursor-pointer",children:[i.jsx("circle",{cx:K+Q.w-2,cy:P+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),i.jsx("line",{x1:K+Q.w-5,y1:P-1,x2:K+Q.w+1,y2:P+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),i.jsx("line",{x1:K+Q.w+1,y1:P-1,x2:K+Q.w-5,y2:P+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},Q.id)}),_&&T.map(Q=>z(Q.id)?i.jsx("rect",{x:Q.cx-Q.w/2-8,y:Q.cy-Q.h/2-8,width:Q.w+16,height:Q.h+16,fill:"transparent",rx:12,onMouseEnter:()=>E(Q.id),onMouseLeave:()=>E(null),onMouseUp:X=>{X.stopPropagation(),Z()}},`drop-${Q.id}`):null),q(),B()]})}const $d="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",mc="block text-[11px] text-text-secondary mb-0.5";function jF({formName:e,formId:t,formDescription:n,formMaxIterations:r,formColor:a,isReadOnly:l,onNameChange:u,onDescriptionChange:c,onMaxIterationsChange:d,onColorChange:h}){return i.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[i.jsxs("div",{className:"min-w-[140px]",children:[i.jsx("label",{className:mc,children:"Name"}),i.jsx("input",{value:e,onChange:p=>u(p.target.value),placeholder:"Workflow name",className:`${$d} ${l?"opacity-50":""}`,readOnly:l})]}),i.jsxs("div",{className:"min-w-[100px]",children:[i.jsx("label",{className:mc,children:"ID"}),i.jsx("input",{value:t,readOnly:!0,className:`${$d} font-mono opacity-50`})]}),i.jsxs("div",{className:"flex-1 min-w-[140px]",children:[i.jsx("label",{className:mc,children:"Description"}),i.jsx("input",{value:n,onChange:p=>!l&&c(p.target.value),readOnly:l,placeholder:"What does this workflow do?",className:`${$d} ${l?"opacity-50":""}`})]}),i.jsxs("div",{className:"w-20",children:[i.jsx("label",{className:mc,children:"Max Iter."}),i.jsx("input",{type:"number",value:r,onChange:p=>!l&&d(Number(p.target.value)),readOnly:l,className:`${$d} font-mono ${l?"opacity-50":""}`})]}),i.jsxs("div",{children:[i.jsx("label",{className:mc,children:"Color"}),i.jsx("input",{type:"color",value:a,onChange:p=>!l&&h(p.target.value),disabled:l,className:`w-8 h-8 rounded border border-border bg-transparent ${l?"opacity-50":"cursor-pointer"}`})]})]})}function EF({name:e,id:t,color:n,description:r,isBuiltIn:a,actions:l}){return i.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:n}}),i.jsx("span",{className:"text-text-primary text-sm font-medium",children:e}),i.jsx("span",{className:"text-text-muted text-xs font-mono",children:t}),a&&i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),r&&i.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:r})]}),i.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 ml-3",children:l})]})}function Ig({title:e,items:t,renderActions:n}){return t.length===0?null:i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),i.jsx("div",{className:"space-y-2",children:t.map(r=>i.jsx(EF,{name:r.name,id:r.id,color:r.color??"#3b82f6",description:r.description,actions:n(r)},r.id))})]})}const ya="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Mg="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",hs="block text-[11px] text-text-secondary mb-0.5";function Pg({variables:e,onInsert:t}){return e.length===0?null:i.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(n=>i.jsx("button",{type:"button",onClick:()=>t(n.name),title:n.description,className:"px-1.5 py-0.5 rounded text-[10px] font-mono bg-bg-primary border border-border text-text-secondary hover:text-accent-primary hover:border-accent-primary/40 transition-colors",children:`{{${n.name}}}`},n.name))})}function NF({step:e,isEntry:t,agentTypes:n,transitionCount:r,templateVariables:a,onUpdate:l,onRemove:u,onSetEntry:c}){const{color:d,name:h}=rb(e,n);return i.jsxs("div",{className:"space-y-3 text-sm",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:d+"20",color:d},children:h}),t&&i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[!t&&i.jsx("button",{onClick:c,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),i.jsx("button",{onClick:u,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:hs,children:"Name"}),i.jsx("input",{value:e.name,onChange:p=>l({...e,name:p.target.value}),placeholder:"Step name",className:ya})]}),i.jsxs("div",{children:[i.jsx("label",{className:hs,children:"Type"}),i.jsx("select",{value:e.type,onChange:p=>{const m=p.target.value,x=m==="sub_agent"?"verification":"build";if(m==="agent"){const y=n.find(S=>!S.subagent);l({...e,type:m,phase:x,agentId:(y==null?void 0:y.id)??"builder",name:(y==null?void 0:y.name)??"Agent"})}else if(m==="sub_agent"){const y=n.find(S=>S.subagent);l({...e,type:m,phase:x,subAgentType:(y==null?void 0:y.id)??"",name:(y==null?void 0:y.name)??"Sub-Agent"})}else l(m==="user"?{...e,type:m,phase:x,name:"User"}:{...e,type:m,phase:x,name:"Shell"})},className:Mg,children:wF.map(p=>i.jsx("option",{value:p.value,children:p.label},p.value))})]}),e.type==="agent"&&i.jsxs("div",{children:[i.jsx("label",{className:hs,children:"Agent Type"}),i.jsx("select",{value:e.agentId??"builder",onChange:p=>{const m=n.find(x=>x.id===p.target.value);l({...e,agentId:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:Mg,children:n.filter(p=>!p.subagent).map(p=>i.jsx("option",{value:p.id,children:p.name},p.id))})]}),e.type==="sub_agent"&&i.jsxs("div",{children:[i.jsx("label",{className:hs,children:"Sub-Agent Type"}),i.jsxs("select",{value:e.subAgentType??"",onChange:p=>{const m=n.find(x=>x.id===p.target.value);l({...e,subAgentType:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:Mg,children:[i.jsx("option",{value:"",children:"— select —"}),n.filter(p=>p.subagent).map(p=>i.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:hs,children:"Prompt"}),i.jsx("textarea",{value:e.prompt??"",onChange:p=>l({...e,prompt:p.target.value||void 0}),rows:6,className:`${ya} resize-y text-xs`,placeholder:"Injected on first entry..."}),i.jsx(Pg,{variables:a,onInsert:p=>l({...e,prompt:(e.prompt??"")+`{{${p}}}`})})]}),i.jsxs("div",{children:[i.jsx("label",{className:hs,children:"Nudge Prompt"}),i.jsx("textarea",{value:e.nudgePrompt??"",onChange:p=>l({...e,nudgePrompt:p.target.value||void 0}),rows:6,className:`${ya} resize-y text-xs`,placeholder:"Injected on re-entry..."}),i.jsx(Pg,{variables:a,onInsert:p=>l({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${p}}}`})})]})]}),e.type==="shell"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:hs,children:"Command"}),i.jsx("textarea",{value:e.command??"",onChange:p=>l({...e,command:p.target.value}),rows:3,className:`${ya} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),i.jsx(Pg,{variables:a,onInsert:p=>l({...e,command:(e.command??"")+`{{${p}}}`})})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("div",{children:[i.jsx("label",{className:hs,children:"Timeout (ms)"}),i.jsx("input",{type:"number",value:e.timeout??6e4,onChange:p=>l({...e,timeout:Number(p.target.value)}),className:`${ya} font-mono text-xs`})]}),i.jsxs("div",{children:[i.jsx("label",{className:hs,children:"Success Codes"}),i.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:p=>l({...e,successExitCodes:p.target.value.split(",").map(m=>Number(m.trim())).filter(m=>!isNaN(m))}),className:`${ya} font-mono text-xs`})]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:hs,children:"Sub-group"}),i.jsx("input",{value:e.subGroup??"",onChange:p=>l({...e,subGroup:p.target.value||void 0}),placeholder:"e.g. build, verify, review",className:ya})]}),i.jsx("div",{className:"pt-1 border-t border-border/50",children:i.jsxs("p",{className:"text-text-muted text-[10px]",children:[r," outgoing transition",r!==1?"s":""," — drag from the bottom port to connect."]})})]})}const To="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",lC="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",ba="block text-[11px] text-text-secondary mb-0.5";function TF({fromLabel:e,toLabel:t,condition:n,subGroup:r,fromStep:a,agentTypes:l,transitionIndex:u,totalTransitions:c,onUpdateCondition:d,onUpdateSubGroup:h,onDelete:p,onMoveUp:m,onMoveDown:x}){var C;const y=a&&(a.type==="sub_agent"||a.type==="agent")?l.find(v=>v.id===(a.type==="sub_agent"?a.subAgentType:a.agentId)):void 0,S=(y==null?void 0:y.results)&&y.results.length>0;return i.jsxs("div",{className:"space-y-3 text-sm",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:["#",u+1]}),c>1&&i.jsxs("div",{className:"flex items-center gap-0.5",children:[i.jsx("button",{onClick:m,disabled:u===0,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move up (higher priority)",children:i.jsx(yn,{className:"w-3 h-3",rotate:180})}),i.jsx("button",{onClick:x,disabled:u===c-1,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move down (lower priority)",children:i.jsx(yn,{className:"w-3 h-3"})})]})]}),i.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[i.jsx("span",{className:"font-medium text-text-primary",children:e}),i.jsx(Ok,{}),i.jsx("span",{className:"font-medium text-text-primary",children:t})]}),i.jsxs("div",{children:[i.jsx("label",{className:ba,children:"Condition"}),i.jsx("select",{value:n.type,onChange:v=>{d(v.target.value==="step_result"?{type:"step_result",result:"success"}:{type:v.target.value})},className:lC,children:DN.map(v=>i.jsx("option",{value:v.value,children:v.label},v.value))})]}),n.type==="step_result"&&i.jsxs("div",{children:[i.jsx("label",{className:ba,children:"Result"}),S?i.jsx("select",{value:n.result??y.results[0],onChange:v=>{d({type:"step_result",result:v.target.value})},className:lC,children:y.results.map(v=>i.jsx("option",{value:v,children:v},v))}):i.jsx("input",{type:"text",value:n.result??"success",onChange:v=>d({type:"step_result",result:v.target.value}),placeholder:"e.g. success, passed, failed",className:To})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:ba,children:"Metadata Key"}),i.jsx("input",{type:"text",value:n.key??"",onChange:v=>d({...n,key:v.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:To})]}),i.jsxs("div",{children:[i.jsx("label",{className:ba,children:"Field"}),i.jsx("input",{type:"text",value:n.field??"",onChange:v=>d({...n,field:v.target.value}),placeholder:"e.g. status",className:To})]}),n.type==="metadata_all_match"?i.jsxs("div",{children:[i.jsx("label",{className:ba,children:"Value"}),i.jsx("input",{type:"text",value:n.value??"",onChange:v=>d({...n,value:v.target.value}),placeholder:"e.g. passed, resolved",className:To})]}):i.jsxs("div",{children:[i.jsx("label",{className:ba,children:"Values (comma-separated)"}),i.jsx("input",{type:"text",value:((C=n.values)==null?void 0:C.join(", "))??"",onChange:v=>d({...n,values:v.target.value.split(",").map(w=>w.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:To})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:ba,children:"Sub-group"}),i.jsx("input",{type:"text",value:r??"",onChange:v=>h(v.target.value||void 0),placeholder:"e.g. build, verify",className:To})]}),i.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function AF(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function LF(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const pc="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",cC="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Ao="block text-[11px] text-text-secondary mb-0.5",uC=[];function RN({isOpen:e,onClose:t,initialEditId:n}){var _e,rt;const r=kt(fe=>fe.defaults),a=kt(fe=>fe.userItems),l=kt(fe=>fe.projectItems),u=kt(fe=>fe.loading),c=kt(fe=>fe.templateVariables),d=kt(fe=>fe.fetchWorkflows),h=kt(fe=>fe.fetchWorkflow),p=kt(fe=>fe.fetchDefaultContent),m=kt(fe=>fe.fetchTemplateVariables),x=kt(fe=>fe.createWorkflow),y=kt(fe=>fe.updateWorkflow),S=kt(fe=>fe.deleteWorkflow),{requestDelete:C,clearConfirm:v,isConfirming:w}=Gc(),[_,b]=N.useState("list"),[k,E]=N.useState(null),[T,D]=N.useState(!1),[L,R]=N.useState(null),[M,W]=N.useState(null),[z,H]=N.useState(""),[I,U]=N.useState(""),[V,Z]=N.useState(""),[ee,F]=N.useState("1.0.0"),[O,B]=N.useState("#3b82f6"),[q,$]=N.useState(""),[Y,Q]=N.useState(50),[X,K]=N.useState(uC),[P,J]=N.useState({type:"always"}),[ne,ce]=N.useState([]),[ae,Ee]=N.useState("user"),[ve,Le]=N.useState(""),[Me,ke]=N.useState(!1),Ge=gt(fe=>fe.defaults),Xe=gt(fe=>fe.userItems),Se=gt(fe=>fe.projectItems),Ie=N.useMemo(()=>[...Ge,...Xe,...Se],[Ge,Xe,Se]),it=gt(fe=>fe.fetchAgents),[ge]=N.useState(null);N.useEffect(()=>{e&&(d(),m(),it(),R(null),W(null),n?r.some(we=>we.id===n)?p(n).then(we=>{we&&Fe({...we,metadata:{...we.metadata,name:we.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):h(n).then(we=>{we&&Fe(we,{editingId:n,isReadOnly:!1})}):(b("list"),E(null),D(!1)))},[e,d,h,p,m,n]);const Fe=(fe,we)=>{H(fe.metadata.name),U(fe.metadata.id),Z(fe.metadata.description),F(fe.metadata.version),B(fe.metadata.color??"#3b82f6"),$(fe.entryStep),Q(fe.settings.maxIterations),K(fe.steps),J(fe.startCondition??{type:"always"}),ce(fe.metadata.parameters??[]),Le(""),(we==null?void 0:we.editingId)!==void 0&&E(we.editingId),(we==null?void 0:we.isReadOnly)!==void 0&&D(we.isReadOnly),(we==null?void 0:we.selectedNodeKey)!==void 0&&R(null),(we==null?void 0:we.selectedEdgeKey)!==void 0&&W(null),b("edit")},He=async fe=>{const we=await h(fe);we&&Fe(we,{editingId:fe,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},ie=async()=>{var at;const fe=k??I;if(!fe||!z)return Le("Name is required."),!1;if(X.length===0)return Le("Add at least one step."),!1;const we=ne.find(dt=>!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(dt.id));if(we)return Le(`Invalid parameter ID "${we.id}". Use letters, digits, and underscores only.`),!1;let Be=q;if(!Be||!X.some(dt=>dt.id===Be)){if(Be=((at=X.find(dt=>dt.id))==null?void 0:at.id)??"",!Be)return Le("All steps need an ID."),!1;$(Be)}ke(!0),Le("");const Qe={metadata:{id:fe,name:z,description:V,version:ee||"1.0.0",color:O,...ne.length>0?{parameters:ne}:{}},entryStep:Be,settings:{maxIterations:Y},steps:X,startCondition:P},Je=k?await y(k,Qe):await x(Qe,ae);return ke(!1),Je.success?(k||E(fe),!0):(Le(Je.error??"Failed to save."),!1)},xe=async()=>{await ie()},se=async()=>{await ie()&&(n?t():b("list"))},he=()=>{n?t():b("list")},Pe=fe=>{H(fe),k||U(AF(fe))},qe=async fe=>r.some(Be=>Be.id===fe)?await p(fe):await h(fe),Ke=async fe=>{const we=await qe(fe);we&&Fe({...we,metadata:{...we.metadata,name:we.metadata.name+" (copy)",id:`${fe}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},et=()=>{E(null),H(""),U(""),Z(""),F("1.0.0"),B("#3b82f6"),$(""),Q(50),K(structuredClone(uC)),J({type:"always"}),ce([]),Ee("user"),Le(""),R(null),W(null),D(!1),b("edit")},ot=async fe=>{await S(fe),v()},ue=N.useCallback(fe=>{R(fe),W(null)},[]),$e=N.useCallback(fe=>{W(fe),R(null)},[]),ut=L!==null?Number(L):-1,ct=ut>=0?X[ut]??null:null,cn=N.useCallback(fe=>{K(we=>we.map((Be,Qe)=>Qe===ut?fe:Be))},[ut]),Xt=P.type==="step_result"?`${P.result}`:P.type==="metadata_all_match"?`${P.key??"?"}=${P.value??"?"}`:P.type==="metadata_all_in"?`${P.key??"?"} in [${((_e=P.values)==null?void 0:_e.join(","))??"?"}]`:LN[P.type]??P.type,rn=()=>{const fe=X.length,we=LF(X),Be=Ie.find(Qe=>!Qe.subagent);K([...X,{id:we,name:(Be==null?void 0:Be.name)??"Agent",type:"agent",phase:"build",agentId:(Be==null?void 0:Be.id)??"builder",transitions:[]}]),q||$(we),ue(String(fe))},On=N.useCallback((fe,we)=>{fe==="$start"?($(we),$e("start")):K(Be=>{const Qe=Be.find(at=>at.id===fe),Je=Qe?Qe.transitions.length:0;return $e(`${fe}:${Je}`),Be.map(at=>at.id===fe?{...at,transitions:[...at.transitions,{when:{type:"always"},goto:we}]}:at)})},[$e]),ye=fe=>{if(fe==="start")return null;const we=fe.lastIndexOf(":"),Be=fe.slice(0,we),Qe=parseInt(fe.slice(we+1));return{stepId:Be,transIdx:Qe}},Ye=N.useCallback((fe,we)=>{const Be=ye(fe);Be&&K(Qe=>Qe.map(Je=>Je.id===Be.stepId?{...Je,transitions:Je.transitions.map((at,dt)=>dt===Be.transIdx?we(at):at)}:Je))},[]),We=N.useCallback((fe,we)=>{if(fe==="start"){$(we);return}Ye(fe,Be=>({...Be,goto:we}))},[Ye]),ze=N.useCallback((fe,we)=>{const Be=ye(fe);Be&&(K(Qe=>{const Je=Qe.find(dt=>dt.id===Be.stepId);if(!Je)return Qe;const at=Je.transitions[Be.transIdx];return at?Qe.map(dt=>dt.id===Be.stepId?{...dt,transitions:dt.transitions.filter((sn,kn)=>kn!==Be.transIdx)}:dt.id===we?{...dt,transitions:[...dt.transitions,at]}:dt):Qe}),W(null))},[]),tt=N.useCallback(fe=>{if(fe==="start"){$(""),W(null);return}const we=ye(fe);we&&(K(Be=>Be.map(Qe=>Qe.id===we.stepId?{...Qe,transitions:Qe.transitions.filter((Je,at)=>at!==we.transIdx)}:Qe)),W(null))},[]),Lt=N.useCallback((fe,we)=>{if(fe==="start"){J(we);return}Ye(fe,Be=>({...Be,when:we}))},[Ye]),hn=N.useCallback((fe,we)=>{fe!=="start"&&Ye(fe,Be=>({...Be,subGroup:we||void 0}))},[Ye]),fn=fe=>rb(fe,Ie).name,Kn=()=>{if(!M)return null;if(M==="start"){const sn=X.find(kn=>kn.id===q);return{type:"start",fromLabel:"Start",toLabel:sn?fn(sn):"(none)",condition:P}}const fe=M.lastIndexOf(":"),we=M.slice(0,fe),Be=parseInt(M.slice(fe+1)),Qe=X.find(sn=>sn.id===we);if(!Qe)return null;const Je=Qe.transitions[Be];if(!Je)return null;const at=X.find(sn=>sn.id===Je.goto),dt=Je.goto==="$done"?"Done":at?fn(at):Je.goto;return{type:"step",fromLabel:fn(Qe),toLabel:dt,condition:Je.when,subGroup:Je.subGroup}};if(_==="edit"){const fe=Kn();return i.jsxs(Tt,{isOpen:e,onClose:he,title:T?z:k?"Edit Workflow":"New Workflow",size:"full",children:[ve&&i.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:ve}),i.jsx(jF,{formName:z,formId:I,formDescription:V,formMaxIterations:Y,formColor:O,isReadOnly:T,onNameChange:Pe,onDescriptionChange:Z,onMaxIterationsChange:Q,onColorChange:B}),!T&&i.jsx("div",{className:"mb-3 pb-3 border-b border-border",children:i.jsxs(SF,{title:`Parameters (${ne.length})`,children:[ne.map((we,Be)=>i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{value:we.id,onChange:Qe=>{const Je=[...ne];Je[Be]={...we,id:Qe.target.value},ce(Je)},placeholder:"ID",className:"w-28 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"}),i.jsx("input",{value:we.label,onChange:Qe=>{const Je=[...ne];Je[Be]={...we,label:Qe.target.value},ce(Je)},placeholder:"Label",className:"w-36 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary"}),i.jsx("input",{value:we.description??"",onChange:Qe=>{const Je=[...ne];Je[Be]={...we,description:Qe.target.value||void 0},ce(Je)},placeholder:"Description",className:"flex-1 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary"}),i.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-text-muted whitespace-nowrap",children:[i.jsx("input",{type:"checkbox",checked:we.required??!1,onChange:Qe=>{const Je=[...ne];Je[Be]={...we,required:Qe.target.checked||void 0},ce(Je)},className:"rounded border-border"}),"Req."]}),i.jsxs("div",{className:"flex gap-0.5",children:[i.jsx("button",{onClick:()=>{Be!==0&&ce(ne.map((Qe,Je)=>Je===Be?{...ne[Be-1],position:Je}:Je===Be-1?{...ne[Be],position:Je}:{...Qe,position:Je}))},disabled:Be===0,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move up","aria-label":`Move ${we.label||we.id} up`,children:"▲"}),i.jsx("button",{onClick:()=>{Be!==ne.length-1&&ce(ne.map((Qe,Je)=>Je===Be?{...ne[Be+1],position:Je}:Je===Be+1?{...ne[Be],position:Je}:{...Qe,position:Je}))},disabled:Be===ne.length-1,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move down","aria-label":`Move ${we.label||we.id} down`,children:"▼"})]}),i.jsx("button",{onClick:()=>ce(ne.filter((Qe,Je)=>Je!==Be)),className:"p-1 text-text-muted hover:text-accent-error transition-colors",title:"Remove parameter",children:"✕"})]},we.id)),i.jsx("button",{onClick:()=>{const we=`param_${ne.length+1}`;ce([...ne,{id:we,label:"",description:"",required:!1}])},className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:"+ Add parameter"})]})}),!k&&!T&&i.jsx(qh,{value:ae,onChange:Ee}),i.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[i.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[i.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),!T&&i.jsx("button",{onClick:rn,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),i.jsxs(Ze,{className:"flex-1 min-h-0 p-2",children:[i.jsx(kF,{steps:X,entryStep:q,selectedNodeId:(ct==null?void 0:ct.id)??null,selectedEdgeKey:M,startConditionLabel:Xt,agentTypes:Ie,isReadOnly:T,onSelectNode:we=>{if(we===null){ue(null);return}const Be=X.findIndex(Qe=>Qe.id===we);ue(Be>=0?String(Be):null)},onSelectEdge:$e,onRemoveStep:we=>{var Qe;const Be=X.findIndex(Je=>Je.id===we);if(K(Je=>Je.filter(at=>at.id!==we)),ut===Be&&ue(null),q===we){const Je=X.filter(at=>at.id!==we);$(((Qe=Je[0])==null?void 0:Qe.id)??"")}},onCreateTransition:On,onReconnectTo:We,onReconnectFrom:ze,onDeleteTransition:tt}),X.length===0&&i.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[i.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),i.jsx("button",{onClick:rn,className:"px-3 py-1.5 rounded bg-accent-primary/10 text-accent-primary text-xs hover:bg-accent-primary/20",children:"+ Add your first step"})]})]})]}),i.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[i.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:i.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),i.jsx(Ze,{className:"p-3 flex-1 min-h-0",children:T&&(fe||ct)?i.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):fe?fe.type==="start"?i.jsxs("div",{className:"space-y-3 text-sm",children:[i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),q&&i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[i.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),i.jsx(Ok,{}),i.jsx("span",{className:"text-text-primary font-medium",children:fe.toLabel})]}),i.jsxs("div",{children:[i.jsx("label",{className:Ao,children:"Activation Condition"}),i.jsx("select",{value:P.type,onChange:we=>J(we.target.value==="step_result"?{type:"step_result",result:"success"}:we.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:we.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:we.target.value}),className:cC,children:DN.map(we=>i.jsx("option",{value:we.value,children:we.label},we.value))})]}),P.type==="step_result"&&i.jsxs("div",{children:[i.jsx("label",{className:Ao,children:"Result"}),q&&(()=>{const we=X.find(at=>at.id===q),Be=we&&(we.type==="sub_agent"||we.type==="agent")?Ie.find(at=>at.id===(we.type==="sub_agent"?we.subAgentType:we.agentId)):void 0,Qe=(Be==null?void 0:Be.results)&&Be.results.length>0,Je=(Be==null?void 0:Be.results)??[];return Qe?i.jsx("select",{value:P.result??Je[0],onChange:at=>J({type:"step_result",result:at.target.value}),className:cC,children:Je.map(at=>i.jsx("option",{value:at,children:at},at))}):i.jsx("input",{type:"text",value:P.result??"success",onChange:at=>J({type:"step_result",result:at.target.value}),placeholder:"e.g. success, passed, failed",className:pc})})()]}),(P.type==="metadata_all_match"||P.type==="metadata_all_in")&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:Ao,children:"Metadata Key"}),i.jsx("input",{type:"text",value:P.key??"",onChange:we=>J({...P,key:we.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:pc})]}),i.jsxs("div",{children:[i.jsx("label",{className:Ao,children:"Field"}),i.jsx("input",{type:"text",value:P.field??"",onChange:we=>J({...P,field:we.target.value}),placeholder:"e.g. status",className:pc})]}),P.type==="metadata_all_match"?i.jsxs("div",{children:[i.jsx("label",{className:Ao,children:"Value"}),i.jsx("input",{type:"text",value:P.value??"",onChange:we=>J({...P,value:we.target.value}),placeholder:"e.g. passed, resolved",className:pc})]}):i.jsxs("div",{children:[i.jsx("label",{className:Ao,children:"Values (comma-separated)"}),i.jsx("input",{type:"text",value:((rt=P.values)==null?void 0:rt.join(", "))??"",onChange:we=>J({...P,values:we.target.value.split(",").map(Be=>Be.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:pc})]})]}),i.jsx("p",{className:"text-text-muted text-[10px]",children:"Workflow only proceeds when this condition is met. Drag the target handle to change entry step."})]}):(()=>{const we=ye(M),Be=we==null?void 0:we.stepId,Qe=(we==null?void 0:we.transIdx)??0,Je=Be?X.find(dt=>dt.id===Be):void 0,at=(Je==null?void 0:Je.transitions.length)??0;return i.jsx(TF,{fromLabel:fe.fromLabel,toLabel:fe.toLabel,condition:fe.condition,subGroup:"subGroup"in fe?fe.subGroup:void 0,fromStep:fe.type==="step"?X.find(dt=>dt.id===fe.fromLabel):void 0,agentTypes:Ie,transitionIndex:Qe,totalTransitions:at,onUpdateCondition:dt=>Lt(M,dt),onUpdateSubGroup:dt=>hn(M,dt),onDelete:()=>tt(M),onMoveUp:()=>{K(dt=>{const sn=dt.find(fr=>fr.id===Be);if(!sn||Qe===0)return dt;const kn=[...sn.transitions];return[kn[Qe-1],kn[Qe]]=[kn[Qe],kn[Qe-1]],dt.map(fr=>fr.id===Be?{...fr,transitions:kn}:fr)}),W(`${Be}:${Qe-1}`)},onMoveDown:()=>{K(dt=>{const sn=dt.find(fr=>fr.id===Be);if(!sn||Qe===sn.transitions.length-1)return dt;const kn=[...sn.transitions];return[kn[Qe],kn[Qe+1]]=[kn[Qe+1],kn[Qe]],dt.map(fr=>fr.id===Be?{...fr,transitions:kn}:fr)}),W(`${Be}:${Qe+1}`)}})})():ct?i.jsx(NF,{step:ct,isEntry:ct.id===q,agentTypes:Ie,transitionCount:ct.transitions.length,templateVariables:c,onUpdate:cn,onRemove:()=>{var we;if(ct&&(K(X.filter((Be,Qe)=>Qe!==ut)),ue(null),q===ct.id)){const Be=X.filter((Qe,Je)=>Je!==ut);$(((we=Be[0])==null?void 0:we.id)??"")}},onSetEntry:()=>$(ct.id)}):i.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",i.jsx("br",{}),"Drag from a port to connect."]})})]})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[i.jsx(mt,{variant:"secondary",onClick:he,children:"Close"}),T?i.jsx(mt,{variant:"primary",onClick:()=>{H(z+" (copy)"),U(`${k}-copy-${Date.now()}`),E(null),D(!1)},children:"Duplicate & Customize"}):i.jsxs(i.Fragment,{children:[i.jsx(mt,{variant:"primary",onClick:xe,children:"Save"}),i.jsx(mt,{variant:"primary",onClick:se,children:"Save & Close"})]})]})]})}return i.jsx(Tt,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:i.jsx(qk,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:et,loading:u,hasItems:r.length>0||a.length>0||l.length>0,children:i.jsxs("div",{className:"space-y-4",children:[i.jsx(Ig,{title:"Built-in",items:r,renderActions:fe=>i.jsx(i.Fragment,{children:i.jsx(ti,{onClick:()=>Ke(fe.id),children:i.jsx(sy,{})})})}),i.jsx(Ig,{title:"Custom",items:a,renderActions:fe=>i.jsxs(i.Fragment,{children:[i.jsx(ti,{onClick:()=>He(fe.id),children:i.jsx("span",{className:"text-[10px]",children:"Edit"})}),i.jsx(Rc,{onClick:()=>Ke(fe.id)}),w(fe.id,"delete")?i.jsx(oh,{onConfirm:()=>ot(fe.id),onCancel:v}):i.jsx(lh,{onClick:()=>C(fe.id)})]})}),l.length>0&&i.jsx(Ig,{title:"Project",items:l,renderActions:fe=>i.jsxs(i.Fragment,{children:[i.jsx(ti,{onClick:()=>He(fe.id),children:i.jsx("span",{className:"text-[10px]",children:"Edit"})}),i.jsx(Rc,{onClick:()=>Ke(fe.id)}),w(fe.id,"delete")?i.jsx(oh,{onConfirm:()=>ot(fe.id),onCancel:v}):i.jsx(lh,{onClick:()=>C(fe.id)})]})})]})})})}function DF(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function RF({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:a,onCloseCompleteAction:l,textareaContent:u,onSearchMessages:c,onToggleAutoScroll:d,isAutoScrollActive:h}){const[,p]=zn(),m=on($=>$.fetchCommands),x=kt($=>$.fetchWorkflows),y=gt($=>$.fetchAgents),S=on($=>$.defaults),C=on($=>$.userItems),v=on($=>$.projectItems),w=kt($=>$.defaults),_=kt($=>$.userItems),b=kt($=>$.projectItems),k=gt($=>$.defaults),E=gt($=>$.userItems),T=gt($=>$.projectItems),D=Re($=>{var Y;return(Y=$.currentSession)==null?void 0:Y.mode}),L=Re($=>{var Y;return((Y=$.currentSession)==null?void 0:Y.dangerLevel)??"normal"}),R=Re($=>$.switchMode),M=Re($=>$.switchDangerLevel),W=Re($=>{var Y;return(Y=$.currentSession)==null?void 0:Y.projectId}),z=N.useRef(void 0),[H,I]=N.useState(""),[U,V]=N.useState(0),Z=N.useRef(null),ee=N.useRef(!1);N.useEffect(()=>{e&&(ee.current=!0)},[e]),N.useEffect(()=>{if(e){m(),x(),y(),I(""),V(0);const $=setTimeout(()=>{var Y;return(Y=Z.current)==null?void 0:Y.focus()},50);return()=>clearTimeout($)}},[e,m,x,y]),N.useEffect(()=>{var $;!e&&ee.current&&(n==null||n(),($=z.current)==null||$.call(z),z.current=void 0)},[e,n]);const O=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const $=W??DF(window.location.pathname);$&&p(`/p/${$}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{z.current=l,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),c==null||c()}},{id:"toggle-autoscroll",name:h?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),d==null||d(!h)}},...ys(ys(k,E),T).filter($=>!$.subagent&&$.id!==D).map($=>({id:$.id,name:$.name,prefix:"Agent > Switch to",action:()=>R($.id)})),...ys(ys(S,C),v).map($=>({id:$.id,name:$.name,prefix:"Command > Launch",action:()=>r($.id,u)})),...ys(ys(w,_),b).map($=>({id:$.id,name:$.name,prefix:"Workflow > Run",action:()=>a($.id)})),...["normal","dangerous"].filter($=>$!==L).map($=>({id:$,name:$.charAt(0).toUpperCase()+$.slice(1),prefix:"Mode > Switch to",action:()=>M($)}))].filter($=>Pi(`${$.prefix} ${$.name}`,H)),B=O.length-1,q=$=>{Q2($,B,V,()=>{var Y;(Y=O[U])==null||Y.action(),t()},t)};return e?si.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[i.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),i.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[i.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[i.jsx("input",{ref:Z,type:"text",value:H,onChange:$=>{I($.target.value),V(0)},onKeyDown:q,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),i.jsx(ly,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),i.jsx(Ze,{className:"max-h-[60vh] p-2",children:O.length===0?i.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:S.length+C.length+w.length+_.length>0?"No matches":"No agents, commands, or workflows yet"}):O.map(($,Y)=>i.jsxs("button",{type:"button",onClick:()=>{$.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${Y===U?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:[i.jsxs("span",{className:"text-text-muted font-normal",children:[$.prefix," "]}),i.jsx("span",{children:$.name})]},$.id))})]})]}),document.body):null}const ON="openfox-message-search-filters",OF=[{key:"user",label:"User prompts"},{key:"thinking",label:"Thinking"},{key:"response",label:"Responses"}];function IF(){try{const e=localStorage.getItem(ON);if(e){const t=JSON.parse(e);return new Set(t)}}catch{}return new Set(["user","thinking","response"])}function MF(e){localStorage.setItem(ON,JSON.stringify([...e]))}function PF(e){var n,r;if(e.type!=="message")return null;const t=e.message;if(t.role==="user")return"user";if(t.role==="assistant"){if((n=t.content)!=null&&n.trim())return"response";if((r=t.thinkingContent)!=null&&r.trim())return"thinking"}return null}function BF(e){const t=new Date(e),n=new Date;if(t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear())return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});const a=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0"),c=String(t.getHours()).padStart(2,"0"),d=String(t.getMinutes()).padStart(2,"0");return`${a}/${l}/${u} ${c}:${d}`}function $F(e){var t;if(e.type==="message")return e.message.timestamp;if(e.type==="subagent")return(t=e.messages[0])==null?void 0:t.timestamp}function zF(e){var t,n;if(e.type==="message"){const r=e.message;if(r.role==="assistant"){const a=(t=r.content)==null?void 0:t.trim();return((n=r.thinkingContent)==null?void 0:n.trim())&&!a?"italic text-text-muted":""}if(r.role==="user")return"font-bold"}return""}function HF(e){var n,r;if(e.type!=="message")return i.jsx(YS,{className:"w-3.5 h-3.5"});const t=e.message;return t.role==="assistant"?(n=t.thinkingContent)!=null&&n.trim()&&!((r=t.content)!=null&&r.trim())?i.jsx(KR,{className:"w-3.5 h-3.5"}):i.jsx(YS,{className:"w-3.5 h-3.5"}):i.jsx(qR,{className:"w-3.5 h-3.5"})}function dC(e){var t;if(e.type==="message"){const n=e.message,r=n.content||"",a=r.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(n.messageKind==="workflow-started")try{return`Workflow: ${JSON.parse(r).workflowName}`}catch{return"Workflow started"}if(n.messageKind==="task-completed")return"Task completed";if(n.messageKind==="auto-prompt")return"Auto-prompt";if(n.messageKind==="correction")return"Correction";if(n.messageKind==="context-reset")return"Context reset";if(n.messageKind==="command")return"Command executed";if(n.role==="assistant")return a?a.slice(0,200):(t=n.thinkingContent)!=null&&t.trim()?n.thinkingContent.slice(0,200):"";const l=a.slice(0,200);return l.length<a.length?`${l}...`:l}return e.type==="subagent"?`Sub-agent: ${e.subAgentType}`:""}function FF({isOpen:e,onClose:t,displayItems:n,onNavigate:r}){const[a,l]=N.useState(""),[u,c]=N.useState(0),[d,h]=N.useState(IF),p=N.useRef(null),m=N.useRef(null),x=N.useRef(null),y=E=>{h(T=>{const D=new Set(T);return D.has(E)?D.delete(E):D.add(E),MF(D),D})},S=N.useMemo(()=>n.filter(E=>{var T,D;return!(E.type==="context-divider"||E.type==="message"&&(E.message.messageKind==="auto-prompt"||E.message.role==="assistant"&&!((T=E.message.content)!=null&&T.trim())&&!((D=E.message.thinkingContent)!=null&&D.trim())))}),[n]),C=N.useMemo(()=>S.filter(E=>{const T=PF(E);return!(T&&!d.has(T))}),[S,d]),v=N.useMemo(()=>a?S.filter(E=>{const T=dC(E);return Pi(T,a)}):C,[C,a]),w=v.length-1;N.useEffect(()=>{if(e){l(""),c(0);const E=setTimeout(()=>{var T;return(T=p.current)==null?void 0:T.focus()},50);return()=>clearTimeout(E)}},[e]),N.useEffect(()=>{var E;if(e&&m.current){const T=(E=m.current.osInstance())==null?void 0:E.elements().viewport;T&&(T.scrollTop=T.scrollHeight)}},[e]),N.useEffect(()=>{x.current&&x.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[u]);const _=E=>{Q2(E,w,c,()=>{const T=v[u];if(T){const D=n.indexOf(T);D>=0&&r(D),t()}},t)},b=E=>{const T=n.indexOf(E);T>=0&&r(T),t()},k=E=>n.indexOf(E);return e?si.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[i.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),i.jsxs("div",{className:"relative w-full max-w-lg bg-bg-secondary border border-border rounded shadow-xl",children:[i.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[i.jsx(Vi,{}),i.jsx("input",{ref:p,type:"text",value:a,onChange:E=>{l(E.target.value),c(0)},onKeyDown:_,placeholder:"Search timeline...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),i.jsx("button",{type:"button",onClick:t,className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Close",children:i.jsx(ri,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"flex gap-1.5 px-4 py-2 border-b border-border",children:OF.map(E=>{const T=d.has(E.key);return i.jsx("button",{type:"button",onClick:()=>y(E.key),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${T?"bg-accent-primary/20 text-accent-primary border border-accent-primary/40":"bg-bg-tertiary text-text-muted border border-border hover:text-text-secondary"}`,children:E.label},E.key)})}),i.jsx(Ze,{ref:m,className:"max-h-[60vh] p-2",children:v.length===0?i.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:C.length>0?"No matches":"No messages yet"}):v.map((E,T)=>{const D=k(E),L=HF(E),R=dC(E),M=zF(E),W=$F(E),z=E.type==="message"&&E.message.role==="user";return i.jsx("button",{ref:T===u?x:null,type:"button",onClick:()=>b(E),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${T===u?"bg-accent-primary/20 text-text-primary":z?"bg-accent-primary/5 text-text-secondary hover:bg-accent-primary/10 hover:text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[i.jsx("span",{className:"flex-shrink-0",children:L}),i.jsx("span",{className:`truncate flex-1 ${M}`,children:R})]}),W&&i.jsx("span",{className:"text-text-muted text-xs shrink-0",children:BF(W)})]})},`${D}-${E.type}`)})})]})]}),document.body):null}function IN(e){const t=new Set,n=[],r=/\{\{(\w+)\}\}/g;let a;for(;(a=r.exec(e))!==null;){const l=a[1];t.has(l)||(t.add(l),n.push(l))}return n}function UF(e,t,n){const r=e.trim();if(!r.startsWith("/"))return null;const a=r.slice(1).split(/\s+/),l=a[0];if(!l)return null;const u=a.slice(1),c={},d=t.find(h=>h.id===l);return d?(d.parameters&&d.parameters.length>0?[...d.parameters].sort((p,m)=>(p.position??0)-(m.position??0)).forEach((p,m)=>{u[m]!==void 0&&(c[p.id]=u[m])}):u.forEach((h,p)=>{c[String(p)]=h}),{workflowId:l,params:c}):n&&n.find(p=>p.id===l)?(u.forEach((p,m)=>{c[String(m)]=p}),{commandId:l,params:c}):null}function VF({attachment:e,onRemove:t}){const n=EN(e.filename);return i.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[i.jsx(eu,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),jN(e.mimeType)?i.jsx("img",{src:e.data,alt:e.description||e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}):i.jsx("div",{className:"w-16 h-16 flex items-center justify-center rounded-md bg-bg-secondary text-xs font-bold text-text-muted",children:n}),i.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),i.jsx("div",{className:"text-[10px] text-text-muted",children:$o(e.size)})]})}function WF({history:e,selectedIndex:t,onSelect:n,onEscape:r,onNavigate:a}){const l=N.useRef(null),u=N.useRef(null);N.useEffect(()=>{var h;u.current&&((h=l.current)!=null&&h.getElement())&&u.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[t]);const c=h=>{switch(h.key){case"Enter":h.preventDefault(),e[t]&&n(e[t].content);break;case"Escape":h.preventDefault(),r();break;case"ArrowUp":h.preventDefault(),a("up");break;case"ArrowDown":h.preventDefault(),a("down");break}},d=h=>{n(h)};return i.jsx(Ze,{ref:l,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg max-h-64",onKeyDown:c,children:e.map((h,p)=>i.jsxs("div",{ref:p===t?u:null,role:"listitem",onClick:()=>d(h.content),className:`
|
|
315
|
+
p-2 rounded cursor-pointer transition-colors
|
|
316
|
+
${p===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
|
|
317
|
+
`,children:[i.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[h.formattedTimestamp,h.sessionName&&i.jsxs(i.Fragment,{children:[" | ",i.jsx("span",{className:"text-accent-primary font-medium",children:h.sessionName})]})]}),i.jsx("div",{className:"text-sm text-text-primary mt-1",children:h.trimmedContent})]},h.id))})}function GF(){const e=CR(),t=e?"bg-amber-400":"bg-accent-primary";return i.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsxs("span",{className:"flex gap-0.5",children:[i.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"0ms"}}),i.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"150ms"}}),i.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"300ms"}})]}),i.jsx("span",{className:"text-text-secondary",children:e?"Running... (abort in progress)":"Running"})]}),!e&&i.jsx("span",{className:"text-text-muted hidden sm:inline",children:"esc to interrupt"})]})}function qF(){const e=Re(u=>u.activeWorkflowExecution),t=Re(u=>u.exitWorkflow),[n,r]=N.useState(!1);N.useEffect(()=>{r(!1)},[e==null?void 0:e.id]);const a=N.useCallback(()=>{n||(r(!0),t())},[n,t]);if(!e||e.status!=="running"&&e.status!=="waiting")return null;const l=e.workflowColor&&/^#[0-9a-fA-F]{6}$/.test(e.workflowColor)?e.workflowColor:"#3b82f6";return i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs border-b border-border",children:[i.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:l}}),i.jsx("span",{className:"font-medium text-text-primary truncate",children:e.workflowName}),e.currentStepName&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsx("span",{className:"text-text-muted truncate",children:e.currentStepName})]}),i.jsx("div",{className:"ml-auto shrink-0",children:i.jsx("button",{onClick:a,disabled:n,className:"text-xs px-2 py-0.5 rounded text-text-tool-error hover:bg-text-tool-error/10 transition-colors disabled:opacity-50",children:n?"Exiting...":"✕ Exit"})})]})}const KF={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function YF(e,t={}){const n={...KF,...t};if(!e.type.startsWith("image/"))throw new Error("File is not an image");if(!["image/png","image/jpeg","image/gif"].includes(e.type))throw new Error(`Unsupported image format: ${e.type}. Only PNG, JPG, and GIF are supported.`);if(e.size<=n.maxSizeBytes){const a=await e.arrayBuffer(),l=nU(a),u=`data:${e.type};base64,${l}`,c=await MN(u);return{dataUrl:u,mimeType:e.type,size:e.size,width:c.width,height:c.height}}return await XF(e,n)}async function XF(e,t){const n=await JF(e),r=await MN(n),{width:a,height:l}=QF(r.width,r.height,t.maxWidth,t.maxHeight),u=ZF();u.width=a,u.height=l;const c=u.getContext("2d");if(!c)throw new Error("Failed to get canvas context");c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="high",c.drawImage(r,0,0,a,l);let d=t.quality,h="";for(let m=0;m<10&&(h=u.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,d),!(hC(h)<=t.maxSizeBytes||d<=.3));m++)d-=.1;const p=hC(h);return{dataUrl:h,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:p,width:a,height:l}}function QF(e,t,n,r){const a=e/t;return e>t&&e>n?{width:n,height:Math.round(n/a)}:t>e&&t>r?{width:Math.round(r*a),height:r}:{width:e,height:t}}function JF(e){return new Promise((t,n)=>{const r=tU(),a=new r;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function MN(e){return new Promise((t,n)=>{const r=eU(),a=new r;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function ZF(){var t;const e=sb();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function eU(){const e=sb();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function tU(){const e=sb();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function sb(){return globalThis}function nU(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.byteLength;r++){const a=t[r];a!==void 0&&(n+=String.fromCharCode(a))}return btoa(n)}function hC(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}const fC=50*1024*1024,mC=1024*1024,rU=["image/png","image/jpeg","image/gif"];function sU(e){return e==="application/pdf"}function iU(e){return rU.includes(e.type)}async function aU(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(new Error("Failed to read file")),r.readAsDataURL(e)})}async function pC(e,t,n){try{if(nb(e.type)){if(e.size>mC){n(`Text file too large (${$o(e.size)}). Maximum is ${$o(mC)}.`);return}const r=await e.text(),a={id:Wd(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}else if(Zd(e.type)||sU(e.type)){if(e.size>fC){const r=Zd(e.type)?"Image":"PDF";n(`${r} file too large (${$o(e.size)}). Maximum is ${$o(fC)}.`);return}if(Zd(e.type)&&iU(e)){const r=await YF(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),a={id:Wd(),filename:e.name||"unnamed-file",mimeType:r.mimeType,size:r.size,data:r.dataUrl};t(a)}else{const r=await aU(e),a={id:Wd(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}}else n(`Unsupported file type: ${e.type}. Supported types: images (PNG, JPG, GIF, WebP, BMP, SVG), PDF, text files, JSON, XML, YAML, and other common text-based formats.`)}catch(r){const a=r instanceof Error?r.message??"Failed to process file":"Failed to process file";n(a)}}function PN(e){const t=Re(l=>l.sendMessage),n=Re(l=>l.launchWorkflow),r=N.useCallback((l,u,c)=>{e(!0),t(l,u,c)},[e,t]),a=N.useCallback((l,u,c,d,h)=>{e(!0),n(l,u,c,d,h)},[e,n]);return{sendMessage:r,launchWorkflow:a}}function oU({children:e}){return si.createPortal(e,document.body)}function lU(e){const t=e.startCondition;if(!t||t.type==="always")return!0;switch(t.type){case"step_result":case"metadata_all_match":case"metadata_all_in":return null;default:return null}}function cU({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:r,onOpenWorkflowsManager:a,onAttach:l,textareaContent:u,attachments:c}){const[d,h]=N.useState(!1),[p,m]=N.useState("commands"),[x,y]=N.useState(""),[S,C]=N.useState(0),[v,w]=N.useState(null),[_,b]=N.useState(null),k=N.useRef(null),E=N.useRef(null),T=on(Y=>Y.defaults),D=on(Y=>Y.userItems),L=on(Y=>Y.projectItems),R=on(Y=>Y.fetchCommands),M=kt(Y=>Y.defaults),W=kt(Y=>Y.userItems),z=kt(Y=>Y.projectItems),H=kt(Y=>Y.fetchWorkflows),I=ys(ys(T,D),L),U=ys(ys(M,W),z);N.useEffect(()=>{d&&(p==="commands"?R():p==="workflows"&&H())},[d,p,R,H]),N.useEffect(()=>{d&&(y(""),C(0),requestAnimationFrame(()=>{var Y;return(Y=k.current)==null?void 0:Y.focus()}))},[d,p]),N.useEffect(()=>{if(!d)return;const Y=Q=>{var X;(X=E.current)!=null&&X.contains(Q.target)||h(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[d]);const V=Y=>{switch(Y.key){case"ArrowDown":Y.preventDefault(),C(Q=>{const K=(p==="commands"?I:U).filter(P=>{const J=x.toLowerCase();return!J||P.name.toLowerCase().includes(J)});return Math.min(Q+1,K.length-1)});break;case"ArrowUp":Y.preventDefault(),C(Q=>Math.max(Q-1,0));break;case"Enter":Y.preventDefault();break;case"Escape":Y.preventDefault(),h(!1);break}},Z=Y=>{y(Y),C(0)},ee=I.filter(Y=>!x||Y.name.toLowerCase().includes(x.toLowerCase())),F=U.filter(Y=>!x||Y.name.toLowerCase().includes(x.toLowerCase())),O=async Y=>{const Q=await on.getState().fetchCommand(Y);Q&&e(Q.prompt,Q.metadata.agentMode,u,c),h(!1)},B=Y=>{t(Y),h(!1)},q=(Y,Q)=>{Q.stopPropagation(),h(!1),w(Y)},$=(Y,Q)=>{Q.stopPropagation(),h(!1),b(Y)};return i.jsxs("div",{ref:E,className:"relative",children:[i.jsx("button",{type:"button",onClick:()=>h(!d),className:"px-1.5 py-2 rounded-r bg-bg-secondary text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors border-l border-border/50",title:"More options",children:i.jsx(Bk,{className:"w-4 h-4"})}),d&&i.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-80 max-w-[calc(100vw-2rem)] bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[i.jsxs("div",{className:"flex border-b border-border",children:[i.jsx("button",{type:"button",onClick:()=>{m("commands"),y(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="commands"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Commands"}),i.jsx("button",{type:"button",onClick:()=>{m("workflows"),y(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="workflows"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Workflows"}),i.jsx("button",{type:"button",onClick:()=>m("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),p!=="attach"&&i.jsx("div",{className:"p-2 border-b border-border",children:i.jsx("input",{ref:k,value:x,onChange:Y=>Z(Y.target.value),onKeyDown:V,placeholder:p==="commands"?"Search commands...":"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),i.jsx(Ze,{className:"max-h-64 p-1",children:p==="commands"?ee.length===0?i.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:I.length===0?"No commands yet":"No matches"}):ee.map((Y,Q)=>i.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${Q===S?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[i.jsx("button",{type:"button",onClick:()=>O(Y.id),className:"flex-1 text-left",children:i.jsx("div",{className:"text-sm text-text-primary font-medium",children:Y.name})}),i.jsx(ti,{className:"opacity-0 group-hover:opacity-100",onClick:X=>q(Y.id,X)})]},Y.id)):p==="workflows"?F.length===0?i.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:U.length===0?"No workflows yet":"No matches"}):F.map((Y,Q)=>{const X=lU(Y),K=Y.color??"#3b82f6";return i.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${Q===S?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[i.jsxs("button",{type:"button",onClick:()=>B(Y.id),className:"flex-1 text-left flex items-center gap-2",children:[i.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:K}}),i.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:Y.name}),X!==null&&i.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:X?"#22c55e":"#6b7280"},title:X?"Entry condition met":"Entry condition not met"})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[Y.subGroups&&Y.subGroups.length>0&&i.jsx(uU,{subGroups:Y.subGroups,onSelect:P=>{h(!1),n(Y.id,P)}}),i.jsx(ti,{className:"opacity-0 group-hover:opacity-100",onClick:P=>$(Y.id,P)})]})]},Y.id)}):i.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[i.jsxs("button",{type:"button",onClick:()=>{l(),h(!1)},className:"flex items-center gap-2 px-4 py-2 rounded bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary transition-colors",children:[i.jsx(OR,{className:"w-4 h-4"}),i.jsx("span",{className:"text-sm font-medium",children:"Attach file"})]}),i.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),p!=="attach"&&i.jsx("div",{className:"border-t border-border p-1",children:i.jsx("button",{type:"button",onClick:()=>{h(!1),p==="commands"?r():a()},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:p==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),i.jsx(AN,{isOpen:!!v,onClose:()=>w(null),initialEditId:v}),i.jsx(RN,{isOpen:!!_,onClose:()=>b(null),initialEditId:_})]})}function uU({subGroups:e,onSelect:t}){const[n,r]=N.useState(!1),[a,l]=N.useState({top:0,right:0}),u=N.useRef(null),c=N.useRef(null);yf(c,()=>r(!1),n);const d=h=>{if(h.stopPropagation(),!n&&u.current){const p=u.current.getBoundingClientRect();l({top:p.bottom+4,right:window.innerWidth-p.right})}r(!n)};return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:u,type:"button",onClick:d,className:"p-1 rounded text-text-muted hover:text-text-primary transition-colors",title:"Sub-groups",children:"⋮"}),n&&i.jsx(oU,{children:i.jsx("div",{ref:c,onMouseDown:h=>h.stopPropagation(),className:"fixed w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-[100] overflow-hidden",style:{top:a.top,right:a.right},children:e.map(h=>i.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),t(h)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:h},h))})})]})}function dU({messages:e,onCancel:t}){return e.length===0?null:i.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:e.map(n=>i.jsxs("div",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-xs ${n.mode==="asap"?"bg-amber-500/15 text-amber-300 border border-amber-500/30":"bg-blue-500/15 text-blue-300 border border-blue-500/30"}`,children:[i.jsxs("span",{className:"font-medium",children:[n.mode==="asap"?"ASAP":"Queue",":"]}),i.jsx("span",{className:"truncate max-w-[200px]",children:n.content}),i.jsx(eu,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function hU({agent:e,isBuiltIn:t,isConfirmingDelete:n,alwaysAllowedNames:r,model:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,onCancelDelete:h}){var x;const p=e.allowedTools.filter(y=>!(r!=null&&r.has(y))),m=a?(x=a.split("/").pop())==null?void 0:x.replace(/-/g," "):void 0;return i.jsxs(nj,{isBuiltIn:t,isConfirmingDelete:n,onView:l,onEdit:u,onDuplicate:c,onDelete:d,onCancelDelete:h,children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:e.color??"#6b7280"}}),i.jsx("span",{className:"text-text-primary text-sm font-medium",children:e.name}),i.jsx("span",{className:"text-text-muted text-xs font-mono",children:e.id}),t&&i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"}),m&&i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-accent-primary/10 text-accent-primary",children:m})]}),e.description&&i.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),i.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[p.slice(0,5).map(y=>i.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:y},y)),p.length>5&&i.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",p.length-5," more"]})]})]})}function gC({title:e,agentTitle:t="Agents",subagentTitle:n="Sub-agents",agents:r,subagents:a,isBuiltIn:l,alwaysAllowedNames:u,modelOverrides:c,onView:d,onDuplicate:h,onEdit:p,onDelete:m,onCancelDelete:x,isConfirmingDelete:y}){if(r.length===0&&a.length===0)return null;const S=C=>i.jsx(hU,{agent:C,model:c==null?void 0:c[C.id],isBuiltIn:l,isConfirmingDelete:(y==null?void 0:y(C.id))??!1,alwaysAllowedNames:u,onView:()=>d(C.id),onEdit:p?()=>p(C.id):void 0,onDuplicate:()=>h(C.id),onDelete:l?void 0:()=>m==null?void 0:m(C.id),onCancelDelete:l?void 0:()=>x==null?void 0:x(C.id)},C.id);return i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),r.length>0&&i.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:t}),i.jsxs("div",{className:"space-y-2",children:[r.map(S),a.length>0&&i.jsxs("div",{className:"mt-3",children:[i.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:n}),i.jsx("div",{className:"space-y-2",children:a.map(S)})]})]})]})}function fU(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function mU(e,t){const n=t.toLowerCase(),r=(e.name??"").toLowerCase(),a=e.id.toLowerCase(),l=a.replace(/-/g," ");return r.includes(n)||a.includes(n)||l.includes(n)}function xC(e){return e.models.some(n=>n.selected)?e.models.filter(n=>n.selected):e.models}function BN({providerId:e,modelConfig:t,isActive:n,isDefault:r,disabled:a,hasSession:l,settingDefault:u,highlighted:c,onModelClick:d,onSetDefault:h,onEditModel:p}){var m;return i.jsxs("div",{className:`flex items-center px-4 py-1.5 text-sm transition-colors group ${c?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${a?"opacity-50 cursor-wait":""} ${n?"text-accent-primary":"text-text-secondary"}`,children:[i.jsx("button",{type:"button",onClick:()=>d(e,t.id),disabled:a,className:"flex-1 truncate text-left",children:t.name??((m=t.id.split("/").pop())==null?void 0:m.replace(/-/g," "))??t.id}),i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 ml-2",children:[i.jsx("span",{className:"text-xs text-text-muted",children:fU(t.contextWindow)}),l&&h&&i.jsx("button",{type:"button",onClick:x=>h(x,e,t.id),disabled:u,className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors disabled:opacity-40",title:r?"Default model":"Set as default model",children:r?i.jsx(Fk,{className:"w-3.5 h-3.5 text-accent-warning"}):i.jsx(Uk,{className:"w-3.5 h-3.5 text-text-muted hover:text-accent-warning"})}),p&&i.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),p(e,t)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:i.jsx(Mk,{className:"w-3 h-3 text-text-muted"})}),n&&i.jsx("span",{className:"text-accent-success flex-shrink-0",title:"Session model",children:i.jsx(is,{className:"w-3.5 h-3.5"})})]})]})}function $N({providers:e,onSelect:t,onEscape:n,extraItemCount:r=0}){const[a,l]=N.useState(""),[u,c]=N.useState(-1),d=N.useRef(null),h=N.useRef(null),p=N.useMemo(()=>a.trim()?e.map(S=>({provider:S,models:xC(S).filter(C=>mU(C,a))})).filter(S=>S.models.length>0):e.map(S=>({provider:S,models:xC(S)})),[e,a]),m=N.useMemo(()=>p.flatMap(S=>S.models.map(C=>({providerId:S.provider.id,modelConfig:C}))),[p]),x=m.length+r;return N.useEffect(()=>{x<=1?c(-1):u>=x?c(x-1):u<0&&a.trim()&&c(0)},[x,u,a]),N.useEffect(()=>{u>=0&&d.current&&d.current.scrollIntoView({block:"nearest"})},[u]),{searchQuery:a,setSearchQuery:l,highlightedIndex:u,setHighlightedIndex:c,visibleGroups:p,flatItems:m,totalNavItems:x,handleSearchKeyDown:S=>{switch(S.key){case"Escape":S.preventDefault(),n==null||n();break;case"ArrowDown":S.preventDefault(),x>0&&c(C=>C<x-1?C+1:0);break;case"ArrowUp":S.preventDefault(),x>0&&c(C=>C>0?C-1:x-1);break;case"Home":S.preventDefault(),c(0);break;case"End":S.preventDefault(),c(x-1);break;case"Enter":if(S.preventDefault(),u>=0&&u<m.length){const C=m[u];C&&t(C.providerId,C.modelConfig.id)}break}},highlightedRef:d,inputRef:h}}function zN({providers:e,value:t,onChange:n,defaultLabel:r="Default (global model)"}){var T;const[a,l]=N.useState(!1),u=N.useRef(null),c=N.useRef(null),[d,h]=N.useState({}),p=t==null?void 0:t.split("/").slice(1).join("/"),m=p?((T=p.split("/").pop())==null?void 0:T.replace(/-/g," "))??p:void 0,{searchQuery:x,setSearchQuery:y,highlightedIndex:S,setHighlightedIndex:C,visibleGroups:v,flatItems:w,handleSearchKeyDown:_,highlightedRef:b,inputRef:k}=$N({providers:e,onSelect:(D,L)=>{n(`${D}/${L}`),l(!1)},onEscape:()=>l(!1)}),E=N.useCallback(()=>{if(!a||!c.current)return;const D=c.current.getBoundingClientRect();h({position:"fixed",top:`${D.bottom+4}px`,left:`${D.left}px`,width:`${Math.max(D.width,288)}px`})},[a]);return N.useEffect(()=>(E(),window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}),[E]),N.useEffect(()=>{if(!a)return;function D(R){var M;u.current&&!u.current.contains(R.target)&&!((M=R.target)!=null&&M.closest("[data-model-picker-dropdown]"))&&(l(!1),y(""),C(-1))}const L=setTimeout(()=>{document.addEventListener("mousedown",D)},0);return()=>{clearTimeout(L),document.removeEventListener("mousedown",D)}},[a,y,C]),N.useEffect(()=>{var D;a?(E(),(D=k.current)==null||D.focus()):(y(""),C(-1))},[a,y,C,k,E]),i.jsxs("div",{className:"relative",ref:u,children:[i.jsxs("button",{ref:c,type:"button",onClick:()=>l(!a),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary hover:bg-bg-secondary transition-colors",children:[i.jsx("span",{className:m?"text-text-primary":"text-text-muted",children:m??r}),i.jsx(yn,{className:`w-3 h-3 text-text-muted transition-transform ${a?"rotate-180":""}`})]}),a&&typeof document<"u"&&si.createPortal(i.jsx("div",{"data-model-picker-dropdown":!0,className:"z-50",style:d,children:i.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg flex flex-col max-h-80",children:[i.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[i.jsx(Vi,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),i.jsx("input",{ref:k,type:"text",value:x,onInput:D=>{y(D.currentTarget.value),C(-1)},onKeyDown:_,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),i.jsxs(Ze,{className:"flex-1",children:[i.jsx("button",{type:"button",onClick:()=>{n(void 0),l(!1)},className:`w-full text-left px-4 py-2 text-sm transition-colors hover:bg-bg-tertiary ${t?"text-text-muted":"text-accent-primary bg-accent-primary/5"}`,children:r}),v.map(D=>i.jsxs("div",{children:[i.jsx("div",{className:"px-4 py-1.5 text-xs font-medium text-text-muted uppercase tracking-wider bg-bg-tertiary/50",children:D.provider.name}),D.models.map(L=>{const M=w.findIndex(z=>z.providerId===D.provider.id&&z.modelConfig.id===L.id)===S,W=t===`${D.provider.id}/${L.id}`;return i.jsx("div",{ref:M?b:void 0,children:i.jsx(BN,{providerId:D.provider.id,modelConfig:L,isActive:W,highlighted:M,onModelClick:(z,H)=>{n(`${z}/${H}`),l(!1)}})},`${D.provider.id}/${L.id}`)})]},D.provider.id)),v.length===0&&x.trim()&&i.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No models match your search"})]})]})}),document.body)]})}function pU(e){const t=new Map;for(const n of e){const r=n.indexOf(":");if(r===-1)t.set(n,new Set);else{const a=n.slice(0,r),u=n.slice(r+1).split(",").filter(Boolean);t.set(a,new Set(u))}}return t}function zd(e){const t=[];for(const[n,r]of e)r.size===0?t.push(n):t.push(`${n}:${[...r].join(",")}`);return t}function gU({formName:e,formId:t,formDescription:n,formSubagent:r,formTools:a,formColor:l,formModel:u,formPrompt:c,formError:d,isReadOnly:h,availableTools:p,providers:m,onNameChange:x,onIdChange:y,onDescriptionChange:S,onSubagentChange:C,onToolsChange:v,onColorChange:w,onModelChange:_,onPromptChange:b}){const k=pU(a),E=p.filter(M=>!(r&&M.topLevelOnly)&&!M.isMcp),T=p.filter(M=>M.isMcp&&!(r&&M.topLevelOnly)),D=new Map;for(const M of T){const W=M.mcpServer??M.name,z=D.get(W)??[];z.push(M),D.set(W,z)}const L=(M,W)=>{const z=new Map(k),H=z.get(M)||new Set,I=new Set(H);I.has(W)?I.delete(W):I.add(W),I.size===0?z.set(M,new Set):z.set(M,I),v(zd(z))},R=M=>{const W=new Map(k);W.has(M)?W.delete(M):W.set(M,new Set),v(zd(W))};return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"space-y-3",children:[d&&i.jsx(Fo,{message:d}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(Fr,{label:"Name",value:e,onChange:x,placeholder:"My Agent",readOnly:h}),i.jsx(Fr,{label:"ID",value:t,onChange:y,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(Fr,{label:"Description",value:n,onChange:S,placeholder:"What this agent does",readOnly:h}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),i.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[i.jsx("button",{onClick:()=>!h&&C(!1),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-bg-tertiary text-text-muted hover:text-text-secondary":"bg-accent-primary/25 text-accent-primary"} ${h?"pointer-events-none opacity-60":""}`,children:"Agent"}),i.jsx("button",{onClick:()=>!h&&C(!0),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-accent-primary/25 text-accent-primary":"bg-bg-tertiary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none opacity-60":""}`,children:"Sub-agent"}),i.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[i.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),i.jsx("input",{type:"color",value:l,onChange:M=>!h&&w(M.target.value),disabled:h,className:"w-6 h-6 rounded cursor-pointer border border-border bg-transparent"})]})]})]})]}),!h&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Model override"}),i.jsx(zN,{providers:m,value:u,onChange:_,defaultLabel:"Default (global model)"}),i.jsx("p",{className:"text-[10px] text-text-muted mt-0.5",children:"When set, this model will be used when this agent is active (overrides the session model)."})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Tools"}),i.jsx(Ze,{className:"flex flex-wrap gap-1.5 p-2 bg-bg-tertiary border border-border rounded max-h-32",children:E.map(M=>{const W=k.has(M.name),z=M.actions.length>0,H=k.get(M.name)||new Set;return z?h?i.jsxs("button",{className:"px-1.5 py-0.5 rounded text-xs font-mono flex items-center gap-1 bg-bg-primary text-text-muted pointer-events-none opacity-60",children:[i.jsx("span",{children:M.name}),i.jsx("span",{className:"text-[10px]",children:"*"})]},M.name):i.jsx(Zc,{trigger:i.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${W?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} cursor-pointer`,children:[i.jsx("span",{children:M.name}),H.size>0&&i.jsx("span",{className:"text-[10px]",children:"*"})]}),minWidth:"160px",items:[...M.actions.map(I=>({label:i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${M.name}-${I}`,children:[i.jsx("input",{type:"checkbox",id:`${M.name}-${I}`,checked:H.has(I),onChange:()=>L(M.name,I),disabled:h,className:"w-3 h-3 rounded accent-accent-primary"}),i.jsx("span",{children:I})]}),closeOnClick:!1})),{label:W?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(W)R(M.name);else{const I=new Map(k);I.set(M.name,new Set(M.actions)),v(zd(I))}}}]},M.name):i.jsx("button",{onClick:()=>!h&&R(M.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${W?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none":"cursor-pointer"}`,children:i.jsx("span",{children:M.name})},M.name)})})]}),D.size>0&&(()=>{const M=new Set(T.map(U=>U.name)),W=k.has("__mcp_none__"),z=[...k.keys()].some(U=>M.has(U)),H=W?"none":z?"partial":"all",I=U=>{const V=new Map(k);for(const Z of V.keys())(Z==="__mcp_none__"||M.has(Z))&&V.delete(Z);if(U==="none"&&V.set("__mcp_none__",new Set),U==="partial")for(const Z of M)V.set(Z,new Set);v(zd(V))};return i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["MCP Tools ",i.jsx("span",{className:"text-text-muted font-normal",children:"— from connected MCP servers"})]}),i.jsxs("div",{className:"bg-bg-tertiary border border-border rounded overflow-hidden",children:[i.jsx("div",{className:"flex items-center gap-4 px-3 py-1.5",children:["all","none","partial"].map(U=>i.jsxs("label",{className:`flex items-center gap-1.5 text-xs cursor-pointer ${h?"pointer-events-none opacity-60":""}`,children:[i.jsx("input",{type:"radio",name:"mcp-mode",checked:H===U,onChange:()=>I(U),disabled:h,className:"w-3 h-3 accent-accent-primary"}),i.jsxs("span",{className:H===U?"text-text-primary font-medium":"text-text-muted",children:[U.charAt(0).toUpperCase()+U.slice(1),U==="partial"&&M.size>0&&i.jsxs("span",{className:"ml-1 text-text-muted font-normal",children:["(",[...k.keys()].filter(V=>M.has(V)).length,"/",M.size,")"]})]})]},U))}),H==="partial"&&(()=>{const[U,V]=N.useState(""),[Z,ee]=N.useState(0),F=N.useRef(null),O=$=>{var Q;const Y=(Q=F.current)==null?void 0:Q.querySelector(`[data-idx="${$}"]`);Y==null||Y.scrollIntoView({block:"nearest"})};N.useEffect(()=>{O(Z)},[Z]);const B=U?T.filter($=>$.name.toLowerCase().includes(U.toLowerCase())):T,q=$=>{$.key==="ArrowDown"?($.preventDefault(),ee(Y=>Math.min(Y+1,B.length-1))):$.key==="ArrowUp"?($.preventDefault(),ee(Y=>Math.max(Y-1,0))):$.key==="Enter"&&B[Z]&&($.preventDefault(),R(B[Z].name))};return i.jsxs("div",{children:[i.jsx("div",{className:"px-3 py-2 border-b border-border",children:i.jsx("input",{type:"text",value:U,onChange:$=>{V($.target.value),ee(0)},onKeyDown:q,placeholder:"Search MCP tools...",className:"w-full px-2 py-1 text-xs bg-bg-primary border border-border rounded font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),i.jsx(Ze,{className:"max-h-60",children:i.jsxs("div",{ref:F,children:[B.map(($,Y)=>{const Q=k.has($.name),X=Y===Z;return i.jsxs("div",{"data-idx":Y,className:`flex items-center justify-between px-3 py-1.5 transition-colors ${X?"bg-bg-primary":"hover:bg-bg-primary/30"}`,onMouseEnter:()=>ee(Y),children:[i.jsx("span",{className:`text-xs font-mono ${Q?"text-text-primary":"text-text-muted"}`,children:$.name}),i.jsx(ns,{enabled:Q,onClick:()=>R($.name),label:$.name})]},$.name)}),B.length===0&&i.jsx("div",{className:"px-3 py-2 text-xs text-text-muted",children:"No MCP tools match your search."})]})})]})})()]})]})})()]}),i.jsxs("div",{className:"flex-1 min-h-[150px] pt-3 flex flex-col",children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),i.jsx("textarea",{value:c,onChange:M=>!h&&b(M.target.value),readOnly:h,placeholder:"Instructions for this agent...",className:`h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary ${h?"opacity-60":""}`})]})]})}function xU(e){const t=e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"");return t?`custom-${t}`:""}function yU({isOpen:e,onClose:t,initialEditId:n}){const r=gt(ue=>ue.defaults),a=gt(ue=>ue.userItems),l=gt(ue=>ue.projectItems),u=gt(ue=>ue.loading),c=gt(ue=>ue.fetchAgents),d=gt(ue=>ue.fetchAgent),h=gt(ue=>ue.fetchDefaultContent),p=gt(ue=>ue.createAgent),m=gt(ue=>ue.updateAgent),x=gt(ue=>ue.deleteAgent),[y,S]=N.useState("list"),[C,v]=N.useState(null),[w,_]=N.useState(!1),[b,k]=N.useState(""),[E,T]=N.useState(""),[D,L]=N.useState(""),[R,M]=N.useState(!0),[W,z]=N.useState([]),[H,I]=N.useState("#6b7280"),[U,V]=N.useState(void 0),[Z,ee]=N.useState(""),[F,O]=N.useState("user"),[B,q]=N.useState(""),[$,Y]=N.useState(!1),[Q,X]=N.useState(!1),[K,P]=N.useState(null),[J,ne]=N.useState([]),[ce,ae]=N.useState(new Set),{requestDelete:Ee,clearConfirm:ve,isConfirming:Le}=Gc(),Me=ue=>{k(ue.metadata.name),T(ue.metadata.id),L(ue.metadata.description),M(ue.metadata.subagent),z(ue.metadata.allowedTools),I(ue.metadata.color??"#6b7280"),ee(ue.prompt),q(""),X(!0),Ce(`/api/agents/${ue.metadata.id}/model`).then($e=>$e.json()).then($e=>{$e.providerId&&$e.model?V(`${$e.providerId}/${$e.model}`):V(void 0)}).catch(()=>V(void 0)).finally(()=>X(!1))},ke=(ue,$e,ut)=>{k(ue.metadata.name+" (copy)"),T(`${$e}-copy-${Date.now()}`),L(ue.metadata.description),M(ue.metadata.subagent),z(ue.metadata.allowedTools),I(ue.metadata.color??"#6b7280"),ee(ue.prompt),q(""),v(null),_(!1),S("edit")},Ge=(ue,$e)=>{Me(ue),v($e),_(!0),S("edit")};N.useEffect(()=>{e&&(c(),Ce("/api/tools").then(ue=>ue.json()).then(ue=>{const $e=ue.tools||[];ae(new Set($e.filter(ut=>ut.alwaysAllowed).map(ut=>ut.name))),ne($e.filter(ut=>!ut.alwaysAllowed))}).catch(()=>{ne([]),ae(new Set)}),n?r.some($e=>$e.id===n)?h(n).then($e=>{$e&&ke($e,n)}):d(n).then($e=>{$e&&(Me($e),v(n),_(!1),S("edit"))}):(S("list"),v(null),_(!1)))},[e,c,d,h,n]);const Xe=async ue=>{if(r.some(ut=>ut.id===ue)){const ut=await h(ue);if(!ut)return;Ge(ut,ue)}else{const ut=await d(ue);if(!ut)return;Ge(ut,ue)}},Se=async ue=>{let $e=await h(ue);$e||($e=await d(ue)),$e&&ke($e,ue)},Ie=()=>{v(null),k(""),T(""),L(""),M(!0),z(["read_file"]),I("#6b7280"),ee(""),O("user"),q(""),_(!1),S("edit")},it=async ue=>{const $e=await d(ue);$e&&(Me($e),v(ue),_(!1),S("edit"))},ge=ue=>{P(ue)},Fe=async ue=>{await x(ue)},He=async()=>{const ue=C??E;if(!ue||!b||!Z){q("Name and prompt are required.");return}Y(!0),q("");const $e={metadata:{id:ue,name:b,description:D,subagent:R,allowedTools:W.filter(Xt=>!ce.has(Xt)),color:H},prompt:Z},ut=C?await m(C,$e):await p($e,F);if(!ut.success){Y(!1),q(ut.error??"Failed to save agent.");return}await HN(C??E,U),await c();const ct=C??E,cn=Re.getState().currentSession;if((cn==null?void 0:cn.mode)===ct&&U){const{providerId:Xt,model:rn}=ib(U);Re.getState().setSessionProvider(Xt,rn)}Y(!1),n?t():S("list")},ie=()=>{n?t():(S("list"),_(!1))},xe=ue=>{k(ue),C||T(xU(ue))},se=gt(ue=>ue.modelOverrides),he=r.filter(ue=>ue.subagent),Pe=r.filter(ue=>!ue.subagent),qe=a.filter(ue=>ue.subagent),Ke=a.filter(ue=>!ue.subagent),et=l.filter(ue=>ue.subagent),ot=l.filter(ue=>!ue.subagent);return y==="edit"?i.jsxs(i.Fragment,{children:[i.jsxs(Tt,{isOpen:e,onClose:ie,title:w?`${b}`:C?"Edit Agent":"New Agent",size:"xl",footer:w?i.jsx("div",{className:"flex justify-end",children:i.jsx("button",{onClick:()=>{k(b+" (copy)"),T(`${C}-copy-${Date.now()}`),v(null),_(!1)},className:"px-3 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 transition-colors",children:"Duplicate & Customize"})}):i.jsx(Gk,{onCancel:ie,onSave:He,saving:$,saveDisabled:!b||!Z||Q}),children:[!C&&!w&&i.jsx(qh,{value:F,onChange:O}),i.jsx(gU,{formName:b,formId:E,formDescription:D,formSubagent:R,formTools:W,formColor:H,formModel:U,formPrompt:Z,formError:B,isReadOnly:w,availableTools:J,providers:nn.getState().providers,onNameChange:xe,onIdChange:T,onDescriptionChange:L,onSubagentChange:ue=>{M(ue),ue&&z($e=>$e.filter(ut=>{var ct;return!((ct=J.find(cn=>cn.name===ut))!=null&&ct.topLevelOnly)}))},onToolsChange:z,onColorChange:I,onModelChange:V,onPromptChange:ee})]}),i.jsx(yC,{agentId:K,onClose:()=>P(null),onSaved:()=>c()})]}):i.jsxs(i.Fragment,{children:[i.jsx(Tt,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:i.jsx(qk,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:Ie,loading:u,hasItems:r.length>0||a.length>0||l.length>0,children:i.jsxs("div",{className:"space-y-4",children:[r.length>0&&i.jsx(gC,{title:"Built-in",agents:Pe,subagents:he,isBuiltIn:!0,alwaysAllowedNames:ce,modelOverrides:se,onView:Xe,onEdit:ge,onDuplicate:Se}),(Ke.length>0||qe.length>0||ot.length>0||et.length>0)&&i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Custom"}),i.jsx("div",{className:"ml-3 space-y-3",children:[{title:"Global",agents:Ke,subagents:qe},{title:"Project",agents:ot,subagents:et}].map(ue=>(ue.agents.length>0||ue.subagents.length>0)&&i.jsx(gC,{title:ue.title,agents:ue.agents,subagents:ue.subagents,isBuiltIn:!1,alwaysAllowedNames:ce,modelOverrides:se,isConfirmingDelete:$e=>Le($e,"delete"),onView:Xe,onDuplicate:Se,onEdit:it,onDelete:$e=>{Le($e,"delete")?(Fe($e),ve()):Ee($e)},onCancelDelete:ve},ue.title))})]})]})})}),i.jsx(yC,{agentId:K,onClose:()=>P(null),onSaved:()=>c()})]})}function ib(e){const t=e.indexOf("/");return t>0?{providerId:e.substring(0,t),model:e.substring(t+1)}:{providerId:e,model:e}}async function HN(e,t){if(t){const{providerId:n,model:r}=ib(t);await Ce(`/api/agents/${e}/model`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})})}else await Ce(`/api/agents/${e}/model`,{method:"DELETE"})}function yC({agentId:e,onClose:t,onSaved:n}){const[r,a]=N.useState(void 0),[l,u]=N.useState(!1),[c,d]=N.useState(!1),[h,p]=N.useState(null),m=gt(_=>_.defaults),x=gt(_=>_.userItems),y=gt(_=>_.projectItems),S=[...m,...x,...y],C=e?S.find(_=>_.id===e):void 0,v=nn(_=>_.providers);N.useEffect(()=>{e&&(u(!0),Ce(`/api/agents/${e}/model`).then(_=>_.json()).then(_=>{a(_.providerId&&_.model?`${_.providerId}/${_.model}`:void 0)}).catch(()=>a(void 0)).finally(()=>u(!1)))},[e]);const w=async()=>{if(e){d(!0),p(null);try{await HN(e,r);const _=Re.getState().currentSession;if((_==null?void 0:_.mode)===e&&r){const{providerId:b,model:k}=ib(r);Re.getState().setSessionProvider(b,k)}n(),t()}catch{p("Failed to save. Please try again.")}d(!1)}};return i.jsx(Tt,{isOpen:!!e,onClose:t,title:`Model — ${(C==null?void 0:C.name)??e??""}`,size:"md",children:i.jsxs("div",{className:"space-y-4 p-2",children:[i.jsx("p",{className:"text-xs text-text-muted",children:"Choose which model to use when this agent is active. This overrides the session/global model."}),l?i.jsx("div",{className:"text-sm text-text-muted py-2",children:"Loading..."}):i.jsx(zN,{providers:v,value:r,onChange:a,defaultLabel:"Default (global model)"}),h&&i.jsx("p",{className:"text-xs text-red-500",children:h}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx("button",{onClick:t,className:"px-4 py-1.5 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),i.jsx("button",{onClick:w,disabled:c,className:"px-4 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-50 transition-colors",children:c?"Saving...":"Save"})]})]})})}function bU(){const e=Re(b=>{var k;return(k=b.currentSession)==null?void 0:k.mode}),t=Re(b=>b.switchMode),n=gt(b=>b.defaults),r=gt(b=>b.userItems),a=gt(b=>b.projectItems),l=gt(b=>b.fetchAgents),u=[...n,...r,...a],[c,d]=N.useState(!1),[h,p]=N.useState(!1),[m,x]=N.useState(null),y=N.useRef(null);N.useEffect(()=>{l()},[l]),yf(y,()=>d(!1));const S=Wc();if(!e)return null;const C=u.filter(b=>!b.subagent),v=C.find(b=>b.id===e),w=(v==null?void 0:v.name)??e,_=Yo(u,e);return i.jsxs("div",{className:"relative",ref:y,children:[i.jsxs("button",{type:"button",onClick:()=>d(!c),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[i.jsx("span",{className:"text-sm font-medium",style:{color:_},children:w}),i.jsx(yn,{className:`w-3 h-3 text-text-muted transition-transform ${c?"rotate-180":""}`})]}),c&&C.length>0&&i.jsxs("div",{className:"absolute bottom-full left-0 mb-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:[C.map((b,k)=>{const E=b.id===e,T=Yo(u,b.id),D=S.agentSwitching[k],L=D?ah(D):null;return i.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors group ${E?"bg-bg-tertiary":"hover:bg-bg-tertiary cursor-pointer"}`,children:[i.jsxs("button",{type:"button",onClick:()=>{E||t(b.id),d(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[i.jsx("span",{className:"font-medium truncate",style:{color:T},children:b.name}),E&&i.jsx(is,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),L&&i.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:L})]},b.id)}),i.jsx("div",{className:"border-t border-border p-1",children:i.jsx("button",{type:"button",onClick:()=>{d(!1),p(!0)},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Agents..."})})]}),i.jsx(yU,{isOpen:h,onClose:()=>{p(!1),x(null)},initialEditId:m})]})}function vU(){const e=Re(r=>r.currentSession),t=Re(r=>r.switchDangerLevel);if(!e)return null;const n=e.dangerLevel??"normal";return i.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[i.jsx("button",{type:"button",onClick:()=>t("normal"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="normal"?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),i.jsx("button",{type:"button",onClick:()=>t("dangerous"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="dangerous"?"bg-red-500/20 text-red-400":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})}function bC({value:e,onChange:t}){return i.jsxs("div",{children:[i.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Query params ",i.jsx("span",{className:"text-text-muted",children:"(optional JSON)"})]}),i.jsx("input",{type:"text",value:e??"",onChange:n=>t(n.target.value),className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono"})]})}const _U=[8080,11434,8e3,1234];function Mx(e){if(e!=null&&e.length)return e.includes("medium")?"medium":e[0]}function FN(e){return{name:e.name,url:e.url,backend:e.backend,apiKey:e.apiKey,isLocal:e.isLocal,thinkingField:e.thinkingField,sendReasoningInMessages:e.sendReasoningInMessages,authAdapter:e.authAdapter,transportAdapter:e.transportAdapter,models:e.models}}function SU({model:e,modelConfigs:t,autoConfigState:n,testResults:r,onUpdateConfig:a,onRunAutoConfig:l,onTestParams:u,onShowRaw:c}){var d,h,p,m,x,y,S,C,v,w,_,b,k,E,T,D,L,R,M,W,z,H,I,U,V,Z,ee,F,O,B,q,$,Y,Q,X,K,P,J,ne,ce,ae,Ee,ve,Le,Me;return i.jsxs("div",{className:"px-4 pb-4 border-t border-border pt-3 space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("button",{onClick:()=>l(e.id),disabled:n.progress[e.id]==="probing",className:"px-4 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:n.progress[e.id]==="probing"?"Probing...":"Auto-config"}),n.progress[e.id]==="done"&&i.jsx("span",{className:"text-sm text-accent-success font-medium",children:"Configured ✓"}),n.progress[e.id]==="error"&&i.jsx("span",{className:"text-sm text-red-500 font-medium",children:"Failed ✗"})]}),i.jsxs("div",{className:"flex gap-3 items-end",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Context window (tokens)"}),i.jsx("input",{type:"number",value:((d=t[e.id])==null?void 0:d.contextWindow)??e.contextWindow,onChange:ke=>a(e.id,{contextWindow:parseInt(ke.target.value)||e.contextWindow}),className:"w-32 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),i.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary pb-1",children:[i.jsx("input",{type:"checkbox",checked:((h=t[e.id])==null?void 0:h.supportsVision)??!1,onChange:ke=>a(e.id,{supportsVision:ke.target.checked}),className:"accent-accent-primary"})," ","Supports vision"]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>u(e.id,"thinking"),disabled:(p=r[e.id+"-thinking"])==null?void 0:p.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(m=r[e.id+"-thinking"])!=null&&m.loading?"Testing...":"Test thinking"}),((x=r[e.id+"-thinking"])==null?void 0:x.result)&&i.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((y=r[e.id+"-thinking"])==null?void 0:y.error)&&i.jsx("span",{className:"text-xs text-red-500",title:(S=r[e.id+"-thinking"])==null?void 0:S.error,children:"Fail"}),((C=r[e.id+"-thinking"])==null?void 0:C.result)&&i.jsx("button",{onClick:()=>c(r[e.id+"-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>u(e.id,"non-thinking"),disabled:(v=r[e.id+"-non-thinking"])==null?void 0:v.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(w=r[e.id+"-non-thinking"])!=null&&w.loading?"Testing...":"Test non-thinking"}),((_=r[e.id+"-non-thinking"])==null?void 0:_.result)&&i.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((b=r[e.id+"-non-thinking"])==null?void 0:b.error)&&i.jsx("span",{className:"text-xs text-red-500",title:(k=r[e.id+"-non-thinking"])==null?void 0:k.error,children:"Fail"}),((E=r[e.id+"-non-thinking"])==null?void 0:E.result)&&i.jsx("button",{onClick:()=>c(r[e.id+"-non-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]})]}),i.jsxs("details",{className:"group",children:[i.jsxs("summary",{className:"text-xs text-text-muted cursor-pointer hover:text-text-secondary list-none flex items-center gap-1 select-none",children:[i.jsx(yn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),"Advanced: thinking & non-thinking params"]}),i.jsxs("div",{className:"mt-3 space-y-2",children:[i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:((T=t[e.id])==null?void 0:T.thinkingEnabled)??!1,onChange:ke=>a(e.id,{thinkingEnabled:ke.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),i.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Thinking"})]}),((D=t[e.id])==null?void 0:D.thinkingEnabled)&&i.jsxs("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-primary/30",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Reasoning effort"}),(L=e.reasoningEfforts)!=null&&L.length?i.jsx("select",{"aria-label":"Reasoning effort",value:((R=t[e.id])==null?void 0:R.thinkingLevel)??Mx(e.reasoningEfforts),onChange:ke=>a(e.id,{thinkingLevel:ke.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary",children:e.reasoningEfforts.map(ke=>i.jsx("option",{value:ke,children:ke},ke))}):i.jsx("input",{type:"text","aria-label":"Reasoning effort",value:((M=t[e.id])==null?void 0:M.thinkingLevel)??"",onChange:ke=>a(e.id,{thinkingLevel:ke.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),i.jsx(bC,{value:(W=t[e.id])==null?void 0:W.thinkingQueryParams,onChange:ke=>a(e.id,{thinkingQueryParams:ke})})]}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:((z=t[e.id])==null?void 0:z.nonThinkingEnabled)??!1,onChange:ke=>a(e.id,{nonThinkingEnabled:ke.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),i.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Non-thinking"})]}),((H=t[e.id])==null?void 0:H.nonThinkingEnabled)&&i.jsx("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:i.jsx(bC,{value:(I=t[e.id])==null?void 0:I.nonThinkingQueryParams,onChange:ke=>a(e.id,{nonThinkingQueryParams:ke})})})]}),i.jsxs("div",{className:"border-t border-border pt-3 mt-3",children:[i.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Sampling parameters"}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Temperature"}),i.jsx("input",{type:"number",step:"0.1",value:((U=t[e.id])==null?void 0:U.temperature)??"",onChange:ke=>a(e.id,{temperature:ke.target.value?parseFloat(ke.target.value):void 0}),placeholder:((Z=(V=t[e.id])==null?void 0:V.defaultTemperature)==null?void 0:Z.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((ee=t[e.id])==null?void 0:ee.defaultTemperature)!==void 0&&i.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(F=t[e.id])==null?void 0:F.defaultTemperature]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top P"}),i.jsx("input",{type:"number",step:"0.05",value:((O=t[e.id])==null?void 0:O.topP)??"",onChange:ke=>a(e.id,{topP:ke.target.value?parseFloat(ke.target.value):void 0}),placeholder:((q=(B=t[e.id])==null?void 0:B.defaultTopP)==null?void 0:q.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),(($=t[e.id])==null?void 0:$.defaultTopP)!==void 0&&i.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Y=t[e.id])==null?void 0:Y.defaultTopP]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top K"}),i.jsx("input",{type:"number",value:((Q=t[e.id])==null?void 0:Q.topK)??"",onChange:ke=>a(e.id,{topK:ke.target.value?parseInt(ke.target.value):void 0}),placeholder:((K=(X=t[e.id])==null?void 0:X.defaultTopK)==null?void 0:K.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((P=t[e.id])==null?void 0:P.defaultTopK)!==void 0&&i.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(J=t[e.id])==null?void 0:J.defaultTopK]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Max tokens"}),i.jsx("input",{type:"number",value:((ne=t[e.id])==null?void 0:ne.maxTokens)??"",onChange:ke=>a(e.id,{maxTokens:ke.target.value?parseInt(ke.target.value):void 0}),placeholder:((ae=(ce=t[e.id])==null?void 0:ce.defaultMaxTokens)==null?void 0:ae.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((Ee=t[e.id])==null?void 0:Ee.defaultMaxTokens)!==void 0&&i.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(ve=t[e.id])==null?void 0:ve.defaultMaxTokens]})]})]})]}),i.jsx("div",{className:"pt-3 border-t border-border",children:i.jsx(wU,{value:(Le=t[e.id])==null?void 0:Le.compactionThreshold,maxTokens:((Me=t[e.id])==null?void 0:Me.contextWindow)??e.contextWindow,onChange:ke=>a(e.id,{compactionThreshold:ke})})})]})]})}function wU({value:e,maxTokens:t,onChange:n}){const l=Math.min(95,Math.floor((t-5e3)/t*100)),u=Math.min(l,Math.ceil(15e3/t*100)),c=Math.min(e??.85,l/100),[d,h]=N.useState(Math.round(c*100));N.useEffect(()=>{const m=Math.min(e??.85,l/100);h(Math.round(m*100))},[e,l]);const p=Math.floor(t*(d/100));return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1",children:[i.jsx("label",{className:"text-xs text-text-secondary",children:"Auto-compaction threshold"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"font-mono text-xs text-text-primary",children:[d,"% · ",Xo(p)]}),i.jsx("button",{type:"button",onClick:()=>{n(void 0),h(Math.round(.85*100))},disabled:e===void 0,className:"text-xs text-accent-primary hover:underline disabled:text-text-muted disabled:no-underline",children:"Default"})]})]}),i.jsx("input",{"aria-label":"Auto-compaction threshold",type:"range",min:u,max:l,step:"1",value:d,onChange:m=>h(Number(m.target.value)),onMouseUp:()=>n(d/100),onTouchEnd:()=>n(d/100),onBlur:()=>n(d/100),onKeyUp:()=>n(d/100),className:"w-full"}),i.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:["Minimum ",Xo(15e3)," tokens · maximum ",l,"% · default 85%"]})]})}function UN({isOpen:e,onClose:t,onSave:n,initialStep:r=1,editProvider:a,editModelId:l}){const[u,c]=N.useState(r),[d,h]=N.useState(""),[p,m]=N.useState(""),[x,y]=N.useState("unknown"),[S,C]=N.useState(""),[v,w]=N.useState(!1),[_,b]=N.useState(),[k,E]=N.useState(),[T,D]=N.useState(!1),[L,R]=N.useState(null),[M,W]=N.useState([]),[z,H]=N.useState(null),[I,U]=N.useState(!1),[V,Z]=N.useState(""),[ee,F]=N.useState(!0),[O,B]=N.useState({}),[q,$]=N.useState({loading:!1,progress:{}}),[Y,Q]=N.useState({}),[X,K]=N.useState(null),[P,J]=N.useState(new Set),[ne,ce]=N.useState(""),[ae,Ee]=N.useState(null),[ve,Le]=N.useState("disconnected"),[Me,ke]=N.useState(!1),[Ge,Xe]=N.useState(null),[Se,Ie]=N.useState([]),[it,ge]=N.useState(!1),[Fe,He]=N.useState(!1),ie=N.useRef(null),xe=N.useRef(!1),se=N.useRef(null);N.useEffect(()=>{u===1&&e&&requestAnimationFrame(()=>{var ye;return(ye=se.current)==null?void 0:ye.focus()})},[u,e]),N.useEffect(()=>()=>{ie.current!==null&&window.clearTimeout(ie.current)},[]),N.useEffect(()=>{e&&Ce("/api/provider-presets").then(async ye=>ye.ok?await ye.json():{presets:[]}).then(ye=>Ie(ye.presets)).catch(()=>Ie([]))},[e]);function he(ye,Ye){B(We=>({...We,[ye]:{...We[ye],...Ye}}))}function Pe(ye){J(Ye=>new Set(Ye).add(ye.id)),B(Ye=>({...Ye,[ye.id]:{contextWindow:ye.contextWindow,...Ye[ye.id]}}))}function qe(ye){if(!ye.trim())return M;const Ye=ye.toLowerCase().split(/\s+/).filter(Boolean);return M.filter(We=>Ye.every(ze=>We.id.toLowerCase().includes(ze)))}N.useEffect(()=>{var ye,Ye;if(e)if(c(r),h((a==null?void 0:a.name)??""),m((a==null?void 0:a.url)??""),y((a==null?void 0:a.backend)??"unknown"),C((a==null?void 0:a.apiKey)??""),w((a==null?void 0:a.isLocal)??!1),b(a==null?void 0:a.authAdapter),E(a==null?void 0:a.transportAdapter),R(null),Z((a==null?void 0:a.thinkingField)??""),F((a==null?void 0:a.sendReasoningInMessages)??!0),Q({}),K(null),Ee(null),Le("disconnected"),Xe(null),ge(!1),He(!1),(ye=a==null?void 0:a.models)!=null&&ye.length){const We={},ze=new Set;for(const tt of a.models)We[tt.id]={contextWindow:tt.contextWindow,supportsVision:tt.supportsVision,thinkingEnabled:tt.thinkingEnabled,thinkingLevel:tt.thinkingLevel??Mx(tt.reasoningEfforts),nonThinkingEnabled:tt.nonThinkingEnabled,thinkingQueryParams:tt.thinkingQueryParams,nonThinkingQueryParams:tt.nonThinkingQueryParams,defaultTemperature:tt.defaultTemperature,defaultTopP:tt.defaultTopP,defaultTopK:tt.defaultTopK,defaultMaxTokens:tt.defaultMaxTokens,temperature:tt.temperature,topP:tt.topP,topK:tt.topK,maxTokens:tt.maxTokens,compactionThreshold:tt.compactionThreshold},tt.selected&&ze.add(tt.id);if(ze.size===0)for(const tt of a.models)ze.add(tt.id);J(ze),B(We),W(a.models),H(l??((Ye=a.models[0])==null?void 0:Ye.id)??null)}else W([]),B({}),H(null),J(new Set)},[e,r,a==null?void 0:a.id,l]),N.useEffect(()=>{const ye=!!_;u===2&&p&&M.length===0&&!T&&!L&&(!ye||ve==="connected")&&ut(p)},[u,ve]),N.useEffect(()=>{!e||!_||!(a!=null&&a.id)||et(a.id)},[e,k,a==null?void 0:a.id]),N.useEffect(()=>{if(!Ge)return;const ye=(a==null?void 0:a.id)??ae;if(!ye)return;let Ye=!1;const We=async()=>{const tt=await et(ye);Ye||tt!=="connected"||(Xe(null),ge(!1),He(!1),await ut(p))};We();const ze=window.setInterval(()=>void We(),2e3);return()=>{Ye=!0,window.clearInterval(ze)}},[Ge,ae,a==null?void 0:a.id]);async function Ke(){if(a!=null&&a.id)return a.id;if(ae)return ae;const ye=await Ce("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d||"Provider",url:p,backend:x,authAdapter:_,transportAdapter:k,isLocal:!1,models:[]})});if(!ye.ok)throw new Error("Unable to create provider");const Ye=await ye.json();return Ee(Ye.provider.id),Ye.provider.id}async function et(ye){const Ye=await Ce(`/api/provider-auth/${ye}/status`);if(!Ye.ok)return"error";const We=await Ye.json(),ze=We.state==="connected"?"connected":We.state==="pending"?"pending":We.state==="error"?"error":"disconnected";return Le(ze),ze}async function ot(){ke(!0),Le("pending");try{const ye=await Ke(),Ye=await Ce(`/api/provider-auth/${ye}/login`,{method:"POST"});if(!Ye.ok)throw new Error("Unable to start provider sign-in");const We=await Ye.json();Xe(We)}catch{Le("error")}finally{ke(!1)}}async function ue(){var ye;Ge!=null&&Ge.userCode&&(await((ye=navigator.clipboard)==null?void 0:ye.writeText(Ge.userCode)),ie.current!==null&&window.clearTimeout(ie.current),He(!1),requestAnimationFrame(()=>He(!0)),ie.current=window.setTimeout(()=>{He(!1),ie.current=null},1500))}function $e(){Ge&&(window.open(Ge.directUrl??Ge.verificationUrl,"_blank","noopener,noreferrer"),ge(!0))}async function ut(ye){var Ye,We;D(!0),R(null),W([]);try{const ze=new URLSearchParams({url:ye});S&&ze.set("apiKey",S),x&&ze.set("backend",x);const tt=k?await Ce(`/api/providers/${await Ke()}/models`):await Ce(`/api/providers/models?${ze.toString()}`);if(tt.ok){const Lt=await tt.json();if((Ye=Lt.models)!=null&&Ye.length){W(Lt.models),H(((We=Lt.models[0])==null?void 0:We.id)??null);const hn={};for(const fn of Lt.models)hn[fn.id]={contextWindow:fn.contextWindow,thinkingEnabled:!0,thinkingLevel:Mx(fn.reasoningEfforts),defaultTemperature:fn.defaultTemperature,defaultTopP:fn.defaultTopP,defaultTopK:fn.defaultTopK,defaultMaxTokens:fn.defaultMaxTokens};B(hn),Lt.models.length===1&&(J(new Set([Lt.models[0].id])),H(Lt.models[0].id),ct(Lt.models[0].id))}}else{const Lt=await tt.json();R(Lt.error??`Failed to fetch models from ${ye}`)}}catch(ze){R(`Failed to fetch models from ${ye}: ${ze instanceof Error?ze.message:"Unknown error"}`)}D(!1)}async function ct(ye){$(Ye=>({loading:!0,progress:{...Ye.progress,[ye]:"probing"}}));try{const Ye=await Ce("/api/providers/auto-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,apiKey:S||void 0,backend:x||"unknown",models:[{id:ye}]})});if(!Ye.ok){const ze=await Ye.json();throw new Error(ze.error??"Auto-config failed")}const We=await Ye.json();for(const ze of We.models){const tt={};ze.contextSource!=="default"&&(tt.contextWindow=ze.contextWindow,tt.supportsVision=ze.supportsVision),ze.thinkingConfig&&(tt.thinkingEnabled=!0,tt.thinkingQueryParams=JSON.stringify(ze.thinkingConfig)),ze.nonThinkingConfig&&(tt.nonThinkingEnabled=!0,tt.nonThinkingQueryParams=JSON.stringify(ze.nonThinkingConfig)),he(ze.id,tt),$(Lt=>({...Lt,progress:{...Lt.progress,[ze.id]:"done"}}))}}catch(Ye){console.error("Auto-config error:",Ye),$(We=>({...We,progress:{...We.progress,[ye]:"error"}}))}finally{$(Ye=>({...Ye,loading:!1}))}}async function cn(ye,Ye){const We=ye+"-"+Ye;Q(ze=>({...ze,[We]:{loading:!0}}));try{const ze=O[ye],tt=await Ce("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,providerId:(a==null?void 0:a.id)??ae??void 0,transportAdapter:k,model:ye,apiKey:S||void 0,backend:x||"unknown",thinkingField:V||void 0,mode:Ye,modelConfig:{temperature:ze==null?void 0:ze.temperature,topP:ze==null?void 0:ze.topP,topK:ze==null?void 0:ze.topK,maxTokens:ze==null?void 0:ze.maxTokens,supportsVision:ze==null?void 0:ze.supportsVision,thinkingEnabled:ze==null?void 0:ze.thinkingEnabled,thinkingLevel:ze==null?void 0:ze.thinkingLevel,nonThinkingEnabled:ze==null?void 0:ze.nonThinkingEnabled,thinkingQueryParams:ze==null?void 0:ze.thinkingQueryParams,nonThinkingQueryParams:ze==null?void 0:ze.nonThinkingQueryParams}})}),Lt=await tt.json();tt.ok?Q(hn=>({...hn,[We]:{loading:!1,result:JSON.stringify(Lt,null,2),message:Lt.message}})):Q(hn=>({...hn,[We]:{loading:!1,error:Lt.error??"Test failed"}}))}catch(ze){Q(tt=>({...tt,[We]:{loading:!1,error:ze instanceof Error?ze.message:"Request failed"}}))}}function Xt(){W([]),B({}),$({loading:!1,progress:{}}),Q({}),K(null),J(new Set),ce("")}function rn(){ae&&!xe.current&&Ce(`/api/providers/${ae}`,{method:"DELETE"}).catch(ye=>{console.warn("Failed to clean up draft provider",ye)}),t()}function On(){const ye=d||"Provider",Ye=(a==null?void 0:a.id)??ae??`temp-${Date.now()}`;n({id:Ye,name:ye,url:p,backend:x||"unknown",apiKey:S||void 0,isLocal:v,thinkingField:V||void 0,sendReasoningInMessages:ee,authAdapter:_,transportAdapter:k,models:M.map(We=>{var ze,tt,Lt,hn,fn,Kn,_e,rt,fe,we,Be,Qe,Je,at,dt,sn;return{id:We.id,name:We.name,apiModelId:We.apiModelId,requestBody:We.requestBody,reasoningEfforts:We.reasoningEfforts,contextWindow:((ze=O[We.id])==null?void 0:ze.contextWindow)??We.contextWindow,selected:P.has(We.id)||void 0,supportsVision:(tt=O[We.id])==null?void 0:tt.supportsVision,thinkingEnabled:(Lt=O[We.id])==null?void 0:Lt.thinkingEnabled,thinkingLevel:(hn=O[We.id])==null?void 0:hn.thinkingLevel,nonThinkingEnabled:(fn=O[We.id])==null?void 0:fn.nonThinkingEnabled,thinkingQueryParams:(Kn=O[We.id])==null?void 0:Kn.thinkingQueryParams,nonThinkingQueryParams:(_e=O[We.id])==null?void 0:_e.nonThinkingQueryParams,temperature:(rt=O[We.id])==null?void 0:rt.temperature,topP:(fe=O[We.id])==null?void 0:fe.topP,topK:(we=O[We.id])==null?void 0:we.topK,maxTokens:(Be=O[We.id])==null?void 0:Be.maxTokens,defaultMaxTokens:(Qe=O[We.id])==null?void 0:Qe.defaultMaxTokens,defaultTemperature:(Je=O[We.id])==null?void 0:Je.defaultTemperature,defaultTopP:(at=O[We.id])==null?void 0:at.defaultTopP,defaultTopK:(dt=O[We.id])==null?void 0:dt.defaultTopK,compactionThreshold:(sn=O[We.id])==null?void 0:sn.compactionThreshold}})}),xe.current=!0,t()}return e?i.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:[i.jsxs(Ze,{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[85vh] shadow-2xl",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[i.jsx("h3",{className:"text-lg font-semibold text-text-primary",children:a?"Edit Provider":"Add Provider"}),i.jsx("button",{onClick:rn,className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),i.jsx("div",{className:"flex gap-1.5 px-6 pt-4",children:[1,2].map(ye=>i.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${ye<u?"bg-accent-success":ye===u?"bg-accent-primary":"bg-border"}`},ye))}),u===1&&i.jsxs("div",{className:"px-6 py-4 space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Inference engine"}),i.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[Se.map(ye=>i.jsx("button",{type:"button",onClick:()=>{h(ye.defaults.name??ye.name),m(ye.defaults.url),y(ye.defaults.backend),w(!1),C(""),b(ye.authAdapter),E(ye.transportAdapter),R(null),Xt()},className:`p-2 rounded border text-center text-sm transition-colors ${k&&k===ye.transportAdapter?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:ye.name},ye.id)),i.jsx("button",{type:"button",onClick:()=>{y("unknown"),w(!1),b(void 0),E(void 0),R(null),Xt()},className:`p-2 rounded border text-center text-sm transition-colors ${x==="unknown"?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:"Other"},"other"),_U.map(ye=>{const Ye={8e3:"vllm",11434:"ollama",8080:"llamacpp",1234:"lmstudio"},We={8e3:"vLLM",11434:"Ollama",8080:"llama.cpp",1234:"LM Studio"};return i.jsx("button",{type:"button",onClick:()=>{h(ze=>ze||(We[ye]??"")),m(ze=>ze||`http://localhost:${ye}`),y(Ye[ye]??""),w(!0),b(void 0),E(void 0),R(null),Xt()},className:`p-2 rounded border text-center text-sm transition-colors ${x===Ye[ye]?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:We[ye]??`localhost:${ye}`},ye)})]})]}),!_&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider URL"}),i.jsx("input",{ref:se,type:"text",value:p,"data-testid":"provider-modal-url",onChange:ye=>{m(ye.target.value),R(null),W([]),B({})},placeholder:"http://localhost:8000",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name"}),i.jsx("input",{type:"text",autoComplete:"off",value:d,onChange:ye=>h(ye.target.value),placeholder:"My LLM Server",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),!_&&i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-text-secondary mb-1",children:["API key ",i.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),i.jsx("input",{type:"text",autoComplete:"off",value:S,onChange:ye=>C(ye.target.value),placeholder:"sk-...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),!_&&i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:v,onChange:ye=>w(ye.target.checked),className:"w-4 h-4 rounded border-border bg-bg-primary accent-accent-primary"}),i.jsx("span",{className:"text-sm text-text-secondary",children:"This is a local provider"})]})]}),u===2&&i.jsxs("div",{className:"px-6 py-4 space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Test & Configure Models"}),i.jsx("button",{type:"button",onClick:()=>U(!0),className:"p-1.5 text-text-muted hover:text-text-primary rounded transition-colors",title:"Provider-level defaults",children:i.jsx(Hk,{className:"w-4 h-4"})})]}),!!_&&i.jsxs("div",{className:"rounded-lg border border-border bg-bg-primary p-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Connect provider"}),i.jsx("p",{className:"mt-1 text-xs text-text-muted",children:"Connect this provider before choosing available models."})]}),ve==="connected"?i.jsx("span",{className:"text-sm font-medium text-accent-success",children:"Connected ✓"}):i.jsx("button",{type:"button",onClick:()=>void ot(),disabled:Me||ve==="pending",className:"rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary disabled:opacity-50",children:Me||ve==="pending"?"Connecting...":ve==="error"?"Retry":"Connect"})]}),Ge&&i.jsx("div",{className:"mt-4 border-t border-border pt-4",children:Ge.mode!=="browser"?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-xs text-text-muted",children:"Use this code to complete authorization:"}),i.jsx("button",{type:"button",onClick:()=>void ue(),className:"mt-3 w-full rounded-lg border border-accent-primary/40 px-4 py-4 font-mono text-2xl font-semibold tracking-[0.2em] text-accent-primary",children:Ge.userCode??"Continue"}),i.jsxs("div",{className:"mt-3 flex gap-2",children:[i.jsx("button",{type:"button",onClick:()=>void ue(),className:"flex-1 rounded-lg border border-border px-3 py-2 text-sm text-text-primary",children:Fe?"Copied":"Copy code"}),i.jsx("button",{type:"button",onClick:$e,className:"flex-1 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:it?"Reopen authorization":"Open authorization"})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-xs text-text-muted mb-3",children:Ge.instructions}),i.jsx("button",{type:"button",onClick:$e,className:"w-full rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:it?"Reopen authorization":"Open authorization"})]})})]}),T&&i.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[i.jsx("span",{className:"w-4 h-4 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),"Fetching models..."]}),L&&i.jsxs("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-500 border border-red-500/20",children:[i.jsx("p",{children:L}),i.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["URL: ",p]}),i.jsxs("div",{className:"flex gap-2 mt-2",children:[i.jsx("button",{onClick:()=>ut(p),className:"text-xs text-accent-primary hover:underline",children:"Retry"}),i.jsx("button",{onClick:()=>{Xt(),c(1)},className:"text-xs text-accent-primary hover:underline",children:"Edit URL"})]})]}),M.length>0&&x&&(!_||ve==="connected")&&i.jsxs(i.Fragment,{children:[P.size>0&&i.jsxs("div",{className:"mb-4",children:[i.jsxs("h4",{className:"text-sm font-medium text-text-primary mb-1",children:["Selected Models (",P.size,")"]}),i.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Only selected models will appear in the model selector."}),i.jsx("div",{className:"space-y-2",children:M.filter(ye=>P.has(ye.id)).map(ye=>{var Ye;return i.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[i.jsxs("div",{onClick:()=>H(z===ye.id?null:ye.id),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-tertiary transition-colors cursor-pointer",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("span",{className:"text-sm font-medium text-text-primary",children:ye.name??ye.id.split("/").pop()}),i.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[(((Ye=O[ye.id])==null?void 0:Ye.contextWindow)??ye.contextWindow).toLocaleString()," ctx"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[q.progress[ye.id]==="probing"?i.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}):q.progress[ye.id]==="done"?i.jsx("span",{className:"text-xs text-accent-success font-medium",children:"Configured ✓"}):q.progress[ye.id]==="error"?i.jsx("span",{className:"text-xs text-red-500 font-medium",children:"Failed ✗"}):_?null:i.jsx("button",{onClick:We=>{We.stopPropagation(),ct(ye.id)},className:"text-xs text-accent-primary hover:underline",children:"Auto-config"}),M.length>1&&i.jsx("button",{onClick:We=>{We.stopPropagation();const ze=new Set(P);ze.delete(ye.id),J(ze),z===ye.id&&H(null)},className:"text-xs text-red-500 hover:text-red-400 px-2 py-1 rounded hover:bg-red-500/10",children:"Remove"}),i.jsx(yn,{className:`w-4 h-4 text-text-muted transition-transform ${z===ye.id?"rotate-180":""}`})]})]}),z===ye.id&&i.jsx(SU,{model:ye,modelConfigs:O,autoConfigState:q,testResults:Y,onUpdateConfig:he,onRunAutoConfig:ct,onTestParams:cn,onShowRaw:K})]},ye.id)})})]}),M.length>1&&i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Available Models"}),P.size===0&&i.jsx("p",{className:"text-xs text-text-muted mb-2",children:"This provider has many models available. Select the ones you want to use below."}),i.jsxs("div",{className:"relative mb-2",children:[i.jsx("input",{type:"text",value:ne,onChange:ye=>ce(ye.target.value),placeholder:"Search models...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),ne&&i.jsx("button",{onClick:()=>ce(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary text-sm",children:"×"})]}),i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("p",{className:"text-xs text-text-muted",children:["Showing ",qe(ne).length," of ",M.length," models"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{onClick:()=>{const ye=new Set(P),Ye=qe(ne);for(const We of Ye)ye.add(We.id);if(J(ye),B(We=>{const ze={...We};for(const tt of Ye)ze[tt.id]={contextWindow:tt.contextWindow,...ze[tt.id]};return ze}),!_)for(const We of Ye)q.progress[We.id]!=="probing"&&q.progress[We.id]!=="done"&&ct(We.id)},className:"text-xs text-accent-primary hover:underline",children:"Select all"}),i.jsx("button",{onClick:()=>{const ye=new Set(P),Ye=qe(ne);for(const We of Ye)ye.delete(We.id);J(ye)},className:"text-xs text-text-muted hover:text-text-secondary",children:"Deselect all"})]})]}),i.jsxs(Ze,{className:"space-y-1 max-h-48 border border-border rounded-lg bg-bg-primary",children:[qe(ne).map(ye=>{var We;const Ye=P.has(ye.id);return i.jsxs("div",{role:"checkbox","aria-checked":Ye,tabIndex:0,className:`flex items-center gap-3 px-4 py-2 hover:bg-bg-tertiary transition-colors cursor-pointer ${Ye?"bg-accent-primary/5":""}`,onClick:()=>{if(Ye){const ze=new Set(P);ze.delete(ye.id),J(ze)}else Pe(ye),_||ct(ye.id)},onKeyDown:ze=>{(ze.key==="Enter"||ze.key===" ")&&(ze.preventDefault(),ze.currentTarget.click())},children:[i.jsx("input",{type:"checkbox",checked:Ye,onChange:()=>{},className:"w-4 h-4 rounded border-border accent-accent-primary pointer-events-none"}),i.jsx("span",{className:"text-sm text-text-primary flex-1 truncate",children:ye.name??ye.id.split("/").pop()}),i.jsxs("span",{className:"text-xs text-text-muted flex-shrink-0",children:[(((We=O[ye.id])==null?void 0:We.contextWindow)??ye.contextWindow).toLocaleString()," ctx"]}),q.progress[ye.id]==="probing"&&i.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin flex-shrink-0"}),q.progress[ye.id]==="done"&&i.jsx("span",{className:"text-xs text-accent-success flex-shrink-0",children:"✓"}),q.progress[ye.id]==="error"&&i.jsx("span",{className:"text-xs text-red-500 flex-shrink-0",children:"✗"})]},ye.id)}),qe(ne).length===0&&i.jsxs("div",{className:"px-4 py-6 text-center text-sm text-text-muted",children:["No models match “",ne,"”"]})]})]})]})]}),i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-border",children:[i.jsx("div",{children:u>1&&i.jsx("button",{onClick:()=>{u===2&&Xt(),c(u-1)},className:"text-sm text-text-muted hover:text-text-secondary transition-colors",children:"← Back"})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{onClick:rn,className:"px-4 py-2 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),u===1?i.jsx("button",{onClick:()=>c(2),disabled:!p,"data-testid":"provider-modal-next",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:"Next — Test & Configure"}):i.jsx("button",{onClick:On,disabled:q.loading,"data-testid":"provider-modal-save",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:q.loading?"Configuring...":"Save Provider"})]})]})]}),I&&i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:ye=>{ye.target===ye.currentTarget&&U(!1)},children:i.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[480px] shadow-2xl",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[i.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Provider-Level Defaults"}),i.jsx("button",{onClick:()=>U(!1),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),i.jsxs("div",{className:"px-6 py-4 space-y-4",children:[i.jsx("p",{className:"text-xs text-text-muted",children:"These apply to all models unless overridden per-model."}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Non-thinking mode params"}),i.jsx("input",{type:"text",defaultValue:'{"chat_template_kwargs":{"enable_thinking":false}}',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Thinking mode params"}),i.jsx("input",{type:"text",defaultValue:'reasoning_effort: "low"',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Thinking response field ",i.jsx("span",{className:"text-text-muted",children:"(override)"})]}),i.jsx("input",{type:"text",value:V,onChange:ye=>Z(ye.target.value),placeholder:"Leave blank for auto-detect",className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-primary font-mono"}),i.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Field name the backend uses for reasoning/thinking content (e.g. reasoning, reasoning_content, thinking)."})]}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:ee,onChange:ye=>F(ye.target.checked),className:"rounded border-border bg-bg-primary text-accent-primary focus:ring-accent-primary"}),i.jsx("span",{className:"text-sm text-text-secondary",children:"Send reasoning in messages"}),i.jsx("span",{className:"text-xs text-text-muted ml-auto",children:"When disabled, strips reasoning/thinking content from assistant messages sent to this provider"})]})]}),i.jsx("div",{className:"flex justify-end px-6 py-4 border-t border-border",children:i.jsx("button",{onClick:()=>U(!1),className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 transition-colors",children:"Done"})})]})}),X&&i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:ye=>{ye.target===ye.currentTarget&&K(null)},children:i.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[80vh] shadow-2xl flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border shrink-0",children:[i.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Raw Response"}),i.jsx("button",{onClick:()=>K(null),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),i.jsx(Ze,{horizontal:!0,children:i.jsx("pre",{className:"px-6 py-4 text-xs text-text-secondary font-mono whitespace-pre-wrap break-all",children:X})})]})})]}):null}function vC({activeProvider:e,shortModelName:t,agentOverrideActive:n,agentColor:r,agentName:a}){return i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"text-sm text-accent-primary flex items-center gap-1",children:[n&&i.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0 ring-1 ring-border",style:{backgroundColor:r??"#6b7280"},title:`Model set by agent "${a??"unknown"}". Change it in Settings > Agents.`}),e?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"hidden sm:inline",children:[e.name," • "]}),t]}):t]}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${e!=null&&e.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:e!=null&&e.isLocal?"local":"api"})]})}function CU(){var Kn;const[,e]=zn(),t=Re(_e=>_e.currentSession),n=Re(_e=>_e.setSessionProvider),[r,a]=N.useState(!1),[l,u]=N.useState([]),[c,d]=N.useState(null),h=N.useRef(null),[p,m]=N.useState(null),[x,y]=N.useState(!1),[S,C]=N.useState({}),[v,w]=N.useState(null),[_,b]=N.useState(null),[k,E]=N.useState(!1),T=N.useRef(null),[D,L]=N.useState(!1),R=N.useRef(new Set),M=nn(_e=>_e.providers),W=nn(_e=>_e.activeProviderId),z=nn(_e=>_e.defaultModelSelection),H=nn(_e=>_e.activating),I=nn(_e=>_e.activateProvider),U=nn(_e=>_e.refreshModel),V=nn(_e=>_e.refreshProviderModels),Z=nn(_e=>_e.setDefaultModel),ee=nn(_e=>_e.fetchConfig),F=Wc();Dc(F.modelSelector,()=>a(_e=>!_e));const O=(t==null?void 0:t.providerId)??null,B=(t==null?void 0:t.providerModel)??null,q=(z==null?void 0:z.split("/")[0])??null,$=(z==null?void 0:z.split("/").slice(1).join("/"))??null,Y=gt(_e=>_e.defaults),Q=gt(_e=>_e.userItems),X=gt(_e=>_e.modelOverrides),K=t==null?void 0:t.mode,P=K?Y.find(_e=>_e.id===K)??Q.find(_e=>_e.id===K):void 0,J=K?X[K]??void 0:void 0,ne=J?J.split("/")[0]??null:null,ce=J?J.split("/").slice(1).join("/")??null:null,ae=K?Yo([...Y,...Q],K):void 0,Ee=!!J,ve=ne??O??q,Le=ce??B??$,Me=Le?((Kn=Le.split("/").pop())==null?void 0:Kn.replace(/-/g," "))??Le:"No model",[ke,Ge]=N.useState(!1);N.useEffect(()=>{function _e(rt){h.current&&!h.current.contains(rt.target)&&(a(!1),u([]),R.current=new Set)}return document.addEventListener("mousedown",_e),()=>document.removeEventListener("mousedown",_e)},[]),N.useEffect(()=>()=>{T.current!==null&&window.clearTimeout(T.current)},[]),N.useEffect(()=>{r||(rn(""),ye(-1))},[r]),N.useEffect(()=>{var _e;r&&((_e=Lt.current)==null||_e.focus())},[r]),N.useEffect(()=>{if(r){const _e=M.map(rt=>rt.id);u(_e),M.filter(rt=>!!rt.authAdapter).forEach(rt=>void se(rt.id)),_e.forEach(rt=>{R.current.has(rt)||(R.current.add(rt),ge(rt))})}},[r,M]),N.useEffect(()=>{if(!_)return;let _e=!1;const rt=async()=>{const we=await se(_.providerId);_e||we==="connected"&&(b(null),E(!1),L(!1),await ee(),R.current.delete(_.providerId),await ge(_.providerId))};rt();const fe=window.setInterval(()=>void rt(),2e3);return()=>{_e=!0,window.clearInterval(fe)}},[_]);const Xe=M.find(_e=>_e.id===ve),Se=(Xe==null?void 0:Xe.status)==="disconnected",Ie=(_e,rt)=>t?t.providerId===_e&&t.providerModel===rt:!1,it=(_e,rt)=>z?z===`${_e}/${rt}`:!1,ge=async _e=>{d(_e);try{await V(_e)}catch{}finally{d(null)}},Fe=_e=>{l.includes(_e.id)?u(l.filter(rt=>rt!==_e.id)):(u([...l,_e.id]),ge(_e.id))},He=async _e=>{if(_e.id===W){Fe(_e);return}t?(n(_e.id,void 0),a(!1),u([])):await I(_e.id)&&(a(!1),u([]))},ie=_e=>{Fe(_e)},xe=async(_e,rt)=>{_e.stopPropagation(),R.current.delete(rt),await ge(rt)},se=async _e=>{const rt=await Ce(`/api/provider-auth/${_e}/status`);if(!rt.ok)return"error";const fe=await rt.json();return C(we=>({...we,[_e]:fe.state})),fe.state},he=async(_e,rt)=>{_e.stopPropagation(),w(rt),C(fe=>({...fe,[rt]:"pending"})),E(!1),L(!1);try{const fe=await Ce(`/api/provider-auth/${rt}/login`,{method:"POST"});if(!fe.ok)throw new Error("Unable to start provider sign-in");const we=await fe.json();b({providerId:rt,...we})}catch{C(fe=>({...fe,[rt]:"error"}))}finally{w(null)}},Pe=async()=>{var _e;_!=null&&_.userCode&&(await((_e=navigator.clipboard)==null?void 0:_e.writeText(_.userCode)),T.current!==null&&window.clearTimeout(T.current),E(!1),requestAnimationFrame(()=>E(!0)),T.current=window.setTimeout(()=>{E(!1),T.current=null},1500))},qe=()=>{_&&(window.open(_.directUrl??_.verificationUrl,"_blank","noopener,noreferrer"),L(!0))},Ke=()=>{b(null),E(!1),L(!1)},et=async(_e,rt)=>{_e.stopPropagation(),w(rt);try{if(!(await Ce(`/api/provider-auth/${rt}/logout`,{method:"POST"})).ok)throw new Error("Unable to disconnect provider account");C(we=>({...we,[rt]:"disconnected"})),await ee()}finally{w(null)}},ot=(_e,rt)=>{m({providerId:_e,model:rt}),y(!0)},ue=p?M.find(_e=>_e.id===p.providerId):void 0,$e=()=>{m(null),y(!1)},ut=async _e=>{try{if(!(await Ce(`/api/providers/${_e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(FN(_e))})).ok)throw new Error("Failed to update provider");await nn.getState().fetchConfig()}catch{}m(null),y(!1)},ct=async(_e,rt)=>{if(K&&J&&J!==`${_e}/${rt}`&&(Ce(`/api/agents/${K}/model`,{method:"DELETE"}).catch(()=>{}),gt.setState(we=>{const Be={...we.modelOverrides};return delete Be[K],{modelOverrides:Be}})),t){Re.setState(we=>({currentSession:we.currentSession?{...we.currentSession,providerId:_e,providerModel:rt}:null})),n(_e,rt),u([]),a(!1),Fc();return}await I(_e)&&(u([]),a(!1),Fc())},cn=async(_e,rt,fe)=>{_e.stopPropagation(),Ge(!0);try{await Z(rt,fe)}catch{}finally{Ge(!1)}},{searchQuery:Xt,setSearchQuery:rn,highlightedIndex:On,setHighlightedIndex:ye,visibleGroups:Ye,flatItems:We,handleSearchKeyDown:ze,highlightedRef:tt,inputRef:Lt}=$N({providers:M,onSelect:ct,onEscape:()=>a(!1),extraItemCount:1}),hn=On===We.length,fn=_e=>{if(_e.key==="Enter"&&On===We.length){_e.preventDefault(),e("/onboarding"),a(!1);return}ze(_e)};return M.length===0?i.jsxs("button",{type:"button",onClick:()=>U(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:Se?"LLM server is offline. Click to retry.":Me??"Click to refresh model",children:[Se?i.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):i.jsx(vC,{activeProvider:Xe,shortModelName:Me,agentOverrideActive:Ee,agentColor:ae,agentName:P==null?void 0:P.name}),i.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):i.jsxs("div",{className:"relative",ref:h,children:[i.jsxs("button",{type:"button",onClick:()=>a(!r),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:"Click to switch provider or model",children:[Se?i.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):i.jsx(vC,{activeProvider:Xe,shortModelName:Me,agentOverrideActive:Ee,agentColor:ae,agentName:P==null?void 0:P.name}),i.jsx(yn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:r?180:0})]}),r&&i.jsxs("div",{className:"absolute bottom-full right-0 mb-1 min-w-72 max-w-[100vw] bg-bg-secondary border border-border rounded-lg shadow-lg z-50 flex flex-col max-h-[80vh]",children:[i.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[i.jsx(Vi,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),i.jsx("input",{ref:Lt,type:"text",value:Xt,onInput:_e=>{rn(_e.currentTarget.value),ye(-1)},onKeyDown:fn,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),i.jsx(Ze,{className:"flex-1 min-h-0",children:i.jsxs("div",{children:[Ye.map(_e=>{const rt=Xt.trim().length>0||l.includes(_e.provider.id);return i.jsxs("div",{children:[i.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${_e.provider.id===ve?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${H?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[i.jsxs("div",{onClick:()=>!H&&He(_e.provider),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[i.jsx("span",{className:`text-sm font-medium truncate ${_e.provider.id===ve?"text-accent-primary":"text-text-primary"}`,children:_e.provider.name}),i.jsx("span",{className:"text-xs text-text-muted truncate",children:_e.provider.backend!=="unknown"&&jk(_e.provider.backend)})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!!_e.provider.authAdapter&&(S[_e.provider.id]==="connected"||_e.provider.credentialRef?i.jsx("button",{type:"button",onClick:fe=>et(fe,_e.provider.id),disabled:v===_e.provider.id,className:"text-[10px] px-1.5 py-0.5 rounded border border-accent-success/40 text-accent-success hover:bg-accent-success/10 disabled:opacity-50",title:"Disconnect provider account",children:"Connected"}):i.jsx("button",{type:"button",onClick:fe=>he(fe,_e.provider.id),disabled:v===_e.provider.id,className:"text-[10px] px-1.5 py-0.5 rounded border border-accent-primary/40 text-accent-primary hover:bg-accent-primary/10 disabled:opacity-50",title:"Connect provider account",children:v===_e.provider.id?"Starting…":S[_e.provider.id]==="error"||S[_e.provider.id]==="expired"?"Retry":"Connect"})),_e.provider.id===ve?i.jsx("span",{className:"text-accent-success",title:"Active provider",children:i.jsx(is,{className:"w-4 h-4"})}):i.jsx("span",{className:"w-4"}),i.jsx("button",{type:"button",onClick:fe=>{fe.stopPropagation(),xe(fe,_e.provider.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:i.jsx(Wh,{className:`w-4 h-4 ${c===_e.provider.id?"animate-spin":""} ${_e.provider.id===W?"text-accent-primary":"text-text-muted"}`})}),i.jsx("button",{type:"button",onClick:fe=>{fe.stopPropagation(),ie(_e.provider)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:i.jsx(yn,{className:`w-4 h-4 transition-transform ${rt?"rotate-180":""} ${_e.provider.id===W?"text-accent-primary":"text-text-muted"}`})})]})]}),rt&&i.jsx(Ze,{className:"bg-bg-primary border-t border-border max-h-40",children:c===_e.provider.id?i.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):_e.models.length>0?_e.models.map(fe=>{const Be=We.findIndex(Qe=>Qe.providerId===_e.provider.id&&Qe.modelConfig.id===fe.id)===On;return i.jsx("div",{ref:Be?tt:void 0,children:i.jsx(BN,{providerId:_e.provider.id,modelConfig:fe,isActive:Ie(_e.provider.id,fe.id),isDefault:it(_e.provider.id,fe.id),disabled:c==="activating",hasSession:!!t,settingDefault:ke,highlighted:Be,onModelClick:ct,onSetDefault:cn,onEditModel:ot})},`${_e.provider.id}/${fe.id}`)}):i.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},_e.provider.id)}),Ye.length===0&&Xt.trim()&&i.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No models match your search"})]})}),i.jsx("div",{className:`border-t border-border px-3 py-2 ${hn?"bg-bg-tertiary":""} flex-shrink-0`,children:i.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),_&&i.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/70 px-4",role:"dialog","aria-modal":"true","aria-labelledby":"provider-device-title",onMouseDown:_e=>{_e.target===_e.currentTarget&&Ke()},children:i.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border bg-bg-secondary p-6 shadow-2xl",children:[i.jsxs("div",{className:"flex items-start justify-between gap-4",children:[i.jsxs("div",{children:[i.jsx("h2",{id:"provider-device-title",className:"text-lg font-semibold text-text-primary",children:"Connect provider"}),i.jsx("p",{className:"mt-1 text-sm text-text-muted",children:"Follow the provider instructions to complete authorization."})]}),i.jsx("button",{type:"button",onClick:Ke,className:"rounded px-2 py-1 text-xl leading-none text-text-muted hover:bg-bg-tertiary hover:text-text-primary","aria-label":"Close",children:"×"})]}),_.mode!=="browser"?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",onClick:Pe,className:"mt-6 w-full select-all rounded-lg border border-accent-primary/40 bg-bg-primary px-4 py-5 font-mono text-3xl font-semibold tracking-[0.2em] text-accent-primary hover:bg-bg-tertiary",title:"Copy code",children:_.userCode??"Continue"}),i.jsx("div",{className:"mt-3 text-center text-xs text-text-muted",children:k?"Copied to clipboard":"Click the code to copy it"}),i.jsxs("div",{className:"mt-6 flex gap-3",children:[i.jsx("button",{type:"button",onClick:Pe,className:"flex-1 rounded-lg border border-border px-4 py-2 text-sm text-text-primary hover:bg-bg-tertiary",children:k?"Copied":"Copy code"}),i.jsx("button",{type:"button",onClick:qe,className:"flex-1 rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:D?"Reopen authorization":"Open authorization"})]}),i.jsx("p",{className:"mt-4 text-center text-xs text-text-muted",children:D?"If the browser blocked or closed the tab, reopen authorization.":"OpenFox stays open while you complete authorization in the other tab."})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"mt-6 text-sm text-text-secondary leading-relaxed bg-bg-primary p-4 rounded-lg border border-border",children:_.instructions}),i.jsx("div",{className:"mt-6 flex gap-3",children:i.jsx("button",{type:"button",onClick:qe,className:"w-full rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:D?"Reopen authorization":"Open authorization"})})]})]})}),p&&x&&i.jsx(UN,{isOpen:!0,onClose:$e,onSave:ut,initialStep:2,editProvider:{id:p.providerId,name:(ue==null?void 0:ue.name)??"",url:(ue==null?void 0:ue.url)??"",backend:(ue==null?void 0:ue.backend)??"unknown",apiKey:ue==null?void 0:ue.apiKey,isLocal:ue==null?void 0:ue.isLocal,thinkingField:ue==null?void 0:ue.thinkingField,sendReasoningInMessages:ue==null?void 0:ue.sendReasoningInMessages,authAdapter:ue==null?void 0:ue.authAdapter,transportAdapter:ue==null?void 0:ue.transportAdapter,models:ue==null?void 0:ue.models},editModelId:p.model.id})]})}function kU(){const e=Ac(k=>k.servers),t=Ac(k=>k.fetchServers),n=Re(k=>k.currentSession),r=n==null?void 0:n.id,[a,l]=N.useState(!1),[u,c]=N.useState(null),[d,h]=N.useState(new Set),[p,m]=N.useState(new Set),x=N.useRef(null),y=N.useCallback(async()=>{if(r)try{const k=await Ce(`/api/sessions/${r}/mcp/overrides`);if(k.ok){const E=await k.json();m(new Set(E.disabledServers??[]))}}catch{}},[r]),S=N.useCallback(async()=>{await t(),await y()},[t,y]);N.useEffect(()=>{const k=()=>S();return window.addEventListener("mcp-servers-changed",k),()=>window.removeEventListener("mcp-servers-changed",k)},[S]),N.useEffect(()=>{y()},[y]),N.useEffect(()=>{a&&y()},[a,y]),yf(x,()=>l(!1));const C=k=>p.has(k.name),v=e.filter(k=>k.status==="connected"&&!C(k)),w=v.length,_=v.reduce((k,E)=>k+E.estimatedTokens,0),b=async(k,E)=>{if(r){c(null),h(T=>new Set(T).add(k));try{const T=new Set(p);E?T.add(k):T.delete(k);const D=await Ce(`/api/sessions/${r}/mcp/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabledServers:Array.from(T)})});if(!D.ok){const L=await D.json().catch(()=>({}));throw new Error(L.error??"Toggle failed")}m(T),await t()}catch(T){c(T instanceof Error?T.message:String(T))}finally{h(T=>{const D=new Set(T);return D.delete(k),D})}}};return i.jsxs("div",{className:"relative",ref:x,children:[i.jsxs("button",{type:"button",onClick:()=>l(!a),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:w>0?`${w} MCP server(s) active`:"No MCP server active",children:[i.jsx("span",{className:"text-sm text-accent-primary whitespace-nowrap",children:w>0?`● ${w} MCP (${Ch(_)})`:"MCP"}),i.jsx(yn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:a?180:0})]}),a&&i.jsxs("div",{className:"absolute bottom-full right-0 mb-1 min-w-72 max-w-[100vw] bg-bg-secondary border border-border rounded-lg shadow-lg z-50 flex flex-col max-h-[80vh]",children:[i.jsx(Ze,{className:"flex-1 min-h-0",children:e.length===0?i.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No MCP servers configured"}):e.map(k=>{const E=C(k),T=d.has(k.name);return i.jsx("div",{children:i.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-bg-tertiary",children:[i.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[i.jsx("span",{className:`text-sm ${qy(E?"disabled":k.status)}`,children:Ky(E?"disabled":k.status)}),i.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:k.name})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted ml-3.5",children:[i.jsxs("span",{children:[k.tools.length," tools"]}),k.estimatedTokens>0&&i.jsxs("span",{children:[Ch(k.estimatedTokens)," tokens"]})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[T&&i.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"..."}),i.jsx(ns,{enabled:!E,onClick:()=>b(k.name,!E)})]})]})},k.name)})}),i.jsx("div",{className:"border-t border-border px-3 py-2 flex-shrink-0",children:u?i.jsx("div",{className:"text-xs text-accent-error",children:u}):i.jsxs("span",{className:"text-xs text-text-muted",children:[e.length," server(s) configured"]})})]})]})}function jU(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r===-1)return null;const a=n.slice(r+1);return a.includes(" ")||a.includes(`
|
|
318
|
+
`)||a.includes(" ")?null:{query:a,startIndex:r}}const EU=N.forwardRef(function({text:t,cursorPos:n,workdir:r,onSelect:a},l){const u=jU(t,n),[c,d]=N.useState([]),[h,p]=N.useState(!1),[m,x]=N.useState(0),y=N.useRef(null),S=N.useRef([]),C=N.useRef(0),v=N.useRef([]);N.useEffect(()=>{C.current=m},[m]),N.useEffect(()=>{v.current=c},[c]),N.useEffect(()=>{if(!u){d([]);return}const b=setTimeout(()=>{w(u.query)},150);return()=>clearTimeout(b)},[u==null?void 0:u.query,r]);const w=async b=>{p(!0);try{const k=new URLSearchParams({q:b});r&&k.set("workdir",r);const T=await(await Ce(`/api/files?${k.toString()}`)).json();d(T),x(0),C.current=0}catch(k){console.error("File search failed:",k),d([])}finally{p(!1)}},_=N.useCallback(b=>{if(!u)return!1;switch(b.key){case"ArrowDown":return b.preventDefault(),x(k=>{var T;const E=Math.min(k+1,v.current.length-1);return S.current[E]&&((T=S.current[E])==null||T.scrollIntoView({block:"nearest"})),E}),C.current=Math.min(C.current+1,v.current.length-1),!0;case"ArrowUp":return b.preventDefault(),x(k=>{var T;const E=Math.max(k-1,0);return S.current[E]&&((T=S.current[E])==null||T.scrollIntoView({block:"nearest"})),E}),C.current=Math.max(C.current-1,0),!0;case"Enter":case"Tab":{const k=v.current;return k[C.current]?(b.preventDefault(),a(k[C.current],u.startIndex),!0):!1}case"Escape":return b.preventDefault(),d([]),!0}return!1},[u,a]);return N.useImperativeHandle(l,()=>({handleKeyDown:_}),[_]),N.useEffect(()=>{if(!u)return;const b=k=>{y.current&&!y.current.contains(k.target)&&d([])};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[u]),u?h?i.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:i.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg",children:i.jsx("div",{className:"p-4 text-center",children:i.jsx(Gi,{size:"sm"})})})}):c.length===0?null:i.jsx("div",{ref:y,className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:i.jsx(Ze,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:i.jsx("ul",{children:c.map((b,k)=>i.jsxs("li",{ref:E=>{S.current[k]=E},className:`px-3 py-2 cursor-pointer flex items-center gap-2 text-sm ${k===m?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{u&&a(b,u.startIndex)},children:[b.type==="directory"?i.jsx(Vr,{className:"w-4 h-4 shrink-0"}):i.jsx("span",{className:"w-4 h-4 shrink-0"}),i.jsx("span",{className:"truncate",children:b.path})]},b.path))})})}):null});function NU(e,t){const n=e.slice(0,t);if(n.length===0||n[0]!=="/")return null;const r=n.slice(1);return r.includes(" ")||r.includes(`
|
|
319
|
+
`)||r.includes(" ")?null:{query:r,startIndex:0}}const TU=N.forwardRef(function({text:t,cursorPos:n,workflows:r,commands:a,onSelect:l},u){const c=NU(t,n),[d,h]=N.useState(0),p=N.useRef(null),m=N.useRef([]),x=N.useRef(0),y=N.useRef([]);N.useEffect(()=>{x.current=d},[d]),N.useEffect(()=>{y.current=C});const S=(c==null?void 0:c.query)??"",C=(()=>{if(!c)return[];const w=S.toLowerCase(),_=r.filter(k=>k.id.toLowerCase().includes(w)||k.name.toLowerCase().includes(w)).map(k=>({type:"workflow",id:k.id,name:k.name,paramCount:(k.parameters??[]).length})),b=a.filter(k=>k.id.toLowerCase().includes(w)||k.name.toLowerCase().includes(w)).map(k=>({type:"command",id:k.id,name:k.name,paramCount:0}));return[..._,...b]})();N.useEffect(()=>{h(0),x.current=0},[C.length]);const v=N.useCallback(w=>{if(!c||C.length===0)return!1;switch(w.key){case"ArrowDown":return w.preventDefault(),h(_=>{var k;const b=Math.min(_+1,C.length-1);return(k=m.current[b])==null||k.scrollIntoView({block:"nearest"}),b}),!0;case"ArrowUp":return w.preventDefault(),h(_=>{var k;const b=Math.max(_-1,0);return(k=m.current[b])==null||k.scrollIntoView({block:"nearest"}),b}),!0;case"Enter":case"Tab":{const _=C[x.current];return _?(w.preventDefault(),l(_,c.startIndex),!0):!1}case"Escape":return w.preventDefault(),!0}return!1},[c,C,l]);return N.useImperativeHandle(u,()=>({handleKeyDown:v}),[v]),!c||C.length===0?null:i.jsx("div",{ref:p,className:"absolute bottom-full left-0 right-0 mb-2 z-50",role:"listbox",children:i.jsx(Ze,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:i.jsx("div",{children:C.map((w,_)=>i.jsxs("button",{ref:b=>{m.current[_]=b},role:"option","aria-selected":_===d,className:`w-full text-left px-3 py-2 flex items-center gap-2 text-sm ${_===d?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{c&&l(w,c.startIndex)},children:[i.jsxs("span",{className:`font-medium ${w.type==="workflow"?"text-accent-primary":"text-accent-warning"}`,children:["/",w.id]}),i.jsx("span",{className:"truncate flex-1",children:w.name}),w.paramCount>0&&i.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded",children:[w.paramCount," param",w.paramCount>1?"s":""]})]},`${w.type}-${w.id}`))})})})});function AU({input:e,setInput:t,attachments:n,setAttachments:r,dragOver:a,setDragOver:l,errorMessage:u,setErrorMessage:c,scrollToBottom:d,sessionId:h,showHistory:p,history:m,selectedIndex:x,openHistory:y,closeHistory:S,navigateUp:C,navigateDown:v,selectCurrent:w,isAutoScrollActive:_,setAutoScroll:b,onOpenMessageSearch:k,onOpenCommandsModal:E,onOpenWorkflowsModal:T,onSelectWorkflow:D,onSelectWorkflowWithSubGroup:L,onSendCommand:R,clearInput:M}){const W=N.useRef(null),z=N.useRef(null),H=N.useRef(0),I=N.useRef(0),U=N.useRef(null),V=N.useRef(null),Z=Vh(),ee=Re(se=>se.stopGeneration),F=Re(se=>se.cancelQueued),O=Re(se=>se.queuedMessages),B=Re(se=>se.restoredInput),q=Re(se=>se.clearRestoredInput),$=Re(se=>{var he;return(he=se.currentSession)==null?void 0:he.workdir}),Y=Re(se=>se.currentSession),Q=N.useRef(!1),X=N.useRef(!1),K=N.useRef(!1),[P,J]=N.useState([]),{sendMessage:ne,launchWorkflow:ce}=PN(b);N.useEffect(()=>{if(X.current)return;X.current=!0;const se=kt.getState();se.defaults.length===0&&se.userItems.length===0&&se.projectItems.length===0&&se.fetchWorkflows();const he=on.getState();he.defaults.length===0&&he.userItems.length===0&&he.projectItems.length===0&&he.fetchCommands()},[]),N.useEffect(()=>{e||J([])},[e]),N.useEffect(()=>{var se;B!==null&&(t(B),q(),(se=W.current)==null||se.focus())},[B,t,q]);const ae=N.useCallback(()=>{const se=W.current;if(!se)return;const he=e.length>=H.current;H.current=e.length,he||(se.style.height="auto"),se.style.height=`${Math.min(200,se.scrollHeight)}px`},[e]);N.useEffect(()=>{if(!h)return;const se=`openfox:draft:${h}`,he=localStorage.getItem(se);he!==null&&t(he)},[h,t]),N.useEffect(()=>{var se;(se=W.current)==null||se.focus(),ae()},[h,ae]),N.useEffect(()=>{if(!h)return;const se=`openfox:draft:${h}`,he=setTimeout(()=>{e?localStorage.setItem(se,e):localStorage.removeItem(se)},500);return()=>clearTimeout(he)},[h,e]),N.useEffect(()=>{ae()},[e,ae]),N.useEffect(()=>{const se=W.current;if(!se)return;const he=async Pe=>{var et;if(document.activeElement!==se)return;const qe=(et=Pe.clipboardData)==null?void 0:et.items;if(!qe)return;const Ke=[];for(const ot of Array.from(qe)){let ue=ot.getAsFile();if(ue&&oF(ue.type)){if(Pe.preventDefault(),!ue.name){const $e=aF(ue.type);ue=new File([ue],`pasted-file.${$e}`,{type:ue.type})}await pC(ue,$e=>Ke.push($e),c)}}Ke.length>0&&r(ot=>[...ot,...Ke])};return se.addEventListener("paste",he),()=>se.removeEventListener("paste",he)},[r,c]);const Ee=se=>{se.preventDefault(),!(!e.trim()&&n.length===0)&&it()},ve=se=>{var he,Pe;if(!((he=V.current)!=null&&he.handleKeyDown(se))&&!((Pe=U.current)!=null&&Pe.handleKeyDown(se))){if(p)switch(se.key){case"Enter":{se.preventDefault();const qe=w();qe&&(t(qe),S());return}case"Escape":se.preventDefault(),S(),Z&&ee();return;case"ArrowUp":se.preventDefault(),C();return;case"ArrowDown":se.preventDefault(),v();return}if(se.key==="ArrowUp"&&e.trim()===""&&!p){se.preventDefault(),y();return}se.key==="Enter"&&!se.shiftKey&&(se.preventDefault(),Ee(se))}};async function Le(se,he,Pe){const qe=[];for(const Ke of Array.from(se))await pC(Ke,et=>qe.push(et),Pe);qe.length>0&&he(Ke=>[...Ke,...qe])}const Me=N.useCallback(async se=>{const he=se.target.files;!he||he.length===0||(c(null),await Le(he,r,c),z.current&&(z.current.value=""))},[r,c]),ke=N.useCallback(se=>{var he;(he=se.dataTransfer.types)!=null&&he.includes("Files")&&(se.preventDefault(),se.stopPropagation(),l(!0))},[l]),Ge=N.useCallback(se=>{se.preventDefault(),se.stopPropagation(),l(!1)},[l]),Xe=N.useCallback(async se=>{se.preventDefault(),se.stopPropagation(),l(!1),c(null);const he=se.dataTransfer.files;!he||he.length===0||await Le(he,r,c)},[r,l,c]),Se=N.useCallback(se=>{r(n.filter(he=>he.id!==se))},[n,r]),Ie=N.useCallback(()=>{var se;(se=z.current)==null||se.click()},[]),it=()=>{if(K.current||!e.trim()&&n.length===0)return;if(K.current=!0,d==null||d(),e.trim().startsWith("/")){const he=kt.getState(),Pe=[...he.defaults,...he.userItems,...he.projectItems],qe=on.getState(),Ke=[...qe.defaults,...qe.userItems,...qe.projectItems],et=UF(e,Pe,Ke);if(et!=null&&et.workflowId){const ot=Pe.find($e=>$e.id===et.workflowId),ue=((ot==null?void 0:ot.parameters)??[]).filter($e=>$e.required&&!($e.id in et.params));if(ue.length>0){const $e=ue.map(ut=>ut.label||ut.id).join(", ");c(`Missing required parameter${ue.length>1?"s":""}: ${$e}`),K.current=!1;return}ce(void 0,void 0,et.workflowId,void 0,et.params),M(),K.current=!1;return}if(et!=null&&et.commandId){qe.fetchCommand(et.commandId).then(ot=>{if(ot){const ue=IN(ot.prompt),$e={};for(const[ct,cn]of Object.entries(et.params)){const Xt=parseInt(ct,10),rn=ue[Xt];rn&&($e[rn]=cn)}let ut=ot.prompt;for(const[ct,cn]of Object.entries($e))ut=ut.replaceAll(`{{${ct}}}`,cn);ne(ut,void 0),M()}K.current=!1});return}M(),K.current=!1;return}ne(e,n),M(),K.current=!1},ge=N.useCallback((se,he)=>{const qe=se.type==="directory"?"/":" ",Ke=e.slice(0,he),et=e.slice(I.current),ot=`${Ke}@${se.path}${qe}${et}`;t(ot);const ue=he+se.path.length+2;I.current=ue,W.current&&(W.current.selectionStart=ue,W.current.selectionEnd=ue,W.current.focus())},[e,t]),Fe=N.useCallback((se,he)=>{const Pe=e.slice(0,he),qe=e.slice(I.current),Ke=`${Pe}/${se.id} ${qe}`;t(Ke);const et=he+se.id.length+2;if(I.current=et,W.current&&(W.current.selectionStart=et,W.current.selectionEnd=et,W.current.focus()),se.type==="workflow"){const ot=[...kt.getState().defaults,...kt.getState().userItems,...kt.getState().projectItems].find(ue=>ue.id===se.id);J(((ot==null?void 0:ot.parameters)??[]).map(ue=>ue.id))}else{const ot=on.getState(),ue=[...ot.defaults,...ot.userItems,...ot.projectItems].find($e=>$e.id===se.id);J((ue==null?void 0:ue.paramNames)??[])}},[e,t]),He=N.useCallback(se=>{const he=se.target.value;t(he),p&&S(),I.current=se.target.selectionStart,P.length>0&&(!he.startsWith("/")||!he.includes(" "))&&J([]),!Q.current&&h&&he&&Y&&Y.messages.length===0&&(Q.current=!0,Ce(`/api/sessions/${h}/warmup`,{method:"POST"}).catch(()=>{}))},[t,p,S,h,Y,P]),ie=N.useCallback(se=>{I.current=se.target.selectionStart},[]),xe=N.useCallback(se=>{I.current=se.currentTarget.selectionStart},[]);return i.jsxs("div",{className:"relative",children:[Z&&i.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:i.jsx(GF,{})}),i.jsxs("div",{className:`absolute -top-8 right-2 md:right-4 z-10 flex items-center gap-2 border${_?" border-transparent":" rounded backdrop-blur-xl saturate-150 border-border"}`,children:[i.jsx(Qy,{isActive:_,onToggle:b,className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),i.jsxs("button",{type:"button",onClick:k,className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors","aria-label":"Browse history",children:[i.jsx(Vi,{}),"Browse history"]})]}),i.jsx(qF,{}),i.jsxs("form",{onSubmit:Ee,className:"p-2 md:p-4 bg-secondary rounded-lg",children:[i.jsx("input",{ref:z,type:"file",accept:"image/*,text/*,.pdf,.json,.xml,.yaml,.yml,.js,.sh,.xhtml",onChange:Me,className:"hidden",multiple:!0}),u&&i.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:u}),n.length>0&&i.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(se=>i.jsx(VF,{attachment:se,onRemove:Se},se.id))}),p&&i.jsx(WF,{history:m,selectedIndex:x,onSelect:se=>{t(se),S()},onEscape:S,onNavigate:se=>{se==="up"?C():v()}}),i.jsx(dU,{messages:O,onCancel:F}),i.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${a?"bg-accent-primary/10":"bg-primary"}`,onDragOver:ke,onDragLeave:Ge,onDrop:Xe,children:[i.jsxs("div",{className:"relative flex-1 min-w-0",children:[i.jsx("textarea",{id:U2,ref:W,value:e,onChange:He,onKeyDown:ve,onSelect:ie,onKeyUp:xe,placeholder:"What would you like to build?","data-testid":"chat-input-textarea",className:"w-full bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:"24px",maxHeight:"200px"},spellCheck:!1}),i.jsx(EU,{ref:U,text:e,cursorPos:I.current,workdir:$,onSelect:ge}),i.jsx(TU,{ref:V,text:e,cursorPos:I.current,workflows:(()=>{const se=kt.getState();return[...se.defaults,...se.userItems,...se.projectItems]})(),commands:(()=>{const se=on.getState();return[...se.defaults,...se.userItems,...se.projectItems]})(),onSelect:Fe}),P.length>0&&(()=>{const se=e.match(/\/(\w+)\s+(.*)$/),Pe=(se?se[2].trim().split(/\s+/):[]).filter(Boolean).length,qe=P[Pe];return qe?i.jsxs("span",{className:"absolute left-3 top-[26px] text-sm text-text-muted/40 pointer-events-none select-none","aria-hidden":!0,children:[qe,"=?"]}):null})()]}),i.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[Z&&i.jsxs("button",{type:"button",onClick:()=>ee(),"data-testid":"chat-stop-button",className:"flex items-center gap-1 px-4 py-1.5 rounded bg-accent-error/20 text-sm text-accent-error font-medium hover:bg-accent-error/30 transition-colors whitespace-nowrap",children:[i.jsx(ay,{}),"Abort"]}),i.jsxs("div",{className:"flex items-center",children:[i.jsx("button",{type:"button",onClick:it,disabled:!e.trim()&&n.length===0,"data-testid":"chat-send-button",className:"px-4 py-1.5 rounded-l bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:"Send"}),i.jsx(cU,{onSendCommand:R,onSelectWorkflow:D,onSelectWorkflowWithSubGroup:L,onOpenCommandsManager:E,onOpenWorkflowsManager:T,onAttach:Ie,textareaContent:e,attachments:n.length>0?n:void 0})]})]})]}),i.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(bU,{}),i.jsx(vU,{})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[Vt(se=>se.settings)[Ae.FEATURES_PER_SESSION_MCP]==="true"&&i.jsx(kU,{}),i.jsx(CU,{})]})]})]})]})}function _C({workflowName:e,parameters:t,onConfirm:n,onCancel:r,confirmLabel:a="Run workflow"}){const[l,u]=N.useState({}),c=[...t].sort((p,m)=>(p.position??0)-(m.position??0)),d=()=>{var m;const p={};for(const x of c){const y=(m=l[x.id])==null?void 0:m.trim();y&&(p[x.id]=y)}n(p)},h=c.every(p=>{var m;return!p.required||(((m=l[p.id])==null?void 0:m.trim())??"")!==""});return i.jsxs(Tt,{isOpen:!0,onClose:r,title:`Run: ${e}`,size:"sm",closeOnEscape:!0,closeOnBackdropClick:!0,children:[i.jsx("div",{className:"space-y-3 py-2",children:c.map(p=>i.jsxs("label",{className:"block",children:[i.jsxs("span",{className:"text-sm text-text-primary font-medium",children:[p.label||p.id,p.required&&i.jsx("span",{className:"text-accent-error ml-1",children:"*"})]}),p.description&&i.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:p.description}),i.jsx("input",{value:l[p.id]??"",onChange:m=>u(x=>({...x,[p.id]:m.target.value})),placeholder:p.label||p.id,className:"mt-1 w-full px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-accent-primary",autoFocus:p.position===0||p===c[0]})]},p.id))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border",children:[i.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm text-text-muted hover:text-text-primary transition-colors",children:"Cancel"}),i.jsx("button",{onClick:d,disabled:!h,className:"px-4 py-1.5 text-sm font-medium rounded bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a})]})]})}const SC=9999,Hd=N.forwardRef(function({trigger:t,children:n},r){const[a,l]=N.useState(!1),u=N.useRef(null),c=N.useRef(null),d=N.useRef(null),h=N.useCallback(()=>{l(!1)},[]);N.useImperativeHandle(r,()=>({close:h}),[h]);const p=N.useCallback(m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),a?h():(d.current=document.activeElement,l(!0))),m.key==="Escape"&&a&&h()},[a,h]);return N.useEffect(()=>{var S;if(!a){(S=d.current)==null||S.focus(),d.current=null;return}const m=C=>{c.current&&!c.current.contains(C.target)&&u.current&&!u.current.contains(C.target)&&h()},x=C=>{C.key==="Escape"&&h()},y=()=>h();return document.addEventListener("mousedown",m),document.addEventListener("keydown",x),window.addEventListener("blur",y),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",x),window.removeEventListener("blur",y)}},[a,h]),i.jsxs(i.Fragment,{children:[i.jsx("span",{ref:u,role:"button",tabIndex:0,"aria-expanded":a,className:"inline-flex cursor-pointer text-text-muted hover:text-text-primary transition-colors outline-none focus-visible:ring-1 focus-visible:ring-accent-primary/50 rounded",onClick:()=>{a||(d.current=document.activeElement),l(m=>!m)},onKeyDown:p,children:t}),a&&si.createPortal(i.jsx("div",{ref:c,role:"dialog","aria-modal":"true",className:"fixed bg-bg-secondary border border-border rounded-lg shadow-xl p-3 w-[320px] max-w-[calc(100vw-16px)] max-h-[60vh]",style:(()=>{if(!u.current)return{zIndex:SC,top:0,left:0};const m=u.current.getBoundingClientRect(),x=320,y=8;let S=m.left;return S+x>window.innerWidth-y&&(S=m.right-x),S=Math.max(y,Math.min(S,window.innerWidth-x-y)),{zIndex:SC,top:m.bottom+4,left:S}})(),children:i.jsx(Ze,{className:"max-h-full",children:n})}),document.body)]})});function LU({entries:e}){const t=new Map;for(const r of e)t.set(r.status,(t.get(r.status)??0)+1);const n=tN.filter(r=>(t.get(r)??0)>0);return n.length===0?i.jsx("span",{className:"text-text-muted text-sm",children:"None"}):i.jsx("span",{className:"flex items-center gap-1.5 text-sm",children:n.map(r=>i.jsxs("span",{className:"flex items-center gap-0.5",children:[i.jsx(ll,{status:r}),i.jsx("span",{className:"text-text-muted",children:t.get(r)})]},r))})}function DU({visible:e}){const t=Re(P=>P.currentSession),n=Un(P=>P.status),r=Un(P=>P.config),a=Un(P=>P.start),l=Re(P=>P.contextState),u=Re(P=>P.queueUpdate),c=Un(P=>P.logs),{branch:d,diff:h}=Yy(),[p,m]=N.useState(!1),[x,y]=N.useState(!1),[S,C]=N.useState(!1),[v,w]=N.useState(null),[_,b]=N.useState(!1),[k,E]=N.useState(!1),T=N.useRef(null),D=N.useRef(null),L=N.useRef(null),R=N.useRef(null),M=Vt(P=>P.settings[Ae.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true";if(!e||!t)return null;const W=t.workspace?t.workspace.split("/").pop()??"original":"original",z=t.workspace??t.workdir,H=t.metadataEntries??{},I=H.criteria??[],U=["review_findings","todos"],V=U.filter(P=>{var J;return P in H&&(((J=H[P])==null?void 0:J.length)??0)>0}),Z=Object.keys(H).filter(P=>P!=="criteria"&&!U.includes(P)).filter(P=>{var J;return(((J=H[P])==null?void 0:J.length)??0)>0}),ee=[...V,...Z].reduce((P,J)=>{var ne;return P+(((ne=H[J])==null?void 0:ne.length)??0)},0),F=[...V,...Z].map(Vo),O=h.files,B=O.reduce((P,J)=>P+J.additions,0),q=O.reduce((P,J)=>P+J.deletions,0),$=(n==null?void 0:n.state)??"off",Y=$==="running"||$==="warning",Q=r!==null,X=P=>{P.stopPropagation(),a()},K=P=>{P.stopPropagation(),n!=null&&n.url&&window.open(n.url,"_blank")};return i.jsxs("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-secondary",children:[i.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:items-center sm:justify-between gap-x-2 gap-y-1 text-sm",children:[i.jsxs("div",{className:"flex items-center gap-1 min-w-0 sm:shrink-0",children:[i.jsx(Vr,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),i.jsx("span",{className:"truncate text-text-secondary max-w-[120px]",children:W}),i.jsx("span",{className:"text-text-muted",children:"/"}),i.jsx(Aa,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),i.jsx("span",{className:"truncate text-text-secondary max-w-[120px]",children:d??"-"}),O.length>0?i.jsxs("span",{className:"text-text-muted shrink-0 font-mono",children:["+",B," -",q]}):i.jsx("span",{className:"shrink-0"}),i.jsx(Hd,{ref:R,trigger:i.jsx(yn,{className:"w-3 h-3"}),children:i.jsx(yN,{workspaceName:W,branch:d,workdir:z,showEditorLink:M,sessionId:t.id,projectId:t.projectId,onEditWorkspace:()=>{var P;(P=R.current)==null||P.close(),b(!0)},onEditBranch:()=>{var P;(P=R.current)==null||P.close(),E(!0)}})})]}),i.jsx("div",{className:"hidden sm:block w-px bg-border self-stretch mx-1"}),i.jsxs("div",{className:"flex-1 flex items-center sm:justify-center justify-self-end gap-1 min-w-0",children:[i.jsx(LU,{entries:I}),ee>0&&i.jsxs("span",{className:"text-text-muted text-xs bg-bg-tertiary px-1 py-0.5 rounded leading-none",title:F.join(", "),children:["+",ee]}),i.jsx(Hd,{ref:L,trigger:i.jsx(yn,{className:"w-3 h-3"}),children:i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("button",{onClick:()=>{var P;(P=L.current)==null||P.close(),w("criteria")},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:i.jsx(Eh,{entries:I,title:"Acceptance Criteria"})}),i.jsx(sN,{entries:I,sessionId:t.id})]}),[...V,...Z].map(P=>{const J=H[P];return i.jsxs("div",{children:[i.jsx("button",{onClick:()=>{var ne;(ne=L.current)==null||ne.close(),w(P)},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:i.jsx(Eh,{entries:J,title:Vo(P)})}),i.jsx(nN,{entries:J})]},P)})]})})]}),i.jsx("div",{className:"hidden sm:block w-px bg-border self-stretch mx-1"}),i.jsx("div",{className:"col-span-2 border-t border-border sm:hidden -mx-4"}),i.jsx("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:l&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-text-muted text-xs font-mono tabular-nums",children:l.currentTokens>=1e3?`${Math.round(l.currentTokens/1e3)}K`:l.currentTokens}),i.jsx(Zy,{percent:Math.round(l.currentTokens/l.maxTokens*100),dangerZone:l.dangerZone,size:"sm"}),i.jsx(Hd,{ref:D,trigger:i.jsx(yn,{className:"w-3 h-3"}),children:i.jsx(vN,{onUpdateSystemPrompt:()=>{var P;(P=D.current)==null||P.close(),C(!0)}})})]})}),i.jsx("div",{className:"hidden sm:block w-px bg-border self-stretch mx-1"}),i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0 justify-self-end",children:[i.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${$==="running"?"bg-accent-success":$==="warning"?"bg-accent-warning":$==="error"?"bg-accent-error":"bg-text-muted"}`}),Q?Y?i.jsx("button",{onClick:K,className:"flex items-center justify-center p-1 rounded text-sm font-medium bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors leading-none",title:"Open dev server",children:i.jsx($k,{className:"w-3.5 h-3.5"})}):i.jsx("button",{onClick:X,className:"flex items-center justify-center p-1 rounded text-sm font-medium bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors leading-none",title:"Start dev server",children:i.jsx(zk,{className:"w-3.5 h-3.5"})}):i.jsx("span",{className:"text-text-muted text-xs",children:"No config"}),i.jsx(Hd,{ref:T,trigger:i.jsx(yn,{className:"w-3 h-3"}),children:i.jsx(cN,{workdir:z,compact:!0,onExpand:()=>m(!0),onConfigure:()=>{var P;(P=T.current)==null||P.close(),y(!0)}})})]})]}),p&&i.jsx(Jy,{title:"Dev Server Logs",logs:c,onClose:()=>m(!1)}),x&&i.jsx(iN,{isOpen:!0,onClose:()=>y(!1)}),v&&t&&i.jsx(rN,{isOpen:!0,onClose:()=>w(null),entries:H[v]??[],sessionId:t.id,metadataKey:v,title:Vo(v)}),_&&i.jsx(gN,{isOpen:!0,onClose:()=>b(!1),projectId:t.projectId,sessionId:t.id,currentWorkspace:W,currentBranch:d}),k&&i.jsx(xN,{isOpen:!0,onClose:()=>E(!1),sessionId:t.id}),S&&l&&i.jsx(eb,{isOpen:!0,onClose:()=>C(!1),isRunning:t.isRunning,onApply:()=>{t.isRunning?u():Pt.send("context.applyDynamic",{}),C(!1)}})]})}function RU(e){return(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="f"&&document.querySelector("[data-global-settings]")===null}function VN(e,t=[]){const n=new Map,r=new Map;for(const h of t)h.type==="message"?n.set(h.message.id,h):h.type==="subagent"&&r.set(h.subAgentId,h);const a=[];let l,u=1,c=null;const d=()=>{if(!c||c.size===0)return;const h=new Map;let p=0;for(const x of e)x.role!=="tool"&&x.contextWindowId===l&&(x.subAgentId&&!h.has(x.subAgentId)&&h.set(x.subAgentId,p),p++);const m=[...c.entries()].sort((x,y)=>(h.get(x[0])??0)-(h.get(y[0])??0));for(const[x,y]of m){const S=r.get(x);(S==null?void 0:S.type)==="subagent"&&S.messages.length===y.messages.length&&S.messages.every((v,w)=>v===y.messages[w])?a.push(S):a.push({type:"subagent",subAgentId:x,subAgentType:y.subAgentType,messages:y.messages})}c=null};for(let h=0;h<e.length;h++){const p=e[h];if(p.role!=="tool")if(p.contextWindowId&&l&&p.contextWindowId!==l&&(d(),u++,a.push({type:"context-divider",windowSequence:u})),l=p.contextWindowId,p.subAgentId&&p.subAgentType){c||(c=new Map);let m=c.get(p.subAgentId);m||(m={subAgentType:p.subAgentType,messages:[]},c.set(p.subAgentId,m)),m.messages.push(p)}else{d();const m=n.get(p.id);(m==null?void 0:m.type)==="message"&&m.message===p?a.push(m):a.push({type:"message",message:p})}}return d(),a}const OU=10,IU=150;function MU(e){const t=[];if(e.recentUserPrompts)for(const n of e.recentUserPrompts)t.push({id:n.id,content:n.content,timestamp:n.timestamp,sessionId:e.id,sessionName:e.title||e.id});return t}function PU(e){return[...e].sort((r,a)=>new Date(a.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,OU).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:GH(r.timestamp),trimmedContent:kh(r.content,IU),sessionId:r.sessionId,sessionName:r.sessionName}))}function BU(e,t,n){const r=[],a=e.filter(l=>l.role==="user"&&!l.isSystemGenerated&&l.messageKind!=="auto-prompt");for(const l of a)r.push({id:l.id,content:l.content,timestamp:l.timestamp,sessionId:n??"",sessionName:"This session"});for(const l of t)n&&l.id===n||r.push(...MU(l));return PU(r)}function $U(e,t=[],n=null){const[r,a]=N.useState(0),[l,u]=N.useState(!1),c=N.useMemo(()=>BU(e,t,n),[e,t,n]),d=N.useCallback(()=>{c.length>0&&(a(c.length-1),u(!0))},[c.length]),h=N.useCallback(()=>{u(!1),a(0)},[]),p=N.useCallback(()=>{a(y=>c.length===0?y:y===0?c.length-1:y-1)},[c.length]),m=N.useCallback(()=>{a(y=>c.length===0?y:y===c.length-1?0:y+1)},[c.length]),x=N.useCallback(()=>{if(c.length===0||!l)return null;const y=c[r];return(y==null?void 0:y.content)??null},[c,r,l]);return{history:c,selectedIndex:r,showHistory:l,openHistory:d,closeHistory:h,navigateUp:p,navigateDown:m,selectCurrent:x}}N.memo(function({item:t}){const[n,r]=N.useState(!1);return t.type==="start"?i.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/30 rounded text-amber-300 text-sm",children:[i.jsx("span",{className:"animate-pulse",children:"●"}),i.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&i.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):i.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[i.jsx("span",{className:"text-accent-success",children:"✓"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),i.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:n?"Hide":"Show"})]}),n&&t.description&&i.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:i.jsx(Jn,{content:t.description})})]})]})});function zU({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t,rawMessages:n,hiddenCount:r}={}){const a=e??!0,[l,u]=N.useState(""),[c,d]=N.useState([]),[h,p]=N.useState(!1),[m,x]=N.useState(null),[y,S]=N.useState(!1),[C,v]=N.useState(!1),[w,_]=N.useState(!1),[b,k]=N.useState(!1),[E,T]=N.useState(null),D=N.useRef(null),L=N.useCallback(()=>{var se,he;return((he=(se=D.current)==null?void 0:se.osInstance())==null?void 0:he.elements().viewport)??null},[]),R=Re(se=>se.currentSession),M=Re(se=>se.messages),W=Re(se=>se.sessions),z=Vh(),H=Re(se=>se.stopGeneration),I=n??M,{maxVisibleItems:U}=Pa(),V=gt(se=>se.defaults),Z=gt(se=>se.userItems),ee=[...V,...Z].filter(se=>!se.subagent),{history:F,selectedIndex:O,showHistory:B,openHistory:q,closeHistory:$,navigateUp:Y,navigateDown:Q,selectCurrent:X}=$U(I,W,R==null?void 0:R.id);N.useEffect(()=>{const se=he=>{T(he.detail.stats)};return window.addEventListener("open-turn-stats",se),()=>window.removeEventListener("open-turn-stats",se)},[]),N.useEffect(()=>{kt.getState().fetchWorkflows()},[]),N.useEffect(()=>{const se=he=>{RU(he)&&(he.preventDefault(),k(!0))};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[]);const K=N.useRef([]),{displayItems:P,hiddenCount:J}=N.useMemo(()=>{const se=VN(I,K.current);return K.current=se,U>0&&se.length>U?{displayItems:se.slice(-U),hiddenCount:se.length-U}:{displayItems:se,hiddenCount:0}},[I,U]),ne=r??J,{isAutoScrollActive:ce,setAutoScroll:ae,handleScrollbarGesture:Ee}=xf(D,R,L),{sendMessage:ve,launchWorkflow:Le}=PN(ae),[Me,ke]=N.useState(null),[Ge,Xe]=N.useState(null),Se=N.useCallback((se,he,Pe)=>{const qe=kt.getState(),et=[...qe.defaults,...qe.userItems,...qe.projectItems].find(ue=>ue.id===se);((et==null?void 0:et.parameters)??[]).filter(ue=>ue.position!==void 0||ue.required).length>0?ke({id:se,name:(et==null?void 0:et.name)??se,subGroup:he}):Le(void 0,void 0,se,he,Pe)},[Le]),Ie=N.useCallback((se,he,Pe)=>{Se(se,he,Pe)},[Se]),it=N.useCallback(se=>{ae(!1);const he=document.querySelector(`[data-item-index="${se}"]`);he&&he.scrollIntoView({behavior:"smooth",block:"center"})},[ae]);N.useEffect(()=>{const se=he=>{const Pe=w||y||C||b||E;he.key==="Escape"&&z&&!Pe&&H(),he.key==="ScrollLock"&&ae(!ce)};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[z,H,ce,w,y,C,b,E]);const ge=Wc();Dc(ge.quickAction,()=>{_(!0)}),Dc(ge.criteriaSidebar,()=>{t==null||t()}),ZR(ge.agentSwitching,ee,se=>{Re.getState().switchMode(se)});const Fe=se=>{Se(se),ie()},He=(se,he)=>{Se(se,he),ie()},ie=()=>{u(""),d([]),R!=null&&R.id&&localStorage.removeItem(`openfox:draft:${R.id}`)},xe=N.useCallback(async(se,he,Pe,qe)=>{const Ke=IN(se);if(Ke.length>0)Xe({prompt:se,paramKeys:Ke,agentMode:he,textareaContent:Pe,attachments:qe});else{he&&(R==null?void 0:R.mode)!==he&&await Re.getState().switchMode(he);const et=Pe&&Pe.trim()?`${Pe.trim()}
|
|
320
|
+
|
|
321
|
+
${se}`:se;ve(et,qe!=null&&qe.length?qe:void 0,{messageKind:"command",isSystemGenerated:!0}),ie()}},[ve,ie,R]);return i.jsxs(i.Fragment,{children:[i.jsxs(c9,{criteriaSidebarOpen:a,onCriteriaSidebarToggle:t,messages:I,children:[i.jsx(DU,{visible:!a}),i.jsx(u9,{}),E&&i.jsx(d9,{stats:E,onClose:()=>T(null)}),i.jsx(yF,{}),i.jsx(gF,{displayItems:P,scrollContainerRef:D,highlightedMessageId:null,onLaunchWorkflow:Ie,onScrollToTop:()=>ae(!1),hiddenCount:ne,onScrollbarGesture:Ee}),i.jsx(AU,{input:l,setInput:u,attachments:c,setAttachments:d,dragOver:h,setDragOver:p,errorMessage:m,setErrorMessage:x,scrollToBottom:()=>{var se,he;return(he=L())==null?void 0:he.scrollTo({top:((se=L())==null?void 0:se.scrollHeight)??0,behavior:"smooth"})},sessionId:R==null?void 0:R.id,showHistory:B,history:F,selectedIndex:O,openHistory:q,closeHistory:$,navigateUp:Y,navigateDown:Q,selectCurrent:X,isAutoScrollActive:ce,setAutoScroll:ae,onOpenMessageSearch:()=>k(!0),onOpenCommandsModal:()=>S(!0),onOpenWorkflowsModal:()=>v(!0),onSelectWorkflow:Fe,onSelectWorkflowWithSubGroup:He,onSendCommand:xe,clearInput:ie}),i.jsx(AN,{isOpen:y,onClose:()=>S(!1)}),i.jsx(RN,{isOpen:C,onClose:()=>v(!1)}),i.jsx(RF,{isOpen:w,onClose:()=>_(!1),onSearchMessages:()=>k(!0),isAutoScrollActive:ce,onToggleAutoScroll:ae,textareaContent:l,onCloseComplete:Fc,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(se,he)=>{const Pe=await on.getState().fetchCommand(se);Pe&&xe(Pe.prompt,Pe.metadata.agentMode,he)},onSelectWorkflow:se=>{Se(se),ie()}}),Me&&i.jsx(_C,{workflowName:Me.name,parameters:(()=>{var Pe;const se=kt.getState();return((Pe=[...se.defaults,...se.userItems,...se.projectItems].find(qe=>qe.id===Me.id))==null?void 0:Pe.parameters)??[]})(),onConfirm:se=>{Le(void 0,void 0,Me.id,Me.subGroup,se),ke(null)},onCancel:()=>ke(null)}),Ge&&i.jsx(_C,{workflowName:"Command",confirmLabel:"Launch command",parameters:Ge.paramKeys.map((se,he)=>({id:se,label:se,position:he})),onConfirm:se=>{let he=Ge.prompt;for(const[ot,ue]of Object.entries(se))he=he.replaceAll(`{{${ot}}}`,ue);const{agentMode:Pe,textareaContent:qe,attachments:Ke}=Ge;Pe&&(R==null?void 0:R.mode)!==Pe&&Re.getState().switchMode(Pe);const et=qe&&qe.trim()?`${qe.trim()}
|
|
322
|
+
|
|
323
|
+
${he}`:he;ve(et,Ke!=null&&Ke.length?Ke:void 0,{messageKind:"command",isSystemGenerated:!0}),ie(),Xe(null)},onCancel:()=>Xe(null)})]}),b&&i.jsx(FF,{isOpen:b,onClose:()=>{k(!1),Fc(!0)},displayItems:P,onNavigate:it})]})}function HU(){var b;const[,e]=Zo("/p/:projectId/s/:sessionId/readonly"),t=e==null?void 0:e.sessionId,[n,r]=N.useState(null),[a,l]=N.useState([]),[u,c]=N.useState(0),[d,h]=N.useState(!0),[p,m]=N.useState(null),x=async()=>{if(t){h(!0),m(null);try{const k=await Ce(`/api/sessions/${t}?full=true`);if(!k.ok){m(`Failed to load session (${k.status})`),h(!1);return}const E=await k.json();r(E.session??null),l(E.messages??[]),c(E.hiddenCount??0)}catch(k){m(k instanceof Error?k.message:"Unknown error")}finally{h(!1)}}};N.useEffect(()=>{Vt.getState().getSettings([...ry])},[]),N.useEffect(()=>{x()},[t]);const{showThinking:y,showVerboseToolOutput:S,showStats:C,showAgentDefinitions:v,showWorkflowBars:w}=Pa(),_=N.useMemo(()=>VN(a),[a]);return d?i.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:i.jsx(Gi,{})}):p?i.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:i.jsxs("div",{className:"text-center space-y-4",children:[i.jsx("div",{className:"text-red-400 text-sm",children:p}),i.jsx("button",{onClick:x,className:"px-3 py-1.5 text-sm bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors",children:"Retry"})]})}):i.jsxs("div",{className:"h-screen print:h-auto flex flex-col bg-primary",children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-secondary shrink-0 print:hidden",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i.jsxs("h1",{className:"text-sm font-medium text-text-primary truncate",children:[((b=n==null?void 0:n.metadata)==null?void 0:b.title)??"Session"," — Read-only view"]}),i.jsxs("span",{className:"text-xs text-text-muted whitespace-nowrap",children:[a.length," messages",u>0?` (${u} older hidden)`:""]})]}),i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("button",{onClick:x,disabled:d,className:"px-3 py-1 text-xs bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors disabled:opacity-50",children:d?"Refreshing...":"Refresh"})})]}),i.jsxs(Ze,{className:"flex-1 print:overflow-visible",children:[i.jsx("div",{className:"pt-4",children:i.jsx(TN,{displayItems:_,showThinking:y,showVerboseToolOutput:S,showStats:C,showAgentDefinitions:v,showWorkflowBars:w})}),i.jsx("div",{className:"h-8"})]})]})}function wC({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[a,l]=N.useState(""),u=N.useRef(null);N.useEffect(()=>{e&&(l(""),setTimeout(()=>{var d;return(d=u.current)==null?void 0:d.focus()},100))},[e]);const c=d=>{d.preventDefault(),a.trim()&&n(a)};return i.jsx(Tt,{isOpen:e,onClose:r,title:t?"Invalid Password":"Password Required",size:"sm",children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsx("p",{className:"text-text-secondary text-sm",children:t?"The password you entered was incorrect. Please try again.":"This server requires a password to connect."}),i.jsx(zi,{ref:u,type:"password",value:a,onChange:d=>l(d.target.value),placeholder:"Enter password",autoFocus:!0}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(mt,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),i.jsx(mt,{type:"submit",disabled:!a.trim(),children:t?"Try Again":"Connect"})]})]})})}function FU({currentStep:e,totalSteps:t,labels:n,onStepClick:r}){return i.jsx("div",{className:"flex justify-center py-6",children:i.jsx("div",{className:"flex items-center",children:Array.from({length:t},(a,l)=>{const u=l+1,c=u<e,d=u===e;return i.jsxs("div",{className:"flex items-center",children:[i.jsx("button",{onClick:()=>r==null?void 0:r(u),className:`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors shrink-0 ${c?"bg-accent-primary text-text-primary hover:opacity-80":d?"bg-accent-primary text-text-primary":"bg-bg-tertiary text-text-muted"}`,children:c?"✓":u}),i.jsx("button",{onClick:()=>r==null?void 0:r(u),className:`ml-2 mr-4 text-sm whitespace-nowrap hidden sm:block ${d?"text-text-primary font-medium":"text-text-muted hover:text-text-secondary"}`,children:n[l]}),l<t-1&&i.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${c?"bg-accent-primary":"bg-border"}`})]},l)})})})}function UU({onNext:e}){const[t,n]=N.useState([]),[r,a]=N.useState([]),[l,u]=N.useState(!1),[c,d]=N.useState(null),[h,p]=N.useState(null),[m,x]=N.useState(null);N.useEffect(()=>{y()},[]);async function y(){try{const E=await Ce("/api/providers");if(E.ok){const D=(await E.json()).providers.map(L=>({id:L.id,name:L.name,url:L.url,backend:L.backend,model:null,apiKey:L.apiKey,isLocal:L.isLocal,thinkingField:L.thinkingField,sendReasoningInMessages:L.sendReasoningInMessages,models:L.models}));n(D),a(D)}}catch{}}async function S(E){const T=E.id.startsWith("temp-"),D=r.some(M=>M.id===E.id),L=r.length===0&&c===null,R=FN(E);try{let M;if(T){const z=await Ce("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});if(!z.ok)throw new Error("Failed to create provider");const H=await z.json();M={...E,id:H.provider.id,model:null}}else{if(!(await Ce(`/api/providers/${E.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)})).ok)throw new Error("Failed to update provider");M={...E,model:null}}const W=z=>z.some(H=>H.id===M.id)?z.map(H=>H.id===M.id?M:H):[...z,M];a(W),n(W),L&&!D&&e({providers:[M]})}catch{if(T){const M={...E,model:null};a(W=>[...W,M])}}}function C(){d(null),u(!0)}function v(E){d(E),u(!0)}function w(){u(!1),d(null)}function _(E){p(E),t.some(D=>D.id===E)?Ce(`/api/providers/${E}`,{method:"DELETE"}).then(()=>{a(r.filter(D=>D.id!==E)),n(t.filter(D=>D.id!==E)),p(null)}).catch(()=>p(null)):(a(r.filter(D=>D.id!==E)),p(null))}function b(){const E=r.filter(T=>!T.id.startsWith("temp-"));e({providers:E})}const k=r.length>0;return i.jsxs("div",{className:"max-w-xl mx-auto",children:[i.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),i.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),i.jsxs("div",{className:"space-y-4",children:[r.length>0?i.jsx("div",{className:"space-y-2",children:r.map(E=>i.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:jk(E.backend)}),i.jsx("span",{className:"text-text-primary font-medium",children:E.name}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${E.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:E.isLocal?"local":"api"})]}),i.jsx("p",{className:"text-text-muted text-sm mt-1 truncate",children:E.url}),E.model&&i.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",E.model]})]}),i.jsx("div",{className:"flex items-center gap-1",children:m===E.id?i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:()=>_(E.id),disabled:h===E.id,className:"px-2 py-1 text-xs text-red-500 hover:text-red-400 bg-red-500/10 rounded transition-colors disabled:opacity-50",children:h===E.id?"Deleting...":"Confirm"}),i.jsx("button",{onClick:()=>x(null),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>v(E),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary border border-border rounded transition-colors",children:"Edit"}),i.jsx("button",{onClick:()=>x(E.id),className:"p-2 text-text-muted hover:text-red-500 transition-colors",title:"Remove provider",children:i.jsx(Ba,{})})]})})]},E.id))}):i.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:i.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),i.jsxs("button",{onClick:C,"data-testid":"onboarding-add-provider-button",className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-bg-secondary border border-dashed border-border rounded-lg text-text-secondary hover:text-text-primary hover:border-text-muted transition-colors",children:[i.jsx(ws,{className:"w-4 h-4"}),"Add Provider"]}),i.jsx("button",{onClick:b,disabled:!k,"data-testid":"onboarding-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]}),i.jsx(UN,{isOpen:l,onClose:w,onSave:S,initialStep:1,editProvider:c??void 0})]})}function VU({onNext:e}){const[t,n]=N.useState(""),[r,a]=N.useState(!1);return N.useEffect(()=>{Ce("/api/config").then(l=>l.json()).then(l=>{l.workdir?n(l.workdir):fetch(ni("/api/directories?path=")+encodeURIComponent("/home")).then(u=>u.json()).then(u=>{u.current&&n(u.current)}).catch(()=>{})}).catch(()=>{fetch(ni("/api/directories?path=")+encodeURIComponent("/home")).then(l=>l.json()).then(l=>{l.current&&n(l.current)}).catch(()=>{})})},[]),i.jsxs("div",{className:"max-w-xl mx-auto",children:[i.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),i.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",value:t,onChange:l=>n(l.target.value),placeholder:"/home/user/projects","data-testid":"onboarding-workdir-input",className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),i.jsx("button",{onClick:()=>a(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),r&&i.jsx(Kh,{initialPath:t||void 0,onSelect:l=>{n(l),a(!1)},onClose:()=>a(!1)}),i.jsx("button",{onClick:()=>e({workdir:t}),disabled:!t,"data-testid":"onboarding-workdir-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function WU(e){var t;return((t=e.split("/").pop())==null?void 0:t.replace(/-/g," "))??e}function GU(e){return N.useMemo(()=>{const t=[];for(const n of e)for(const r of n.models)r.supportsVision&&t.push({providerId:n.id,providerName:n.name,modelId:r.id,modelName:r.name??WU(r.id)});return t},[e])}function qU({value:e,options:t,onChange:n,className:r}){return i.jsxs("select",{value:e,onChange:a=>n(a.target.value),className:r??"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[i.jsx("option",{value:"",children:"Manual configuration..."}),t.map(a=>i.jsxs("option",{value:`${a.providerId}/${a.modelId}`,children:[a.providerName," • ",a.modelName]},`${a.providerId}/${a.modelId}`))]})}function KU({backend:e,url:t,model:n,onBackendChange:r,onUrlChange:a,onModelChange:l}){return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Backend type"}),i.jsxs("select",{value:e,onChange:u=>r(u.target.value),className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[i.jsx("option",{value:"ollama",children:"Ollama"}),i.jsx("option",{value:"openai",children:"OpenAI-compatible (vLLM, sglang, llama.cpp)"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),i.jsx("input",{type:"text",value:t,onChange:u=>a(u.target.value),placeholder:e==="ollama"?"http://localhost:11434":"http://localhost:8000/v1",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),i.jsx("input",{type:"text",value:n,onChange:u=>l(u.target.value),placeholder:e==="ollama"?"qwen3.5:0.8b":"qwen3.5-27b",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]})}function YU(e,t,n,r){return a=>{e(a),t(""),a==="ollama"?(n("http://localhost:11434"),r("qwen3.5:0.8b")):(n("http://localhost:8000/v1"),r("qwen3.5-27b"))}}function XU(e,t,n){return r=>{e(r),r&&(t(""),n(""))}}function QU({enabled:e,hasOptions:t,selectedRef:n,visionModelOptions:r,onProviderModelSelect:a,backend:l,url:u,model:c,onBackendChange:d,onUrlChange:h,onModelChange:p,noOptionsMessage:m,children:x}){return e?i.jsxs("div",{className:"space-y-4 pl-8",children:[t?i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model from your providers"}),i.jsx(qU,{value:n,options:r,onChange:a})]}):i.jsx("p",{className:"text-sm text-text-muted italic",children:m}),i.jsx(KU,{backend:l,url:u,model:c,onBackendChange:d,onUrlChange:h,onModelChange:p}),x]}):null}function JU({onNext:e}){const[t,n]=N.useState(!1),[r,a]=N.useState("http://localhost:11434"),[l,u]=N.useState("qwen3.5:0.8b"),[c,d]=N.useState("ollama"),[h,p]=N.useState([]),[m,x]=N.useState(""),{copied:y,copy:S}=B2();N.useEffect(()=>{Ce("/api/config").then(E=>E.json()).then(E=>{E.visionFallback&&(n(E.visionFallback.enabled),E.visionFallback.providerModelRef?x(E.visionFallback.providerModelRef):(a(E.visionFallback.url??"http://localhost:11434"),u(E.visionFallback.model??"qwen3.5:0.8b"),E.visionFallback.backend&&d(E.visionFallback.backend))),E.providers&&p(E.providers)}).catch(()=>{})},[]);const C=GU(h),v=XU(x,a,u),w=YU(d,x,a,u);function _(E){if(E){e({});return}e(t&&m?{visionFallback:{enabled:t,providerModelRef:m,timeout:120}}:{visionFallback:{enabled:t,url:r,model:l,timeout:120,backend:c,providerModelRef:""}})}const b=C.length>0;return i.jsxs("div",{className:"max-w-xl mx-auto",children:[i.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),i.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[i.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"You need a server with a vision model. Choose your backend type below."}),i.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"For Ollama:"}),i.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),i.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[i.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3.5:0.8b"}),i.jsx("button",{onClick:()=>S("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:y?i.jsx(is,{className:"w-4 h-4 text-accent-primary"}):i.jsx(PR,{className:"w-4 h-4"})})]}),i.jsxs("p",{className:"text-text-secondary text-sm mt-3",children:["For OpenAI-compatible servers (vLLM, sglang, llama.cpp): use the ",i.jsx("strong",{children:"OpenAI"})," backend type."]})]}),i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t,onChange:E=>n(E.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),i.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),i.jsx(QU,{enabled:t,hasOptions:b,selectedRef:m,visionModelOptions:C,onProviderModelSelect:v,backend:c,url:r,model:l,onBackendChange:w,onUrlChange:a,onModelChange:u,noOptionsMessage:"No vision-capable models found in your providers. You can manually enter a model below."}),i.jsxs("div",{className:"flex items-center justify-between pt-4",children:[i.jsx("button",{onClick:()=>_(!0),"data-testid":"onboarding-skip-button",className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),i.jsx("button",{onClick:()=>_(!1),className:"px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Finish Setup"})]})]})]})}function ZU({onComplete:e}){const[t,n]=N.useState(1),[r,a]=N.useState(!1),[l,u]=N.useState({});async function c(m){u(x=>({...x,providers:m.providers})),n(2)}async function d(m){u(x=>({...x,...m})),n(3)}async function h(m){a(!0);try{if(!(await Ce("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:l.workdir,visionFallback:m.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(x){console.error("Failed to save onboarding data:",x),a(!1)}}const p=m=>{n(m)};return i.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[i.jsx(eu,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),i.jsx(FU,{currentStep:t,totalSteps:3,labels:["LLM Providers","Projects Folder","Vision"],onStepClick:p}),i.jsx("div",{className:"max-w-xl mx-auto",children:r?i.jsxs("div",{className:"text-center",children:[i.jsx(ws,{className:"w-6 h-6"}),i.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):i.jsxs(i.Fragment,{children:[t===1&&i.jsx(UU,{onNext:c}),t===2&&i.jsx(VU,{onNext:d}),t===3&&i.jsx(JU,{onNext:h})]})})]})}function eV({projectId:e}){var p;const[,t]=zn(),n=Re(m=>m.sessionsWithPendingConfirmations),r=Re(m=>{var x;return(x=m.currentSession)==null?void 0:x.id}),a=Re(m=>m.crossSessionConfirmations),l=Re(m=>m.sessions),u=n.find(m=>m!==r);if(!u)return null;const c=l.find(m=>m.id===u),d=(c==null?void 0:c.title)??u.slice(0,6),h=((p=a[u])==null?void 0:p.length)??0;return i.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 cursor-pointer hover:bg-amber-500/20 transition-colors",onClick:()=>t(e?`/p/${e}/s/${u}`:`/s/${u}`),role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&t(e?`/p/${e}/s/${u}`:`/s/${u}`)},children:[i.jsx(iy,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),i.jsxs("span",{className:"text-sm text-amber-300 flex-1 truncate",children:[h," confirmation",h>1?"s":"",' pending in session "',d,'"']}),i.jsx("span",{className:"text-xs text-amber-400 font-medium flex-shrink-0",children:"View session →"})]})}const Bg="openfox_updated_to",$g="update_pending";function tV(){const[e,t]=N.useState(!1),n=localStorage.getItem(Bg),r=localStorage.getItem($g);N.useEffect(()=>{if(!n||!r)return;const l=setTimeout(()=>{localStorage.removeItem(Bg),localStorage.removeItem($g),t(!0)},8e3);return()=>clearTimeout(l)},[n,r]);const a=()=>{localStorage.removeItem(Bg),localStorage.removeItem($g),t(!0)};return e||r!=="true"||!n?null:i.jsxs("div",{className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-[100] flex items-center gap-3 px-4 py-2.5 bg-bg-secondary border border-border rounded-lg shadow-xl animate-slide-down",role:"status","aria-live":"polite",children:[i.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:i.jsx(is,{className:"w-3 h-3 text-accent-primary"})}),i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),i.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),i.jsx("button",{onClick:a,className:"ml-2 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:i.jsx(oy,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Ut.getState().loadUserPresets(),Ut.getState().applySavedTheme());function ab(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function WN(){return i.jsx("div",{className:"flex-1 flex items-center justify-center",children:i.jsx(Gi,{})})}function nV({sidebarOpen:e,onSidebarToggle:t}){const[,n]=Zo("/p/:projectId"),r=n==null?void 0:n.projectId,a=Re(d=>d.connectionStatus),l=Jt(d=>d.currentProject),u=ab();return LR({canLoad:a==="connected"||u,projectId:r,currentProjectId:l==null?void 0:l.id}),!l||l.id!==r?i.jsx(WN,{}):i.jsxs(i.Fragment,{children:[i.jsx(J2,{projectId:r,isOpen:e,onClose:t}),i.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:i.jsx(l7,{})})]})}function rV({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,a]=Zo("/p/:projectId/s/:sessionId"),l=a==null?void 0:a.projectId,u=a==null?void 0:a.sessionId,[,c]=zn(),d=Re(C=>C.connectionStatus),h=Re(C=>C.currentSession),p=Re(C=>C.error),m=Re(C=>C.clearError),x=Jt(C=>C.currentProject),y=ab();return DR({canLoad:d==="connected"||y,projectId:l,sessionId:u,currentProjectId:x==null?void 0:x.id,currentSessionId:h==null?void 0:h.id}),N.useEffect(()=>{(p==null?void 0:p.code)==="NOT_FOUND"&&l&&(m(),c(`/p/${l}`))},[p,l,m,c]),!x||x.id!==l?i.jsx(WN,{}):i.jsxs(i.Fragment,{children:[i.jsx(J2,{projectId:l,isOpen:e,onClose:t}),i.jsxs("div",{className:"flex-1 min-w-0 bg-primary flex flex-col",children:[i.jsx(eV,{projectId:l}),i.jsx(zU,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})]})]})}function sV(){const e=nn(r=>r.fetchConfig),[,t]=zn();async function n(){await e(),t("/")}return i.jsx(Ze,{className:"flex-1",children:i.jsx(ZU,{onComplete:n})})}function iV(){const{connectionStatus:e}=kR(),t=nn(O=>O.fetchConfig),n=nn(O=>O.refreshProviderModels),r=nn(O=>O.providers),a=nn(O=>O.activeProviderId),[,l]=zn(),u=ab(),[c,d]=N.useState(!1);N.useEffect(()=>{(e==="connected"||u)&&t().then(()=>{d(!0),Vt.getState().getSettings([...ry,Ae.DISPLAY_THEME,Ae.DISPLAY_USER_PRESETS,Ae.DISPLAY_CUSTOM_CSS,Ae.KEYBINDINGS,Ae.FEATURES_PER_SESSION_MCP]),Ac.getState().fetchServers()})},[e,u,t]),N.useEffect(()=>{c&&a&&n(a).then(()=>{const O=nn.getState().defaultModelSelection;(O?O.split("/")[0]:null)!==a&&t()})},[c,a,n,t]);const h=Vt(O=>O.settings);N.useEffect(()=>{c&&r.length===0&&l("/onboarding")},[c,r.length]),N.useEffect(()=>{const{applyPreset:O,applyTokens:B,setFollowSystemTheme:q,initSystemThemeListener:$}=Ut.getState(),Y=h[Ae.DISPLAY_THEME],Q=h[Ae.DISPLAY_USER_PRESETS],X=h[Ae.DISPLAY_FOLLOW_SYSTEM_THEME];if(Q&&localStorage.setItem("openfox:userPresets",Q),Y){localStorage.setItem("openfox:theme",Y);try{const P=JSON.parse(Y);P.preset&&P.tokens?(O(P.preset),Ut.setState({basePreset:P.preset}),B(P.tokens)):P.preset?O(P.preset):P.tokens&&B(P.tokens)}catch{O("dark")}}else O("system");X!==void 0&&Ut.getState().followSystemTheme!==(X==="true")&&q(X==="true");const K=$();return()=>K()},[h[Ae.DISPLAY_THEME],h[Ae.DISPLAY_USER_PRESETS]]),N.useEffect(()=>{const O=h[Ae.DISPLAY_CUSTOM_CSS]??"";let B=document.getElementById("custom-css");B||(B=document.createElement("style"),B.id="custom-css",document.head.appendChild(B)),B.textContent=O},[h[Ae.DISPLAY_CUSTOM_CSS]]);const[p,m]=N.useState(!1);N.useEffect(()=>{const O=Vt.getState().settings[Ae.DISPLAY_SHOW_CHANGELOG_ON_UPDATE];if(O===void 0||O==="false")return;let B=!1;if(localStorage.getItem("update_pending")==="true"&&(B=!0,localStorage.removeItem("update_pending")),c){const $=nn.getState().version,Y=localStorage.getItem("openfox_last_version");$&&Y&&$!==Y&&(B=!0),localStorage.setItem("openfox_last_version",$??"")}B&&m(!0)},[h[Ae.DISPLAY_SHOW_CHANGELOG_ON_UPDATE],c]);const x=()=>{const O=localStorage.getItem("openfox:leftSidebar");return O!==null?O==="true":!0},y=()=>{const O=localStorage.getItem("openfox:rightSidebar");return O!==null?O==="true":!0},[S,C]=N.useState(x),[v,w]=N.useState(y),[_,b]=N.useState(!1),[k,E]=N.useState(!1),[T,D]=N.useState(!1),L=eR();N.useEffect(()=>{const O=()=>{D(window.innerWidth<768)};return O(),window.addEventListener("resize",O),()=>window.removeEventListener("resize",O)},[]);const[R]=zn(),M=/^\/p\/[^/]+$/.test(R),W=T?_:M?!0:S,z=T?k:v,H=()=>{T?b(!_):C(!S)},I=()=>{T?E(!k):w(!v)};N.useEffect(()=>{T||localStorage.setItem("openfox:leftSidebar",String(S))},[S,T]),N.useEffect(()=>{T||localStorage.setItem("openfox:rightSidebar",String(v))},[v,T]),N.useEffect(()=>{(e==="connected"||u)&&t()},[e,t,u]);const U=Re(O=>O.showPasswordModal),V=Re(O=>O.passwordModalRetry),Z=Re(O=>O.submitPassword),ee=Re(O=>O.cancelPassword),[F]=Zo("/p/:projectId/s/:sessionId/readonly");return!F&&e!=="connected"&&!U&&!u?i.jsxs(i.Fragment,{children:[i.jsx(wC,{isOpen:!0,isRetry:V,onSubmit:Z,onCancel:ee}),i.jsx("div",{className:"h-screen flex items-center justify-center",children:i.jsx(a3,{text:"Connecting to server..."})})]}):F?i.jsx(HU,{}):i.jsxs(i.Fragment,{children:[i.jsx(wC,{isOpen:U,isRetry:V,onSubmit:Z,onCancel:ee}),i.jsxs("div",{className:"flex flex-col",style:{height:T?`calc(${L.offsetTop}px + ${L.height}px)`:"100vh"},children:[i.jsx(s7,{}),i.jsx(XH,{onMenuClick:H,onCriteriaToggle:I}),i.jsx("div",{className:"flex-1 flex overflow-hidden",children:i.jsxs(BL,{children:[i.jsx(ec,{path:"/onboarding",children:i.jsx(sV,{})}),i.jsx(ec,{path:"/p/:projectId/s/:sessionId",children:i.jsx(rV,{sidebarOpen:W,onSidebarToggle:H,rightSidebarOpen:z,onRightSidebarToggle:I})}),i.jsx(ec,{path:"/p/:projectId/new",children:i.jsx(o7,{})}),i.jsx(ec,{path:"/p/:projectId",children:i.jsx(nV,{sidebarOpen:W,onSidebarToggle:H})}),i.jsx(ec,{path:"/",children:i.jsx(a7,{})})]})})]}),i.jsx(tV,{}),i.jsx($2,{isOpen:p,onClose:()=>m(!1)})]})}xL.createRoot(document.getElementById("root")).render(i.jsx(bs.StrictMode,{children:i.jsx(DC,{base:Ck,children:i.jsx(iV,{})})}));
|