openfox 2.0.115 → 2.0.117
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 +46 -0
- package/dist/CHANGELOG.md +46 -0
- package/dist/{ask-ZYPCJKZD.js → ask-UBIRH3SO.js} +2 -2
- package/dist/{auth-YY5PJYSC.js → auth-GTGIGX5X.js} +2 -2
- package/dist/{auto-config-T5GR2N6X.js → auto-config-AAUO4PKW.js} +2 -2
- package/dist/{backend-LVYHLGQJ.js → backend-67OLCS5O.js} +2 -2
- package/dist/{branch.api-XVTYACSH.js → branch.api-UMKSQMSA.js} +2 -2
- package/dist/changelog-FZUE6OSG.js +63 -0
- package/dist/{chat-handler-5SP265CR.js → chat-handler-URSNELCE.js} +17 -17
- package/dist/{chunk-JFK4GKQD.js → chunk-2PQA3DHY.js} +62 -91
- package/dist/{chunk-TFF5T3K3.js → chunk-3PEYTWCS.js} +3 -3
- package/dist/{chunk-I7FY2LTR.js → chunk-4GHLULHB.js} +18 -2
- package/dist/{chunk-TGLVWAFC.js → chunk-6XHDNSA3.js} +5 -5
- package/dist/{chunk-3QQAIUZI.js → chunk-7SDJXHJH.js} +175 -30
- package/dist/{chunk-4H427UBV.js → chunk-AGXJ5O63.js} +2 -2
- package/dist/{chunk-OCBBAEMT.js → chunk-ECCSVMRT.js} +179 -137
- package/dist/{chunk-OCSTEGK7.js → chunk-EQ5CGNOT.js} +2 -2
- package/dist/{chunk-YX3OQBNX.js → chunk-EQ7DK2TG.js} +9 -5
- package/dist/{chunk-OKVHMKE2.js → chunk-EZD7WFBZ.js} +33 -29
- package/dist/{chunk-BVVCRIVM.js → chunk-GZTMCTUS.js} +3 -3
- package/dist/{chunk-6RGACY4E.js → chunk-HZSKKJHQ.js} +4 -3
- package/dist/{chunk-3NPLERPQ.js → chunk-I6MY65LO.js} +9 -8
- package/dist/{chunk-VWEATA7R.js → chunk-KLQEL2DZ.js} +7 -1
- package/dist/{chunk-JGWHRYWG.js → chunk-MKWS7TQH.js} +2 -2
- package/dist/chunk-NPTI5RCQ.js +7 -0
- package/dist/{chunk-6KPJLELC.js → chunk-QQVPUZQB.js} +156 -20
- package/dist/{chunk-ERNWAKUB.js → chunk-TGVDUK4N.js} +2 -2
- package/dist/{chunk-V4IE7HJY.js → chunk-W7VIYHPQ.js} +2 -2
- package/dist/{chunk-BWVO5WFK.js → chunk-X3XKYGUN.js} +3 -3
- package/dist/{chunk-5WRI5ZAA.js → chunk-YLJ4XMA6.js} +6 -2
- package/dist/{chunk-X25Q6RAV.js → chunk-ZKLE2Q3I.js} +1 -1
- package/dist/{chunk-37QLXLML.js → chunk-ZS6MW2WM.js} +14 -14
- package/dist/cli/dev.js +3 -3
- package/dist/cli/index.js +3 -3
- package/dist/{client-KE7EDI2D.js → client-KCNTDTIR.js} +4 -4
- package/dist/{client-pure-66Z6FWS6.js → client-pure-B5DHEKQJ.js} +2 -2
- package/dist/command-defaults/mark-done.command.md +6 -6
- package/dist/{compactor-SKVC2VNL.js → compactor-LAXZLPPA.js} +7 -7
- package/dist/{config-EAB3V4QK.js → config-TUCHLIWD.js} +2 -2
- package/dist/{dynamic-context-QNB4ELLP.js → dynamic-context-NNBVVFBT.js} +3 -3
- package/dist/{events-5PLO4QJU.js → events-IVPAMMR5.js} +4 -4
- package/dist/{folding-CJWYFUKD.js → folding-RTGU63BW.js} +2 -2
- package/dist/{http-client-KLODRQC2.js → http-client-IPUW2MSW.js} +2 -2
- package/dist/{inspect-proxy-K6QKEYDT.js → inspect-proxy-WPEDMCG7.js} +2 -2
- package/dist/{install-CPOPMCSE.js → install-VA2F6X6Z.js} +2 -2
- package/dist/{launch-EOXVWLOP.js → launch-HSSFGQ5A.js} +17 -17
- package/dist/{manager-LZ3JQ443.js → manager-EMLSLMMT.js} +2 -2
- package/dist/{model-overrides-5UVW3KTE.js → model-overrides-7F2EOA4U.js} +2 -2
- package/dist/{oauth-provider-52YILVUJ.js → oauth-provider-DGBC2YM6.js} +2 -2
- package/dist/{oauth-store-XCFXV2VM.js → oauth-store-KECHUT54.js} +2 -2
- package/dist/{openFolder-HX7X356L.js → openFolder-XCMSU3OI.js} +2 -2
- package/dist/{orchestrator-ED3KFPXO.js → orchestrator-FVXUJW3K.js} +16 -16
- package/dist/package.json +5 -2
- package/dist/{path-security-B6EZC63L.js → path-security-JTCHWYG3.js} +7 -7
- package/dist/{paths-F27V3S4I.js → paths-BHR7CZ7I.js} +2 -2
- package/dist/{permissions-K6YEA2ZZ.js → permissions-UKR524ZB.js} +2 -2
- package/dist/{platform-6RPPBHKH.js → platform-ECDDYMAR.js} +2 -2
- package/dist/{processor-226ZOTRI.js → processor-JRVW5QBA.js} +16 -16
- package/dist/profiles-GYHXBWPV.js +10 -0
- package/dist/{project-creator-VBFE35NI.js → project-creator-PMQ65NKN.js} +2 -2
- package/dist/{projects-AXHZOBR2.js → projects-NDPNOV6D.js} +2 -2
- package/dist/{protocol-JdxRpPxM.d.ts → protocol-CfUkCYxF.d.ts} +11 -2
- package/dist/{protocol-RKSWKNXI.js → protocol-HYA5BYVN.js} +8 -4
- package/dist/{provider-DL4ZWQY7.js → provider-Q7J4UFTS.js} +7 -7
- package/dist/{provider-manager-6CLRMGDE.js → provider-manager-TMBO4DFG.js} +5 -5
- package/dist/{pwa-XPHP3PY2.js → pwa-2GRFSXD7.js} +3 -3
- package/dist/{registry-5XI5NDBF.js → registry-5QL3BOWN.js} +2 -2
- package/dist/{serve-DARV4NJG.js → serve-CW6PR3M2.js} +22 -22
- package/dist/server/index.d.ts +15 -2
- package/dist/server/index.js +21 -21
- package/dist/{server-LQJ7MBDS.js → server-V46SOIGP.js} +20 -20
- package/dist/{service-4JKTGPRG.js → service-M7XJHAK4.js} +6 -6
- package/dist/{service-CXWJQFOZ.js → service-WKABQHKL.js} +2 -2
- package/dist/{session-overrides-AZKV6BRD.js → session-overrides-CWBKPHMF.js} +4 -4
- package/dist/{sessions-752IZIIK.js → sessions-I7ELDIIP.js} +5 -3
- package/dist/{settings-2AHDKCD7.js → settings-FGXQHKUH.js} +2 -2
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.js +2 -2
- package/dist/{store-SARB6V2N.js → store-JYPZ2RXB.js} +2 -2
- package/dist/{tasks-XJXHU623.js → tasks-X5H5HM4J.js} +6 -6
- package/dist/{tool-adapter-FEAHWU5C.js → tool-adapter-FJAFLDZA.js} +2 -2
- package/dist/{tools-QYYNFMGU.js → tools-2Q3GRECI.js} +14 -14
- package/dist/{update-2REP2WB6.js → update-YP7IRT6M.js} +4 -4
- package/dist/{update-server-LOOXIXDW.js → update-server-SVPV6ZJZ.js} +2 -2
- package/dist/{url-utils-SAJP7AEX.js → url-utils-C5BM7NF7.js} +2 -2
- package/dist/web/assets/index-C58KXxRi.js +324 -0
- package/dist/web/assets/{index-BmILAZrT.css → index-DTiVSJJu.css} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/dist/workflow-defaults/default.workflow.json +2 -2
- package/dist/{workspace-RMZVTFJD.js → workspace-IQLLHMYR.js} +2 -2
- package/package.json +5 -2
- package/dist/chunk-5V3BF67X.js +0 -7
- package/dist/profiles-5J7F4BML.js +0 -10
- package/dist/web/assets/index-M7ToECa4.js +0 -324
|
@@ -0,0 +1,324 @@
|
|
|
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 sD=Object.defineProperty;var iD=Object.getPrototypeOf;var aD=Reflect.get;var Sw=e=>{throw TypeError(e)};var oD=(e,t,n)=>t in e?sD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Le=(e,t,n)=>oD(e,typeof t!="symbol"?t+"":t,n),Tg=(e,t,n)=>t.has(e)||Sw("Cannot "+n);var cr=(e,t,n)=>(Tg(e,t,"read from private field"),n?n.call(e):t.get(e)),Da=(e,t,n)=>t.has(e)?Sw("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),us=(e,t,n,r)=>(Tg(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Ag=(e,t,n)=>(Tg(e,t,"access private method"),n);var ww=(e,t,n)=>aD(iD(e),n,t);function lD(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 o=Object.getOwnPropertyDescriptor(r,a);o&&Object.defineProperty(e,a,o.get?o:{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 o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function Nf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Lg={exports:{}},Rc={};/**
|
|
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 Cw;function cD(){if(Cw)return Rc;Cw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,o){var c=null;if(o!==void 0&&(c=""+o),a.key!==void 0&&(c=""+a.key),"key"in a){o={};for(var u in a)u!=="key"&&(o[u]=a[u])}else o=a;return a=o.ref,{$$typeof:e,type:r,key:c,ref:a!==void 0?a:null,props:o}}return Rc.Fragment=t,Rc.jsx=n,Rc.jsxs=n,Rc}var kw;function uD(){return kw||(kw=1,Lg.exports=cD()),Lg.exports}var s=uD(),Rg={exports:{}},St={};/**
|
|
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 jw;function dD(){if(jw)return St;jw=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"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function x(D){return D===null||typeof D!="object"?null:(D=g&&D[g]||D["@@iterator"],typeof D=="function"?D:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,v={};function S(D,U,$){this.props=D,this.context=U,this.refs=v,this.updater=$||w}S.prototype.isReactComponent={},S.prototype.setState=function(D,U){if(typeof D!="object"&&typeof D!="function"&&D!=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,D,U,"setState")},S.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function _(){}_.prototype=S.prototype;function b(D,U,$){this.props=D,this.context=U,this.refs=v,this.updater=$||w}var k=b.prototype=new _;k.constructor=b,C(k,S.prototype),k.isPureReactComponent=!0;var E=Array.isArray;function T(){}var L={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function O(D,U,$){var te=$.ref;return{$$typeof:e,type:D,key:U,ref:te!==void 0?te:null,props:$}}function M(D,U){return O(D.type,U,D.props)}function H(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function B(D){var U={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function($){return U[$]})}var F=/\/+/g;function K(D,U){return typeof D=="object"&&D!==null&&D.key!=null?B(""+D.key):U.toString(36)}function G(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(T,T):(D.status="pending",D.then(function(U){D.status==="pending"&&(D.status="fulfilled",D.value=U)},function(U){D.status==="pending"&&(D.status="rejected",D.reason=U)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function V(D,U,$,te,q){var X=typeof D;(X==="undefined"||X==="boolean")&&(D=null);var Y=!1;if(D===null)Y=!0;else switch(X){case"bigint":case"string":case"number":Y=!0;break;case"object":switch(D.$$typeof){case e:case t:Y=!0;break;case m:return Y=D._init,V(Y(D._payload),U,$,te,q)}}if(Y)return q=q(D),Y=te===""?"."+K(D,0):te,E(q)?($="",Y!=null&&($=Y.replace(F,"$&/")+"/"),V(q,U,$,"",function(ne){return ne})):q!=null&&(H(q)&&(q=M(q,$+(q.key==null||D&&D.key===q.key?"":(""+q.key).replace(F,"$&/")+"/")+Y)),U.push(q)),1;Y=0;var I=te===""?".":te+":";if(E(D))for(var Q=0;Q<D.length;Q++)te=D[Q],X=I+K(te,Q),Y+=V(te,U,$,X,q);else if(Q=x(D),typeof Q=="function")for(D=Q.call(D),Q=0;!(te=D.next()).done;)te=te.value,X=I+K(te,Q++),Y+=V(te,U,$,X,q);else if(X==="object"){if(typeof D.then=="function")return V(G(D),U,$,te,q);throw U=String(D),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return Y}function Z(D,U,$){if(D==null)return D;var te=[],q=0;return V(D,te,"","",function(X){return U.call($,X,q++)}),te}function J(D){if(D._status===-1){var U=D._result;U=U(),U.then(function($){(D._status===0||D._status===-1)&&(D._status=1,D._result=$)},function($){(D._status===0||D._status===-1)&&(D._status=2,D._result=$)}),D._status===-1&&(D._status=0,D._result=U)}if(D._status===1)return D._result.default;throw D._result}var z=typeof reportError=="function"?reportError:function(D){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof D=="object"&&D!==null&&typeof D.message=="string"?String(D.message):String(D),error:D});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",D);return}console.error(D)},P={map:Z,forEach:function(D,U,$){Z(D,function(){U.apply(this,arguments)},$)},count:function(D){var U=0;return Z(D,function(){U++}),U},toArray:function(D){return Z(D,function(U){return U})||[]},only:function(D){if(!H(D))throw Error("React.Children.only expected to receive a single React element child.");return D}};return St.Activity=f,St.Children=P,St.Component=S,St.Fragment=n,St.Profiler=a,St.PureComponent=b,St.StrictMode=r,St.Suspense=d,St.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,St.__COMPILER_RUNTIME={__proto__:null,c:function(D){return L.H.useMemoCache(D)}},St.cache=function(D){return function(){return D.apply(null,arguments)}},St.cacheSignal=function(){return null},St.cloneElement=function(D,U,$){if(D==null)throw Error("The argument must be a React element, but you passed "+D+".");var te=C({},D.props),q=D.key;if(U!=null)for(X in U.key!==void 0&&(q=""+U.key),U)!A.call(U,X)||X==="key"||X==="__self"||X==="__source"||X==="ref"&&U.ref===void 0||(te[X]=U[X]);var X=arguments.length-2;if(X===1)te.children=$;else if(1<X){for(var Y=Array(X),I=0;I<X;I++)Y[I]=arguments[I+2];te.children=Y}return O(D.type,q,te)},St.createContext=function(D){return D={$$typeof:c,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null},D.Provider=D,D.Consumer={$$typeof:o,_context:D},D},St.createElement=function(D,U,$){var te,q={},X=null;if(U!=null)for(te in U.key!==void 0&&(X=""+U.key),U)A.call(U,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(q[te]=U[te]);var Y=arguments.length-2;if(Y===1)q.children=$;else if(1<Y){for(var I=Array(Y),Q=0;Q<Y;Q++)I[Q]=arguments[Q+2];q.children=I}if(D&&D.defaultProps)for(te in Y=D.defaultProps,Y)q[te]===void 0&&(q[te]=Y[te]);return O(D,X,q)},St.createRef=function(){return{current:null}},St.forwardRef=function(D){return{$$typeof:u,render:D}},St.isValidElement=H,St.lazy=function(D){return{$$typeof:m,_payload:{_status:-1,_result:D},_init:J}},St.memo=function(D,U){return{$$typeof:h,type:D,compare:U===void 0?null:U}},St.startTransition=function(D){var U=L.T,$={};L.T=$;try{var te=D(),q=L.S;q!==null&&q($,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(T,z)}catch(X){z(X)}finally{U!==null&&$.types!==null&&(U.types=$.types),L.T=U}},St.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},St.use=function(D){return L.H.use(D)},St.useActionState=function(D,U,$){return L.H.useActionState(D,U,$)},St.useCallback=function(D,U){return L.H.useCallback(D,U)},St.useContext=function(D){return L.H.useContext(D)},St.useDebugValue=function(){},St.useDeferredValue=function(D,U){return L.H.useDeferredValue(D,U)},St.useEffect=function(D,U){return L.H.useEffect(D,U)},St.useEffectEvent=function(D){return L.H.useEffectEvent(D)},St.useId=function(){return L.H.useId()},St.useImperativeHandle=function(D,U,$){return L.H.useImperativeHandle(D,U,$)},St.useInsertionEffect=function(D,U){return L.H.useInsertionEffect(D,U)},St.useLayoutEffect=function(D,U){return L.H.useLayoutEffect(D,U)},St.useMemo=function(D,U){return L.H.useMemo(D,U)},St.useOptimistic=function(D,U){return L.H.useOptimistic(D,U)},St.useReducer=function(D,U,$){return L.H.useReducer(D,U,$)},St.useRef=function(D){return L.H.useRef(D)},St.useState=function(D){return L.H.useState(D)},St.useSyncExternalStore=function(D,U,$){return L.H.useSyncExternalStore(D,U,$)},St.useTransition=function(){return L.H.useTransition()},St.version="19.2.8",St}var Ew;function Tf(){return Ew||(Ew=1,Rg.exports=dD()),Rg.exports}var j=Tf();const ps=Nf(j),hD=lD({__proto__:null,default:ps},[j]);var Dg={exports:{}},Dc={},Og={exports:{}},Ig={};/**
|
|
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 Nw;function fD(){return Nw||(Nw=1,(function(e){function t(V,Z){var J=V.length;V.push(Z);e:for(;0<J;){var z=J-1>>>1,P=V[z];if(0<a(P,Z))V[z]=Z,V[J]=P,J=z;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],J=V.pop();if(J!==Z){V[0]=J;e:for(var z=0,P=V.length,D=P>>>1;z<D;){var U=2*(z+1)-1,$=V[U],te=U+1,q=V[te];if(0>a($,J))te<P&&0>a(q,$)?(V[z]=q,V[te]=J,z=te):(V[z]=$,V[U]=J,z=U);else if(te<P&&0>a(q,J))V[z]=q,V[te]=J,z=te;else break e}}return Z}function a(V,Z){var J=V.sortIndex-Z.sortIndex;return J!==0?J:V.id-Z.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var d=[],h=[],m=1,f=null,g=3,x=!1,w=!1,C=!1,v=!1,S=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),!w)if(n(d)!==null)w=!0,T||(T=!0,B());else{var Z=n(h);Z!==null&&G(E,Z.startTime-V)}}var T=!1,L=-1,A=5,O=-1;function M(){return v?!0:!(e.unstable_now()-O<A)}function H(){if(v=!1,T){var V=e.unstable_now();O=V;var Z=!0;try{e:{w=!1,C&&(C=!1,_(L),L=-1),x=!0;var J=g;try{t:{for(k(V),f=n(d);f!==null&&!(f.expirationTime>V&&M());){var z=f.callback;if(typeof z=="function"){f.callback=null,g=f.priorityLevel;var P=z(f.expirationTime<=V);if(V=e.unstable_now(),typeof P=="function"){f.callback=P,k(V),Z=!0;break t}f===n(d)&&r(d),k(V)}else r(d);f=n(d)}if(f!==null)Z=!0;else{var D=n(h);D!==null&&G(E,D.startTime-V),Z=!1}}break e}finally{f=null,g=J,x=!1}Z=void 0}}finally{Z?B():T=!1}}}var B;if(typeof b=="function")B=function(){b(H)};else if(typeof MessageChannel<"u"){var F=new MessageChannel,K=F.port2;F.port1.onmessage=H,B=function(){K.postMessage(null)}}else B=function(){S(H,0)};function G(V,Z){L=S(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"):A=0<V?Math.floor(1e3/V):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_next=function(V){switch(g){case 1:case 2:case 3:var Z=3;break;default:Z=g}var J=g;g=Z;try{return V()}finally{g=J}},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 J=g;g=V;try{return Z()}finally{g=J}},e.unstable_scheduleCallback=function(V,Z,J){var z=e.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?z+J:z):J=z,V){case 1:var P=-1;break;case 2:P=250;break;case 5:P=1073741823;break;case 4:P=1e4;break;default:P=5e3}return P=J+P,V={id:m++,callback:Z,priorityLevel:V,startTime:J,expirationTime:P,sortIndex:-1},J>z?(V.sortIndex=J,t(h,V),n(d)===null&&V===n(h)&&(C?(_(L),L=-1):C=!0,G(E,J-z))):(V.sortIndex=P,t(d,V),w||x||(w=!0,T||(T=!0,B()))),V},e.unstable_shouldYield=M,e.unstable_wrapCallback=function(V){var Z=g;return function(){var J=g;g=Z;try{return V.apply(this,arguments)}finally{g=J}}}})(Ig)),Ig}var Tw;function mD(){return Tw||(Tw=1,Og.exports=fD()),Og.exports}var Mg={exports:{}},er={};/**
|
|
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 Aw;function pD(){if(Aw)return er;Aw=1;var e=Tf();function t(d){var h="https://react.dev/errors/"+d;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)h+="&args[]="+encodeURIComponent(arguments[m])}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 o(d,h,m){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:f==null?null:""+f,children:d,containerInfo:h,implementation:m}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(d,h){if(d==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return er.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,er.createPortal=function(d,h){var m=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 o(d,h,null,m)},er.flushSync=function(d){var h=c.T,m=r.p;try{if(c.T=null,r.p=2,d)return d()}finally{c.T=h,r.p=m,r.d.f()}},er.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))},er.prefetchDNS=function(d){typeof d=="string"&&r.d.D(d)},er.preinit=function(d,h){if(typeof d=="string"&&h&&typeof h.as=="string"){var m=h.as,f=u(m,h.crossOrigin),g=typeof h.integrity=="string"?h.integrity:void 0,x=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;m==="style"?r.d.S(d,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:x}):m==="script"&&r.d.X(d,{crossOrigin:f,integrity:g,fetchPriority:x,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},er.preinitModule=function(d,h){if(typeof d=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var m=u(h.as,h.crossOrigin);r.d.M(d,{crossOrigin:m,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)},er.preload=function(d,h){if(typeof d=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var m=h.as,f=u(m,h.crossOrigin);r.d.L(d,m,{crossOrigin:f,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})}},er.preloadModule=function(d,h){if(typeof d=="string")if(h){var m=u(h.as,h.crossOrigin);r.d.m(d,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(d)},er.requestFormReset=function(d){r.d.r(d)},er.unstable_batchedUpdates=function(d,h){return d(h)},er.useFormState=function(d,h,m){return c.H.useFormState(d,h,m)},er.useFormStatus=function(){return c.H.useHostTransitionStatus()},er.version="19.2.8",er}var Lw;function uj(){if(Lw)return Mg.exports;Lw=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(),Mg.exports=pD(),Mg.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 Rw;function gD(){if(Rw)return Dc;Rw=1;var e=mD(),t=Tf(),n=uj();function r(i){var l="https://react.dev/errors/"+i;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)l+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+i+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function o(i){var l=i,p=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,(l.flags&4098)!==0&&(p=l.return),i=l.return;while(i)}return l.tag===3?p:null}function c(i){if(i.tag===13){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function u(i){if(i.tag===31){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function d(i){if(o(i)!==i)throw Error(r(188))}function h(i){var l=i.alternate;if(!l){if(l=o(i),l===null)throw Error(r(188));return l!==i?null:i}for(var p=i,y=l;;){var N=p.return;if(N===null)break;var R=N.alternate;if(R===null){if(y=N.return,y!==null){p=y;continue}break}if(N.child===R.child){for(R=N.child;R;){if(R===p)return d(N),i;if(R===y)return d(N),l;R=R.sibling}throw Error(r(188))}if(p.return!==y.return)p=N,y=R;else{for(var W=!1,ee=N.child;ee;){if(ee===p){W=!0,p=N,y=R;break}if(ee===y){W=!0,y=N,p=R;break}ee=ee.sibling}if(!W){for(ee=R.child;ee;){if(ee===p){W=!0,p=R,y=N;break}if(ee===y){W=!0,y=R,p=N;break}ee=ee.sibling}if(!W)throw Error(r(189))}}if(p.alternate!==y)throw Error(r(190))}if(p.tag!==3)throw Error(r(188));return p.stateNode.current===p?i:l}function m(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(l=m(i),l!==null)return l;i=i.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),S=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"),L=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),H=Symbol.iterator;function B(i){return i===null||typeof i!="object"?null:(i=H&&i[H]||i["@@iterator"],typeof i=="function"?i:null)}var F=Symbol.for("react.client.reference");function K(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===F?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case C:return"Fragment";case S:return"Profiler";case v:return"StrictMode";case E:return"Suspense";case T:return"SuspenseList";case O:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case w:return"Portal";case b:return i.displayName||"Context";case _:return(i._context.displayName||"Context")+".Consumer";case k:var l=i.render;return i=i.displayName,i||(i=l.displayName||l.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case L:return l=i.displayName||null,l!==null?l:K(i.type)||"Memo";case A:l=i._payload,i=i._init;try{return K(i(l))}catch{}}return null}var G=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,J={pending:!1,data:null,method:null,action:null},z=[],P=-1;function D(i){return{current:i}}function U(i){0>P||(i.current=z[P],z[P]=null,P--)}function $(i,l){P++,z[P]=i.current,i.current=l}var te=D(null),q=D(null),X=D(null),Y=D(null);function I(i,l){switch($(X,l),$(q,i),$(te,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?WS(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=WS(l),i=GS(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}U(te),$(te,i)}function Q(){U(te),U(q),U(X)}function ne(i){i.memoizedState!==null&&$(Y,i);var l=te.current,p=GS(l,i.type);l!==p&&($(q,i),$(te,p))}function re(i){q.current===i&&(U(te),U(q)),Y.current===i&&(U(Y),Nc._currentValue=J)}var ie,pe;function ye(i){if(ie===void 0)try{throw Error()}catch(p){var l=p.stack.trim().match(/\n( *(at )?)/);ie=l&&l[1]||"",pe=-1<p.stack.indexOf(`
|
|
43
|
+
at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
+
`+ie+i+pe}var Ie=!1;function $e(i,l){if(!i||Ie)return"";Ie=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var y={DetermineComponentFrameRoot:function(){try{if(l){var ze=function(){throw Error()};if(Object.defineProperty(ze.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ze,[])}catch(je){var we=je}Reflect.construct(i,[],ze)}else{try{ze.call()}catch(je){we=je}i.call(ze.prototype)}}else{try{throw Error()}catch(je){we=je}(ze=i())&&typeof ze.catch=="function"&&ze.catch(function(){})}}catch(je){if(je&&we&&typeof je.stack=="string")return[je.stack,we.stack]}return[null,null]}};y.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var N=Object.getOwnPropertyDescriptor(y.DetermineComponentFrameRoot,"name");N&&N.configurable&&Object.defineProperty(y.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var R=y.DetermineComponentFrameRoot(),W=R[0],ee=R[1];if(W&&ee){var oe=W.split(`
|
|
45
|
+
`),be=ee.split(`
|
|
46
|
+
`);for(N=y=0;y<oe.length&&!oe[y].includes("DetermineComponentFrameRoot");)y++;for(;N<be.length&&!be[N].includes("DetermineComponentFrameRoot");)N++;if(y===oe.length||N===be.length)for(y=oe.length-1,N=be.length-1;1<=y&&0<=N&&oe[y]!==be[N];)N--;for(;1<=y&&0<=N;y--,N--)if(oe[y]!==be[N]){if(y!==1||N!==1)do if(y--,N--,0>N||oe[y]!==be[N]){var Me=`
|
|
47
|
+
`+oe[y].replace(" at new "," at ");return i.displayName&&Me.includes("<anonymous>")&&(Me=Me.replace("<anonymous>",i.displayName)),Me}while(1<=y&&0<=N);break}}}finally{Ie=!1,Error.prepareStackTrace=p}return(p=i?i.displayName||i.name:"")?ye(p):""}function Se(i,l){switch(i.tag){case 26:case 27:case 5:return ye(i.type);case 16:return ye("Lazy");case 13:return i.child!==l&&l!==null?ye("Suspense Fallback"):ye("Suspense");case 19:return ye("SuspenseList");case 0:case 15:return $e(i.type,!1);case 11:return $e(i.type.render,!1);case 1:return $e(i.type,!0);case 31:return ye("Activity");default:return""}}function Ge(i){try{var l="",p=null;do l+=Se(i,p),p=i,i=i.return;while(i);return l}catch(y){return`
|
|
48
|
+
Error generating stack: `+y.message+`
|
|
49
|
+
`+y.stack}}var Je=Object.prototype.hasOwnProperty,_e=e.unstable_scheduleCallback,ge=e.unstable_cancelCallback,he=e.unstable_shouldYield,ae=e.unstable_requestPaint,Pe=e.unstable_now,Ue=e.unstable_getCurrentPriorityLevel,de=e.unstable_ImmediatePriority,Ae=e.unstable_UserBlockingPriority,ue=e.unstable_NormalPriority,Fe=e.unstable_LowPriority,Xe=e.unstable_IdlePriority,it=e.log,Ze=e.unstable_setDisableYieldValue,lt=null,gt=null;function De(i){if(typeof it=="function"&&Ze(i),gt&&typeof gt.setStrictMode=="function")try{gt.setStrictMode(lt,i)}catch{}}var Re=Math.clz32?Math.clz32:Ce,ke=Math.log,We=Math.LN2;function Ce(i){return i>>>=0,i===0?32:31-(ke(i)/We|0)|0}var nt=256,tt=262144,ht=4194304;function Lt(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function qt(i,l,p){var y=i.pendingLanes;if(y===0)return 0;var N=0,R=i.suspendedLanes,W=i.pingedLanes;i=i.warmLanes;var ee=y&134217727;return ee!==0?(y=ee&~R,y!==0?N=Lt(y):(W&=ee,W!==0?N=Lt(W):p||(p=ee&~i,p!==0&&(N=Lt(p))))):(ee=y&~R,ee!==0?N=Lt(ee):W!==0?N=Lt(W):p||(p=y&~i,p!==0&&(N=Lt(p)))),N===0?0:l!==0&&l!==N&&(l&R)===0&&(R=N&-N,p=l&-l,R>=p||R===32&&(p&4194048)!==0)?l:N}function bn(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function vn(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 xn(){var i=ht;return ht<<=1,(ht&62914560)===0&&(ht=4194304),i}function hr(i){for(var l=[],p=0;31>p;p++)l.push(i);return l}function ve(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function rt(i,l,p,y,N,R){var W=i.pendingLanes;i.pendingLanes=p,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=p,i.entangledLanes&=p,i.errorRecoveryDisabledLanes&=p,i.shellSuspendCounter=0;var ee=i.entanglements,oe=i.expirationTimes,be=i.hiddenUpdates;for(p=W&~p;0<p;){var Me=31-Re(p),ze=1<<Me;ee[Me]=0,oe[Me]=-1;var we=be[Me];if(we!==null)for(be[Me]=null,Me=0;Me<we.length;Me++){var je=we[Me];je!==null&&(je.lane&=-536870913)}p&=~ze}y!==0&&Qe(i,y,0),R!==0&&N===0&&i.tag!==0&&(i.suspendedLanes|=R&~(W&~l))}function Qe(i,l,p){i.pendingLanes|=l,i.suspendedLanes&=~l;var y=31-Re(l);i.entangledLanes|=l,i.entanglements[y]=i.entanglements[y]|1073741824|p&261930}function Ve(i,l){var p=i.entangledLanes|=l;for(i=i.entanglements;p;){var y=31-Re(p),N=1<<y;N&l|i[y]&l&&(i[y]|=l),p&=~N}}function le(i,l){var p=l&-l;return p=(p&42)!==0?1:Ye(p),(p&(i.suspendedLanes|l))!==0?0:p}function Ye(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function xt(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function It(){var i=Z.p;return i!==0?i:(i=window.event,i===void 0?32:pw(i.type))}function Ee(i,l){var p=Z.p;try{return Z.p=i,l()}finally{Z.p=p}}var Te=Math.random().toString(36).slice(2),He="__reactFiber$"+Te,et="__reactProps$"+Te,st="__reactContainer$"+Te,bt="__reactEvents$"+Te,jt="__reactListeners$"+Te,Pn="__reactHandles$"+Te,Cn="__reactResources$"+Te,Tn="__reactMarker$"+Te;function fo(i){delete i[He],delete i[et],delete i[bt],delete i[jt],delete i[Pn]}function mo(i){var l=i[He];if(l)return l;for(var p=i.parentNode;p;){if(l=p[st]||p[He]){if(p=l.alternate,l.child!==null||p!==null&&p.child!==null)for(i=ZS(i);i!==null;){if(p=i[He])return p;i=ZS(i)}return l}i=p,p=i.parentNode}return null}function po(i){if(i=i[He]||i[st]){var l=i.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return i}return null}function Vl(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i.stateNode;throw Error(r(33))}function go(i){var l=i[Cn];return l||(l=i[Cn]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function zn(i){i[Tn]=!0}var Dv=new Set,Ov={};function ga(i,l){xo(i,l),xo(i+"Capture",l)}function xo(i,l){for(Ov[i]=l,i=0;i<l.length;i++)Dv.add(l[i])}var YA=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]*$"),Iv={},Mv={};function XA(i){return Je.call(Mv,i)?!0:Je.call(Iv,i)?!1:YA.test(i)?Mv[i]=!0:(Iv[i]=!0,!1)}function Fu(i,l,p){if(XA(l))if(p===null)i.removeAttribute(l);else{switch(typeof p){case"undefined":case"function":case"symbol":i.removeAttribute(l);return;case"boolean":var y=l.toLowerCase().slice(0,5);if(y!=="data-"&&y!=="aria-"){i.removeAttribute(l);return}}i.setAttribute(l,""+p)}}function Hu(i,l,p){if(p===null)i.removeAttribute(l);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(l);return}i.setAttribute(l,""+p)}}function Us(i,l,p,y){if(y===null)i.removeAttribute(p);else{switch(typeof y){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(p);return}i.setAttributeNS(l,p,""+y)}}function Ur(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Pv(i){var l=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function QA(i,l,p){var y=Object.getOwnPropertyDescriptor(i.constructor.prototype,l);if(!i.hasOwnProperty(l)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var N=y.get,R=y.set;return Object.defineProperty(i,l,{configurable:!0,get:function(){return N.call(this)},set:function(W){p=""+W,R.call(this,W)}}),Object.defineProperty(i,l,{enumerable:y.enumerable}),{getValue:function(){return p},setValue:function(W){p=""+W},stopTracking:function(){i._valueTracker=null,delete i[l]}}}}function Sm(i){if(!i._valueTracker){var l=Pv(i)?"checked":"value";i._valueTracker=QA(i,l,""+i[l])}}function Bv(i){if(!i)return!1;var l=i._valueTracker;if(!l)return!0;var p=l.getValue(),y="";return i&&(y=Pv(i)?i.checked?"true":"false":i.value),i=y,i!==p?(l.setValue(i),!0):!1}function zu(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var JA=/[\n"\\]/g;function Vr(i){return i.replace(JA,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function wm(i,l,p,y,N,R,W,ee){i.name="",W!=null&&typeof W!="function"&&typeof W!="symbol"&&typeof W!="boolean"?i.type=W:i.removeAttribute("type"),l!=null?W==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+Ur(l)):i.value!==""+Ur(l)&&(i.value=""+Ur(l)):W!=="submit"&&W!=="reset"||i.removeAttribute("value"),l!=null?Cm(i,W,Ur(l)):p!=null?Cm(i,W,Ur(p)):y!=null&&i.removeAttribute("value"),N==null&&R!=null&&(i.defaultChecked=!!R),N!=null&&(i.checked=N&&typeof N!="function"&&typeof N!="symbol"),ee!=null&&typeof ee!="function"&&typeof ee!="symbol"&&typeof ee!="boolean"?i.name=""+Ur(ee):i.removeAttribute("name")}function $v(i,l,p,y,N,R,W,ee){if(R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"&&(i.type=R),l!=null||p!=null){if(!(R!=="submit"&&R!=="reset"||l!=null)){Sm(i);return}p=p!=null?""+Ur(p):"",l=l!=null?""+Ur(l):p,ee||l===i.value||(i.value=l),i.defaultValue=l}y=y??N,y=typeof y!="function"&&typeof y!="symbol"&&!!y,i.checked=ee?i.checked:!!y,i.defaultChecked=!!y,W!=null&&typeof W!="function"&&typeof W!="symbol"&&typeof W!="boolean"&&(i.name=W),Sm(i)}function Cm(i,l,p){l==="number"&&zu(i.ownerDocument)===i||i.defaultValue===""+p||(i.defaultValue=""+p)}function yo(i,l,p,y){if(i=i.options,l){l={};for(var N=0;N<p.length;N++)l["$"+p[N]]=!0;for(p=0;p<i.length;p++)N=l.hasOwnProperty("$"+i[p].value),i[p].selected!==N&&(i[p].selected=N),N&&y&&(i[p].defaultSelected=!0)}else{for(p=""+Ur(p),l=null,N=0;N<i.length;N++){if(i[N].value===p){i[N].selected=!0,y&&(i[N].defaultSelected=!0);return}l!==null||i[N].disabled||(l=i[N])}l!==null&&(l.selected=!0)}}function Fv(i,l,p){if(l!=null&&(l=""+Ur(l),l!==i.value&&(i.value=l),p==null)){i.defaultValue!==l&&(i.defaultValue=l);return}i.defaultValue=p!=null?""+Ur(p):""}function Hv(i,l,p,y){if(l==null){if(y!=null){if(p!=null)throw Error(r(92));if(G(y)){if(1<y.length)throw Error(r(93));y=y[0]}p=y}p==null&&(p=""),l=p}p=Ur(l),i.defaultValue=p,y=i.textContent,y===p&&y!==""&&y!==null&&(i.value=y),Sm(i)}function bo(i,l){if(l){var p=i.firstChild;if(p&&p===i.lastChild&&p.nodeType===3){p.nodeValue=l;return}}i.textContent=l}var ZA=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 zv(i,l,p){var y=l.indexOf("--")===0;p==null||typeof p=="boolean"||p===""?y?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="":y?i.setProperty(l,p):typeof p!="number"||p===0||ZA.has(l)?l==="float"?i.cssFloat=p:i[l]=(""+p).trim():i[l]=p+"px"}function Uv(i,l,p){if(l!=null&&typeof l!="object")throw Error(r(62));if(i=i.style,p!=null){for(var y in p)!p.hasOwnProperty(y)||l!=null&&l.hasOwnProperty(y)||(y.indexOf("--")===0?i.setProperty(y,""):y==="float"?i.cssFloat="":i[y]="");for(var N in l)y=l[N],l.hasOwnProperty(N)&&p[N]!==y&&zv(i,N,y)}else for(var R in l)l.hasOwnProperty(R)&&zv(i,R,l[R])}function km(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var eL=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"]]),tL=/^[\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 Uu(i){return tL.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Vs(){}var jm=null;function Em(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var vo=null,_o=null;function Vv(i){var l=po(i);if(l&&(i=l.stateNode)){var p=i[et]||null;e:switch(i=l.stateNode,l.type){case"input":if(wm(i,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name),l=p.name,p.type==="radio"&&l!=null){for(p=i;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll('input[name="'+Vr(""+l)+'"][type="radio"]'),l=0;l<p.length;l++){var y=p[l];if(y!==i&&y.form===i.form){var N=y[et]||null;if(!N)throw Error(r(90));wm(y,N.value,N.defaultValue,N.defaultValue,N.checked,N.defaultChecked,N.type,N.name)}}for(l=0;l<p.length;l++)y=p[l],y.form===i.form&&Bv(y)}break e;case"textarea":Fv(i,p.value,p.defaultValue);break e;case"select":l=p.value,l!=null&&yo(i,!!p.multiple,l,!1)}}}var Nm=!1;function Wv(i,l,p){if(Nm)return i(l,p);Nm=!0;try{var y=i(l);return y}finally{if(Nm=!1,(vo!==null||_o!==null)&&(Ad(),vo&&(l=vo,i=_o,_o=vo=null,Vv(l),i)))for(l=0;l<i.length;l++)Vv(i[l])}}function Wl(i,l){var p=i.stateNode;if(p===null)return null;var y=p[et]||null;if(y===null)return null;p=y[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(y=!y.disabled)||(i=i.type,y=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!y;break e;default:i=!1}if(i)return null;if(p&&typeof p!="function")throw Error(r(231,l,typeof p));return p}var Ws=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Tm=!1;if(Ws)try{var Gl={};Object.defineProperty(Gl,"passive",{get:function(){Tm=!0}}),window.addEventListener("test",Gl,Gl),window.removeEventListener("test",Gl,Gl)}catch{Tm=!1}var ki=null,Am=null,Vu=null;function Gv(){if(Vu)return Vu;var i,l=Am,p=l.length,y,N="value"in ki?ki.value:ki.textContent,R=N.length;for(i=0;i<p&&l[i]===N[i];i++);var W=p-i;for(y=1;y<=W&&l[p-y]===N[R-y];y++);return Vu=N.slice(i,1<y?1-y:void 0)}function Wu(i){var l=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&l===13&&(i=13)):i=l,i===10&&(i=13),32<=i||i===13?i:0}function Gu(){return!0}function qv(){return!1}function fr(i){function l(p,y,N,R,W){this._reactName=p,this._targetInst=N,this.type=y,this.nativeEvent=R,this.target=W,this.currentTarget=null;for(var ee in i)i.hasOwnProperty(ee)&&(p=i[ee],this[ee]=p?p(R):R[ee]);return this.isDefaultPrevented=(R.defaultPrevented!=null?R.defaultPrevented:R.returnValue===!1)?Gu:qv,this.isPropagationStopped=qv,this}return f(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=Gu)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Gu)},persist:function(){},isPersistent:Gu}),l}var xa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qu=fr(xa),ql=f({},xa,{view:0,detail:0}),nL=fr(ql),Lm,Rm,Kl,Ku=f({},ql,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Om,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==Kl&&(Kl&&i.type==="mousemove"?(Lm=i.screenX-Kl.screenX,Rm=i.screenY-Kl.screenY):Rm=Lm=0,Kl=i),Lm)},movementY:function(i){return"movementY"in i?i.movementY:Rm}}),Kv=fr(Ku),rL=f({},Ku,{dataTransfer:0}),sL=fr(rL),iL=f({},ql,{relatedTarget:0}),Dm=fr(iL),aL=f({},xa,{animationName:0,elapsedTime:0,pseudoElement:0}),oL=fr(aL),lL=f({},xa,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),cL=fr(lL),uL=f({},xa,{data:0}),Yv=fr(uL),dL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hL={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"},fL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mL(i){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(i):(i=fL[i])?!!l[i]:!1}function Om(){return mL}var pL=f({},ql,{key:function(i){if(i.key){var l=dL[i.key]||i.key;if(l!=="Unidentified")return l}return i.type==="keypress"?(i=Wu(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?hL[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Om,charCode:function(i){return i.type==="keypress"?Wu(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Wu(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),gL=fr(pL),xL=f({},Ku,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Xv=fr(xL),yL=f({},ql,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Om}),bL=fr(yL),vL=f({},xa,{propertyName:0,elapsedTime:0,pseudoElement:0}),_L=fr(vL),SL=f({},Ku,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),wL=fr(SL),CL=f({},xa,{newState:0,oldState:0}),kL=fr(CL),jL=[9,13,27,32],Im=Ws&&"CompositionEvent"in window,Yl=null;Ws&&"documentMode"in document&&(Yl=document.documentMode);var EL=Ws&&"TextEvent"in window&&!Yl,Qv=Ws&&(!Im||Yl&&8<Yl&&11>=Yl),Jv=" ",Zv=!1;function e_(i,l){switch(i){case"keyup":return jL.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function t_(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var So=!1;function NL(i,l){switch(i){case"compositionend":return t_(l);case"keypress":return l.which!==32?null:(Zv=!0,Jv);case"textInput":return i=l.data,i===Jv&&Zv?null:i;default:return null}}function TL(i,l){if(So)return i==="compositionend"||!Im&&e_(i,l)?(i=Gv(),Vu=Am=ki=null,So=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return Qv&&l.locale!=="ko"?null:l.data;default:return null}}var AL={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 n_(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l==="input"?!!AL[i.type]:l==="textarea"}function r_(i,l,p,y){vo?_o?_o.push(y):_o=[y]:vo=y,l=Pd(l,"onChange"),0<l.length&&(p=new qu("onChange","change",null,p,y),i.push({event:p,listeners:l}))}var Xl=null,Ql=null;function LL(i){$S(i,0)}function Yu(i){var l=Vl(i);if(Bv(l))return i}function s_(i,l){if(i==="change")return l}var i_=!1;if(Ws){var Mm;if(Ws){var Pm="oninput"in document;if(!Pm){var a_=document.createElement("div");a_.setAttribute("oninput","return;"),Pm=typeof a_.oninput=="function"}Mm=Pm}else Mm=!1;i_=Mm&&(!document.documentMode||9<document.documentMode)}function o_(){Xl&&(Xl.detachEvent("onpropertychange",l_),Ql=Xl=null)}function l_(i){if(i.propertyName==="value"&&Yu(Ql)){var l=[];r_(l,Ql,i,Em(i)),Wv(LL,l)}}function RL(i,l,p){i==="focusin"?(o_(),Xl=l,Ql=p,Xl.attachEvent("onpropertychange",l_)):i==="focusout"&&o_()}function DL(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Yu(Ql)}function OL(i,l){if(i==="click")return Yu(l)}function IL(i,l){if(i==="input"||i==="change")return Yu(l)}function ML(i,l){return i===l&&(i!==0||1/i===1/l)||i!==i&&l!==l}var Nr=typeof Object.is=="function"?Object.is:ML;function Jl(i,l){if(Nr(i,l))return!0;if(typeof i!="object"||i===null||typeof l!="object"||l===null)return!1;var p=Object.keys(i),y=Object.keys(l);if(p.length!==y.length)return!1;for(y=0;y<p.length;y++){var N=p[y];if(!Je.call(l,N)||!Nr(i[N],l[N]))return!1}return!0}function c_(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function u_(i,l){var p=c_(i);i=0;for(var y;p;){if(p.nodeType===3){if(y=i+p.textContent.length,i<=l&&y>=l)return{node:p,offset:l-i};i=y}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=c_(p)}}function d_(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?d_(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function h_(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=zu(i.document);l instanceof i.HTMLIFrameElement;){try{var p=typeof l.contentWindow.location.href=="string"}catch{p=!1}if(p)i=l.contentWindow;else break;l=zu(i.document)}return l}function Bm(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var PL=Ws&&"documentMode"in document&&11>=document.documentMode,wo=null,$m=null,Zl=null,Fm=!1;function f_(i,l,p){var y=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Fm||wo==null||wo!==zu(y)||(y=wo,"selectionStart"in y&&Bm(y)?y={start:y.selectionStart,end:y.selectionEnd}:(y=(y.ownerDocument&&y.ownerDocument.defaultView||window).getSelection(),y={anchorNode:y.anchorNode,anchorOffset:y.anchorOffset,focusNode:y.focusNode,focusOffset:y.focusOffset}),Zl&&Jl(Zl,y)||(Zl=y,y=Pd($m,"onSelect"),0<y.length&&(l=new qu("onSelect","select",null,l,p),i.push({event:l,listeners:y}),l.target=wo)))}function ya(i,l){var p={};return p[i.toLowerCase()]=l.toLowerCase(),p["Webkit"+i]="webkit"+l,p["Moz"+i]="moz"+l,p}var Co={animationend:ya("Animation","AnimationEnd"),animationiteration:ya("Animation","AnimationIteration"),animationstart:ya("Animation","AnimationStart"),transitionrun:ya("Transition","TransitionRun"),transitionstart:ya("Transition","TransitionStart"),transitioncancel:ya("Transition","TransitionCancel"),transitionend:ya("Transition","TransitionEnd")},Hm={},m_={};Ws&&(m_=document.createElement("div").style,"AnimationEvent"in window||(delete Co.animationend.animation,delete Co.animationiteration.animation,delete Co.animationstart.animation),"TransitionEvent"in window||delete Co.transitionend.transition);function ba(i){if(Hm[i])return Hm[i];if(!Co[i])return i;var l=Co[i],p;for(p in l)if(l.hasOwnProperty(p)&&p in m_)return Hm[i]=l[p];return i}var p_=ba("animationend"),g_=ba("animationiteration"),x_=ba("animationstart"),BL=ba("transitionrun"),$L=ba("transitionstart"),FL=ba("transitioncancel"),y_=ba("transitionend"),b_=new Map,zm="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(" ");zm.push("scrollEnd");function os(i,l){b_.set(i,l),ga(l,[i])}var Xu=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Wr=[],ko=0,Um=0;function Qu(){for(var i=ko,l=Um=ko=0;l<i;){var p=Wr[l];Wr[l++]=null;var y=Wr[l];Wr[l++]=null;var N=Wr[l];Wr[l++]=null;var R=Wr[l];if(Wr[l++]=null,y!==null&&N!==null){var W=y.pending;W===null?N.next=N:(N.next=W.next,W.next=N),y.pending=N}R!==0&&v_(p,N,R)}}function Ju(i,l,p,y){Wr[ko++]=i,Wr[ko++]=l,Wr[ko++]=p,Wr[ko++]=y,Um|=y,i.lanes|=y,i=i.alternate,i!==null&&(i.lanes|=y)}function Vm(i,l,p,y){return Ju(i,l,p,y),Zu(i)}function va(i,l){return Ju(i,null,null,l),Zu(i)}function v_(i,l,p){i.lanes|=p;var y=i.alternate;y!==null&&(y.lanes|=p);for(var N=!1,R=i.return;R!==null;)R.childLanes|=p,y=R.alternate,y!==null&&(y.childLanes|=p),R.tag===22&&(i=R.stateNode,i===null||i._visibility&1||(N=!0)),i=R,R=R.return;return i.tag===3?(R=i.stateNode,N&&l!==null&&(N=31-Re(p),i=R.hiddenUpdates,y=i[N],y===null?i[N]=[l]:y.push(l),l.lane=p|536870912),R):null}function Zu(i){if(50<_c)throw _c=0,Zp=null,Error(r(185));for(var l=i.return;l!==null;)i=l,l=i.return;return i.tag===3?i.stateNode:null}var jo={};function HL(i,l,p,y){this.tag=i,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Tr(i,l,p,y){return new HL(i,l,p,y)}function Wm(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Gs(i,l){var p=i.alternate;return p===null?(p=Tr(i.tag,l,i.key,i.mode),p.elementType=i.elementType,p.type=i.type,p.stateNode=i.stateNode,p.alternate=i,i.alternate=p):(p.pendingProps=l,p.type=i.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=i.flags&65011712,p.childLanes=i.childLanes,p.lanes=i.lanes,p.child=i.child,p.memoizedProps=i.memoizedProps,p.memoizedState=i.memoizedState,p.updateQueue=i.updateQueue,l=i.dependencies,p.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},p.sibling=i.sibling,p.index=i.index,p.ref=i.ref,p.refCleanup=i.refCleanup,p}function __(i,l){i.flags&=65011714;var p=i.alternate;return p===null?(i.childLanes=0,i.lanes=l,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=p.childLanes,i.lanes=p.lanes,i.child=p.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=p.memoizedProps,i.memoizedState=p.memoizedState,i.updateQueue=p.updateQueue,i.type=p.type,l=p.dependencies,i.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),i}function ed(i,l,p,y,N,R){var W=0;if(y=i,typeof i=="function")Wm(i)&&(W=1);else if(typeof i=="string")W=GR(i,p,te.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case O:return i=Tr(31,p,l,N),i.elementType=O,i.lanes=R,i;case C:return _a(p.children,N,R,l);case v:W=8,N|=24;break;case S:return i=Tr(12,p,l,N|2),i.elementType=S,i.lanes=R,i;case E:return i=Tr(13,p,l,N),i.elementType=E,i.lanes=R,i;case T:return i=Tr(19,p,l,N),i.elementType=T,i.lanes=R,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case b:W=10;break e;case _:W=9;break e;case k:W=11;break e;case L:W=14;break e;case A:W=16,y=null;break e}W=29,p=Error(r(130,i===null?"null":typeof i,"")),y=null}return l=Tr(W,p,l,N),l.elementType=i,l.type=y,l.lanes=R,l}function _a(i,l,p,y){return i=Tr(7,i,y,l),i.lanes=p,i}function Gm(i,l,p){return i=Tr(6,i,null,l),i.lanes=p,i}function S_(i){var l=Tr(18,null,null,0);return l.stateNode=i,l}function qm(i,l,p){return l=Tr(4,i.children!==null?i.children:[],i.key,l),l.lanes=p,l.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},l}var w_=new WeakMap;function Gr(i,l){if(typeof i=="object"&&i!==null){var p=w_.get(i);return p!==void 0?p:(l={value:i,source:l,stack:Ge(l)},w_.set(i,l),l)}return{value:i,source:l,stack:Ge(l)}}var Eo=[],No=0,td=null,ec=0,qr=[],Kr=0,ji=null,ws=1,Cs="";function qs(i,l){Eo[No++]=ec,Eo[No++]=td,td=i,ec=l}function C_(i,l,p){qr[Kr++]=ws,qr[Kr++]=Cs,qr[Kr++]=ji,ji=i;var y=ws;i=Cs;var N=32-Re(y)-1;y&=~(1<<N),p+=1;var R=32-Re(l)+N;if(30<R){var W=N-N%5;R=(y&(1<<W)-1).toString(32),y>>=W,N-=W,ws=1<<32-Re(l)+N|p<<N|y,Cs=R+i}else ws=1<<R|p<<N|y,Cs=i}function Km(i){i.return!==null&&(qs(i,1),C_(i,1,0))}function Ym(i){for(;i===td;)td=Eo[--No],Eo[No]=null,ec=Eo[--No],Eo[No]=null;for(;i===ji;)ji=qr[--Kr],qr[Kr]=null,Cs=qr[--Kr],qr[Kr]=null,ws=qr[--Kr],qr[Kr]=null}function k_(i,l){qr[Kr++]=ws,qr[Kr++]=Cs,qr[Kr++]=ji,ws=l.id,Cs=l.overflow,ji=i}var Kn=null,un=null,Ot=!1,Ei=null,Yr=!1,Xm=Error(r(519));function Ni(i){var l=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw tc(Gr(l,i)),Xm}function j_(i){var l=i.stateNode,p=i.type,y=i.memoizedProps;switch(l[He]=i,l[et]=y,p){case"dialog":Tt("cancel",l),Tt("close",l);break;case"iframe":case"object":case"embed":Tt("load",l);break;case"video":case"audio":for(p=0;p<wc.length;p++)Tt(wc[p],l);break;case"source":Tt("error",l);break;case"img":case"image":case"link":Tt("error",l),Tt("load",l);break;case"details":Tt("toggle",l);break;case"input":Tt("invalid",l),$v(l,y.value,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name,!0);break;case"select":Tt("invalid",l);break;case"textarea":Tt("invalid",l),Hv(l,y.value,y.defaultValue,y.children)}p=y.children,typeof p!="string"&&typeof p!="number"&&typeof p!="bigint"||l.textContent===""+p||y.suppressHydrationWarning===!0||US(l.textContent,p)?(y.popover!=null&&(Tt("beforetoggle",l),Tt("toggle",l)),y.onScroll!=null&&Tt("scroll",l),y.onScrollEnd!=null&&Tt("scrollend",l),y.onClick!=null&&(l.onclick=Vs),l=!0):l=!1,l||Ni(i,!0)}function E_(i){for(Kn=i.return;Kn;)switch(Kn.tag){case 5:case 31:case 13:Yr=!1;return;case 27:case 3:Yr=!0;return;default:Kn=Kn.return}}function To(i){if(i!==Kn)return!1;if(!Ot)return E_(i),Ot=!0,!1;var l=i.tag,p;if((p=l!==3&&l!==27)&&((p=l===5)&&(p=i.type,p=!(p!=="form"&&p!=="button")||mg(i.type,i.memoizedProps)),p=!p),p&&un&&Ni(i),E_(i),l===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));un=JS(i)}else if(l===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));un=JS(i)}else l===27?(l=un,zi(i.type)?(i=bg,bg=null,un=i):un=l):un=Kn?Qr(i.stateNode.nextSibling):null;return!0}function Sa(){un=Kn=null,Ot=!1}function Qm(){var i=Ei;return i!==null&&(xr===null?xr=i:xr.push.apply(xr,i),Ei=null),i}function tc(i){Ei===null?Ei=[i]:Ei.push(i)}var Jm=D(null),wa=null,Ks=null;function Ti(i,l,p){$(Jm,l._currentValue),l._currentValue=p}function Ys(i){i._currentValue=Jm.current,U(Jm)}function Zm(i,l,p){for(;i!==null;){var y=i.alternate;if((i.childLanes&l)!==l?(i.childLanes|=l,y!==null&&(y.childLanes|=l)):y!==null&&(y.childLanes&l)!==l&&(y.childLanes|=l),i===p)break;i=i.return}}function ep(i,l,p,y){var N=i.child;for(N!==null&&(N.return=i);N!==null;){var R=N.dependencies;if(R!==null){var W=N.child;R=R.firstContext;e:for(;R!==null;){var ee=R;R=N;for(var oe=0;oe<l.length;oe++)if(ee.context===l[oe]){R.lanes|=p,ee=R.alternate,ee!==null&&(ee.lanes|=p),Zm(R.return,p,i),y||(W=null);break e}R=ee.next}}else if(N.tag===18){if(W=N.return,W===null)throw Error(r(341));W.lanes|=p,R=W.alternate,R!==null&&(R.lanes|=p),Zm(W,p,i),W=null}else W=N.child;if(W!==null)W.return=N;else for(W=N;W!==null;){if(W===i){W=null;break}if(N=W.sibling,N!==null){N.return=W.return,W=N;break}W=W.return}N=W}}function Ao(i,l,p,y){i=null;for(var N=l,R=!1;N!==null;){if(!R){if((N.flags&524288)!==0)R=!0;else if((N.flags&262144)!==0)break}if(N.tag===10){var W=N.alternate;if(W===null)throw Error(r(387));if(W=W.memoizedProps,W!==null){var ee=N.type;Nr(N.pendingProps.value,W.value)||(i!==null?i.push(ee):i=[ee])}}else if(N===Y.current){if(W=N.alternate,W===null)throw Error(r(387));W.memoizedState.memoizedState!==N.memoizedState.memoizedState&&(i!==null?i.push(Nc):i=[Nc])}N=N.return}i!==null&&ep(l,i,p,y),l.flags|=262144}function nd(i){for(i=i.firstContext;i!==null;){if(!Nr(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Ca(i){wa=i,Ks=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Yn(i){return N_(wa,i)}function rd(i,l){return wa===null&&Ca(i),N_(i,l)}function N_(i,l){var p=l._currentValue;if(l={context:l,memoizedValue:p,next:null},Ks===null){if(i===null)throw Error(r(308));Ks=l,i.dependencies={lanes:0,firstContext:l},i.flags|=524288}else Ks=Ks.next=l;return p}var zL=typeof AbortController<"u"?AbortController:function(){var i=[],l=this.signal={aborted:!1,addEventListener:function(p,y){i.push(y)}};this.abort=function(){l.aborted=!0,i.forEach(function(p){return p()})}},UL=e.unstable_scheduleCallback,VL=e.unstable_NormalPriority,An={$$typeof:b,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function tp(){return{controller:new zL,data:new Map,refCount:0}}function nc(i){i.refCount--,i.refCount===0&&UL(VL,function(){i.controller.abort()})}var rc=null,np=0,Lo=0,Ro=null;function WL(i,l){if(rc===null){var p=rc=[];np=0,Lo=ig(),Ro={status:"pending",value:void 0,then:function(y){p.push(y)}}}return np++,l.then(T_,T_),l}function T_(){if(--np===0&&rc!==null){Ro!==null&&(Ro.status="fulfilled");var i=rc;rc=null,Lo=0,Ro=null;for(var l=0;l<i.length;l++)(0,i[l])()}}function GL(i,l){var p=[],y={status:"pending",value:null,reason:null,then:function(N){p.push(N)}};return i.then(function(){y.status="fulfilled",y.value=l;for(var N=0;N<p.length;N++)(0,p[N])(l)},function(N){for(y.status="rejected",y.reason=N,N=0;N<p.length;N++)(0,p[N])(void 0)}),y}var A_=V.S;V.S=function(i,l){fS=Pe(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&WL(i,l),A_!==null&&A_(i,l)};var ka=D(null);function rp(){var i=ka.current;return i!==null?i:tn.pooledCache}function sd(i,l){l===null?$(ka,ka.current):$(ka,l.pool)}function L_(){var i=rp();return i===null?null:{parent:An._currentValue,pool:i}}var Do=Error(r(460)),sp=Error(r(474)),id=Error(r(542)),ad={then:function(){}};function R_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function D_(i,l,p){switch(p=i[p],p===void 0?i.push(l):p!==l&&(l.then(Vs,Vs),l=p),l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,I_(i),i;default:if(typeof l.status=="string")l.then(Vs,Vs);else{if(i=tn,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=l,i.status="pending",i.then(function(y){if(l.status==="pending"){var N=l;N.status="fulfilled",N.value=y}},function(y){if(l.status==="pending"){var N=l;N.status="rejected",N.reason=y}})}switch(l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,I_(i),i}throw Ea=l,Do}}function ja(i){try{var l=i._init;return l(i._payload)}catch(p){throw p!==null&&typeof p=="object"&&typeof p.then=="function"?(Ea=p,Do):p}}var Ea=null;function O_(){if(Ea===null)throw Error(r(459));var i=Ea;return Ea=null,i}function I_(i){if(i===Do||i===id)throw Error(r(483))}var Oo=null,sc=0;function od(i){var l=sc;return sc+=1,Oo===null&&(Oo=[]),D_(Oo,i,l)}function ic(i,l){l=l.props.ref,i.ref=l!==void 0?l:null}function ld(i,l){throw l.$$typeof===g?Error(r(525)):(i=Object.prototype.toString.call(l),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":i)))}function M_(i){function l(fe,ce){if(i){var xe=fe.deletions;xe===null?(fe.deletions=[ce],fe.flags|=16):xe.push(ce)}}function p(fe,ce){if(!i)return null;for(;ce!==null;)l(fe,ce),ce=ce.sibling;return null}function y(fe){for(var ce=new Map;fe!==null;)fe.key!==null?ce.set(fe.key,fe):ce.set(fe.index,fe),fe=fe.sibling;return ce}function N(fe,ce){return fe=Gs(fe,ce),fe.index=0,fe.sibling=null,fe}function R(fe,ce,xe){return fe.index=xe,i?(xe=fe.alternate,xe!==null?(xe=xe.index,xe<ce?(fe.flags|=67108866,ce):xe):(fe.flags|=67108866,ce)):(fe.flags|=1048576,ce)}function W(fe){return i&&fe.alternate===null&&(fe.flags|=67108866),fe}function ee(fe,ce,xe,Be){return ce===null||ce.tag!==6?(ce=Gm(xe,fe.mode,Be),ce.return=fe,ce):(ce=N(ce,xe),ce.return=fe,ce)}function oe(fe,ce,xe,Be){var ut=xe.type;return ut===C?Me(fe,ce,xe.props.children,Be,xe.key):ce!==null&&(ce.elementType===ut||typeof ut=="object"&&ut!==null&&ut.$$typeof===A&&ja(ut)===ce.type)?(ce=N(ce,xe.props),ic(ce,xe),ce.return=fe,ce):(ce=ed(xe.type,xe.key,xe.props,null,fe.mode,Be),ic(ce,xe),ce.return=fe,ce)}function be(fe,ce,xe,Be){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==xe.containerInfo||ce.stateNode.implementation!==xe.implementation?(ce=qm(xe,fe.mode,Be),ce.return=fe,ce):(ce=N(ce,xe.children||[]),ce.return=fe,ce)}function Me(fe,ce,xe,Be,ut){return ce===null||ce.tag!==7?(ce=_a(xe,fe.mode,Be,ut),ce.return=fe,ce):(ce=N(ce,xe),ce.return=fe,ce)}function ze(fe,ce,xe){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return ce=Gm(""+ce,fe.mode,xe),ce.return=fe,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case x:return xe=ed(ce.type,ce.key,ce.props,null,fe.mode,xe),ic(xe,ce),xe.return=fe,xe;case w:return ce=qm(ce,fe.mode,xe),ce.return=fe,ce;case A:return ce=ja(ce),ze(fe,ce,xe)}if(G(ce)||B(ce))return ce=_a(ce,fe.mode,xe,null),ce.return=fe,ce;if(typeof ce.then=="function")return ze(fe,od(ce),xe);if(ce.$$typeof===b)return ze(fe,rd(fe,ce),xe);ld(fe,ce)}return null}function we(fe,ce,xe,Be){var ut=ce!==null?ce.key:null;if(typeof xe=="string"&&xe!==""||typeof xe=="number"||typeof xe=="bigint")return ut!==null?null:ee(fe,ce,""+xe,Be);if(typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case x:return xe.key===ut?oe(fe,ce,xe,Be):null;case w:return xe.key===ut?be(fe,ce,xe,Be):null;case A:return xe=ja(xe),we(fe,ce,xe,Be)}if(G(xe)||B(xe))return ut!==null?null:Me(fe,ce,xe,Be,null);if(typeof xe.then=="function")return we(fe,ce,od(xe),Be);if(xe.$$typeof===b)return we(fe,ce,rd(fe,xe),Be);ld(fe,xe)}return null}function je(fe,ce,xe,Be,ut){if(typeof Be=="string"&&Be!==""||typeof Be=="number"||typeof Be=="bigint")return fe=fe.get(xe)||null,ee(ce,fe,""+Be,ut);if(typeof Be=="object"&&Be!==null){switch(Be.$$typeof){case x:return fe=fe.get(Be.key===null?xe:Be.key)||null,oe(ce,fe,Be,ut);case w:return fe=fe.get(Be.key===null?xe:Be.key)||null,be(ce,fe,Be,ut);case A:return Be=ja(Be),je(fe,ce,xe,Be,ut)}if(G(Be)||B(Be))return fe=fe.get(xe)||null,Me(ce,fe,Be,ut,null);if(typeof Be.then=="function")return je(fe,ce,xe,od(Be),ut);if(Be.$$typeof===b)return je(fe,ce,xe,rd(ce,Be),ut);ld(ce,Be)}return null}function at(fe,ce,xe,Be){for(var ut=null,$t=null,ct=ce,kt=ce=0,Dt=null;ct!==null&&kt<xe.length;kt++){ct.index>kt?(Dt=ct,ct=null):Dt=ct.sibling;var Ft=we(fe,ct,xe[kt],Be);if(Ft===null){ct===null&&(ct=Dt);break}i&&ct&&Ft.alternate===null&&l(fe,ct),ce=R(Ft,ce,kt),$t===null?ut=Ft:$t.sibling=Ft,$t=Ft,ct=Dt}if(kt===xe.length)return p(fe,ct),Ot&&qs(fe,kt),ut;if(ct===null){for(;kt<xe.length;kt++)ct=ze(fe,xe[kt],Be),ct!==null&&(ce=R(ct,ce,kt),$t===null?ut=ct:$t.sibling=ct,$t=ct);return Ot&&qs(fe,kt),ut}for(ct=y(ct);kt<xe.length;kt++)Dt=je(ct,fe,kt,xe[kt],Be),Dt!==null&&(i&&Dt.alternate!==null&&ct.delete(Dt.key===null?kt:Dt.key),ce=R(Dt,ce,kt),$t===null?ut=Dt:$t.sibling=Dt,$t=Dt);return i&&ct.forEach(function(qi){return l(fe,qi)}),Ot&&qs(fe,kt),ut}function mt(fe,ce,xe,Be){if(xe==null)throw Error(r(151));for(var ut=null,$t=null,ct=ce,kt=ce=0,Dt=null,Ft=xe.next();ct!==null&&!Ft.done;kt++,Ft=xe.next()){ct.index>kt?(Dt=ct,ct=null):Dt=ct.sibling;var qi=we(fe,ct,Ft.value,Be);if(qi===null){ct===null&&(ct=Dt);break}i&&ct&&qi.alternate===null&&l(fe,ct),ce=R(qi,ce,kt),$t===null?ut=qi:$t.sibling=qi,$t=qi,ct=Dt}if(Ft.done)return p(fe,ct),Ot&&qs(fe,kt),ut;if(ct===null){for(;!Ft.done;kt++,Ft=xe.next())Ft=ze(fe,Ft.value,Be),Ft!==null&&(ce=R(Ft,ce,kt),$t===null?ut=Ft:$t.sibling=Ft,$t=Ft);return Ot&&qs(fe,kt),ut}for(ct=y(ct);!Ft.done;kt++,Ft=xe.next())Ft=je(ct,fe,kt,Ft.value,Be),Ft!==null&&(i&&Ft.alternate!==null&&ct.delete(Ft.key===null?kt:Ft.key),ce=R(Ft,ce,kt),$t===null?ut=Ft:$t.sibling=Ft,$t=Ft);return i&&ct.forEach(function(rD){return l(fe,rD)}),Ot&&qs(fe,kt),ut}function Jt(fe,ce,xe,Be){if(typeof xe=="object"&&xe!==null&&xe.type===C&&xe.key===null&&(xe=xe.props.children),typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case x:e:{for(var ut=xe.key;ce!==null;){if(ce.key===ut){if(ut=xe.type,ut===C){if(ce.tag===7){p(fe,ce.sibling),Be=N(ce,xe.props.children),Be.return=fe,fe=Be;break e}}else if(ce.elementType===ut||typeof ut=="object"&&ut!==null&&ut.$$typeof===A&&ja(ut)===ce.type){p(fe,ce.sibling),Be=N(ce,xe.props),ic(Be,xe),Be.return=fe,fe=Be;break e}p(fe,ce);break}else l(fe,ce);ce=ce.sibling}xe.type===C?(Be=_a(xe.props.children,fe.mode,Be,xe.key),Be.return=fe,fe=Be):(Be=ed(xe.type,xe.key,xe.props,null,fe.mode,Be),ic(Be,xe),Be.return=fe,fe=Be)}return W(fe);case w:e:{for(ut=xe.key;ce!==null;){if(ce.key===ut)if(ce.tag===4&&ce.stateNode.containerInfo===xe.containerInfo&&ce.stateNode.implementation===xe.implementation){p(fe,ce.sibling),Be=N(ce,xe.children||[]),Be.return=fe,fe=Be;break e}else{p(fe,ce);break}else l(fe,ce);ce=ce.sibling}Be=qm(xe,fe.mode,Be),Be.return=fe,fe=Be}return W(fe);case A:return xe=ja(xe),Jt(fe,ce,xe,Be)}if(G(xe))return at(fe,ce,xe,Be);if(B(xe)){if(ut=B(xe),typeof ut!="function")throw Error(r(150));return xe=ut.call(xe),mt(fe,ce,xe,Be)}if(typeof xe.then=="function")return Jt(fe,ce,od(xe),Be);if(xe.$$typeof===b)return Jt(fe,ce,rd(fe,xe),Be);ld(fe,xe)}return typeof xe=="string"&&xe!==""||typeof xe=="number"||typeof xe=="bigint"?(xe=""+xe,ce!==null&&ce.tag===6?(p(fe,ce.sibling),Be=N(ce,xe),Be.return=fe,fe=Be):(p(fe,ce),Be=Gm(xe,fe.mode,Be),Be.return=fe,fe=Be),W(fe)):p(fe,ce)}return function(fe,ce,xe,Be){try{sc=0;var ut=Jt(fe,ce,xe,Be);return Oo=null,ut}catch(ct){if(ct===Do||ct===id)throw ct;var $t=Tr(29,ct,null,fe.mode);return $t.lanes=Be,$t.return=fe,$t}finally{}}}var Na=M_(!0),P_=M_(!1),Ai=!1;function ip(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ap(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Li(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Ri(i,l,p){var y=i.updateQueue;if(y===null)return null;if(y=y.shared,(Ut&2)!==0){var N=y.pending;return N===null?l.next=l:(l.next=N.next,N.next=l),y.pending=l,l=Zu(i),v_(i,null,p),l}return Ju(i,y,l,p),Zu(i)}function ac(i,l,p){if(l=l.updateQueue,l!==null&&(l=l.shared,(p&4194048)!==0)){var y=l.lanes;y&=i.pendingLanes,p|=y,l.lanes=p,Ve(i,p)}}function op(i,l){var p=i.updateQueue,y=i.alternate;if(y!==null&&(y=y.updateQueue,p===y)){var N=null,R=null;if(p=p.firstBaseUpdate,p!==null){do{var W={lane:p.lane,tag:p.tag,payload:p.payload,callback:null,next:null};R===null?N=R=W:R=R.next=W,p=p.next}while(p!==null);R===null?N=R=l:R=R.next=l}else N=R=l;p={baseState:y.baseState,firstBaseUpdate:N,lastBaseUpdate:R,shared:y.shared,callbacks:y.callbacks},i.updateQueue=p;return}i=p.lastBaseUpdate,i===null?p.firstBaseUpdate=l:i.next=l,p.lastBaseUpdate=l}var lp=!1;function oc(){if(lp){var i=Ro;if(i!==null)throw i}}function lc(i,l,p,y){lp=!1;var N=i.updateQueue;Ai=!1;var R=N.firstBaseUpdate,W=N.lastBaseUpdate,ee=N.shared.pending;if(ee!==null){N.shared.pending=null;var oe=ee,be=oe.next;oe.next=null,W===null?R=be:W.next=be,W=oe;var Me=i.alternate;Me!==null&&(Me=Me.updateQueue,ee=Me.lastBaseUpdate,ee!==W&&(ee===null?Me.firstBaseUpdate=be:ee.next=be,Me.lastBaseUpdate=oe))}if(R!==null){var ze=N.baseState;W=0,Me=be=oe=null,ee=R;do{var we=ee.lane&-536870913,je=we!==ee.lane;if(je?(Rt&we)===we:(y&we)===we){we!==0&&we===Lo&&(lp=!0),Me!==null&&(Me=Me.next={lane:0,tag:ee.tag,payload:ee.payload,callback:null,next:null});e:{var at=i,mt=ee;we=l;var Jt=p;switch(mt.tag){case 1:if(at=mt.payload,typeof at=="function"){ze=at.call(Jt,ze,we);break e}ze=at;break e;case 3:at.flags=at.flags&-65537|128;case 0:if(at=mt.payload,we=typeof at=="function"?at.call(Jt,ze,we):at,we==null)break e;ze=f({},ze,we);break e;case 2:Ai=!0}}we=ee.callback,we!==null&&(i.flags|=64,je&&(i.flags|=8192),je=N.callbacks,je===null?N.callbacks=[we]:je.push(we))}else je={lane:we,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null},Me===null?(be=Me=je,oe=ze):Me=Me.next=je,W|=we;if(ee=ee.next,ee===null){if(ee=N.shared.pending,ee===null)break;je=ee,ee=je.next,je.next=null,N.lastBaseUpdate=je,N.shared.pending=null}}while(!0);Me===null&&(oe=ze),N.baseState=oe,N.firstBaseUpdate=be,N.lastBaseUpdate=Me,R===null&&(N.shared.lanes=0),Pi|=W,i.lanes=W,i.memoizedState=ze}}function B_(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function $_(i,l){var p=i.callbacks;if(p!==null)for(i.callbacks=null,i=0;i<p.length;i++)B_(p[i],l)}var Io=D(null),cd=D(0);function F_(i,l){i=si,$(cd,i),$(Io,l),si=i|l.baseLanes}function cp(){$(cd,si),$(Io,Io.current)}function up(){si=cd.current,U(Io),U(cd)}var Ar=D(null),Xr=null;function Di(i){var l=i.alternate;$(kn,kn.current&1),$(Ar,i),Xr===null&&(l===null||Io.current!==null||l.memoizedState!==null)&&(Xr=i)}function dp(i){$(kn,kn.current),$(Ar,i),Xr===null&&(Xr=i)}function H_(i){i.tag===22?($(kn,kn.current),$(Ar,i),Xr===null&&(Xr=i)):Oi()}function Oi(){$(kn,kn.current),$(Ar,Ar.current)}function Lr(i){U(Ar),Xr===i&&(Xr=null),U(kn)}var kn=D(0);function ud(i){for(var l=i;l!==null;){if(l.tag===13){var p=l.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||xg(p)||yg(p)))return l}else if(l.tag===19&&(l.memoizedProps.revealOrder==="forwards"||l.memoizedProps.revealOrder==="backwards"||l.memoizedProps.revealOrder==="unstable_legacy-backwards"||l.memoizedProps.revealOrder==="together")){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Xs=0,Ct=null,Xt=null,Ln=null,dd=!1,Mo=!1,Ta=!1,hd=0,cc=0,Po=null,qL=0;function _n(){throw Error(r(321))}function hp(i,l){if(l===null)return!1;for(var p=0;p<l.length&&p<i.length;p++)if(!Nr(i[p],l[p]))return!1;return!0}function fp(i,l,p,y,N,R){return Xs=R,Ct=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,V.H=i===null||i.memoizedState===null?C0:Np,Ta=!1,R=p(y,N),Ta=!1,Mo&&(R=U_(l,p,y,N)),z_(i),R}function z_(i){V.H=hc;var l=Xt!==null&&Xt.next!==null;if(Xs=0,Ln=Xt=Ct=null,dd=!1,cc=0,Po=null,l)throw Error(r(300));i===null||Rn||(i=i.dependencies,i!==null&&nd(i)&&(Rn=!0))}function U_(i,l,p,y){Ct=i;var N=0;do{if(Mo&&(Po=null),cc=0,Mo=!1,25<=N)throw Error(r(301));if(N+=1,Ln=Xt=null,i.updateQueue!=null){var R=i.updateQueue;R.lastEffect=null,R.events=null,R.stores=null,R.memoCache!=null&&(R.memoCache.index=0)}V.H=k0,R=l(p,y)}while(Mo);return R}function KL(){var i=V.H,l=i.useState()[0];return l=typeof l.then=="function"?uc(l):l,i=i.useState()[0],(Xt!==null?Xt.memoizedState:null)!==i&&(Ct.flags|=1024),l}function mp(){var i=hd!==0;return hd=0,i}function pp(i,l,p){l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~p}function gp(i){if(dd){for(i=i.memoizedState;i!==null;){var l=i.queue;l!==null&&(l.pending=null),i=i.next}dd=!1}Xs=0,Ln=Xt=Ct=null,Mo=!1,cc=hd=0,Po=null}function lr(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ln===null?Ct.memoizedState=Ln=i:Ln=Ln.next=i,Ln}function jn(){if(Xt===null){var i=Ct.alternate;i=i!==null?i.memoizedState:null}else i=Xt.next;var l=Ln===null?Ct.memoizedState:Ln.next;if(l!==null)Ln=l,Xt=i;else{if(i===null)throw Ct.alternate===null?Error(r(467)):Error(r(310));Xt=i,i={memoizedState:Xt.memoizedState,baseState:Xt.baseState,baseQueue:Xt.baseQueue,queue:Xt.queue,next:null},Ln===null?Ct.memoizedState=Ln=i:Ln=Ln.next=i}return Ln}function fd(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function uc(i){var l=cc;return cc+=1,Po===null&&(Po=[]),i=D_(Po,i,l),l=Ct,(Ln===null?l.memoizedState:Ln.next)===null&&(l=l.alternate,V.H=l===null||l.memoizedState===null?C0:Np),i}function md(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return uc(i);if(i.$$typeof===b)return Yn(i)}throw Error(r(438,String(i)))}function xp(i){var l=null,p=Ct.updateQueue;if(p!==null&&(l=p.memoCache),l==null){var y=Ct.alternate;y!==null&&(y=y.updateQueue,y!==null&&(y=y.memoCache,y!=null&&(l={data:y.data.map(function(N){return N.slice()}),index:0})))}if(l==null&&(l={data:[],index:0}),p===null&&(p=fd(),Ct.updateQueue=p),p.memoCache=l,p=l.data[l.index],p===void 0)for(p=l.data[l.index]=Array(i),y=0;y<i;y++)p[y]=M;return l.index++,p}function Qs(i,l){return typeof l=="function"?l(i):l}function pd(i){var l=jn();return yp(l,Xt,i)}function yp(i,l,p){var y=i.queue;if(y===null)throw Error(r(311));y.lastRenderedReducer=p;var N=i.baseQueue,R=y.pending;if(R!==null){if(N!==null){var W=N.next;N.next=R.next,R.next=W}l.baseQueue=N=R,y.pending=null}if(R=i.baseState,N===null)i.memoizedState=R;else{l=N.next;var ee=W=null,oe=null,be=l,Me=!1;do{var ze=be.lane&-536870913;if(ze!==be.lane?(Rt&ze)===ze:(Xs&ze)===ze){var we=be.revertLane;if(we===0)oe!==null&&(oe=oe.next={lane:0,revertLane:0,gesture:null,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null}),ze===Lo&&(Me=!0);else if((Xs&we)===we){be=be.next,we===Lo&&(Me=!0);continue}else ze={lane:0,revertLane:be.revertLane,gesture:null,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null},oe===null?(ee=oe=ze,W=R):oe=oe.next=ze,Ct.lanes|=we,Pi|=we;ze=be.action,Ta&&p(R,ze),R=be.hasEagerState?be.eagerState:p(R,ze)}else we={lane:ze,revertLane:be.revertLane,gesture:be.gesture,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null},oe===null?(ee=oe=we,W=R):oe=oe.next=we,Ct.lanes|=ze,Pi|=ze;be=be.next}while(be!==null&&be!==l);if(oe===null?W=R:oe.next=ee,!Nr(R,i.memoizedState)&&(Rn=!0,Me&&(p=Ro,p!==null)))throw p;i.memoizedState=R,i.baseState=W,i.baseQueue=oe,y.lastRenderedState=R}return N===null&&(y.lanes=0),[i.memoizedState,y.dispatch]}function bp(i){var l=jn(),p=l.queue;if(p===null)throw Error(r(311));p.lastRenderedReducer=i;var y=p.dispatch,N=p.pending,R=l.memoizedState;if(N!==null){p.pending=null;var W=N=N.next;do R=i(R,W.action),W=W.next;while(W!==N);Nr(R,l.memoizedState)||(Rn=!0),l.memoizedState=R,l.baseQueue===null&&(l.baseState=R),p.lastRenderedState=R}return[R,y]}function V_(i,l,p){var y=Ct,N=jn(),R=Ot;if(R){if(p===void 0)throw Error(r(407));p=p()}else p=l();var W=!Nr((Xt||N).memoizedState,p);if(W&&(N.memoizedState=p,Rn=!0),N=N.queue,Sp(q_.bind(null,y,N,i),[i]),N.getSnapshot!==l||W||Ln!==null&&Ln.memoizedState.tag&1){if(y.flags|=2048,Bo(9,{destroy:void 0},G_.bind(null,y,N,p,l),null),tn===null)throw Error(r(349));R||(Xs&127)!==0||W_(y,l,p)}return p}function W_(i,l,p){i.flags|=16384,i={getSnapshot:l,value:p},l=Ct.updateQueue,l===null?(l=fd(),Ct.updateQueue=l,l.stores=[i]):(p=l.stores,p===null?l.stores=[i]:p.push(i))}function G_(i,l,p,y){l.value=p,l.getSnapshot=y,K_(l)&&Y_(i)}function q_(i,l,p){return p(function(){K_(l)&&Y_(i)})}function K_(i){var l=i.getSnapshot;i=i.value;try{var p=l();return!Nr(i,p)}catch{return!0}}function Y_(i){var l=va(i,2);l!==null&&yr(l,i,2)}function vp(i){var l=lr();if(typeof i=="function"){var p=i;if(i=p(),Ta){De(!0);try{p()}finally{De(!1)}}}return l.memoizedState=l.baseState=i,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qs,lastRenderedState:i},l}function X_(i,l,p,y){return i.baseState=p,yp(i,Xt,typeof y=="function"?y:Qs)}function YL(i,l,p,y,N){if(yd(i))throw Error(r(485));if(i=l.action,i!==null){var R={payload:N,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(W){R.listeners.push(W)}};V.T!==null?p(!0):R.isTransition=!1,y(R),p=l.pending,p===null?(R.next=l.pending=R,Q_(l,R)):(R.next=p.next,l.pending=p.next=R)}}function Q_(i,l){var p=l.action,y=l.payload,N=i.state;if(l.isTransition){var R=V.T,W={};V.T=W;try{var ee=p(N,y),oe=V.S;oe!==null&&oe(W,ee),J_(i,l,ee)}catch(be){_p(i,l,be)}finally{R!==null&&W.types!==null&&(R.types=W.types),V.T=R}}else try{R=p(N,y),J_(i,l,R)}catch(be){_p(i,l,be)}}function J_(i,l,p){p!==null&&typeof p=="object"&&typeof p.then=="function"?p.then(function(y){Z_(i,l,y)},function(y){return _p(i,l,y)}):Z_(i,l,p)}function Z_(i,l,p){l.status="fulfilled",l.value=p,e0(l),i.state=p,l=i.pending,l!==null&&(p=l.next,p===l?i.pending=null:(p=p.next,l.next=p,Q_(i,p)))}function _p(i,l,p){var y=i.pending;if(i.pending=null,y!==null){y=y.next;do l.status="rejected",l.reason=p,e0(l),l=l.next;while(l!==y)}i.action=null}function e0(i){i=i.listeners;for(var l=0;l<i.length;l++)(0,i[l])()}function t0(i,l){return l}function n0(i,l){if(Ot){var p=tn.formState;if(p!==null){e:{var y=Ct;if(Ot){if(un){t:{for(var N=un,R=Yr;N.nodeType!==8;){if(!R){N=null;break t}if(N=Qr(N.nextSibling),N===null){N=null;break t}}R=N.data,N=R==="F!"||R==="F"?N:null}if(N){un=Qr(N.nextSibling),y=N.data==="F!";break e}}Ni(y)}y=!1}y&&(l=p[0])}}return p=lr(),p.memoizedState=p.baseState=l,y={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t0,lastRenderedState:l},p.queue=y,p=_0.bind(null,Ct,y),y.dispatch=p,y=vp(!1),R=Ep.bind(null,Ct,!1,y.queue),y=lr(),N={state:l,dispatch:null,action:i,pending:null},y.queue=N,p=YL.bind(null,Ct,N,R,p),N.dispatch=p,y.memoizedState=i,[l,p,!1]}function r0(i){var l=jn();return s0(l,Xt,i)}function s0(i,l,p){if(l=yp(i,l,t0)[0],i=pd(Qs)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var y=uc(l)}catch(W){throw W===Do?id:W}else y=l;l=jn();var N=l.queue,R=N.dispatch;return p!==l.memoizedState&&(Ct.flags|=2048,Bo(9,{destroy:void 0},XL.bind(null,N,p),null)),[y,R,i]}function XL(i,l){i.action=l}function i0(i){var l=jn(),p=Xt;if(p!==null)return s0(l,p,i);jn(),l=l.memoizedState,p=jn();var y=p.queue.dispatch;return p.memoizedState=i,[l,y,!1]}function Bo(i,l,p,y){return i={tag:i,create:p,deps:y,inst:l,next:null},l=Ct.updateQueue,l===null&&(l=fd(),Ct.updateQueue=l),p=l.lastEffect,p===null?l.lastEffect=i.next=i:(y=p.next,p.next=i,i.next=y,l.lastEffect=i),i}function a0(){return jn().memoizedState}function gd(i,l,p,y){var N=lr();Ct.flags|=i,N.memoizedState=Bo(1|l,{destroy:void 0},p,y===void 0?null:y)}function xd(i,l,p,y){var N=jn();y=y===void 0?null:y;var R=N.memoizedState.inst;Xt!==null&&y!==null&&hp(y,Xt.memoizedState.deps)?N.memoizedState=Bo(l,R,p,y):(Ct.flags|=i,N.memoizedState=Bo(1|l,R,p,y))}function o0(i,l){gd(8390656,8,i,l)}function Sp(i,l){xd(2048,8,i,l)}function QL(i){Ct.flags|=4;var l=Ct.updateQueue;if(l===null)l=fd(),Ct.updateQueue=l,l.events=[i];else{var p=l.events;p===null?l.events=[i]:p.push(i)}}function l0(i){var l=jn().memoizedState;return QL({ref:l,nextImpl:i}),function(){if((Ut&2)!==0)throw Error(r(440));return l.impl.apply(void 0,arguments)}}function c0(i,l){return xd(4,2,i,l)}function u0(i,l){return xd(4,4,i,l)}function d0(i,l){if(typeof l=="function"){i=i();var p=l(i);return function(){typeof p=="function"?p():l(null)}}if(l!=null)return i=i(),l.current=i,function(){l.current=null}}function h0(i,l,p){p=p!=null?p.concat([i]):null,xd(4,4,d0.bind(null,l,i),p)}function wp(){}function f0(i,l){var p=jn();l=l===void 0?null:l;var y=p.memoizedState;return l!==null&&hp(l,y[1])?y[0]:(p.memoizedState=[i,l],i)}function m0(i,l){var p=jn();l=l===void 0?null:l;var y=p.memoizedState;if(l!==null&&hp(l,y[1]))return y[0];if(y=i(),Ta){De(!0);try{i()}finally{De(!1)}}return p.memoizedState=[y,l],y}function Cp(i,l,p){return p===void 0||(Xs&1073741824)!==0&&(Rt&261930)===0?i.memoizedState=l:(i.memoizedState=p,i=pS(),Ct.lanes|=i,Pi|=i,p)}function p0(i,l,p,y){return Nr(p,l)?p:Io.current!==null?(i=Cp(i,p,y),Nr(i,l)||(Rn=!0),i):(Xs&42)===0||(Xs&1073741824)!==0&&(Rt&261930)===0?(Rn=!0,i.memoizedState=p):(i=pS(),Ct.lanes|=i,Pi|=i,l)}function g0(i,l,p,y,N){var R=Z.p;Z.p=R!==0&&8>R?R:8;var W=V.T,ee={};V.T=ee,Ep(i,!1,l,p);try{var oe=N(),be=V.S;if(be!==null&&be(ee,oe),oe!==null&&typeof oe=="object"&&typeof oe.then=="function"){var Me=GL(oe,y);dc(i,l,Me,Or(i))}else dc(i,l,y,Or(i))}catch(ze){dc(i,l,{then:function(){},status:"rejected",reason:ze},Or())}finally{Z.p=R,W!==null&&ee.types!==null&&(W.types=ee.types),V.T=W}}function JL(){}function kp(i,l,p,y){if(i.tag!==5)throw Error(r(476));var N=x0(i).queue;g0(i,N,l,J,p===null?JL:function(){return y0(i),p(y)})}function x0(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qs,lastRenderedState:J},next:null};var p={};return l.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qs,lastRenderedState:p},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function y0(i){var l=x0(i);l.next===null&&(l=i.alternate.memoizedState),dc(i,l.next.queue,{},Or())}function jp(){return Yn(Nc)}function b0(){return jn().memoizedState}function v0(){return jn().memoizedState}function ZL(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var p=Or();i=Li(p);var y=Ri(l,i,p);y!==null&&(yr(y,l,p),ac(y,l,p)),l={cache:tp()},i.payload=l;return}l=l.return}}function eR(i,l,p){var y=Or();p={lane:y,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},yd(i)?S0(l,p):(p=Vm(i,l,p,y),p!==null&&(yr(p,i,y),w0(p,l,y)))}function _0(i,l,p){var y=Or();dc(i,l,p,y)}function dc(i,l,p,y){var N={lane:y,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null};if(yd(i))S0(l,N);else{var R=i.alternate;if(i.lanes===0&&(R===null||R.lanes===0)&&(R=l.lastRenderedReducer,R!==null))try{var W=l.lastRenderedState,ee=R(W,p);if(N.hasEagerState=!0,N.eagerState=ee,Nr(ee,W))return Ju(i,l,N,0),tn===null&&Qu(),!1}catch{}finally{}if(p=Vm(i,l,N,y),p!==null)return yr(p,i,y),w0(p,l,y),!0}return!1}function Ep(i,l,p,y){if(y={lane:2,revertLane:ig(),gesture:null,action:y,hasEagerState:!1,eagerState:null,next:null},yd(i)){if(l)throw Error(r(479))}else l=Vm(i,p,y,2),l!==null&&yr(l,i,2)}function yd(i){var l=i.alternate;return i===Ct||l!==null&&l===Ct}function S0(i,l){Mo=dd=!0;var p=i.pending;p===null?l.next=l:(l.next=p.next,p.next=l),i.pending=l}function w0(i,l,p){if((p&4194048)!==0){var y=l.lanes;y&=i.pendingLanes,p|=y,l.lanes=p,Ve(i,p)}}var hc={readContext:Yn,use:md,useCallback:_n,useContext:_n,useEffect:_n,useImperativeHandle:_n,useLayoutEffect:_n,useInsertionEffect:_n,useMemo:_n,useReducer:_n,useRef:_n,useState:_n,useDebugValue:_n,useDeferredValue:_n,useTransition:_n,useSyncExternalStore:_n,useId:_n,useHostTransitionStatus:_n,useFormState:_n,useActionState:_n,useOptimistic:_n,useMemoCache:_n,useCacheRefresh:_n};hc.useEffectEvent=_n;var C0={readContext:Yn,use:md,useCallback:function(i,l){return lr().memoizedState=[i,l===void 0?null:l],i},useContext:Yn,useEffect:o0,useImperativeHandle:function(i,l,p){p=p!=null?p.concat([i]):null,gd(4194308,4,d0.bind(null,l,i),p)},useLayoutEffect:function(i,l){return gd(4194308,4,i,l)},useInsertionEffect:function(i,l){gd(4,2,i,l)},useMemo:function(i,l){var p=lr();l=l===void 0?null:l;var y=i();if(Ta){De(!0);try{i()}finally{De(!1)}}return p.memoizedState=[y,l],y},useReducer:function(i,l,p){var y=lr();if(p!==void 0){var N=p(l);if(Ta){De(!0);try{p(l)}finally{De(!1)}}}else N=l;return y.memoizedState=y.baseState=N,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:N},y.queue=i,i=i.dispatch=eR.bind(null,Ct,i),[y.memoizedState,i]},useRef:function(i){var l=lr();return i={current:i},l.memoizedState=i},useState:function(i){i=vp(i);var l=i.queue,p=_0.bind(null,Ct,l);return l.dispatch=p,[i.memoizedState,p]},useDebugValue:wp,useDeferredValue:function(i,l){var p=lr();return Cp(p,i,l)},useTransition:function(){var i=vp(!1);return i=g0.bind(null,Ct,i.queue,!0,!1),lr().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,p){var y=Ct,N=lr();if(Ot){if(p===void 0)throw Error(r(407));p=p()}else{if(p=l(),tn===null)throw Error(r(349));(Rt&127)!==0||W_(y,l,p)}N.memoizedState=p;var R={value:p,getSnapshot:l};return N.queue=R,o0(q_.bind(null,y,R,i),[i]),y.flags|=2048,Bo(9,{destroy:void 0},G_.bind(null,y,R,p,l),null),p},useId:function(){var i=lr(),l=tn.identifierPrefix;if(Ot){var p=Cs,y=ws;p=(y&~(1<<32-Re(y)-1)).toString(32)+p,l="_"+l+"R_"+p,p=hd++,0<p&&(l+="H"+p.toString(32)),l+="_"}else p=qL++,l="_"+l+"r_"+p.toString(32)+"_";return i.memoizedState=l},useHostTransitionStatus:jp,useFormState:n0,useActionState:n0,useOptimistic:function(i){var l=lr();l.memoizedState=l.baseState=i;var p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=p,l=Ep.bind(null,Ct,!0,p),p.dispatch=l,[i,l]},useMemoCache:xp,useCacheRefresh:function(){return lr().memoizedState=ZL.bind(null,Ct)},useEffectEvent:function(i){var l=lr(),p={impl:i};return l.memoizedState=p,function(){if((Ut&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}},Np={readContext:Yn,use:md,useCallback:f0,useContext:Yn,useEffect:Sp,useImperativeHandle:h0,useInsertionEffect:c0,useLayoutEffect:u0,useMemo:m0,useReducer:pd,useRef:a0,useState:function(){return pd(Qs)},useDebugValue:wp,useDeferredValue:function(i,l){var p=jn();return p0(p,Xt.memoizedState,i,l)},useTransition:function(){var i=pd(Qs)[0],l=jn().memoizedState;return[typeof i=="boolean"?i:uc(i),l]},useSyncExternalStore:V_,useId:b0,useHostTransitionStatus:jp,useFormState:r0,useActionState:r0,useOptimistic:function(i,l){var p=jn();return X_(p,Xt,i,l)},useMemoCache:xp,useCacheRefresh:v0};Np.useEffectEvent=l0;var k0={readContext:Yn,use:md,useCallback:f0,useContext:Yn,useEffect:Sp,useImperativeHandle:h0,useInsertionEffect:c0,useLayoutEffect:u0,useMemo:m0,useReducer:bp,useRef:a0,useState:function(){return bp(Qs)},useDebugValue:wp,useDeferredValue:function(i,l){var p=jn();return Xt===null?Cp(p,i,l):p0(p,Xt.memoizedState,i,l)},useTransition:function(){var i=bp(Qs)[0],l=jn().memoizedState;return[typeof i=="boolean"?i:uc(i),l]},useSyncExternalStore:V_,useId:b0,useHostTransitionStatus:jp,useFormState:i0,useActionState:i0,useOptimistic:function(i,l){var p=jn();return Xt!==null?X_(p,Xt,i,l):(p.baseState=i,[i,p.queue.dispatch])},useMemoCache:xp,useCacheRefresh:v0};k0.useEffectEvent=l0;function Tp(i,l,p,y){l=i.memoizedState,p=p(y,l),p=p==null?l:f({},l,p),i.memoizedState=p,i.lanes===0&&(i.updateQueue.baseState=p)}var Ap={enqueueSetState:function(i,l,p){i=i._reactInternals;var y=Or(),N=Li(y);N.payload=l,p!=null&&(N.callback=p),l=Ri(i,N,y),l!==null&&(yr(l,i,y),ac(l,i,y))},enqueueReplaceState:function(i,l,p){i=i._reactInternals;var y=Or(),N=Li(y);N.tag=1,N.payload=l,p!=null&&(N.callback=p),l=Ri(i,N,y),l!==null&&(yr(l,i,y),ac(l,i,y))},enqueueForceUpdate:function(i,l){i=i._reactInternals;var p=Or(),y=Li(p);y.tag=2,l!=null&&(y.callback=l),l=Ri(i,y,p),l!==null&&(yr(l,i,p),ac(l,i,p))}};function j0(i,l,p,y,N,R,W){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(y,R,W):l.prototype&&l.prototype.isPureReactComponent?!Jl(p,y)||!Jl(N,R):!0}function E0(i,l,p,y){i=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(p,y),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(p,y),l.state!==i&&Ap.enqueueReplaceState(l,l.state,null)}function Aa(i,l){var p=l;if("ref"in l){p={};for(var y in l)y!=="ref"&&(p[y]=l[y])}if(i=i.defaultProps){p===l&&(p=f({},p));for(var N in i)p[N]===void 0&&(p[N]=i[N])}return p}function N0(i){Xu(i)}function T0(i){console.error(i)}function A0(i){Xu(i)}function bd(i,l){try{var p=i.onUncaughtError;p(l.value,{componentStack:l.stack})}catch(y){setTimeout(function(){throw y})}}function L0(i,l,p){try{var y=i.onCaughtError;y(p.value,{componentStack:p.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(N){setTimeout(function(){throw N})}}function Lp(i,l,p){return p=Li(p),p.tag=3,p.payload={element:null},p.callback=function(){bd(i,l)},p}function R0(i){return i=Li(i),i.tag=3,i}function D0(i,l,p,y){var N=p.type.getDerivedStateFromError;if(typeof N=="function"){var R=y.value;i.payload=function(){return N(R)},i.callback=function(){L0(l,p,y)}}var W=p.stateNode;W!==null&&typeof W.componentDidCatch=="function"&&(i.callback=function(){L0(l,p,y),typeof N!="function"&&(Bi===null?Bi=new Set([this]):Bi.add(this));var ee=y.stack;this.componentDidCatch(y.value,{componentStack:ee!==null?ee:""})})}function tR(i,l,p,y,N){if(p.flags|=32768,y!==null&&typeof y=="object"&&typeof y.then=="function"){if(l=p.alternate,l!==null&&Ao(l,p,N,!0),p=Ar.current,p!==null){switch(p.tag){case 31:case 13:return Xr===null?Ld():p.alternate===null&&Sn===0&&(Sn=3),p.flags&=-257,p.flags|=65536,p.lanes=N,y===ad?p.flags|=16384:(l=p.updateQueue,l===null?p.updateQueue=new Set([y]):l.add(y),ng(i,y,N)),!1;case 22:return p.flags|=65536,y===ad?p.flags|=16384:(l=p.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([y])},p.updateQueue=l):(p=l.retryQueue,p===null?l.retryQueue=new Set([y]):p.add(y)),ng(i,y,N)),!1}throw Error(r(435,p.tag))}return ng(i,y,N),Ld(),!1}if(Ot)return l=Ar.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=N,y!==Xm&&(i=Error(r(422),{cause:y}),tc(Gr(i,p)))):(y!==Xm&&(l=Error(r(423),{cause:y}),tc(Gr(l,p))),i=i.current.alternate,i.flags|=65536,N&=-N,i.lanes|=N,y=Gr(y,p),N=Lp(i.stateNode,y,N),op(i,N),Sn!==4&&(Sn=2)),!1;var R=Error(r(520),{cause:y});if(R=Gr(R,p),vc===null?vc=[R]:vc.push(R),Sn!==4&&(Sn=2),l===null)return!0;y=Gr(y,p),p=l;do{switch(p.tag){case 3:return p.flags|=65536,i=N&-N,p.lanes|=i,i=Lp(p.stateNode,y,i),op(p,i),!1;case 1:if(l=p.type,R=p.stateNode,(p.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||R!==null&&typeof R.componentDidCatch=="function"&&(Bi===null||!Bi.has(R))))return p.flags|=65536,N&=-N,p.lanes|=N,N=R0(N),D0(N,i,p,y),op(p,N),!1}p=p.return}while(p!==null);return!1}var Rp=Error(r(461)),Rn=!1;function Xn(i,l,p,y){l.child=i===null?P_(l,null,p,y):Na(l,i.child,p,y)}function O0(i,l,p,y,N){p=p.render;var R=l.ref;if("ref"in y){var W={};for(var ee in y)ee!=="ref"&&(W[ee]=y[ee])}else W=y;return Ca(l),y=fp(i,l,p,W,R,N),ee=mp(),i!==null&&!Rn?(pp(i,l,N),Js(i,l,N)):(Ot&&ee&&Km(l),l.flags|=1,Xn(i,l,y,N),l.child)}function I0(i,l,p,y,N){if(i===null){var R=p.type;return typeof R=="function"&&!Wm(R)&&R.defaultProps===void 0&&p.compare===null?(l.tag=15,l.type=R,M0(i,l,R,y,N)):(i=ed(p.type,null,y,l,l.mode,N),i.ref=l.ref,i.return=l,l.child=i)}if(R=i.child,!Fp(i,N)){var W=R.memoizedProps;if(p=p.compare,p=p!==null?p:Jl,p(W,y)&&i.ref===l.ref)return Js(i,l,N)}return l.flags|=1,i=Gs(R,y),i.ref=l.ref,i.return=l,l.child=i}function M0(i,l,p,y,N){if(i!==null){var R=i.memoizedProps;if(Jl(R,y)&&i.ref===l.ref)if(Rn=!1,l.pendingProps=y=R,Fp(i,N))(i.flags&131072)!==0&&(Rn=!0);else return l.lanes=i.lanes,Js(i,l,N)}return Dp(i,l,p,y,N)}function P0(i,l,p,y){var N=y.children,R=i!==null?i.memoizedState:null;if(i===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),y.mode==="hidden"){if((l.flags&128)!==0){if(R=R!==null?R.baseLanes|p:p,i!==null){for(y=l.child=i.child,N=0;y!==null;)N=N|y.lanes|y.childLanes,y=y.sibling;y=N&~R}else y=0,l.child=null;return B0(i,l,R,p,y)}if((p&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},i!==null&&sd(l,R!==null?R.cachePool:null),R!==null?F_(l,R):cp(),H_(l);else return y=l.lanes=536870912,B0(i,l,R!==null?R.baseLanes|p:p,p,y)}else R!==null?(sd(l,R.cachePool),F_(l,R),Oi(),l.memoizedState=null):(i!==null&&sd(l,null),cp(),Oi());return Xn(i,l,N,p),l.child}function fc(i,l){return i!==null&&i.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function B0(i,l,p,y,N){var R=rp();return R=R===null?null:{parent:An._currentValue,pool:R},l.memoizedState={baseLanes:p,cachePool:R},i!==null&&sd(l,null),cp(),H_(l),i!==null&&Ao(i,l,y,!0),l.childLanes=N,null}function vd(i,l){return l=Sd({mode:l.mode,children:l.children},i.mode),l.ref=i.ref,i.child=l,l.return=i,l}function $0(i,l,p){return Na(l,i.child,null,p),i=vd(l,l.pendingProps),i.flags|=2,Lr(l),l.memoizedState=null,i}function nR(i,l,p){var y=l.pendingProps,N=(l.flags&128)!==0;if(l.flags&=-129,i===null){if(Ot){if(y.mode==="hidden")return i=vd(l,y),l.lanes=536870912,fc(null,i);if(dp(l),(i=un)?(i=QS(i,Yr),i=i!==null&&i.data==="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:ji!==null?{id:ws,overflow:Cs}:null,retryLane:536870912,hydrationErrors:null},p=S_(i),p.return=l,l.child=p,Kn=l,un=null)):i=null,i===null)throw Ni(l);return l.lanes=536870912,null}return vd(l,y)}var R=i.memoizedState;if(R!==null){var W=R.dehydrated;if(dp(l),N)if(l.flags&256)l.flags&=-257,l=$0(i,l,p);else if(l.memoizedState!==null)l.child=i.child,l.flags|=128,l=null;else throw Error(r(558));else if(Rn||Ao(i,l,p,!1),N=(p&i.childLanes)!==0,Rn||N){if(y=tn,y!==null&&(W=le(y,p),W!==0&&W!==R.retryLane))throw R.retryLane=W,va(i,W),yr(y,i,W),Rp;Ld(),l=$0(i,l,p)}else i=R.treeContext,un=Qr(W.nextSibling),Kn=l,Ot=!0,Ei=null,Yr=!1,i!==null&&k_(l,i),l=vd(l,y),l.flags|=4096;return l}return i=Gs(i.child,{mode:y.mode,children:y.children}),i.ref=l.ref,l.child=i,i.return=l,i}function _d(i,l){var p=l.ref;if(p===null)i!==null&&i.ref!==null&&(l.flags|=4194816);else{if(typeof p!="function"&&typeof p!="object")throw Error(r(284));(i===null||i.ref!==p)&&(l.flags|=4194816)}}function Dp(i,l,p,y,N){return Ca(l),p=fp(i,l,p,y,void 0,N),y=mp(),i!==null&&!Rn?(pp(i,l,N),Js(i,l,N)):(Ot&&y&&Km(l),l.flags|=1,Xn(i,l,p,N),l.child)}function F0(i,l,p,y,N,R){return Ca(l),l.updateQueue=null,p=U_(l,y,p,N),z_(i),y=mp(),i!==null&&!Rn?(pp(i,l,R),Js(i,l,R)):(Ot&&y&&Km(l),l.flags|=1,Xn(i,l,p,R),l.child)}function H0(i,l,p,y,N){if(Ca(l),l.stateNode===null){var R=jo,W=p.contextType;typeof W=="object"&&W!==null&&(R=Yn(W)),R=new p(y,R),l.memoizedState=R.state!==null&&R.state!==void 0?R.state:null,R.updater=Ap,l.stateNode=R,R._reactInternals=l,R=l.stateNode,R.props=y,R.state=l.memoizedState,R.refs={},ip(l),W=p.contextType,R.context=typeof W=="object"&&W!==null?Yn(W):jo,R.state=l.memoizedState,W=p.getDerivedStateFromProps,typeof W=="function"&&(Tp(l,p,W,y),R.state=l.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof R.getSnapshotBeforeUpdate=="function"||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(W=R.state,typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount(),W!==R.state&&Ap.enqueueReplaceState(R,R.state,null),lc(l,y,R,N),oc(),R.state=l.memoizedState),typeof R.componentDidMount=="function"&&(l.flags|=4194308),y=!0}else if(i===null){R=l.stateNode;var ee=l.memoizedProps,oe=Aa(p,ee);R.props=oe;var be=R.context,Me=p.contextType;W=jo,typeof Me=="object"&&Me!==null&&(W=Yn(Me));var ze=p.getDerivedStateFromProps;Me=typeof ze=="function"||typeof R.getSnapshotBeforeUpdate=="function",ee=l.pendingProps!==ee,Me||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(ee||be!==W)&&E0(l,R,y,W),Ai=!1;var we=l.memoizedState;R.state=we,lc(l,y,R,N),oc(),be=l.memoizedState,ee||we!==be||Ai?(typeof ze=="function"&&(Tp(l,p,ze,y),be=l.memoizedState),(oe=Ai||j0(l,p,oe,y,we,be,W))?(Me||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount()),typeof R.componentDidMount=="function"&&(l.flags|=4194308)):(typeof R.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=y,l.memoizedState=be),R.props=y,R.state=be,R.context=W,y=oe):(typeof R.componentDidMount=="function"&&(l.flags|=4194308),y=!1)}else{R=l.stateNode,ap(i,l),W=l.memoizedProps,Me=Aa(p,W),R.props=Me,ze=l.pendingProps,we=R.context,be=p.contextType,oe=jo,typeof be=="object"&&be!==null&&(oe=Yn(be)),ee=p.getDerivedStateFromProps,(be=typeof ee=="function"||typeof R.getSnapshotBeforeUpdate=="function")||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(W!==ze||we!==oe)&&E0(l,R,y,oe),Ai=!1,we=l.memoizedState,R.state=we,lc(l,y,R,N),oc();var je=l.memoizedState;W!==ze||we!==je||Ai||i!==null&&i.dependencies!==null&&nd(i.dependencies)?(typeof ee=="function"&&(Tp(l,p,ee,y),je=l.memoizedState),(Me=Ai||j0(l,p,Me,y,we,je,oe)||i!==null&&i.dependencies!==null&&nd(i.dependencies))?(be||typeof R.UNSAFE_componentWillUpdate!="function"&&typeof R.componentWillUpdate!="function"||(typeof R.componentWillUpdate=="function"&&R.componentWillUpdate(y,je,oe),typeof R.UNSAFE_componentWillUpdate=="function"&&R.UNSAFE_componentWillUpdate(y,je,oe)),typeof R.componentDidUpdate=="function"&&(l.flags|=4),typeof R.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof R.componentDidUpdate!="function"||W===i.memoizedProps&&we===i.memoizedState||(l.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||W===i.memoizedProps&&we===i.memoizedState||(l.flags|=1024),l.memoizedProps=y,l.memoizedState=je),R.props=y,R.state=je,R.context=oe,y=Me):(typeof R.componentDidUpdate!="function"||W===i.memoizedProps&&we===i.memoizedState||(l.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||W===i.memoizedProps&&we===i.memoizedState||(l.flags|=1024),y=!1)}return R=y,_d(i,l),y=(l.flags&128)!==0,R||y?(R=l.stateNode,p=y&&typeof p.getDerivedStateFromError!="function"?null:R.render(),l.flags|=1,i!==null&&y?(l.child=Na(l,i.child,null,N),l.child=Na(l,null,p,N)):Xn(i,l,p,N),l.memoizedState=R.state,i=l.child):i=Js(i,l,N),i}function z0(i,l,p,y){return Sa(),l.flags|=256,Xn(i,l,p,y),l.child}var Op={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ip(i){return{baseLanes:i,cachePool:L_()}}function Mp(i,l,p){return i=i!==null?i.childLanes&~p:0,l&&(i|=Dr),i}function U0(i,l,p){var y=l.pendingProps,N=!1,R=(l.flags&128)!==0,W;if((W=R)||(W=i!==null&&i.memoizedState===null?!1:(kn.current&2)!==0),W&&(N=!0,l.flags&=-129),W=(l.flags&32)!==0,l.flags&=-33,i===null){if(Ot){if(N?Di(l):Oi(),(i=un)?(i=QS(i,Yr),i=i!==null&&i.data!=="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:ji!==null?{id:ws,overflow:Cs}:null,retryLane:536870912,hydrationErrors:null},p=S_(i),p.return=l,l.child=p,Kn=l,un=null)):i=null,i===null)throw Ni(l);return yg(i)?l.lanes=32:l.lanes=536870912,null}var ee=y.children;return y=y.fallback,N?(Oi(),N=l.mode,ee=Sd({mode:"hidden",children:ee},N),y=_a(y,N,p,null),ee.return=l,y.return=l,ee.sibling=y,l.child=ee,y=l.child,y.memoizedState=Ip(p),y.childLanes=Mp(i,W,p),l.memoizedState=Op,fc(null,y)):(Di(l),Pp(l,ee))}var oe=i.memoizedState;if(oe!==null&&(ee=oe.dehydrated,ee!==null)){if(R)l.flags&256?(Di(l),l.flags&=-257,l=Bp(i,l,p)):l.memoizedState!==null?(Oi(),l.child=i.child,l.flags|=128,l=null):(Oi(),ee=y.fallback,N=l.mode,y=Sd({mode:"visible",children:y.children},N),ee=_a(ee,N,p,null),ee.flags|=2,y.return=l,ee.return=l,y.sibling=ee,l.child=y,Na(l,i.child,null,p),y=l.child,y.memoizedState=Ip(p),y.childLanes=Mp(i,W,p),l.memoizedState=Op,l=fc(null,y));else if(Di(l),yg(ee)){if(W=ee.nextSibling&&ee.nextSibling.dataset,W)var be=W.dgst;W=be,y=Error(r(419)),y.stack="",y.digest=W,tc({value:y,source:null,stack:null}),l=Bp(i,l,p)}else if(Rn||Ao(i,l,p,!1),W=(p&i.childLanes)!==0,Rn||W){if(W=tn,W!==null&&(y=le(W,p),y!==0&&y!==oe.retryLane))throw oe.retryLane=y,va(i,y),yr(W,i,y),Rp;xg(ee)||Ld(),l=Bp(i,l,p)}else xg(ee)?(l.flags|=192,l.child=i.child,l=null):(i=oe.treeContext,un=Qr(ee.nextSibling),Kn=l,Ot=!0,Ei=null,Yr=!1,i!==null&&k_(l,i),l=Pp(l,y.children),l.flags|=4096);return l}return N?(Oi(),ee=y.fallback,N=l.mode,oe=i.child,be=oe.sibling,y=Gs(oe,{mode:"hidden",children:y.children}),y.subtreeFlags=oe.subtreeFlags&65011712,be!==null?ee=Gs(be,ee):(ee=_a(ee,N,p,null),ee.flags|=2),ee.return=l,y.return=l,y.sibling=ee,l.child=y,fc(null,y),y=l.child,ee=i.child.memoizedState,ee===null?ee=Ip(p):(N=ee.cachePool,N!==null?(oe=An._currentValue,N=N.parent!==oe?{parent:oe,pool:oe}:N):N=L_(),ee={baseLanes:ee.baseLanes|p,cachePool:N}),y.memoizedState=ee,y.childLanes=Mp(i,W,p),l.memoizedState=Op,fc(i.child,y)):(Di(l),p=i.child,i=p.sibling,p=Gs(p,{mode:"visible",children:y.children}),p.return=l,p.sibling=null,i!==null&&(W=l.deletions,W===null?(l.deletions=[i],l.flags|=16):W.push(i)),l.child=p,l.memoizedState=null,p)}function Pp(i,l){return l=Sd({mode:"visible",children:l},i.mode),l.return=i,i.child=l}function Sd(i,l){return i=Tr(22,i,null,l),i.lanes=0,i}function Bp(i,l,p){return Na(l,i.child,null,p),i=Pp(l,l.pendingProps.children),i.flags|=2,l.memoizedState=null,i}function V0(i,l,p){i.lanes|=l;var y=i.alternate;y!==null&&(y.lanes|=l),Zm(i.return,l,p)}function $p(i,l,p,y,N,R){var W=i.memoizedState;W===null?i.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:y,tail:p,tailMode:N,treeForkCount:R}:(W.isBackwards=l,W.rendering=null,W.renderingStartTime=0,W.last=y,W.tail=p,W.tailMode=N,W.treeForkCount=R)}function W0(i,l,p){var y=l.pendingProps,N=y.revealOrder,R=y.tail;y=y.children;var W=kn.current,ee=(W&2)!==0;if(ee?(W=W&1|2,l.flags|=128):W&=1,$(kn,W),Xn(i,l,y,p),y=Ot?ec:0,!ee&&i!==null&&(i.flags&128)!==0)e:for(i=l.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&V0(i,p,l);else if(i.tag===19)V0(i,p,l);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===l)break e;for(;i.sibling===null;){if(i.return===null||i.return===l)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(N){case"forwards":for(p=l.child,N=null;p!==null;)i=p.alternate,i!==null&&ud(i)===null&&(N=p),p=p.sibling;p=N,p===null?(N=l.child,l.child=null):(N=p.sibling,p.sibling=null),$p(l,!1,N,p,R,y);break;case"backwards":case"unstable_legacy-backwards":for(p=null,N=l.child,l.child=null;N!==null;){if(i=N.alternate,i!==null&&ud(i)===null){l.child=N;break}i=N.sibling,N.sibling=p,p=N,N=i}$p(l,!0,p,null,R,y);break;case"together":$p(l,!1,null,null,void 0,y);break;default:l.memoizedState=null}return l.child}function Js(i,l,p){if(i!==null&&(l.dependencies=i.dependencies),Pi|=l.lanes,(p&l.childLanes)===0)if(i!==null){if(Ao(i,l,p,!1),(p&l.childLanes)===0)return null}else return null;if(i!==null&&l.child!==i.child)throw Error(r(153));if(l.child!==null){for(i=l.child,p=Gs(i,i.pendingProps),l.child=p,p.return=l;i.sibling!==null;)i=i.sibling,p=p.sibling=Gs(i,i.pendingProps),p.return=l;p.sibling=null}return l.child}function Fp(i,l){return(i.lanes&l)!==0?!0:(i=i.dependencies,!!(i!==null&&nd(i)))}function rR(i,l,p){switch(l.tag){case 3:I(l,l.stateNode.containerInfo),Ti(l,An,i.memoizedState.cache),Sa();break;case 27:case 5:ne(l);break;case 4:I(l,l.stateNode.containerInfo);break;case 10:Ti(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,dp(l),null;break;case 13:var y=l.memoizedState;if(y!==null)return y.dehydrated!==null?(Di(l),l.flags|=128,null):(p&l.child.childLanes)!==0?U0(i,l,p):(Di(l),i=Js(i,l,p),i!==null?i.sibling:null);Di(l);break;case 19:var N=(i.flags&128)!==0;if(y=(p&l.childLanes)!==0,y||(Ao(i,l,p,!1),y=(p&l.childLanes)!==0),N){if(y)return W0(i,l,p);l.flags|=128}if(N=l.memoizedState,N!==null&&(N.rendering=null,N.tail=null,N.lastEffect=null),$(kn,kn.current),y)break;return null;case 22:return l.lanes=0,P0(i,l,p,l.pendingProps);case 24:Ti(l,An,i.memoizedState.cache)}return Js(i,l,p)}function G0(i,l,p){if(i!==null)if(i.memoizedProps!==l.pendingProps)Rn=!0;else{if(!Fp(i,p)&&(l.flags&128)===0)return Rn=!1,rR(i,l,p);Rn=(i.flags&131072)!==0}else Rn=!1,Ot&&(l.flags&1048576)!==0&&C_(l,ec,l.index);switch(l.lanes=0,l.tag){case 16:e:{var y=l.pendingProps;if(i=ja(l.elementType),l.type=i,typeof i=="function")Wm(i)?(y=Aa(i,y),l.tag=1,l=H0(null,l,i,y,p)):(l.tag=0,l=Dp(null,l,i,y,p));else{if(i!=null){var N=i.$$typeof;if(N===k){l.tag=11,l=O0(null,l,i,y,p);break e}else if(N===L){l.tag=14,l=I0(null,l,i,y,p);break e}}throw l=K(i)||i,Error(r(306,l,""))}}return l;case 0:return Dp(i,l,l.type,l.pendingProps,p);case 1:return y=l.type,N=Aa(y,l.pendingProps),H0(i,l,y,N,p);case 3:e:{if(I(l,l.stateNode.containerInfo),i===null)throw Error(r(387));y=l.pendingProps;var R=l.memoizedState;N=R.element,ap(i,l),lc(l,y,null,p);var W=l.memoizedState;if(y=W.cache,Ti(l,An,y),y!==R.cache&&ep(l,[An],p,!0),oc(),y=W.element,R.isDehydrated)if(R={element:y,isDehydrated:!1,cache:W.cache},l.updateQueue.baseState=R,l.memoizedState=R,l.flags&256){l=z0(i,l,y,p);break e}else if(y!==N){N=Gr(Error(r(424)),l),tc(N),l=z0(i,l,y,p);break e}else{switch(i=l.stateNode.containerInfo,i.nodeType){case 9:i=i.body;break;default:i=i.nodeName==="HTML"?i.ownerDocument.body:i}for(un=Qr(i.firstChild),Kn=l,Ot=!0,Ei=null,Yr=!0,p=P_(l,null,y,p),l.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling}else{if(Sa(),y===N){l=Js(i,l,p);break e}Xn(i,l,y,p)}l=l.child}return l;case 26:return _d(i,l),i===null?(p=rw(l.type,null,l.pendingProps,null))?l.memoizedState=p:Ot||(p=l.type,i=l.pendingProps,y=Bd(X.current).createElement(p),y[He]=l,y[et]=i,Qn(y,p,i),zn(y),l.stateNode=y):l.memoizedState=rw(l.type,i.memoizedProps,l.pendingProps,i.memoizedState),null;case 27:return ne(l),i===null&&Ot&&(y=l.stateNode=ew(l.type,l.pendingProps,X.current),Kn=l,Yr=!0,N=un,zi(l.type)?(bg=N,un=Qr(y.firstChild)):un=N),Xn(i,l,l.pendingProps.children,p),_d(i,l),i===null&&(l.flags|=4194304),l.child;case 5:return i===null&&Ot&&((N=y=un)&&(y=DR(y,l.type,l.pendingProps,Yr),y!==null?(l.stateNode=y,Kn=l,un=Qr(y.firstChild),Yr=!1,N=!0):N=!1),N||Ni(l)),ne(l),N=l.type,R=l.pendingProps,W=i!==null?i.memoizedProps:null,y=R.children,mg(N,R)?y=null:W!==null&&mg(N,W)&&(l.flags|=32),l.memoizedState!==null&&(N=fp(i,l,KL,null,null,p),Nc._currentValue=N),_d(i,l),Xn(i,l,y,p),l.child;case 6:return i===null&&Ot&&((i=p=un)&&(p=OR(p,l.pendingProps,Yr),p!==null?(l.stateNode=p,Kn=l,un=null,i=!0):i=!1),i||Ni(l)),null;case 13:return U0(i,l,p);case 4:return I(l,l.stateNode.containerInfo),y=l.pendingProps,i===null?l.child=Na(l,null,y,p):Xn(i,l,y,p),l.child;case 11:return O0(i,l,l.type,l.pendingProps,p);case 7:return Xn(i,l,l.pendingProps,p),l.child;case 8:return Xn(i,l,l.pendingProps.children,p),l.child;case 12:return Xn(i,l,l.pendingProps.children,p),l.child;case 10:return y=l.pendingProps,Ti(l,l.type,y.value),Xn(i,l,y.children,p),l.child;case 9:return N=l.type._context,y=l.pendingProps.children,Ca(l),N=Yn(N),y=y(N),l.flags|=1,Xn(i,l,y,p),l.child;case 14:return I0(i,l,l.type,l.pendingProps,p);case 15:return M0(i,l,l.type,l.pendingProps,p);case 19:return W0(i,l,p);case 31:return nR(i,l,p);case 22:return P0(i,l,p,l.pendingProps);case 24:return Ca(l),y=Yn(An),i===null?(N=rp(),N===null&&(N=tn,R=tp(),N.pooledCache=R,R.refCount++,R!==null&&(N.pooledCacheLanes|=p),N=R),l.memoizedState={parent:y,cache:N},ip(l),Ti(l,An,N)):((i.lanes&p)!==0&&(ap(i,l),lc(l,null,null,p),oc()),N=i.memoizedState,R=l.memoizedState,N.parent!==y?(N={parent:y,cache:y},l.memoizedState=N,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=N),Ti(l,An,y)):(y=R.cache,Ti(l,An,y),y!==N.cache&&ep(l,[An],p,!0))),Xn(i,l,l.pendingProps.children,p),l.child;case 29:throw l.pendingProps}throw Error(r(156,l.tag))}function Zs(i){i.flags|=4}function Hp(i,l,p,y,N){if((l=(i.mode&32)!==0)&&(l=!1),l){if(i.flags|=16777216,(N&335544128)===N)if(i.stateNode.complete)i.flags|=8192;else if(bS())i.flags|=8192;else throw Ea=ad,sp}else i.flags&=-16777217}function q0(i,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!lw(l))if(bS())i.flags|=8192;else throw Ea=ad,sp}function wd(i,l){l!==null&&(i.flags|=4),i.flags&16384&&(l=i.tag!==22?xn():536870912,i.lanes|=l,zo|=l)}function mc(i,l){if(!Ot)switch(i.tailMode){case"hidden":l=i.tail;for(var p=null;l!==null;)l.alternate!==null&&(p=l),l=l.sibling;p===null?i.tail=null:p.sibling=null;break;case"collapsed":p=i.tail;for(var y=null;p!==null;)p.alternate!==null&&(y=p),p=p.sibling;y===null?l||i.tail===null?i.tail=null:i.tail.sibling=null:y.sibling=null}}function dn(i){var l=i.alternate!==null&&i.alternate.child===i.child,p=0,y=0;if(l)for(var N=i.child;N!==null;)p|=N.lanes|N.childLanes,y|=N.subtreeFlags&65011712,y|=N.flags&65011712,N.return=i,N=N.sibling;else for(N=i.child;N!==null;)p|=N.lanes|N.childLanes,y|=N.subtreeFlags,y|=N.flags,N.return=i,N=N.sibling;return i.subtreeFlags|=y,i.childLanes=p,l}function sR(i,l,p){var y=l.pendingProps;switch(Ym(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dn(l),null;case 1:return dn(l),null;case 3:return p=l.stateNode,y=null,i!==null&&(y=i.memoizedState.cache),l.memoizedState.cache!==y&&(l.flags|=2048),Ys(An),Q(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(i===null||i.child===null)&&(To(l)?Zs(l):i===null||i.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Qm())),dn(l),null;case 26:var N=l.type,R=l.memoizedState;return i===null?(Zs(l),R!==null?(dn(l),q0(l,R)):(dn(l),Hp(l,N,null,y,p))):R?R!==i.memoizedState?(Zs(l),dn(l),q0(l,R)):(dn(l),l.flags&=-16777217):(i=i.memoizedProps,i!==y&&Zs(l),dn(l),Hp(l,N,i,y,p)),null;case 27:if(re(l),p=X.current,N=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==y&&Zs(l);else{if(!y){if(l.stateNode===null)throw Error(r(166));return dn(l),null}i=te.current,To(l)?j_(l):(i=ew(N,y,p),l.stateNode=i,Zs(l))}return dn(l),null;case 5:if(re(l),N=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==y&&Zs(l);else{if(!y){if(l.stateNode===null)throw Error(r(166));return dn(l),null}if(R=te.current,To(l))j_(l);else{var W=Bd(X.current);switch(R){case 1:R=W.createElementNS("http://www.w3.org/2000/svg",N);break;case 2:R=W.createElementNS("http://www.w3.org/1998/Math/MathML",N);break;default:switch(N){case"svg":R=W.createElementNS("http://www.w3.org/2000/svg",N);break;case"math":R=W.createElementNS("http://www.w3.org/1998/Math/MathML",N);break;case"script":R=W.createElement("div"),R.innerHTML="<script><\/script>",R=R.removeChild(R.firstChild);break;case"select":R=typeof y.is=="string"?W.createElement("select",{is:y.is}):W.createElement("select"),y.multiple?R.multiple=!0:y.size&&(R.size=y.size);break;default:R=typeof y.is=="string"?W.createElement(N,{is:y.is}):W.createElement(N)}}R[He]=l,R[et]=y;e:for(W=l.child;W!==null;){if(W.tag===5||W.tag===6)R.appendChild(W.stateNode);else if(W.tag!==4&&W.tag!==27&&W.child!==null){W.child.return=W,W=W.child;continue}if(W===l)break e;for(;W.sibling===null;){if(W.return===null||W.return===l)break e;W=W.return}W.sibling.return=W.return,W=W.sibling}l.stateNode=R;e:switch(Qn(R,N,y),N){case"button":case"input":case"select":case"textarea":y=!!y.autoFocus;break e;case"img":y=!0;break e;default:y=!1}y&&Zs(l)}}return dn(l),Hp(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,p),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==y&&Zs(l);else{if(typeof y!="string"&&l.stateNode===null)throw Error(r(166));if(i=X.current,To(l)){if(i=l.stateNode,p=l.memoizedProps,y=null,N=Kn,N!==null)switch(N.tag){case 27:case 5:y=N.memoizedProps}i[He]=l,i=!!(i.nodeValue===p||y!==null&&y.suppressHydrationWarning===!0||US(i.nodeValue,p)),i||Ni(l,!0)}else i=Bd(i).createTextNode(y),i[He]=l,l.stateNode=i}return dn(l),null;case 31:if(p=l.memoizedState,i===null||i.memoizedState!==null){if(y=To(l),p!==null){if(i===null){if(!y)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[He]=l}else Sa(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;dn(l),i=!1}else p=Qm(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=p),i=!0;if(!i)return l.flags&256?(Lr(l),l):(Lr(l),null);if((l.flags&128)!==0)throw Error(r(558))}return dn(l),null;case 13:if(y=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(N=To(l),y!==null&&y.dehydrated!==null){if(i===null){if(!N)throw Error(r(318));if(N=l.memoizedState,N=N!==null?N.dehydrated:null,!N)throw Error(r(317));N[He]=l}else Sa(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;dn(l),N=!1}else N=Qm(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=N),N=!0;if(!N)return l.flags&256?(Lr(l),l):(Lr(l),null)}return Lr(l),(l.flags&128)!==0?(l.lanes=p,l):(p=y!==null,i=i!==null&&i.memoizedState!==null,p&&(y=l.child,N=null,y.alternate!==null&&y.alternate.memoizedState!==null&&y.alternate.memoizedState.cachePool!==null&&(N=y.alternate.memoizedState.cachePool.pool),R=null,y.memoizedState!==null&&y.memoizedState.cachePool!==null&&(R=y.memoizedState.cachePool.pool),R!==N&&(y.flags|=2048)),p!==i&&p&&(l.child.flags|=8192),wd(l,l.updateQueue),dn(l),null);case 4:return Q(),i===null&&cg(l.stateNode.containerInfo),dn(l),null;case 10:return Ys(l.type),dn(l),null;case 19:if(U(kn),y=l.memoizedState,y===null)return dn(l),null;if(N=(l.flags&128)!==0,R=y.rendering,R===null)if(N)mc(y,!1);else{if(Sn!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(R=ud(i),R!==null){for(l.flags|=128,mc(y,!1),i=R.updateQueue,l.updateQueue=i,wd(l,i),l.subtreeFlags=0,i=p,p=l.child;p!==null;)__(p,i),p=p.sibling;return $(kn,kn.current&1|2),Ot&&qs(l,y.treeForkCount),l.child}i=i.sibling}y.tail!==null&&Pe()>Nd&&(l.flags|=128,N=!0,mc(y,!1),l.lanes=4194304)}else{if(!N)if(i=ud(R),i!==null){if(l.flags|=128,N=!0,i=i.updateQueue,l.updateQueue=i,wd(l,i),mc(y,!0),y.tail===null&&y.tailMode==="hidden"&&!R.alternate&&!Ot)return dn(l),null}else 2*Pe()-y.renderingStartTime>Nd&&p!==536870912&&(l.flags|=128,N=!0,mc(y,!1),l.lanes=4194304);y.isBackwards?(R.sibling=l.child,l.child=R):(i=y.last,i!==null?i.sibling=R:l.child=R,y.last=R)}return y.tail!==null?(i=y.tail,y.rendering=i,y.tail=i.sibling,y.renderingStartTime=Pe(),i.sibling=null,p=kn.current,$(kn,N?p&1|2:p&1),Ot&&qs(l,y.treeForkCount),i):(dn(l),null);case 22:case 23:return Lr(l),up(),y=l.memoizedState!==null,i!==null?i.memoizedState!==null!==y&&(l.flags|=8192):y&&(l.flags|=8192),y?(p&536870912)!==0&&(l.flags&128)===0&&(dn(l),l.subtreeFlags&6&&(l.flags|=8192)):dn(l),p=l.updateQueue,p!==null&&wd(l,p.retryQueue),p=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(p=i.memoizedState.cachePool.pool),y=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(y=l.memoizedState.cachePool.pool),y!==p&&(l.flags|=2048),i!==null&&U(ka),null;case 24:return p=null,i!==null&&(p=i.memoizedState.cache),l.memoizedState.cache!==p&&(l.flags|=2048),Ys(An),dn(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function iR(i,l){switch(Ym(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return Ys(An),Q(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return re(l),null;case 31:if(l.memoizedState!==null){if(Lr(l),l.alternate===null)throw Error(r(340));Sa()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(Lr(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Sa()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return U(kn),null;case 4:return Q(),null;case 10:return Ys(l.type),null;case 22:case 23:return Lr(l),up(),i!==null&&U(ka),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return Ys(An),null;case 25:return null;default:return null}}function K0(i,l){switch(Ym(l),l.tag){case 3:Ys(An),Q();break;case 26:case 27:case 5:re(l);break;case 4:Q();break;case 31:l.memoizedState!==null&&Lr(l);break;case 13:Lr(l);break;case 19:U(kn);break;case 10:Ys(l.type);break;case 22:case 23:Lr(l),up(),i!==null&&U(ka);break;case 24:Ys(An)}}function pc(i,l){try{var p=l.updateQueue,y=p!==null?p.lastEffect:null;if(y!==null){var N=y.next;p=N;do{if((p.tag&i)===i){y=void 0;var R=p.create,W=p.inst;y=R(),W.destroy=y}p=p.next}while(p!==N)}}catch(ee){Yt(l,l.return,ee)}}function Ii(i,l,p){try{var y=l.updateQueue,N=y!==null?y.lastEffect:null;if(N!==null){var R=N.next;y=R;do{if((y.tag&i)===i){var W=y.inst,ee=W.destroy;if(ee!==void 0){W.destroy=void 0,N=l;var oe=p,be=ee;try{be()}catch(Me){Yt(N,oe,Me)}}}y=y.next}while(y!==R)}}catch(Me){Yt(l,l.return,Me)}}function Y0(i){var l=i.updateQueue;if(l!==null){var p=i.stateNode;try{$_(l,p)}catch(y){Yt(i,i.return,y)}}}function X0(i,l,p){p.props=Aa(i.type,i.memoizedProps),p.state=i.memoizedState;try{p.componentWillUnmount()}catch(y){Yt(i,l,y)}}function gc(i,l){try{var p=i.ref;if(p!==null){switch(i.tag){case 26:case 27:case 5:var y=i.stateNode;break;case 30:y=i.stateNode;break;default:y=i.stateNode}typeof p=="function"?i.refCleanup=p(y):p.current=y}}catch(N){Yt(i,l,N)}}function ks(i,l){var p=i.ref,y=i.refCleanup;if(p!==null)if(typeof y=="function")try{y()}catch(N){Yt(i,l,N)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(N){Yt(i,l,N)}else p.current=null}function Q0(i){var l=i.type,p=i.memoizedProps,y=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":p.autoFocus&&y.focus();break e;case"img":p.src?y.src=p.src:p.srcSet&&(y.srcset=p.srcSet)}}catch(N){Yt(i,i.return,N)}}function zp(i,l,p){try{var y=i.stateNode;ER(y,i.type,p,l),y[et]=l}catch(N){Yt(i,i.return,N)}}function J0(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&zi(i.type)||i.tag===4}function Up(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||J0(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&zi(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Vp(i,l,p){var y=i.tag;if(y===5||y===6)i=i.stateNode,l?(p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p).insertBefore(i,l):(l=p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p,l.appendChild(i),p=p._reactRootContainer,p!=null||l.onclick!==null||(l.onclick=Vs));else if(y!==4&&(y===27&&zi(i.type)&&(p=i.stateNode,l=null),i=i.child,i!==null))for(Vp(i,l,p),i=i.sibling;i!==null;)Vp(i,l,p),i=i.sibling}function Cd(i,l,p){var y=i.tag;if(y===5||y===6)i=i.stateNode,l?p.insertBefore(i,l):p.appendChild(i);else if(y!==4&&(y===27&&zi(i.type)&&(p=i.stateNode),i=i.child,i!==null))for(Cd(i,l,p),i=i.sibling;i!==null;)Cd(i,l,p),i=i.sibling}function Z0(i){var l=i.stateNode,p=i.memoizedProps;try{for(var y=i.type,N=l.attributes;N.length;)l.removeAttributeNode(N[0]);Qn(l,y,p),l[He]=i,l[et]=p}catch(R){Yt(i,i.return,R)}}var ei=!1,Dn=!1,Wp=!1,eS=typeof WeakSet=="function"?WeakSet:Set,Un=null;function aR(i,l){if(i=i.containerInfo,hg=Wd,i=h_(i),Bm(i)){if("selectionStart"in i)var p={start:i.selectionStart,end:i.selectionEnd};else e:{p=(p=i.ownerDocument)&&p.defaultView||window;var y=p.getSelection&&p.getSelection();if(y&&y.rangeCount!==0){p=y.anchorNode;var N=y.anchorOffset,R=y.focusNode;y=y.focusOffset;try{p.nodeType,R.nodeType}catch{p=null;break e}var W=0,ee=-1,oe=-1,be=0,Me=0,ze=i,we=null;t:for(;;){for(var je;ze!==p||N!==0&&ze.nodeType!==3||(ee=W+N),ze!==R||y!==0&&ze.nodeType!==3||(oe=W+y),ze.nodeType===3&&(W+=ze.nodeValue.length),(je=ze.firstChild)!==null;)we=ze,ze=je;for(;;){if(ze===i)break t;if(we===p&&++be===N&&(ee=W),we===R&&++Me===y&&(oe=W),(je=ze.nextSibling)!==null)break;ze=we,we=ze.parentNode}ze=je}p=ee===-1||oe===-1?null:{start:ee,end:oe}}else p=null}p=p||{start:0,end:0}}else p=null;for(fg={focusedElem:i,selectionRange:p},Wd=!1,Un=l;Un!==null;)if(l=Un,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,Un=i;else for(;Un!==null;){switch(l=Un,R=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(p=0;p<i.length;p++)N=i[p],N.ref.impl=N.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&R!==null){i=void 0,p=l,N=R.memoizedProps,R=R.memoizedState,y=p.stateNode;try{var at=Aa(p.type,N);i=y.getSnapshotBeforeUpdate(at,R),y.__reactInternalSnapshotBeforeUpdate=i}catch(mt){Yt(p,p.return,mt)}}break;case 3:if((i&1024)!==0){if(i=l.stateNode.containerInfo,p=i.nodeType,p===9)gg(i);else if(p===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":gg(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=l.sibling,i!==null){i.return=l.return,Un=i;break}Un=l.return}}function tS(i,l,p){var y=p.flags;switch(p.tag){case 0:case 11:case 15:ni(i,p),y&4&&pc(5,p);break;case 1:if(ni(i,p),y&4)if(i=p.stateNode,l===null)try{i.componentDidMount()}catch(W){Yt(p,p.return,W)}else{var N=Aa(p.type,l.memoizedProps);l=l.memoizedState;try{i.componentDidUpdate(N,l,i.__reactInternalSnapshotBeforeUpdate)}catch(W){Yt(p,p.return,W)}}y&64&&Y0(p),y&512&&gc(p,p.return);break;case 3:if(ni(i,p),y&64&&(i=p.updateQueue,i!==null)){if(l=null,p.child!==null)switch(p.child.tag){case 27:case 5:l=p.child.stateNode;break;case 1:l=p.child.stateNode}try{$_(i,l)}catch(W){Yt(p,p.return,W)}}break;case 27:l===null&&y&4&&Z0(p);case 26:case 5:ni(i,p),l===null&&y&4&&Q0(p),y&512&&gc(p,p.return);break;case 12:ni(i,p);break;case 31:ni(i,p),y&4&&sS(i,p);break;case 13:ni(i,p),y&4&&iS(i,p),y&64&&(i=p.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(p=pR.bind(null,p),IR(i,p))));break;case 22:if(y=p.memoizedState!==null||ei,!y){l=l!==null&&l.memoizedState!==null||Dn,N=ei;var R=Dn;ei=y,(Dn=l)&&!R?ri(i,p,(p.subtreeFlags&8772)!==0):ni(i,p),ei=N,Dn=R}break;case 30:break;default:ni(i,p)}}function nS(i){var l=i.alternate;l!==null&&(i.alternate=null,nS(l)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(l=i.stateNode,l!==null&&fo(l)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var pn=null,mr=!1;function ti(i,l,p){for(p=p.child;p!==null;)rS(i,l,p),p=p.sibling}function rS(i,l,p){if(gt&&typeof gt.onCommitFiberUnmount=="function")try{gt.onCommitFiberUnmount(lt,p)}catch{}switch(p.tag){case 26:Dn||ks(p,l),ti(i,l,p),p.memoizedState?p.memoizedState.count--:p.stateNode&&(p=p.stateNode,p.parentNode.removeChild(p));break;case 27:Dn||ks(p,l);var y=pn,N=mr;zi(p.type)&&(pn=p.stateNode,mr=!1),ti(i,l,p),kc(p.stateNode),pn=y,mr=N;break;case 5:Dn||ks(p,l);case 6:if(y=pn,N=mr,pn=null,ti(i,l,p),pn=y,mr=N,pn!==null)if(mr)try{(pn.nodeType===9?pn.body:pn.nodeName==="HTML"?pn.ownerDocument.body:pn).removeChild(p.stateNode)}catch(R){Yt(p,l,R)}else try{pn.removeChild(p.stateNode)}catch(R){Yt(p,l,R)}break;case 18:pn!==null&&(mr?(i=pn,YS(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,p.stateNode),Xo(i)):YS(pn,p.stateNode));break;case 4:y=pn,N=mr,pn=p.stateNode.containerInfo,mr=!0,ti(i,l,p),pn=y,mr=N;break;case 0:case 11:case 14:case 15:Ii(2,p,l),Dn||Ii(4,p,l),ti(i,l,p);break;case 1:Dn||(ks(p,l),y=p.stateNode,typeof y.componentWillUnmount=="function"&&X0(p,l,y)),ti(i,l,p);break;case 21:ti(i,l,p);break;case 22:Dn=(y=Dn)||p.memoizedState!==null,ti(i,l,p),Dn=y;break;default:ti(i,l,p)}}function sS(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Xo(i)}catch(p){Yt(l,l.return,p)}}}function iS(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Xo(i)}catch(p){Yt(l,l.return,p)}}function oR(i){switch(i.tag){case 31:case 13:case 19:var l=i.stateNode;return l===null&&(l=i.stateNode=new eS),l;case 22:return i=i.stateNode,l=i._retryCache,l===null&&(l=i._retryCache=new eS),l;default:throw Error(r(435,i.tag))}}function kd(i,l){var p=oR(i);l.forEach(function(y){if(!p.has(y)){p.add(y);var N=gR.bind(null,i,y);y.then(N,N)}})}function pr(i,l){var p=l.deletions;if(p!==null)for(var y=0;y<p.length;y++){var N=p[y],R=i,W=l,ee=W;e:for(;ee!==null;){switch(ee.tag){case 27:if(zi(ee.type)){pn=ee.stateNode,mr=!1;break e}break;case 5:pn=ee.stateNode,mr=!1;break e;case 3:case 4:pn=ee.stateNode.containerInfo,mr=!0;break e}ee=ee.return}if(pn===null)throw Error(r(160));rS(R,W,N),pn=null,mr=!1,R=N.alternate,R!==null&&(R.return=null),N.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)aS(l,i),l=l.sibling}var ls=null;function aS(i,l){var p=i.alternate,y=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:pr(l,i),gr(i),y&4&&(Ii(3,i,i.return),pc(3,i),Ii(5,i,i.return));break;case 1:pr(l,i),gr(i),y&512&&(Dn||p===null||ks(p,p.return)),y&64&&ei&&(i=i.updateQueue,i!==null&&(y=i.callbacks,y!==null&&(p=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=p===null?y:p.concat(y))));break;case 26:var N=ls;if(pr(l,i),gr(i),y&512&&(Dn||p===null||ks(p,p.return)),y&4){var R=p!==null?p.memoizedState:null;if(y=i.memoizedState,p===null)if(y===null)if(i.stateNode===null){e:{y=i.type,p=i.memoizedProps,N=N.ownerDocument||N;t:switch(y){case"title":R=N.getElementsByTagName("title")[0],(!R||R[Tn]||R[He]||R.namespaceURI==="http://www.w3.org/2000/svg"||R.hasAttribute("itemprop"))&&(R=N.createElement(y),N.head.insertBefore(R,N.querySelector("head > title"))),Qn(R,y,p),R[He]=i,zn(R),y=R;break e;case"link":var W=aw("link","href",N).get(y+(p.href||""));if(W){for(var ee=0;ee<W.length;ee++)if(R=W[ee],R.getAttribute("href")===(p.href==null||p.href===""?null:p.href)&&R.getAttribute("rel")===(p.rel==null?null:p.rel)&&R.getAttribute("title")===(p.title==null?null:p.title)&&R.getAttribute("crossorigin")===(p.crossOrigin==null?null:p.crossOrigin)){W.splice(ee,1);break t}}R=N.createElement(y),Qn(R,y,p),N.head.appendChild(R);break;case"meta":if(W=aw("meta","content",N).get(y+(p.content||""))){for(ee=0;ee<W.length;ee++)if(R=W[ee],R.getAttribute("content")===(p.content==null?null:""+p.content)&&R.getAttribute("name")===(p.name==null?null:p.name)&&R.getAttribute("property")===(p.property==null?null:p.property)&&R.getAttribute("http-equiv")===(p.httpEquiv==null?null:p.httpEquiv)&&R.getAttribute("charset")===(p.charSet==null?null:p.charSet)){W.splice(ee,1);break t}}R=N.createElement(y),Qn(R,y,p),N.head.appendChild(R);break;default:throw Error(r(468,y))}R[He]=i,zn(R),y=R}i.stateNode=y}else ow(N,i.type,i.stateNode);else i.stateNode=iw(N,y,i.memoizedProps);else R!==y?(R===null?p.stateNode!==null&&(p=p.stateNode,p.parentNode.removeChild(p)):R.count--,y===null?ow(N,i.type,i.stateNode):iw(N,y,i.memoizedProps)):y===null&&i.stateNode!==null&&zp(i,i.memoizedProps,p.memoizedProps)}break;case 27:pr(l,i),gr(i),y&512&&(Dn||p===null||ks(p,p.return)),p!==null&&y&4&&zp(i,i.memoizedProps,p.memoizedProps);break;case 5:if(pr(l,i),gr(i),y&512&&(Dn||p===null||ks(p,p.return)),i.flags&32){N=i.stateNode;try{bo(N,"")}catch(at){Yt(i,i.return,at)}}y&4&&i.stateNode!=null&&(N=i.memoizedProps,zp(i,N,p!==null?p.memoizedProps:N)),y&1024&&(Wp=!0);break;case 6:if(pr(l,i),gr(i),y&4){if(i.stateNode===null)throw Error(r(162));y=i.memoizedProps,p=i.stateNode;try{p.nodeValue=y}catch(at){Yt(i,i.return,at)}}break;case 3:if(Hd=null,N=ls,ls=$d(l.containerInfo),pr(l,i),ls=N,gr(i),y&4&&p!==null&&p.memoizedState.isDehydrated)try{Xo(l.containerInfo)}catch(at){Yt(i,i.return,at)}Wp&&(Wp=!1,oS(i));break;case 4:y=ls,ls=$d(i.stateNode.containerInfo),pr(l,i),gr(i),ls=y;break;case 12:pr(l,i),gr(i);break;case 31:pr(l,i),gr(i),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,kd(i,y)));break;case 13:pr(l,i),gr(i),i.child.flags&8192&&i.memoizedState!==null!=(p!==null&&p.memoizedState!==null)&&(Ed=Pe()),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,kd(i,y)));break;case 22:N=i.memoizedState!==null;var oe=p!==null&&p.memoizedState!==null,be=ei,Me=Dn;if(ei=be||N,Dn=Me||oe,pr(l,i),Dn=Me,ei=be,gr(i),y&8192)e:for(l=i.stateNode,l._visibility=N?l._visibility&-2:l._visibility|1,N&&(p===null||oe||ei||Dn||La(i)),p=null,l=i;;){if(l.tag===5||l.tag===26){if(p===null){oe=p=l;try{if(R=oe.stateNode,N)W=R.style,typeof W.setProperty=="function"?W.setProperty("display","none","important"):W.display="none";else{ee=oe.stateNode;var ze=oe.memoizedProps.style,we=ze!=null&&ze.hasOwnProperty("display")?ze.display:null;ee.style.display=we==null||typeof we=="boolean"?"":(""+we).trim()}}catch(at){Yt(oe,oe.return,at)}}}else if(l.tag===6){if(p===null){oe=l;try{oe.stateNode.nodeValue=N?"":oe.memoizedProps}catch(at){Yt(oe,oe.return,at)}}}else if(l.tag===18){if(p===null){oe=l;try{var je=oe.stateNode;N?XS(je,!0):XS(oe.stateNode,!1)}catch(at){Yt(oe,oe.return,at)}}}else if((l.tag!==22&&l.tag!==23||l.memoizedState===null||l===i)&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break e;for(;l.sibling===null;){if(l.return===null||l.return===i)break e;p===l&&(p=null),l=l.return}p===l&&(p=null),l.sibling.return=l.return,l=l.sibling}y&4&&(y=i.updateQueue,y!==null&&(p=y.retryQueue,p!==null&&(y.retryQueue=null,kd(i,p))));break;case 19:pr(l,i),gr(i),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,kd(i,y)));break;case 30:break;case 21:break;default:pr(l,i),gr(i)}}function gr(i){var l=i.flags;if(l&2){try{for(var p,y=i.return;y!==null;){if(J0(y)){p=y;break}y=y.return}if(p==null)throw Error(r(160));switch(p.tag){case 27:var N=p.stateNode,R=Up(i);Cd(i,R,N);break;case 5:var W=p.stateNode;p.flags&32&&(bo(W,""),p.flags&=-33);var ee=Up(i);Cd(i,ee,W);break;case 3:case 4:var oe=p.stateNode.containerInfo,be=Up(i);Vp(i,be,oe);break;default:throw Error(r(161))}}catch(Me){Yt(i,i.return,Me)}i.flags&=-3}l&4096&&(i.flags&=-4097)}function oS(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var l=i;oS(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),i=i.sibling}}function ni(i,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)tS(i,l.alternate,l),l=l.sibling}function La(i){for(i=i.child;i!==null;){var l=i;switch(l.tag){case 0:case 11:case 14:case 15:Ii(4,l,l.return),La(l);break;case 1:ks(l,l.return);var p=l.stateNode;typeof p.componentWillUnmount=="function"&&X0(l,l.return,p),La(l);break;case 27:kc(l.stateNode);case 26:case 5:ks(l,l.return),La(l);break;case 22:l.memoizedState===null&&La(l);break;case 30:La(l);break;default:La(l)}i=i.sibling}}function ri(i,l,p){for(p=p&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var y=l.alternate,N=i,R=l,W=R.flags;switch(R.tag){case 0:case 11:case 15:ri(N,R,p),pc(4,R);break;case 1:if(ri(N,R,p),y=R,N=y.stateNode,typeof N.componentDidMount=="function")try{N.componentDidMount()}catch(be){Yt(y,y.return,be)}if(y=R,N=y.updateQueue,N!==null){var ee=y.stateNode;try{var oe=N.shared.hiddenCallbacks;if(oe!==null)for(N.shared.hiddenCallbacks=null,N=0;N<oe.length;N++)B_(oe[N],ee)}catch(be){Yt(y,y.return,be)}}p&&W&64&&Y0(R),gc(R,R.return);break;case 27:Z0(R);case 26:case 5:ri(N,R,p),p&&y===null&&W&4&&Q0(R),gc(R,R.return);break;case 12:ri(N,R,p);break;case 31:ri(N,R,p),p&&W&4&&sS(N,R);break;case 13:ri(N,R,p),p&&W&4&&iS(N,R);break;case 22:R.memoizedState===null&&ri(N,R,p),gc(R,R.return);break;case 30:break;default:ri(N,R,p)}l=l.sibling}}function Gp(i,l){var p=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(p=i.memoizedState.cachePool.pool),i=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(i=l.memoizedState.cachePool.pool),i!==p&&(i!=null&&i.refCount++,p!=null&&nc(p))}function qp(i,l){i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&nc(i))}function cs(i,l,p,y){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)lS(i,l,p,y),l=l.sibling}function lS(i,l,p,y){var N=l.flags;switch(l.tag){case 0:case 11:case 15:cs(i,l,p,y),N&2048&&pc(9,l);break;case 1:cs(i,l,p,y);break;case 3:cs(i,l,p,y),N&2048&&(i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&nc(i)));break;case 12:if(N&2048){cs(i,l,p,y),i=l.stateNode;try{var R=l.memoizedProps,W=R.id,ee=R.onPostCommit;typeof ee=="function"&&ee(W,l.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(oe){Yt(l,l.return,oe)}}else cs(i,l,p,y);break;case 31:cs(i,l,p,y);break;case 13:cs(i,l,p,y);break;case 23:break;case 22:R=l.stateNode,W=l.alternate,l.memoizedState!==null?R._visibility&2?cs(i,l,p,y):xc(i,l):R._visibility&2?cs(i,l,p,y):(R._visibility|=2,$o(i,l,p,y,(l.subtreeFlags&10256)!==0||!1)),N&2048&&Gp(W,l);break;case 24:cs(i,l,p,y),N&2048&&qp(l.alternate,l);break;default:cs(i,l,p,y)}}function $o(i,l,p,y,N){for(N=N&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var R=i,W=l,ee=p,oe=y,be=W.flags;switch(W.tag){case 0:case 11:case 15:$o(R,W,ee,oe,N),pc(8,W);break;case 23:break;case 22:var Me=W.stateNode;W.memoizedState!==null?Me._visibility&2?$o(R,W,ee,oe,N):xc(R,W):(Me._visibility|=2,$o(R,W,ee,oe,N)),N&&be&2048&&Gp(W.alternate,W);break;case 24:$o(R,W,ee,oe,N),N&&be&2048&&qp(W.alternate,W);break;default:$o(R,W,ee,oe,N)}l=l.sibling}}function xc(i,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var p=i,y=l,N=y.flags;switch(y.tag){case 22:xc(p,y),N&2048&&Gp(y.alternate,y);break;case 24:xc(p,y),N&2048&&qp(y.alternate,y);break;default:xc(p,y)}l=l.sibling}}var yc=8192;function Fo(i,l,p){if(i.subtreeFlags&yc)for(i=i.child;i!==null;)cS(i,l,p),i=i.sibling}function cS(i,l,p){switch(i.tag){case 26:Fo(i,l,p),i.flags&yc&&i.memoizedState!==null&&qR(p,ls,i.memoizedState,i.memoizedProps);break;case 5:Fo(i,l,p);break;case 3:case 4:var y=ls;ls=$d(i.stateNode.containerInfo),Fo(i,l,p),ls=y;break;case 22:i.memoizedState===null&&(y=i.alternate,y!==null&&y.memoizedState!==null?(y=yc,yc=16777216,Fo(i,l,p),yc=y):Fo(i,l,p));break;default:Fo(i,l,p)}}function uS(i){var l=i.alternate;if(l!==null&&(i=l.child,i!==null)){l.child=null;do l=i.sibling,i.sibling=null,i=l;while(i!==null)}}function bc(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var p=0;p<l.length;p++){var y=l[p];Un=y,hS(y,i)}uS(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)dS(i),i=i.sibling}function dS(i){switch(i.tag){case 0:case 11:case 15:bc(i),i.flags&2048&&Ii(9,i,i.return);break;case 3:bc(i);break;case 12:bc(i);break;case 22:var l=i.stateNode;i.memoizedState!==null&&l._visibility&2&&(i.return===null||i.return.tag!==13)?(l._visibility&=-3,jd(i)):bc(i);break;default:bc(i)}}function jd(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var p=0;p<l.length;p++){var y=l[p];Un=y,hS(y,i)}uS(i)}for(i=i.child;i!==null;){switch(l=i,l.tag){case 0:case 11:case 15:Ii(8,l,l.return),jd(l);break;case 22:p=l.stateNode,p._visibility&2&&(p._visibility&=-3,jd(l));break;default:jd(l)}i=i.sibling}}function hS(i,l){for(;Un!==null;){var p=Un;switch(p.tag){case 0:case 11:case 15:Ii(8,p,l);break;case 23:case 22:if(p.memoizedState!==null&&p.memoizedState.cachePool!==null){var y=p.memoizedState.cachePool.pool;y!=null&&y.refCount++}break;case 24:nc(p.memoizedState.cache)}if(y=p.child,y!==null)y.return=p,Un=y;else e:for(p=i;Un!==null;){y=Un;var N=y.sibling,R=y.return;if(nS(y),y===p){Un=null;break e}if(N!==null){N.return=R,Un=N;break e}Un=R}}}var lR={getCacheForType:function(i){var l=Yn(An),p=l.data.get(i);return p===void 0&&(p=i(),l.data.set(i,p)),p},cacheSignal:function(){return Yn(An).controller.signal}},cR=typeof WeakMap=="function"?WeakMap:Map,Ut=0,tn=null,Nt=null,Rt=0,Kt=0,Rr=null,Mi=!1,Ho=!1,Kp=!1,si=0,Sn=0,Pi=0,Ra=0,Yp=0,Dr=0,zo=0,vc=null,xr=null,Xp=!1,Ed=0,fS=0,Nd=1/0,Td=null,Bi=null,Bn=0,$i=null,Uo=null,ii=0,Qp=0,Jp=null,mS=null,_c=0,Zp=null;function Or(){return(Ut&2)!==0&&Rt!==0?Rt&-Rt:V.T!==null?ig():It()}function pS(){if(Dr===0)if((Rt&536870912)===0||Ot){var i=tt;tt<<=1,(tt&3932160)===0&&(tt=262144),Dr=i}else Dr=536870912;return i=Ar.current,i!==null&&(i.flags|=32),Dr}function yr(i,l,p){(i===tn&&(Kt===2||Kt===9)||i.cancelPendingCommit!==null)&&(Vo(i,0),Fi(i,Rt,Dr,!1)),ve(i,p),((Ut&2)===0||i!==tn)&&(i===tn&&((Ut&2)===0&&(Ra|=p),Sn===4&&Fi(i,Rt,Dr,!1)),js(i))}function gS(i,l,p){if((Ut&6)!==0)throw Error(r(327));var y=!p&&(l&127)===0&&(l&i.expiredLanes)===0||bn(i,l),N=y?hR(i,l):tg(i,l,!0),R=y;do{if(N===0){Ho&&!y&&Fi(i,l,0,!1);break}else{if(p=i.current.alternate,R&&!uR(p)){N=tg(i,l,!1),R=!1;continue}if(N===2){if(R=l,i.errorRecoveryDisabledLanes&R)var W=0;else W=i.pendingLanes&-536870913,W=W!==0?W:W&536870912?536870912:0;if(W!==0){l=W;e:{var ee=i;N=vc;var oe=ee.current.memoizedState.isDehydrated;if(oe&&(Vo(ee,W).flags|=256),W=tg(ee,W,!1),W!==2){if(Kp&&!oe){ee.errorRecoveryDisabledLanes|=R,Ra|=R,N=4;break e}R=xr,xr=N,R!==null&&(xr===null?xr=R:xr.push.apply(xr,R))}N=W}if(R=!1,N!==2)continue}}if(N===1){Vo(i,0),Fi(i,l,0,!0);break}e:{switch(y=i,R=N,R){case 0:case 1:throw Error(r(345));case 4:if((l&4194048)!==l)break;case 6:Fi(y,l,Dr,!Mi);break e;case 2:xr=null;break;case 3:case 5:break;default:throw Error(r(329))}if((l&62914560)===l&&(N=Ed+300-Pe(),10<N)){if(Fi(y,l,Dr,!Mi),qt(y,0,!0)!==0)break e;ii=l,y.timeoutHandle=qS(xS.bind(null,y,p,xr,Td,Xp,l,Dr,Ra,zo,Mi,R,"Throttled",-0,0),N);break e}xS(y,p,xr,Td,Xp,l,Dr,Ra,zo,Mi,R,null,-0,0)}}break}while(!0);js(i)}function xS(i,l,p,y,N,R,W,ee,oe,be,Me,ze,we,je){if(i.timeoutHandle=-1,ze=l.subtreeFlags,ze&8192||(ze&16785408)===16785408){ze={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Vs},cS(l,R,ze);var at=(R&62914560)===R?Ed-Pe():(R&4194048)===R?fS-Pe():0;if(at=KR(ze,at),at!==null){ii=R,i.cancelPendingCommit=at(kS.bind(null,i,l,R,p,y,N,W,ee,oe,Me,ze,null,we,je)),Fi(i,R,W,!be);return}}kS(i,l,R,p,y,N,W,ee,oe)}function uR(i){for(var l=i;;){var p=l.tag;if((p===0||p===11||p===15)&&l.flags&16384&&(p=l.updateQueue,p!==null&&(p=p.stores,p!==null)))for(var y=0;y<p.length;y++){var N=p[y],R=N.getSnapshot;N=N.value;try{if(!Nr(R(),N))return!1}catch{return!1}}if(p=l.child,l.subtreeFlags&16384&&p!==null)p.return=l,l=p;else{if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Fi(i,l,p,y){l&=~Yp,l&=~Ra,i.suspendedLanes|=l,i.pingedLanes&=~l,y&&(i.warmLanes|=l),y=i.expirationTimes;for(var N=l;0<N;){var R=31-Re(N),W=1<<R;y[R]=-1,N&=~W}p!==0&&Qe(i,p,l)}function Ad(){return(Ut&6)===0?(Sc(0),!1):!0}function eg(){if(Nt!==null){if(Kt===0)var i=Nt.return;else i=Nt,Ks=wa=null,gp(i),Oo=null,sc=0,i=Nt;for(;i!==null;)K0(i.alternate,i),i=i.return;Nt=null}}function Vo(i,l){var p=i.timeoutHandle;p!==-1&&(i.timeoutHandle=-1,AR(p)),p=i.cancelPendingCommit,p!==null&&(i.cancelPendingCommit=null,p()),ii=0,eg(),tn=i,Nt=p=Gs(i.current,null),Rt=l,Kt=0,Rr=null,Mi=!1,Ho=bn(i,l),Kp=!1,zo=Dr=Yp=Ra=Pi=Sn=0,xr=vc=null,Xp=!1,(l&8)!==0&&(l|=l&32);var y=i.entangledLanes;if(y!==0)for(i=i.entanglements,y&=l;0<y;){var N=31-Re(y),R=1<<N;l|=i[N],y&=~R}return si=l,Qu(),p}function yS(i,l){Ct=null,V.H=hc,l===Do||l===id?(l=O_(),Kt=3):l===sp?(l=O_(),Kt=4):Kt=l===Rp?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,Rr=l,Nt===null&&(Sn=1,bd(i,Gr(l,i.current)))}function bS(){var i=Ar.current;return i===null?!0:(Rt&4194048)===Rt?Xr===null:(Rt&62914560)===Rt||(Rt&536870912)!==0?i===Xr:!1}function vS(){var i=V.H;return V.H=hc,i===null?hc:i}function _S(){var i=V.A;return V.A=lR,i}function Ld(){Sn=4,Mi||(Rt&4194048)!==Rt&&Ar.current!==null||(Ho=!0),(Pi&134217727)===0&&(Ra&134217727)===0||tn===null||Fi(tn,Rt,Dr,!1)}function tg(i,l,p){var y=Ut;Ut|=2;var N=vS(),R=_S();(tn!==i||Rt!==l)&&(Td=null,Vo(i,l)),l=!1;var W=Sn;e:do try{if(Kt!==0&&Nt!==null){var ee=Nt,oe=Rr;switch(Kt){case 8:eg(),W=6;break e;case 3:case 2:case 9:case 6:Ar.current===null&&(l=!0);var be=Kt;if(Kt=0,Rr=null,Wo(i,ee,oe,be),p&&Ho){W=0;break e}break;default:be=Kt,Kt=0,Rr=null,Wo(i,ee,oe,be)}}dR(),W=Sn;break}catch(Me){yS(i,Me)}while(!0);return l&&i.shellSuspendCounter++,Ks=wa=null,Ut=y,V.H=N,V.A=R,Nt===null&&(tn=null,Rt=0,Qu()),W}function dR(){for(;Nt!==null;)SS(Nt)}function hR(i,l){var p=Ut;Ut|=2;var y=vS(),N=_S();tn!==i||Rt!==l?(Td=null,Nd=Pe()+500,Vo(i,l)):Ho=bn(i,l);e:do try{if(Kt!==0&&Nt!==null){l=Nt;var R=Rr;t:switch(Kt){case 1:Kt=0,Rr=null,Wo(i,l,R,1);break;case 2:case 9:if(R_(R)){Kt=0,Rr=null,wS(l);break}l=function(){Kt!==2&&Kt!==9||tn!==i||(Kt=7),js(i)},R.then(l,l);break e;case 3:Kt=7;break e;case 4:Kt=5;break e;case 7:R_(R)?(Kt=0,Rr=null,wS(l)):(Kt=0,Rr=null,Wo(i,l,R,7));break;case 5:var W=null;switch(Nt.tag){case 26:W=Nt.memoizedState;case 5:case 27:var ee=Nt;if(W?lw(W):ee.stateNode.complete){Kt=0,Rr=null;var oe=ee.sibling;if(oe!==null)Nt=oe;else{var be=ee.return;be!==null?(Nt=be,Rd(be)):Nt=null}break t}}Kt=0,Rr=null,Wo(i,l,R,5);break;case 6:Kt=0,Rr=null,Wo(i,l,R,6);break;case 8:eg(),Sn=6;break e;default:throw Error(r(462))}}fR();break}catch(Me){yS(i,Me)}while(!0);return Ks=wa=null,V.H=y,V.A=N,Ut=p,Nt!==null?0:(tn=null,Rt=0,Qu(),Sn)}function fR(){for(;Nt!==null&&!he();)SS(Nt)}function SS(i){var l=G0(i.alternate,i,si);i.memoizedProps=i.pendingProps,l===null?Rd(i):Nt=l}function wS(i){var l=i,p=l.alternate;switch(l.tag){case 15:case 0:l=F0(p,l,l.pendingProps,l.type,void 0,Rt);break;case 11:l=F0(p,l,l.pendingProps,l.type.render,l.ref,Rt);break;case 5:gp(l);default:K0(p,l),l=Nt=__(l,si),l=G0(p,l,si)}i.memoizedProps=i.pendingProps,l===null?Rd(i):Nt=l}function Wo(i,l,p,y){Ks=wa=null,gp(l),Oo=null,sc=0;var N=l.return;try{if(tR(i,N,l,p,Rt)){Sn=1,bd(i,Gr(p,i.current)),Nt=null;return}}catch(R){if(N!==null)throw Nt=N,R;Sn=1,bd(i,Gr(p,i.current)),Nt=null;return}l.flags&32768?(Ot||y===1?i=!0:Ho||(Rt&536870912)!==0?i=!1:(Mi=i=!0,(y===2||y===9||y===3||y===6)&&(y=Ar.current,y!==null&&y.tag===13&&(y.flags|=16384))),CS(l,i)):Rd(l)}function Rd(i){var l=i;do{if((l.flags&32768)!==0){CS(l,Mi);return}i=l.return;var p=sR(l.alternate,l,si);if(p!==null){Nt=p;return}if(l=l.sibling,l!==null){Nt=l;return}Nt=l=i}while(l!==null);Sn===0&&(Sn=5)}function CS(i,l){do{var p=iR(i.alternate,i);if(p!==null){p.flags&=32767,Nt=p;return}if(p=i.return,p!==null&&(p.flags|=32768,p.subtreeFlags=0,p.deletions=null),!l&&(i=i.sibling,i!==null)){Nt=i;return}Nt=i=p}while(i!==null);Sn=6,Nt=null}function kS(i,l,p,y,N,R,W,ee,oe){i.cancelPendingCommit=null;do Dd();while(Bn!==0);if((Ut&6)!==0)throw Error(r(327));if(l!==null){if(l===i.current)throw Error(r(177));if(R=l.lanes|l.childLanes,R|=Um,rt(i,p,R,W,ee,oe),i===tn&&(Nt=tn=null,Rt=0),Uo=l,$i=i,ii=p,Qp=R,Jp=N,mS=y,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,xR(ue,function(){return AS(),null})):(i.callbackNode=null,i.callbackPriority=0),y=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||y){y=V.T,V.T=null,N=Z.p,Z.p=2,W=Ut,Ut|=4;try{aR(i,l,p)}finally{Ut=W,Z.p=N,V.T=y}}Bn=1,jS(),ES(),NS()}}function jS(){if(Bn===1){Bn=0;var i=$i,l=Uo,p=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||p){p=V.T,V.T=null;var y=Z.p;Z.p=2;var N=Ut;Ut|=4;try{aS(l,i);var R=fg,W=h_(i.containerInfo),ee=R.focusedElem,oe=R.selectionRange;if(W!==ee&&ee&&ee.ownerDocument&&d_(ee.ownerDocument.documentElement,ee)){if(oe!==null&&Bm(ee)){var be=oe.start,Me=oe.end;if(Me===void 0&&(Me=be),"selectionStart"in ee)ee.selectionStart=be,ee.selectionEnd=Math.min(Me,ee.value.length);else{var ze=ee.ownerDocument||document,we=ze&&ze.defaultView||window;if(we.getSelection){var je=we.getSelection(),at=ee.textContent.length,mt=Math.min(oe.start,at),Jt=oe.end===void 0?mt:Math.min(oe.end,at);!je.extend&&mt>Jt&&(W=Jt,Jt=mt,mt=W);var fe=u_(ee,mt),ce=u_(ee,Jt);if(fe&&ce&&(je.rangeCount!==1||je.anchorNode!==fe.node||je.anchorOffset!==fe.offset||je.focusNode!==ce.node||je.focusOffset!==ce.offset)){var xe=ze.createRange();xe.setStart(fe.node,fe.offset),je.removeAllRanges(),mt>Jt?(je.addRange(xe),je.extend(ce.node,ce.offset)):(xe.setEnd(ce.node,ce.offset),je.addRange(xe))}}}}for(ze=[],je=ee;je=je.parentNode;)je.nodeType===1&&ze.push({element:je,left:je.scrollLeft,top:je.scrollTop});for(typeof ee.focus=="function"&&ee.focus(),ee=0;ee<ze.length;ee++){var Be=ze[ee];Be.element.scrollLeft=Be.left,Be.element.scrollTop=Be.top}}Wd=!!hg,fg=hg=null}finally{Ut=N,Z.p=y,V.T=p}}i.current=l,Bn=2}}function ES(){if(Bn===2){Bn=0;var i=$i,l=Uo,p=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||p){p=V.T,V.T=null;var y=Z.p;Z.p=2;var N=Ut;Ut|=4;try{tS(i,l.alternate,l)}finally{Ut=N,Z.p=y,V.T=p}}Bn=3}}function NS(){if(Bn===4||Bn===3){Bn=0,ae();var i=$i,l=Uo,p=ii,y=mS;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?Bn=5:(Bn=0,Uo=$i=null,TS(i,i.pendingLanes));var N=i.pendingLanes;if(N===0&&(Bi=null),xt(p),l=l.stateNode,gt&&typeof gt.onCommitFiberRoot=="function")try{gt.onCommitFiberRoot(lt,l,void 0,(l.current.flags&128)===128)}catch{}if(y!==null){l=V.T,N=Z.p,Z.p=2,V.T=null;try{for(var R=i.onRecoverableError,W=0;W<y.length;W++){var ee=y[W];R(ee.value,{componentStack:ee.stack})}}finally{V.T=l,Z.p=N}}(ii&3)!==0&&Dd(),js(i),N=i.pendingLanes,(p&261930)!==0&&(N&42)!==0?i===Zp?_c++:(_c=0,Zp=i):_c=0,Sc(0)}}function TS(i,l){(i.pooledCacheLanes&=l)===0&&(l=i.pooledCache,l!=null&&(i.pooledCache=null,nc(l)))}function Dd(){return jS(),ES(),NS(),AS()}function AS(){if(Bn!==5)return!1;var i=$i,l=Qp;Qp=0;var p=xt(ii),y=V.T,N=Z.p;try{Z.p=32>p?32:p,V.T=null,p=Jp,Jp=null;var R=$i,W=ii;if(Bn=0,Uo=$i=null,ii=0,(Ut&6)!==0)throw Error(r(331));var ee=Ut;if(Ut|=4,dS(R.current),lS(R,R.current,W,p),Ut=ee,Sc(0,!1),gt&&typeof gt.onPostCommitFiberRoot=="function")try{gt.onPostCommitFiberRoot(lt,R)}catch{}return!0}finally{Z.p=N,V.T=y,TS(i,l)}}function LS(i,l,p){l=Gr(p,l),l=Lp(i.stateNode,l,2),i=Ri(i,l,2),i!==null&&(ve(i,2),js(i))}function Yt(i,l,p){if(i.tag===3)LS(i,i,p);else for(;l!==null;){if(l.tag===3){LS(l,i,p);break}else if(l.tag===1){var y=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&(Bi===null||!Bi.has(y))){i=Gr(p,i),p=R0(2),y=Ri(l,p,2),y!==null&&(D0(p,y,l,i),ve(y,2),js(y));break}}l=l.return}}function ng(i,l,p){var y=i.pingCache;if(y===null){y=i.pingCache=new cR;var N=new Set;y.set(l,N)}else N=y.get(l),N===void 0&&(N=new Set,y.set(l,N));N.has(p)||(Kp=!0,N.add(p),i=mR.bind(null,i,l,p),l.then(i,i))}function mR(i,l,p){var y=i.pingCache;y!==null&&y.delete(l),i.pingedLanes|=i.suspendedLanes&p,i.warmLanes&=~p,tn===i&&(Rt&p)===p&&(Sn===4||Sn===3&&(Rt&62914560)===Rt&&300>Pe()-Ed?(Ut&2)===0&&Vo(i,0):Yp|=p,zo===Rt&&(zo=0)),js(i)}function RS(i,l){l===0&&(l=xn()),i=va(i,l),i!==null&&(ve(i,l),js(i))}function pR(i){var l=i.memoizedState,p=0;l!==null&&(p=l.retryLane),RS(i,p)}function gR(i,l){var p=0;switch(i.tag){case 31:case 13:var y=i.stateNode,N=i.memoizedState;N!==null&&(p=N.retryLane);break;case 19:y=i.stateNode;break;case 22:y=i.stateNode._retryCache;break;default:throw Error(r(314))}y!==null&&y.delete(l),RS(i,p)}function xR(i,l){return _e(i,l)}var Od=null,Go=null,rg=!1,Id=!1,sg=!1,Hi=0;function js(i){i!==Go&&i.next===null&&(Go===null?Od=Go=i:Go=Go.next=i),Id=!0,rg||(rg=!0,bR())}function Sc(i,l){if(!sg&&Id){sg=!0;do for(var p=!1,y=Od;y!==null;){if(i!==0){var N=y.pendingLanes;if(N===0)var R=0;else{var W=y.suspendedLanes,ee=y.pingedLanes;R=(1<<31-Re(42|i)+1)-1,R&=N&~(W&~ee),R=R&201326741?R&201326741|1:R?R|2:0}R!==0&&(p=!0,MS(y,R))}else R=Rt,R=qt(y,y===tn?R:0,y.cancelPendingCommit!==null||y.timeoutHandle!==-1),(R&3)===0||bn(y,R)||(p=!0,MS(y,R));y=y.next}while(p);sg=!1}}function yR(){DS()}function DS(){Id=rg=!1;var i=0;Hi!==0&&TR()&&(i=Hi);for(var l=Pe(),p=null,y=Od;y!==null;){var N=y.next,R=OS(y,l);R===0?(y.next=null,p===null?Od=N:p.next=N,N===null&&(Go=p)):(p=y,(i!==0||(R&3)!==0)&&(Id=!0)),y=N}Bn!==0&&Bn!==5||Sc(i),Hi!==0&&(Hi=0)}function OS(i,l){for(var p=i.suspendedLanes,y=i.pingedLanes,N=i.expirationTimes,R=i.pendingLanes&-62914561;0<R;){var W=31-Re(R),ee=1<<W,oe=N[W];oe===-1?((ee&p)===0||(ee&y)!==0)&&(N[W]=vn(ee,l)):oe<=l&&(i.expiredLanes|=ee),R&=~ee}if(l=tn,p=Rt,p=qt(i,i===l?p:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),y=i.callbackNode,p===0||i===l&&(Kt===2||Kt===9)||i.cancelPendingCommit!==null)return y!==null&&y!==null&&ge(y),i.callbackNode=null,i.callbackPriority=0;if((p&3)===0||bn(i,p)){if(l=p&-p,l===i.callbackPriority)return l;switch(y!==null&&ge(y),xt(p)){case 2:case 8:p=Ae;break;case 32:p=ue;break;case 268435456:p=Xe;break;default:p=ue}return y=IS.bind(null,i),p=_e(p,y),i.callbackPriority=l,i.callbackNode=p,l}return y!==null&&y!==null&&ge(y),i.callbackPriority=2,i.callbackNode=null,2}function IS(i,l){if(Bn!==0&&Bn!==5)return i.callbackNode=null,i.callbackPriority=0,null;var p=i.callbackNode;if(Dd()&&i.callbackNode!==p)return null;var y=Rt;return y=qt(i,i===tn?y:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),y===0?null:(gS(i,y,l),OS(i,Pe()),i.callbackNode!=null&&i.callbackNode===p?IS.bind(null,i):null)}function MS(i,l){if(Dd())return null;gS(i,l,!0)}function bR(){LR(function(){(Ut&6)!==0?_e(de,yR):DS()})}function ig(){if(Hi===0){var i=Lo;i===0&&(i=nt,nt<<=1,(nt&261888)===0&&(nt=256)),Hi=i}return Hi}function PS(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Uu(""+i)}function BS(i,l){var p=l.ownerDocument.createElement("input");return p.name=l.name,p.value=l.value,i.id&&p.setAttribute("form",i.id),l.parentNode.insertBefore(p,l),i=new FormData(i),p.parentNode.removeChild(p),i}function vR(i,l,p,y,N){if(l==="submit"&&p&&p.stateNode===N){var R=PS((N[et]||null).action),W=y.submitter;W&&(l=(l=W[et]||null)?PS(l.formAction):W.getAttribute("formAction"),l!==null&&(R=l,W=null));var ee=new qu("action","action",null,y,N);i.push({event:ee,listeners:[{instance:null,listener:function(){if(y.defaultPrevented){if(Hi!==0){var oe=W?BS(N,W):new FormData(N);kp(p,{pending:!0,data:oe,method:N.method,action:R},null,oe)}}else typeof R=="function"&&(ee.preventDefault(),oe=W?BS(N,W):new FormData(N),kp(p,{pending:!0,data:oe,method:N.method,action:R},R,oe))},currentTarget:N}]})}}for(var ag=0;ag<zm.length;ag++){var og=zm[ag],_R=og.toLowerCase(),SR=og[0].toUpperCase()+og.slice(1);os(_R,"on"+SR)}os(p_,"onAnimationEnd"),os(g_,"onAnimationIteration"),os(x_,"onAnimationStart"),os("dblclick","onDoubleClick"),os("focusin","onFocus"),os("focusout","onBlur"),os(BL,"onTransitionRun"),os($L,"onTransitionStart"),os(FL,"onTransitionCancel"),os(y_,"onTransitionEnd"),xo("onMouseEnter",["mouseout","mouseover"]),xo("onMouseLeave",["mouseout","mouseover"]),xo("onPointerEnter",["pointerout","pointerover"]),xo("onPointerLeave",["pointerout","pointerover"]),ga("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ga("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ga("onBeforeInput",["compositionend","keypress","textInput","paste"]),ga("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var wc="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(" "),wR=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(wc));function $S(i,l){l=(l&4)!==0;for(var p=0;p<i.length;p++){var y=i[p],N=y.event;y=y.listeners;e:{var R=void 0;if(l)for(var W=y.length-1;0<=W;W--){var ee=y[W],oe=ee.instance,be=ee.currentTarget;if(ee=ee.listener,oe!==R&&N.isPropagationStopped())break e;R=ee,N.currentTarget=be;try{R(N)}catch(Me){Xu(Me)}N.currentTarget=null,R=oe}else for(W=0;W<y.length;W++){if(ee=y[W],oe=ee.instance,be=ee.currentTarget,ee=ee.listener,oe!==R&&N.isPropagationStopped())break e;R=ee,N.currentTarget=be;try{R(N)}catch(Me){Xu(Me)}N.currentTarget=null,R=oe}}}}function Tt(i,l){var p=l[bt];p===void 0&&(p=l[bt]=new Set);var y=i+"__bubble";p.has(y)||(FS(l,i,2,!1),p.add(y))}function lg(i,l,p){var y=0;l&&(y|=4),FS(p,i,y,l)}var Md="_reactListening"+Math.random().toString(36).slice(2);function cg(i){if(!i[Md]){i[Md]=!0,Dv.forEach(function(p){p!=="selectionchange"&&(wR.has(p)||lg(p,!1,i),lg(p,!0,i))});var l=i.nodeType===9?i:i.ownerDocument;l===null||l[Md]||(l[Md]=!0,lg("selectionchange",!1,l))}}function FS(i,l,p,y){switch(pw(l)){case 2:var N=QR;break;case 8:N=JR;break;default:N=Cg}p=N.bind(null,l,p,i),N=void 0,!Tm||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(N=!0),y?N!==void 0?i.addEventListener(l,p,{capture:!0,passive:N}):i.addEventListener(l,p,!0):N!==void 0?i.addEventListener(l,p,{passive:N}):i.addEventListener(l,p,!1)}function ug(i,l,p,y,N){var R=y;if((l&1)===0&&(l&2)===0&&y!==null)e:for(;;){if(y===null)return;var W=y.tag;if(W===3||W===4){var ee=y.stateNode.containerInfo;if(ee===N)break;if(W===4)for(W=y.return;W!==null;){var oe=W.tag;if((oe===3||oe===4)&&W.stateNode.containerInfo===N)return;W=W.return}for(;ee!==null;){if(W=mo(ee),W===null)return;if(oe=W.tag,oe===5||oe===6||oe===26||oe===27){y=R=W;continue e}ee=ee.parentNode}}y=y.return}Wv(function(){var be=R,Me=Em(p),ze=[];e:{var we=b_.get(i);if(we!==void 0){var je=qu,at=i;switch(i){case"keypress":if(Wu(p)===0)break e;case"keydown":case"keyup":je=gL;break;case"focusin":at="focus",je=Dm;break;case"focusout":at="blur",je=Dm;break;case"beforeblur":case"afterblur":je=Dm;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=Kv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=sL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=bL;break;case p_:case g_:case x_:je=oL;break;case y_:je=_L;break;case"scroll":case"scrollend":je=nL;break;case"wheel":je=wL;break;case"copy":case"cut":case"paste":je=cL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=Xv;break;case"toggle":case"beforetoggle":je=kL}var mt=(l&4)!==0,Jt=!mt&&(i==="scroll"||i==="scrollend"),fe=mt?we!==null?we+"Capture":null:we;mt=[];for(var ce=be,xe;ce!==null;){var Be=ce;if(xe=Be.stateNode,Be=Be.tag,Be!==5&&Be!==26&&Be!==27||xe===null||fe===null||(Be=Wl(ce,fe),Be!=null&&mt.push(Cc(ce,Be,xe))),Jt)break;ce=ce.return}0<mt.length&&(we=new je(we,at,null,p,Me),ze.push({event:we,listeners:mt}))}}if((l&7)===0){e:{if(we=i==="mouseover"||i==="pointerover",je=i==="mouseout"||i==="pointerout",we&&p!==jm&&(at=p.relatedTarget||p.fromElement)&&(mo(at)||at[st]))break e;if((je||we)&&(we=Me.window===Me?Me:(we=Me.ownerDocument)?we.defaultView||we.parentWindow:window,je?(at=p.relatedTarget||p.toElement,je=be,at=at?mo(at):null,at!==null&&(Jt=o(at),mt=at.tag,at!==Jt||mt!==5&&mt!==27&&mt!==6)&&(at=null)):(je=null,at=be),je!==at)){if(mt=Kv,Be="onMouseLeave",fe="onMouseEnter",ce="mouse",(i==="pointerout"||i==="pointerover")&&(mt=Xv,Be="onPointerLeave",fe="onPointerEnter",ce="pointer"),Jt=je==null?we:Vl(je),xe=at==null?we:Vl(at),we=new mt(Be,ce+"leave",je,p,Me),we.target=Jt,we.relatedTarget=xe,Be=null,mo(Me)===be&&(mt=new mt(fe,ce+"enter",at,p,Me),mt.target=xe,mt.relatedTarget=Jt,Be=mt),Jt=Be,je&&at)t:{for(mt=CR,fe=je,ce=at,xe=0,Be=fe;Be;Be=mt(Be))xe++;Be=0;for(var ut=ce;ut;ut=mt(ut))Be++;for(;0<xe-Be;)fe=mt(fe),xe--;for(;0<Be-xe;)ce=mt(ce),Be--;for(;xe--;){if(fe===ce||ce!==null&&fe===ce.alternate){mt=fe;break t}fe=mt(fe),ce=mt(ce)}mt=null}else mt=null;je!==null&&HS(ze,we,je,mt,!1),at!==null&&Jt!==null&&HS(ze,Jt,at,mt,!0)}}e:{if(we=be?Vl(be):window,je=we.nodeName&&we.nodeName.toLowerCase(),je==="select"||je==="input"&&we.type==="file")var $t=s_;else if(n_(we))if(i_)$t=IL;else{$t=DL;var ct=RL}else je=we.nodeName,!je||je.toLowerCase()!=="input"||we.type!=="checkbox"&&we.type!=="radio"?be&&km(be.elementType)&&($t=s_):$t=OL;if($t&&($t=$t(i,be))){r_(ze,$t,p,Me);break e}ct&&ct(i,we,be),i==="focusout"&&be&&we.type==="number"&&be.memoizedProps.value!=null&&Cm(we,"number",we.value)}switch(ct=be?Vl(be):window,i){case"focusin":(n_(ct)||ct.contentEditable==="true")&&(wo=ct,$m=be,Zl=null);break;case"focusout":Zl=$m=wo=null;break;case"mousedown":Fm=!0;break;case"contextmenu":case"mouseup":case"dragend":Fm=!1,f_(ze,p,Me);break;case"selectionchange":if(PL)break;case"keydown":case"keyup":f_(ze,p,Me)}var kt;if(Im)e:{switch(i){case"compositionstart":var Dt="onCompositionStart";break e;case"compositionend":Dt="onCompositionEnd";break e;case"compositionupdate":Dt="onCompositionUpdate";break e}Dt=void 0}else So?e_(i,p)&&(Dt="onCompositionEnd"):i==="keydown"&&p.keyCode===229&&(Dt="onCompositionStart");Dt&&(Qv&&p.locale!=="ko"&&(So||Dt!=="onCompositionStart"?Dt==="onCompositionEnd"&&So&&(kt=Gv()):(ki=Me,Am="value"in ki?ki.value:ki.textContent,So=!0)),ct=Pd(be,Dt),0<ct.length&&(Dt=new Yv(Dt,i,null,p,Me),ze.push({event:Dt,listeners:ct}),kt?Dt.data=kt:(kt=t_(p),kt!==null&&(Dt.data=kt)))),(kt=EL?NL(i,p):TL(i,p))&&(Dt=Pd(be,"onBeforeInput"),0<Dt.length&&(ct=new Yv("onBeforeInput","beforeinput",null,p,Me),ze.push({event:ct,listeners:Dt}),ct.data=kt)),vR(ze,i,be,p,Me)}$S(ze,l)})}function Cc(i,l,p){return{instance:i,listener:l,currentTarget:p}}function Pd(i,l){for(var p=l+"Capture",y=[];i!==null;){var N=i,R=N.stateNode;if(N=N.tag,N!==5&&N!==26&&N!==27||R===null||(N=Wl(i,p),N!=null&&y.unshift(Cc(i,N,R)),N=Wl(i,l),N!=null&&y.push(Cc(i,N,R))),i.tag===3)return y;i=i.return}return[]}function CR(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function HS(i,l,p,y,N){for(var R=l._reactName,W=[];p!==null&&p!==y;){var ee=p,oe=ee.alternate,be=ee.stateNode;if(ee=ee.tag,oe!==null&&oe===y)break;ee!==5&&ee!==26&&ee!==27||be===null||(oe=be,N?(be=Wl(p,R),be!=null&&W.unshift(Cc(p,be,oe))):N||(be=Wl(p,R),be!=null&&W.push(Cc(p,be,oe)))),p=p.return}W.length!==0&&i.push({event:l,listeners:W})}var kR=/\r\n?/g,jR=/\u0000|\uFFFD/g;function zS(i){return(typeof i=="string"?i:""+i).replace(kR,`
|
|
50
|
+
`).replace(jR,"")}function US(i,l){return l=zS(l),zS(i)===l}function Qt(i,l,p,y,N,R){switch(p){case"children":typeof y=="string"?l==="body"||l==="textarea"&&y===""||bo(i,y):(typeof y=="number"||typeof y=="bigint")&&l!=="body"&&bo(i,""+y);break;case"className":Hu(i,"class",y);break;case"tabIndex":Hu(i,"tabindex",y);break;case"dir":case"role":case"viewBox":case"width":case"height":Hu(i,p,y);break;case"style":Uv(i,y,R);break;case"data":if(l!=="object"){Hu(i,"data",y);break}case"src":case"href":if(y===""&&(l!=="a"||p!=="href")){i.removeAttribute(p);break}if(y==null||typeof y=="function"||typeof y=="symbol"||typeof y=="boolean"){i.removeAttribute(p);break}y=Uu(""+y),i.setAttribute(p,y);break;case"action":case"formAction":if(typeof y=="function"){i.setAttribute(p,"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 R=="function"&&(p==="formAction"?(l!=="input"&&Qt(i,l,"name",N.name,N,null),Qt(i,l,"formEncType",N.formEncType,N,null),Qt(i,l,"formMethod",N.formMethod,N,null),Qt(i,l,"formTarget",N.formTarget,N,null)):(Qt(i,l,"encType",N.encType,N,null),Qt(i,l,"method",N.method,N,null),Qt(i,l,"target",N.target,N,null)));if(y==null||typeof y=="symbol"||typeof y=="boolean"){i.removeAttribute(p);break}y=Uu(""+y),i.setAttribute(p,y);break;case"onClick":y!=null&&(i.onclick=Vs);break;case"onScroll":y!=null&&Tt("scroll",i);break;case"onScrollEnd":y!=null&&Tt("scrollend",i);break;case"dangerouslySetInnerHTML":if(y!=null){if(typeof y!="object"||!("__html"in y))throw Error(r(61));if(p=y.__html,p!=null){if(N.children!=null)throw Error(r(60));i.innerHTML=p}}break;case"multiple":i.multiple=y&&typeof y!="function"&&typeof y!="symbol";break;case"muted":i.muted=y&&typeof y!="function"&&typeof y!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(y==null||typeof y=="function"||typeof y=="boolean"||typeof y=="symbol"){i.removeAttribute("xlink:href");break}p=Uu(""+y),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",p);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":y!=null&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(p,""+y):i.removeAttribute(p);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":y&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(p,""):i.removeAttribute(p);break;case"capture":case"download":y===!0?i.setAttribute(p,""):y!==!1&&y!=null&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(p,y):i.removeAttribute(p);break;case"cols":case"rows":case"size":case"span":y!=null&&typeof y!="function"&&typeof y!="symbol"&&!isNaN(y)&&1<=y?i.setAttribute(p,y):i.removeAttribute(p);break;case"rowSpan":case"start":y==null||typeof y=="function"||typeof y=="symbol"||isNaN(y)?i.removeAttribute(p):i.setAttribute(p,y);break;case"popover":Tt("beforetoggle",i),Tt("toggle",i),Fu(i,"popover",y);break;case"xlinkActuate":Us(i,"http://www.w3.org/1999/xlink","xlink:actuate",y);break;case"xlinkArcrole":Us(i,"http://www.w3.org/1999/xlink","xlink:arcrole",y);break;case"xlinkRole":Us(i,"http://www.w3.org/1999/xlink","xlink:role",y);break;case"xlinkShow":Us(i,"http://www.w3.org/1999/xlink","xlink:show",y);break;case"xlinkTitle":Us(i,"http://www.w3.org/1999/xlink","xlink:title",y);break;case"xlinkType":Us(i,"http://www.w3.org/1999/xlink","xlink:type",y);break;case"xmlBase":Us(i,"http://www.w3.org/XML/1998/namespace","xml:base",y);break;case"xmlLang":Us(i,"http://www.w3.org/XML/1998/namespace","xml:lang",y);break;case"xmlSpace":Us(i,"http://www.w3.org/XML/1998/namespace","xml:space",y);break;case"is":Fu(i,"is",y);break;case"innerText":case"textContent":break;default:(!(2<p.length)||p[0]!=="o"&&p[0]!=="O"||p[1]!=="n"&&p[1]!=="N")&&(p=eL.get(p)||p,Fu(i,p,y))}}function dg(i,l,p,y,N,R){switch(p){case"style":Uv(i,y,R);break;case"dangerouslySetInnerHTML":if(y!=null){if(typeof y!="object"||!("__html"in y))throw Error(r(61));if(p=y.__html,p!=null){if(N.children!=null)throw Error(r(60));i.innerHTML=p}}break;case"children":typeof y=="string"?bo(i,y):(typeof y=="number"||typeof y=="bigint")&&bo(i,""+y);break;case"onScroll":y!=null&&Tt("scroll",i);break;case"onScrollEnd":y!=null&&Tt("scrollend",i);break;case"onClick":y!=null&&(i.onclick=Vs);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ov.hasOwnProperty(p))e:{if(p[0]==="o"&&p[1]==="n"&&(N=p.endsWith("Capture"),l=p.slice(2,N?p.length-7:void 0),R=i[et]||null,R=R!=null?R[p]:null,typeof R=="function"&&i.removeEventListener(l,R,N),typeof y=="function")){typeof R!="function"&&R!==null&&(p in i?i[p]=null:i.hasAttribute(p)&&i.removeAttribute(p)),i.addEventListener(l,y,N);break e}p in i?i[p]=y:y===!0?i.setAttribute(p,""):Fu(i,p,y)}}}function Qn(i,l,p){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Tt("error",i),Tt("load",i);var y=!1,N=!1,R;for(R in p)if(p.hasOwnProperty(R)){var W=p[R];if(W!=null)switch(R){case"src":y=!0;break;case"srcSet":N=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,l));default:Qt(i,l,R,W,p,null)}}N&&Qt(i,l,"srcSet",p.srcSet,p,null),y&&Qt(i,l,"src",p.src,p,null);return;case"input":Tt("invalid",i);var ee=R=W=N=null,oe=null,be=null;for(y in p)if(p.hasOwnProperty(y)){var Me=p[y];if(Me!=null)switch(y){case"name":N=Me;break;case"type":W=Me;break;case"checked":oe=Me;break;case"defaultChecked":be=Me;break;case"value":R=Me;break;case"defaultValue":ee=Me;break;case"children":case"dangerouslySetInnerHTML":if(Me!=null)throw Error(r(137,l));break;default:Qt(i,l,y,Me,p,null)}}$v(i,R,ee,oe,be,W,N,!1);return;case"select":Tt("invalid",i),y=W=R=null;for(N in p)if(p.hasOwnProperty(N)&&(ee=p[N],ee!=null))switch(N){case"value":R=ee;break;case"defaultValue":W=ee;break;case"multiple":y=ee;default:Qt(i,l,N,ee,p,null)}l=R,p=W,i.multiple=!!y,l!=null?yo(i,!!y,l,!1):p!=null&&yo(i,!!y,p,!0);return;case"textarea":Tt("invalid",i),R=N=y=null;for(W in p)if(p.hasOwnProperty(W)&&(ee=p[W],ee!=null))switch(W){case"value":y=ee;break;case"defaultValue":N=ee;break;case"children":R=ee;break;case"dangerouslySetInnerHTML":if(ee!=null)throw Error(r(91));break;default:Qt(i,l,W,ee,p,null)}Hv(i,y,N,R);return;case"option":for(oe in p)if(p.hasOwnProperty(oe)&&(y=p[oe],y!=null))switch(oe){case"selected":i.selected=y&&typeof y!="function"&&typeof y!="symbol";break;default:Qt(i,l,oe,y,p,null)}return;case"dialog":Tt("beforetoggle",i),Tt("toggle",i),Tt("cancel",i),Tt("close",i);break;case"iframe":case"object":Tt("load",i);break;case"video":case"audio":for(y=0;y<wc.length;y++)Tt(wc[y],i);break;case"image":Tt("error",i),Tt("load",i);break;case"details":Tt("toggle",i);break;case"embed":case"source":case"link":Tt("error",i),Tt("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(be in p)if(p.hasOwnProperty(be)&&(y=p[be],y!=null))switch(be){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,l));default:Qt(i,l,be,y,p,null)}return;default:if(km(l)){for(Me in p)p.hasOwnProperty(Me)&&(y=p[Me],y!==void 0&&dg(i,l,Me,y,p,void 0));return}}for(ee in p)p.hasOwnProperty(ee)&&(y=p[ee],y!=null&&Qt(i,l,ee,y,p,null))}function ER(i,l,p,y){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var N=null,R=null,W=null,ee=null,oe=null,be=null,Me=null;for(je in p){var ze=p[je];if(p.hasOwnProperty(je)&&ze!=null)switch(je){case"checked":break;case"value":break;case"defaultValue":oe=ze;default:y.hasOwnProperty(je)||Qt(i,l,je,null,y,ze)}}for(var we in y){var je=y[we];if(ze=p[we],y.hasOwnProperty(we)&&(je!=null||ze!=null))switch(we){case"type":R=je;break;case"name":N=je;break;case"checked":be=je;break;case"defaultChecked":Me=je;break;case"value":W=je;break;case"defaultValue":ee=je;break;case"children":case"dangerouslySetInnerHTML":if(je!=null)throw Error(r(137,l));break;default:je!==ze&&Qt(i,l,we,je,y,ze)}}wm(i,W,ee,oe,be,Me,R,N);return;case"select":je=W=ee=we=null;for(R in p)if(oe=p[R],p.hasOwnProperty(R)&&oe!=null)switch(R){case"value":break;case"multiple":je=oe;default:y.hasOwnProperty(R)||Qt(i,l,R,null,y,oe)}for(N in y)if(R=y[N],oe=p[N],y.hasOwnProperty(N)&&(R!=null||oe!=null))switch(N){case"value":we=R;break;case"defaultValue":ee=R;break;case"multiple":W=R;default:R!==oe&&Qt(i,l,N,R,y,oe)}l=ee,p=W,y=je,we!=null?yo(i,!!p,we,!1):!!y!=!!p&&(l!=null?yo(i,!!p,l,!0):yo(i,!!p,p?[]:"",!1));return;case"textarea":je=we=null;for(ee in p)if(N=p[ee],p.hasOwnProperty(ee)&&N!=null&&!y.hasOwnProperty(ee))switch(ee){case"value":break;case"children":break;default:Qt(i,l,ee,null,y,N)}for(W in y)if(N=y[W],R=p[W],y.hasOwnProperty(W)&&(N!=null||R!=null))switch(W){case"value":we=N;break;case"defaultValue":je=N;break;case"children":break;case"dangerouslySetInnerHTML":if(N!=null)throw Error(r(91));break;default:N!==R&&Qt(i,l,W,N,y,R)}Fv(i,we,je);return;case"option":for(var at in p)if(we=p[at],p.hasOwnProperty(at)&&we!=null&&!y.hasOwnProperty(at))switch(at){case"selected":i.selected=!1;break;default:Qt(i,l,at,null,y,we)}for(oe in y)if(we=y[oe],je=p[oe],y.hasOwnProperty(oe)&&we!==je&&(we!=null||je!=null))switch(oe){case"selected":i.selected=we&&typeof we!="function"&&typeof we!="symbol";break;default:Qt(i,l,oe,we,y,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 mt in p)we=p[mt],p.hasOwnProperty(mt)&&we!=null&&!y.hasOwnProperty(mt)&&Qt(i,l,mt,null,y,we);for(be in y)if(we=y[be],je=p[be],y.hasOwnProperty(be)&&we!==je&&(we!=null||je!=null))switch(be){case"children":case"dangerouslySetInnerHTML":if(we!=null)throw Error(r(137,l));break;default:Qt(i,l,be,we,y,je)}return;default:if(km(l)){for(var Jt in p)we=p[Jt],p.hasOwnProperty(Jt)&&we!==void 0&&!y.hasOwnProperty(Jt)&&dg(i,l,Jt,void 0,y,we);for(Me in y)we=y[Me],je=p[Me],!y.hasOwnProperty(Me)||we===je||we===void 0&&je===void 0||dg(i,l,Me,we,y,je);return}}for(var fe in p)we=p[fe],p.hasOwnProperty(fe)&&we!=null&&!y.hasOwnProperty(fe)&&Qt(i,l,fe,null,y,we);for(ze in y)we=y[ze],je=p[ze],!y.hasOwnProperty(ze)||we===je||we==null&&je==null||Qt(i,l,ze,we,y,je)}function VS(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function NR(){if(typeof performance.getEntriesByType=="function"){for(var i=0,l=0,p=performance.getEntriesByType("resource"),y=0;y<p.length;y++){var N=p[y],R=N.transferSize,W=N.initiatorType,ee=N.duration;if(R&&ee&&VS(W)){for(W=0,ee=N.responseEnd,y+=1;y<p.length;y++){var oe=p[y],be=oe.startTime;if(be>ee)break;var Me=oe.transferSize,ze=oe.initiatorType;Me&&VS(ze)&&(oe=oe.responseEnd,W+=Me*(oe<ee?1:(ee-be)/(oe-be)))}if(--y,l+=8*(R+W)/(N.duration/1e3),i++,10<i)break}}if(0<i)return l/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var hg=null,fg=null;function Bd(i){return i.nodeType===9?i:i.ownerDocument}function WS(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function GS(i,l){if(i===0)switch(l){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&l==="foreignObject"?0:i}function mg(i,l){return i==="textarea"||i==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.children=="bigint"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var pg=null;function TR(){var i=window.event;return i&&i.type==="popstate"?i===pg?!1:(pg=i,!0):(pg=null,!1)}var qS=typeof setTimeout=="function"?setTimeout:void 0,AR=typeof clearTimeout=="function"?clearTimeout:void 0,KS=typeof Promise=="function"?Promise:void 0,LR=typeof queueMicrotask=="function"?queueMicrotask:typeof KS<"u"?function(i){return KS.resolve(null).then(i).catch(RR)}:qS;function RR(i){setTimeout(function(){throw i})}function zi(i){return i==="head"}function YS(i,l){var p=l,y=0;do{var N=p.nextSibling;if(i.removeChild(p),N&&N.nodeType===8)if(p=N.data,p==="/$"||p==="/&"){if(y===0){i.removeChild(N),Xo(l);return}y--}else if(p==="$"||p==="$?"||p==="$~"||p==="$!"||p==="&")y++;else if(p==="html")kc(i.ownerDocument.documentElement);else if(p==="head"){p=i.ownerDocument.head,kc(p);for(var R=p.firstChild;R;){var W=R.nextSibling,ee=R.nodeName;R[Tn]||ee==="SCRIPT"||ee==="STYLE"||ee==="LINK"&&R.rel.toLowerCase()==="stylesheet"||p.removeChild(R),R=W}}else p==="body"&&kc(i.ownerDocument.body);p=N}while(p);Xo(l)}function XS(i,l){var p=i;i=0;do{var y=p.nextSibling;if(p.nodeType===1?l?(p._stashedDisplay=p.style.display,p.style.display="none"):(p.style.display=p._stashedDisplay||"",p.getAttribute("style")===""&&p.removeAttribute("style")):p.nodeType===3&&(l?(p._stashedText=p.nodeValue,p.nodeValue=""):p.nodeValue=p._stashedText||""),y&&y.nodeType===8)if(p=y.data,p==="/$"){if(i===0)break;i--}else p!=="$"&&p!=="$?"&&p!=="$~"&&p!=="$!"||i++;p=y}while(p)}function gg(i){var l=i.firstChild;for(l&&l.nodeType===10&&(l=l.nextSibling);l;){var p=l;switch(l=l.nextSibling,p.nodeName){case"HTML":case"HEAD":case"BODY":gg(p),fo(p);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(p.rel.toLowerCase()==="stylesheet")continue}i.removeChild(p)}}function DR(i,l,p,y){for(;i.nodeType===1;){var N=p;if(i.nodeName.toLowerCase()!==l.toLowerCase()){if(!y&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(y){if(!i[Tn])switch(l){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(R=i.getAttribute("rel"),R==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(R!==N.rel||i.getAttribute("href")!==(N.href==null||N.href===""?null:N.href)||i.getAttribute("crossorigin")!==(N.crossOrigin==null?null:N.crossOrigin)||i.getAttribute("title")!==(N.title==null?null:N.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(R=i.getAttribute("src"),(R!==(N.src==null?null:N.src)||i.getAttribute("type")!==(N.type==null?null:N.type)||i.getAttribute("crossorigin")!==(N.crossOrigin==null?null:N.crossOrigin))&&R&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(l==="input"&&i.type==="hidden"){var R=N.name==null?null:""+N.name;if(N.type==="hidden"&&i.getAttribute("name")===R)return i}else return i;if(i=Qr(i.nextSibling),i===null)break}return null}function OR(i,l,p){if(l==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!p||(i=Qr(i.nextSibling),i===null))return null;return i}function QS(i,l){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!l||(i=Qr(i.nextSibling),i===null))return null;return i}function xg(i){return i.data==="$?"||i.data==="$~"}function yg(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function IR(i,l){var p=i.ownerDocument;if(i.data==="$~")i._reactRetry=l;else if(i.data!=="$?"||p.readyState!=="loading")l();else{var y=function(){l(),p.removeEventListener("DOMContentLoaded",y)};p.addEventListener("DOMContentLoaded",y),i._reactRetry=y}}function Qr(i){for(;i!=null;i=i.nextSibling){var l=i.nodeType;if(l===1||l===3)break;if(l===8){if(l=i.data,l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"||l==="F!"||l==="F")break;if(l==="/$"||l==="/&")return null}}return i}var bg=null;function JS(i){i=i.nextSibling;for(var l=0;i;){if(i.nodeType===8){var p=i.data;if(p==="/$"||p==="/&"){if(l===0)return Qr(i.nextSibling);l--}else p!=="$"&&p!=="$!"&&p!=="$?"&&p!=="$~"&&p!=="&"||l++}i=i.nextSibling}return null}function ZS(i){i=i.previousSibling;for(var l=0;i;){if(i.nodeType===8){var p=i.data;if(p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"){if(l===0)return i;l--}else p!=="/$"&&p!=="/&"||l++}i=i.previousSibling}return null}function ew(i,l,p){switch(l=Bd(p),i){case"html":if(i=l.documentElement,!i)throw Error(r(452));return i;case"head":if(i=l.head,!i)throw Error(r(453));return i;case"body":if(i=l.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function kc(i){for(var l=i.attributes;l.length;)i.removeAttributeNode(l[0]);fo(i)}var Jr=new Map,tw=new Set;function $d(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var ai=Z.d;Z.d={f:MR,r:PR,D:BR,C:$R,L:FR,m:HR,X:UR,S:zR,M:VR};function MR(){var i=ai.f(),l=Ad();return i||l}function PR(i){var l=po(i);l!==null&&l.tag===5&&l.type==="form"?y0(l):ai.r(i)}var qo=typeof document>"u"?null:document;function nw(i,l,p){var y=qo;if(y&&typeof l=="string"&&l){var N=Vr(l);N='link[rel="'+i+'"][href="'+N+'"]',typeof p=="string"&&(N+='[crossorigin="'+p+'"]'),tw.has(N)||(tw.add(N),i={rel:i,crossOrigin:p,href:l},y.querySelector(N)===null&&(l=y.createElement("link"),Qn(l,"link",i),zn(l),y.head.appendChild(l)))}}function BR(i){ai.D(i),nw("dns-prefetch",i,null)}function $R(i,l){ai.C(i,l),nw("preconnect",i,l)}function FR(i,l,p){ai.L(i,l,p);var y=qo;if(y&&i&&l){var N='link[rel="preload"][as="'+Vr(l)+'"]';l==="image"&&p&&p.imageSrcSet?(N+='[imagesrcset="'+Vr(p.imageSrcSet)+'"]',typeof p.imageSizes=="string"&&(N+='[imagesizes="'+Vr(p.imageSizes)+'"]')):N+='[href="'+Vr(i)+'"]';var R=N;switch(l){case"style":R=Ko(i);break;case"script":R=Yo(i)}Jr.has(R)||(i=f({rel:"preload",href:l==="image"&&p&&p.imageSrcSet?void 0:i,as:l},p),Jr.set(R,i),y.querySelector(N)!==null||l==="style"&&y.querySelector(jc(R))||l==="script"&&y.querySelector(Ec(R))||(l=y.createElement("link"),Qn(l,"link",i),zn(l),y.head.appendChild(l)))}}function HR(i,l){ai.m(i,l);var p=qo;if(p&&i){var y=l&&typeof l.as=="string"?l.as:"script",N='link[rel="modulepreload"][as="'+Vr(y)+'"][href="'+Vr(i)+'"]',R=N;switch(y){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":R=Yo(i)}if(!Jr.has(R)&&(i=f({rel:"modulepreload",href:i},l),Jr.set(R,i),p.querySelector(N)===null)){switch(y){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(p.querySelector(Ec(R)))return}y=p.createElement("link"),Qn(y,"link",i),zn(y),p.head.appendChild(y)}}}function zR(i,l,p){ai.S(i,l,p);var y=qo;if(y&&i){var N=go(y).hoistableStyles,R=Ko(i);l=l||"default";var W=N.get(R);if(!W){var ee={loading:0,preload:null};if(W=y.querySelector(jc(R)))ee.loading=5;else{i=f({rel:"stylesheet",href:i,"data-precedence":l},p),(p=Jr.get(R))&&vg(i,p);var oe=W=y.createElement("link");zn(oe),Qn(oe,"link",i),oe._p=new Promise(function(be,Me){oe.onload=be,oe.onerror=Me}),oe.addEventListener("load",function(){ee.loading|=1}),oe.addEventListener("error",function(){ee.loading|=2}),ee.loading|=4,Fd(W,l,y)}W={type:"stylesheet",instance:W,count:1,state:ee},N.set(R,W)}}}function UR(i,l){ai.X(i,l);var p=qo;if(p&&i){var y=go(p).hoistableScripts,N=Yo(i),R=y.get(N);R||(R=p.querySelector(Ec(N)),R||(i=f({src:i,async:!0},l),(l=Jr.get(N))&&_g(i,l),R=p.createElement("script"),zn(R),Qn(R,"link",i),p.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},y.set(N,R))}}function VR(i,l){ai.M(i,l);var p=qo;if(p&&i){var y=go(p).hoistableScripts,N=Yo(i),R=y.get(N);R||(R=p.querySelector(Ec(N)),R||(i=f({src:i,async:!0,type:"module"},l),(l=Jr.get(N))&&_g(i,l),R=p.createElement("script"),zn(R),Qn(R,"link",i),p.head.appendChild(R)),R={type:"script",instance:R,count:1,state:null},y.set(N,R))}}function rw(i,l,p,y){var N=(N=X.current)?$d(N):null;if(!N)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof p.precedence=="string"&&typeof p.href=="string"?(l=Ko(p.href),p=go(N).hoistableStyles,y=p.get(l),y||(y={type:"style",instance:null,count:0,state:null},p.set(l,y)),y):{type:"void",instance:null,count:0,state:null};case"link":if(p.rel==="stylesheet"&&typeof p.href=="string"&&typeof p.precedence=="string"){i=Ko(p.href);var R=go(N).hoistableStyles,W=R.get(i);if(W||(N=N.ownerDocument||N,W={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},R.set(i,W),(R=N.querySelector(jc(i)))&&!R._p&&(W.instance=R,W.state.loading=5),Jr.has(i)||(p={rel:"preload",as:"style",href:p.href,crossOrigin:p.crossOrigin,integrity:p.integrity,media:p.media,hrefLang:p.hrefLang,referrerPolicy:p.referrerPolicy},Jr.set(i,p),R||WR(N,i,p,W.state))),l&&y===null)throw Error(r(528,""));return W}if(l&&y!==null)throw Error(r(529,""));return null;case"script":return l=p.async,p=p.src,typeof p=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=Yo(p),p=go(N).hoistableScripts,y=p.get(l),y||(y={type:"script",instance:null,count:0,state:null},p.set(l,y)),y):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function Ko(i){return'href="'+Vr(i)+'"'}function jc(i){return'link[rel="stylesheet"]['+i+"]"}function sw(i){return f({},i,{"data-precedence":i.precedence,precedence:null})}function WR(i,l,p,y){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?y.loading=1:(l=i.createElement("link"),y.preload=l,l.addEventListener("load",function(){return y.loading|=1}),l.addEventListener("error",function(){return y.loading|=2}),Qn(l,"link",p),zn(l),i.head.appendChild(l))}function Yo(i){return'[src="'+Vr(i)+'"]'}function Ec(i){return"script[async]"+i}function iw(i,l,p){if(l.count++,l.instance===null)switch(l.type){case"style":var y=i.querySelector('style[data-href~="'+Vr(p.href)+'"]');if(y)return l.instance=y,zn(y),y;var N=f({},p,{"data-href":p.href,"data-precedence":p.precedence,href:null,precedence:null});return y=(i.ownerDocument||i).createElement("style"),zn(y),Qn(y,"style",N),Fd(y,p.precedence,i),l.instance=y;case"stylesheet":N=Ko(p.href);var R=i.querySelector(jc(N));if(R)return l.state.loading|=4,l.instance=R,zn(R),R;y=sw(p),(N=Jr.get(N))&&vg(y,N),R=(i.ownerDocument||i).createElement("link"),zn(R);var W=R;return W._p=new Promise(function(ee,oe){W.onload=ee,W.onerror=oe}),Qn(R,"link",y),l.state.loading|=4,Fd(R,p.precedence,i),l.instance=R;case"script":return R=Yo(p.src),(N=i.querySelector(Ec(R)))?(l.instance=N,zn(N),N):(y=p,(N=Jr.get(R))&&(y=f({},p),_g(y,N)),i=i.ownerDocument||i,N=i.createElement("script"),zn(N),Qn(N,"link",y),i.head.appendChild(N),l.instance=N);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(y=l.instance,l.state.loading|=4,Fd(y,p.precedence,i));return l.instance}function Fd(i,l,p){for(var y=p.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),N=y.length?y[y.length-1]:null,R=N,W=0;W<y.length;W++){var ee=y[W];if(ee.dataset.precedence===l)R=ee;else if(R!==N)break}R?R.parentNode.insertBefore(i,R.nextSibling):(l=p.nodeType===9?p.head:p,l.insertBefore(i,l.firstChild))}function vg(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.title==null&&(i.title=l.title)}function _g(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.integrity==null&&(i.integrity=l.integrity)}var Hd=null;function aw(i,l,p){if(Hd===null){var y=new Map,N=Hd=new Map;N.set(p,y)}else N=Hd,y=N.get(p),y||(y=new Map,N.set(p,y));if(y.has(i))return y;for(y.set(i,null),p=p.getElementsByTagName(i),N=0;N<p.length;N++){var R=p[N];if(!(R[Tn]||R[He]||i==="link"&&R.getAttribute("rel")==="stylesheet")&&R.namespaceURI!=="http://www.w3.org/2000/svg"){var W=R.getAttribute(l)||"";W=i+W;var ee=y.get(W);ee?ee.push(R):y.set(W,[R])}}return y}function ow(i,l,p){i=i.ownerDocument||i,i.head.insertBefore(p,l==="title"?i.querySelector("head > title"):null)}function GR(i,l,p){if(p===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;switch(l.rel){case"stylesheet":return i=l.disabled,typeof l.precedence=="string"&&i==null;default:return!0}case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function lw(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function qR(i,l,p,y){if(p.type==="stylesheet"&&(typeof y.media!="string"||matchMedia(y.media).matches!==!1)&&(p.state.loading&4)===0){if(p.instance===null){var N=Ko(y.href),R=l.querySelector(jc(N));if(R){l=R._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=zd.bind(i),l.then(i,i)),p.state.loading|=4,p.instance=R,zn(R);return}R=l.ownerDocument||l,y=sw(y),(N=Jr.get(N))&&vg(y,N),R=R.createElement("link"),zn(R);var W=R;W._p=new Promise(function(ee,oe){W.onload=ee,W.onerror=oe}),Qn(R,"link",y),p.instance=R}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(p,l),(l=p.state.preload)&&(p.state.loading&3)===0&&(i.count++,p=zd.bind(i),l.addEventListener("load",p),l.addEventListener("error",p))}}var Sg=0;function KR(i,l){return i.stylesheets&&i.count===0&&Vd(i,i.stylesheets),0<i.count||0<i.imgCount?function(p){var y=setTimeout(function(){if(i.stylesheets&&Vd(i,i.stylesheets),i.unsuspend){var R=i.unsuspend;i.unsuspend=null,R()}},6e4+l);0<i.imgBytes&&Sg===0&&(Sg=62500*NR());var N=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Vd(i,i.stylesheets),i.unsuspend)){var R=i.unsuspend;i.unsuspend=null,R()}},(i.imgBytes>Sg?50:800)+l);return i.unsuspend=p,function(){i.unsuspend=null,clearTimeout(y),clearTimeout(N)}}:null}function zd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Vd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Ud=null;function Vd(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Ud=new Map,l.forEach(YR,i),Ud=null,zd.call(i))}function YR(i,l){if(!(l.state.loading&4)){var p=Ud.get(i);if(p)var y=p.get(null);else{p=new Map,Ud.set(i,p);for(var N=i.querySelectorAll("link[data-precedence],style[data-precedence]"),R=0;R<N.length;R++){var W=N[R];(W.nodeName==="LINK"||W.getAttribute("media")!=="not all")&&(p.set(W.dataset.precedence,W),y=W)}y&&p.set(null,y)}N=l.instance,W=N.getAttribute("data-precedence"),R=p.get(W)||y,R===y&&p.set(null,N),p.set(W,N),this.count++,y=zd.bind(this),N.addEventListener("load",y),N.addEventListener("error",y),R?R.parentNode.insertBefore(N,R.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(N,i.firstChild)),l.state.loading|=4}}var Nc={$$typeof:b,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function XR(i,l,p,y,N,R,W,ee,oe){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=hr(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hr(0),this.hiddenUpdates=hr(null),this.identifierPrefix=y,this.onUncaughtError=N,this.onCaughtError=R,this.onRecoverableError=W,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=oe,this.incompleteTransitions=new Map}function cw(i,l,p,y,N,R,W,ee,oe,be,Me,ze){return i=new XR(i,l,p,W,oe,be,Me,ze,ee),l=1,R===!0&&(l|=24),R=Tr(3,null,null,l),i.current=R,R.stateNode=i,l=tp(),l.refCount++,i.pooledCache=l,l.refCount++,R.memoizedState={element:y,isDehydrated:p,cache:l},ip(R),i}function uw(i){return i?(i=jo,i):jo}function dw(i,l,p,y,N,R){N=uw(N),y.context===null?y.context=N:y.pendingContext=N,y=Li(l),y.payload={element:p},R=R===void 0?null:R,R!==null&&(y.callback=R),p=Ri(i,y,l),p!==null&&(yr(p,i,l),ac(p,i,l))}function hw(i,l){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var p=i.retryLane;i.retryLane=p!==0&&p<l?p:l}}function wg(i,l){hw(i,l),(i=i.alternate)&&hw(i,l)}function fw(i){if(i.tag===13||i.tag===31){var l=va(i,67108864);l!==null&&yr(l,i,67108864),wg(i,67108864)}}function mw(i){if(i.tag===13||i.tag===31){var l=Or();l=Ye(l);var p=va(i,l);p!==null&&yr(p,i,l),wg(i,l)}}var Wd=!0;function QR(i,l,p,y){var N=V.T;V.T=null;var R=Z.p;try{Z.p=2,Cg(i,l,p,y)}finally{Z.p=R,V.T=N}}function JR(i,l,p,y){var N=V.T;V.T=null;var R=Z.p;try{Z.p=8,Cg(i,l,p,y)}finally{Z.p=R,V.T=N}}function Cg(i,l,p,y){if(Wd){var N=kg(y);if(N===null)ug(i,l,y,Gd,p),gw(i,y);else if(eD(N,i,l,p,y))y.stopPropagation();else if(gw(i,y),l&4&&-1<ZR.indexOf(i)){for(;N!==null;){var R=po(N);if(R!==null)switch(R.tag){case 3:if(R=R.stateNode,R.current.memoizedState.isDehydrated){var W=Lt(R.pendingLanes);if(W!==0){var ee=R;for(ee.pendingLanes|=2,ee.entangledLanes|=2;W;){var oe=1<<31-Re(W);ee.entanglements[1]|=oe,W&=~oe}js(R),(Ut&6)===0&&(Nd=Pe()+500,Sc(0))}}break;case 31:case 13:ee=va(R,2),ee!==null&&yr(ee,R,2),Ad(),wg(R,2)}if(R=kg(y),R===null&&ug(i,l,y,Gd,p),R===N)break;N=R}N!==null&&y.stopPropagation()}else ug(i,l,y,null,p)}}function kg(i){return i=Em(i),jg(i)}var Gd=null;function jg(i){if(Gd=null,i=mo(i),i!==null){var l=o(i);if(l===null)i=null;else{var p=l.tag;if(p===13){if(i=c(l),i!==null)return i;i=null}else if(p===31){if(i=u(l),i!==null)return i;i=null}else if(p===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;i=null}else l!==i&&(i=null)}}return Gd=i,null}function pw(i){switch(i){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ue()){case de:return 2;case Ae:return 8;case ue:case Fe:return 32;case Xe:return 268435456;default:return 32}default:return 32}}var Eg=!1,Ui=null,Vi=null,Wi=null,Tc=new Map,Ac=new Map,Gi=[],ZR="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 gw(i,l){switch(i){case"focusin":case"focusout":Ui=null;break;case"dragenter":case"dragleave":Vi=null;break;case"mouseover":case"mouseout":Wi=null;break;case"pointerover":case"pointerout":Tc.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ac.delete(l.pointerId)}}function Lc(i,l,p,y,N,R){return i===null||i.nativeEvent!==R?(i={blockedOn:l,domEventName:p,eventSystemFlags:y,nativeEvent:R,targetContainers:[N]},l!==null&&(l=po(l),l!==null&&fw(l)),i):(i.eventSystemFlags|=y,l=i.targetContainers,N!==null&&l.indexOf(N)===-1&&l.push(N),i)}function eD(i,l,p,y,N){switch(l){case"focusin":return Ui=Lc(Ui,i,l,p,y,N),!0;case"dragenter":return Vi=Lc(Vi,i,l,p,y,N),!0;case"mouseover":return Wi=Lc(Wi,i,l,p,y,N),!0;case"pointerover":var R=N.pointerId;return Tc.set(R,Lc(Tc.get(R)||null,i,l,p,y,N)),!0;case"gotpointercapture":return R=N.pointerId,Ac.set(R,Lc(Ac.get(R)||null,i,l,p,y,N)),!0}return!1}function xw(i){var l=mo(i.target);if(l!==null){var p=o(l);if(p!==null){if(l=p.tag,l===13){if(l=c(p),l!==null){i.blockedOn=l,Ee(i.priority,function(){mw(p)});return}}else if(l===31){if(l=u(p),l!==null){i.blockedOn=l,Ee(i.priority,function(){mw(p)});return}}else if(l===3&&p.stateNode.current.memoizedState.isDehydrated){i.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}i.blockedOn=null}function qd(i){if(i.blockedOn!==null)return!1;for(var l=i.targetContainers;0<l.length;){var p=kg(i.nativeEvent);if(p===null){p=i.nativeEvent;var y=new p.constructor(p.type,p);jm=y,p.target.dispatchEvent(y),jm=null}else return l=po(p),l!==null&&fw(l),i.blockedOn=p,!1;l.shift()}return!0}function yw(i,l,p){qd(i)&&p.delete(l)}function tD(){Eg=!1,Ui!==null&&qd(Ui)&&(Ui=null),Vi!==null&&qd(Vi)&&(Vi=null),Wi!==null&&qd(Wi)&&(Wi=null),Tc.forEach(yw),Ac.forEach(yw)}function Kd(i,l){i.blockedOn===l&&(i.blockedOn=null,Eg||(Eg=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,tD)))}var Yd=null;function bw(i){Yd!==i&&(Yd=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Yd===i&&(Yd=null);for(var l=0;l<i.length;l+=3){var p=i[l],y=i[l+1],N=i[l+2];if(typeof y!="function"){if(jg(y||p)===null)continue;break}var R=po(p);R!==null&&(i.splice(l,3),l-=3,kp(R,{pending:!0,data:N,method:p.method,action:y},y,N))}}))}function Xo(i){function l(oe){return Kd(oe,i)}Ui!==null&&Kd(Ui,i),Vi!==null&&Kd(Vi,i),Wi!==null&&Kd(Wi,i),Tc.forEach(l),Ac.forEach(l);for(var p=0;p<Gi.length;p++){var y=Gi[p];y.blockedOn===i&&(y.blockedOn=null)}for(;0<Gi.length&&(p=Gi[0],p.blockedOn===null);)xw(p),p.blockedOn===null&&Gi.shift();if(p=(i.ownerDocument||i).$$reactFormReplay,p!=null)for(y=0;y<p.length;y+=3){var N=p[y],R=p[y+1],W=N[et]||null;if(typeof R=="function")W||bw(p);else if(W){var ee=null;if(R&&R.hasAttribute("formAction")){if(N=R,W=R[et]||null)ee=W.formAction;else if(jg(N)!==null)continue}else ee=W.action;typeof ee=="function"?p[y+1]=ee:(p.splice(y,3),y-=3),bw(p)}}}function vw(){function i(R){R.canIntercept&&R.info==="react-transition"&&R.intercept({handler:function(){return new Promise(function(W){return N=W})},focusReset:"manual",scroll:"manual"})}function l(){N!==null&&(N(),N=null),y||setTimeout(p,20)}function p(){if(!y&&!navigation.transition){var R=navigation.currentEntry;R&&R.url!=null&&navigation.navigate(R.url,{state:R.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var y=!1,N=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",l),navigation.addEventListener("navigateerror",l),setTimeout(p,100),function(){y=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),N!==null&&(N(),N=null)}}}function Ng(i){this._internalRoot=i}Xd.prototype.render=Ng.prototype.render=function(i){var l=this._internalRoot;if(l===null)throw Error(r(409));var p=l.current,y=Or();dw(p,y,i,l,null,null)},Xd.prototype.unmount=Ng.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var l=i.containerInfo;dw(i.current,2,null,i,null,null),Ad(),l[st]=null}};function Xd(i){this._internalRoot=i}Xd.prototype.unstable_scheduleHydration=function(i){if(i){var l=It();i={blockedOn:null,target:i,priority:l};for(var p=0;p<Gi.length&&l!==0&&l<Gi[p].priority;p++);Gi.splice(p,0,i),p===0&&xw(i)}};var _w=t.version;if(_w!=="19.2.8")throw Error(r(527,_w,"19.2.8"));Z.findDOMNode=function(i){var l=i._reactInternals;if(l===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=h(l),i=i!==null?m(i):null,i=i===null?null:i.stateNode,i};var nD={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:V,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Qd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Qd.isDisabled&&Qd.supportsFiber)try{lt=Qd.inject(nD),gt=Qd}catch{}}return Dc.createRoot=function(i,l){if(!a(i))throw Error(r(299));var p=!1,y="",N=N0,R=T0,W=A0;return l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(y=l.identifierPrefix),l.onUncaughtError!==void 0&&(N=l.onUncaughtError),l.onCaughtError!==void 0&&(R=l.onCaughtError),l.onRecoverableError!==void 0&&(W=l.onRecoverableError)),l=cw(i,1,!1,null,null,p,y,null,N,R,W,vw),i[st]=l.current,cg(i),new Ng(l)},Dc.hydrateRoot=function(i,l,p){if(!a(i))throw Error(r(299));var y=!1,N="",R=N0,W=T0,ee=A0,oe=null;return p!=null&&(p.unstable_strictMode===!0&&(y=!0),p.identifierPrefix!==void 0&&(N=p.identifierPrefix),p.onUncaughtError!==void 0&&(R=p.onUncaughtError),p.onCaughtError!==void 0&&(W=p.onCaughtError),p.onRecoverableError!==void 0&&(ee=p.onRecoverableError),p.formState!==void 0&&(oe=p.formState)),l=cw(i,1,!0,l,p??null,y,N,oe,R,W,ee,vw),l.context=uw(null),p=l.current,y=Or(),y=Ye(y),N=Li(y),N.callback=null,Ri(p,N,y),p=y,l.current.lanes=p,ve(l,p),js(l),i[st]=l.current,cg(i),new Xd(l)},Dc.version="19.2.8",Dc}var Dw;function xD(){if(Dw)return Dg.exports;Dw=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(),Dg.exports=gD(),Dg.exports}var yD=xD();const bD=Nf(yD);function vD(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,a,o,c=[],u="",d=e.split("/");for(d[0]||d.shift();a=d.shift();)n=a[0],n==="*"?(c.push(n),u+=a[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(r=a.indexOf("?",1),o=a.indexOf(".",1),c.push(a.substring(1,~r?r:~o?o:a.length)),u+=~r&&!~o?"(?:/([^/]+?))?":"/([^/]+?)",~o&&(u+=(~r?"?":"")+"\\"+a.substring(o))):u+="/"+a;return{keys:c,pattern:new RegExp("^"+u+(t?"(?=$|/)":"/?$"),"i")}}var Pg={exports:{}},Bg={};/**
|
|
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 Ow;function _D(){if(Ow)return Bg;Ow=1;var e=Tf();function t(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,a=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function u(f,g){var x=g(),w=r({inst:{value:x,getSnapshot:g}}),C=w[0].inst,v=w[1];return o(function(){C.value=x,C.getSnapshot=g,d(C)&&v({inst:C})},[f,x,g]),a(function(){return d(C)&&v({inst:C}),f(function(){d(C)&&v({inst:C})})},[f]),c(x),x}function d(f){var g=f.getSnapshot;f=f.value;try{var x=g();return!n(f,x)}catch{return!0}}function h(f,g){return g()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;return Bg.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,Bg}var Iw;function SD(){return Iw||(Iw=1,Pg.exports=_D()),Pg.exports}var wD=SD();const CD=hD.useInsertionEffect,kD=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",jD=kD?j.useLayoutEffect:j.useEffect,ED=CD||jD,dj=e=>{const t=j.useRef([e,(...n)=>t[0](...n)]).current;return ED(()=>{t[0]=e}),t[1]},ND="popstate",Qy="pushState",Jy="replaceState",TD="hashchange",Mw=[ND,Qy,Jy,TD],AD=e=>{for(const t of Mw)addEventListener(t,e);return()=>{for(const t of Mw)removeEventListener(t,e)}},hj=(e,t)=>wD.useSyncExternalStore(AD,e,t),Pw=()=>location.search,LD=({ssrSearch:e}={})=>hj(Pw,e!=null?()=>e:Pw),Bw=()=>location.pathname,RD=({ssrPath:e}={})=>hj(Bw,e!=null?()=>e:Bw),DD=(e,{replace:t=!1,state:n=null}={})=>history[t?Jy:Qy](n,"",e),OD=(e={})=>[RD(e),DD],$w=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[$w]>"u"){for(const e of[Qy,Jy]){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,$w,{value:!0})}const ID=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",fj=(e="")=>e==="/"?"":e,MD=(e,t)=>e[0]==="~"?e.slice(1):fj(t)+e,PD=(e="",t)=>ID(Fw(fj(e)),Fw(t)),Fw=e=>{try{return decodeURI(e)}catch{return e}},mj={hook:OD,searchHook:LD,parser:vD,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},pj=j.createContext(mj),Rl=()=>j.useContext(pj),gj={},xj=j.createContext(gj),BD=()=>j.useContext(xj),Af=e=>{const[t,n]=e.hook(e);return[PD(e.base,t),dj((r,a)=>e.aroundNav(n,MD(r,e.base),a))]},Nn=()=>Af(Rl()),Zy=(e,t,n,r)=>{const{pattern:a,keys:o}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",r),c=a.exec(n)||[],[u,...d]=c;return u!==void 0?[!0,(()=>{const h=o!==!1?Object.fromEntries(o.map((f,g)=>[f,d[g]])):c.groups;let m={...d};return h&&Object.assign(m,h),m})(),...r?[u]:[]]:[!1,null]},Dl=e=>Zy(Rl().parser,e,Nn()[0]),yj=({children:e,...t})=>{var m,f,g;const n=Rl(),r=t.hook?mj:n;let a=r;const[o,c=t.ssrSearch??""]=((m=t.ssrPath)==null?void 0:m.split("?"))??[];o&&(t.ssrSearch=c,t.ssrPath=o),t.hrefs=t.hrefs??((f=t.hook)==null?void 0:f.hrefs),t.searchHook=t.searchHook??((g=t.hook)==null?void 0:g.searchHook);let u=j.useRef({}),d=u.current,h=d;for(let x in r){const w=x==="base"?r[x]+(t[x]??""):t[x]??r[x];d===h&&w!==h[x]&&(u.current=h={...h}),h[x]=w,(w!==r[x]||w!==a[x])&&(a=h)}return j.createElement(pj.Provider,{value:a,children:e})},Hw=({children:e,component:t},n)=>t?j.createElement(t,{params:n}):typeof e=="function"?e(n):e,$D=e=>{let t=j.useRef(gj);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},Qo=({path:e,nest:t,match:n,...r})=>{const a=Rl(),[o]=Af(a),[c,u,d]=n??Zy(a.parser,e,o,t),h=$D({...BD(),...u});if(!c)return null;const m=d?j.createElement(yj,{base:d},Hw(r,h)):Hw(r,h);return j.createElement(xj.Provider,{value:h,children:m})},ir=j.forwardRef((e,t)=>{const n=Rl(),[r,a]=Af(n),{to:o="",href:c=o,onClick:u,asChild:d,children:h,className:m,replace:f,state:g,transition:x,...w}=e,C=dj(S=>{S.ctrlKey||S.metaKey||S.altKey||S.shiftKey||S.button!==0||(u==null||u(S),S.defaultPrevented||(S.preventDefault(),a(c,e)))}),v=n.hrefs(c[0]==="~"?c.slice(1):n.base+c,n);return d&&j.isValidElement(h)?j.cloneElement(h,{onClick:C,href:v}):j.createElement("a",{...w,onClick:C,href:v,className:m!=null&&m.call?m(r===c):m,children:h,ref:t})}),bj=e=>Array.isArray(e)?e.flatMap(t=>bj(t&&t.type===j.Fragment?t.props.children:t)):[e],FD=({children:e,location:t})=>{const n=Rl(),[r]=Af(n);for(const a of bj(e)){let o=0;if(j.isValidElement(a)&&(o=Zy(n.parser,a.props.path,t||r,a.props.nest))[0])return j.cloneElement(a,{match:o})}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 Pr=(e,t)=>{const{o:n,i:r,u:a}=e;let o=n,c;const u=(m,f)=>{const g=o,x=m,w=f||(r?!r(g,x):g!==x);return(w||a)&&(o=x,c=g),[o,w,c]};return[t?m=>u(t(o,c),m):u,m=>[o,!!m,c]]},HD=typeof window<"u"&&typeof HTMLElement<"u"&&!!window.document,wr=HD?window:{},vj=Math.max,zD=Math.min,qx=Math.round,ra=Math.abs,zw=Math.sign,_j=wr.cancelAnimationFrame,eb=wr.requestAnimationFrame,tb=wr.setTimeout,Sj=wr.clearTimeout,Lf=e=>typeof wr[e]<"u"?wr[e]:void 0,UD=Lf("MutationObserver"),Uw=Lf("IntersectionObserver"),fl=Lf("ResizeObserver"),Xc=Lf("ScrollTimeline"),nb=e=>e===void 0,Rf=e=>e===null,oa=e=>typeof e=="number",Ol=e=>typeof e=="string",Df=e=>typeof e=="boolean",_s=e=>typeof e=="function",as=e=>Array.isArray(e),Wh=e=>typeof e=="object"&&!as(e)&&!Rf(e),rb=e=>{const t=!!e&&e.length,n=oa(t)&&t>-1&&t%1==0;return as(e)||!_s(e)&&n?t>0&&Wh(e)?t-1 in e:!0:!1},ou=e=>!!e&&e.constructor===Object,Gh=e=>e instanceof HTMLElement,Of=e=>e instanceof Element;function en(e,t){if(rb(e))for(let n=0;n<e.length&&t(e[n],n,e)!==!1;n++);else e&&en(Object.keys(e),(n=>t(e[n],n,e)));return e}const wj=(e,t)=>e.indexOf(t)>=0,Cl=(e,t)=>e.concat(t),yn=(e,t,n)=>(!Ol(t)&&rb(t)?Array.prototype.push.apply(e,t):e.push(t),e),ha=e=>Array.from(e||[]),sb=e=>as(e)?e:!Ol(e)&&rb(e)?ha(e):[e],qh=e=>!!e&&!e.length,Kh=e=>ha(new Set(e)),$r=(e,t,n)=>{en(e,a=>a?a.apply(void 0,t||[]):!0),n||(e.length=0)},Cj="paddingTop",kj="paddingRight",jj="paddingLeft",Ej="paddingBottom",Nj="marginLeft",Tj="marginRight",Aj="marginBottom",ib="overflowX",ab="overflowY",If="width",Mf="height",mi="visible",hs="hidden",Qa="scroll",VD=e=>{const t=String(e||"");return t?t[0].toUpperCase()+t.slice(1):""},Pf=(e,t,n,r)=>{if(e&&t){let a=!0;return en(n,(o=>{const c=e[o],u=t[o];c!==u&&(a=!1)})),a}return!1},Lj=(e,t)=>Pf(e,t,["w","h"]),Dh=(e,t)=>Pf(e,t,["x","y"]),WD=(e,t)=>Pf(e,t,["t","r","b","l"]),yt=(e,...t)=>e.bind(0,...t),ml=e=>{let t;const n=e?tb:eb,r=e?Sj:_j;return[a=>{r(t),t=n((()=>a()),_s(e)?e():e)},()=>r(t)]},Vw=e=>{const t=_s(e)?e():e;if(oa(t)){const n=t?tb:eb,r=t?Sj:_j;return a=>{const o=n((()=>a()),t);return()=>{r(o)}}}return t&&t._},Rj=(e,t)=>{const{p:n,v:r,S:a,m:o}=t||{};let c,u,d,h;const m=function(C){u&&u(),c&&c(),h=u=c=d=void 0,e.apply(this,C)},f=w=>o&&d?o(d,w):w,g=()=>{u&&d&&m(f(d)||d)},x=function(){const C=ha(arguments),v=Vw(n);if(v){const S=typeof a=="function"?a():a,_=Vw(r),k=f(C)||C,E=m.bind(0,k);u&&u(),S&&!h?(E(),h=!0,u=v((()=>h=void 0))):(u=v(E),_&&!c&&(c=_(g))),d=k}else m(C)};return x.O=g,x},Dj=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),_r=e=>e?Object.keys(e):[],zt=(e,t,n,r,a,o,c)=>{const u=[t,n,r,a,o,c];return(typeof e!="object"||Rf(e))&&!_s(e)&&(e={}),en(u,(d=>{en(d,((h,m)=>{const f=d[m];if(e===f)return!0;const g=as(f);if(f&&ou(f)){const x=e[m];let w=x;g&&!as(x)?w=[]:!g&&!ou(x)&&(w={}),e[m]=zt(w,f)}else e[m]=g?f.slice():f}))})),e},Oj=(e,t)=>en(zt({},e),((n,r,a)=>{n===void 0?delete a[r]:n&&ou(n)&&(a[r]=Oj(n))})),ob=e=>!_r(e).length,lu=()=>{},Ij=(e,t,n)=>vj(e,zD(t,n)),Ja=e=>Kh((as(e)?e:(e||"").split(" ")).filter((t=>t))),lb=(e,t)=>e&&e.getAttribute(t),Ww=(e,t)=>e&&e.hasAttribute(t),di=(e,t,n)=>{en(Ja(t),(r=>{e&&e.setAttribute(r,String(n||""))}))},Ts=(e,t)=>{en(Ja(t),(n=>e&&e.removeAttribute(n)))},Bf=(e,t)=>{const n=Ja(lb(e,t)),r=yt(di,e,t),a=(o,c)=>{const u=new Set(n);return en(Ja(o),(d=>{u[c](d)})),ha(u).join(" ")};return{C:o=>r(a(o,"delete")),$:o=>r(a(o,"add")),H:o=>{const c=Ja(o);return c.reduce(((u,d)=>u&&n.includes(d)),c.length>0)}}},Mj=(e,t,n)=>(Bf(e,t).C(n),yt(cb,e,t,n)),cb=(e,t,n)=>(Bf(e,t).$(n),yt(Mj,e,t,n)),Yh=(e,t,n,r)=>(r?cb:Mj)(e,t,n),ub=(e,t,n)=>Bf(e,t).H(n),Pj=e=>Bf(e,"class"),Bj=(e,t)=>{Pj(e).C(t)},db=(e,t)=>(Pj(e).$(t),yt(Bj,e,t)),$j=(e,t)=>{const n=t?Of(t)&&t:document;return n?ha(n.querySelectorAll(e)):[]},GD=(e,t)=>{const n=t?Of(t)&&t:document;return n&&n.querySelector(e)},Kx=(e,t)=>Of(e)&&e.matches(t),Fj=e=>Kx(e,"body"),Yx=e=>e?ha(e.childNodes):[],cu=e=>e&&e.parentElement,pl=(e,t)=>Of(e)&&e.closest(t),Xx=e=>document.activeElement,qD=(e,t,n)=>{const r=pl(e,t),a=e&&GD(n,r),o=pl(a,t)===r;return r&&a?r===e||a===e||o&&pl(pl(e,n),t)!==r:!1},kl=e=>{en(sb(e),(t=>{const n=cu(t);t&&n&&n.removeChild(t)}))},Sr=(e,t)=>yt(kl,e&&t&&en(sb(t),(n=>{n&&e.appendChild(n)})));let Hj;const KD=()=>Hj,YD=e=>{Hj=e},yl=e=>{const t=document.createElement("div");return di(t,"class",e),t},zj=e=>{const t=yl(),n=KD(),r=e.trim();return t.innerHTML=n?n.createHTML(r):r,en(Yx(t),(a=>kl(a)))},Gw=(e,t)=>e.getPropertyValue(t)||e[t]||"",Uj=e=>{const t=e||0;return isFinite(t)?t:0},Jd=e=>Uj(parseFloat(e||"")),Qx=e=>Math.round(e*1e4)/1e4,Vj=e=>`${Qx(Uj(e))}px`;function uu(e,t){e&&t&&en(t,((n,r)=>{try{const a=e.style,o=Rf(n)||Df(n)?"":oa(n)?Vj(n):n;r.indexOf("--")===0?a.setProperty(r,o):a[r]=o}catch{}}))}function Bs(e,t,n){const r=Ol(t);let a=r?"":{};if(e){const o=wr.getComputedStyle(e,n)||e.style;a=r?Gw(o,t):ha(t).reduce(((c,u)=>(c[u]=Gw(o,u),c)),a)}return a}const qw=(e,t,n)=>{const r=t?`${t}-`:"",a=n?`-${n}`:"",o=`${r}top${a}`,c=`${r}right${a}`,u=`${r}bottom${a}`,d=`${r}left${a}`,h=Bs(e,[o,c,u,d]);return{t:Jd(h[o]),r:Jd(h[c]),b:Jd(h[u]),l:Jd(h[d])}},$g=(e,t)=>`translate${Wh(e)?`(${e.x},${e.y})`:`${t?"X":"Y"}(${e})`}`,XD=e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length),QD={w:0,h:0},$f=(e,t)=>t?{w:t[`${e}Width`],h:t[`${e}Height`]}:QD,JD=e=>$f("inner",e||wr),bl=yt($f,"offset"),Wj=yt($f,"client"),Xh=yt($f,"scroll"),hb=e=>{const t=parseFloat(Bs(e,If))||0,n=parseFloat(Bs(e,Mf))||0;return{w:t-qx(t),h:n-qx(n)}},Fg=e=>e.getBoundingClientRect(),ZD=e=>!!e&&XD(e),Jx=e=>!!(e&&(e[Mf]||e[If])),Gj=(e,t)=>{const n=Jx(e);return!Jx(t)&&n},Kw=(e,t,n,r)=>{en(Ja(t),(a=>{e&&e.removeEventListener(a,n,r)}))},hn=(e,t,n,r)=>{var a;const o=(a=r&&r.D)!=null?a:!0,c=r&&r.I||!1,u=r&&r.A||!1,d={passive:o,capture:c};return yt($r,Ja(t).map((h=>{const m=u?f=>{Kw(e,h,m,c),n&&n(f)}:n;return e&&e.addEventListener(h,m,d),yt(Kw,e,h,m,c)})))},qj=e=>e.stopPropagation(),Zx=e=>e.preventDefault(),Kj=e=>qj(e)||Zx(e),Os=(e,t)=>{const{x:n,y:r}=oa(t)?{x:t,y:t}:t||{};oa(n)&&(e.scrollLeft=n),oa(r)&&(e.scrollTop=r)},Br=e=>({x:e.scrollLeft,y:e.scrollTop}),Yj=()=>({T:{x:0,y:0},k:{x:0,y:0}}),e5=(e,t)=>{const{T:n,k:r}=e,{w:a,h:o}=t,c=(f,g,x)=>{let w=zw(f)*x,C=zw(g)*x;if(w===C){const v=ra(f),S=ra(g);C=v>S?0:C,w=v<S?0:w}return w=w===C?0:w,[w+0,C+0]},[u,d]=c(n.x,r.x,a),[h,m]=c(n.y,r.y,o);return{T:{x:u,y:h},k:{x:d,y:m}}},Hg=({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)}},Yw=({T:e,k:t},n)=>{const r=(a,o,c)=>Ij(0,1,(a-c)/(a-o)||0);return{x:r(e.x,t.x,n.x),y:r(e.y,t.y,n.y)}},ey=e=>{e&&e.focus&&e.focus({preventScroll:!0,focusVisible:!1})},Xw=(e,t)=>{en(sb(t),e)},ty=e=>{const t=new Map,n=(o,c)=>{if(o){const u=t.get(o);Xw((d=>{u&&u[d?"delete":"clear"](d)}),c)}else t.forEach((u=>{u.clear()})),t.clear()},r=(o,c)=>{if(Ol(o)){const h=t.get(o)||new Set;return t.set(o,h),Xw((m=>{_s(m)&&h.add(m)}),c),yt(n,o,c)}Df(c)&&c&&n();const u=_r(o),d=[];return en(u,(h=>{const m=o[h];m&&yn(d,r(h,m))})),yt($r,d)},a=(o,c)=>{en(ha(t.get(o)),(u=>{c&&!qh(c)?u.apply(0,c):u()}))};return r(e||{}),[r,n,a]},Xj={},Qj={},t5=e=>{en(e,(t=>en(t,((n,r)=>{Xj[r]=t[r]}))))},Jj=(e,t,n)=>_r(e).map((r=>{const{static:a,instance:o}=e[r],[c,u,d]=n||[],h=n?o:a;if(h){const m=n?h(c,u,t):h(t);return(d||Qj)[r]=m}})),n5=(e,t)=>e[t],Il=e=>n5(Qj,e),r5="__osOptionsValidationPlugin",Ml="data-overlayscrollbars",Oh="os-environment",Zd=`${Oh}-scrollbar-hidden`,zg=`${Ml}-initialize`,Ih="noClipping",Qw=`${Ml}-body`,la=Ml,s5="host",hi=`${Ml}-viewport`,i5=ib,a5=ab,o5="arrange",Zj="measuring",l5="scrolling",eE="scrollbarHidden",c5="noContent",ny=`${Ml}-padding`,Jw=`${Ml}-content`,fb="os-size-observer",u5=`${fb}-appear`,d5=`${fb}-listener`,h5="os-trinsic-observer",f5="os-theme-none",zr="os-scrollbar",m5=`${zr}-rtl`,p5=`${zr}-horizontal`,g5=`${zr}-vertical`,tE=`${zr}-track`,mb=`${zr}-handle`,x5=`${zr}-visible`,y5=`${zr}-cornerless`,Zw=`${zr}-interaction`,e1=`${zr}-unusable`,ry=`${zr}-auto-hide`,b5=`${ry}-hidden`,t1=`${zr}-wheel`,v5=`${tE}-interactive`,_5=`${mb}-interactive`,S5="__osSizeObserverPlugin",w5=(e,t)=>{const{M:n}=t,[r,a]=e("showNativeOverlaidScrollbars");return[r&&n.x&&n.y,a]},gl=e=>e.indexOf(mi)===0,C5=e=>e.replace(`${mi}-`,""),sy=(e,t)=>{if(e==="auto")return t?Qa:hs;const n=e||hs;return[hs,Qa,mi].includes(n)?n:hs},k5=(e,t)=>{const{overflowX:n,overflowY:r}=Bs(e,[ib,ab]);return{x:sy(n,t.x),y:sy(r,t.y)}},pb="__osScrollbarsHidingPlugin",j5="__osClickScrollPlugin",n1=e=>JSON.stringify(e,((t,n)=>{if(_s(n))throw 0;return n})),r1=(e,t)=>e?`${t}`.split(".").reduce(((n,r)=>n&&Dj(n,r)?n[r]:void 0),e):void 0,E5=[0,33],nE=[33,99],rE=[222,666,!0],N5={paddingAbsolute:!1,showNativeOverlaidScrollbars:!1,update:{elementEvents:[["img","load"]],debounce:{mutation:E5,resize:null,event:nE,env:rE},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"]}},sE=(e,t)=>{const n={},r=Cl(_r(t),_r(e));return en(r,(a=>{const o=e[a],c=t[a];if(Wh(o)&&Wh(c))zt(n[a]={},sE(o,c)),ob(n[a])&&delete n[a];else if(Dj(t,a)&&c!==o){let u=!0;if(as(o)||as(c))try{n1(o)===n1(c)&&(u=!1)}catch{}u&&(n[a]=c)}})),n},Ug=(e,t,n)=>r=>[r1(e,r),n||r1(t,r)!==void 0];let iE;const T5=()=>iE,A5=e=>{iE=e};let Vg;const L5=()=>{const e=(k,E,T)=>{Sr(document.body,k),Sr(document.body,k);const L=Wj(k),A=bl(k),O=hb(E);return T&&kl(k),{x:A.h-L.h+O.h,y:A.w-L.w+O.w}},t=k=>{let E=!1;const T=db(k,Zd);try{E=Bs(k,"scrollbar-width")==="none"||Bs(k,"display","::-webkit-scrollbar")==="none"}catch{}return T(),E},n=`.${Oh}{scroll-behavior:auto!important;position:fixed;opacity:0;visibility:hidden;overflow:scroll;height:200px;width:200px;z-index:-1}.${Oh} div{width:200%;height:200%;margin:10px 0}.${Zd}{scrollbar-width:none!important}.${Zd}::-webkit-scrollbar,.${Zd}::-webkit-scrollbar-corner{appearance:none!important;display:none!important;width:0!important;height:0!important}`,a=zj(`<div class="${Oh}"><div></div><style>${n}</style></div>`)[0],o=a.firstChild,c=a.lastChild,u=T5();u&&(c.nonce=u);const[d,,h]=ty(),[m,f]=Pr({o:e(a,o),i:Dh},yt(e,a,o,!0)),[g]=f(),x=t(a),w={x:g.x===0,y:g.y===0},C={elements:{host:null,padding:!x,viewport:k=>x&&Fj(k)&&k,content:!1},scrollbars:{slot:!0},cancel:{nativeScrollbarsOverlaid:!1,body:null}},v=zt({},N5),S=yt(zt,{},v),_=yt(zt,{},C),b={U:g,M:w,P:x,J:!!Xc,G:yt(d,"r"),K:_,Z:k=>zt(C,k)&&_(),tt:S,nt:k=>zt(v,k)&&S(),ot:zt({},C),st:zt({},v)};if(Ts(a,"style"),kl(a),hn(wr,"resize",(()=>{h("r",[])})),_s(wr.matchMedia)&&!x&&(!w.x||!w.y)){const k=E=>{const T=wr.matchMedia(`(resolution: ${wr.devicePixelRatio}dppx)`);hn(T,"change",(()=>{E(),k(E)}),{A:!0})};k((()=>{const[E,T]=m();zt(b.U,E),h("r",[T])}))}return b},$s=()=>(Vg||(Vg=L5()),Vg),R5=(e,t,n)=>{let r=!1;const a=n?new WeakMap:!1,o=()=>{r=!0},c=u=>{if(a&&n){const d=n.map((h=>{const[m,f]=h||[];return[f&&m?(u||$j)(m,e):[],f]}));en(d,(h=>en(h[0],(m=>{const f=h[1],g=a.get(m)||[];if(e.contains(m)&&f){const w=hn(m,f,(C=>{r?(w(),a.delete(m)):t(C)}));a.set(m,yn(g,w))}else $r(g),a.delete(m)}))))}};return c(),[o,c]},s1=(e,t,n,r)=>{let a=!1;const{et:o,ct:c,rt:u,it:d,lt:h,ut:m}=r||{},[f,g]=R5(e,(()=>a&&n(!0)),u),x=o||[],w=c||[],C=Cl(x,w),v=(_,b)=>{if(!qh(b)){const k=h||lu,E=m||lu,T=[],L=[];let A=!1,O=!1;if(en(b,(M=>{const{attributeName:H,target:B,type:F,oldValue:K,addedNodes:G,removedNodes:V}=M,Z=F==="attributes",J=F==="childList",z=e===B,P=Z&&H,D=P&&lb(B,H||""),U=Ol(D)?D:null,$=P&&K!==U,te=wj(w,H)&&$;if(t&&(J||!z)){const q=Z&&$,X=q&&d&&Kx(B,d),I=(X?!k(B,H,K,U):!Z||q)&&!E(M,!!X,e,r);en(G,(Q=>yn(T,Q))),en(V,(Q=>yn(T,Q))),O=O||I}!t&&z&&$&&!k(B,H,K,U)&&(yn(L,H),A=A||te)})),g((M=>Kh(T).reduce(((H,B)=>(yn(H,$j(M,B)),Kx(B,M)?yn(H,B):H)),[]))),t)return!_&&O&&n(!1),[!1];if(!qh(L)||A){const M=[Kh(L),A];return _||n.apply(0,M),M}}},S=new UD(yt(v,!1));return[()=>(S.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:C,subtree:t,childList:t,characterData:t}),a=!0,()=>{a&&(f(),S.disconnect(),a=!1)}),()=>{if(a)return v(!0,S.takeRecords())}]};let Oa=null;const aE=(e,t,n)=>{const{ft:r}=n||{},a=Il(S5),[o]=Pr({o:!1,u:!0});return()=>{const c=[],d=zj(`<div class="${fb}"><div class="${d5}"></div></div>`)[0],h=d.firstChild,m=f=>{const g=as(f)&&!qh(f);let x=!1,w=!1;if(g){const C=f[0],[v,,S]=o(C.contentRect),_=Jx(v);w=Gj(v,S),x=!w&&!_}else w=f===!0;x||t({_t:!0,ft:w})};if(fl){if(!Df(Oa)){const w=new fl(lu);w.observe(e,{get box(){Oa=!0}}),Oa=Oa||!1,w.disconnect()}const f=Rj(m,{p:0,v:0}),g=w=>f(w),x=new fl(g);if(x.observe(Oa?e:h),yn(c,[()=>{x.disconnect()},!Oa&&Sr(e,d)]),Oa){const w=new fl(g);w.observe(e,{box:"border-box"}),yn(c,(()=>w.disconnect()))}}else if(a){const[f,g]=a(h,m,r);yn(c,Cl([db(d,u5),hn(d,"animationstart",f),Sr(e,d)],g))}else return lu;return yt($r,c)}},D5=(e,t)=>{let n;const r=d=>d.h===0||d.isIntersecting||d.intersectionRatio>0,a=yl(h5),[o]=Pr({o:!1}),c=(d,h)=>{if(d){const m=o(r(d)),[,f]=m;return f&&!h&&t(m)&&[m]}},u=(d,h)=>c(h.pop(),d);return[()=>{const d=[];if(Uw)n=new Uw(yt(u,!1),{root:e}),n.observe(a),yn(d,(()=>{n.disconnect()}));else{const h=()=>{const m=bl(a);c(m)};yn(d,aE(a,h)()),h()}return yt($r,yn(d,Sr(e,a)))},()=>n&&u(!0,n.takeRecords())]},O5=(e,t,n,r)=>{let a,o,c,u,d,h,m,f;const g=`[${la}]`,x=`[${hi}]`,w=["id","class","style","open","wrap","cols","rows"],{dt:C,vt:v,L:S,gt:_,ht:b,V:k,bt:E,yt:T,wt:L,St:A}=e,O=Y=>Bs(Y,"direction")==="rtl",M=()=>{let Y,I,Q;const ne=Rj(r,{p:()=>Y,v:()=>I,S:()=>Q,m(ie,pe){const[ye]=ie,[Ie]=pe;return[Cl(_r(ye),_r(Ie)).reduce((($e,Se)=>($e[Se]=ye[Se]||Ie[Se],$e)),{})]}}),re=(ie,pe)=>{if(as(pe)){const[ye,Ie,$e]=pe;Y=ye,I=Ie,Q=$e}else oa(pe)?(Y=pe,I=!1,Q=!1):(Y=!1,I=!1,Q=!1);ne(ie)};return re.O=ne.O,re},H={Ot:!1,B:O(C)},B=$s(),F=Il(pb),[K]=Pr({i:Lj,o:{w:0,h:0}},(()=>{const Y=F&&F.R(e,t,H,B,n).Y,Q=!(E&&k)&&ub(v,la,Ih),ne=!k&&T(o5),re=ne&&Br(_),ie=re&&A(),pe=L(Zj,Q),ye=ne&&Y&&Y(),Ie=Xh(S),$e=hb(S);return ye&&ye(),Os(_,re),ie&&ie(),Q&&pe(),{w:Ie.w+$e.w,h:Ie.h+$e.h}})),G=M(),V=Y=>{const I=O(C);zt(Y,{Ct:f!==I}),zt(H,{B:I}),f=I},Z=(Y,I)=>{const[Q,ne]=Y,re={$t:ne};return zt(H,{Ot:Q}),I||r(re),re},J=({_t:Y,ft:I})=>{const Q=I?r:G,ne={_t:Y||I,ft:I};V(ne),Q(ne,o)},z=(Y,I)=>{const[,Q]=K(),ne={xt:Q};return V(ne),Q&&!I&&G(ne,Y?c:a),ne},P=(Y,I,Q)=>{const ne={Ht:I};return V(ne),I&&!Q&&G(ne,a),ne},[D,U]=b?D5(v,Z):[],$=!k&&aE(v,J,{ft:!0}),[te,q]=s1(v,!1,P,{ct:w,et:w}),X=k&&fl&&new fl((Y=>{const I=Y[Y.length-1].contentRect;J({_t:!0,ft:Gj(I,m)}),m=I}));return[()=>{X&&X.observe(v);const Y=$&&$(),I=D&&D(),Q=te(),ne=B.G((re=>{const[,ie]=K();G({Et:re,xt:ie,_t:E},u)}));return()=>{X&&X.disconnect(),Y&&Y(),I&&I(),h&&h(),Q(),ne()}},({Dt:Y,zt:I,It:Q})=>{const ne={},[re]=Y("update.ignoreMutation"),[ie,pe]=Y("update.attributes"),[ye,Ie]=Y("update.elementEvents"),[$e,Se]=Y("update.debounce"),Ge=Ie||pe,Je=I||Q,_e=ge=>_s(re)&&!!re(ge);if(Ge){d&&d(),h&&h();const[ge,he]=s1(b||S,!0,z,{et:Cl(w,ie||[]),rt:ye,it:g,ut:(ae,Pe)=>{const{target:Ue,attributeName:de}=ae;return(!Pe&&de&&!k?qD(Ue,g,x):!1)||!!pl(Ue,`.${zr}`)||_e(ae)}});h=ge(),d=he}if(Se&&(G.O(),as($e)||oa($e)?(a=$e,o=!1,c=nE,u=rE):ou($e)?(a=$e.mutation,o=$e.resize,c=$e.event,u=$e.env):(a=!1,o=!1,c=!1,u=!1)),Je){const ge=q(),he=U&&U(),ae=d&&d();ge&&zt(ne,P(ge[0],ge[1],Je)),he&&zt(ne,Z(he[0],Je)),ae&&zt(ne,z(ae[0],Je))}return V(ne),ne},H]},oE=(e,t)=>_s(t)?t.apply(0,e):t,I5=(e,t,n,r)=>{const a=nb(r)?n:r;return oE(e,a)||t.apply(0,e)},lE=(e,t,n,r)=>{const a=nb(r)?n:r,o=oE(e,a);return!!o&&(Gh(o)?o:t.apply(0,e))},M5=(e,t)=>{const{nativeScrollbarsOverlaid:n,body:r}=t||{},{M:a,P:o,K:c}=$s(),{nativeScrollbarsOverlaid:u,body:d}=c().cancel,h=n??u,m=nb(r)?d:r,f=(a.x||a.y)&&h,g=e&&(Rf(m)?!o:m);return!!f||!!g},P5=(e,t,n,r)=>{const a="--os-viewport-percent",o="--os-scroll-percent",c="--os-scroll-direction",{K:u}=$s(),{scrollbars:d}=u(),{slot:h}=d,{dt:m,vt:f,L:g,At:x,gt:w,bt:C,V:v}=t,{scrollbars:S}=x?{}:e,{slot:_}=S||{},b=[],k=[],E=[],T=lE([m,f,g],(()=>v&&C?m:f),h,_),L=D=>{if(Xc){let U=null,$=[];const te=new Xc({source:w,axis:D}),q=()=>{U&&U.cancel(),U=null};return{Mt:Y=>{const{Tt:I}=n,Q=Hg(I)[D],ne=D==="x",re=[$g(0,ne),$g(`calc(-100% + 100cq${ne?"w":"h"})`,ne)],ie=Q?re:re.reverse();return $[0]===ie[0]&&$[1]===ie[1]||($=ie,q(),U=Y.kt.animate({clear:["left"],transform:ie},{timeline:te})),q}}}},A={x:L("x"),y:L("y")},O=()=>{const{Rt:D,Vt:U}=n,$=(te,q)=>Ij(0,1,te/(te+q)||0);return{x:$(U.x,D.x),y:$(U.y,D.y)}},M=(D,U,$)=>{const te=$?db:Bj;en(D,(q=>{te(q.Lt,U)}))},H=(D,U)=>{en(D,($=>{const[te,q]=U($);uu(te,q)}))},B=(D,U,$)=>{const te=Df($),q=te?$:!0,X=te?!$:!0;q&&M(k,D,U),X&&M(E,D,U)},F=()=>{const D=O(),U=$=>te=>[te.Lt,{[a]:Qx($)+""}];H(k,U(D.x)),H(E,U(D.y))},K=()=>{if(!Xc){const{Tt:D}=n,U=Yw(D,Br(w)),$=te=>q=>[q.Lt,{[o]:Qx(te)+""}];H(k,$(U.x)),H(E,$(U.y))}},G=()=>{const{Tt:D}=n,U=Hg(D),$=te=>q=>[q.Lt,{[c]:te?"0":"1"}];H(k,$(U.x)),H(E,$(U.y)),Xc&&(k.forEach(A.x.Mt),E.forEach(A.y.Mt))},V=()=>{if(v&&!C){const{Rt:D,Tt:U}=n,$=Hg(U),te=Yw(U,Br(w)),q=X=>{const{Lt:Y}=X,I=cu(Y)===g&&Y,Q=(ne,re,ie)=>{const pe=re*ne;return Vj(ie?pe:-pe)};return[I,I&&{transform:$g({x:Q(te.x,D.x,$.x),y:Q(te.y,D.y,$.y)})}]};H(k,q),H(E,q)}},Z=D=>{const U=D?"x":"y",te=yl(`${zr} ${D?p5:g5}`),q=yl(tE),X=yl(mb),Y={Lt:te,Pt:q,kt:X},I=A[U];return yn(D?k:E,Y),yn(b,[Sr(te,q),Sr(q,X),yt(kl,te),I&&I.Mt(Y),r(Y,B,D)]),Y},J=yt(Z,!0),z=yt(Z,!1),P=()=>(Sr(T,k[0].Lt),Sr(T,E[0].Lt),yt($r,b));return J(),z(),[{Ut:F,Nt:K,qt:G,Bt:V,Ft:B,jt:{Xt:k,Yt:J,Wt:yt(H,k)},Jt:{Xt:E,Yt:z,Wt:yt(H,E)}},P]},B5=(e,t,n,r,a)=>(o,c,u)=>{const{vt:d,L:h,V:m,gt:f,Gt:g,St:x}=t,{Lt:w,Pt:C,kt:v}=o,[S,_]=ml(333),[b,k]=ml(444),E=A=>{_s(f.scrollBy)&&f.scrollBy({behavior:"smooth",left:A.x,top:A.y})},T=()=>{const A="pointerup pointercancel lostpointercapture",O=`client${u?"X":"Y"}`,M=u?If:Mf,H=u?"left":"top",B=u?"w":"h",F=u?"x":"y",K=[];return hn(C,"pointerdown",r((G=>{const V=pl(G.target,`.${mb}`)===v,Z=V?v:C,J=e.scrollbars,z=J[V?"dragScroll":"clickScroll"],{button:P,isPrimary:D,pointerType:U}=G,{pointers:$}=J;if(P===0&&D&&z&&($||[]).includes(U)){$r(K),k();const q=!V&&(G.shiftKey||z==="instant"),X=yt(Fg,v),Y=yt(Fg,C),I=(Ue,de)=>(Ue||X())[H]-(de||Y())[H],Q=qx(Fg(f)[M])/bl(f)[B]||1,ne=Br(f)[F],re=Ue=>{Os(f,{[F]:ne+Ue})},ie=Ue=>{const{Rt:de}=n,Ae=bl(C)[B]-bl(v)[B],ue=1/Q*Ue/Ae;re(ue*de[F])},pe=G[O],ye=X(),Ie=Y(),$e=ye[M],Se=I(ye,Ie)+$e/2,Je=pe-Ie[H]-Se,_e=V?0:Je,ge=Ue=>{$r(Pe),Z.releasePointerCapture(Ue.pointerId)},he=V||q,ae=x(),Pe=[hn(g,A,ge),hn(g,"selectstart",(Ue=>Zx(Ue)),{D:!1}),hn(C,A,ge),he&&hn(C,"pointermove",(Ue=>ie(_e+Ue[O]-pe))),he&&(()=>{const Ue=Br(f);ae();const de=Br(f),Ae={x:de.x-Ue.x,y:de.y-Ue.y};(ra(Ae.x)>3||ra(Ae.y)>3)&&(x(),Os(f,Ue),E(Ae),b(ae))})];if(Z.setPointerCapture(G.pointerId),q)ie(Je);else if(!V){const Ue=Il(j5);if(Ue){const{Vt:de}=n,Ae=Ue(re,ie,yt(I),Je,de[F],z,!!u,(ue=>{ue?ae():yn(Pe,ae)}));yn(Pe,Ae),yn(K,yt(Ae,!0))}}}})))};let L=!0;return yt($r,[hn(v,"pointermove pointerleave",r(a)),hn(w,"pointerenter",r((()=>{c(Zw,!0)}))),hn(w,"pointerleave pointercancel",r((()=>{c(Zw,!1)}))),hn(w,"wheel",r((A=>{const{deltaX:O,deltaY:M,deltaMode:H}=A;L&&H===0&&cu(w)===d&&E({x:O,y:M}),L=!1,c(t1,!0),S((()=>{L=!0,c(t1)})),Zx(A)})),{D:!1,I:!0}),!m&&hn(w,"mousedown",r((()=>{const A=Xx();(Ww(A,hi)||Ww(A,la)||A===document.body)&&tb(yt(ey,h),25)}))),hn(w,"pointerdown",(()=>{const A=hn(g,"click",(M=>{O(),Kj(M)}),{A:!0,I:!0,D:!1}),O=hn(g,"pointerup pointercancel",(()=>{O(),setTimeout(A,150)}),{I:!0,D:!0})}),{I:!0,D:!0}),T(),_,k])},$5=(e,t,n,r,a,o,c)=>{let u,d,h,m,f,g=lu,x=0;const w=["mouse","pen"],C=X=>Y=>{n.Kt||X(Y)},v=X=>w.includes(X.pointerType),[S,_]=ml(),[b,k]=ml(100),[E,T]=ml(50),[L,A]=ml((()=>x)),[O,M]=P5(e,o,a,B5(t,o,a,C,(X=>v(X)&&P()))),{vt:H,Qt:B,bt:F}=o,{Ft:K,Ut:G,Nt:V,qt:Z,Bt:J}=O,z=(X,Y)=>{A();const I=Q=>{n.Kt||K(b5,Q)};if(X)I();else{const Q=h?!u:!0;x>0&&!Y?L(yt(I,Q)):I(Q)}},P=()=>{(h?!u:!m)&&(z(!0),b((()=>{z(!1)})))},D=X=>{v(X)&&(u=!0,!n.Kt&&h&&z(!0))},U=X=>{v(X)&&(u=!1,!n.Kt&&h&&z(!1))},$=X=>{K(ry,X,!0),K(ry,X,!1)},te=[A,k,T,_,()=>g(),hn(H,"pointerover",D,{A:!0}),hn(H,"pointerenter",D),hn(H,"pointerleave",U),hn(H,"pointermove",C((X=>{v(X)&&d&&P()}))),hn(B,"scroll",C((X=>{S((()=>{V(),P()})),c(X),J()})))],q=Il(pb);return[()=>yt($r,yn(te,M())),({Dt:X,It:Y,Zt:I,tn:Q})=>{const{nn:ne,sn:re,en:ie,cn:pe}=Q||{},{Ct:ye,ft:Ie}=I||{},{B:$e}=r,{M:Se,P:Ge}=$s(),{rn:Je,j:_e}=a,[ge,he]=X("showNativeOverlaidScrollbars"),[ae,Pe]=X("scrollbars.theme"),[Ue,de]=X("scrollbars.visibility"),[Ae,ue]=X("scrollbars.autoHide"),[Fe,Xe]=X("scrollbars.autoHideSuspend"),[it]=X("scrollbars.autoHideDelay"),[Ze,lt]=X("scrollbars.dragScroll"),[gt,De]=X("scrollbars.clickScroll"),[Re,ke]=X("overflow"),We=Ie&&!Y,Ce=ne||re||pe||ye||Y,nt=ie||de||ke,tt=ge&&Se.x&&Se.y,ht=!Ge&&!q,Lt=tt||ht,qt=(bn,vn,xn)=>{const hr=bn.includes(Qa)&&(Ue===mi||Ue==="auto"&&vn===Qa);return K(x5,hr,xn),hr};if(x=it,(he||ht)&&K(f5,Lt),Pe&&(K(f),K(ae,!0),f=ae),(Xe||We)&&($(!Fe),We&&Fe&&(_e.x||_e.y?(g(),E((()=>{g=hn(B,Qa,C(yt($,!0)),{A:!0})}))):$(!0))),ue&&(d=Ae==="move",h=Ae==="leave",m=Ae==="never",z(m,!0)),lt&&K(_5,Ze),De&&K(v5,!!gt),nt){const bn=qt(Re.x,Je.x,!0),vn=qt(Re.y,Je.y,!1);K(y5,!(bn&&vn))}Ce&&(V(),G(),J(),pe&&Z(),K(e1,!_e.x,!0),K(e1,!_e.y,!1),K(m5,$e&&!F))},{},O]},F5=e=>{const t=$s(),{K:n,P:r}=t,{elements:a}=n(),{padding:o,viewport:c,content:u}=a,d=Gh(e),h=d?{}:e,{elements:m}=h,{padding:f,viewport:g,content:x}=m||{},w=d?e:h.target,C=Fj(w),v=w.ownerDocument,S=v.documentElement,_=()=>v.defaultView||wr,b=yt(I5,[w]),k=yt(lE,[w]),E=yt(yl,""),T=yt(b,E,c),L=yt(k,E,u),A=ye=>{const Ie=bl(ye),$e=Xh(ye),Se=Bs(ye,ib),Ge=Bs(ye,ab);return $e.w-Ie.w>0&&!gl(Se)||$e.h-Ie.h>0&&!gl(Ge)},O=T(g),M=O===w,H=M&&C,B=!M&&L(x),F=!M&&O===B,K=H?S:O,G=H?K:w,V=!M&&k(E,o,f),Z=!F&&B,J=[Z,K,V,G].map((ye=>Gh(ye)&&!cu(ye)&&ye)),z=ye=>ye&&wj(J,ye),P=!z(K)&&A(K)?K:w,D=H?S:K,$={dt:w,vt:G,L:K,ln:V,ht:Z,gt:D,Qt:H?v:K,an:C?S:P,Gt:v,bt:C,At:d,V:M,un:_,yt:ye=>ub(K,hi,ye),wt:(ye,Ie)=>Yh(K,hi,ye,Ie),St:()=>Yh(D,hi,l5,!0)},{dt:te,vt:q,ln:X,L:Y,ht:I}=$,Q=[()=>{Ts(q,[la,zg]),Ts(te,zg),C&&Ts(S,[zg,la])}];let ne=Yx([I,Y,X,q,te].find((ye=>ye&&!z(ye))));const re=H?te:I||Y,ie=yt($r,Q);return[$,()=>{const ye=_(),Ie=Xx(),$e=ge=>{Sr(cu(ge),Yx(ge)),kl(ge)},Se=ge=>hn(ge,"focusin focusout focus blur",Kj,{I:!0,D:!1}),Ge="tabindex",Je=lb(Y,Ge),_e=Se(Ie);return di(q,la,M?"":s5),di(X,ny,""),di(Y,hi,""),di(I,Jw,""),M||(di(Y,Ge,Je||"-1"),C&&di(S,Qw,"")),Sr(re,ne),Sr(q,X),Sr(X||q,!M&&Y),Sr(Y,I),yn(Q,[_e,()=>{const ge=Xx(),he=z(Y),ae=he&&ge===Y?te:ge,Pe=Se(ae);Ts(X,ny),Ts(I,Jw),Ts(Y,hi),C&&Ts(S,Qw),Je?di(Y,Ge,Je):Ts(Y,Ge),z(I)&&$e(I),he&&$e(Y),z(X)&&$e(X),ey(ae),Pe()}]),r&&!M&&(cb(Y,hi,eE),yn(Q,yt(Ts,Y,hi))),ey(!M&&C&&Ie===te&&ye.top===ye?Y:Ie),_e(),ne=0,ie},ie]},H5=({ht:e})=>({Zt:t,fn:n,It:r})=>{const{$t:a}=t||{},{Ot:o}=n;e&&(a||r)&&uu(e,{[Mf]:o&&"100%"})},z5=({vt:e,ln:t,L:n,V:r},a)=>{const[o,c]=Pr({i:WD,o:qw()},yt(qw,e,"padding",""));return({Dt:u,Zt:d,fn:h,It:m})=>{let[f,g]=c(m);const{P:x}=$s(),{_t:w,xt:C,Ct:v}=d||{},{B:S}=h,[_,b]=u("paddingAbsolute");(w||g||(m||C))&&([f,g]=o(m));const E=!r&&(b||v||g);if(E){const T=!_||!t&&!x,L=f.r+f.l,A=f.t+f.b,O={[Tj]:T&&!S?-L:0,[Aj]:T?-A:0,[Nj]:T&&S?-L:0,top:T?-f.t:0,right:T?S?-f.r:"auto":0,left:T?S?"auto":-f.l:0,[If]:T&&`calc(100% + ${L}px)`},M={[Cj]:T?f.t:0,[kj]:T?f.r:0,[Ej]:T?f.b:0,[jj]:T?f.l:0};uu(t||n,O),uu(n,M),zt(a,{ln:f,_n:!T,F:t?M:zt({},O,M)})}return{dn:E}}},U5=(e,t)=>{const n=$s(),{vt:r,ln:a,L:o,V:c,Qt:u,gt:d,bt:h,wt:m,un:f}=e,{P:g}=n,x=h&&c,w=yt(vj,0),C={display:()=>!1,direction:te=>te!=="ltr",flexDirection:te=>te.endsWith("-reverse"),writingMode:te=>te!=="horizontal-tb"},v=_r(C),S={i:Lj,o:{w:0,h:0}},_={i:Dh,o:{}},b=te=>{m(Zj,!x&&te)},k=()=>Bs(o,v),E=(te,q)=>{const X=!_r(te).length,Y=q?!0:v.some((Ge=>{const Je=te[Ge];return Ol(Je)&&C[Ge](Je)}));if(X||!Y||!ZD(o))return{T:{x:0,y:0},k:{x:1,y:1}};b(!0);const I=Br(d),Q=hn(u,Qa,(Ge=>{const Je=Br(d);Ge.isTrusted&&Je.x===I.x&&Je.y===I.y&&qj(Ge)}),{I:!0,A:!0}),ne=m(c5,!0);Os(d,{x:0,y:0}),ne();const re=Br(d),ie=Xh(d);Os(d,{x:ie.w,y:ie.h});const pe=Br(d),ye={x:pe.x-re.x,y:pe.y-re.y};Os(d,{x:-ie.w,y:-ie.h});const Ie=Br(d),$e={x:Ie.x-re.x,y:Ie.y-re.y},Se={x:ra(ye.x)>=ra($e.x)?pe.x:Ie.x,y:ra(ye.y)>=ra($e.y)?pe.y:Ie.y};return Os(d,I),eb((()=>Q())),{T:re,k:Se}},T=(te,q)=>{const X=wr.devicePixelRatio%1!==0?1:0,Y={w:w(te.w-q.w),h:w(te.h-q.h)};return{w:Y.w>X?Y.w:0,h:Y.h>X?Y.h:0}},L=(te,q)=>{const X=(Y,I,Q,ne)=>{const re=Y===mi?hs:C5(Y),ie=gl(Y),pe=gl(Q);return!I&&!ne?hs:ie&&pe?mi:ie?I&&ne?re:I?mi:hs:I?re:pe&&ne?mi:hs};return{x:X(q.x,te.x,q.y,te.y),y:X(q.y,te.y,q.x,te.x)}},A=te=>{const q=Y=>[mi,hs,Qa].map((I=>$(sy(I),Y))),X=q(!0).concat(q()).join(" ");m(X),m(_r(te).map((Y=>$(te[Y],Y==="x"))).join(" "),!0)},[O,M]=Pr(S,yt(hb,o)),[H,B]=Pr(S,yt(Xh,o)),[F,K]=Pr(S),[G]=Pr(_),[V,Z]=Pr(S),[J]=Pr(_),[z]=Pr({i:(te,q)=>Pf(te,q,Kh(Cl(_r(te),_r(q)))),o:{}}),[P,D]=Pr({i:(te,q)=>Dh(te.T,q.T)&&Dh(te.k,q.k),o:Yj()}),U=Il(pb),$=(te,q)=>`${q?i5:a5}${VD(te)}`;return({Dt:te,Zt:q,fn:X,It:Y},{dn:I})=>{const{_t:Q,Ht:ne,xt:re,Ct:ie,ft:pe,Et:ye}=q||{},Ie=U&&U.R(e,t,X,n,te),{X:$e,Y:Se,W:Ge}=Ie||{},[Je,_e]=w5(te,n),[ge,he]=te("overflow"),ae=gl(ge.x),Pe=gl(ge.y),Ue=Q||I||re||ie||ye||_e;let de=M(Y),Ae=B(Y),ue=K(Y),Fe=Z(Y);if(_e&&g&&m(eE,!Je),Ue){ub(r,la,Ih)&&b(!0);const rt=Se&&Se(),[Qe]=de=O(Y),[Ve]=Ae=H(Y),le=Wj(o),Ye=x&&JD(f()),xt={w:w(Ve.w+Qe.w),h:w(Ve.h+Qe.h)},It={w:w((Ye?Ye.w:le.w+w(le.w-Ve.w))+Qe.w),h:w((Ye?Ye.h:le.h+w(le.h-Ve.h))+Qe.h)};rt&&rt(),Fe=V(It),ue=F(T(xt,It),Y)}const[Xe,it]=Fe,[Ze,lt]=ue,[gt,De]=Ae,[Re,ke]=de,[We]=G({x:Ze.w>0,y:Ze.h>0}),Ce=ae&&Pe&&(We.x||We.y)||ae&&We.x&&!We.y||Pe&&We.y&&!We.x,nt=I||ie||ye||ke||De||it||lt||he||_e||Ue||ne&&x,[tt]=te("update.flowDirectionStyles"),[ht,Lt]=z(tt?tt(o)||{}:k(),Y),qt=ie||pe||Lt||Y,[bn,vn]=qt?P(E(ht,!!tt),Y):D();let xn=L(We,ge);b(!1),nt&&(A(xn),xn=k5(o,We),Ge&&$e&&($e(xn,gt,Re),uu(o,Ge(xn))));const[hr,ve]=J(xn);return Yh(r,la,Ih,Ce),Yh(a,ny,Ih,Ce),zt(t,{rn:hr,Vt:{x:Xe.w,y:Xe.h},Rt:{x:Ze.w,y:Ze.h},j:We,Tt:e5(bn,Ze)}),{en:ve,nn:it,sn:lt,cn:vn||lt}}},V5=e=>{const[t,n,r]=F5(e),a={ln:{t:0,r:0,b:0,l:0},_n:!1,F:{[Tj]:0,[Aj]:0,[Nj]:0,[Cj]:0,[kj]:0,[Ej]:0,[jj]:0},Vt:{x:0,y:0},Rt:{x:0,y:0},rn:{x:hs,y:hs},j:{x:!1,y:!1},Tt:Yj()},{dt:o,gt:c,V:u,St:d}=t,{P:h,M:m}=$s(),f=!h&&(m.x||m.y),g=[H5(t),z5(t,a),U5(t,a)];return[n,x=>{const w={},v=f&&Br(c),S=v&&d();return en(g,(_=>{zt(w,_(x,w)||{})})),Os(c,v),S&&S(),u||Os(o,0),w},a,t,r]},W5=(e,t,n,r)=>{let a=!1;const o={Kt:!1,pn:!1},c=Ug(t,{}),[u,d,h,m,f]=V5(e),[g,x,w]=O5(m,h,c,(k=>{b({},k)})),[C,v,,S]=$5(e,t,o,w,h,m,r),_=k=>_r(k).some((E=>!!k[E])),b=(k,E)=>{const{Kt:T,pn:L}=o;if(L||T&&a)return!1;const{vn:A,It:O,zt:M}=k,H=A||{},B=!!O||!a,F={Dt:Ug(t,H,B),vn:H,It:B},K=E||x(zt({},F,{zt:M})),G=d(zt({},F,{fn:w,Zt:K}));v(zt({},F,{Zt:K,tn:G}));const V=_(K),Z=_(G),J=V||Z||!ob(H)||B;return a=!0,J&&n(k,{Zt:K,tn:G}),J};return[()=>{const{an:k,gt:E,St:T}=m,L=Br(k),A=[g(),u(),C(),()=>{o.pn=!0}],O=T();return Os(E,L),O(),yt($r,A)},b,k=>{const E=o.Kt;o.Kt=k,!k&&E!==k&&b({It:!0,zt:!0})},()=>{v({Dt:Ug(t,{},!1),vn:{},It:!1})},()=>({gn:o,hn:w,bn:h}),{yn:m,wn:S},f]},gb=new WeakMap,G5=(e,t)=>{gb.set(e,t)},q5=e=>{gb.delete(e)},cE=e=>gb.get(e),gs=(e,t,n)=>{const{tt:r}=$s(),a=Gh(e),o=a?e:e.target,c=cE(o);if(t&&!c){const u=[],d={},h=B=>{const F=Oj(B),K=Il(r5);return K?K(F,!0):F},m=zt({},r(),h(t)),[f,g,x]=ty(),[w,C,v]=ty(n),S=(B,F)=>{v(B,F),x(B,F)},[_,b,k,E,T,L,A]=W5(e,m,(({vn:B,It:F},{Zt:K,tn:G})=>{const{_t:V,Ct:Z,$t:J,xt:z,Ht:P,ft:D}=K,{nn:U,sn:$,en:te,cn:q}=G;S("updated",[H,{updateHints:{sizeChanged:!!V,directionChanged:!!Z,heightIntrinsicChanged:!!J,overflowEdgeChanged:!!U,overflowAmountChanged:!!$,overflowStyleChanged:!!te,scrollCoordinatesChanged:!!q,contentMutation:!!z,hostMutation:!!P,appear:!!D},changedOptions:B||{},force:!!F}])}),(B=>S("scroll",[H,B]))),O=B=>{const{gn:F}=T(),{pn:K}=F;K||(q5(o),$r(u),S("destroyed",[H,B]),g(),C())},H={options(B,F){if(B){const K=F?r():{},G=sE(m,zt(K,h(B)));ob(G)||(zt(m,G),b({vn:G}))}return zt({},m)},on:w,off:(B,F)=>{B&&F&&C(B,F)},state(){const{gn:B,hn:F,bn:K}=T(),{pn:G,Kt:V}=B,{B:Z}=F,{Vt:J,Rt:z,rn:P,j:D,ln:U,_n:$,Tt:te}=K;return zt({},{overflowEdge:J,overflowAmount:z,overflowStyle:P,hasOverflow:D,scrollCoordinates:{start:te.T,end:te.k},padding:U,paddingAbsolute:$,directionRTL:Z,sleeping:V,destroyed:G})},elements(){const{dt:B,vt:F,ln:K,L:G,ht:V,gt:Z,Qt:J}=L.yn,{jt:z,Jt:P}=L.wn,D=$=>{const{kt:te,Pt:q,Lt:X}=$;return{scrollbar:X,track:q,handle:te}},U=$=>{const{Xt:te,Yt:q}=$,X=D(te[0]);return zt({},X,{clone:()=>{const Y=D(q());return E(),Y}})};return zt({},{target:B,host:F,padding:K||G,viewport:G,content:V||G,scrollOffsetElement:Z,scrollEventElement:J,scrollbarHorizontal:U(z),scrollbarVertical:U(P)})},update:B=>b({It:B,zt:!0}),destroy:yt(O,!1),sleep:k,plugin:B=>d[_r(B)[0]]};return yn(u,[A]),G5(o,H),Jj(Xj,gs,[H,f,d]),M5(L.yn.bt,!a&&e.cancel)?(O(!0),H):(yn(u,_()),S("initialized",[H]),H.update(),H)}return c};gs.plugin=e=>{const t=as(e),n=t?e:[e],r=n.map((a=>Jj(a,gs)[0]));return t5(n),t?r:r[0]};gs.valid=e=>{const t=e&&e.elements,n=_s(t)&&t();return ou(n)&&!!cE(n.target)};gs.env=()=>{const{U:e,M:t,P:n,J:r,ot:a,st:o,K:c,Z:u,tt:d,nt:h}=$s();return zt({},{scrollbarsSize:e,scrollbarsOverlaid:t,scrollbarsHiding:n,scrollTimeline:r,staticDefaultInitialization:a,staticDefaultOptions:o,getDefaultInitialization:c,setDefaultInitialization:u,getDefaultOptions:d,setDefaultOptions:h})};gs.nonce=A5;gs.trustedTypePolicy=YD;const K5=()=>{if(typeof window>"u"){const h=()=>{};return[h,h]}let e,t;const n=window,r=typeof n.requestIdleCallback=="function",a=n.requestAnimationFrame,o=n.cancelAnimationFrame,c=r?n.requestIdleCallback:a,u=r?n.cancelIdleCallback:o,d=()=>{u(e),o(t)};return[(h,m)=>{d(),e=c(r?()=>{d(),t=a(h)}:h,typeof m=="object"?m:{timeout:2233})},d]},Y5=e=>{const{options:t,events:n,defer:r}=e||{},[a,o]=j.useMemo(K5,[]),c=j.useRef(null),u=j.useRef(r),d=j.useRef(t),h=j.useRef(n);return j.useEffect(()=>{u.current=r},[r]),j.useEffect(()=>{const{current:m}=c;d.current=t,gs.valid(m)&&m.options(t||{},!0)},[t]),j.useEffect(()=>{const{current:m}=c;h.current=n,gs.valid(m)&&m.on(n||{},!0)},[n]),j.useEffect(()=>()=>{var m;o(),(m=c.current)==null||m.destroy()},[]),j.useMemo(()=>[m=>{const f=c.current;if(gs.valid(f))return;const g=u.current,x=d.current||{},w=h.current||{},C=()=>c.current=gs(m,x,w);g?a(C,g):C()},()=>c.current],[])},X5=(e,t)=>{const{element:n="div",options:r,events:a,defer:o,children:c,...u}=e,d=n,h=j.useRef(null),m=j.useRef(null),[f,g]=Y5({options:r,events:a,defer:o});return j.useEffect(()=>{const{current:x}=h,{current:w}=m;if(!x)return;const C=x;return f(n==="body"?{target:C,cancel:{body:null}}:{target:C,elements:{viewport:w,content:w}}),()=>{var v;return(v=g())==null?void 0:v.destroy()}},[f,n]),j.useImperativeHandle(t,()=>({osInstance:g,getElement:()=>h.current}),[]),ps.createElement(d,{"data-overlayscrollbars-initialize":"",ref:h,...u},n==="body"?c:ps.createElement("div",{"data-overlayscrollbars-contents":"",ref:m},c))},Q5=j.forwardRef(X5),pt=j.forwardRef(({options:e,horizontal:t,both:n,onScrollbarGesture:r,...a},o)=>{const c=t||n,u=j.useRef(r);u.current=r;const d=j.useRef(null),h=j.useMemo(()=>({initialized:f=>{var _;(_=d.current)==null||_.call(d);const g=f.elements().scrollbarVertical,x=()=>{const b=g.handle.getBoundingClientRect(),k=g.track.getBoundingClientRect();return b.height===0||k.height===0?null:Math.max(0,k.bottom-b.bottom)};let w=null;const C=()=>{var b;(b=u.current)==null||b.call(u,"up",x()),w==null||w()},v=b=>{var k;if(b.buttons===0){C();return}(k=u.current)==null||k.call(u,"move",x())},S=()=>{var b;(b=u.current)==null||b.call(u,"down",x()),w==null||w(),window.addEventListener("pointermove",v),window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C),w=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C),w=null}};g.track.addEventListener("pointerdown",S),d.current=()=>{g.track.removeEventListener("pointerdown",S),w==null||w()}}}),[]);return j.useEffect(()=>()=>{var m;return(m=d.current)==null?void 0:m.call(d)},[]),s.jsx(Q5,{ref:o,events:h,options:{overflow:{x:c?"scroll":"hidden",y:n?"scroll":t?"hidden":"scroll"},scrollbars:{autoHide:c?"leave":"move",autoHideDelay:c?1500:600,clickScroll:"instant"},update:{elementEvents:[[":scope","mouseenter"]]},...e},...a})});pt.displayName="ScrollArea";const i1=e=>{let t;const n=new Set,r=(h,m)=>{const f=typeof h=="function"?h(t):h;if(!Object.is(f,t)){const g=t;t=m??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(x=>x(t,g))}},a=()=>t,u={setState:r,getState:a,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h))},d=t=e(r,a,u);return u},J5=(e=>e?i1(e):i1),Z5=e=>e;function e3(e,t=Z5){const n=ps.useSyncExternalStore(e.subscribe,ps.useCallback(()=>t(e.getState()),[e,t]),ps.useCallback(()=>t(e.getInitialState()),[e,t]));return ps.useDebugValue(n),n}const a1=e=>{const t=J5(e),n=r=>e3(t,r);return Object.assign(n,t),n},Zn=(e=>e?a1(e):a1);function t3(){if(typeof document>"u")return"";const e=Array.from(document.scripts).find(a=>{const o=new URL(a.src,window.location.href).pathname;return o.includes("/assets/")||o.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 uE=t3();function vs(e){return e.startsWith("/")?`${uE}${e}`||"/":e}async function me(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(vs(e),{...t,headers:r})}async function o1(e,t,n,r){try{return(await me(`/api/sessions/${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t,...n!==void 0?{content:n}:{},...r!==void 0?{attachments:r}:{}})})).ok}catch{return!1}}async function dE(e,t,n){try{const r=await me(`/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 Ne={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",DISPLAY_USE_NATIVE_SCROLLBARS:"display.useNativeScrollbars",DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS:"display.useNativeScrollbarsCodeBlocks",DISPLAY_COLLAPSE_LARGE_TOOL_CALLS:"display.collapseLargeToolCalls",DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING:"display.deferCodeHighlightWhileStreaming",DISPLAY_FEED_VIRTUALIZATION:"display.feedVirtualization",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 eh(e,t){return n=>({loading:{...n.loading,[e]:t}})}function l1(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const xb=[Ne.DISPLAY_SHOW_THINKING,Ne.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,Ne.DISPLAY_SHOW_STATS,Ne.DISPLAY_SHOW_AGENT_DEFINITIONS,Ne.DISPLAY_SHOW_WORKFLOW_BARS,Ne.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,Ne.DISPLAY_FOLLOW_SYSTEM_THEME,Ne.DISPLAY_SHOW_OPEN_IN_EDITOR,Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,Ne.DISPLAY_MAX_VISIBLE_ITEMS,Ne.DISPLAY_TERMINAL_FONT,Ne.DISPLAY_USE_NATIVE_SCROLLBARS,Ne.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS,Ne.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS,Ne.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING,Ne.DISPLAY_FEED_VIRTUALIZATION];function Fs(){return{showThinking:Bt(e=>e.settings[Ne.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:Bt(e=>e.settings[Ne.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:Bt(e=>e.settings[Ne.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:Bt(e=>e.settings[Ne.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:Bt(e=>e.settings[Ne.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:Bt(e=>e.settings[Ne.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true",maxVisibleItems:Number(Bt(e=>e.settings[Ne.DISPLAY_MAX_VISIBLE_ITEMS]??"300")),useNativeScrollbars:Bt(e=>e.settings[Ne.DISPLAY_USE_NATIVE_SCROLLBARS]??"false")==="true",useNativeScrollbarsCodeBlocks:Bt(e=>e.settings[Ne.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS]??"false")==="true",collapseLargeToolCalls:Bt(e=>e.settings[Ne.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS]??"false")==="true",deferCodeHighlightWhileStreaming:Bt(e=>e.settings[Ne.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING]??"false")==="true",feedVirtualization:Bt(e=>e.settings[Ne.DISPLAY_FEED_VIRTUALIZATION]??"false")==="true"}}const Bt=Zn(e=>({settings:{},loading:{},getSetting:async t=>{e(eh(t,!0));try{const r=await(await me(`/api/settings/${t}`)).json();return e(l1(t,r.value??"")),r.value}catch{return e(eh(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const r=await(await me(`/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(eh(t,!0));try{const a=await(await me(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(l1(t,a.value??""))}catch{e(eh(t,!1))}}})),Oc=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:xb,SETTINGS_KEYS:Ne,useDisplaySettings:Fs,useSettingsStore:Bt},Symbol.toStringTag,{value:"Module"}));function n3(){const[e,t]=j.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=j.useRef(window.innerHeight);return j.useEffect(()=>{const r=window.visualViewport;if(!r)return;const a=()=>{const o=r.offsetTop,c=r.height,u=n.current-c>100;t({offsetTop:o,height:c,keyboardVisible:u})};return a(),r.addEventListener("resize",a),r.addEventListener("scroll",a),()=>{r.removeEventListener("resize",a),r.removeEventListener("scroll",a)}},[]),e}const c1=1e4,jl=new Map;function r3(){const e=Date.now();for(const[t,n]of jl)n.expiresAt<e&&jl.delete(t)}function s3(e){if(jl.has(e))return;const t=localStorage.getItem("openfox_token"),n=fetch(vs(`/api/sessions/${e}`),{headers:t?{"x-session-token":t}:void 0}).then(async r=>r.ok?{ok:!0,data:await r.json()}:{ok:!1}).catch(()=>({ok:!1}));jl.set(e,{promise:n,expiresAt:Date.now()+c1}),setTimeout(r3,c1)}function i3(e){const t=jl.get(e);if(t&&(jl.delete(e),!(t.expiresAt<Date.now())))return t.promise}function a3(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function Mh(){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 o3{constructor(t){Le(this,"ws",null);Le(this,"handlers",new Set);Le(this,"statusHandler",null);Le(this,"baseUrl");Le(this,"isReconnecting",!1);Le(this,"connectingPromise",null);Le(this,"lastCloseCode",0);Le(this,"reconnectAttempts",0);Le(this,"manualReconnectScheduled",!1);Le(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,o)=>{try{const c=this.getUrl();this.ws=new WebSocket(c);const u=setTimeout(()=>{var d;((d=this.ws)==null?void 0:d.readyState)===WebSocket.CONNECTING&&(this.ws.close(),o(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var d;clearTimeout(u),this.isReconnecting=!1,this.reconnectAttempts=0,this.connectingPromise=null,(d=this.statusHandler)==null||d.call(this,"connected"),a()},this.ws.onclose=d=>{var h,m,f;clearTimeout(u),this.lastCloseCode=d.code,((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(m=this.statusHandler)==null||m.call(this,"disconnected"),o(new Error(`Connection closed: ${d.code}`))):(this.connectingPromise=null,(f=this.statusHandler)==null||f.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=d=>{clearTimeout(u),console.error("WebSocket error:",d),this.connectingPromise=null,o(d)},this.ws.onmessage=d=>{try{const h=JSON.parse(d.data);a3(h)&&this.handlers.forEach(m=>m(h))}catch(h){console.error("Failed to parse WebSocket message:",h)}}}catch(c){this.connectingPromise=null,o(c)}}),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=Mh(),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 l3=window.location.protocol==="https:"?"wss:":"ws:";let iy=window.location.port;iy||(iy=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const c3=`${l3}//${window.location.hostname}:${iy}${vs("/ws")}`,Vt=new o3(c3),u3=3e4;function hE(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"}}let Ic=null;const an=Zn((e,t)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,platform:null,workdir:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>Ic||(e({loading:!0,error:null}),Ic=(async()=>{try{const n=await me("/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,workdir:r.workdir??null,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}finally{Ic=null}})(),Ic),refreshModel:async()=>{try{const n=await me("/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 o=await me(`/api/providers/${n}/activate`,{method:"POST"});if(!o.ok){const u=await o.json();throw new Error(u.error??"Failed to activate provider")}const c=await o.json();return e({activeProviderId:c.activeProviderId,model:c.model,backend:c.backend,providers:a.map(u=>({...u,isActive:u.id===c.activeProviderId})),activating:!1}),!0}catch(o){return e({error:o instanceof Error?o.message:"Failed to switch provider",activating:!1}),!1}},setDefaultModel:async(n,r)=>{const{providers:a}=t();try{const o=await me("/api/default-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})});if(!o.ok)return!1;const c=await o.json();return e({activeProviderId:n,model:r,defaultModelSelection:c.defaultModelSelection,providers:a.map(u=>({...u,isActive:u.id===n}))}),!0}catch{return!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const r=await me(`/api/providers/${n}/refresh`,{method:"POST"});if(!r.ok){const c=await r.json();throw new Error(c.error??"Failed to refresh models")}const a=await r.json(),{providers:o}=t();return e({providers:o.map(c=>c.id===n?{...c,models:a.models,status:a.status}:c),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()},u3);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(),o=r.find(u=>u.id===a);if(!o)return 2e5;const c=o.models.find(u=>u.id===n);return(c==null?void 0:c.contextWindow)??2e5}})),Pt=Zn((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const r=await(await me("/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 me("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:r})});if(!a.ok){const c=await a.json().catch(()=>({}));return{error:{code:c.code||"UNKNOWN",path:c.path,message:c.error}}}const o=await a.json();return await t().listProjects(),o.project}catch{return null}},loadProject:async n=>{try{const r=await me(`/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 o=await me(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)return null;const c=await o.json();return((a=t().currentProject)==null?void 0:a.id)===n&&e({currentProject:c.project}),await t().listProjects(),c.project}catch{return null}},deleteProject:async n=>{var r;try{return(await me(`/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 o=await me(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:r})});if(!o.ok)return!1;if(((a=t().currentProject)==null?void 0:a.id)===n){const c=await o.json();e({currentProject:c.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}})),da=async(e,t,n)=>{try{const r=await me(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"}}},Ff=async(e,t,n)=>{try{const r=await me(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 fE(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let th=[];const eu=Zn()((e,t)=>{function n(){if(th.length===0)return;const a=th;th=[],e(o=>{const c={...o.logs};for(const u of a){const d=c[u.processId]??[];c[u.processId]=[...d,{offset:d.length,content:u.content,timestamp:Date.now(),stream:u.stream}]}return{logs:c}})}const r=fE(n);return{processes:[],logs:{},loading:!1,setProcesses:a=>e({processes:a}),addProcess:a=>e(o=>({processes:[...o.processes,a]})),updateProcess:(a,o)=>e(c=>({processes:c.processes.map(u=>u.id===a?{...u,...o}:u)})),removeProcess:a=>e(o=>({processes:o.processes.filter(c=>c.id!==a),logs:Object.fromEntries(Object.entries(o.logs).filter(([c])=>c!==a))})),stopProcess:async(a,o)=>{try{(await me(`/api/sessions/${o}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,o,c)=>{th.push({processId:a,stream:o,content:c}),r()},setLogs:(a,o)=>e(c=>({logs:{...c.logs,[a]:o}})),clearLogs:a=>e(o=>({logs:{...o.logs,[a]:[]}})),handleMessage:(a,o)=>{switch(a){case"backgroundProcess.started":{const{processId:c,name:u,command:d,cwd:h,pid:m,status:f}=o;e(g=>({processes:[...g.processes,{id:c,sessionId:"",name:u,command:d,cwd:h,pid:m,status:f,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const c=o.processId,u=o.stream,d=o.content;t().appendLog(c,u,d);break}case"backgroundProcess.exited":{const c=o.processId,u=o.exitCode;e(d=>({processes:d.processes.map(h=>h.id===c?{...h,status:"exited",exitCode:u}:h)}));break}case"backgroundProcess.removed":{const c=o.processId;t().removeProcess(c);break}}}}}),mE="/split-view",ay="openfox:split",pE="openfox:split:layout";function d3(){return typeof window>"u"?!1:window.location.pathname===mE}function gE(){const[e]=Nn();return e===mE}function h3(){return typeof localStorage>"u"?"columns":localStorage.getItem(pE)==="grid"?"grid":"columns"}function f3(e){typeof localStorage>"u"||localStorage.setItem(pE,e)}function m3(){if(typeof localStorage>"u")return null;const e=localStorage.getItem(ay);if(!e)return null;try{const t=JSON.parse(e);if(!Array.isArray(t.openSessionIds))return null;const n=t.openSessionIds.filter(Boolean),r=typeof t.focusedSessionId=="string"?t.focusedSessionId:null;return{openSessionIds:n,focusedSessionId:r}}catch{return null}}function p3(e){if(!(typeof localStorage>"u")){if(!e||e.openSessionIds.length===0){localStorage.removeItem(ay);return}localStorage.setItem(ay,JSON.stringify(e))}}const Hf="__default__",Qh=new Map,du=new Set;let Za=null,gi=null,vl=null,yb=0;const u1=16;function g3(e){Za=e}function ll(e=Hf){let t=Qh.get(e);return t||(t={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]},Qh.set(e,t)),t}function x3(e=Hf){Qh.delete(e),du.delete(e)}function y3(){gi!==null&&(vl==="raf"?cancelAnimationFrame(gi):clearTimeout(gi),gi=null,vl=null)}function Wg(){gi=null,vl=null,yb=Date.now();for(const e of du)Za==null||Za(e);du.clear()}function Gg(e=Hf){if(du.add(e),gi!==null)return;const t=Date.now()-yb;t>=u1?typeof document<"u"&&document.hidden?(gi=setTimeout(Wg,0),vl="timeout"):(gi=requestAnimationFrame(Wg),vl="raf"):(gi=setTimeout(Wg,u1-t),vl="timeout")}function sa(e=Hf){yb=0,y3(),du.delete(e),Za==null||Za(e);const t=Qh.get(e);t&&(t.deltaContent.length>0||t.thinkingContent.length>0||t.toolOutput.length>0||(t.messageId=null,t.deltaContent="",t.thinkingContent="",t.toolOutput=[]))}let nh=[];const nr=Zn()((e,t)=>{function n(){if(nh.length===0)return;const a=nh;nh=[],e(o=>({logs:[...o.logs,...a]}))}const r=fE(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 c=await(await me(`/api/dev-server?workdir=${encodeURIComponent(a)}`)).json();e({status:c,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const a=t().workdir;if(a)try{const c=await(await me(`/api/dev-server/config?workdir=${encodeURIComponent(a)}`)).json();e({config:c.config??null})}catch{}},fetchLogs:async()=>{const a=t().workdir;if(a)try{const u=(await(await me(`/api/dev-server/logs?workdir=${encodeURIComponent(a)}`)).json()).logs.map(d=>({stream:d.stream,content:d.content,...d.type?{type:d.type}:{}}));e({logs:u})}catch{}},clearLogs:async()=>{const a=t().workdir;if(a)try{await me(`/api/dev-server/clear-logs?workdir=${encodeURIComponent(a)}`,{method:"POST"}),e({logs:[]})}catch{}},insertMarker:async()=>{const a=t().workdir;if(a)try{await me(`/api/dev-server/insert-marker?workdir=${encodeURIComponent(a)}`,{method:"POST"}),t().fetchLogs()}catch{}},start:async()=>{const a=t().workdir;if(a)try{const c=await(await me(`/api/dev-server/start?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:c,logs:[]})}catch{}},stop:async()=>{const a=t().workdir;if(a)try{const c=await(await me(`/api/dev-server/stop?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:c})}catch{}},restart:async()=>{const a=t().workdir;if(a)try{const c=await(await me(`/api/dev-server/restart?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:c,logs:[]})}catch{}},saveConfig:async a=>{const o=t().workdir;if(o)try{const u=await(await me(`/api/dev-server/config?workdir=${encodeURIComponent(o)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();e({config:u.config??a}),t().fetchStatus()}catch{}},handleMessage:a=>{const o=t().workdir;if(o)switch(a.type){case"devServer.output":{const c=a.payload;if(c.workdir!==o)return;nh.push({stream:c.stream,content:c.content}),r();break}case"devServer.state":{const c=a.payload;if(c.workdir!==o)return;e(u=>({status:u.status?{...u.status,state:c.state,errorMessage:c.errorMessage,...c.url!==void 0?{url:c.url}:{},...c.inspectProxyPort!==void 0?{inspectProxyPort:c.inspectProxyPort}:{}}:{state:c.state,url:c.url??null,hotReload:!1,config:null,errorMessage:c.errorMessage,inspectProxyPort:c.inspectProxyPort??null}}));break}}}}}),d1={open:0,todo:0,inProgress:0,running:0,queued:0,done:0};function b3(e,t,n){e(r=>({...n.tasks?{tasks:n.tasks}:{},...n.settings?{settings:n.settings}:{},...n.counts?{counts:n.counts}:{},...n.gates?{gates:n.gates}:{},activeProjectId:t,lastError:null}))}const Ht=Zn((e,t)=>({tasks:[],settings:{slotLimit:1,queuePaused:!1},counts:d1,gates:[],summaries:{},loading:!1,activeProjectId:null,lastError:null,lastAutoLaunch:null,loadBoard:async n=>{e({loading:!0});try{const r=await me(`/api/projects/${n}/tasks`);if(!r.ok){e({loading:!1});return}const a=await r.json();b3(e,n,a),e({loading:!1})}catch{e({loading:!1})}},loadCounts:async n=>{try{const r=await me(`/api/projects/${n}/tasks/count`);if(!r.ok)return;const a=await r.json();e(o=>({counts:a.counts??o.counts,activeProjectId:n}))}catch{}},loadGates:async n=>{try{const r=await me(`/api/projects/${n}/tasks/gates`);if(!r.ok)return;const a=await r.json();e({gates:a.gates??[]})}catch{}},loadSummaries:async n=>{await Promise.all(n.map(async r=>{try{const a=await me(`/api/projects/${r}/tasks/count`);if(!a.ok)return;const o=await a.json(),c=o==null?void 0:o.counts;if(!c)return;const u=t().summaries[r];if(u&&Object.keys(c).every(d=>u[d]===c[d]))return;e(d=>({summaries:{...d.summaries,[r]:c}}))}catch{}}))},createTask:async(n,r)=>{try{const a=await me(`/api/projects/${n}/tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),o=await a.json();return a.ok?(await t().loadBoard(n),o.task):(e({lastError:o.error??"Failed to create task"}),null)}catch{return e({lastError:"Failed to create task"}),null}},updateTask:async(n,r,a)=>{try{const o=await me(`/api/projects/${n}/tasks/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await o.json();return o.ok?(await t().loadBoard(n),c.task):(e({lastError:c.error??"Failed to update task"}),null)}catch{return e({lastError:"Failed to update task"}),null}},deleteTask:async(n,r)=>{try{return(await me(`/api/projects/${n}/tasks/${r}`,{method:"DELETE"})).ok?(await t().loadBoard(n),!0):!1}catch{return!1}},duplicateTask:async(n,r)=>{try{const a=await me(`/api/projects/${n}/tasks/${r}/duplicate`,{method:"POST"}),o=await a.json();return a.ok?(await t().loadBoard(n),o.task):null}catch{return null}},moveTask:async(n,r,a,o)=>{try{const c=await me(`/api/projects/${n}/tasks/${r}/move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({to:a,...o?{reason:o}:{}})}),u=await c.json();return c.ok?(e({lastError:null}),u.autoLaunched&&e({lastAutoLaunch:u.autoLaunched}),await t().loadBoard(n),u):(e({lastError:u.error??"Failed to move task"}),null)}catch{return e({lastError:"Failed to move task"}),null}},setGateValue:async(n,r,a,o)=>{try{const c=await me(`/api/projects/${n}/tasks/${r}/gate-values/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:o})}),u=await c.json();return c.ok?(await t().loadBoard(n),u.task):(e({lastError:u.error??"Failed to set gate value"}),null)}catch{return e({lastError:"Failed to set gate value"}),null}},setGateConfig:async(n,r)=>{try{return(await me(`/api/projects/${n}/tasks/gates`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({gates:r})})).ok?(e({gates:r}),!0):!1}catch{return!1}},setSettings:async(n,r)=>{e(a=>a.activeProjectId===n?{settings:{...a.settings,...r}}:{});try{return!!(await me(`/api/projects/${n}/tasks/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).ok}catch{return!1}},reorderTask:async(n,r,a,o)=>{try{return!!(await me(`/api/projects/${n}/tasks/${r}/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:a,index:o})})).ok}catch{return!1}},clearBoard:()=>{e({tasks:[],gates:[],settings:{slotLimit:1,queuePaused:!1},counts:d1,activeProjectId:null})},clearAutoLaunch:()=>e({lastAutoLaunch:null}),handleTasksUpdate:n=>{n.counts&&e(r=>({summaries:{...r.summaries,[n.projectId]:n.counts}})),n.projectId===t().activeProjectId&&e(r=>({tasks:n.tasks??r.tasks,settings:n.settings??r.settings,counts:n.counts??r.counts,...n.gates?{gates:n.gates}:{},...n.autoLaunched?{lastAutoLaunch:n.autoLaunched}:{}}))}})),v3=[{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"}],_3=[{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"}],xE={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"},ia={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},yE={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},oy={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...ia},waiting_for_user:{...ia},phase_done:{...ia},phase_blocked:{...ia},new_message:{...yE}},agentOverrides:{}};function bE(e,t,n){var o;const r=e.events[t];if(!n)return r;const a=(o=e.agentOverrides[n])==null?void 0:o[t];return a?{soundEnabled:a.soundEnabled??r.soundEnabled,browserNotification:a.browserNotification??r.browserNotification,customSoundUrl:a.customSoundUrl!==void 0?a.customSoundUrl:r.customSoundUrl}:r}const Va=Zn((e,t)=>({settings:oy,loaded:!1,load:()=>{Bt.getState().getSetting(Ne.NOTIFICATION_SETTINGS);const r=Bt.subscribe(o=>{const c=o.settings[Ne.NOTIFICATION_SETTINGS];if(c!==void 0)try{const u=JSON.parse(c);e({settings:h1(u),loaded:!0})}catch{e({loaded:!0})}}),a=Bt.getState().settings[Ne.NOTIFICATION_SETTINGS];if(a)try{const o=JSON.parse(a);e({settings:h1(o),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),qg(n)},updateEvent:(n,r)=>{const a=t().settings,o={...a,events:{...a.events,[n]:{...a.events[n],...r}}};e({settings:o}),qg(o)},updateAgentOverride:(n,r,a)=>{var d;const o=t().settings,c={...o.agentOverrides};if(a===null){if(c[n]){const h={...c[n]};delete h[r],Object.keys(h).length===0?delete c[n]:c[n]=h}}else c[n]={...c[n],[r]:{...((d=c[n])==null?void 0:d[r])??{},...a}};const u={...o,agentOverrides:c};e({settings:u}),qg(u)}}));function qg(e){Bt.getState().setSetting(Ne.NOTIFICATION_SETTINGS,JSON.stringify(e))}function h1(e){var t,n,r,a,o;return{soundEnabled:e.soundEnabled??oy.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??oy.browserNotificationEnabled,events:{complete:{...ia,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...ia,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...ia,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...ia,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...yE,...(o=e.events)==null?void 0:o.new_message}},agentOverrides:e.agentOverrides??{}}}const f1=new Map;function S3(e){let t=f1.get(e);return t||(t=new Audio(vs(e)),t.volume=.5,f1.set(e,t)),t}let vE=typeof Notification<"u"?Notification.permission:"denied";function w3(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(vE=e,e))}const C3={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},k3={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 j3(e){typeof Notification>"u"||vE==="granted"&&(document.hasFocus()||new Notification(C3[e],{body:k3[e],icon:vs("/fox.svg"),tag:`openfox-${e}`}))}function Eu(e,t){const{settings:n}=Va.getState(),r=bE(n,e,t);if(n.soundEnabled&&r.soundEnabled){const a=r.customSoundUrl??xE[e],o=S3(a);o.currentTime=0,o.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&j3(e)}const E3=e=>Eu("complete",e),N3=e=>Eu("phase_done",e),T3=e=>Eu("phase_blocked",e),Kg=e=>Eu("waiting_for_user",e),A3=e=>Eu("new_message",e),m1=new Map;function cl(e,t){var o;const n=t===((o=e.currentSession)==null?void 0:o.id)?e.currentSession:null,r=e.sessions.find(c=>c.id===t),a=(n==null?void 0:n.mode)??(r==null?void 0:r.mode);return a==="planner"?"planner":a==="builder"?"build":"planner"}function L3(e,t){if(e.type==="chat.done"){const n=e.payload,r=cl(t,e.sessionId),a=n.agentType??r;n.reason==="complete"&&E3(a),n.reason==="waiting_for_user"&&Kg(a);return}if(e.type==="chat.path_confirmation"){const n=cl(t,e.sessionId);Kg(n);return}if(e.type==="session.confirmation_pending"){const n=cl(t,e.sessionId);Kg(n);return}if(e.type==="task.completed"){const n=cl(t,e.sessionId);N3(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=m1.get(e.sessionId)??null;if(m1.set(e.sessionId,n.phase),r===n.phase)return;const a=cl(t,e.sessionId);n.phase==="blocked"&&T3(a)}}const hu=Zn(e=>({servers:[],setServers:t=>e({servers:t}),fetchServers:async()=>{try{const t=await me("/api/mcp/servers");if(!t.ok)return;const r=((await t.json()).servers??[]).sort((a,o)=>a.name.localeCompare(o.name));e({servers:r})}catch{}}}));function fu(){return{session:null,messages:[],hiddenCount:0,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],pendingQuestions:[],visionFallbackByMessage:{},queuedMessages:[],abortInProgress:!1,restoredInput:null,activeWorkflowExecution:null,gitStatus:null,error:null}}function ea(e){return{session:e.currentSession,messages:e.messages,hiddenCount:e.hiddenCount,currentTodos:e.currentTodos,contextState:e.contextState,subAgentContextStates:e.subAgentContextStates,pendingPathConfirmations:e.pendingPathConfirmations,pendingQuestions:e.pendingQuestions,visionFallbackByMessage:e.visionFallbackByMessage,queuedMessages:e.queuedMessages,abortInProgress:e.abortInProgress,restoredInput:e.restoredInput,activeWorkflowExecution:e.activeWorkflowExecution,gitStatus:e.gitStatus,error:e.error}}function xi(e){return{currentSession:e.session,messages:e.messages,hiddenCount:e.hiddenCount,currentTodos:e.currentTodos,contextState:e.contextState,subAgentContextStates:e.subAgentContextStates,pendingPathConfirmations:e.pendingPathConfirmations,pendingQuestions:e.pendingQuestions,visionFallbackByMessage:e.visionFallbackByMessage,queuedMessages:e.queuedMessages,abortInProgress:e.abortInProgress,restoredInput:e.restoredInput,activeWorkflowExecution:e.activeWorkflowExecution,gitStatus:e.gitStatus,error:e.error}}function Is(e){var t;return e.focusedSessionId??((t=e.currentSession)==null?void 0:t.id)??null}function vr(e,t){return t?Is(e)===t||e.panes[t]!==void 0:!1}function sn(e,t,n){const r=e.panes[t],a=Is(e)===t;if(!r){if(!a)return e;const u=n(ea(e));return{...e,panes:{...e.panes,[t]:u},...xi(u)}}const o=n(r),c={...e,panes:{...e.panes,[t]:o}};return a?{...c,...xi(o)}:c}function Ph(e,t,n){const r=Is(e)===t,a={...e,panes:{...e.panes,[t]:n}};return r?{...a,...xi(n)}:a}function ly(e,t,n){return sn(e,t,r=>r.session?{...r,session:n(r.session)}:r)}function p1(e,t){if(e.panes[t]===void 0&&e.openSessionIds.includes(t)===!1)return e;const n={...e.panes};delete n[t];const r=e.openSessionIds.filter(c=>c!==t);let a=e.focusedSessionId,o={};return e.focusedSessionId===t&&(a=r.length>0?r[r.length-1]:null,o=xi(a?n[a]??fu():fu())),{...e,panes:n,openSessionIds:r,focusedSessionId:a,...o}}const Yg=new Set;function R3(e,t){return e.includes(t)?e:[...e,t]}function g1(e,t){return e.filter(n=>n!==t)}function wn(e,t){const n=t.sessionId;n&&e(r=>({unreadSessionIds:R3(r.unreadSessionIds,n)}))}function D3(e,t){const n=e.find(o=>o.id===t.id),r=t.messageCount??0,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(o=>o.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,isFavorite:!1,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(o=>o.status.type==="passed").length,messageCount:r};return n?e.map(o=>o.id===t.id?a:o):[a,...e]}function rh(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 O3(e,t,n){return e.map(r=>{const a=(n==null?void 0:n.id)===r.id?n:null,o=t.find(c=>c.id===r.id);return{...r,title:r.title??(o==null?void 0:o.title),mode:(a==null?void 0:a.mode)??(o==null?void 0:o.mode)??r.mode,phase:(a==null?void 0:a.phase)??(o==null?void 0:o.phase)??r.phase,isRunning:r.isRunning&&(o==null?void 0:o.isRunning)!==!1,messageCount:r.messageCount,recentUserPrompts:r.recentUserPrompts}})}function x1(e,t,n,r){const a=e.sessionId;if(!a)return;const o=n(),c=vr(o,a);t(u=>{let d={...u,sessions:u.sessions.map(h=>h.id===a?r(h):h)};return c&&(d=ly(d,a,h=>{const m=r(h);return{...h,...m}})),d})}function On(e,t,n,r){if(!n)return!1;const a=t();return vr(a,n)?(e(o=>sn(o,n,r)),!0):!1}function y1(e,t,n){var o,c,u;const r=n();L3(e,r);const a=r.focusedSessionId??((o=r.currentSession)==null?void 0:o.id)??null;switch(e.type){case"session.state":{const d=e.payload,h=e.sessionId,m=n();if(!(e.id!==void 0||vr(m,h)||m.pendingSessionCreate===!0&&h!==void 0))break;const g=ll(h??"").messageId;sa(h??"");const x=n().pendingSessionCreate===!0,w=d.pendingConfirmations??[],C=d.session.id,v={...n().crossSessionConfirmations};delete v[C],t(S=>{const _=S.panes[C]??(Is(S)===C?ea(S):fu()),b=d.messages.map(T=>{const L=_.messages.find(F=>F.id===T.id);if(T.id===g&&L)return L;if(!L)return T;const A=L.content??"",O=T.content??"",M=L.thinkingContent??"",H=T.thinkingContent??"";if(A.length<=O.length&&M.length<=H.length)return T;const B={...T};return A.length>O.length&&(B.content=A),M.length>H.length&&(B.thinkingContent=M),B}),k={..._,session:d.session,messages:b,hiddenCount:d.hiddenCount??0,currentTodos:[],pendingPathConfirmations:w,pendingQuestions:d.pendingQuestions??[],activeWorkflowExecution:d.activeWorkflowExecution??null,queuedMessages:_.queuedMessages},E=Ph(S,C,k);return{...E,sessions:D3(E.sessions,d.session),unreadSessionIds:g1(E.unreadSessionIds,C),crossSessionConfirmations:v,sessionsWithPendingConfirmations:Object.keys(v),workflowRetry:null,...x?{pendingSessionCreate:C}:{}}});break}case"session.list":{const d=e.payload;t(h=>({sessions:O3(d.sessions,h.sessions,h.currentSession)}));break}case"session.created":{const d=e.payload;t(h=>({sessions:h.sessions.some(m=>m.id===d.session.id)?h.sessions.map(m=>m.id===d.session.id?{...m,...d.session}:m):[d.session,...h.sessions],searchSessions:null}));break}case"session.deleted":{const d=e.payload;t(h=>{const m={...h.panes};return delete m[d.sessionId],{panes:m,openSessionIds:h.openSessionIds.filter(f=>f!==d.sessionId),unreadSessionIds:g1(h.unreadSessionIds,d.sessionId),searchSessions:null}}),n().listSessions();break}case"session.deletedAll":{t({searchSessions:null}),n().listSessions();break}case"session.running":{const d=e.payload;x1(e,t,n,m=>({...m,isRunning:d.isRunning}));const h=e.sessionId;if(!h||!vr(n(),h))break;d.isRunning||t(m=>sn(m,h,f=>({...f,abortInProgress:!1,queuedMessages:[]}))),d.isRunning&&t(m=>sn(m,h,f=>({...f,restoredInput:null})));break}case"chat.message":{On(t,n,e.sessionId,d=>{const h=e.payload;if(d.messages.some(f=>f.id===h.message.id))return d;const m=h.message.role==="user";return{...d,messages:[...d.messages,h.message],session:d.session&&m?{...d.session,messageCount:(d.session.messageCount??0)+1}:d.session}})||(e.payload.message.role==="user"&&t(h=>({sessions:h.sessions.map(m=>m.id===e.sessionId?{...m,messageCount:m.messageCount+1}:m)})),wn(t,e));break}case"chat.message_updated":{const d=e.payload,h=e.sessionId,m=n().panes[h??""],f=(m==null?void 0:m.messages.find(x=>x.id===d.messageId))??(((c=n().currentSession)==null?void 0:c.id)===h?n().messages.find(x=>x.id===d.messageId):void 0);d.updates.isStreaming===!1&&(f==null?void 0:f.isStreaming)===!0&&sa(h??""),On(t,n,h,x=>({...x,messages:x.messages.map(w=>{if(w.id!==d.messageId)return w;const C={...w,...d.updates},v=C.content??"",S=w.content??"";return S.length>v.length&&(C.content=S),C})}))||wn(t,e);break}case"chat.delta":{const d=e.sessionId,h=e.payload;On(t,n,d,m=>{if(d===a&&!Yg.has(h.messageId)){Yg.add(h.messageId);const g=h.subAgentType?"sub-agent":cl(n(),d);A3(g)}const f=ll(d??"");return f.messageId=h.messageId,f.deltaContent+=h.content,Gg(d??""),m})||wn(t,e);break}case"chat.thinking":{const d=e.sessionId,h=e.payload;On(t,n,d,m=>{const f=ll(d??"");return f.messageId=h.messageId,f.thinkingContent+=h.content,Gg(d??""),m})||wn(t,e);break}case"chat.tool_preparing":{const d=e.sessionId,h=e.payload;On(t,n,d,m=>{var v;const f=m.messages.find(S=>S.id===h.messageId);if(!f||((v=f.toolCalls)==null?void 0:v.find((S,_)=>_===h.index)))return m;const x=f.preparingToolCalls??[],w=x.findIndex(S=>S.index===h.index);let C;return w>=0?C=x.map((S,_)=>_===w?{...S,arguments:h.arguments}:S):C=[...x,{index:h.index,name:h.name,...h.arguments?{arguments:h.arguments}:{}}],{...m,messages:m.messages.map(S=>S.id===h.messageId?{...S,preparingToolCalls:C}:S)}})||wn(t,e);break}case"chat.tool_call":{const d=e.sessionId,h=e.payload,m=f=>{var v;const g=(f.toolCalls??[]).length,x=(v=f.preparingToolCalls)==null?void 0:v.filter(S=>S.index!==g),w=ll(d??""),C=w.toolOutput.filter(S=>S.callId===h.callId);return C.length>0&&(w.toolOutput=w.toolOutput.filter(S=>S.callId!==h.callId)),{...f,toolCalls:[...f.toolCalls??[],{id:h.callId,name:h.tool,arguments:h.args,startedAt:Date.now(),...C.length>0?{streamingOutput:C.map(S=>({stream:S.stream,content:S.content,timestamp:Date.now()}))}:{}}],...x&&x.length>0?{preparingToolCalls:x}:{preparingToolCalls:void 0}}};On(t,n,d,f=>({...f,messages:f.messages.map(g=>g.id===h.messageId?m(g):g)}))||wn(t,e);break}case"chat.tool_output":{const d=e.sessionId,h=e.payload;On(t,n,d,m=>{const f=ll(d??"");return f.messageId=h.messageId,f.toolOutput.push({messageId:h.messageId,callId:h.callId,stream:h.stream,content:h.output}),Gg(d??""),m})||wn(t,e);break}case"chat.tool_result":{const d=e.sessionId,h=e.payload;On(t,n,d,m=>({...m,messages:m.messages.map(f=>{var g;return f.id===h.messageId?{...f,toolCalls:(g=f.toolCalls)==null?void 0:g.map(x=>x.id===h.callId?{...x,result:h.result}:x)}:f})}))||wn(t,e);break}case"chat.vision_fallback":{const d=e.sessionId,h=e.payload;On(t,n,d,m=>{const f=`${h.messageId}-${h.attachmentId}`,g={...m.visionFallbackByMessage};return g[f]={type:h.type,attachmentId:h.attachmentId,filename:h.filename,description:h.description},{...m,visionFallbackByMessage:g}})||wn(t,e);break}case"chat.todo":{const d=e.payload;On(t,n,e.sessionId,h=>({...h,currentTodos:d.todos}))||wn(t,e);break}case"chat.progress":{vr(n(),e.sessionId)||wn(t,e);break}case"chat.format_retry":{vr(n(),e.sessionId)||wn(t,e);break}case"chat.done":{const d=e.sessionId,h=e.payload;if(!vr(n(),d)){wn(t,e);break}sa(d??""),Yg.delete(h.messageId);const m=h.stats;t(f=>sn(f,d??"",g=>({...g,messages:g.messages.map(x=>x.id===h.messageId?{...x,isStreaming:!1,stats:m??x.stats,completeReason:h.reason,preparingToolCalls:void 0}:x),visionFallbackByMessage:{}}))),h.reason!=="error"&&t({workflowRetry:null});break}case"chat.message_removed":{const d=e.sessionId,h=e.payload,m=new Set(h.messageIds);On(t,n,d,f=>({...f,messages:f.messages.filter(g=>!m.has(g.id)),error:null}));break}case"chat.step_retry":{const d=e.sessionId,h=e.payload;if(!vr(n(),d)){wn(t,e);break}On(t,n,d,m=>({...m,error:null})),t({workflowRetry:{stepName:h.stepName,attempt:h.attempt,retryInMs:h.retryInMs}});break}case"chat.error":{const d=e.sessionId,h=e.payload;if(!vr(n(),d)){wn(t,e);break}sa(d??""),console.error("Chat error:",h.error,"recoverable:",h.recoverable),t(m=>sn(m,d??"",f=>({...f,error:{code:"CHAT_ERROR",message:h.error}})));break}case"chat.path_confirmation":{const d=e.sessionId,h=e.payload,m={callId:h.callId,tool:h.tool,paths:h.paths,workdir:h.workdir,reason:h.reason};On(t,n,d,f=>({...f,pendingPathConfirmations:rh(f.pendingPathConfirmations,m)}))||(wn(t,e),d&&t(f=>({crossSessionConfirmations:{...f.crossSessionConfirmations,[d]:rh(f.crossSessionConfirmations[d]??[],m)},sessionsWithPendingConfirmations:f.sessionsWithPendingConfirmations.includes(d)?f.sessionsWithPendingConfirmations:[...f.sessionsWithPendingConfirmations,d]})));break}case"session.confirmation_pending":{const d=e.sessionId,h=e.payload,m={callId:h.callId,tool:h.tool,paths:h.paths,workdir:h.workdir,reason:h.reason};!On(t,n,d,f=>({...f,pendingPathConfirmations:rh(f.pendingPathConfirmations,m)}))&&d&&t(f=>({crossSessionConfirmations:{...f.crossSessionConfirmations,[d]:rh(f.crossSessionConfirmations[d]??[],m)},sessionsWithPendingConfirmations:f.sessionsWithPendingConfirmations.includes(d)?f.sessionsWithPendingConfirmations:[...f.sessionsWithPendingConfirmations,d]}));break}case"session.confirmation_resolved":{const d=e.sessionId,h=e.payload;d&&(t(m=>{const g=(m.crossSessionConfirmations[d]??[]).filter(w=>w.callId!==h.callId),x={...m.crossSessionConfirmations};return g.length===0?delete x[d]:x[d]=g,{crossSessionConfirmations:x,sessionsWithPendingConfirmations:Object.keys(x)}}),On(t,n,d,m=>({...m,pendingPathConfirmations:m.pendingPathConfirmations.filter(f=>f.callId!==h.callId)})));break}case"chat.ask_user":{const d=e.sessionId,h=e.payload;On(t,n,d,m=>{const f={callId:h.callId,question:h.question,type:h.type??"text",options:h.options??void 0};return{...m,pendingQuestions:[...m.pendingQuestions.filter(g=>g.callId!==h.callId),f]}})||wn(t,e);break}case"mode.changed":{const d=e.sessionId,h=e.payload;On(t,n,d,m=>m.session?{...m,session:{...m.session,mode:h.mode}}:m)||wn(t,e);break}case"phase.changed":{const d=e.payload;x1(e,t,n,h=>({...h,phase:d.phase}));break}case"workflow.execution_changed":{const d=e.sessionId,h=e.payload,m={...h.currentStepId?{currentStepId:h.currentStepId}:{},...h.currentStepName?{currentStepName:h.currentStepName}:{},...h.pendingChoices?{pendingChoices:h.pendingChoices}:{}};On(t,n,d,f=>{const g=f.activeWorkflowExecution;return g?{...f,activeWorkflowExecution:{...g,status:h.status,...m}}:{...f,activeWorkflowExecution:{id:h.executionId,sessionId:e.sessionId??"",workflowId:h.workflowId,workflowName:h.workflowName,...h.workflowColor?{workflowColor:h.workflowColor}:{},status:h.status,...m,stepOutput:{},params:{},createdAt:Date.now(),updatedAt:Date.now()}}})||wn(t,e),h.status!=="running"&&t({workflowRetry:null});break}case"criteria.updated":{const d=e.sessionId,h=e.payload;On(t,n,d,m=>m.session?{...m,session:{...m.session,criteria:h.criteria}}:m)||wn(t,e);break}case"metadata.updated":{const d=e.sessionId,h=e.payload;On(t,n,d,m=>m.session?{...m,session:{...m.session,metadataEntries:{...m.session.metadataEntries,[h.key]:h.entries}}}:m)||wn(t,e);break}case"context.state":{const d=e.payload,h=e.sessionId,m=vr(n(),h);d.subAgentId?m&&h&&t(f=>sn(f,h,g=>({...g,subAgentContextStates:{...g.subAgentContextStates,[d.subAgentId]:d.context}}))):m&&h?t(f=>sn(f,h,g=>({...g,contextState:d.context}))):wn(t,e);break}case"session.name_generated":{const d=e.payload,h=e.sessionId,m=n().focusedSessionId??((u=n().currentSession)==null?void 0:u.id);t(f=>{var x;const g=h&&((x=f.panes[h])!=null&&x.session)?sn(f,h,w=>({...w,session:{...w.session,metadata:{...w.session.metadata,title:d.name}}})):f;return{...g,sessions:g.sessions.map(w=>w.id===h?{...w,title:d.name}:w),currentSession:m===h&&g.currentSession?{...g.currentSession,metadata:{...g.currentSession.metadata,title:d.name}}:g.currentSession}});break}case"queue.state":{const d=e.payload,h=e.sessionId??Is(n());h&&vr(n(),h)?t(m=>sn(m,h,f=>({...f,queuedMessages:d.messages??[]}))):t({queuedMessages:d.messages??[]});break}case"mcp.servers.changed":{const d=e.payload;if(d!=null&&d.servers){const h=[...d.servers].sort((m,f)=>m.name.localeCompare(f.name));hu.getState().setServers(h)}else window.dispatchEvent(new CustomEvent("mcp-servers-changed"));break}case"git.status":{const d=e.payload,h=e.sessionId??Is(n());h&&vr(n(),h)?t(m=>sn(m,h,f=>({...f,gitStatus:{branch:d.branch,diff:d.diff}}))):t({gitStatus:{branch:d.branch,diff:d.diff}});break}case"devServer.output":case"devServer.state":{nr.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{eu.getState().handleMessage(e.type,e.payload);break}case"tasks.update":{Ht.getState().handleTasksUpdate(e.payload);break}case"error":{const d=e.payload;console.error("Server error:",d);const h=e.sessionId??Is(n());t(m=>h&&vr(m,h)?sn(m,h,f=>({...f,error:{code:d.code,message:d.message}})):{error:{code:d.code,message:d.message}});break}}}let Mc=!1,Es=null;const Xg=new Set,Jo=new Set,sh=new Map;let Pc=null;function I3(e,t,n){return e==null?void 0:e.map(r=>{const a=t.filter(o=>o.callId===r.id);return a.length===0?r:(n.add(r.id),{...r,streamingOutput:[...r.streamingOutput??[],...a.map(o=>({stream:o.stream,content:o.content,timestamp:Date.now()}))]})})}function b1(e,t){return e.includes(t)?e:[...e,t]}async function v1(e,t,n,r,a){try{const c=await(await me(`/api/sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,messageKind:r})})).json();c.queueState&&a(u=>sn(u,e,d=>({...d,queuedMessages:c.queueState})))}catch(o){console.error("Error queueing message:",o)}}function _1(e,t){return e.map(n=>{const r=t.sessions.find(c=>c.id===n.id),a=t.panes[n.id],o=a==null?void 0:a.session;return{...n,title:n.title??(r==null?void 0:r.title),mode:(o==null?void 0:o.id)===n.id?o.mode:(r==null?void 0:r.mode)??n.mode,phase:(o==null?void 0:o.id)===n.id?o.phase:(r==null?void 0:r.phase)??n.phase,isRunning:n.isRunning&&(r==null?void 0:r.isRunning)!==!1,messageCount:n.messageCount,...n.recentUserPrompts!==void 0&&{recentUserPrompts:n.recentUserPrompts}}})}function Jn(e,t){var r;const n=e.panes[t];return n||(((r=e.currentSession)==null?void 0:r.id)===t?ea(e):null)}const Oe=Zn((e,t)=>{const n=()=>{const o=t();p3({openSessionIds:o.openSessionIds,focusedSessionId:o.focusedSessionId})};g3(o=>{const c=ll(o);if(!c.messageId)return;const u=c.deltaContent.length>0,d=c.thinkingContent.length>0,h=c.toolOutput.length>0;!u&&!d&&!h||e(m=>vr(m,o)?sn(m,o,f=>{const g=f.messages.find(C=>C.id===c.messageId);if(!g)return f;const x={...g};let w=!1;if(u&&(x.content=x.content+c.deltaContent,c.deltaContent="",w=!0),d&&(x.thinkingContent=(x.thinkingContent??"")+c.thinkingContent,c.thinkingContent="",w=!0),h){const C=new Set;x.toolCalls=I3(x.toolCalls,c.toolOutput,C);const v=c.toolOutput.filter(S=>!C.has(S.callId));c.toolOutput=v,w=!0}return w?{...f,messages:f.messages.map(C=>C.id===c.messageId?x:C)}:f}):m)});function r(o,c,u,d,h,m){return{sessionId:c,workflowId:o.workflowId,resumeFrom:o.currentStepId,stepOutput:o.stepOutput,...o.params&&Object.keys(o.params).length>0?{params:o.params}:{},...o.subGroup?{subGroup:o.subGroup}:{},...m?{userChoice:m}:{},...u!=null&&u.trim()?{content:u}:{},...d&&d.length>0?{attachments:d}:{},...h?{messageKind:h}:{}}}async function a(o,c,u=!1){var d,h;if(!(!u&&Xg.has(o))){if(!u&&Jo.has(o)){c&&e(m=>{var g;const f=m.panes[o]??(((g=m.currentSession)==null?void 0:g.id)===o?ea(m):null);return f?{focusedSessionId:o,...xi(f),unreadSessionIds:m.unreadSessionIds.filter(x=>x!==o)}:m});return}Xg.add(o);try{const m=t(),f=Is(m),g=f!==null&&f!==o,x={...m.crossSessionConfirmations};if(g&&f){const k=((d=m.panes[f])==null?void 0:d.pendingPathConfirmations)??m.pendingPathConfirmations;k.length>0&&(x[f]=[...x[f]??[],...k])}e(k=>{const E=k.panes[o],T=E??(Is(k)===o?ea(k):fu()),L=c&&g&&!E;return{focusedSessionId:c?o:k.focusedSessionId,panes:{...k.panes,[o]:T},...c?xi(L?fu():T):{},unreadSessionIds:k.unreadSessionIds.filter(A=>A!==o),crossSessionConfirmations:x,sessionsWithPendingConfirmations:Object.keys(x),workflowRetry:null,pendingSessionCreate:!1}}),g&&f&&sa(f);const w=i3(o),C=w?w.then(async k=>{if(k.ok)return k.data;const E=await me(`/api/sessions/${o}`);return E.ok?await E.json():null}):me(`/api/sessions/${o}`).then(async k=>k.ok?await k.json():null),v=me(`/api/sessions/${o}/background-processes`),S=await C;if(!S){((h=t().panes[o])==null?void 0:h.session)==null&&(e(k=>p1(k,o)),n());return}const _=S.messages??[],b={...t().crossSessionConfirmations};delete b[o],e(k=>{const T={...k.panes[o]??ea(k),session:S.session,messages:_,hiddenCount:S.hiddenCount??0,contextState:S.contextState??null,queuedMessages:S.queueState??[],pendingPathConfirmations:S.pendingConfirmations??[],pendingQuestions:S.pendingQuestions??[],activeWorkflowExecution:S.activeWorkflowExecution??null};return{...Ph(k,o,T),crossSessionConfirmations:b,sessionsWithPendingConfirmations:Object.keys(b)}}),Vt.send("session.load",{sessionId:o});try{const k=await v;if(k.ok){const E=await k.json();eu.getState().setProcesses(E.processes??[])}}catch{}Jo.add(o)}catch{}finally{Xg.delete(o)}}}return{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],searchSessions:null,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,workflowRetry:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,pendingUpdate:null,panes:{},openSessionIds:[],focusedSessionId:null,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let c=!1;try{c=(await(await me("/api/auth")).json()).requiresAuth}catch{}if(c&&!Vt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Vt.onStatusChange(u=>{var d,h;if(e({connectionStatus:u}),u==="connected"){if(d3())t().listHomeSessions();else{const f=(d=t().currentSession)==null?void 0:d.projectId;f&&t().listSessions(f)}Pt.getState().listProjects();const m=t().focusedSessionId??((h=t().currentSession)==null?void 0:h.id);m&&t().loadSession(m)}else(u==="disconnected"||u==="reconnecting")&&Jo.clear()});try{await Vt.connect(),Mc||(Mc=!0,Es=Vt.subscribe(u=>{y1(u,e,t)}))}catch(u){console.error("Failed to connect:",u);const d=Vt.getLastCloseCode();if(!Vt.hasToken()&&(d===1006||d===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}Es&&(Es(),Es=null),Mc=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Vt.disconnect(),Es&&(Es(),Es=null),Mc=!1,Jo.clear(),e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Vt.disconnect(),Es&&(Es(),Es=null),Mc=!1,Jo.clear(),e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async o=>{try{const c=await fetch(vs("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:o})});if(!c.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:u}=await c.json();Vt.setToken(u),e({showPasswordModal:!1}),t().connect();const{listProjects:d}=Pt.getState(),{fetchConfig:h}=an.getState();d(),h(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Vt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(o,c)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const d=await me("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:o,title:c})});if(!d.ok)return e({pendingSessionCreate:!1}),null;const h=await d.json();e({searchSessions:null});try{Vt.send("session.load",{sessionId:h.session.id})}catch{}return h.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async(o,c=!1)=>{await a(o,!0,c)},openPane:async(o,c={})=>{const u=c.focus??!1;e(d=>({openSessionIds:b1(d.openSessionIds,o)})),await a(o,u),u&&t().focusPane(o),n()},closePane:o=>{sa(o),x3(o),e(c=>p1(c,o)),n()},focusPane:o=>{e(c=>{var d;if(Is(c)===o)return c;const u=c.panes[o]??(((d=c.currentSession)==null?void 0:d.id)===o?ea(c):null);return u?{...c,focusedSessionId:o,openSessionIds:b1(c.openSessionIds,o),...xi(u)}:c}),n()},reorderPane:(o,c)=>{e(u=>{const d=u.openSessionIds.indexOf(o);if(d===-1)return u;const h=d+c;if(h<0||h>=u.openSessionIds.length)return u;const m=[...u.openSessionIds],[f,g]=[m[d],m[h]];return m[d]=g,m[h]=f,{...u,openSessionIds:m}}),n()},isPaneOpen:o=>{const c=t();return c.openSessionIds.includes(o)||c.panes[o]!==void 0},enterSplitView:async(o,c)=>{const u=o.filter(Boolean);if(u.length===0)return;t().listHomeSessions();const d=u.filter(m=>!t().panes[m]);await Promise.all(d.map(m=>t().openPane(m,{focus:!1})));const h=c&&u.includes(c)?c:u[0];e(m=>{const f=[...new Set([...m.openSessionIds,...u])],g=m.panes[h]??null;return{openSessionIds:f,focusedSessionId:h,...g?xi(g):{},unreadSessionIds:m.unreadSessionIds.filter(x=>x!==h)}}),n()},exitSplitView:()=>{n()},listSessions:async(o,c=20)=>{const u=o??"global";if(sh.has(u))return sh.get(u);const d=(async()=>{var h;try{const m=new URLSearchParams;m.set("limit",String(c)),o&&m.set("projectId",o);const g=await(await me(`/api/sessions?${m.toString()}`)).json(),x=g.sessions??[];e(C=>({sessions:_1(x,C),sessionsHasMore:o?g.hasMore??!1:!0}));const w=g.pendingConfirmationsBySession;if(w){const C=t().focusedSessionId??((h=t().currentSession)==null?void 0:h.id),v={};for(const[S,_]of Object.entries(w))S!==C&&(v[S]=_);e({crossSessionConfirmations:v,sessionsWithPendingConfirmations:Object.keys(v)})}}catch{}finally{sh.delete(u)}})();return sh.set(u,d),d},listHomeSessions:async()=>{try{const o=await me("/api/sessions/home");if(!o.ok)return;const c=await o.json();e(u=>({sessions:_1(c.sessions,u),sessionsHasMore:!1}))}catch{}},ensureFullSessionList:async()=>{if(!t().searchSessions)return Pc||(Pc=(async()=>{try{const u=(await(await me("/api/sessions")).json()).sessions??[];e({searchSessions:u})}catch{}finally{Pc=null}})(),Pc)},loadMoreSessions:async o=>{const c=t();if(!(c.sessionsPaginationLoading||!c.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const u=new URLSearchParams;u.set("limit","20"),u.set("offset",String(c.sessions.length)),u.set("projectId",o);const h=await(await me(`/api/sessions?${u.toString()}`)).json(),m=h.sessions??[];e(f=>({sessions:[...f.sessions,...m.map(g=>{const x=f.sessions.find(w=>w.id===g.id);return(x==null?void 0:x.isRunning)===!1?{...g,isRunning:!1}:g})],sessionsHasMore:h.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async o=>{var c;try{return(await me(`/api/sessions/${o}`,{method:"DELETE"})).ok?(e({searchSessions:null}),await t().listSessions(),(t().focusedSessionId===o||((c=t().currentSession)==null?void 0:c.id)===o)&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(o,c)=>{try{return(await me(`/api/sessions/${o}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:c})})).ok?(e({searchSessions:null}),await t().listSessions(),e(d=>{const h=d.panes[o];if(!h)return{};const m=h.session?{...h.session,metadata:{...h.session.metadata,title:c}}:h.session;return{...Ph(d,o,{...h,session:m})}}),!0):!1}catch{return!1}},toggleFavorite:async(o,c)=>{e(u=>({sessions:u.sessions.map(d=>d.id===o?{...d,isFavorite:c}:d)}));try{const u=await me(`/api/sessions/${o}/favorite`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isFavorite:c})});return u.ok?(await t().listSessions(),!0):(console.warn("Failed to toggle favorite",{sessionId:o,isFavorite:c,status:u.status}),e(d=>({sessions:d.sessions.map(h=>h.id===o?{...h,isFavorite:!c}:h)})),!1)}catch(u){return console.error("Error toggling favorite:",u),e(d=>({sessions:d.sessions.map(h=>h.id===o?{...h,isFavorite:!c}:h)})),!1}},deleteAllSessions:async o=>{try{return(await me(`/api/projects/${o}/sessions`,{method:"DELETE"})).ok?(e({searchSessions:null}),await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{var c;const o=t().focusedSessionId??((c=t().currentSession)==null?void 0:c.id);o&&sa(o),Jo.clear(),e(u=>{const d={...u.panes};return o&&delete d[o],{currentSession:null,messages:[],hiddenCount:0,currentTodos:[],contextState:null,restoredInput:null,pendingSessionCreate:!1,focusedSessionId:null,panes:d,openSessionIds:u.openSessionIds.filter(h=>h!==o),unreadSessionIds:o?u.unreadSessionIds.filter(h=>h!==o):u.unreadSessionIds}})},sendMessage:async(o,c,u,d)=>{const h=Jn(t(),o);if(!(h!=null&&h.session))return;e(f=>sn(f,o,g=>({...g,error:null})));const m=h.activeWorkflowExecution;if(m&&m.status==="running"){Vt.send("runner.launch",r(m,o,c,u,d==null?void 0:d.messageKind));return}try{const f=c==null?void 0:c.trim(),g=u&&u.length>0,x={};f&&(x.content=c),g&&(x.attachments=u),d!=null&&d.messageKind&&(x.messageKind=d.messageKind);const C=await(await me(`/api/sessions/${o}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)})).json();C.queueState&&e(v=>sn(v,o,S=>({...S,queuedMessages:C.queueState})))}catch(f){console.error("Error sending message:",f)}},stopGeneration:async o=>{var c,u;if((c=Jn(t(),o))!=null&&c.session&&!((u=t().panes[o])!=null&&u.abortInProgress)){sa(o),e(d=>sn(d,o,h=>({...h,abortInProgress:!0})));try{const h=await(await me(`/api/sessions/${o}/stop`,{method:"POST"})).json();if(h.queuedMessages&&h.queuedMessages.length>0){const m=h.queuedMessages.map(f=>f.content).join(`
|
|
67
|
+
`);e(f=>sn(f,o,g=>({...g,restoredInput:m})))}}catch(d){console.error("Error stopping generation:",d)}}},continueGeneration:async o=>{var c;if((c=Jn(t(),o))!=null&&c.session)try{await me(`/api/sessions/${o}/continue`,{method:"POST"})}catch(u){console.error("Error continuing generation:",u)}},launchWorkflow:(o,c,u,d,h,m,f)=>{var x;if(!((x=Jn(t(),o))!=null&&x.session))return;const g={sessionId:o};c!=null&&c.trim()&&(g.content=c),u&&u.length>0&&(g.attachments=u),d&&(g.workflowId=d),h&&(g.subGroup=h),m&&(g.params=m),g.scope=f??"auto",Vt.send("runner.launch",g)},continueWorkflow:(o,c)=>{const u=Jn(t(),o),d=u==null?void 0:u.activeWorkflowExecution;!d||d.status!=="waiting"||Vt.send("runner.launch",r(d,o,void 0,void 0,void 0,c))},retryWorkflowStep:o=>{var d;const c=Jn(t(),o),u=c==null?void 0:c.activeWorkflowExecution;!u||!u.currentStepId||(d=c==null?void 0:c.session)!=null&&d.isRunning||(e({workflowRetry:null}),e(h=>sn(h,o,m=>({...m,error:null}))),Vt.send("runner.launch",r(u,o,void 0,void 0,void 0)))},exitWorkflow:o=>{var c;(c=Jn(t(),o))!=null&&c.session&&Vt.send("workflow.exit",{sessionId:o})},switchMode:async(o,c)=>{var u;if((u=Jn(t(),o))!=null&&u.session)try{const d=await me(`/api/sessions/${o}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:c})});if(!d.ok){console.error("Failed to switch mode:",await d.json());return}const h=await d.json();h.session&&e(m=>ly(m,o,()=>h.session)),h.messages&&e(m=>sn(m,o,f=>({...f,messages:h.messages,hiddenCount:h.hiddenCount??0})))}catch(d){console.error("Error switching mode:",d)}},switchDangerLevel:async(o,c)=>{var u;if((u=Jn(t(),o))!=null&&u.session)try{const d=await me(`/api/sessions/${o}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:c})});if(!d.ok){console.error("Failed to switch danger level:",await d.json());return}const h=await d.json();h.session&&e(m=>ly(m,o,()=>h.session))}catch(d){console.error("Error switching danger level:",d)}},editCriteria:async(o,c)=>{var u;if((u=Jn(t(),o))!=null&&u.session)try{const d=await me(`/api/sessions/${o}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:c})});d.ok||console.error("Failed to update criteria:",await d.json())}catch(d){console.error("Error updating criteria:",d)}},compactContext:o=>{var c;(c=Jn(t(),o))!=null&&c.session&&Vt.send("context.compact",{sessionId:o})},setSessionProvider:async(o,c,u)=>{var d;try{if(!((d=Jn(t(),o))!=null&&d.session))return null;const h=await me(`/api/sessions/${o}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:c,...u?{model:u}:{}})});if(!h.ok)return null;const m=await h.json();return e(f=>{const g=f.panes[o]??ea(f),x={...g,session:m.session,messages:m.messages??g.messages,hiddenCount:m.hiddenCount??g.hiddenCount,contextState:m.contextState??g.contextState};return Ph(f,o,x)}),m.session}catch{return null}},updateContextState:o=>{var u;const c=t().focusedSessionId??((u=t().currentSession)==null?void 0:u.id);c&&e(d=>sn(d,c,h=>({...h,contextState:o})))},updateSubAgentContextState:(o,c)=>{var d;const u=t().focusedSessionId??((d=t().currentSession)==null?void 0:d.id);u&&e(h=>sn(h,u,m=>({...m,subAgentContextStates:{...m.subAgentContextStates,[o]:c}})))},clearSubAgentContextState:o=>{var u;const c=t().focusedSessionId??((u=t().currentSession)==null?void 0:u.id);c&&e(d=>sn(d,c,h=>{const m={...h.subAgentContextStates};return delete m[o],{...h,subAgentContextStates:m}}))},confirmPath:async(o,c,u,d=!1)=>{var h;if((h=Jn(t(),o))!=null&&h.session)try{const m=await me(`/api/sessions/${o}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:c,approved:u,alwaysAllow:d})});if(!m.ok){const f=await m.json().catch(()=>({}));console.error("Error confirming path:",f.error??`HTTP ${m.status}`)}}catch(m){console.error("Error confirming path:",m)}},answerQuestion:async(o,c,u,d)=>{var h;if((h=Jn(t(),o))!=null&&h.session){try{await me(`/api/sessions/${o}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:c,answer:u,skip:d})})}catch(m){console.error("Error answering question:",m)}e(m=>sn(m,o,f=>({...f,pendingQuestions:f.pendingQuestions.filter(g=>g.callId!==c)})))}},queueAsap:async(o,c,u,d)=>{var h;(h=Jn(t(),o))!=null&&h.session&&await v1(o,c,u,d,e)},queueCompletion:async(o,c,u,d)=>{var h;(h=Jn(t(),o))!=null&&h.session&&await v1(o,c,u,d,e)},cancelQueued:async(o,c)=>{var u;if((u=Jn(t(),o))!=null&&u.session)try{const h=await(await me(`/api/sessions/${o}/queue/${c}`,{method:"DELETE"})).json();h.queueState&&e(m=>sn(m,o,f=>({...f,queuedMessages:h.queueState})))}catch(d){console.error("Error canceling queued message:",d)}},clearError:()=>{var c;const o=t().focusedSessionId??((c=t().currentSession)==null?void 0:c.id);o&&e(u=>sn(u,o,d=>({...d,error:null})))},clearRestoredInput:o=>{var u;const c=o??t().focusedSessionId??((u=t().currentSession)==null?void 0:u.id);c&&e(d=>sn(d,c,h=>({...h,restoredInput:null})))},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},queueUpdate:o=>{e({pendingUpdate:o})},triggerPendingUpdate:()=>{const o=t().pendingUpdate;o&&(e({pendingUpdate:null}),Vt.send("context.applyDynamic",{sessionId:o}))},handleServerMessage:o=>{y1(o,e,t)}}}),ih=[],ah=[];function zf(e){return Oe(t=>{var n,r,a,o,c,u;return e?(n=t.panes)!=null&&n[e]?((o=(a=(r=t.panes)==null?void 0:r[e])==null?void 0:a.session)==null?void 0:o.isRunning)??!1:((c=t.currentSession)==null?void 0:c.id)===e?t.currentSession.isRunning??!1:!1:((u=t.currentSession)==null?void 0:u.isRunning)??!1})}function M3(e){return Oe(t=>{var n,r;if(e){const a=(n=t.panes)==null?void 0:n[e];return a?a.queuedMessages??ih:((r=t.currentSession)==null?void 0:r.id)===e?t.queuedMessages??ih:ih}return t.queuedMessages??ih})}function P3(e){return Oe(t=>t.abortInProgress)}function B3(e){return Oe(t=>{var n,r;if(e){const a=(n=t.panes)==null?void 0:n[e];return a?a.pendingQuestions??ah:((r=t.currentSession)==null?void 0:r.id)===e?t.pendingQuestions??ah:ah}return t.pendingQuestions??ah})}function $3(){const e=Oe(a=>a.connect),t=Oe(a=>a.connectionStatus),n=Va(a=>a.load),r=Dl("/p/:projectId/s/:sessionId/readonly")[0];return j.useEffect(()=>{r||e()},[e,r]),j.useEffect(()=>{r||t==="connected"&&n()},[t,n,r]),{connectionStatus:t}}const F3="modulepreload",H3=function(e){return"/"+e},S1={},se=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let c=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),d=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));a=c(n.map(h=>{if(h=H3(h),h in S1)return;S1[h]=!0;const m=h.endsWith(".css"),f=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${f}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":F3,m||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),m)return new Promise((x,w)=>{g.addEventListener("load",x),g.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return a.then(c=>{for(const u of c||[])u.status==="rejected"&&o(u.reason);return t().catch(o)})},z3=[{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"}],U3=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"}]'),_E={tokens:z3,presets:U3},SE=_E.tokens,ur=_E.presets;function w1(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}function V3(){try{const e=localStorage.getItem("openfox:systemThemePrefs");if(e)return JSON.parse(e)}catch{}return{darkPreset:"dark",lightPreset:"light"}}const Zt=Zn((e,t)=>{const n=V3();return{currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:w1(),followSystemTheme:!0,isSystem:!1,systemDarkPreset:n.darkPreset,systemLightPreset:n.lightPreset,activeUserPresetId:null,applySavedTheme:()=>{const{getSavedTheme:r,applyPreset:a,applyTokens:o}=t(),c=r();if(c)try{const u=JSON.parse(c);u.preset&&u.tokens?(a(u.preset),e({basePreset:u.preset}),o(u.tokens)):u.preset?a(u.preset):u.tokens&&o(u.tokens)}catch{a("dark")}else a("dark")},applyPreset:r=>{if(ur.find(o=>o.id===r))if(r==="system"){const o=window.matchMedia("(prefers-color-scheme: dark)"),{systemDarkPreset:c,systemLightPreset:u,userPresets:d}=t(),h=o.matches?c:u,m=d.find(f=>f.id===h);e(m?{basePreset:"system",currentPreset:m.basePreset,customTokens:{...m.tokens},isCustom:!0,isCustomizing:!1,isSystem:!0,activeUserPresetId:m.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 o;const{currentPreset:r}=t(),a=((o=ur.find(c=>c.id===r))==null?void 0:o.tokens)??{};e({basePreset:r,customTokens:{...a},isCustom:!0,isCustomizing:!0})},setCustomToken:(r,a)=>{e(o=>({customTokens:{...o.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 u,d;const{basePreset:r,customTokens:a,isCustom:o}=t();if(o&&r)return{...((u=ur.find(m=>m.id===r))==null?void 0:u.tokens)??{},...a};if(o)return{...SE.reduce((h,m)=>({...h,[m.key]:m.defaultValue}),{}),...a};const c=ur.find(h=>h.id===t().currentPreset);return(c==null?void 0:c.tokens)??((d=ur[0])==null?void 0:d.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const r=t().getActiveTheme(),a=document.documentElement;Object.entries(r).forEach(([o,c])=>{a.style.setProperty(`--${o}`,c)})},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 se(async()=>{const{useSettingsStore:o}=await Promise.resolve().then(()=>Oc);return{useSettingsStore:o}},void 0);await a.getState().setSetting(Ne.DISPLAY_THEME,r)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:r=>{e({followSystemTheme:r}),se(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Oc);return{useSettingsStore:a,SETTINGS_KEYS:o}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:o})=>{a.getState().setSetting(o.DISPLAY_FOLLOW_SYSTEM_THEME,String(r))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const r=window.matchMedia("(prefers-color-scheme: dark)"),a=c=>{const{followSystemTheme:u,systemDarkPreset:d,systemLightPreset:h}=t();if(!u)return;const m=c?d:h;t().applyPreset(m),t().saveTheme(JSON.stringify({preset:m}))},o=c=>a(c.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},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:o,currentPreset:c}=t(),u=a||c,d=ur.find(f=>f.id===u),h={id:"custom-"+Date.now(),name:r,basePreset:u,mode:d==null?void 0:d.mode,tokens:{...o}},m=[...t().userPresets,h];e({userPresets:m}),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((o,c)=>c!==r);e({userPresets:a}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:w1()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),se(async()=>{const{useSettingsStore:r}=await Promise.resolve().then(()=>Oc);return{useSettingsStore:r}},void 0).then(({useSettingsStore:r})=>{r.getState().setSetting(Ne.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})},setSystemDarkPreset:r=>{e({systemDarkPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset})),se(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Oc);return{useSettingsStore:a,SETTINGS_KEYS:o}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:o})=>{a.getState().setSetting(o.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})),se(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Oc);return{useSettingsStore:a,SETTINGS_KEYS:o}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:o})=>{a.getState().setSetting(o.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r}))}),t().isSystem&&t().applyPreset("system")}}});function W3({canLoad:e,projectId:t,currentProjectId:n}){const r=Pt(c=>c.loadProject),a=Oe(c=>c.listSessions),o=Oe(c=>c.clearSession);j.useEffect(()=>{e&&t&&(n!==t&&r(t),a(t),o())},[e,t,n,r,a,o])}function G3({canLoad:e,projectId:t,sessionId:n,currentProjectId:r,currentSessionId:a}){const o=Oe(h=>h.loadSession),c=Pt(h=>h.loadProject),u=Oe(h=>h.listSessions),d=Oe(h=>h.pendingSessionCreate);j.useEffect(()=>{e&&t&&r!==t&&c(t)},[e,t,r,c]),j.useEffect(()=>{e&&n&&a!==n&&o(n),e&&t&&u(t)},[e,n,a,o,u,d,t])}function q3({className:e="w-5 h-5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function Uf({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function wE({className:e="w-5 h-5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 K3({className:e="w-3 h-3 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 eo({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.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 Hs({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function mu({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("rect",{x:"3.5",y:"4",width:"7",height:"16",rx:"1.5",strokeWidth:1.8}),s.jsx("rect",{x:"13.5",y:"4",width:"7",height:"16",rx:"1.5",strokeWidth:1.8})]})}function bb({className:e="w-3 h-3 text-text-muted",rotate:t,direction:n="down"}){return s.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:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:n==="up"?"M5 15l7-7 7 7":n==="right"?"M9 18l6-6-6-6":"M19 9l-7 7-7-7"})})}function gn(e){return s.jsx(bb,{direction:"down",...e})}function vb(e){return s.jsx(bb,{direction:"up",...e})}function Y3(e){return s.jsx(bb,{direction:"right",...e})}function X3({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function El({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 _b({className:e="w-3 h-3"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 Sb({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("circle",{cx:"12",cy:"5",r:"2"}),s.jsx("circle",{cx:"12",cy:"12",r:"2"}),s.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function wb({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 Cr({className:e="w-5 h-5 text-accent-primary"}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:s.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 Q3({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 J3({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 CE({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.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 Vf({className:e="w-3 h-3"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 Z3({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 cy({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function kE({className:e="w-[18px] h-[18px]"}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function Cb({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.jsx("path",{d:"M9.5 2h4.5v4.5"}),s.jsx("path",{d:"M14 2L7.5 8.5"})]})}function Wf({className:e="w-3 h-3",color:t}){return s.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M8 5v14l11-7z"})})}function Hr({className:e="w-3 h-3 text-accent-primary"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function eO({className:e="w-5 h-5"}){return s.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:s.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 Gf({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 jE({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.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"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function tO({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return s.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[s.jsx("title",{children:"Running"}),s.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),s.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function pu({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:s.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 qf({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 kb({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function nO({className:e="w-3.5 h-3.5 shrink-0",color:t}){return s.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:s.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 Kf({className:e="w-5 h-5"}){return s.jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"4.5",width:"4.5",height:"4.5",rx:"1",fill:"currentColor",stroke:"none"}),s.jsx("rect",{x:"3",y:"10.5",width:"4.5",height:"4.5",rx:"1",fill:"currentColor",stroke:"none"}),s.jsx("rect",{x:"3",y:"16.5",width:"4.5",height:"4.5",rx:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 6.75h11"}),s.jsx("path",{d:"M10 12.75h8"}),s.jsx("path",{d:"M10 18.75h9"})]})}function EE({className:e="w-4 h-4",color:t}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:t??"currentColor",children:[s.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),s.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})}function rO({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("polyline",{points:"4 17 10 11 4 5"}),s.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function Si({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 _i({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 sO({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 uy({className:e="w-2.5 h-2.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 Ss({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:s.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 jb({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.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 iO({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 aO({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 C1({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 dy(){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 k1(e,t){const n=Vt.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:dy(),type:e,payload:t}))}const fs=Zn((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 me(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(r.ok){const a=await r.json();e({sessions:a});const o=Vt.ws;if(o&&o.readyState===WebSocket.OPEN)for(const c of a)o.send(JSON.stringify({id:dy(),type:"terminal.subscribe",payload:{sessionId:c.id}}))}}catch(r){console.error("Failed to fetch terminals:",r)}},createSession:async(n,r)=>{try{const a=await me("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:r})});if(a.ok){const o=await a.json();e(u=>({sessions:[...u.sessions,o]}));const c=Vt.ws;c&&c.readyState===WebSocket.OPEN&&c.send(JSON.stringify({id:dy(),type:"terminal.subscribe",payload:{sessionId:o.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,r)=>{k1("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,a)=>{k1("terminal.resize",{sessionId:n,cols:r,rows:a})},killSession:async n=>{try{(await me(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(a=>({sessions:a.sessions.filter(o=>o.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 o=a.sessions.filter(c=>c.id!==r);return o.length===0&&a.isOpen?{sessions:[],isOpen:!1}:{sessions:o}});break}}}}));Vt.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&fs.getState().handleMessage(e)});const bi=Zn((e,t)=>({status:"idle",current:null,latest:null,check:async n=>{if(!(!n&&t().status==="checking")){e({status:"checking"});try{const r=await fetch(vs(`/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"})}}}})),Ds={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 hy(e){if(!e)return structuredClone(Ds);try{const t=JSON.parse(e),n=r=>t[r]===void 0?structuredClone(Ds[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(Ds)}}function j1(e){return e.code.startsWith("Digit")?e.code.slice(-1):/^[a-zA-Z]$/.test(e.key)?e.key.toLowerCase():e.key}function Eb(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 oO(e){return e.type==="double-press"}function NE(e){return e.type==="chord"}function lO(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 TE(e,t){const n=t.modifiers.includes("ctrl"),r=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),o=t.modifiers.includes("shift");return lO(e,t.key)&&e.ctrlKey===n&&e.metaKey===r&&e.altKey===a&&e.shiftKey===o}function Nu(){const e=Bt(t=>t.settings[Ne.KEYBINDINGS]);return hy(e)}function cO(e,t,n){const r=j.useRef(0),a=j.useRef(t);a.current=t,j.useEffect(()=>{if(!e)return;const o=e.threshold??300,c=u=>{if(u.key!==e.key)return;const d=e.key==="Control",h=e.key==="Shift",m=e.key==="Alt",f=e.key==="Meta";if(!d&&u.ctrlKey||!h&&u.shiftKey||!m&&u.altKey||!f&&u.metaKey)return;const g=Date.now();g-r.current<o?(u.preventDefault(),u.stopPropagation(),a.current(),r.current=0):r.current=g};return window.addEventListener("keydown",c,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",c,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function uO(e,t){const n=j.useRef(t);n.current=t,j.useEffect(()=>{if(!e)return;const r=a=>{TE(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e])}function gu(e,t,n){cO(e&&oO(e)?e:void 0,t,n),uO(e&&NE(e)?e:void 0,t)}function dO(e,t,n){const r=j.useRef(n);r.current=n,j.useEffect(()=>{const a=o=>{for(let c=0;c<e.length;c++){const u=e[c];if(!u)continue;const d=t[c];if(d&&NE(u)&&TE(o,u)){o.preventDefault(),r.current(d.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var wi=uj();const Yf=j.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...r},a)=>s.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:s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));Yf.displayName="IconButton";const hO="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",vi=j.forwardRef((e,t)=>s.jsx(Yf,{ref:t,icon:hO,title:"Edit",...e}));vi.displayName="EditButton";const fO="M6 18L18 6M6 6l12 12",Nb=j.forwardRef((e,t)=>s.jsx(Yf,{ref:t,icon:fO,...e}));Nb.displayName="CloseButton";const mO={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 Et({label:e,title:t,headerRight:n,size:r="md",minHeight:a,children:o,footer:c,className:u,onClose:d,isOpen:h,closeOnBackdropClick:m=!0,closeOnEscape:f=!0,showCloseButton:g=!0,scrollable:x=!0}){const[w,C]=j.useState(!1),v=h!==void 0,S=v?h:w,_=j.useCallback(()=>{v||C(!0)},[v]),b=j.useCallback(()=>{v||C(!1),d==null||d()},[v,d]);j.useEffect(()=>{if(!S||!f)return;const E=T=>{if(T.key==="Escape"){const L=document.activeElement;if(L&&(L.tagName==="INPUT"||L.tagName==="TEXTAREA"))return;T.stopPropagation(),b()}};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[S,b,f]);const k=e&&(typeof e=="string"?s.jsx("button",{type:"button",onClick:_,className:u,children:e}):s.jsx("span",{onClick:_,className:u,style:{cursor:"pointer"},children:e}));return s.jsxs(s.Fragment,{children:[k,S&&(typeof document<"u"?wi.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:m?b:void 0}),s.jsxs("div",{role:"dialog",className:`relative w-full ${mO[r]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||n||g)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 border-b border-border",children:[t&&s.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),s.jsxs("div",{className:"flex items-center gap-2 ml-auto w-full sm:w-auto min-w-0",children:[n,g&&s.jsx(Nb,{onClick:b,"aria-label":"Close"})]})]}),x?s.jsx(pt,{className:"p-4 flex-1 min-h-0",style:a?{minHeight:a}:void 0,children:o}):s.jsx("div",{className:"p-4 flex-1 min-h-0 overflow-hidden flex flex-col",style:a?{minHeight:a}:void 0,children:o}),c&&s.jsx("div",{className:"px-4 py-3 border-t border-border",children:c})]})]}),document.body):null)]})}function pO({value:e,defaultUrl:t,disabled:n,onChange:r}){const a=e??t;return s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:a,disabled:n,onChange:o=>{const c=o.target.value;r(c===t?null:c)},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:_3.map(({url:o,label:c})=>s.jsx("option",{value:o,title:c,children:c.split(" ")[0]},o))}),s.jsx(gn,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const E1=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function gO(){const e=Va(d=>d.settings),t=Va(d=>d.update),n=Va(d=>d.updateEvent),r=Va(d=>d.updateAgentOverride),a=Va(d=>d.load);j.useEffect(()=>{a()},[a]);const o=async()=>{await w3()==="granted"&&t({...e,browserNotificationEnabled:!0})},c=(d,h,m,f)=>{d==="general"?n(h,{[m]:f}):r(d,h,{[m]:f})},u=(d,h,m)=>{d==="general"?n(h,{customSoundUrl:m}):r(d,h,{customSoundUrl:m})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),s.jsx(N1,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>t({...e,soundEnabled:d})}),s.jsx(N1,{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"?o():t({...e,browserNotificationEnabled:d})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&s.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),s.jsx("div",{className:"border border-border rounded overflow-hidden",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:s.jsxs("tr",{className:"border-b border-border",children:[s.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),E1.map(d=>s.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:d.label},d.key))]})}),s.jsx("tbody",{children:v3.map(d=>s.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[s.jsx("td",{className:"px-3 py-2",children:s.jsx("div",{className:"text-text-primary text-xs",children:d.label})}),E1.map(h=>{const m=bE(e,d.key,h.key==="general"?void 0:h.key),f=xE[d.key];return s.jsx("td",{className:"px-2 py-2 align-top",children:s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:s.jsx("input",{type:"checkbox",checked:m.soundEnabled,onChange:g=>c(h.key,d.key,"soundEnabled",g.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),s.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:s.jsx("input",{type:"checkbox",checked:m.browserNotification,onChange:g=>c(h.key,d.key,"browserNotification",g.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),m.soundEnabled&&e.soundEnabled&&s.jsx(pO,{value:m.customSoundUrl,defaultUrl:f,disabled:!e.soundEnabled,onChange:g=>u(h.key,d.key,g)})]})},h.key)})]},d.key))})]})})]})]})}function N1({label:e,description:t,checked:n,onChange:r}){return s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer group",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),s.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:t})]}),s.jsx("div",{className:"flex-shrink-0 pt-0.5",children:s.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:s.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 ot=j.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:r,...a},o)=>{const c="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",u={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 s.jsx("button",{ref:o,className:`${c} ${u[e]} ${d[t]} ${n}`,...a,children:r})});ot.displayName="Button";async function T1(e,t,n){try{const r=await me(e,t);return r.ok?(await n(),{success:!0}):{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}}function Ia(e,t){return t?`${e}?workdir=${encodeURIComponent(t)}`:e}const Vn=Zn((e,t)=>({defaults:[],userItems:[],projectItems:[],items:[],selectedDirectory:null,diagnostics:[],loading:!1,workdir:null,setWorkdir:n=>{e({workdir:n})},fetchSkills:async n=>{const r=n??t().workdir;e({loading:!0});try{const o=await(await me(Ia("/api/skills",r))).json();e({defaults:o.defaults??[],userItems:o.userItems??[],projectItems:o.projectItems??[],items:o.items??[],selectedDirectory:o.selectedDirectory??null,diagnostics:o.diagnostics??[],loading:!1})}catch{e({loading:!1})}},toggleSkill:async n=>{try{const a=await(await me(Ia(`/api/skills/${n}/toggle`,t().workdir),{method:"POST"})).json();e(o=>({defaults:o.defaults.map(c=>c.id===n?{...c,enabled:a.enabled}:c),userItems:o.userItems.map(c=>c.id===n?{...c,enabled:a.enabled}:c),projectItems:o.projectItems.map(c=>c.id===n?{...c,enabled:a.enabled}:c),items:o.items.map(c=>c.id===n?{...c,enabled:a.enabled}:c)}))}catch{}},fetchSkill:async n=>{try{const r=await me(Ia(`/api/skills/${n}`,t().workdir));return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await me(`/api/skills/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(n,r)=>{const a=await da("POST",Ia("/api/skills",t().workdir),{...n,destination:r});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,r)=>{const a=await da("PUT",Ia(`/api/skills/${n}`,t().workdir),r);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const r=await me(Ia(`/api/skills/${n}`,t().workdir),{method:"DELETE"}),a=await r.json();return r.ok?(e(o=>({userItems:o.userItems.filter(c=>c.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,r)=>Ff(Ia(`/api/skills/${n}/duplicate`,t().workdir),()=>t().fetchSkills(),r),selectDirectory:async n=>T1("/api/skills/library",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})},t().fetchSkills),removeDirectory:async()=>{await me("/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 T1("/api/skills/install",{method:"POST",body:r},t().fetchSkills)}}));function Tu(){const[e,t]=j.useState({id:null,type:null}),n=j.useCallback(o=>t({id:o,type:"delete"}),[]),r=j.useCallback(()=>t({id:null,type:null}),[]),a=j.useCallback((o,c)=>e.id===o&&e.type===c,[e.id,e.type]);return{requestDelete:n,clearConfirm:r,isConfirming:a}}function Jh({onConfirm:e,onCancel:t}){return s.jsxs("div",{className:"flex items-center gap-1",children:[s.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"}),s.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 Zh({onClick:e}){return s.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:s.jsx(Si,{})})}function xu({onClick:e}){return s.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:s.jsx(El,{})})}function ss({label:e,value:t,onChange:n,placeholder:r,readOnly:a,hint:o,mono:c}){return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,o&&s.jsx("span",{className:"text-text-muted ml-1",children:o})]}),s.jsx("input",{value:t,onChange:u=>n(u.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 ${c?"font-mono":""} ${a?"opacity-60":""}`})]})}function AE({onCancel:e,onSave:t,saving:n,saveDisabled:r}){return s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(ot,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(ot,{variant:"primary",onClick:t,disabled:n||r,children:n?"Saving...":"Save"})]})}function _l({message:e}){return s.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function Xf({value:e,onChange:t}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),s.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:[s.jsx("option",{value:"user",children:"Global config"}),s.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]})}function LE({description:e,onNew:t,loading:n,hasItems:r,children:a}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("p",{className:"text-text-secondary text-sm",children:e}),s.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:s.jsx(ot,{variant:"primary",size:"sm",onClick:t,children:"+ New"})})]}),n&&!r?s.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."}):r?a:s.jsx("div",{className:"text-text-muted text-sm",children:"No items defined."})]})}function RE({label:e="Custom",children:t}){return s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),s.jsx("div",{className:"space-y-2",children:t})]})}function DE({description:e,onNew:t,newLabel:n="+ New"}){return s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("p",{className:"text-text-secondary text-sm",children:e}),s.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:s.jsx(ot,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function Tb({loading:e,hasItems:t,loadingLabel:n,emptyLabel:r,children:a}){return e&&!t?s.jsx("div",{className:"text-text-muted text-sm",children:n}):t?s.jsx("div",{className:"space-y-4",children:a}):r?s.jsx("div",{className:"text-text-muted text-sm",children:r}):null}function OE({name:e,id:t,nameLabel:n="Name",idLabel:r="ID",namePlaceholder:a="My Item",idPlaceholder:o="my-item",nameHint:c,readOnlyId:u=!1,readOnlyHint:d="(read-only)",onNameChange:h,onIdChange:m}){return s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(ss,{label:n,value:e,onChange:h,placeholder:a,hint:c}),s.jsx(ss,{label:r,value:t,onChange:m,readOnly:u,placeholder:o,hint:u?d:void 0,mono:!0})]})}function IE(e={}){const{initialData:t={}}=e,[n,r]=j.useState("list"),[a,o]=j.useState(null),[c,u]=j.useState(""),[d,h]=j.useState(!1),[m,f]=j.useState(t),g=j.useCallback(()=>{f(t),u(""),o(null)},[t]),x=j.useCallback(S=>{r(S),S==="list"&&g()},[g]),w=j.useCallback(S=>{f(_=>typeof S=="function"?S(_):S)},[]),C=j.useCallback((S,_={})=>{o(S),r("edit"),f({..._}),u("")},[]),v=j.useCallback(()=>{o(null),r("edit"),f(t),u("")},[t]);return{view:n,editingId:a,formError:c,saving:d,formData:m,setView:x,setEditingId:o,setFormError:u,setFormData:w,setSaving:h,resetForm:g,startEditing:C,startNew:v}}function Nl({isOpen:e,onClose:t,onConfirm:n,title:r,message:a,confirmLabel:o="Confirm",confirmVariant:c="primary",disabled:u=!1}){return s.jsx(Et,{isOpen:e,onClose:t,title:r,size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"text-text-secondary",children:a}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(ot,{variant:"secondary",onClick:t,disabled:u,children:"Cancel"}),s.jsx(ot,{variant:c,onClick:n,disabled:u,autoFocus:!0,children:o})]})]})})}const xO={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function fa({size:e="md",className:t=""}){return s.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${xO[e]} ${t}`})}function yO({text:e,...t}){return s.jsxs("div",{className:"text-center",children:[s.jsx(fa,{...t,className:"mx-auto mb-4"}),e&&s.jsx("div",{className:"text-text-secondary",children:e})]})}function Au(e){return e.split(/[\\/]/).filter(Boolean).pop()??""}function bO(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 Ab(e,t=28){if(e.length<=t)return e;const n=e.includes("\\")?"\\":"/",r=e.split(/[\\/]/).filter(Boolean);if(r.length<=2)return e;const a=r[0],o=r[r.length-1],c=r.slice(1,-1).join(n),u=t-a.length-o.length-3;if(u<0)return e;const d=c.slice(0,Math.floor(u/2)),h=c.slice(-Math.ceil(u/2));return`${e.startsWith(n)?n:""}${a}${n}${d}...${h}${n}${o}`}function Gt(){return typeof window>"u"||typeof window.matchMedia!="function"?!0:!window.matchMedia("(hover: none) and (pointer: coarse)").matches}const Ms=j.forwardRef(({className:e="",...t},n)=>s.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}));Ms.displayName="Input";function Qf({onSelect:e,onClose:t,initialPath:n}){const[r,a]=j.useState(null),[o,c]=j.useState(!0),[u,d]=j.useState(""),[h,m]=j.useState(-1),f=j.useRef(null),g=j.useRef(null),x=j.useCallback(async b=>{c(!0),d(""),m(-1);try{const k=b?`/api/directories?path=${encodeURIComponent(b)}`:"/api/directories",T=await(await me(k)).json();a(T)}catch(k){console.error("Failed to load directories:",k)}finally{c(!1)}},[]);j.useEffect(()=>{x(n)},[n,x]);const w=bO((r==null?void 0:r.current)??""),C=(r==null?void 0:r.directories.filter(b=>u===""||b.name.toLowerCase().includes(u.toLowerCase())))??[],v=[...!u&&(r!=null&&r.parent)?[{type:"parent",path:r.parent,name:".."}]:[],...C.map(b=>({type:"dir",path:b.path,name:b.name}))];j.useEffect(()=>{m(u?0:-1)},[u,C.length]),j.useEffect(()=>{if(h>=0&&g.current){const b=g.current.querySelector(`[data-index="${h}"]`);b==null||b.scrollIntoView({block:"nearest"})}},[h]);const S=b=>{var k;if(b.key==="ArrowDown")b.preventDefault(),m(E=>Math.min(E+1,v.length-1));else if(b.key==="ArrowUp")b.preventDefault(),m(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?x(v[h].path):e(v[h].path)}else b.key==="Escape"&&(d(""),Gt()&&((k=f.current)==null||k.focus()))},_=s.jsx("div",{className:"flex flex-col gap-2",children:s.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})});return s.jsx(Et,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",footer:_,scrollable:!1,children:s.jsxs("div",{ref:g,className:"flex flex-col flex-1 min-h-0 -m-4",onKeyDown:S,children:[s.jsxs("div",{className:"flex-shrink-0 bg-bg-secondary border-b border-border",children:[r&&s.jsx("div",{className:"px-3 pt-3 pb-1",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsxs("div",{className:"flex items-center flex-wrap min-w-0",children:[w.map((b,k)=>s.jsxs("span",{className:"flex items-center shrink-0",children:[s.jsx("span",{className:"text-text-muted",children:"/"}),s.jsx("button",{onClick:()=>x(b.path),className:`px-1 ${k===w.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:b.name})]},b.path)),w.length===0&&s.jsx("button",{onClick:()=>x("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]}),(r==null?void 0:r.current)&&s.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"})]})}),s.jsx("div",{className:"px-4 py-2",children:s.jsxs("div",{className:"relative",children:[s.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:s.jsx(_i,{})}),s.jsx(Ms,{autoFocus:Gt(),ref:f,value:u,onChange:b=>d(b.target.value),placeholder:"Filter directories...",className:"w-full pl-9"})]})})]}),s.jsx(pt,{className:"flex-1",children:o?s.jsx("div",{className:"p-8 text-center",children:s.jsx(fa,{size:"sm"})}):v.length===0?s.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:u?"No matching directories":"No subdirectories"}):s.jsx("div",{className:"divide-y divide-border",children:v.map((b,k)=>s.jsxs("div",{"data-index":k,className:`group flex items-center ${k===h?"bg-accent-primary/20":"hover:bg-bg-tertiary/50"}`,children:[s.jsxs("button",{onClick:()=>{x(b.path)},className:"flex-1 flex items-center gap-3 p-3 text-left min-w-0",tabIndex:-1,children:[b.type==="parent"?s.jsx(q3,{className:"w-5 h-5 text-text-muted shrink-0"}):s.jsx(Cr,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"truncate",children:b.name}),b.type==="dir"&&s.jsx(gn,{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"&&s.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 ME(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 vO(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 ME(r,t.map(a=>({path:a.webkitRelativePath.slice(r.length+1),file:a})))}function _O(e){return new Promise((t,n)=>e.file(t,n))}async function PE(e,t=""){const n=e.createReader(),r=[];for(;;){const o=await new Promise((c,u)=>n.readEntries(c,u));if(!o.length)break;r.push(...o)}return(await Promise.all(r.map(async o=>{const c=t?`${t}/${o.name}`:o.name;return o.isDirectory?PE(o,c):[{path:c,file:await _O(o)}]}))).flat()}async function SO(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 ME(n.name,await PE(n))}function wO({selectedDirectory:e,onSelect:t,onRemove:n,onRefresh:r,onInstall:a}){const[o,c]=j.useState(!1),[u,d]=j.useState(!1),[h,m]=j.useState(""),[f,g]=j.useState(null),[x,w]=j.useState(!1),C=j.useRef(null);j.useEffect(()=>{var k;(k=C.current)==null||k.setAttribute("webkitdirectory","")},[]);const v=k=>{g(k)},S=async()=>{if(!f||x)return;w(!0);const k=await t(f);if(k&&!k.success){m(k.error??"Cannot use selected folder."),w(!1);return}g(null),c(!1),w(!1)},_=async k=>{d(!0),m("");const E=await a(k);d(!1),E.success||m(E.error??"Failed to install skill package.")},b=async k=>{if(k.preventDefault(),!(!(e!=null&&e.available)||u))try{await _(await SO(k.dataTransfer))}catch(E){m(E instanceof Error?E.message:"Invalid skill folder.")}};return s.jsxs("section",{className:"mb-4 rounded border border-border bg-bg-tertiary/30 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Skills folder"}),s.jsx("p",{className:"mt-1 truncate text-xs text-text-muted",children:(e==null?void 0:e.configuredPath)??"No shared folder selected"})]}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx(ot,{variant:"secondary",onClick:()=>c(!0),children:"Change folder"}),e&&s.jsxs(s.Fragment,{children:[s.jsx(ot,{variant:"secondary",onClick:r,children:"Refresh"}),e.custom&&s.jsx(ot,{variant:"secondary",onClick:n,children:"Use default"})]})]})]}),s.jsx("button",{type:"button",disabled:!(e!=null&&e.available)||u,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?u?"Installing skill package...":"Drop one skill folder here":"Choose a skills folder to enable drag and drop."}),s.jsx("input",{ref:C,hidden:!0,type:"file",multiple:!0,onChange:k=>{var E;if((E=k.target.files)!=null&&E.length)try{_(vO(k.target.files))}catch(T){m(T instanceof Error?T.message:"Invalid skill folder.")}finally{k.target.value=""}}}),h&&s.jsx("p",{className:"mt-2 text-xs text-error",children:h}),o&&s.jsx(Qf,{initialPath:(e==null?void 0:e.resolvedPath)??void 0,onSelect:v,onClose:()=>c(!1)}),s.jsx(Nl,{isOpen:f!==null,onClose:()=>g(null),onConfirm:S,title:"Trust this folder?",message:"Skills may contain instructions and scripts. Select this folder for discovery without executing package content?",confirmLabel:"Trust folder",disabled:x})]})}function xs({enabled:e,onClick:t,label:n,disabled:r}){return s.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:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function BE({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:r,onDuplicate:a,onDelete:o,onCancelDelete:c,actions:u,children:d}){return s.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[s.jsx("div",{className:"min-w-0 flex-1 mr-3",children:d}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&r&&s.jsx(vi,{onClick:r}),e&&!r&&n&&s.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:s.jsx(wb,{})}),s.jsx(xu,{onClick:a}),!e&&r&&s.jsx(vi,{onClick:r}),!e&&o&&(t?s.jsx(Jh,{onConfirm:()=>{o==null||o()},onCancel:()=>c==null?void 0:c()}):s.jsx(Zh,{onClick:()=>o==null?void 0:o()})),u]})]})}function CO({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:a,onView:o,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h,actions:m}){return s.jsxs(BE,{isBuiltIn:r,isConfirmingDelete:a,onView:o,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h,actions:m,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&s.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function A1({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:o,onDelete:c,onToggle:u,readOnly:d=!1}){return s.jsx(CO,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:d?void 0:a,onDuplicate:o,onDelete:d?void 0:c,actions:s.jsx(xs,{enabled:e.enabled,onClick:u,label:`Activation for ${e.name}`})})}function kO({skill:e,deleting:t,error:n,onClose:r,onConfirm:a}){return s.jsxs(Et,{isOpen:e!==null,onClose:r,title:"Delete skill?",size:"sm",closeOnBackdropClick:!t,closeOnEscape:!t,footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(ot,{variant:"secondary",onClick:r,disabled:t,children:"Cancel"}),s.jsx(ot,{variant:"danger",onClick:a,disabled:t,children:t?"Deleting...":"Delete skill"})]}),children:[s.jsx("p",{className:"text-sm font-medium text-text-primary",children:"This skill files will be deleted."}),s.jsx("p",{className:"mt-2 text-sm text-text-secondary",children:"The full skill folder and all its contents will be removed."}),e&&s.jsx("p",{className:"mt-3 break-all font-mono text-xs text-text-muted",children:e.path}),n&&s.jsx("p",{className:"mt-3 text-sm text-error",children:n})]})}function jO({isOpen:e}){const t=Vn(re=>re.defaults),n=Vn(re=>re.userItems),r=Vn(re=>re.projectItems),a=Vn(re=>re.items),o=Vn(re=>re.selectedDirectory),c=Vn(re=>re.diagnostics),u=Vn(re=>re.loading),d=Vn(re=>re.fetchSkills),h=Vn(re=>re.setWorkdir),m=Vn(re=>re.fetchSkill),f=Vn(re=>re.fetchDefaultContent),g=Vn(re=>re.createSkill),x=Vn(re=>re.updateSkill),w=Vn(re=>re.deleteSkill),C=Vn(re=>re.selectDirectory),v=Vn(re=>re.removeDirectory),S=Vn(re=>re.installSkill),_=Vn(re=>re.toggleSkill),b=Oe(re=>re.currentSession),[k,E]=j.useState(null),[T,L]=j.useState(!1),[A,O]=j.useState(""),{view:M,editingId:H,formError:B,saving:F,formData:K,setView:G,setEditingId:V,setFormError:Z,setFormData:J,setSaving:z}=IE(),{clearConfirm:P}=Tu();j.useEffect(()=>{if(e){const re=(b==null?void 0:b.workdir)??null;h(re),d(re),G("list"),V(null),P()}},[e,d,h,P,b==null?void 0:b.workdir]);const D=(re,ie,pe,ye)=>{J({name:ye??re.metadata.name,id:pe??re.metadata.id,description:re.metadata.description??"",version:re.metadata.version??"1.0.0",prompt:re.prompt,isReadOnly:ie,destination:"user"})},U=async re=>{if(t.some(pe=>pe.id===re)){const pe=await f(re);if(!pe)return;D(pe,!0),V(re),Z(""),G("edit")}else{const pe=await m(re);if(!pe)return;D(pe,!0),V(re),Z(""),G("edit")}},$=async re=>{const pe=t.some(Ie=>Ie.id===re)?await f(re):await m(re);if(!pe)return;const ye=`${re}-copy-${Date.now()}`;D(pe,!1,ye,`${pe.metadata.name} (copy)`),V(null),Z(""),G("edit")},te=()=>{J({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),G("edit")},q=async re=>{const ie=await m(re);ie&&(D(ie,!1),V(re),Z(""),G("edit"))},X=async()=>{if(!k)return;L(!0),O("");const re=await w(k.id);if(L(!1),!re.success){O(re.error??"Failed to delete skill.");return}await d(),E(null),P()},Y=async()=>{const re=H??K.id;if(!re||!K.name||!K.prompt){Z("Name, ID, and prompt are required.");return}z(!0),Z("");const ie={metadata:{id:re,name:K.name,description:K.description,version:K.version},prompt:K.prompt},pe=H?await x(H,ie):await g(ie,K.destination);if(z(!1),!pe.success){Z(pe.error??"Failed to save skill.");return}G("list")},I=re=>{J(ie=>({...ie,name:re})),H||J(ie=>({...ie,id:re.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},Q=K.isReadOnly;if(M==="edit")return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:Q?K.name:H?"Edit Skill":"New Skill"}),s.jsx("button",{onClick:()=>G("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),B&&s.jsx(_l,{message:B}),s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsx(OE,{name:K.name,id:K.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:I,onIdChange:()=>{}}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(ss,{label:"Description",value:K.description,onChange:re=>J(ie=>({...ie,description:re})),placeholder:"What this skill does...",readOnly:Q}),s.jsx(ss,{label:"Version",value:K.version,onChange:re=>J(ie=>({...ie,version:re})),placeholder:"1.0.0",readOnly:Q})]})]}),s.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),s.jsx("textarea",{value:K.prompt,onChange:re=>J(ie=>({...ie,prompt:re.target.value})),readOnly:Q,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"})]}),!H&&s.jsx(Xf,{value:K.destination,onChange:re=>J(ie=>({...ie,destination:re}))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[s.jsx(ot,{variant:"secondary",onClick:()=>G("list"),children:"Cancel"}),Q?s.jsx(ot,{variant:"primary",onClick:()=>{J(re=>({...re,name:re.name+" (copy)",id:`${H}-copy-${Date.now()}`,isReadOnly:!1})),V(null)},children:"Duplicate & Customize"}):s.jsx(ot,{variant:"primary",onClick:Y,disabled:F||!K.name||!K.id||!K.prompt,children:F?"Saving...":"Save"})]})]});function ne({items:re}){return re.map(ie=>s.jsx(A1,{skill:ie,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>U(ie.id),onEdit:()=>q(ie.id),onDuplicate:()=>$(ie.id),onDelete:()=>{O(""),E(ie)},onToggle:()=>_(ie.id),readOnly:ie.readOnly},ie.id))}return s.jsxs("div",{children:[s.jsx(kO,{skill:k,deleting:T,error:A,onClose:()=>{T||E(null)},onConfirm:X}),s.jsx(wO,{selectedDirectory:o,onSelect:C,onRemove:v,onRefresh:d,onInstall:S}),c.length>0&&s.jsx("div",{className:"mb-3 rounded border border-accent-warning/40 bg-accent-warning/10 p-2 text-xs text-text-secondary",children:c.map((re,ie)=>s.jsx("p",{children:re},`${re}-${ie}`))}),s.jsx(DE,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:te}),s.jsxs(Tb,{loading:u,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),s.jsx("div",{className:"space-y-2",children:t.map(re=>s.jsx(A1,{skill:re,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>U(re.id),onDuplicate:()=>$(re.id),onToggle:()=>_(re.id)},re.id))})]}),n.length>0&&s.jsx(RE,{children:s.jsx(ne,{items:n})}),a.some(re=>["global-shared","selected","project-shared"].includes(re.source))&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Shared"}),s.jsx("div",{className:"space-y-2",children:s.jsx(ne,{items:a.filter(re=>["global-shared","selected","project-shared"].includes(re.source))})})]}),r.length>0&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),s.jsx("div",{className:"space-y-2",children:s.jsx(ne,{items:r})})]})]})]})}function ma(){const e=Bt(a=>a.settings),t=Bt(a=>a.loading),n=Bt(a=>a.getSetting),r=Bt(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function EO({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:a}=ma(),o=t[Ne.GLOBAL_INSTRUCTIONS]??"",c=n[Ne.GLOBAL_INSTRUCTIONS]??!1,[u,d]=j.useState(o),[h,m]=j.useState(!1),[f,g]=j.useState(!1);j.useEffect(()=>{e&&r(Ne.GLOBAL_INSTRUCTIONS)},[e,r]),j.useEffect(()=>{d(o),m(!1)},[o]);const x=async()=>{g(!0),await a(Ne.GLOBAL_INSTRUCTIONS,u),g(!1),m(!1)},w=()=>{d(o),m(!1)},C=c||f;return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),s.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),s.jsx("textarea",{value:u,onChange:v=>{d(v.target.value),m(!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})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(ot,{variant:"secondary",onClick:w,disabled:!h,children:"Discard"}),s.jsx(ot,{variant:"primary",onClick:x,disabled:!h||C,children:f?"Saving...":"Save"})]})]})}function NO(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 Bh(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 TO({isOpen:e,isNew:t,basePresetId:n,presetName:r,mode:a,initialTokens:o,onClose:c,onSave:u}){const[d,h]=j.useState(o),[m,f]=j.useState(r),[g,x]=j.useState(a);j.useEffect(()=>{h(o),f(r)},[o,r]);const w=(b,k)=>{const E=k.startsWith("#")?NO(k):k;h(T=>({...T,[b]:E}))},C=()=>{u(m.trim()||"Untitled",{...d},g)},v=SE.reduce((b,k)=>{const E=k.category;return b[E]||(b[E]=[]),b[E].push(k),b},{}),S={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},_=ur.find(b=>b.id===n);return s.jsx(Et,{isOpen:e,onClose:c,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx("button",{type:"button",onClick:c,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),s.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:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),s.jsx("input",{type:"text",value:m,onChange:b=>f(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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Mode"}),s.jsxs("div",{className:"flex rounded overflow-hidden border border-border",children:[s.jsx("button",{type:"button",onClick:()=>x("dark"),className:`px-3 py-2 text-xs font-medium transition-colors ${g==="dark"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Dark"}),s.jsx("button",{type:"button",onClick:()=>x("light"),className:`px-3 py-2 text-xs font-medium transition-colors ${g==="light"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Light"})]})]})]}),!t&&s.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",s.jsx("span",{className:"text-text-primary",children:_==null?void 0:_.name})]}),Object.entries(v).map(([b,k])=>s.jsxs("div",{className:"space-y-3",children:[s.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:S[b]??b}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:k.map(E=>s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("label",{htmlFor:E.key,className:"text-xs text-text-muted",children:E.label}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"color",id:E.key,value:Bh(d[E.key]??E.defaultValue),onChange:T=>w(E.key,T.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent flex-shrink-0"}),s.jsx("input",{type:"text",value:d[E.key]??E.defaultValue,onChange:T=>w(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 L1({preset:e,isActive:t,isUnderlying:n,onClick:r,onNewFrom:a,onEdit:o,onDelete:c}){return s.jsxs("div",{className:"relative group",children:[s.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:[s.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:e.id==="system"?"transparent":Bh(e.tokens["color-bg-primary"]??"#000"),borderColor:Bh(e.tokens["color-border"]??"#000")},children:e.id==="system"?s.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:"linear-gradient(135deg, #000 50%, #fff 50%)"}}):s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Bh(e.tokens["color-text-primary"]??"#fff")}})}),s.jsx("span",{className:"text-xs",children:e.name})]}),a&&s.jsx("button",{type:"button",onClick:u=>{u.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:s.jsx("span",{className:"text-xs",children:"✎"})}),o&&s.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),o()},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:s.jsx("span",{className:"text-xs",children:"✎"})}),c&&s.jsx("button",{type:"button",onClick:u=>c(u),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:s.jsx(Ss,{className:"w-3 h-3"})})]})}function AO(){const[e,t]=j.useState(null),n=Zt(B=>B.currentPreset),r=Zt(B=>B.isCustom),a=Zt(B=>B.basePreset),o=Zt(B=>B.isSystem),c=Zt(B=>B.systemDarkPreset),u=Zt(B=>B.systemLightPreset),d=Zt(B=>B.applyPreset),h=Zt(B=>B.applyUserPreset),m=Zt(B=>B.deleteUserPreset),f=Zt(B=>B.saveTheme),g=Zt(B=>B.setSystemDarkPreset),x=Zt(B=>B.setSystemLightPreset),w=Zt(B=>B.activeUserPresetId),C=Zt(B=>B.userPresets),v=ur.filter(B=>B.mode==="dark"),S=ur.filter(B=>B.mode==="light"),_=B=>{var F;if(o){const K=C[B];if(!K)return;const G=K.mode??((F=ur.find(V=>V.id===K.basePreset))==null?void 0:F.mode);G==="dark"?g(K.id):G==="light"&&x(K.id)}else h(B)},b=B=>{const F=ur.find(K=>K.id===B);F&&t({type:"new",presetIndex:C.length,basePresetId:B,presetName:F.name+" Copy",mode:F.mode??"dark",tokens:{...F.tokens}})},k=B=>{const F=C[B];if(!F)return;const K=ur.find(V=>V.id===F.basePreset),G=K?{...K.tokens,...F.tokens}:F.tokens;t({type:"edit",presetIndex:B,basePresetId:F.basePreset,presetName:F.name,mode:F.mode??"dark",tokens:G})},E=(B,F,K)=>{if(!e)return;const G=[...C];if(e.type==="new"){const V={id:"custom-"+Date.now(),name:B,basePreset:e.basePresetId,mode:K,tokens:F};G.push(V);const Z=G.length-1;Zt.setState({userPresets:G}),Zt.getState().saveUserPresets(),Zt.getState().applyUserPreset(Z)}else{const V=G[e.presetIndex];V&&(G[e.presetIndex]={...V,name:B,mode:K,tokens:F}),Zt.setState({userPresets:G}),Zt.getState().saveUserPresets(),Zt.getState().applyUserPreset(e.presetIndex)}t(null)},T=()=>{t(null)},L=(B,F)=>{B.stopPropagation(),m(F)},A=o?"system":r?a:n,O=()=>{o?(d(n),f(JSON.stringify({preset:n})).catch(()=>{})):(d("system"),f(JSON.stringify({preset:"system"})).catch(()=>{}))},M=B=>{if(o){const F=ur.find(K=>K.id===B);(F==null?void 0:F.mode)==="dark"?g(B):(F==null?void 0:F.mode)==="light"&&x(B)}else d(B),f(JSON.stringify({preset:B})).catch(()=>{})},H=B=>{const F=ur.find(K=>K.id===B.basePreset);return F?{...F.tokens,...B.tokens}:B.tokens};return s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),s.jsxs("label",{className:"flex items-center justify-between gap-3 cursor-pointer",children:[s.jsx("span",{className:"text-sm text-text-primary font-medium",children:"Follow system theme"}),s.jsx("button",{type:"button",onClick:O,className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${o?"bg-accent-primary":"bg-bg-tertiary"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${o?"translate-x-6":"translate-x-1"}`})})]}),[{title:"Dark Themes",mode:"dark"},{title:"Light Themes",mode:"light"}].map(({title:B,mode:F})=>{const K=F==="dark"?v:S,G=C.filter(V=>{var J;return(V.mode??((J=ur.find(z=>z.id===V.basePreset))==null?void 0:J.mode))===F});return s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:B}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[K.map(V=>s.jsx(L1,{preset:V,isActive:V.id===A&&!r,isUnderlying:o&&(V.id===c||V.id===u),onClick:()=>M(V.id),onNewFrom:()=>b(V.id)},V.id)),G.map(V=>{const Z=C.indexOf(V),J=H(V);return s.jsx(L1,{preset:{id:V.id,name:V.name,tokens:J},isActive:w===V.id,isUnderlying:o&&(V.id===c||V.id===u),onClick:()=>_(Z),onEdit:()=>k(Z),onDelete:z=>L(z,Z)},V.id)})]})]},B)}),e&&s.jsx(TO,{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 LO=["monospace","serif","sans-serif"],$E=["JetBrains Mono","Cascadia Mono","Menlo","Consolas","DejaVu Sans Mono","Liberation Mono"],$h=`${$E.map(e=>`"${e}"`).join(", ")}, monospace`,RO=["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"],DO="mmmmmmmmmmlliWWWW@0Oo",OO="72px";let Bc;function IO(){if(Bc!==void 0)return Bc;try{Bc=document.createElement("canvas").getContext("2d")}catch{Bc=null}return Bc}function Lb(e){const t=IO();if(!t)throw new Error("Canvas 2D context unavailable");return t.font=`${OO} ${e}`,t.measureText(DO).width}function FE(e,t=Lb){const n=e.trim();if(!n)return!1;try{return LO.some(r=>{const a=t(r);return t(`"${n}", ${r}`)!==a})}catch{return!1}}function MO(e=RO,t=Lb){const n=new Set;for(const r of e)FE(r,t)&&n.add(r);return[...n].sort((r,a)=>r.localeCompare(a))}function PO(e=$E,t=Lb){return e.find(n=>FE(n,t))??""}function BO(e){const t=e.trim();return t?`"${t}", monospace`:""}function $O(e){var n;return(((n=e.split(",")[0])==null?void 0:n.trim())??"").replace(/^['"]|['"]$/g,"")}function FO(){return s.jsx(AO,{})}function HO(){const{settings:e,loading:t,getSetting:n,setSetting:r}=ma(),a=t[Ne.DISPLAY_SHOW_THINKING]??!1,o=e[Ne.DISPLAY_MAX_VISIBLE_ITEMS]??"300",[c,u]=j.useState(o);j.useEffect(()=>{n(Ne.DISPLAY_MAX_VISIBLE_ITEMS)},[n]),j.useEffect(()=>{u(o)},[o]);const d=()=>{const _=parseInt(c,10),b=isNaN(_)||_<0?0:Math.min(_,9999);u(String(b)),r(Ne.DISPLAY_MAX_VISIBLE_ITEMS,String(b))},h=[{key:Ne.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:Ne.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:Ne.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:Ne.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:Ne.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"}],m=[{key:Ne.DISPLAY_USE_NATIVE_SCROLLBARS,label:"Use native scrollbars in tool calls",description:"Swap custom styled scrollbars for native ones in tool call views (file previews, arguments, results). Faster, but native scrollbars look different on some platforms.",defaultValue:"false"},{key:Ne.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS,label:"Use native scrollbars in code blocks",description:"Swap custom styled scrollbars for native ones in markdown code blocks and tables.",defaultValue:"false"},{key:Ne.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS,label:"Collapse large tool calls automatically",description:"Start finished tool calls with large outputs collapsed; click to expand. Speeds up loading long sessions.",defaultValue:"false"},{key:Ne.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING,label:"Defer code highlighting while streaming",description:"While a code block is streaming, wait until it closes to highlight it. Smoother streaming, but code stays plain until the end.",defaultValue:"false"},{key:Ne.DISPLAY_FEED_VIRTUALIZATION,label:"Virtualize long feeds",description:"Mount only the most recent items and reveal older ones as you scroll up. Faster on very long sessions, but older history loading is experimental.",defaultValue:"false"},{key:Ne.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but costly - applies to code blocks, diffs, and file previews",defaultValue:"true"}],f=[...h,...m],g=Object.fromEntries(h.map(_=>[_.key,e[_.key]??"true"])),x=Object.fromEntries(m.map(_=>[_.key,e[_.key]??_.defaultValue])),w={...g,...x},[C,v]=j.useState(()=>Object.fromEntries(f.map(_=>[_.key,w[_.key]==="true"])));j.useEffect(()=>{f.forEach(_=>n(_.key))},[n]),j.useEffect(()=>{v(Object.fromEntries(f.map(_=>[_.key,w[_.key]==="true"])))},[JSON.stringify(w)]);const S=async _=>{const b=String(!C[_]);v(k=>({...k,[_]:!k[_]})),await r(_,b)};return a?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(FO,{}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-2",children:"Custom CSS"}),s.jsx("p",{className:"text-xs text-text-muted mb-3",children:"Add global CSS overrides for any element."}),s.jsx(VO,{})]}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),s.jsx(R1,{toggles:h,local:C,onToggle:S})]}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Performance"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(R1,{toggles:m,local:C,onToggle:S}),s.jsxs("label",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary font-medium",children:"Max visible items"}),s.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."})]}),s.jsx("input",{type:"number",min:0,max:9999,value:c,onChange:_=>{const b=_.target.value.replace(/[^0-9]/g,"");u(b)},onBlur:d,onKeyDown:_=>{_.key==="Enter"&&d()},className:"w-20 px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded text-right"})]})]})]}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-2",children:"Terminal"}),s.jsx(UO,{})]})]})}const zO="~/project git status ✓ ✗ → 0123 iIlL1 |─┤";function R1({toggles:e,local:t,onToggle:n}){return s.jsx("div",{className:"space-y-4",children:e.map(({key:r,label:a,description:o})=>s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary font-medium",children:a}),s.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:o})]}),s.jsx("button",{type:"button",onClick:()=>n(r),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${t[r]?"bg-accent-primary":"bg-bg-tertiary"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${t[r]?"translate-x-6":"translate-x-1"}`})})]},r))})}function UO(){const{settings:e,getSetting:t,setSetting:n}=ma(),r=e[Ne.DISPLAY_TERMINAL_FONT]??$h,[a,o]=j.useState(r),c=j.useMemo(()=>MO(),[]),u=j.useMemo(()=>PO(),[]);j.useEffect(()=>{t(Ne.DISPLAY_TERMINAL_FONT)},[t]),j.useEffect(()=>{o(r)},[r]);const h=r===$h?u:$O(r),m=h!==""&&!c.includes(h),f=x=>{const w=x.target.value;w&&n(Ne.DISPLAY_TERMINAL_FONT,BO(w))},g=()=>{n(Ne.DISPLAY_TERMINAL_FONT,a.trim()||$h)};return s.jsxs("div",{className:"space-y-2",children:[s.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."}),s.jsxs("select",{value:m?"":h,onChange:f,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:[m&&s.jsx("option",{value:"",children:`Custom: ${h}`}),c.length===0&&s.jsx("option",{value:"",children:"No monospace font detected"}),c.map(x=>s.jsx("option",{value:x,style:{fontFamily:`"${x}", monospace`},children:x},x))]}),s.jsx(pt,{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:zO}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-text-muted mb-1",children:'Not listed? Enter a CSS font-family manually (e.g. "My Font", monospace)'}),s.jsx("input",{type:"text",value:a,onChange:x=>o(x.target.value),onBlur:g,onKeyDown:x=>{x.key==="Enter"&&g()},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 VO(){const{settings:e,getSetting:t,setSetting:n}=ma(),r=e[Ne.DISPLAY_CUSTOM_CSS]??"",[a,o]=j.useState(r);j.useEffect(()=>{t(Ne.DISPLAY_CUSTOM_CSS)},[t]),j.useEffect(()=>{o(r)},[r]);const c=()=>{n(Ne.DISPLAY_CUSTOM_CSS,a)};return s.jsx("div",{className:"space-y-2",children:s.jsx("textarea",{value:a,onChange:u=>o(u.target.value),onBlur:c,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 fy(){const[e,t]=j.useState("Test"),[n,r]=j.useState(""),[a,o]=j.useState(!1),c=j.useCallback(async u=>{t("Testing..."),r(""),o(!1);try{const d=await u();d.success?(t("Success"),o(!0),setTimeout(()=>{t("Test"),o(!1)},3e3)):(r(d.error??"Test failed"),t("Test"))}catch{r("Connection error"),t("Test")}},[]);return[e,n,a,c]}function WO(e){try{return new RegExp(e),!0}catch{return!1}}function GO({value:e,onChange:t}){const[n,r]=j.useState({}),a=(d,h)=>{const m=e.patterns.map((f,g)=>g===d?{...f,...h}:f);t({...e,patterns:m})},o=d=>{const h=e.patterns.filter((m,f)=>f!==d);t({...e,patterns:h})},c=()=>{const d={field:"content",pattern:"",action:"retry",active:!0};t({...e,patterns:[...e.patterns,d]})},u=(d,h)=>{r(m=>({...m,[d]:h.length>0&&!WO(h)})),a(d,{pattern:h})};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-text-primary",children:"Max Retries Per Turn"}),s.jsx("input",{type:"number",min:1,max:100,value:e.maxRetriesPerTurn,onChange:d=>{const h=parseInt(d.target.value,10),m=isNaN(h)?10:Math.max(1,Math.min(100,h));t({...e,maxRetriesPerTurn:m})},className:"mt-1 block w-24 px-2 py-1 text-sm bg-bg-secondary border border-border rounded"})]}),e.patterns.length===0?s.jsx("p",{className:"text-sm text-text-muted",children:"No retry patterns configured."}):s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-left text-text-muted border-b border-border",children:[s.jsx("th",{className:"pb-2 pr-2 w-12",children:"Active"}),s.jsx("th",{className:"pb-2 pr-2",children:"Field"}),s.jsx("th",{className:"pb-2 pr-2",children:"Pattern"}),s.jsx("th",{className:"pb-2 pr-2",children:"Action"}),s.jsx("th",{className:"pb-2 w-8"})]})}),s.jsx("tbody",{children:e.patterns.map((d,h)=>s.jsxs("tr",{className:"border-b border-border",children:[s.jsx("td",{className:"py-2 pr-2",children:s.jsx("input",{type:"checkbox",checked:d.active,onChange:()=>a(h,{active:!d.active}),className:"accent-accent-primary","aria-label":`Toggle pattern ${h+1}`})}),s.jsx("td",{className:"py-2 pr-2",children:s.jsxs("select",{value:d.field,onChange:m=>a(h,{field:m.target.value}),className:"px-2 py-1 bg-bg-secondary border border-border rounded text-sm",children:[s.jsx("option",{value:"content",children:"content"}),s.jsx("option",{value:"thinking",children:"thinking"}),s.jsx("option",{value:"both",children:"both"})]})}),s.jsx("td",{className:"py-2 pr-2",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{type:"text",value:d.pattern,onChange:m=>u(h,m.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&&s.jsx("span",{className:`text-sm ${n[h]?"text-red-500":"text-green-500"}`,children:n[h]?"✗":"✓"})]})}),s.jsx("td",{className:"py-2 pr-2 text-text-muted",children:"retry"}),s.jsx("td",{className:"py-2",children:s.jsx("button",{onClick:()=>o(h),title:"Remove pattern",className:"text-text-muted hover:text-red-500 transition-colors",children:"×"})})]},h))})]}),s.jsx(ot,{variant:"secondary",onClick:c,children:"Add Pattern"})]})}const HE="openfox_last_version",zE="openfox_previous_version";function Rb(){return localStorage.getItem(HE)}function qO(){return localStorage.getItem(zE)}function UE(e){e&&localStorage.setItem(zE,e)}function KO(e){if(!e)return;const t=Rb();t&&t!==e&&UE(t),localStorage.setItem(HE,e)}function YO(e,t){if(!e||!t)return!1;const n=e.split(".").map(Number),r=t.split(".").map(Number);if(n.length!==3||r.length!==3||n.some(a=>!Number.isInteger(a))||r.some(a=>!Number.isInteger(a)))return!1;for(let a=0;a<3;a++){const o=n[a],c=r[a];if(o!==c)return o>c}return!1}const D1=1e3,XO=3e4;function O1({message:e,command:t,hint:n}){return s.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[s.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:[s.jsx("span",{children:"⚠️"}),s.jsx("p",{className:"text-text-secondary",children:e})]}),s.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:t}),s.jsx("p",{className:"text-xs text-text-muted",children:n})]})}function VE({isOpen:e,onClose:t,versionInfo:n}){const[r,a]=j.useState("ready"),[o,c]=j.useState(""),[u,d]=j.useState(n),[h,m]=j.useState(null),[f,g]=j.useState(null),[x,w]=j.useState(!1),[C,v]=j.useState(!1),[S,_]=j.useState(!1),b=j.useRef(!1),k=j.useRef(null),E=j.useRef(null),T=j.useRef(!0),L=j.useRef(n);L.current=n,j.useEffect(()=>{if(!e)return;let J=!1;return(async()=>{try{const P=await(await fetch(vs("/api/auto-update/check"))).json();if(J)return;v(!!P.isService),!L.current&&P.current&&P.latest&&d({current:P.current,latest:P.latest})}catch{J||v(!1)}})(),()=>{J=!0}},[e]),j.useEffect(()=>{if(!e||r!=="updating"&&r!=="restarting")return;const J=setInterval(()=>{c(z=>z.length>=3?"":z+".")},400);return()=>clearInterval(J)},[e,r]);const A=j.useCallback(()=>{k.current!==null&&(clearTimeout(k.current),k.current=null),E.current=null},[]),O=j.useCallback(J=>{g(J),a("restartFailed")},[]),M=j.useCallback(J=>{b.current=J,_(J)},[]),H=j.useCallback(J=>{var P;const z=Rb()??((P=L.current)==null?void 0:P.current)??null;z&&z!==J&&UE(z),localStorage.setItem("openfox_updated_to",J),localStorage.setItem("update_pending","true")},[]),B=j.useCallback(async J=>{a("restarting"),g(null),A();try{await me("/api/auto-update/restart",{method:"POST"})}catch{}if(!T.current)return;E.current=Date.now();const z=async()=>{if(!T.current){A();return}const P=E.current;if(P!==null&&Date.now()-P>=XO){A(),O("OpenFox could not be reached after restart within 30 seconds. Please restart OpenFox manually.");return}try{const D=await fetch(vs("/api/auto-update/check?force=true"));if(!D.ok)throw new Error(`HTTP ${D.status}`);if((await D.json()).current===J){A(),H(J),window.location.reload();return}}catch{}if(!T.current){A();return}k.current=setTimeout(()=>{z()},D1)};k.current=setTimeout(()=>{z()},D1)},[A,O,H]),F=j.useCallback(async()=>{a("updating"),g(null);try{const z=await(await me("/api/auto-update",{method:"POST"})).json();if(z.success){const P=z.version??"unknown";m(P),w(!!z.isService),b.current&&z.isService?B(P):a("complete")}else g(z.error??"Update failed"),a("failed")}catch(J){g(J instanceof Error?J.message:"Update request failed"),a("failed")}},[B]),K=j.useCallback(()=>{const J=h??(u==null?void 0:u.latest)??null;if(!J){O("Installed version unknown; cannot verify restart.");return}B(J)},[h,u,O,B]);j.useEffect(()=>(T.current=!0,()=>{T.current=!1,A()}),[A]),j.useEffect(()=>{e&&(c(""),A(),a("ready"),m(null),g(null),w(!1),v(!1),M(!1))},[e,A,M]);const G=r!=="updating"&&r!=="restarting",V=J=>J,Z=r==="failed"?"Update Failed":r==="restarting"?"Restarting…":r==="complete"?"Update Complete":r==="restartFailed"?"Restart Not Confirmed":"New OpenFox version available";return s.jsxs(Et,{isOpen:e,onClose:G?t:void 0,title:Z,size:"md",closeOnBackdropClick:G,showCloseButton:G,children:[s.jsxs("div",{className:"flex flex-col gap-4",children:[u&&s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-text-muted",children:"Current version"}),s.jsx("span",{className:"text-text-primary font-mono",children:V(u.current)})]}),u&&s.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[s.jsx("span",{className:"text-text-muted",children:"Latest version"}),s.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:u.latest})]}),(r==="updating"||r==="restarting")&&s.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[s.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),s.jsxs("p",{className:"text-xs text-text-muted text-center",children:[r==="restarting"?"Restarting":"Updating",o]})]}),r==="complete"&&s.jsx("div",{className:"flex flex-col gap-3 mt-2",children:s.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",h??(u==null?void 0:u.latest),".",x?' Click "Restart OpenFox now" to apply the update.':" Please restart OpenFox to use the new version."]})}),r==="failed"&&s.jsx(O1,{message:f,command:"openfox update",hint:"Run this command in your terminal to complete the update."}),r==="restartFailed"&&s.jsx(O1,{message:f,command:"openfox service restart",hint:"Run this command in your terminal to restart OpenFox."})]}),r==="ready"&&s.jsx("button",{onClick:F,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==="ready"||r==="updating")&&C&&s.jsxs("label",{className:"flex items-center justify-center gap-2 text-xs text-text-muted cursor-pointer select-none mt-2",children:[s.jsx("input",{type:"checkbox",checked:S,onChange:J=>M(J.target.checked)}),"Auto-restart once update is done"]}),r==="complete"&&x&&s.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[s.jsx("button",{onClick:K,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Restart OpenFox now"}),s.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",children:"Later"})]}),r==="complete"&&!x&&s.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"}),(r==="failed"||r==="restartFailed")&&s.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 mn({children:e,className:t="",horizontal:n=!1,style:r,scope:a="toolCalls"}){const{useNativeScrollbars:o,useNativeScrollbarsCodeBlocks:c}=Fs();if(a==="codeBlocks"?c:o){const d=n?"overflow-x-auto":"overflow-y-auto";return s.jsx("div",{className:`${d} ${t}`.trim(),style:r,children:e})}return s.jsx(pt,{horizontal:n,className:t,style:r,children:e})}function QO(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const JO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ZO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eI={};function I1(e,t){return(eI.jsx?ZO:JO).test(e)}const tI=/[ \t\n\f\r]/g;function nI(e){return typeof e=="object"?e.type==="text"?M1(e.value):!1:M1(e)}function M1(e){return e.replace(tI,"")===""}let Lu=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Lu.prototype.normal={};Lu.prototype.property={};Lu.prototype.space=void 0;function WE(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Lu(n,r,t)}function my(e){return e.toLowerCase()}let kr=class{constructor(t,n){this.attribute=n,this.property=t}};kr.prototype.attribute="";kr.prototype.booleanish=!1;kr.prototype.boolean=!1;kr.prototype.commaOrSpaceSeparated=!1;kr.prototype.commaSeparated=!1;kr.prototype.defined=!1;kr.prototype.mustUseProperty=!1;kr.prototype.number=!1;kr.prototype.overloadedBoolean=!1;kr.prototype.property="";kr.prototype.spaceSeparated=!1;kr.prototype.space=void 0;let rI=0;const vt=co(),In=co(),py=co(),qe=co(),nn=co(),to=co(),Ir=co();function co(){return 2**++rI}const gy=Object.freeze(Object.defineProperty({__proto__:null,boolean:vt,booleanish:In,commaOrSpaceSeparated:Ir,commaSeparated:to,number:qe,overloadedBoolean:py,spaceSeparated:nn},Symbol.toStringTag,{value:"Module"})),Qg=Object.keys(gy);let Db=class extends kr{constructor(t,n,r,a){let o=-1;if(super(t,n),P1(this,"space",a),typeof r=="number")for(;++o<Qg.length;){const c=Qg[o];P1(this,Qg[o],(r&gy[c])===gy[c])}}};Db.prototype.defined=!0;function P1(e,t,n){n&&(e[t]=n)}function Pl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const o=new Db(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[my(r)]=r,n[my(o.attribute)]=r}return new Lu(t,n,e.space)}const GE=Pl({properties:{ariaActiveDescendant:null,ariaAtomic:In,ariaAutoComplete:null,ariaBusy:In,ariaChecked:In,ariaColCount:qe,ariaColIndex:qe,ariaColSpan:qe,ariaControls:nn,ariaCurrent:null,ariaDescribedBy:nn,ariaDetails:null,ariaDisabled:In,ariaDropEffect:nn,ariaErrorMessage:null,ariaExpanded:In,ariaFlowTo:nn,ariaGrabbed:In,ariaHasPopup:null,ariaHidden:In,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:nn,ariaLevel:qe,ariaLive:null,ariaModal:In,ariaMultiLine:In,ariaMultiSelectable:In,ariaOrientation:null,ariaOwns:nn,ariaPlaceholder:null,ariaPosInSet:qe,ariaPressed:In,ariaReadOnly:In,ariaRelevant:null,ariaRequired:In,ariaRoleDescription:nn,ariaRowCount:qe,ariaRowIndex:qe,ariaRowSpan:qe,ariaSelected:In,ariaSetSize:qe,ariaSort:null,ariaValueMax:qe,ariaValueMin:qe,ariaValueNow:qe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function qE(e,t){return t in e?e[t]:t}function KE(e,t){return qE(e,t.toLowerCase())}const sI=Pl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:to,acceptCharset:nn,accessKey:nn,action:null,allow:null,allowFullScreen:vt,allowPaymentRequest:vt,allowUserMedia:vt,alpha:vt,alt:null,as:null,async:vt,autoCapitalize:null,autoComplete:nn,autoFocus:vt,autoPlay:vt,blocking:nn,capture:null,charSet:null,checked:vt,cite:null,className:nn,closedBy:null,colorSpace:null,cols:qe,colSpan:qe,command:null,commandFor:null,content:null,contentEditable:In,controls:vt,controlsList:nn,coords:qe|to,crossOrigin:null,data:null,dateTime:null,decoding:null,default:vt,defer:vt,dir:null,dirName:null,disabled:vt,download:py,draggable:In,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:vt,formTarget:null,headers:nn,height:qe,hidden:py,high:qe,href:null,hrefLang:null,htmlFor:nn,httpEquiv:nn,id:null,imageSizes:null,imageSrcSet:null,inert:vt,inputMode:null,integrity:null,is:null,isMap:vt,itemId:null,itemProp:nn,itemRef:nn,itemScope:vt,itemType:nn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:vt,low:qe,manifest:null,max:null,maxLength:qe,media:null,method:null,min:null,minLength:qe,multiple:vt,muted:vt,name:null,nonce:null,noModule:vt,noValidate:vt,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:vt,optimum:qe,pattern:null,ping:nn,placeholder:null,playsInline:vt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:vt,referrerPolicy:null,rel:nn,required:vt,reversed:vt,rows:qe,rowSpan:qe,sandbox:nn,scope:null,scoped:vt,seamless:vt,selected:vt,shadowRootClonable:vt,shadowRootCustomElementRegistry:vt,shadowRootDelegatesFocus:vt,shadowRootMode:null,shadowRootSerializable:vt,shape:null,size:qe,sizes:null,slot:null,span:qe,spellCheck:In,src:null,srcDoc:null,srcLang:null,srcSet:null,start:qe,step:null,style:null,tabIndex:qe,target:null,title:null,translate:null,type:null,typeMustMatch:vt,useMap:null,value:In,width:qe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:nn,axis:null,background:null,bgColor:null,border:qe,borderColor:null,bottomMargin:qe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:vt,declare:vt,event:null,face:null,frame:null,frameBorder:null,hSpace:qe,leftMargin:qe,link:null,longDesc:null,lowSrc:null,marginHeight:qe,marginWidth:qe,noResize:vt,noHref:vt,noShade:vt,noWrap:vt,object:null,profile:null,prompt:null,rev:null,rightMargin:qe,rules:null,scheme:null,scrolling:In,standby:null,summary:null,text:null,topMargin:qe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:qe,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:vt,disablePictureInPicture:vt,disableRemotePlayback:vt,exportParts:to,part:nn,prefix:null,property:null,results:qe,security:null,unselectable:null},space:"html",transform:KE}),iI=Pl({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:Ir,accentHeight:qe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:qe,amplitude:qe,arabicForm:null,ascent:qe,attributeName:null,attributeType:null,azimuth:qe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:qe,by:null,calcMode:null,capHeight:qe,className:nn,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:qe,diffuseConstant:qe,direction:null,display:null,dur:null,divisor:qe,dominantBaseline:null,download:vt,dx:null,dy:null,edgeMode:null,editable:null,elevation:qe,enableBackground:null,end:null,event:null,exponent:qe,externalResourcesRequired:null,fill:null,fillOpacity:qe,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:to,g2:to,glyphName:to,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:qe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:qe,horizOriginX:qe,horizOriginY:qe,id:null,ideographic:qe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:qe,k:qe,k1:qe,k2:qe,k3:qe,k4:qe,kernelMatrix:Ir,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:qe,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:qe,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:qe,overlineThickness:qe,paintOrder:null,panose1:null,path:null,pathLength:qe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:nn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:qe,pointsAtY:qe,pointsAtZ:qe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ir,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ir,rev:Ir,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ir,requiredFeatures:Ir,requiredFonts:Ir,requiredFormats:Ir,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:qe,specularExponent:qe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:qe,strikethroughThickness:qe,string:null,stroke:null,strokeDashArray:Ir,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:qe,strokeOpacity:qe,strokeWidth:null,style:null,surfaceScale:qe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ir,tabIndex:qe,tableValues:null,target:null,targetX:qe,targetY:qe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ir,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:qe,underlineThickness:qe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:qe,values:null,vAlphabetic:qe,vMathematical:qe,vectorEffect:null,vHanging:qe,vIdeographic:qe,version:null,vertAdvY:qe,vertOriginX:qe,vertOriginY:qe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:qe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:qE}),YE=Pl({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()}}),XE=Pl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:KE}),QE=Pl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),aI={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"},oI=/[A-Z]/g,B1=/-[a-z]/g,lI=/^data[-\w.:]+$/i;function cI(e,t){const n=my(t);let r=t,a=kr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&lI.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(B1,dI);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!B1.test(o)){let c=o.replace(oI,uI);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Db}return new a(r,t)}function uI(e){return"-"+e.toLowerCase()}function dI(e){return e.charAt(1).toUpperCase()}const hI=WE([GE,sI,YE,XE,QE],"html"),Ob=WE([GE,iI,YE,XE,QE],"svg");function fI(e){return e.join(" ").trim()}var Zo={},Jg,$1;function mI(){if($1)return Jg;$1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,d=`
|
|
68
|
+
`,h="/",m="*",f="",g="comment",x="declaration";function w(v,S){if(typeof v!="string")throw new TypeError("First argument must be a string");if(!v)return[];S=S||{};var _=1,b=1;function k(K){var G=K.match(t);G&&(_+=G.length);var V=K.lastIndexOf(d);b=~V?K.length-V:b+K.length}function E(){var K={line:_,column:b};return function(G){return G.position=new T(K),O(),G}}function T(K){this.start=K,this.end={line:_,column:b},this.source=S.source}T.prototype.content=v;function L(K){var G=new Error(S.source+":"+_+":"+b+": "+K);if(G.reason=K,G.filename=S.source,G.line=_,G.column=b,G.source=v,!S.silent)throw G}function A(K){var G=K.exec(v);if(G){var V=G[0];return k(V),v=v.slice(V.length),G}}function O(){A(n)}function M(K){var G;for(K=K||[];G=H();)G!==!1&&K.push(G);return K}function H(){var K=E();if(!(h!=v.charAt(0)||m!=v.charAt(1))){for(var G=2;f!=v.charAt(G)&&(m!=v.charAt(G)||h!=v.charAt(G+1));)++G;if(G+=2,f===v.charAt(G-1))return L("End of comment missing");var V=v.slice(2,G-2);return b+=2,k(V),v=v.slice(G),b+=2,K({type:g,comment:V})}}function B(){var K=E(),G=A(r);if(G){if(H(),!A(a))return L("property missing ':'");var V=A(o),Z=K({type:x,property:C(G[0].replace(e,f)),value:V?C(V[0].replace(e,f)):f});return A(c),Z}}function F(){var K=[];M(K);for(var G;G=B();)G!==!1&&(K.push(G),M(K));return K}return O(),F()}function C(v){return v?v.replace(u,f):f}return Jg=w,Jg}var F1;function pI(){if(F1)return Zo;F1=1;var e=Zo&&Zo.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Zo,"__esModule",{value:!0}),Zo.default=n;const t=e(mI());function n(r,a){let o=null;if(!r||typeof r!="string")return o;const c=(0,t.default)(r),u=typeof a=="function";return c.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:m}=d;u?a(h,m,d):m&&(o=o||{},o[h]=m)}),o}return Zo}var $c={},H1;function gI(){if(H1)return $c;H1=1,Object.defineProperty($c,"__esModule",{value:!0}),$c.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||n.test(h)||e.test(h)},c=function(h,m){return m.toUpperCase()},u=function(h,m){return"".concat(m,"-")},d=function(h,m){return m===void 0&&(m={}),o(h)?h:(h=h.toLowerCase(),m.reactCompat?h=h.replace(a,u):h=h.replace(r,u),h.replace(t,c))};return $c.camelCase=d,$c}var Fc,z1;function xI(){if(z1)return Fc;z1=1;var e=Fc&&Fc.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(pI()),n=gI();function r(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(u,d){u&&d&&(c[(0,n.camelCase)(u,o)]=d)}),c}return r.default=r,Fc=r,Fc}var yI=xI();const bI=Nf(yI),JE=ZE("end"),Ib=ZE("start");function ZE(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 vI(e){const t=Ib(e),n=JE(e);if(t&&n)return{start:t,end:n}}function tu(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?U1(e.position):"start"in e||"end"in e?U1(e):"line"in e||"column"in e?xy(e):""}function xy(e){return V1(e&&e.line)+":"+V1(e&&e.column)}function U1(e){return xy(e&&e.start)+"-"+xy(e&&e.end)}function V1(e){return e&&typeof e=="number"?e:1}class or extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",o={},c=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(c=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const d=r.indexOf(":");d===-1?o.ruleId=r:(o.source=r.slice(0,d),o.ruleId=r.slice(d+1))}if(!o.place&&o.ancestors&&o.ancestors){const d=o.ancestors[o.ancestors.length-1];d&&(o.place=d.position)}const u=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=u?u.line:void 0,this.name=tu(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=c&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}or.prototype.file="";or.prototype.name="";or.prototype.reason="";or.prototype.message="";or.prototype.stack="";or.prototype.column=void 0;or.prototype.line=void 0;or.prototype.ancestors=void 0;or.prototype.cause=void 0;or.prototype.fatal=void 0;or.prototype.place=void 0;or.prototype.ruleId=void 0;or.prototype.source=void 0;const Mb={}.hasOwnProperty,_I=new Map,SI=/[A-Z]/g,wI=new Set(["table","tbody","thead","tfoot","tr"]),CI=new Set(["td","th"]),eN="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function kI(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=DI(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=RI(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"?Ob:hI,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=tN(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function tN(e,t,n){if(t.type==="element")return jI(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return EI(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return TI(e,t,n);if(t.type==="mdxjsEsm")return NI(e,t);if(t.type==="root")return AI(e,t,n);if(t.type==="text")return LI(e,t)}function jI(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=Ob,e.schema=a),e.ancestors.push(t);const o=rN(e,t.tagName,!1),c=OI(e,t);let u=Bb(e,t);return wI.has(t.tagName)&&(u=u.filter(function(d){return typeof d=="string"?!nI(d):!0})),nN(e,c,o,t),Pb(c,u),e.ancestors.pop(),e.schema=r,e.create(t,o,c,n)}function EI(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)}yu(e,t.position)}function NI(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);yu(e,t.position)}function TI(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=Ob,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:rN(e,t.name,!0),c=II(e,t),u=Bb(e,t);return nN(e,c,o,t),Pb(c,u),e.ancestors.pop(),e.schema=r,e.create(t,o,c,n)}function AI(e,t,n){const r={};return Pb(r,Bb(e,t)),e.create(t,e.Fragment,r,n)}function LI(e,t){return t.value}function nN(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Pb(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function RI(e,t,n){return r;function r(a,o,c,u){const h=Array.isArray(c.children)?n:t;return u?h(o,c,u):h(o,c)}}function DI(e,t){return n;function n(r,a,o,c){const u=Array.isArray(o.children),d=Ib(r);return t(a,o,c,u,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function OI(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&Mb.call(t.properties,a)){const o=MI(e,a,t.properties[a]);if(o){const[c,u]=o;e.tableCellAlignToStyle&&c==="align"&&typeof u=="string"&&CI.has(t.tagName)?r=u:n[c]=u}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function II(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const c=o.expression;c.type;const u=c.properties[0];u.type,Object.assign(n,e.evaluater.evaluateExpression(u.argument))}else yu(e,t.position);else{const a=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const u=r.value.data.estree.body[0];u.type,o=e.evaluater.evaluateExpression(u.expression)}else yu(e,t.position);else o=r.value===null?!0:r.value;n[a]=o}return n}function Bb(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:_I;for(;++r<t.children.length;){const o=t.children[r];let c;if(e.passKeys){const d=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(d){const h=a.get(d)||0;c=d+"-"+h,a.set(d,h+1)}}const u=tN(e,o,c);u!==void 0&&n.push(u)}return n}function MI(e,t,n){const r=cI(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?QO(n):fI(n)),r.property==="style"){let a=typeof n=="object"?n:PI(e,String(n));return e.stylePropertyNameCase==="css"&&(a=BI(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?aI[r.property]||r.property:r.attribute,n]}}function PI(e,t){try{return bI(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new or("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=eN+"#cannot-parse-style-attribute",a}}function rN(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let o=-1,c;for(;++o<a.length;){const u=I1(a[o])?{type:"Identifier",name:a[o]}:{type:"Literal",value:a[o]};c=c?{type:"MemberExpression",object:c,property:u,computed:!!(o&&u.type==="Literal"),optional:!1}:u}r=c}else r=I1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return Mb.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);yu(e)}function yu(e,t){const n=new or("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=eN+"#cannot-handle-mdx-estrees-without-createevaluater",n}function BI(e){const t={};let n;for(n in e)Mb.call(e,n)&&(t[$I(n)]=e[n]);return t}function $I(e){let t=e.replace(SI,FI);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function FI(e){return"-"+e.toLowerCase()}const Zg={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"]},HI={};function $b(e,t){const n=HI,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return sN(e,r,a)}function sN(e,t,n){if(zI(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 W1(e.children,t,n)}return Array.isArray(e)?W1(e,t,n):""}function W1(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=sN(e[a],t,n);return r.join("")}function zI(e){return!!(e&&typeof e=="object")}const G1=document.createElement("i");function Fb(e){const t="&"+e+";";G1.innerHTML=t;const n=G1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Fr(e,t,n,r){const a=e.length;let o=0,c;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)c=Array.from(r),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);o<r.length;)c=r.slice(o,o+1e4),c.unshift(t,0),e.splice(...c),o+=1e4,t+=1e4}function es(e,t){return e.length>0?(Fr(e,e.length,0,t),e):t}const q1={}.hasOwnProperty;function iN(e){const t={};let n=-1;for(;++n<e.length;)UI(t,e[n]);return t}function UI(e,t){let n;for(n in t){const a=(q1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let c;if(o)for(c in o){q1.call(a,c)||(a[c]=[]);const u=o[c];VI(a[c],Array.isArray(u)?u:u?[u]:[])}}}function VI(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Fr(e,0,0,r)}function aN(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 ys(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const dr=pa(/[A-Za-z]/),ar=pa(/[\dA-Za-z]/),WI=pa(/[#-'*+\--9=?A-Z^-~]/);function ef(e){return e!==null&&(e<32||e===127)}const yy=pa(/\d/),GI=pa(/[\dA-Fa-f]/),qI=pa(/[!-/:-@[-`{-~]/);function ft(e){return e!==null&&e<-2}function on(e){return e!==null&&(e<0||e===32)}function At(e){return e===-2||e===-1||e===32}const Jf=pa(new RegExp("\\p{P}|\\p{S}","u")),io=pa(/\s/);function pa(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Bl(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const o=e.charCodeAt(n);let c="";if(o===37&&ar(e.charCodeAt(n+1))&&ar(e.charCodeAt(n+2)))a=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(c=String.fromCharCode(o));else if(o>55295&&o<57344){const u=e.charCodeAt(n+1);o<56320&&u>56319&&u<57344?(c=String.fromCharCode(o,u),a=1):c="�"}else c=String.fromCharCode(o);c&&(t.push(e.slice(r,n),encodeURIComponent(c)),r=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function Mt(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(d){return At(d)?(e.enter(n),u(d)):t(d)}function u(d){return At(d)&&o++<a?(e.consume(d),u):(e.exit(n),t(d))}}const KI={tokenize:YI};function YI(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),Mt(e,t,"linePrefix")}function a(u){return e.enter("paragraph"),o(u)}function o(u){const d=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,c(u)}function c(u){if(u===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(u);return}return ft(u)?(e.consume(u),e.exit("chunkText"),o):(e.consume(u),c)}}const XI={tokenize:QI},K1={tokenize:JI};function QI(e){const t=this,n=[];let r=0,a,o,c;return u;function u(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}S(r);let L=k;for(;L<t.events.length;)t.events[L][1].end={...T},L++;return Fr(t.events,E+1,0,t.events.slice(k)),t.events.length=L,h(b)}return u(b)}function h(b){if(r===n.length){if(!a)return g(b);if(a.currentConstruct&&a.currentConstruct.concrete)return w(b);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(K1,m,f)(b)}function m(b){return a&&_(),S(r),g(b)}function f(b){return t.parser.lazy[t.now().line]=r!==n.length,c=t.now().offset,w(b)}function g(b){return t.containerState={},e.attempt(K1,x,w)(b)}function x(b){return r++,n.push([t.currentConstruct,t.containerState]),g(b)}function w(b){if(b===null){a&&_(),S(0),e.consume(b);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:o}),C(b)}function C(b){if(b===null){v(e.exit("chunkFlow"),!0),S(0),e.consume(b);return}return ft(b)?(e.consume(b),v(e.exit("chunkFlow")),r=0,t.interrupt=void 0,u):(e.consume(b),C)}function v(b,k){const E=t.sliceStream(b);if(k&&E.push(null),b.previous=o,o&&(o.next=b),o=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<c&&(!a.events[T][1].end||a.events[T][1].end.offset>c))return;const L=t.events.length;let A=L,O,M;for(;A--;)if(t.events[A][0]==="exit"&&t.events[A][1].type==="chunkFlow"){if(O){M=t.events[A][1].end;break}O=!0}for(S(r),T=L;T<t.events.length;)t.events[T][1].end={...M},T++;Fr(t.events,A+1,0,t.events.slice(L)),t.events.length=T}}function S(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]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function JI(e,t,n){return Mt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Tl(e){if(e===null||on(e)||io(e))return 1;if(Jf(e))return 2}function Zf(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const o=e[a].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const by={name:"attention",resolveAll:ZI,tokenize:eM};function ZI(e,t){let n=-1,r,a,o,c,u,d,h,m;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 f={...e[r][1].end},g={...e[n][1].start};Y1(f,-d),Y1(g,d),c={type:d>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},u={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},o={type:d>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:d>1?"strong":"emphasis",start:{...c.start},end:{...u.end}},e[r][1].end={...c.start},e[n][1].start={...u.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=es(h,[["enter",e[r][1],t],["exit",e[r][1],t]])),h=es(h,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),h=es(h,Zf(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),h=es(h,[["exit",o,t],["enter",u,t],["exit",u,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(m=2,h=es(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):m=0,Fr(e,r-1,n-r+3,h),n=r+h.length-m-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function eM(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Tl(r);let o;return c;function c(d){return o=d,e.enter("attentionSequence"),u(d)}function u(d){if(d===o)return e.consume(d),u;const h=e.exit("attentionSequence"),m=Tl(d),f=!m||m===2&&a||n.includes(d),g=!a||a===2&&m||n.includes(r);return h._open=!!(o===42?f:f&&(a||!g)),h._close=!!(o===42?g:g&&(m||!f)),t(d)}}function Y1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const tM={name:"autolink",tokenize:nM};function nM(e,t,n){let r=0;return a;function a(x){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(x){return dr(x)?(e.consume(x),c):x===64?n(x):h(x)}function c(x){return x===43||x===45||x===46||ar(x)?(r=1,u(x)):h(x)}function u(x){return x===58?(e.consume(x),r=0,d):(x===43||x===45||x===46||ar(x))&&r++<32?(e.consume(x),u):(r=0,h(x))}function d(x){return x===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.exit("autolink"),t):x===null||x===32||x===60||ef(x)?n(x):(e.consume(x),d)}function h(x){return x===64?(e.consume(x),m):WI(x)?(e.consume(x),h):n(x)}function m(x){return ar(x)?f(x):n(x)}function f(x){return x===46?(e.consume(x),r=0,m):x===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.exit("autolink"),t):g(x)}function g(x){if((x===45||ar(x))&&r++<63){const w=x===45?g:f;return e.consume(x),w}return n(x)}}const Ru={partial:!0,tokenize:rM};function rM(e,t,n){return r;function r(o){return At(o)?Mt(e,a,"linePrefix")(o):a(o)}function a(o){return o===null||ft(o)?t(o):n(o)}}const oN={continuation:{tokenize:iM},exit:aM,name:"blockQuote",tokenize:sM};function sM(e,t,n){const r=this;return a;function a(c){if(c===62){const u=r.containerState;return u.open||(e.enter("blockQuote",{_container:!0}),u.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),o}return n(c)}function o(c){return At(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function iM(e,t,n){const r=this;return a;function a(c){return At(c)?Mt(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):o(c)}function o(c){return e.attempt(oN,t,n)(c)}}function aM(e){e.exit("blockQuote")}const lN={name:"characterEscape",tokenize:oM};function oM(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),a}function a(o){return qI(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const cN={name:"characterReference",tokenize:lM};function lM(e,t,n){const r=this;let a=0,o,c;return u;function u(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),d}function d(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),o=31,c=ar,m(f))}function h(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,c=GI,m):(e.enter("characterReferenceValue"),o=7,c=yy,m(f))}function m(f){if(f===59&&a){const g=e.exit("characterReferenceValue");return c===ar&&!Fb(r.sliceSerialize(g))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(f)&&a++<o?(e.consume(f),m):n(f)}}const X1={partial:!0,tokenize:uM},Q1={concrete:!0,name:"codeFenced",tokenize:cM};function cM(e,t,n){const r=this,a={partial:!0,tokenize:E};let o=0,c=0,u;return d;function d(T){return h(T)}function h(T){const L=r.events[r.events.length-1];return o=L&&L[1].type==="linePrefix"?L[2].sliceSerialize(L[1],!0).length:0,u=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),m(T)}function m(T){return T===u?(c++,e.consume(T),m):c<3?n(T):(e.exit("codeFencedFenceSequence"),At(T)?Mt(e,f,"whitespace")(T):f(T))}function f(T){return T===null||ft(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(X1,C,k)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(T))}function g(T){return T===null||ft(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(T)):At(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Mt(e,x,"whitespace")(T)):T===96&&T===u?n(T):(e.consume(T),g)}function x(T){return T===null||ft(T)?f(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(T))}function w(T){return T===null||ft(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(T)):T===96&&T===u?n(T):(e.consume(T),w)}function C(T){return e.attempt(a,k,v)(T)}function v(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),S}function S(T){return o>0&&At(T)?Mt(e,_,"linePrefix",o+1)(T):_(T)}function _(T){return T===null||ft(T)?e.check(X1,C,k)(T):(e.enter("codeFlowValue"),b(T))}function b(T){return T===null||ft(T)?(e.exit("codeFlowValue"),_(T)):(e.consume(T),b)}function k(T){return e.exit("codeFenced"),t(T)}function E(T,L,A){let O=0;return M;function M(G){return T.enter("lineEnding"),T.consume(G),T.exit("lineEnding"),H}function H(G){return T.enter("codeFencedFence"),At(G)?Mt(T,B,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(G):B(G)}function B(G){return G===u?(T.enter("codeFencedFenceSequence"),F(G)):A(G)}function F(G){return G===u?(O++,T.consume(G),F):O>=c?(T.exit("codeFencedFenceSequence"),At(G)?Mt(T,K,"whitespace")(G):K(G)):A(G)}function K(G){return G===null||ft(G)?(T.exit("codeFencedFence"),L(G)):A(G)}}}function uM(e,t,n){const r=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return r.parser.lazy[r.now().line]?n(c):t(c)}}const ex={name:"codeIndented",tokenize:hM},dM={partial:!0,tokenize:fM};function hM(e,t,n){const r=this;return a;function a(h){return e.enter("codeIndented"),Mt(e,o,"linePrefix",5)(h)}function o(h){const m=r.events[r.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?c(h):n(h)}function c(h){return h===null?d(h):ft(h)?e.attempt(dM,c,d)(h):(e.enter("codeFlowValue"),u(h))}function u(h){return h===null||ft(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),u)}function d(h){return e.exit("codeIndented"),t(h)}}function fM(e,t,n){const r=this;return a;function a(c){return r.parser.lazy[r.now().line]?n(c):ft(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Mt(e,o,"linePrefix",5)(c)}function o(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):ft(c)?a(c):n(c)}}const mM={name:"codeText",previous:gM,resolve:pM,tokenize:xM};function pM(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 gM(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function xM(e,t,n){let r=0,a,o;return c;function c(f){return e.enter("codeText"),e.enter("codeTextSequence"),u(f)}function u(f){return f===96?(e.consume(f),r++,u):(e.exit("codeTextSequence"),d(f))}function d(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),d):f===96?(o=e.enter("codeTextSequence"),a=0,m(f)):ft(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),d):(e.enter("codeTextData"),h(f))}function h(f){return f===null||f===32||f===96||ft(f)?(e.exit("codeTextData"),d(f)):(e.consume(f),h)}function m(f){return f===96?(e.consume(f),a++,m):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(o.type="codeTextData",h(f))}}class yM{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 o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&Hc(this.left,r),o.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),Hc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Hc(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);Hc(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Hc(this.left,n.reverse())}}}function Hc(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 uN(e){const t={};let n=-1,r,a,o,c,u,d,h;const m=new yM(e);for(;++n<m.length;){for(;n in t;)n=t[n];if(r=m.get(n),n&&r[1].type==="chunkFlow"&&m.get(n-1)[1].type==="listItemPrefix"&&(d=r[1]._tokenizer.events,o=0,o<d.length&&d[o][1].type==="lineEndingBlank"&&(o+=2),o<d.length&&d[o][1].type==="content"))for(;++o<d.length&&d[o][1].type!=="content";)d[o][1].type==="chunkText"&&(d[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,bM(m,n)),n=t[n],h=!0);else if(r[1]._container){for(o=n,a=void 0;o--;)if(c=m.get(o),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(a&&(m.get(a)[1].type="lineEndingBlank"),c[1].type="lineEnding",a=o);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;a&&(r[1].end={...m.get(a)[1].start},u=m.slice(a,n),u.unshift(r),m.splice(a,n-a+1,u))}}return Fr(e,0,Number.POSITIVE_INFINITY,m.slice(0)),!h}function bM(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const o=[];let c=n._tokenizer;c||(c=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const u=c.events,d=[],h={};let m,f,g=-1,x=n,w=0,C=0;const v=[C];for(;x;){for(;e.get(++a)[1]!==x;);o.push(a),x._tokenizer||(m=r.sliceStream(x),x.next||m.push(null),f&&c.defineSkip(x.start),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(m),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),f=x,x=x.next}for(x=n;++g<u.length;)u[g][0]==="exit"&&u[g-1][0]==="enter"&&u[g][1].type===u[g-1][1].type&&u[g][1].start.line!==u[g][1].end.line&&(C=g+1,v.push(C),x._tokenizer=void 0,x.previous=void 0,x=x.next);for(c.events=[],x?(x._tokenizer=void 0,x.previous=void 0):v.pop(),g=v.length;g--;){const S=u.slice(v[g],v[g+1]),_=o.pop();d.push([_,_+S.length-1]),e.splice(_,2,S)}for(d.reverse(),g=-1;++g<d.length;)h[w+d[g][0]]=w+d[g][1],w+=d[g][1]-d[g][0]-1;return h}const vM={resolve:SM,tokenize:wM},_M={partial:!0,tokenize:CM};function SM(e){return uN(e),e}function wM(e,t){let n;return r;function r(u){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(u)}function a(u){return u===null?o(u):ft(u)?e.check(_M,c,o)(u):(e.consume(u),a)}function o(u){return e.exit("chunkContent"),e.exit("content"),t(u)}function c(u){return e.consume(u),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function CM(e,t,n){const r=this;return a;function a(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Mt(e,o,"linePrefix")}function o(c){if(c===null||ft(c))return n(c);const u=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):e.interrupt(r.parser.constructs.flow,n,t)(c)}}function dN(e,t,n,r,a,o,c,u,d){const h=d||Number.POSITIVE_INFINITY;let m=0;return f;function f(S){return S===60?(e.enter(r),e.enter(a),e.enter(o),e.consume(S),e.exit(o),g):S===null||S===32||S===41||ef(S)?n(S):(e.enter(r),e.enter(c),e.enter(u),e.enter("chunkString",{contentType:"string"}),C(S))}function g(S){return S===62?(e.enter(o),e.consume(S),e.exit(o),e.exit(a),e.exit(r),t):(e.enter(u),e.enter("chunkString",{contentType:"string"}),x(S))}function x(S){return S===62?(e.exit("chunkString"),e.exit(u),g(S)):S===null||S===60||ft(S)?n(S):(e.consume(S),S===92?w:x)}function w(S){return S===60||S===62||S===92?(e.consume(S),x):x(S)}function C(S){return!m&&(S===null||S===41||on(S))?(e.exit("chunkString"),e.exit(u),e.exit(c),e.exit(r),t(S)):m<h&&S===40?(e.consume(S),m++,C):S===41?(e.consume(S),m--,C):S===null||S===32||S===40||ef(S)?n(S):(e.consume(S),S===92?v:C)}function v(S){return S===40||S===41||S===92?(e.consume(S),C):C(S)}}function hN(e,t,n,r,a,o){const c=this;let u=0,d;return h;function h(x){return e.enter(r),e.enter(a),e.consume(x),e.exit(a),e.enter(o),m}function m(x){return u>999||x===null||x===91||x===93&&!d||x===94&&!u&&"_hiddenFootnoteSupport"in c.parser.constructs?n(x):x===93?(e.exit(o),e.enter(a),e.consume(x),e.exit(a),e.exit(r),t):ft(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),f(x))}function f(x){return x===null||x===91||x===93||ft(x)||u++>999?(e.exit("chunkString"),m(x)):(e.consume(x),d||(d=!At(x)),x===92?g:f)}function g(x){return x===91||x===92||x===93?(e.consume(x),u++,f):f(x)}}function fN(e,t,n,r,a,o){let c;return u;function u(g){return g===34||g===39||g===40?(e.enter(r),e.enter(a),e.consume(g),e.exit(a),c=g===40?41:g,d):n(g)}function d(g){return g===c?(e.enter(a),e.consume(g),e.exit(a),e.exit(r),t):(e.enter(o),h(g))}function h(g){return g===c?(e.exit(o),d(c)):g===null?n(g):ft(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Mt(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(g))}function m(g){return g===c||g===null||ft(g)?(e.exit("chunkString"),h(g)):(e.consume(g),g===92?f:m)}function f(g){return g===c||g===92?(e.consume(g),m):m(g)}}function nu(e,t){let n;return r;function r(a){return ft(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):At(a)?Mt(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const kM={name:"definition",tokenize:EM},jM={partial:!0,tokenize:NM};function EM(e,t,n){const r=this;let a;return o;function o(x){return e.enter("definition"),c(x)}function c(x){return hN.call(r,e,u,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function u(x){return a=ys(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),d):n(x)}function d(x){return on(x)?nu(e,h)(x):h(x)}function h(x){return dN(e,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function m(x){return e.attempt(jM,f,f)(x)}function f(x){return At(x)?Mt(e,g,"whitespace")(x):g(x)}function g(x){return x===null||ft(x)?(e.exit("definition"),r.parser.defined.push(a),t(x)):n(x)}}function NM(e,t,n){return r;function r(u){return on(u)?nu(e,a)(u):n(u)}function a(u){return fN(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function o(u){return At(u)?Mt(e,c,"whitespace")(u):c(u)}function c(u){return u===null||ft(u)?t(u):n(u)}}const TM={name:"hardBreakEscape",tokenize:AM};function AM(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return ft(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const LM={name:"headingAtx",resolve:RM,tokenize:DM};function RM(e,t){let n=e.length-2,r=3,a,o;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},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Fr(e,r,n-r+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function DM(e,t,n){let r=0;return a;function a(m){return e.enter("atxHeading"),o(m)}function o(m){return e.enter("atxHeadingSequence"),c(m)}function c(m){return m===35&&r++<6?(e.consume(m),c):m===null||on(m)?(e.exit("atxHeadingSequence"),u(m)):n(m)}function u(m){return m===35?(e.enter("atxHeadingSequence"),d(m)):m===null||ft(m)?(e.exit("atxHeading"),t(m)):At(m)?Mt(e,u,"whitespace")(m):(e.enter("atxHeadingText"),h(m))}function d(m){return m===35?(e.consume(m),d):(e.exit("atxHeadingSequence"),u(m))}function h(m){return m===null||m===35||on(m)?(e.exit("atxHeadingText"),u(m)):(e.consume(m),h)}}const OM=["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"],J1=["pre","script","style","textarea"],IM={concrete:!0,name:"htmlFlow",resolveTo:BM,tokenize:$M},MM={partial:!0,tokenize:HM},PM={partial:!0,tokenize:FM};function BM(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 $M(e,t,n){const r=this;let a,o,c,u,d;return h;function h($){return m($)}function m($){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume($),f}function f($){return $===33?(e.consume($),g):$===47?(e.consume($),o=!0,C):$===63?(e.consume($),a=3,r.interrupt?t:P):dr($)?(e.consume($),c=String.fromCharCode($),v):n($)}function g($){return $===45?(e.consume($),a=2,x):$===91?(e.consume($),a=5,u=0,w):dr($)?(e.consume($),a=4,r.interrupt?t:P):n($)}function x($){return $===45?(e.consume($),r.interrupt?t:P):n($)}function w($){const te="CDATA[";return $===te.charCodeAt(u++)?(e.consume($),u===te.length?r.interrupt?t:B:w):n($)}function C($){return dr($)?(e.consume($),c=String.fromCharCode($),v):n($)}function v($){if($===null||$===47||$===62||on($)){const te=$===47,q=c.toLowerCase();return!te&&!o&&J1.includes(q)?(a=1,r.interrupt?t($):B($)):OM.includes(c.toLowerCase())?(a=6,te?(e.consume($),S):r.interrupt?t($):B($)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n($):o?_($):b($))}return $===45||ar($)?(e.consume($),c+=String.fromCharCode($),v):n($)}function S($){return $===62?(e.consume($),r.interrupt?t:B):n($)}function _($){return At($)?(e.consume($),_):M($)}function b($){return $===47?(e.consume($),M):$===58||$===95||dr($)?(e.consume($),k):At($)?(e.consume($),b):M($)}function k($){return $===45||$===46||$===58||$===95||ar($)?(e.consume($),k):E($)}function E($){return $===61?(e.consume($),T):At($)?(e.consume($),E):b($)}function T($){return $===null||$===60||$===61||$===62||$===96?n($):$===34||$===39?(e.consume($),d=$,L):At($)?(e.consume($),T):A($)}function L($){return $===d?(e.consume($),d=null,O):$===null||ft($)?n($):(e.consume($),L)}function A($){return $===null||$===34||$===39||$===47||$===60||$===61||$===62||$===96||on($)?E($):(e.consume($),A)}function O($){return $===47||$===62||At($)?b($):n($)}function M($){return $===62?(e.consume($),H):n($)}function H($){return $===null||ft($)?B($):At($)?(e.consume($),H):n($)}function B($){return $===45&&a===2?(e.consume($),V):$===60&&a===1?(e.consume($),Z):$===62&&a===4?(e.consume($),D):$===63&&a===3?(e.consume($),P):$===93&&a===5?(e.consume($),z):ft($)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(MM,U,F)($)):$===null||ft($)?(e.exit("htmlFlowData"),F($)):(e.consume($),B)}function F($){return e.check(PM,K,U)($)}function K($){return e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),G}function G($){return $===null||ft($)?F($):(e.enter("htmlFlowData"),B($))}function V($){return $===45?(e.consume($),P):B($)}function Z($){return $===47?(e.consume($),c="",J):B($)}function J($){if($===62){const te=c.toLowerCase();return J1.includes(te)?(e.consume($),D):B($)}return dr($)&&c.length<8?(e.consume($),c+=String.fromCharCode($),J):B($)}function z($){return $===93?(e.consume($),P):B($)}function P($){return $===62?(e.consume($),D):$===45&&a===2?(e.consume($),P):B($)}function D($){return $===null||ft($)?(e.exit("htmlFlowData"),U($)):(e.consume($),D)}function U($){return e.exit("htmlFlow"),t($)}}function FM(e,t,n){const r=this;return a;function a(c){return ft(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):n(c)}function o(c){return r.parser.lazy[r.now().line]?n(c):t(c)}}function HM(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Ru,t,n)}}const zM={name:"htmlText",tokenize:UM};function UM(e,t,n){const r=this;let a,o,c;return u;function u(P){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(P),d}function d(P){return P===33?(e.consume(P),h):P===47?(e.consume(P),E):P===63?(e.consume(P),b):dr(P)?(e.consume(P),A):n(P)}function h(P){return P===45?(e.consume(P),m):P===91?(e.consume(P),o=0,w):dr(P)?(e.consume(P),_):n(P)}function m(P){return P===45?(e.consume(P),x):n(P)}function f(P){return P===null?n(P):P===45?(e.consume(P),g):ft(P)?(c=f,Z(P)):(e.consume(P),f)}function g(P){return P===45?(e.consume(P),x):f(P)}function x(P){return P===62?V(P):P===45?g(P):f(P)}function w(P){const D="CDATA[";return P===D.charCodeAt(o++)?(e.consume(P),o===D.length?C:w):n(P)}function C(P){return P===null?n(P):P===93?(e.consume(P),v):ft(P)?(c=C,Z(P)):(e.consume(P),C)}function v(P){return P===93?(e.consume(P),S):C(P)}function S(P){return P===62?V(P):P===93?(e.consume(P),S):C(P)}function _(P){return P===null||P===62?V(P):ft(P)?(c=_,Z(P)):(e.consume(P),_)}function b(P){return P===null?n(P):P===63?(e.consume(P),k):ft(P)?(c=b,Z(P)):(e.consume(P),b)}function k(P){return P===62?V(P):b(P)}function E(P){return dr(P)?(e.consume(P),T):n(P)}function T(P){return P===45||ar(P)?(e.consume(P),T):L(P)}function L(P){return ft(P)?(c=L,Z(P)):At(P)?(e.consume(P),L):V(P)}function A(P){return P===45||ar(P)?(e.consume(P),A):P===47||P===62||on(P)?O(P):n(P)}function O(P){return P===47?(e.consume(P),V):P===58||P===95||dr(P)?(e.consume(P),M):ft(P)?(c=O,Z(P)):At(P)?(e.consume(P),O):V(P)}function M(P){return P===45||P===46||P===58||P===95||ar(P)?(e.consume(P),M):H(P)}function H(P){return P===61?(e.consume(P),B):ft(P)?(c=H,Z(P)):At(P)?(e.consume(P),H):O(P)}function B(P){return P===null||P===60||P===61||P===62||P===96?n(P):P===34||P===39?(e.consume(P),a=P,F):ft(P)?(c=B,Z(P)):At(P)?(e.consume(P),B):(e.consume(P),K)}function F(P){return P===a?(e.consume(P),a=void 0,G):P===null?n(P):ft(P)?(c=F,Z(P)):(e.consume(P),F)}function K(P){return P===null||P===34||P===39||P===60||P===61||P===96?n(P):P===47||P===62||on(P)?O(P):(e.consume(P),K)}function G(P){return P===47||P===62||on(P)?O(P):n(P)}function V(P){return P===62?(e.consume(P),e.exit("htmlTextData"),e.exit("htmlText"),t):n(P)}function Z(P){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),J}function J(P){return At(P)?Mt(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):z(P)}function z(P){return e.enter("htmlTextData"),c(P)}}const Hb={name:"labelEnd",resolveAll:qM,resolveTo:KM,tokenize:YM},VM={tokenize:XM},WM={tokenize:QM},GM={tokenize:JM};function qM(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&&Fr(e,0,e.length,n),e}function KM(e,t){let n=e.length,r=0,a,o,c,u;for(;n--;)if(a=e[n][1],o){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(c){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(o=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(c=n);const d={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[o][1].start},end:{...e[c][1].end}},m={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[c-2][1].start}};return u=[["enter",d,t],["enter",h,t]],u=es(u,e.slice(o+1,o+r+3)),u=es(u,[["enter",m,t]]),u=es(u,Zf(t.parser.constructs.insideSpan.null,e.slice(o+r+4,c-3),t)),u=es(u,[["exit",m,t],e[c-2],e[c-1],["exit",h,t]]),u=es(u,e.slice(c+1)),u=es(u,[["exit",d,t]]),Fr(e,o,e.length,u),e}function YM(e,t,n){const r=this;let a=r.events.length,o,c;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){o=r.events[a][1];break}return u;function u(g){return o?o._inactive?f(g):(c=r.parser.defined.includes(ys(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),d):n(g)}function d(g){return g===40?e.attempt(VM,m,c?m:f)(g):g===91?e.attempt(WM,m,c?h:f)(g):c?m(g):f(g)}function h(g){return e.attempt(GM,m,f)(g)}function m(g){return t(g)}function f(g){return o._balanced=!0,n(g)}}function XM(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),a}function a(f){return on(f)?nu(e,o)(f):o(f)}function o(f){return f===41?m(f):dN(e,c,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function c(f){return on(f)?nu(e,d)(f):m(f)}function u(f){return n(f)}function d(f){return f===34||f===39||f===40?fN(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):m(f)}function h(f){return on(f)?nu(e,m)(f):m(f)}function m(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function QM(e,t,n){const r=this;return a;function a(u){return hN.call(r,e,o,c,"reference","referenceMarker","referenceString")(u)}function o(u){return r.parser.defined.includes(ys(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(u):n(u)}function c(u){return n(u)}}function JM(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),a}function a(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const ZM={name:"labelStartImage",resolveAll:Hb.resolveAll,tokenize:e4};function e4(e,t,n){const r=this;return a;function a(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),o}function o(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),c):n(u)}function c(u){return u===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):t(u)}}const t4={name:"labelStartLink",resolveAll:Hb.resolveAll,tokenize:n4};function n4(e,t,n){const r=this;return a;function a(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),o}function o(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const tx={name:"lineEnding",tokenize:r4};function r4(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Mt(e,t,"linePrefix")}}const Fh={name:"thematicBreak",tokenize:s4};function s4(e,t,n){let r=0,a;return o;function o(h){return e.enter("thematicBreak"),c(h)}function c(h){return a=h,u(h)}function u(h){return h===a?(e.enter("thematicBreakSequence"),d(h)):r>=3&&(h===null||ft(h))?(e.exit("thematicBreak"),t(h)):n(h)}function d(h){return h===a?(e.consume(h),r++,d):(e.exit("thematicBreakSequence"),At(h)?Mt(e,u,"whitespace")(h):u(h))}}const br={continuation:{tokenize:l4},exit:u4,name:"list",tokenize:o4},i4={partial:!0,tokenize:d4},a4={partial:!0,tokenize:c4};function o4(e,t,n){const r=this,a=r.events[r.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return u;function u(x){const w=r.containerState.type||(x===42||x===43||x===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!r.containerState.marker||x===r.containerState.marker:yy(x)){if(r.containerState.type||(r.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),x===42||x===45?e.check(Fh,n,h)(x):h(x);if(!r.interrupt||x===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(x)}return n(x)}function d(x){return yy(x)&&++c<10?(e.consume(x),d):(!r.interrupt||c<2)&&(r.containerState.marker?x===r.containerState.marker:x===41||x===46)?(e.exit("listItemValue"),h(x)):n(x)}function h(x){return e.enter("listItemMarker"),e.consume(x),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||x,e.check(Ru,r.interrupt?n:m,e.attempt(i4,g,f))}function m(x){return r.containerState.initialBlankLine=!0,o++,g(x)}function f(x){return At(x)?(e.enter("listItemPrefixWhitespace"),e.consume(x),e.exit("listItemPrefixWhitespace"),g):n(x)}function g(x){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(x)}}function l4(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ru,a,o);function a(u){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Mt(e,t,"listItemIndent",r.containerState.size+1)(u)}function o(u){return r.containerState.furtherBlankLines||!At(u)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,c(u)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(a4,t,c)(u))}function c(u){return r.containerState._closeFlow=!0,r.interrupt=void 0,Mt(e,e.attempt(br,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function c4(e,t,n){const r=this;return Mt(e,a,"listItemIndent",r.containerState.size+1);function a(o){const c=r.events[r.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===r.containerState.size?t(o):n(o)}}function u4(e){e.exit(this.containerState.type)}function d4(e,t,n){const r=this;return Mt(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const c=r.events[r.events.length-1];return!At(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Z1={name:"setextUnderline",resolveTo:h4,tokenize:f4};function h4(e,t){let n=e.length,r,a,o;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),!o&&e[n][1].type==="definition"&&(o=n);const c={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",c,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=c,e.push(["exit",c,t]),e}function f4(e,t,n){const r=this;let a;return o;function o(h){let m=r.events.length,f;for(;m--;)if(r.events[m][1].type!=="lineEnding"&&r.events[m][1].type!=="linePrefix"&&r.events[m][1].type!=="content"){f=r.events[m][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),a=h,c(h)):n(h)}function c(h){return e.enter("setextHeadingLineSequence"),u(h)}function u(h){return h===a?(e.consume(h),u):(e.exit("setextHeadingLineSequence"),At(h)?Mt(e,d,"lineSuffix")(h):d(h))}function d(h){return h===null||ft(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const m4={tokenize:p4};function p4(e){const t=this,n=e.attempt(Ru,r,e.attempt(this.parser.constructs.flowInitial,a,Mt(e,e.attempt(this.parser.constructs.flow,a,e.attempt(vM,a)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const g4={resolveAll:pN()},x4=mN("string"),y4=mN("text");function mN(e){return{resolveAll:pN(e==="text"?b4:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],o=n.attempt(a,c,u);return c;function c(m){return h(m)?o(m):u(m)}function u(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),d}function d(m){return h(m)?(n.exit("data"),o(m)):(n.consume(m),d)}function h(m){if(m===null)return!0;const f=a[m];let g=-1;if(f)for(;++g<f.length;){const x=f[g];if(!x.previous||x.previous.call(r,r.previous))return!0}return!1}}}function pN(e){return t;function t(n,r){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,r):n}}function b4(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 o=a.length,c=-1,u=0,d;for(;o--;){const h=a[o];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)u++,c--;if(c)break;c=-1}else if(h===-2)d=!0,u++;else if(h!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(u=0),u){const h={type:n===e.length||d||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:r.start._bufferIndex+c,_index:r.start._index+o,line:r.end.line,column:r.end.column-u,offset:r.end.offset-u},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 v4={42:br,43:br,45:br,48:br,49:br,50:br,51:br,52:br,53:br,54:br,55:br,56:br,57:br,62:oN},_4={91:kM},S4={[-2]:ex,[-1]:ex,32:ex},w4={35:LM,42:Fh,45:[Z1,Fh],60:IM,61:Z1,95:Fh,96:Q1,126:Q1},C4={38:cN,92:lN},k4={[-5]:tx,[-4]:tx,[-3]:tx,33:ZM,38:cN,42:by,60:[tM,zM],91:t4,92:[TM,lN],93:Hb,95:by,96:mM},j4={null:[by,g4]},E4={null:[42,95]},N4={null:[]},T4=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:E4,contentInitial:_4,disable:N4,document:v4,flow:w4,flowInitial:S4,insideSpan:j4,string:C4,text:k4},Symbol.toStringTag,{value:"Module"}));function A4(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={},o=[];let c=[],u=[];const d={attempt:L(E),check:L(T),consume:_,enter:b,exit:k,interrupt:L(T,{interrupt:!0})},h={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:e,previous:null,sliceSerialize:g,sliceStream:x,write:f};let m=t.tokenize.call(h,d);return t.resolveAll&&o.push(t),h;function f(H){return c=es(c,H),v(),c[c.length-1]!==null?[]:(A(t,0),h.events=Zf(o,h.events,h),h.events)}function g(H,B){return R4(x(H),B)}function x(H){return L4(c,H)}function w(){const{_bufferIndex:H,_index:B,line:F,column:K,offset:G}=r;return{_bufferIndex:H,_index:B,line:F,column:K,offset:G}}function C(H){a[H.line]=H.column,M()}function v(){let H;for(;r._index<c.length;){const B=c[r._index];if(typeof B=="string")for(H=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===H&&r._bufferIndex<B.length;)S(B.charCodeAt(r._bufferIndex));else S(B)}}function S(H){m=m(H)}function _(H){ft(H)?(r.line++,r.column=1,r.offset+=H===-3?2:1,M()):H!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===c[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=H}function b(H,B){const F=B||{};return F.type=H,F.start=w(),h.events.push(["enter",F,h]),u.push(F),F}function k(H){const B=u.pop();return B.end=w(),h.events.push(["exit",B,h]),B}function E(H,B){A(H,B.from)}function T(H,B){B.restore()}function L(H,B){return F;function F(K,G,V){let Z,J,z,P;return Array.isArray(K)?U(K):"tokenize"in K?U([K]):D(K);function D(X){return Y;function Y(I){const Q=I!==null&&X[I],ne=I!==null&&X.null,re=[...Array.isArray(Q)?Q:Q?[Q]:[],...Array.isArray(ne)?ne:ne?[ne]:[]];return U(re)(I)}}function U(X){return Z=X,J=0,X.length===0?V:$(X[J])}function $(X){return Y;function Y(I){return P=O(),z=X,X.partial||(h.currentConstruct=X),X.name&&h.parser.constructs.disable.null.includes(X.name)?q():X.tokenize.call(B?Object.assign(Object.create(h),B):h,d,te,q)(I)}}function te(X){return H(z,P),G}function q(X){return P.restore(),++J<Z.length?$(Z[J]):V}}}function A(H,B){H.resolveAll&&!o.includes(H)&&o.push(H),H.resolve&&Fr(h.events,B,h.events.length-B,H.resolve(h.events.slice(B),h)),H.resolveTo&&(h.events=H.resolveTo(h.events,h))}function O(){const H=w(),B=h.previous,F=h.currentConstruct,K=h.events.length,G=Array.from(u);return{from:K,restore:V};function V(){r=H,h.previous=B,h.currentConstruct=F,h.events.length=K,u=G,M()}}function M(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function L4(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;let c;if(n===a)c=[e[n].slice(r,o)];else{if(c=e.slice(n,a),r>-1){const u=c[0];typeof u=="string"?c[0]=u.slice(r):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function R4(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const o=e[n];let c;if(typeof o=="string")c=o;else switch(o){case-5:{c="\r";break}case-4:{c=`
|
|
69
|
+
`;break}case-3:{c=`\r
|
|
70
|
+
`;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&a)continue;c=" ";break}default:c=String.fromCharCode(o)}a=o===-2,r.push(c)}return r.join("")}function D4(e){const r={constructs:iN([T4,...(e||{}).extensions||[]]),content:a(KI),defined:[],document:a(XI),flow:a(m4),lazy:{},string:a(x4),text:a(y4)};return r;function a(o){return c;function c(u){return A4(r,o,u)}}}function O4(e){for(;!uN(e););return e}const eC=/[\0\t\n\r]/g;function I4(){let e=1,t="",n=!0,r;return a;function a(o,c,u){const d=[];let h,m,f,g,x;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(c||void 0).decode(o)),f=0,t="",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(eC.lastIndex=f,h=eC.exec(o),g=h&&h.index!==void 0?h.index:o.length,x=o.charCodeAt(g),!h){t=o.slice(f);break}if(x===10&&f===g&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),f<g&&(d.push(o.slice(f,g)),e+=g-f),x){case 0:{d.push(65533),e++;break}case 9:{for(m=Math.ceil(e/4)*4,d.push(-2);e++<m;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:r=!0,e=1}f=g+1}return u&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const M4=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function P4(e){return e.replace(M4,B4)}function B4(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),o=a===120||a===88;return aN(n.slice(o?2:1),o?16:10)}return Fb(n)||e}const gN={}.hasOwnProperty;function $4(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),F4(n)(O4(D4(n).document().write(I4()(e,t,!0))))}function F4(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Je),autolinkProtocol:O,autolinkEmail:O,atxHeading:o(Ie),blockQuote:o(ne),characterEscape:O,characterReference:O,codeFenced:o(re),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:o(re,c),codeText:o(ie,c),codeTextData:O,data:O,codeFlowValue:O,definition:o(pe),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:o(ye),hardBreakEscape:o($e),hardBreakTrailing:o($e),htmlFlow:o(Se,c),htmlFlowData:O,htmlText:o(Se,c),htmlTextData:O,image:o(Ge),label:c,link:o(Je),listItem:o(ge),listItemValue:g,listOrdered:o(_e,f),listUnordered:o(_e),paragraph:o(he),reference:$,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:o(Ie),strong:o(ae),thematicBreak:o(Ue)},exit:{atxHeading:d(),atxHeadingSequence:E,autolink:d(),autolinkEmail:Q,autolinkProtocol:I,blockQuote:d(),characterEscapeValue:M,characterReferenceMarkerHexadecimal:q,characterReferenceMarkerNumeric:q,characterReferenceValue:X,characterReference:Y,codeFenced:d(v),codeFencedFence:C,codeFencedFenceInfo:x,codeFencedFenceMeta:w,codeFlowValue:M,codeIndented:d(S),codeText:d(G),codeTextData:M,data:M,definition:d(),definitionDestinationString:k,definitionLabelString:_,definitionTitleString:b,emphasis:d(),hardBreakEscape:d(B),hardBreakTrailing:d(B),htmlFlow:d(F),htmlFlowData:M,htmlText:d(K),htmlTextData:M,image:d(Z),label:z,labelText:J,lineEnding:H,link:d(V),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:te,resourceDestinationString:P,resourceTitleString:D,resource:U,setextHeading:d(A),setextHeadingLineSequence:L,setextHeadingText:T,strong:d(),thematicBreak:d()}};xN(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(de){let Ae={type:"root",children:[]};const ue={stack:[Ae],tokenStack:[],config:t,enter:u,exit:h,buffer:c,resume:m,data:n},Fe=[];let Xe=-1;for(;++Xe<de.length;)if(de[Xe][1].type==="listOrdered"||de[Xe][1].type==="listUnordered")if(de[Xe][0]==="enter")Fe.push(Xe);else{const it=Fe.pop();Xe=a(de,it,Xe)}for(Xe=-1;++Xe<de.length;){const it=t[de[Xe][0]];gN.call(it,de[Xe][1].type)&&it[de[Xe][1].type].call(Object.assign({sliceSerialize:de[Xe][2].sliceSerialize},ue),de[Xe][1])}if(ue.tokenStack.length>0){const it=ue.tokenStack[ue.tokenStack.length-1];(it[1]||tC).call(ue,void 0,it[0])}for(Ae.position={start:Ki(de.length>0?de[0][1].start:{line:1,column:1,offset:0}),end:Ki(de.length>0?de[de.length-2][1].end:{line:1,column:1,offset:0})},Xe=-1;++Xe<t.transforms.length;)Ae=t.transforms[Xe](Ae)||Ae;return Ae}function a(de,Ae,ue){let Fe=Ae-1,Xe=-1,it=!1,Ze,lt,gt,De;for(;++Fe<=ue;){const Re=de[Fe];switch(Re[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Re[0]==="enter"?Xe++:Xe--,De=void 0;break}case"lineEndingBlank":{Re[0]==="enter"&&(Ze&&!De&&!Xe&&!gt&&(gt=Fe),De=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:De=void 0}if(!Xe&&Re[0]==="enter"&&Re[1].type==="listItemPrefix"||Xe===-1&&Re[0]==="exit"&&(Re[1].type==="listUnordered"||Re[1].type==="listOrdered")){if(Ze){let ke=Fe;for(lt=void 0;ke--;){const We=de[ke];if(We[1].type==="lineEnding"||We[1].type==="lineEndingBlank"){if(We[0]==="exit")continue;lt&&(de[lt][1].type="lineEndingBlank",it=!0),We[1].type="lineEnding",lt=ke}else if(!(We[1].type==="linePrefix"||We[1].type==="blockQuotePrefix"||We[1].type==="blockQuotePrefixWhitespace"||We[1].type==="blockQuoteMarker"||We[1].type==="listItemIndent"))break}gt&&(!lt||gt<lt)&&(Ze._spread=!0),Ze.end=Object.assign({},lt?de[lt][1].start:Re[1].end),de.splice(lt||Fe,0,["exit",Ze,Re[2]]),Fe++,ue++}if(Re[1].type==="listItemPrefix"){const ke={type:"listItem",_spread:!1,start:Object.assign({},Re[1].start),end:void 0};Ze=ke,de.splice(Fe,0,["enter",ke,Re[2]]),Fe++,ue++,gt=void 0,De=!0}}}return de[Ae][1]._spread=it,ue}function o(de,Ae){return ue;function ue(Fe){u.call(this,de(Fe),Fe),Ae&&Ae.call(this,Fe)}}function c(){this.stack.push({type:"fragment",children:[]})}function u(de,Ae,ue){this.stack[this.stack.length-1].children.push(de),this.stack.push(de),this.tokenStack.push([Ae,ue||void 0]),de.position={start:Ki(Ae.start),end:void 0}}function d(de){return Ae;function Ae(ue){de&&de.call(this,ue),h.call(this,ue)}}function h(de,Ae){const ue=this.stack.pop(),Fe=this.tokenStack.pop();if(Fe)Fe[0].type!==de.type&&(Ae?Ae.call(this,de,Fe[0]):(Fe[1]||tC).call(this,de,Fe[0]));else throw new Error("Cannot close `"+de.type+"` ("+tu({start:de.start,end:de.end})+"): it’s not open");ue.position.end=Ki(de.end)}function m(){return $b(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function g(de){if(this.data.expectingFirstListItemValue){const Ae=this.stack[this.stack.length-2];Ae.start=Number.parseInt(this.sliceSerialize(de),10),this.data.expectingFirstListItemValue=void 0}}function x(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.lang=de}function w(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.meta=de}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=de.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=de.replace(/(\r?\n|\r)$/g,"")}function _(de){const Ae=this.resume(),ue=this.stack[this.stack.length-1];ue.label=Ae,ue.identifier=ys(this.sliceSerialize(de)).toLowerCase()}function b(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.title=de}function k(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.url=de}function E(de){const Ae=this.stack[this.stack.length-1];if(!Ae.depth){const ue=this.sliceSerialize(de).length;Ae.depth=ue}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function L(de){const Ae=this.stack[this.stack.length-1];Ae.depth=this.sliceSerialize(de).codePointAt(0)===61?1:2}function A(){this.data.setextHeadingSlurpLineEnding=void 0}function O(de){const ue=this.stack[this.stack.length-1].children;let Fe=ue[ue.length-1];(!Fe||Fe.type!=="text")&&(Fe=Pe(),Fe.position={start:Ki(de.start),end:void 0},ue.push(Fe)),this.stack.push(Fe)}function M(de){const Ae=this.stack.pop();Ae.value+=this.sliceSerialize(de),Ae.position.end=Ki(de.end)}function H(de){const Ae=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ue=Ae.children[Ae.children.length-1];ue.position.end=Ki(de.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Ae.type)&&(O.call(this,de),M.call(this,de))}function B(){this.data.atHardBreak=!0}function F(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=de}function K(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=de}function G(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=de}function V(){const de=this.stack[this.stack.length-1];if(this.data.inReference){const Ae=this.data.referenceType||"shortcut";de.type+="Reference",de.referenceType=Ae,delete de.url,delete de.title}else delete de.identifier,delete de.label;this.data.referenceType=void 0}function Z(){const de=this.stack[this.stack.length-1];if(this.data.inReference){const Ae=this.data.referenceType||"shortcut";de.type+="Reference",de.referenceType=Ae,delete de.url,delete de.title}else delete de.identifier,delete de.label;this.data.referenceType=void 0}function J(de){const Ae=this.sliceSerialize(de),ue=this.stack[this.stack.length-2];ue.label=P4(Ae),ue.identifier=ys(Ae).toLowerCase()}function z(){const de=this.stack[this.stack.length-1],Ae=this.resume(),ue=this.stack[this.stack.length-1];if(this.data.inReference=!0,ue.type==="link"){const Fe=de.children;ue.children=Fe}else ue.alt=Ae}function P(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.url=de}function D(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.title=de}function U(){this.data.inReference=void 0}function $(){this.data.referenceType="collapsed"}function te(de){const Ae=this.resume(),ue=this.stack[this.stack.length-1];ue.label=Ae,ue.identifier=ys(this.sliceSerialize(de)).toLowerCase(),this.data.referenceType="full"}function q(de){this.data.characterReferenceType=de.type}function X(de){const Ae=this.sliceSerialize(de),ue=this.data.characterReferenceType;let Fe;ue?(Fe=aN(Ae,ue==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Fe=Fb(Ae);const Xe=this.stack[this.stack.length-1];Xe.value+=Fe}function Y(de){const Ae=this.stack.pop();Ae.position.end=Ki(de.end)}function I(de){M.call(this,de);const Ae=this.stack[this.stack.length-1];Ae.url=this.sliceSerialize(de)}function Q(de){M.call(this,de);const Ae=this.stack[this.stack.length-1];Ae.url="mailto:"+this.sliceSerialize(de)}function ne(){return{type:"blockquote",children:[]}}function re(){return{type:"code",lang:null,meta:null,value:""}}function ie(){return{type:"inlineCode",value:""}}function pe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ye(){return{type:"emphasis",children:[]}}function Ie(){return{type:"heading",depth:0,children:[]}}function $e(){return{type:"break"}}function Se(){return{type:"html",value:""}}function Ge(){return{type:"image",title:null,url:"",alt:null}}function Je(){return{type:"link",title:null,url:"",children:[]}}function _e(de){return{type:"list",ordered:de.type==="listOrdered",start:null,spread:de._spread,children:[]}}function ge(de){return{type:"listItem",spread:de._spread,checked:null,children:[]}}function he(){return{type:"paragraph",children:[]}}function ae(){return{type:"strong",children:[]}}function Pe(){return{type:"text",value:""}}function Ue(){return{type:"thematicBreak"}}}function Ki(e){return{line:e.line,column:e.column,offset:e.offset}}function xN(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?xN(e,r):H4(e,r)}}function H4(e,t){let n;for(n in t)if(gN.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 tC(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+tu({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+tu({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+tu({start:t.start,end:t.end})+") is still open")}function z4(e){const t=this;t.parser=n;function n(r){return $4(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function U4(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 V4(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
71
|
+
`}]}function W4(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 o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function G4(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function q4(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function K4(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=Bl(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let c,u=e.footnoteCounts.get(r);u===void 0?(u=0,e.footnoteOrder.push(r),c=e.footnoteOrder.length):c=o+1,u+=1,e.footnoteCounts.set(r,u);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,d);const h={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,h),e.applyData(t,h)}function Y4(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 X4(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function yN(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),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const c=a[a.length-1];return c&&c.type==="text"?c.value+=r:a.push({type:"text",value:r}),a}function Q4(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return yN(e,t);const a={src:Bl(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(a.title=r.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function J4(e,t){const n={src:Bl(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 Z4(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 eP(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return yN(e,t);const a={href:Bl(r.url||"")};r.title!==null&&r.title!==void 0&&(a.title=r.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function tP(e,t){const n={href:Bl(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 nP(e,t,n){const r=e.all(t),a=n?rP(n):bN(t),o={},c=[];if(typeof t.checked=="boolean"){const m=r[0];let f;m&&m.type==="element"&&m.tagName==="p"?f=m:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let u=-1;for(;++u<r.length;){const m=r[u];(a||u!==0||m.type!=="element"||m.tagName!=="p")&&c.push({type:"text",value:`
|
|
73
|
+
`}),m.type==="element"&&m.tagName==="p"&&!a?c.push(...m.children):c.push(m)}const d=r[r.length-1];d&&(a||d.type!=="element"||d.tagName!=="p")&&c.push({type:"text",value:`
|
|
74
|
+
`});const h={type:"element",tagName:"li",properties:o,children:c};return e.patch(t,h),e.applyData(t,h)}function rP(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=bN(n[r])}return t}function bN(e){const t=e.spread;return t??e.children.length>1}function sP(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 c=r[a];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function iP(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function aP(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function oP(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function lP(e,t){const n=e.all(t),r=n.shift(),a=[];if(r){const c={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],c),a.push(c)}if(n.length>0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},u=Ib(t.children[1]),d=JE(t.children[t.children.length-1]);u&&d&&(c.position={start:u,end:d}),a.push(c)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function cP(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",c=n&&n.type==="table"?n.align:void 0,u=c?c.length:t.children.length;let d=-1;const h=[];for(;++d<u;){const f=t.children[d],g={},x=c?c[d]:void 0;x&&(g.align=x);let w={type:"element",tagName:o,properties:g,children:[]};f&&(w.children=e.all(f),e.patch(f,w),w=e.applyData(f,w)),h.push(w)}const m={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,m),e.applyData(t,m)}function uP(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const nC=9,rC=32;function dP(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const o=[];for(;r;)o.push(sC(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return o.push(sC(t.slice(a),a>0,!1)),o.join("")}function sC(e,t,n){let r=0,a=e.length;if(t){let o=e.codePointAt(r);for(;o===nC||o===rC;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(a-1);for(;o===nC||o===rC;)a--,o=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}function hP(e,t){const n={type:"text",value:dP(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function fP(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const mP={blockquote:U4,break:V4,code:W4,delete:G4,emphasis:q4,footnoteReference:K4,heading:Y4,html:X4,imageReference:Q4,image:J4,inlineCode:Z4,linkReference:eP,link:tP,listItem:nP,list:sP,paragraph:iP,root:aP,strong:oP,table:lP,tableCell:uP,tableRow:cP,text:hP,thematicBreak:fP,toml:oh,yaml:oh,definition:oh,footnoteDefinition:oh};function oh(){}const vN=-1,em=0,ru=1,tf=2,zb=3,Ub=4,Vb=5,Wb=6,_N=7,SN=8,wN=typeof self=="object"?self:globalThis,iC=(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 wN[e](t)},pP=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),r=a=>{if(e.has(a))return e.get(a);const[o,c]=t[a];switch(o){case em:case vN:return n(c,a);case ru:{const u=n([],a);for(const d of c)u.push(r(d));return u}case tf:{const u=n({},a);for(const[d,h]of c)u[r(d)]=r(h);return u}case zb:return n(new Date(c),a);case Ub:{const{source:u,flags:d}=c;return n(new RegExp(u,d),a)}case Vb:{const u=n(new Map,a);for(const[d,h]of c)u.set(r(d),r(h));return u}case Wb:{const u=n(new Set,a);for(const d of c)u.add(r(d));return u}case _N:{const{name:u,message:d}=c;return n(typeof wN[u]=="function"?iC(u,d):new Error(d),a)}case SN:return n(BigInt(c),a);case"BigInt":return n(Object(BigInt(c)),a);case"ArrayBuffer":return n(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:u}=new Uint8Array(c);return n(new DataView(u),c)}}return n(iC(o,c),a)};return r},aC=e=>pP(new Map,e)(0),Ua="",{toString:gP}={},{keys:xP}=Object,zc=e=>{const t=typeof e;if(t!=="object"||!e)return[em,t];const n=gP.call(e).slice(8,-1);switch(n){case"Array":return[ru,Ua];case"Object":return[tf,Ua];case"Date":return[zb,Ua];case"RegExp":return[Ub,Ua];case"Map":return[Vb,Ua];case"Set":return[Wb,Ua];case"DataView":return[ru,n]}return n.includes("Array")?[ru,n]:e instanceof Error?[_N,e.name||"Error"]:[tf,n]},lh=([e,t])=>e===em&&(t==="function"||t==="symbol"),yP=(e,t,n,r)=>{const a=(c,u)=>{const d=r.push(c)-1;return n.set(u,d),d},o=c=>{if(n.has(c))return n.get(c);let[u,d]=zc(c);switch(u){case em:{let m=c;switch(d){case"bigint":u=SN,m=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);m=null;break;case"undefined":return a([vN],c)}return a([u,m],c)}case ru:{if(d){let g=c;return d==="DataView"?g=new Uint8Array(c.buffer):d==="ArrayBuffer"&&(g=new Uint8Array(c)),a([d,[...g]],c)}const m=[],f=a([u,m],c);for(const g of c)m.push(o(g));return f}case tf:{if(d)switch(d){case"BigInt":return a([d,c.toString()],c);case"Boolean":case"Number":case"String":return a([d,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const m=[],f=a([u,m],c);for(const g of xP(c))(e||!lh(zc(c[g])))&&m.push([o(g),o(c[g])]);return f}case zb:return a([u,isNaN(c.getTime())?Ua:c.toISOString()],c);case Ub:{const{source:m,flags:f}=c;return a([u,{source:m,flags:f}],c)}case Vb:{const m=[],f=a([u,m],c);for(const[g,x]of c)(e||!(lh(zc(g))||lh(zc(x))))&&m.push([o(g),o(x)]);return f}case Wb:{const m=[],f=a([u,m],c);for(const g of c)(e||!lh(zc(g)))&&m.push(o(g));return f}}const{message:h}=c;return a([u,{name:d,message:h}],c)};return o},oC=(e,{json:t,lossy:n}={})=>{const r=[];return yP(!(t||n),!!t,new Map,r)(e),r},nf=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?aC(oC(e,t)):structuredClone(e):(e,t)=>aC(oC(e,t));function bP(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 vP(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function _P(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||bP,r=e.options.footnoteBackLabel||vP,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},u=[];let d=-1;for(;++d<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[d]);if(!h)continue;const m=e.all(h),f=String(h.identifier).toUpperCase(),g=Bl(f.toLowerCase());let x=0;const w=[],C=e.footnoteCounts.get(f);for(;C!==void 0&&++x<=C;){w.length>0&&w.push({type:"text",value:" "});let _=typeof n=="string"?n:n(d,x);typeof _=="string"&&(_={type:"text",value:_}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(x>1?"-"+x:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(d,x),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const v=m[m.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(...w)}else m.push(...w);const S={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(m,!0)};e.patch(h,S),u.push(S)}if(u.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...nf(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
|
|
75
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(u,!0)},{type:"text",value:`
|
|
76
|
+
`}]}}const tm=(function(e){if(e==null)return kP;if(typeof e=="function")return nm(e);if(typeof e=="object")return Array.isArray(e)?SP(e):wP(e);if(typeof e=="string")return CP(e);throw new Error("Expected function, string, or object as test")});function SP(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=tm(e[n]);return nm(r);function r(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function wP(e){const t=e;return nm(n);function n(r){const a=r;let o;for(o in e)if(a[o]!==t[o])return!1;return!0}}function CP(e){return nm(t);function t(n){return n&&n.type===e}}function nm(e){return t;function t(n,r,a){return!!(jP(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function kP(){return!0}function jP(e){return e!==null&&typeof e=="object"&&"type"in e}const CN=[],EP=!0,vy=!1,NP="skip";function kN(e,t,n,r){let a;typeof t=="function"&&typeof n!="function"?(r=n,n=t):a=t;const o=tm(a),c=r?-1:1;u(e,void 0,[])();function u(d,h,m){const f=d&&typeof d=="object"?d:{};if(typeof f.type=="string"){const x=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(d.type+(x?"<"+x+">":""))+")"})}return g;function g(){let x=CN,w,C,v;if((!t||o(d,h,m[m.length-1]||void 0))&&(x=TP(n(d,m)),x[0]===vy))return x;if("children"in d&&d.children){const S=d;if(S.children&&x[0]!==NP)for(C=(r?S.children.length:-1)+c,v=m.concat(S);C>-1&&C<S.children.length;){const _=S.children[C];if(w=u(_,C,v)(),w[0]===vy)return w;C=typeof w[1]=="number"?w[1]:C+c}}return x}}}function TP(e){return Array.isArray(e)?e:typeof e=="number"?[EP,e]:e==null?CN:[e]}function Gb(e,t,n,r){let a,o,c;typeof t=="function"&&typeof n!="function"?(o=void 0,c=t,a=n):(o=t,c=n,a=r),kN(e,o,u,a);function u(d,h){const m=h[h.length-1],f=m?m.children.indexOf(d):void 0;return c(d,f,m)}}const _y={}.hasOwnProperty,AP={};function LP(e,t){const n=t||AP,r=new Map,a=new Map,o=new Map,c={...mP,...n.handlers},u={all:h,applyData:DP,definitionById:r,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:c,one:d,options:n,patch:RP,wrap:IP};return Gb(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const f=m.type==="definition"?r:a,g=String(m.identifier).toUpperCase();f.has(g)||f.set(g,m)}}),u;function d(m,f){const g=m.type,x=u.handlers[g];if(_y.call(u.handlers,g)&&x)return x(u,m,f);if(u.options.passThrough&&u.options.passThrough.includes(g)){if("children"in m){const{children:C,...v}=m,S=nf(v);return S.children=u.all(m),S}return nf(m)}return(u.options.unknownHandler||OP)(u,m,f)}function h(m){const f=[];if("children"in m){const g=m.children;let x=-1;for(;++x<g.length;){const w=u.one(g[x],m);if(w){if(x&&g[x-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=lC(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=lC(C.value))}Array.isArray(w)?f.push(...w):f.push(w)}}}return f}}function RP(e,t){e.position&&(t.position=vI(e))}function DP(e,t){let n=t;if(e&&e.data){const r=e.data.hName,a=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const c="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:c}}n.type==="element"&&o&&Object.assign(n.properties,nf(o)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function OP(e,t){const n=t.data||{},r="value"in t&&!(_y.call(n,"hProperties")||_y.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 IP(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 lC(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function cC(e,t){const n=LP(e,t),r=n.one(e,void 0),a=_P(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&o.children.push({type:"text",value:`
|
|
80
|
+
`},a),o}function MP(e,t){return e&&"run"in e?async function(n,r){const a=cC(n,{file:r,...t});await e.run(a,r)}:function(n,r){return cC(n,{file:r,...e||t})}}function uC(e){if(e)throw e}var nx,dC;function PP(){if(dC)return nx;dC=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]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var m=e.call(h,"constructor"),f=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!m&&!f)return!1;var g;for(g in h);return typeof g>"u"||e.call(h,g)},c=function(h,m){n&&m.name==="__proto__"?n(h,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):h[m.name]=m.newValue},u=function(h,m){if(m==="__proto__")if(e.call(h,m)){if(r)return r(h,m).value}else return;return h[m]};return nx=function d(){var h,m,f,g,x,w,C=arguments[0],v=1,S=arguments.length,_=!1;for(typeof C=="boolean"&&(_=C,C=arguments[1]||{},v=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});v<S;++v)if(h=arguments[v],h!=null)for(m in h)f=u(C,m),g=u(h,m),C!==g&&(_&&g&&(o(g)||(x=a(g)))?(x?(x=!1,w=f&&a(f)?f:[]):w=f&&o(f)?f:{},c(C,{name:m,newValue:d(_,w,g)})):typeof g<"u"&&c(C,{name:m,newValue:g}));return C},nx}var BP=PP();const rx=Nf(BP);function Sy(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 $P(){const e=[],t={run:n,use:r};return t;function n(...a){let o=-1;const c=a.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);u(null,...a);function u(d,...h){const m=e[++o];let f=-1;if(d){c(d);return}for(;++f<a.length;)(h[f]===null||h[f]===void 0)&&(h[f]=a[f]);a=h,m?FP(m,u)(...h):c(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 FP(e,t){let n;return r;function r(...c){const u=e.length>c.length;let d;u&&c.push(a);try{d=e.apply(this,c)}catch(h){const m=h;if(u&&n)throw m;return a(m)}u||(d&&d.then&&typeof d.then=="function"?d.then(o,a):d instanceof Error?a(d):o(d))}function a(c,...u){n||(n=!0,t(c,...u))}function o(c){a(null,c)}}const Rs={basename:HP,dirname:zP,extname:UP,join:VP,sep:"/"};function HP(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Du(e);let n=0,r=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else r<0&&(o=!0,r=a+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let c=-1,u=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else c<0&&(o=!0,c=a+1),u>-1&&(e.codePointAt(a)===t.codePointAt(u--)?u<0&&(r=a):(u=-1,r=c));return n===r?r=c:r<0&&(r=e.length),e.slice(n,r)}function zP(e){if(Du(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 UP(e){Du(e);let t=e.length,n=-1,r=0,a=-1,o=0,c;for(;t--;){const u=e.codePointAt(t);if(u===47){if(c){r=t+1;break}continue}n<0&&(c=!0,n=t+1),u===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===r+1?"":e.slice(a,n)}function VP(...e){let t=-1,n;for(;++t<e.length;)Du(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":WP(n)}function WP(e){Du(e);const t=e.codePointAt(0)===47;let n=GP(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function GP(e,t){let n="",r=0,a=-1,o=0,c=-1,u,d;for(;++c<=e.length;){if(c<e.length)u=e.codePointAt(c);else{if(u===47)break;u=47}if(u===47){if(!(a===c-1||o===1))if(a!==c-1&&o===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=c,o=0;continue}}else if(n.length>0){n="",r=0,a=c,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),r=c-a-1;a=c,o=0}else u===46&&o>-1?o++:o=-1}return n}function Du(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const qP={cwd:KP};function KP(){return"/"}function wy(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function YP(e){if(typeof e=="string")e=new URL(e);else if(!wy(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 XP(e)}function XP(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 sx=["history","path","basename","stem","extname","dirname"];class jN{constructor(t){let n;t?wy(t)?n={path:t}:typeof t=="string"||QP(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":qP.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<sx.length;){const o=sx[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let a;for(a in n)sx.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Rs.basename(this.path):void 0}set basename(t){ax(t,"basename"),ix(t,"basename"),this.path=Rs.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Rs.dirname(this.path):void 0}set dirname(t){hC(this.basename,"dirname"),this.path=Rs.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Rs.extname(this.path):void 0}set extname(t){if(ix(t,"extname"),hC(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=Rs.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){wy(t)&&(t=YP(t)),ax(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Rs.basename(this.path,this.extname):void 0}set stem(t){ax(t,"stem"),ix(t,"stem"),this.path=Rs.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 or(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 ix(e,t){if(e&&e.includes(Rs.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Rs.sep+"`")}function ax(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function hC(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function QP(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const JP=(function(e){const r=this.constructor.prototype,a=r[e],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,r),o}),ZP={}.hasOwnProperty;class qb extends JP{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=$P()}copy(){const t=new qb;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(rx(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(cx("data",this.frozen),this.namespace[t]=n,this):ZP.call(this.namespace,t)&&this.namespace[t]||void 0:t?(cx("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=ch(t),r=this.parser||this.Parser;return ox("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),ox("process",this.parser||this.Parser),lx("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(o,c){const u=ch(t),d=r.parse(u);r.run(d,u,function(m,f,g){if(m||!f||!g)return h(m);const x=f,w=r.stringify(x,g);n6(w)?g.value=w:g.result=w,h(m,g)});function h(m,f){m||!f?c(m):o?o(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),ox("processSync",this.parser||this.Parser),lx("processSync",this.compiler||this.Compiler),this.process(t,a),mC("processSync","process",n),r;function a(o,c){n=!0,uC(o),r=c}}run(t,n,r){fC(t),this.freeze();const a=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(c,u){const d=ch(n);a.run(t,d,h);function h(m,f,g){const x=f||t;m?u(m):c?c(x):r(void 0,x,g)}}}runSync(t,n){let r=!1,a;return this.run(t,n,o),mC("runSync","run",r),a;function o(c,u){uC(c),a=u,r=!0}}stringify(t,n){this.freeze();const r=ch(n),a=this.compiler||this.Compiler;return lx("stringify",a),fC(t),a(t,r)}use(t,...n){const r=this.attachers,a=this.namespace;if(cx("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?u(t):c(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(h){if(typeof h=="function")d(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[m,...f]=h;d(m,f)}else c(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function c(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");u(h.plugins),h.settings&&(a.settings=rx(!0,a.settings,h.settings))}function u(h){let m=-1;if(h!=null)if(Array.isArray(h))for(;++m<h.length;){const f=h[m];o(f)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function d(h,m){let f=-1,g=-1;for(;++f<r.length;)if(r[f][0]===h){g=f;break}if(g===-1)r.push([h,...m]);else if(m.length>0){let[x,...w]=m;const C=r[g][1];Sy(C)&&Sy(x)&&(x=rx(!0,C,x)),r[g]=[h,x,...w]}}}}const e6=new qb().freeze();function ox(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function lx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function cx(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 fC(e){if(!Sy(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function mC(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ch(e){return t6(e)?e:new jN(e)}function t6(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function n6(e){return typeof e=="string"||r6(e)}function r6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const s6="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",pC=[],gC={allowDangerousHtml:!0},i6=/^(https?|ircs?|mailto|xmpp)$/i,a6=[{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 o6(e){const t=l6(e),n=c6(e);return u6(t.runSync(t.parse(n),n),e)}function l6(e){const t=e.rehypePlugins||pC,n=e.remarkPlugins||pC,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...gC}:gC;return e6().use(z4).use(n).use(MP,r).use(t)}function c6(e){const t=e.children||"",n=new jN;return typeof t=="string"&&(n.value=t),n}function u6(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,u=t.unwrapDisallowed,d=t.urlTransform||d6;for(const m of a6)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+s6+m.id,void 0);return Gb(e,h),kI(e,{Fragment:s.Fragment,components:a,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function h(m,f,g){if(m.type==="raw"&&g&&typeof f=="number")return c?g.children.splice(f,1):g.children[f]={type:"text",value:m.value},f;if(m.type==="element"){let x;for(x in Zg)if(Object.hasOwn(Zg,x)&&Object.hasOwn(m.properties,x)){const w=m.properties[x],C=Zg[x];(C===null||C.includes(m.tagName))&&(m.properties[x]=d(String(w||""),x,m))}}if(m.type==="element"){let x=n?!n.includes(m.tagName):o?o.includes(m.tagName):!1;if(!x&&r&&typeof f=="number"&&(x=!r(m,f,g)),x&&g&&typeof f=="number")return u&&m.children?g.children.splice(f,1,...m.children):g.children.splice(f,1),f}}}function d6(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||i6.test(e.slice(0,t))?e:""}function xC(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 h6(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function f6(e,t,n){const a=tm((n||{}).ignore||[]),o=m6(t);let c=-1;for(;++c<o.length;)kN(e,"text",u);function u(h,m){let f=-1,g;for(;++f<m.length;){const x=m[f],w=g?g.children:void 0;if(a(x,w?w.indexOf(x):void 0,g))return;g=x}if(g)return d(h,m)}function d(h,m){const f=m[m.length-1],g=o[c][0],x=o[c][1];let w=0;const v=f.children.indexOf(h);let S=!1,_=[];g.lastIndex=0;let b=g.exec(h.value);for(;b;){const k=b.index,E={index:b.index,input:b.input,stack:[...m,h]};let T=x(...b,E);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?g.lastIndex=k+1:(w!==k&&_.push({type:"text",value:h.value.slice(w,k)}),Array.isArray(T)?_.push(...T):T&&_.push(T),w=k+b[0].length,S=!0),!g.global)break;b=g.exec(h.value)}return S?(w<h.value.length&&_.push({type:"text",value:h.value.slice(w)}),f.children.splice(v,1,..._)):_=[h],v+_.length}}function m6(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([p6(a[0]),g6(a[1])])}return t}function p6(e){return typeof e=="string"?new RegExp(h6(e),"g"):e}function g6(e){return typeof e=="function"?e:function(){return e}}const ux="phrasing",dx=["autolink","link","image","label"];function x6(){return{transforms:[C6],enter:{literalAutolink:b6,literalAutolinkEmail:hx,literalAutolinkHttp:hx,literalAutolinkWww:hx},exit:{literalAutolink:w6,literalAutolinkEmail:S6,literalAutolinkHttp:v6,literalAutolinkWww:_6}}}function y6(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ux,notInConstruct:dx},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ux,notInConstruct:dx},{character:":",before:"[ps]",after:"\\/",inConstruct:ux,notInConstruct:dx}]}}function b6(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function hx(e){this.config.enter.autolinkProtocol.call(this,e)}function v6(e){this.config.exit.autolinkProtocol.call(this,e)}function _6(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 S6(e){this.config.exit.autolinkEmail.call(this,e)}function w6(e){this.exit(e)}function C6(e){f6(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,k6],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),j6]],{ignore:["link","linkReference"]})}function k6(e,t,n,r,a){let o="";if(!EN(a)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!E6(n)))return!1;const c=N6(n+r);if(!c[0])return!1;const u={type:"link",title:null,url:o+t+c[0],children:[{type:"text",value:t+c[0]}]};return c[1]?[u,{type:"text",value:c[1]}]:u}function j6(e,t,n,r){return!EN(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function E6(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 N6(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=xC(e,"(");let o=xC(e,")");for(;r!==-1&&a>o;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[e,n]}function EN(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||io(n)||Jf(n))&&(!t||n!==47)}NN.peek=P6;function T6(){this.buffer()}function A6(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function L6(){this.buffer()}function R6(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function D6(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ys(this.sliceSerialize(e)).toLowerCase(),n.label=t}function O6(e){this.exit(e)}function I6(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ys(this.sliceSerialize(e)).toLowerCase(),n.label=t}function M6(e){this.exit(e)}function P6(){return"["}function NN(e,t,n,r){const a=n.createTracker(r);let o=a.move("[^");const c=n.enter("footnoteReference"),u=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),u(),c(),o+=a.move("]"),o}function B6(){return{enter:{gfmFootnoteCallString:T6,gfmFootnoteCall:A6,gfmFootnoteDefinitionLabelString:L6,gfmFootnoteDefinition:R6},exit:{gfmFootnoteCallString:D6,gfmFootnoteCall:O6,gfmFootnoteDefinitionLabelString:I6,gfmFootnoteDefinition:M6}}}function $6(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:NN},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,a,o,c){const u=o.createTracker(c);let d=u.move("[^");const h=o.enter("footnoteDefinition"),m=o.enter("label");return d+=u.move(o.safe(o.associationId(r),{before:d,after:"]"})),m(),d+=u.move("]:"),r.children&&r.children.length>0&&(u.shift(4),d+=u.move((t?`
|
|
81
|
+
`:" ")+o.indentLines(o.containerFlow(r,u.current()),t?TN:F6))),h(),d}}function F6(e,t,n){return t===0?e:TN(e,t,n)}function TN(e,t,n){return(n?"":" ")+e}const H6=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];AN.peek=G6;function z6(){return{canContainEols:["delete"],enter:{strikethrough:V6},exit:{strikethrough:W6}}}function U6(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:H6}],handlers:{delete:AN}}}function V6(e){this.enter({type:"delete",children:[]},e)}function W6(e){this.exit(e)}function AN(e,t,n,r){const a=n.createTracker(r),o=n.enter("strikethrough");let c=a.move("~~");return c+=n.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),o(),c}function G6(){return"~"}function q6(e){return e.length}function K6(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||q6,o=[],c=[],u=[],d=[];let h=0,m=-1;for(;++m<e.length;){const C=[],v=[];let S=-1;for(e[m].length>h&&(h=e[m].length);++S<e[m].length;){const _=Y6(e[m][S]);if(n.alignDelimiters!==!1){const b=a(_);v[S]=b,(d[S]===void 0||b>d[S])&&(d[S]=b)}C.push(_)}c[m]=C,u[m]=v}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<h;)o[f]=yC(r[f]);else{const C=yC(r);for(;++f<h;)o[f]=C}f=-1;const g=[],x=[];for(;++f<h;){const C=o[f];let v="",S="";C===99?(v=":",S=":"):C===108?v=":":C===114&&(S=":");let _=n.alignDelimiters===!1?1:Math.max(1,d[f]-v.length-S.length);const b=v+"-".repeat(_)+S;n.alignDelimiters!==!1&&(_=v.length+_+S.length,_>d[f]&&(d[f]=_),x[f]=_),g[f]=b}c.splice(1,0,g),u.splice(1,0,x),m=-1;const w=[];for(;++m<c.length;){const C=c[m],v=u[m];f=-1;const S=[];for(;++f<h;){const _=C[f]||"";let b="",k="";if(n.alignDelimiters!==!1){const E=d[f]-(v[f]||0),T=o[f];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&&!f&&S.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||f)&&S.push(" "),n.alignDelimiters!==!1&&S.push(b),S.push(_),n.alignDelimiters!==!1&&S.push(k),n.padding!==!1&&S.push(" "),(n.delimiterEnd!==!1||f!==h-1)&&S.push("|")}w.push(n.delimiterEnd===!1?S.join("").replace(/ +$/,""):S.join(""))}return w.join(`
|
|
82
|
+
`)}function Y6(e){return e==null?"":String(e)}function yC(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 X6(e,t,n,r){const a=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const c=n.indentLines(n.containerFlow(e,o.current()),Q6);return a(),c}function Q6(e,t,n){return">"+(n?"":" ")+e}function J6(e,t){return bC(e,t.inConstruct,!0)&&!bC(e,t.notInConstruct,!1)}function bC(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 vC(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
|
|
83
|
+
`&&J6(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
84
|
+
`}function Z6(e,t){const n=String(e);let r=n.indexOf(t),a=r,o=0,c=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===a?++o>c&&(c=o):o=1,a=r+t.length,r=n.indexOf(t,a);return c}function eB(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 tB(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 nB(e,t,n,r){const a=tB(n),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(eB(e,n)){const f=n.enter("codeIndented"),g=n.indentLines(o,rB);return f(),g}const u=n.createTracker(r),d=a.repeat(Math.max(Z6(o,a)+1,3)),h=n.enter("codeFenced");let m=u.move(d);if(e.lang){const f=n.enter(`codeFencedLang${c}`);m+=u.move(n.safe(e.lang,{before:m,after:" ",encode:["`"],...u.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${c}`);m+=u.move(" "),m+=u.move(n.safe(e.meta,{before:m,after:`
|
|
85
|
+
`,encode:["`"],...u.current()})),f()}return m+=u.move(`
|
|
86
|
+
`),o&&(m+=u.move(o+`
|
|
87
|
+
`)),m+=u.move(d),h(),m}function rB(e,t,n){return(n?"":" ")+e}function Kb(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 sB(e,t,n,r){const a=Kb(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("definition");let u=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("]: "),u(),!e.url||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(n.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(u=n.enter("destinationRaw"),h+=d.move(n.safe(e.url,{before:h,after:e.title?" ":`
|
|
88
|
+
`,...d.current()}))),u(),e.title&&(u=n.enter(`title${o}`),h+=d.move(" "+a),h+=d.move(n.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),u()),c(),h}function iB(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 bu(e){return"&#x"+e.toString(16).toUpperCase()+";"}function rf(e,t,n){const r=Tl(e),a=Tl(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}}LN.peek=aB;function LN(e,t,n,r){const a=iB(n),o=n.enter("emphasis"),c=n.createTracker(r),u=c.move(a);let d=c.move(n.containerPhrasing(e,{after:a,before:u,...c.current()}));const h=d.charCodeAt(0),m=rf(r.before.charCodeAt(r.before.length-1),h,a);m.inside&&(d=bu(h)+d.slice(1));const f=d.charCodeAt(d.length-1),g=rf(r.after.charCodeAt(0),f,a);g.inside&&(d=d.slice(0,-1)+bu(f));const x=c.move(a);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:m.outside},u+d+x}function aB(e,t,n){return n.options.emphasis||"*"}function oB(e,t){let n=!1;return Gb(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,vy}),!!((!e.depth||e.depth<3)&&$b(e)&&(t.options.setext||n))}function lB(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(oB(e,n)){const m=n.enter("headingSetext"),f=n.enter("phrasing"),g=n.containerPhrasing(e,{...o.current(),before:`
|
|
89
|
+
`,after:`
|
|
90
|
+
`});return f(),m(),g+`
|
|
91
|
+
`+(a===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
|
|
92
|
+
`))+1))}const c="#".repeat(a),u=n.enter("headingAtx"),d=n.enter("phrasing");o.move(c+" ");let h=n.containerPhrasing(e,{before:"# ",after:`
|
|
93
|
+
`,...o.current()});return/^[\t ]/.test(h)&&(h=bu(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,n.options.closeAtx&&(h+=" "+c),d(),u(),h}RN.peek=cB;function RN(e){return e.value||""}function cB(){return"<"}DN.peek=uB;function DN(e,t,n,r){const a=Kb(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("image");let u=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("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(n.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(u=n.enter("destinationRaw"),h+=d.move(n.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),u(),e.title&&(u=n.enter(`title${o}`),h+=d.move(" "+a),h+=d.move(n.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),u()),h+=d.move(")"),c(),h}function uB(){return"!"}ON.peek=dB;function ON(e,t,n,r){const a=e.referenceType,o=n.enter("imageReference");let c=n.enter("label");const u=n.createTracker(r);let d=u.move("![");const h=n.safe(e.alt,{before:d,after:"]",...u.current()});d+=u.move(h+"]["),c();const m=n.stack;n.stack=[],c=n.enter("reference");const f=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return c(),n.stack=m,o(),a==="full"||!h||h!==f?d+=u.move(f+"]"):a==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function dB(){return"!"}IN.peek=hB;function IN(e,t,n){let r=e.value||"",a="`",o=-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+" ");++o<n.unsafe.length;){const c=n.unsafe[o],u=n.compilePattern(c);let d;if(c.atBreak)for(;d=u.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 hB(){return"`"}function MN(e,t){const n=$b(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))}PN.peek=fB;function PN(e,t,n,r){const a=Kb(n),o=a==='"'?"Quote":"Apostrophe",c=n.createTracker(r);let u,d;if(MN(e,n)){const m=n.stack;n.stack=[],u=n.enter("autolink");let f=c.move("<");return f+=c.move(n.containerPhrasing(e,{before:f,after:">",...c.current()})),f+=c.move(">"),u(),n.stack=m,f}u=n.enter("link"),d=n.enter("label");let h=c.move("[");return h+=c.move(n.containerPhrasing(e,{before:h,after:"](",...c.current()})),h+=c.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(n.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(d=n.enter("destinationRaw"),h+=c.move(n.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),d(),e.title&&(d=n.enter(`title${o}`),h+=c.move(" "+a),h+=c.move(n.safe(e.title,{before:h,after:a,...c.current()})),h+=c.move(a),d()),h+=c.move(")"),u(),h}function fB(e,t,n){return MN(e,n)?"<":"["}BN.peek=mB;function BN(e,t,n,r){const a=e.referenceType,o=n.enter("linkReference");let c=n.enter("label");const u=n.createTracker(r);let d=u.move("[");const h=n.containerPhrasing(e,{before:d,after:"]",...u.current()});d+=u.move(h+"]["),c();const m=n.stack;n.stack=[],c=n.enter("reference");const f=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return c(),n.stack=m,o(),a==="full"||!h||h!==f?d+=u.move(f+"]"):a==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function mB(){return"["}function Yb(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 pB(e){const t=Yb(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 gB(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 $N(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 xB(e,t,n,r){const a=n.enter("list"),o=n.bulletCurrent;let c=e.ordered?gB(n):Yb(n);const u=e.ordered?c==="."?")":".":pB(n);let d=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&m&&(!m.children||!m.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),$N(n)===c&&m){let f=-1;for(;++f<e.children.length;){const g=e.children[f];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(c=u),n.bulletCurrent=c;const h=n.containerFlow(e,r);return n.bulletLastUsed=c,n.bulletCurrent=o,a(),h}function yB(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 bB(e,t,n,r){const a=yB(n);let o=n.bulletCurrent||Yb(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let c=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const u=n.createTracker(r);u.move(o+" ".repeat(c-o.length)),u.shift(c);const d=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,u.current()),m);return d(),h;function m(f,g,x){return g?(x?"":" ".repeat(c))+f:(x?o:o+" ".repeat(c-o.length))+f}}function vB(e,t,n,r){const a=n.enter("paragraph"),o=n.enter("phrasing"),c=n.containerPhrasing(e,r);return o(),a(),c}const _B=tm(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function SB(e,t,n,r){return(e.children.some(function(c){return _B(c)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function wB(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}FN.peek=CB;function FN(e,t,n,r){const a=wB(n),o=n.enter("strong"),c=n.createTracker(r),u=c.move(a+a);let d=c.move(n.containerPhrasing(e,{after:a,before:u,...c.current()}));const h=d.charCodeAt(0),m=rf(r.before.charCodeAt(r.before.length-1),h,a);m.inside&&(d=bu(h)+d.slice(1));const f=d.charCodeAt(d.length-1),g=rf(r.after.charCodeAt(0),f,a);g.inside&&(d=d.slice(0,-1)+bu(f));const x=c.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:m.outside},u+d+x}function CB(e,t,n){return n.options.strong||"*"}function kB(e,t,n,r){return n.safe(e.value,r)}function jB(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 EB(e,t,n){const r=($N(n)+(n.options.ruleSpaces?" ":"")).repeat(jB(n));return n.options.ruleSpaces?r.slice(0,-1):r}const HN={blockquote:X6,break:vC,code:nB,definition:sB,emphasis:LN,hardBreak:vC,heading:lB,html:RN,image:DN,imageReference:ON,inlineCode:IN,link:PN,linkReference:BN,list:xB,listItem:bB,paragraph:vB,root:SB,strong:FN,text:kB,thematicBreak:EB};function NB(){return{enter:{table:TB,tableData:_C,tableHeader:_C,tableRow:LB},exit:{codeText:RB,table:AB,tableData:fx,tableHeader:fx,tableRow:fx}}}function TB(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 AB(e){this.exit(e),this.data.inTable=void 0}function LB(e){this.enter({type:"tableRow",children:[]},e)}function fx(e){this.exit(e)}function _C(e){this.enter({type:"tableCell",children:[]},e)}function RB(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,DB));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function DB(e,t){return t==="|"?t:e}function OB(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,o=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:g,table:c,tableCell:d,tableRow:u}};function c(x,w,C,v){return h(m(x,C,v),x.align)}function u(x,w,C,v){const S=f(x,C,v),_=h([S]);return _.slice(0,_.indexOf(`
|
|
95
|
+
`))}function d(x,w,C,v){const S=C.enter("tableCell"),_=C.enter("phrasing"),b=C.containerPhrasing(x,{...v,before:o,after:o});return _(),S(),b}function h(x,w){return K6(x,{align:w,alignDelimiters:r,padding:n,stringLength:a})}function m(x,w,C){const v=x.children;let S=-1;const _=[],b=w.enter("table");for(;++S<v.length;)_[S]=f(v[S],w,C);return b(),_}function f(x,w,C){const v=x.children;let S=-1;const _=[],b=w.enter("tableRow");for(;++S<v.length;)_[S]=d(v[S],x,w,C);return b(),_}function g(x,w,C){let v=HN.inlineCode(x,w,C);return C.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function IB(){return{exit:{taskListCheckValueChecked:SC,taskListCheckValueUnchecked:SC,paragraph:PB}}}function MB(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:BB}}}function SC(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function PB(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 o=-1,c;for(;++o<a.length;){const u=a[o];if(u.type==="paragraph"){c=u;break}}c===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 BB(e,t,n,r){const a=e.children[0],o=typeof e.checked=="boolean"&&a&&a.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",u=n.createTracker(r);o&&u.move(c);let d=HN.listItem(e,t,n,{...r,...u.current()});return o&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),d;function h(m){return m+c}}function $B(){return[x6(),B6(),z6(),NB(),IB()]}function FB(e){return{extensions:[y6(),$6(e),U6(),OB(e),MB()]}}const HB={tokenize:qB,partial:!0},zN={tokenize:KB,partial:!0},UN={tokenize:YB,partial:!0},VN={tokenize:XB,partial:!0},zB={tokenize:QB,partial:!0},WN={name:"wwwAutolink",tokenize:WB,previous:qN},GN={name:"protocolAutolink",tokenize:GB,previous:KN},Ci={name:"emailAutolink",tokenize:VB,previous:YN},zs={};function UB(){return{text:zs}}let Ma=48;for(;Ma<123;)zs[Ma]=Ci,Ma++,Ma===58?Ma=65:Ma===91&&(Ma=97);zs[43]=Ci;zs[45]=Ci;zs[46]=Ci;zs[95]=Ci;zs[72]=[Ci,GN];zs[104]=[Ci,GN];zs[87]=[Ci,WN];zs[119]=[Ci,WN];function VB(e,t,n){const r=this;let a,o;return c;function c(f){return!Cy(f)||!YN.call(r,r.previous)||Xb(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(f))}function u(f){return Cy(f)?(e.consume(f),u):f===64?(e.consume(f),d):n(f)}function d(f){return f===46?e.check(zB,m,h)(f):f===45||f===95||ar(f)?(o=!0,e.consume(f),d):m(f)}function h(f){return e.consume(f),a=!0,d}function m(f){return o&&a&&dr(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function WB(e,t,n){const r=this;return a;function a(c){return c!==87&&c!==119||!qN.call(r,r.previous)||Xb(r.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(HB,e.attempt(zN,e.attempt(UN,o),n),n)(c))}function o(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function GB(e,t,n){const r=this;let a="",o=!1;return c;function c(f){return(f===72||f===104)&&KN.call(r,r.previous)&&!Xb(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(f),e.consume(f),u):n(f)}function u(f){if(dr(f)&&a.length<5)return a+=String.fromCodePoint(f),e.consume(f),u;if(f===58){const g=a.toLowerCase();if(g==="http"||g==="https")return e.consume(f),d}return n(f)}function d(f){return f===47?(e.consume(f),o?h:(o=!0,d)):n(f)}function h(f){return f===null||ef(f)||on(f)||io(f)||Jf(f)?n(f):e.attempt(zN,e.attempt(UN,m),n)(f)}function m(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function qB(e,t,n){let r=0;return a;function a(c){return(c===87||c===119)&&r<3?(r++,e.consume(c),a):c===46&&r===3?(e.consume(c),o):n(c)}function o(c){return c===null?n(c):t(c)}}function KB(e,t,n){let r,a,o;return c;function c(h){return h===46||h===95?e.check(VN,d,u)(h):h===null||on(h)||io(h)||h!==45&&Jf(h)?d(h):(o=!0,e.consume(h),c)}function u(h){return h===95?r=!0:(a=r,r=void 0),e.consume(h),c}function d(h){return a||r||!o?n(h):t(h)}}function YB(e,t){let n=0,r=0;return a;function a(c){return c===40?(n++,e.consume(c),a):c===41&&r<n?o(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(VN,t,o)(c):c===null||on(c)||io(c)?t(c):(e.consume(c),a)}function o(c){return c===41&&r++,e.consume(c),a}}function XB(e,t,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(e.consume(u),r):u===38?(e.consume(u),o):u===93?(e.consume(u),a):u===60||u===null||on(u)||io(u)?t(u):n(u)}function a(u){return u===null||u===40||u===91||on(u)||io(u)?t(u):r(u)}function o(u){return dr(u)?c(u):n(u)}function c(u){return u===59?(e.consume(u),r):dr(u)?(e.consume(u),c):n(u)}}function QB(e,t,n){return r;function r(o){return e.consume(o),a}function a(o){return ar(o)?n(o):t(o)}}function qN(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||on(e)}function KN(e){return!dr(e)}function YN(e){return!(e===47||Cy(e))}function Cy(e){return e===43||e===45||e===46||e===95||ar(e)}function Xb(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 JB={tokenize:a8,partial:!0};function ZB(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:r8,continuation:{tokenize:s8},exit:i8}},text:{91:{name:"gfmFootnoteCall",tokenize:n8},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:e8,resolveTo:t8}}}}function e8(e,t,n){const r=this;let a=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let c;for(;a--;){const d=r.events[a][1];if(d.type==="labelImage"){c=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return u;function u(d){if(!c||!c._balanced)return n(d);const h=ys(r.sliceSerialize({start:c.end,end:r.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function t8(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 o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},u=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...u),e}function n8(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,c;return u;function u(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),d}function d(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(f){if(o>999||f===93&&!c||f===null||f===91||on(f))return n(f);if(f===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return a.includes(ys(r.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return on(f)||(c=!0),o++,e.consume(f),f===92?m:h}function m(f){return f===91||f===92||f===93?(e.consume(f),o++,h):h(f)}}function r8(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,c=0,u;return d;function d(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):n(w)}function m(w){if(c>999||w===93&&!u||w===null||w===91||on(w))return n(w);if(w===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return o=ys(r.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return on(w)||(u=!0),c++,e.consume(w),w===92?f:m}function f(w){return w===91||w===92||w===93?(e.consume(w),c++,m):m(w)}function g(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(o)||a.push(o),Mt(e,x,"gfmFootnoteDefinitionWhitespace")):n(w)}function x(w){return t(w)}}function s8(e,t,n){return e.check(Ru,t,e.attempt(JB,t,n))}function i8(e){e.exit("gfmFootnoteDefinition")}function a8(e,t,n){const r=this;return Mt(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const c=r.events[r.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(o):n(o)}}function o8(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(c,u){let d=-1;for(;++d<c.length;)if(c[d][0]==="enter"&&c[d][1].type==="strikethroughSequenceTemporary"&&c[d][1]._close){let h=d;for(;h--;)if(c[h][0]==="exit"&&c[h][1].type==="strikethroughSequenceTemporary"&&c[h][1]._open&&c[d][1].end.offset-c[d][1].start.offset===c[h][1].end.offset-c[h][1].start.offset){c[d][1].type="strikethroughSequence",c[h][1].type="strikethroughSequence";const m={type:"strikethrough",start:Object.assign({},c[h][1].start),end:Object.assign({},c[d][1].end)},f={type:"strikethroughText",start:Object.assign({},c[h][1].end),end:Object.assign({},c[d][1].start)},g=[["enter",m,u],["enter",c[h][1],u],["exit",c[h][1],u],["enter",f,u]],x=u.parser.constructs.insideSpan.null;x&&Fr(g,g.length,0,Zf(x,c.slice(h+1,d),u)),Fr(g,g.length,0,[["exit",f,u],["enter",c[d][1],u],["exit",c[d][1],u],["exit",m,u]]),Fr(c,h-1,d-h+3,g),d=h+g.length-2;break}}for(d=-1;++d<c.length;)c[d][1].type==="strikethroughSequenceTemporary"&&(c[d][1].type="data");return c}function o(c,u,d){const h=this.previous,m=this.events;let f=0;return g;function g(w){return h===126&&m[m.length-1][1].type!=="characterEscape"?d(w):(c.enter("strikethroughSequenceTemporary"),x(w))}function x(w){const C=Tl(h);if(w===126)return f>1?d(w):(c.consume(w),f++,x);if(f<2&&!n)return d(w);const v=c.exit("strikethroughSequenceTemporary"),S=Tl(w);return v._open=!S||S===2&&!!C,v._close=!C||C===2&&!!S,u(w)}}}class l8{constructor(){this.map=[]}add(t,n,r){c8(this,t,n,r)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[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 o of a)t.push(o);a=r.pop()}this.map.length=0}}function c8(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 u8(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 o=r.length-1;r[o]=r[o]==="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 d8(){return{flow:{null:{name:"table",tokenize:h8,resolveAll:f8}}}}function h8(e,t,n){const r=this;let a=0,o=0,c;return u;function u(M){let H=r.events.length-1;for(;H>-1;){const K=r.events[H][1].type;if(K==="lineEnding"||K==="linePrefix")H--;else break}const B=H>-1?r.events[H][1].type:null,F=B==="tableHead"||B==="tableRow"?T:d;return F===T&&r.parser.lazy[r.now().line]?n(M):F(M)}function d(M){return e.enter("tableHead"),e.enter("tableRow"),h(M)}function h(M){return M===124||(c=!0,o+=1),m(M)}function m(M){return M===null?n(M):ft(M)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),x):n(M):At(M)?Mt(e,m,"whitespace")(M):(o+=1,c&&(c=!1,a+=1),M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),c=!0,m):(e.enter("data"),f(M)))}function f(M){return M===null||M===124||on(M)?(e.exit("data"),m(M)):(e.consume(M),M===92?g:f)}function g(M){return M===92||M===124?(e.consume(M),f):f(M)}function x(M){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(M):(e.enter("tableDelimiterRow"),c=!1,At(M)?Mt(e,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):w(M))}function w(M){return M===45||M===58?v(M):M===124?(c=!0,e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),C):E(M)}function C(M){return At(M)?Mt(e,v,"whitespace")(M):v(M)}function v(M){return M===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(M),e.exit("tableDelimiterMarker"),S):M===45?(o+=1,S(M)):M===null||ft(M)?k(M):E(M)}function S(M){return M===45?(e.enter("tableDelimiterFiller"),_(M)):E(M)}function _(M){return M===45?(e.consume(M),_):M===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(M),e.exit("tableDelimiterMarker"),b):(e.exit("tableDelimiterFiller"),b(M))}function b(M){return At(M)?Mt(e,k,"whitespace")(M):k(M)}function k(M){return M===124?w(M):M===null||ft(M)?!c||a!==o?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"),L(M)}function L(M){return M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),L):M===null||ft(M)?(e.exit("tableRow"),t(M)):At(M)?Mt(e,L,"whitespace")(M):(e.enter("data"),A(M))}function A(M){return M===null||M===124||on(M)?(e.exit("data"),L(M)):(e.consume(M),M===92?O:A)}function O(M){return M===92||M===124?(e.consume(M),A):A(M)}}function f8(e,t){let n=-1,r=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],u=!1,d=0,h,m,f;const g=new l8;for(;++n<e.length;){const x=e[n],w=x[1];x[0]==="enter"?w.type==="tableHead"?(u=!1,d!==0&&(wC(g,t,d,h,m),m=void 0,d=0),h={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(n,0,[["enter",h,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(r=!0,f=void 0,o=[0,0,0,0],c=[0,n+1,0,0],u&&(u=!1,m={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(n,0,[["enter",m,t]])),a=w.type==="tableDelimiterRow"?2:m?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,c[2]===0&&(o[1]!==0&&(c[0]=c[1],f=uh(g,t,o,a,void 0,f),o=[0,0,0,0]),c[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(c[0]=c[1],f=uh(g,t,o,a,void 0,f)),o=c,c=[o[1],n,0,0])):w.type==="tableHead"?(u=!0,d=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(d=n,o[1]!==0?(c[0]=c[1],f=uh(g,t,o,a,n,f)):c[1]!==0&&(f=uh(g,t,c,a,n,f)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(c[3]=n)}for(d!==0&&wC(g,t,d,h,m),g.consume(t.events),n=-1;++n<t.events.length;){const x=t.events[n];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=u8(t.events,n))}return e}function uh(e,t,n,r,a,o){const c=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(o.end=Object.assign({},ul(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const d=ul(t.events,n[1]);if(o={type:c,start:Object.assign({},d),end:Object.assign({},d)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const h=ul(t.events,n[2]),m=ul(t.events,n[3]),f={type:u,start:Object.assign({},h),end:Object.assign({},m)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const g=t.events[n[2]],x=t.events[n[3]];if(g[1].end=Object.assign({},x[1].end),g[1].type="chunkText",g[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,C=n[3]-n[2]-1;e.add(w,C,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return a!==void 0&&(o.end=Object.assign({},ul(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function wC(e,t,n,r,a){const o=[],c=ul(t.events,n);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),r.end=Object.assign({},c),o.push(["exit",r,t]),e.add(n+1,0,o)}function ul(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const m8={name:"tasklistCheck",tokenize:g8};function p8(){return{text:{91:m8}}}function g8(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"),o)}function o(d){return on(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),c):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),c):n(d)}function c(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),u):n(d)}function u(d){return ft(d)?t(d):At(d)?e.check({tokenize:x8},t,n)(d):n(d)}}function x8(e,t,n){return Mt(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function y8(e){return iN([UB(),ZB(),o8(e),d8(),p8()])}const b8={};function v8(e){const t=this,n=e||b8,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),c=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(y8(n)),o.push($B()),c.push(FB(n))}var ky=Object.defineProperty,_8=Object.getOwnPropertyDescriptor,S8=Object.getOwnPropertyNames,w8=Object.prototype.hasOwnProperty,Qb=(e,t)=>{let n={};for(var r in e)ky(n,r,{get:e[r],enumerable:!0});return ky(n,Symbol.toStringTag,{value:"Module"}),n},C8=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=S8(t),o=0,c=a.length,u;o<c;o++)u=a[o],!w8.call(e,u)&&u!==n&&ky(e,u,{get:(d=>t[d]).bind(null,u),enumerable:!(r=_8(t,u))||r.enumerable});return e},XN=(e,t,n)=>(C8(e,t,"default"),n);const rm=[{id:"abap",name:"ABAP",import:(()=>se(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>se(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>se(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>se(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>se(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>se(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>se(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>se(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>se(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>se(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>se(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>se(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>se(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>se(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>se(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>se(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>se(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>se(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>se(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>se(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>se(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>se(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>se(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>se(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>se(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>se(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>se(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>se(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>se(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>se(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>se(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>se(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>se(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>se(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>se(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>se(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>se(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>se(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>se(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>se(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>se(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>se(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>se(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>se(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>se(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>se(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>se(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>se(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>se(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>se(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>se(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>se(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>se(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>se(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>se(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>se(()=>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:(()=>se(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>se(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>se(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>se(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>se(()=>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:(()=>se(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>se(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>se(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>se(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>se(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>se(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>se(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>se(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>se(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>se(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>se(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>se(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>se(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>se(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>se(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>se(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>se(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>se(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>se(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>se(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>se(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>se(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>se(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>se(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>se(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>se(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>se(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>se(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>se(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>se(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>se(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>se(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>se(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>se(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>se(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>se(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>se(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>se(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>se(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>se(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>se(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>se(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>se(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>se(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>se(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>se(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>se(()=>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:(()=>se(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>se(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>se(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>se(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>se(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>se(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>se(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>se(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>se(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>se(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>se(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>se(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>se(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>se(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>se(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>se(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>se(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>se(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>se(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>se(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>se(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>se(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>se(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>se(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>se(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>se(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>se(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>se(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>se(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>se(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>se(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>se(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>se(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>se(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>se(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>se(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>se(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>se(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>se(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>se(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>se(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>se(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>se(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>se(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>se(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>se(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>se(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>se(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>se(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>se(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>se(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>se(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>se(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>se(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>se(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>se(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>se(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>se(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>se(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>se(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>se(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>se(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>se(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>se(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>se(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>se(()=>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:(()=>se(()=>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:(()=>se(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>se(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>se(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>se(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>se(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>se(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>se(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>se(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>se(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>se(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>se(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>se(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>se(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>se(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>se(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>se(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>se(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>se(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>se(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>se(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>se(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>se(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>se(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>se(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>se(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>se(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>se(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>se(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>se(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>se(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>se(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>se(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>se(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>se(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>se(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>se(()=>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:(()=>se(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>se(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>se(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>se(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>se(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>se(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>se(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>se(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>se(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>se(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>se(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>se(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>se(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>se(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>se(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>se(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>se(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>se(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>se(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>se(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>se(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>se(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>se(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>se(()=>import("./zig-VOosw3JB.js"),[]))}],Jb=Object.fromEntries(rm.map(e=>[e.id,e.import])),Zb=Object.fromEntries(rm.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),sm={...Jb,...Zb},ev=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>se(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>se(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>se(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>se(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>se(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>se(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>se(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>se(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>se(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>se(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>se(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>se(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>se(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>se(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>se(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>se(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>se(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>se(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>se(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>se(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>se(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>se(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>se(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>se(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>se(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>se(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>se(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>se(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>se(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>se(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>se(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>se(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>se(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>se(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>se(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>se(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>se(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>se(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>se(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>se(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>se(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>se(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>se(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>se(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>se(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>se(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>se(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>se(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>se(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>se(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>se(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>se(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>se(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>se(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>se(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>se(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>se(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>se(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>se(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>se(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>se(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>se(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>se(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>se(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>se(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],tv=Object.fromEntries(ev.map(e=>[e.id,e.import]));var nv=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function k8(){return 2147483648}function j8(){return typeof performance<"u"?performance.now():Date.now()}const E8=(e,t)=>e+(t-e%t)%t;async function N8(e){let t,n;const r={};function a(x){n=x,r.HEAPU8=new Uint8Array(x),r.HEAPU32=new Uint32Array(x)}function o(x,w,C){r.HEAPU8.copyWithin(x,w,w+C)}function c(x){try{return t.grow(x-n.byteLength+65535>>>16),a(t.buffer),1}catch{}}function u(x){const w=r.HEAPU8.length;x=x>>>0;const C=k8();if(x>C)return!1;for(let v=1;v<=4;v*=2){let S=w*(1+.2/v);S=Math.min(S,x+100663296);const _=Math.min(C,E8(Math.max(x,S),65536));if(c(_))return!0}return!1}const d=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function h(x,w,C=1024){const v=w+C;let S=w;for(;x[S]&&!(S>=v);)++S;if(S-w>16&&x.buffer&&d)return d.decode(x.subarray(w,S));let _="";for(;w<S;){let b=x[w++];if(!(b&128)){_+=String.fromCharCode(b);continue}const k=x[w++]&63;if((b&224)===192){_+=String.fromCharCode((b&31)<<6|k);continue}const E=x[w++]&63;if((b&240)===224?b=(b&15)<<12|k<<6|E:b=(b&7)<<18|k<<12|E<<6|x[w++]&63,b<65536)_+=String.fromCharCode(b);else{const T=b-65536;_+=String.fromCharCode(55296|T>>10,56320|T&1023)}}return _}function m(x,w){return x?h(r.HEAPU8,x,w):""}const f={emscripten_get_now:j8,emscripten_memcpy_big:o,emscripten_resize_heap:u,fd_write:()=>0};async function g(){const w=await e({env:f,wasi_snapshot_preview1:f});t=w.memory,a(t.buffer),Object.assign(r,w),r.UTF8ToString=m}return await g(),r}var T8=Object.defineProperty,A8=(e,t,n)=>t in e?T8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$n=(e,t,n)=>A8(e,typeof t!="symbol"?t+"":t,n);let Wn=null;function L8(e){throw new nv(e.UTF8ToString(e.getLastOnigError()))}class im{constructor(t){$n(this,"utf16Length"),$n(this,"utf8Length"),$n(this,"utf16Value"),$n(this,"utf8Value"),$n(this,"utf16OffsetToUtf8"),$n(this,"utf8OffsetToUtf16");const n=t.length,r=im._utf8ByteLength(t),a=r!==n,o=a?new Uint32Array(n+1):null;a&&(o[n]=r);const c=a?new Uint32Array(r+1):null;a&&(c[r]=n);const u=new Uint8Array(r);let d=0;for(let h=0;h<n;h++){const m=t.charCodeAt(h);let f=m,g=!1;if(m>=55296&&m<=56319&&h+1<n){const x=t.charCodeAt(h+1);x>=56320&&x<=57343&&(f=(m-55296<<10)+65536|x-56320,g=!0)}a&&(o[h]=d,g&&(o[h+1]=d),f<=127?c[d+0]=h:f<=2047?(c[d+0]=h,c[d+1]=h):f<=65535?(c[d+0]=h,c[d+1]=h,c[d+2]=h):(c[d+0]=h,c[d+1]=h,c[d+2]=h,c[d+3]=h)),f<=127?u[d++]=f:f<=2047?(u[d++]=192|(f&1984)>>>6,u[d++]=128|(f&63)>>>0):f<=65535?(u[d++]=224|(f&61440)>>>12,u[d++]=128|(f&4032)>>>6,u[d++]=128|(f&63)>>>0):(u[d++]=240|(f&1835008)>>>18,u[d++]=128|(f&258048)>>>12,u[d++]=128|(f&4032)>>>6,u[d++]=128|(f&63)>>>0),g&&h++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=u,this.utf16OffsetToUtf8=o,this.utf8OffsetToUtf16=c}static _utf8ByteLength(t){let n=0;for(let r=0,a=t.length;r<a;r++){const o=t.charCodeAt(r);let c=o,u=!1;if(o>=55296&&o<=56319&&r+1<a){const d=t.charCodeAt(r+1);d>=56320&&d<=57343&&(c=(o-55296<<10)+65536|d-56320,u=!0)}c<=127?n+=1:c<=2047?n+=2:c<=65535?n+=3:n+=4,u&&r++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const am=class As{constructor(t){if($n(this,"id",++As.LAST_ID),$n(this,"_onigBinding"),$n(this,"content"),$n(this,"utf16Length"),$n(this,"utf8Length"),$n(this,"utf16OffsetToUtf8"),$n(this,"utf8OffsetToUtf16"),$n(this,"ptr"),!Wn)throw new nv("Must invoke loadWasm first.");this._onigBinding=Wn,this.content=t;const n=new im(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!As._sharedPtrInUse?(As._sharedPtr||(As._sharedPtr=Wn.omalloc(1e4)),As._sharedPtrInUse=!0,Wn.HEAPU8.set(n.utf8Value,As._sharedPtr),this.ptr=As._sharedPtr):this.ptr=n.createString(Wn)}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===As._sharedPtr?As._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};$n(am,"LAST_ID",0);$n(am,"_sharedPtr",0);$n(am,"_sharedPtrInUse",!1);let QN=am;class R8{constructor(t){if($n(this,"_onigBinding"),$n(this,"_ptr"),!Wn)throw new nv("Must invoke loadWasm first.");const n=[],r=[];for(let u=0,d=t.length;u<d;u++){const h=new im(t[u]);n[u]=h.createString(Wn),r[u]=h.utf8Length}const a=Wn.omalloc(4*t.length);Wn.HEAPU32.set(n,a/4);const o=Wn.omalloc(4*t.length);Wn.HEAPU32.set(r,o/4);const c=Wn.createOnigScanner(a,o,t.length);for(let u=0,d=t.length;u<d;u++)Wn.ofree(n[u]);Wn.ofree(o),Wn.ofree(a),c===0&&L8(Wn),this._onigBinding=Wn,this._ptr=c}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let a=0;if(typeof r=="number"&&(a=r),typeof t=="string"){t=new QN(t);const o=this._findNextMatchSync(t,n,!1,a);return t.dispose(),o}return this._findNextMatchSync(t,n,!1,a)}_findNextMatchSync(t,n,r,a){const o=this._onigBinding,c=o.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),a);if(c===0)return null;const u=o.HEAPU32;let d=c/4;const h=u[d++],m=u[d++],f=[];for(let g=0;g<m;g++){const x=t.convertUtf8OffsetToUtf16(u[d++]),w=t.convertUtf8OffsetToUtf16(u[d++]);f[g]={start:x,end:w,length:w-x}}return{index:h,captureIndices:f}}}function D8(e){return typeof e.instantiator=="function"}function O8(e){return typeof e.default=="function"}function I8(e){return typeof e.data<"u"}function M8(e){return typeof Response<"u"&&e instanceof Response}function P8(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 dh;function rv(e){if(dh)return dh;async function t(){Wn=await N8(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),D8(r)?r=await r.instantiator(n):O8(r)?r=await r.default(n):(I8(r)&&(r=r.data),M8(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await B8(r)(n):r=await $8(r)(n):P8(r)?r=await mx(r)(n):r instanceof WebAssembly.Module?r=await mx(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await mx(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return dh=t(),dh}function mx(e){return t=>WebAssembly.instantiate(e,t)}function B8(e){return t=>WebAssembly.instantiateStreaming(e,t)}function $8(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let JN;function F8(e){JN=e}function H8(){return JN}async function ZN(e){return e&&await rv(e),{createScanner(t){return new R8(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new QN(t)}}}const z8=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:ZN,getDefaultWasmLoader:H8,loadWasm:rv,setDefaultWasmLoader:F8},Symbol.toStringTag,{value:"Module"}));var e2=Qb({});XN(e2,z8);var ln=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function U8(e){return sv(e)}function sv(e){return Array.isArray(e)?V8(e):e instanceof RegExp?e:typeof e=="object"?W8(e):e}function V8(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=sv(e[n]);return t}function W8(e){let t={};for(let n in e)t[n]=sv(e[n]);return t}function t2(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function n2(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?n2(e.substring(0,e.length-1)):e.substr(~t+1)}var px=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,hh=class{static hasCaptures(e){return e===null?!1:(px.lastIndex=0,px.test(e))}static replaceCaptures(e,t,n){return e.replace(px,(r,a,o,c)=>{let u=n[parseInt(a||o,10)];if(u){let d=t.substring(u.start,u.end);for(;d[0]===".";)d=d.substring(1);switch(c){case"downcase":return d.toLowerCase();case"upcase":return d.toUpperCase();default:return d}}else return r})}};function r2(e,t){return e<t?-1:e>t?1:0}function s2(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 o=r2(e[a],t[a]);if(o!==0)return o}return 0}return n-r}function CC(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 i2(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var a2=class{constructor(e){Le(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}},sf=class{constructor(e,t,n){Le(this,"_cachedMatchRoot",new a2(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(K8(e),t)}static createFromParsedTheme(e,t){return X8(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=>G8(e.parent,a.parentScopes));return r?new o2(r.fontStyle,r.foreground,r.background):null}},gx=class Hh{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new Hh(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Hh(n,t[r]);return n}push(t){return new Hh(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 G8(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&&!q8(e.scopeName,r);){if(a)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function q8(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var o2=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function K8(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let a=0,o=t.length;a<o;a++){let c=t[a];if(!c.settings)continue;let u;if(typeof c.scope=="string"){let f=c.scope;f=f.replace(/^[,]+/,""),f=f.replace(/[,]+$/,""),u=f.split(",")}else Array.isArray(c.scope)?u=c.scope:u=[""];let d=-1;if(typeof c.settings.fontStyle=="string"){d=0;let f=c.settings.fontStyle.split(" ");for(let g=0,x=f.length;g<x;g++)switch(f[g]){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 c.settings.foreground=="string"&&CC(c.settings.foreground)&&(h=c.settings.foreground);let m=null;typeof c.settings.background=="string"&&CC(c.settings.background)&&(m=c.settings.background);for(let f=0,g=u.length;f<g;f++){let w=u[f].trim().split(" "),C=w[w.length-1],v=null;w.length>1&&(v=w.slice(0,w.length-1),v.reverse()),n[r++]=new Y8(C,v,a,d,h,m)}}return n}var Y8=class{constructor(e,t,n,r,a,o){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=a,this.background=o}},sr=(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))(sr||{});function X8(e,t){e.sort((d,h)=>{let m=r2(d.scope,h.scope);return m!==0||(m=s2(d.parentScopes,h.parentScopes),m!==0)?m: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 o=new Q8(t),c=new o2(n,o.getId(r),o.getId(a)),u=new Z8(new jy(0,null,-1,0,0),[]);for(let d=0,h=e.length;d<h;d++){let m=e[d];u.insert(0,m.scope,m.parentScopes,m.fontStyle,o.getId(m.foreground),o.getId(m.background))}return new sf(o,c,u)}var Q8=class{constructor(e){Le(this,"_isFrozen");Le(this,"_lastColorId");Le(this,"_id2color");Le(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)}},J8=Object.freeze([]),jy=class l2{constructor(t,n,r,a,o){Le(this,"scopeDepth");Le(this,"parentScopes");Le(this,"fontStyle");Le(this,"foreground");Le(this,"background");this.scopeDepth=t,this.parentScopes=n||J8,this.fontStyle=r,this.foreground=a,this.background=o}clone(){return new l2(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)}},Z8=class Ey{constructor(t,n=[],r={}){Le(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 o=n.parentScopes[a].length-t.parentScopes[r].length;if(o!==0)return o;r++,a++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),a,o;if(r===-1?(a=t,o=""):(a=t.substring(0,r),o=t.substring(r+1)),this._children.hasOwnProperty(a))return this._children[a].match(o)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Ey._cmpBySpecificity),n}insert(t,n,r,a,o,c){if(n===""){this._doInsertHere(t,r,a,o,c);return}let u=n.indexOf("."),d,h;u===-1?(d=n,h=""):(d=n.substring(0,u),h=n.substring(u+1));let m;this._children.hasOwnProperty(d)?m=this._children[d]:(m=new Ey(this._mainRule.clone(),jy.cloneArr(this._rulesWithParentScopes)),this._children[d]=m),m.insert(t+1,h,r,a,o,c)}_doInsertHere(t,n,r,a,o){if(n===null){this._mainRule.acceptOverwrite(t,r,a,o);return}for(let c=0,u=this._rulesWithParentScopes.length;c<u;c++){let d=this._rulesWithParentScopes[c];if(s2(d.parentScopes,n)===0){d.acceptOverwrite(t,r,a,o);return}}r===-1&&(r=this._mainRule.fontStyle),a===0&&(a=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new jy(t,n,r,a,o))}},no=class Zr{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=Zr.getLanguageId(t),r=Zr.getTokenType(t),a=Zr.getFontStyle(t),o=Zr.getForeground(t),c=Zr.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:a,foreground:o,background:c})}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,o,c,u){let d=Zr.getLanguageId(t),h=Zr.getTokenType(t),m=Zr.containsBalancedBrackets(t)?1:0,f=Zr.getFontStyle(t),g=Zr.getForeground(t),x=Zr.getBackground(t);return n!==0&&(d=n),r!==8&&(h=r),a!==null&&(m=a?1:0),o!==-1&&(f=o),c!==0&&(g=c),u!==0&&(x=u),(d<<0|h<<8|m<<10|f<<11|g<<15|x<<24)>>>0}};function af(e,t){const n=[],r=e$(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=c();if(n.push({matcher:h,priority:d}),a!==",")break;a=r.next()}return n;function o(){if(a==="-"){a=r.next();const d=o();return h=>!!d&&!d(h)}if(a==="("){a=r.next();const d=u();return a===")"&&(a=r.next()),d}if(kC(a)){const d=[];do d.push(a),a=r.next();while(kC(a));return h=>t(d,h)}return null}function c(){const d=[];let h=o();for(;h;)d.push(h),h=o();return m=>d.every(f=>f(m))}function u(){const d=[];let h=c();for(;h&&(d.push(h),a==="|"||a===",");){do a=r.next();while(a==="|"||a===",");h=c()}return m=>d.some(f=>f(m))}}function kC(e){return!!e&&!!e.match(/[\w\.:]+/)}function e$(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 c2(e){typeof e.dispose=="function"&&e.dispose()}var vu=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},t$=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},n$=class{constructor(){Le(this,"_references",[]);Le(this,"_seenReferenceKeys",new Set);Le(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))}},r$=class{constructor(e,t){Le(this,"seenFullScopeRequests",new Set);Le(this,"seenPartialScopeRequests",new Set);Le(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new vu(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new n$;for(const n of e)s$(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof vu){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 s$(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 o=n.lookup(t);e instanceof vu?zh({baseGrammar:o,selfGrammar:a},r):Ny(e.ruleName,{baseGrammar:o,selfGrammar:a,repository:a.repository},r);const c=n.injections(e.scopeName);if(c)for(const u of c)r.add(new vu(u))}function Ny(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];of([r],t,n)}}function zh(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&of(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&of(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function of(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const a=r.repository?t2({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&of(r.patterns,{...t,repository:a},n);const o=r.include;if(!o)continue;const c=u2(o);switch(c.kind){case 0:zh({...t,selfGrammar:t.baseGrammar},n);break;case 1:zh(t,n);break;case 2:Ny(c.ruleName,{...t,repository:a},n);break;case 3:case 4:const u=c.scopeName===t.selfGrammar.scopeName?t.selfGrammar:c.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(u){const d={baseGrammar:t.baseGrammar,selfGrammar:u,repository:a};c.kind===4?Ny(c.ruleName,d,n):zh(d,n)}else c.kind===4?n.add(new t$(c.scopeName,c.ruleName)):n.add(new vu(c.scopeName));break}}}var i$=class{constructor(){Le(this,"kind",0)}},a$=class{constructor(){Le(this,"kind",1)}},o$=class{constructor(e){Le(this,"kind",2);this.ruleName=e}},l$=class{constructor(e){Le(this,"kind",3);this.scopeName=e}},c$=class{constructor(e,t){Le(this,"kind",4);this.scopeName=e,this.ruleName=t}};function u2(e){if(e==="$base")return new i$;if(e==="$self")return new a$;const t=e.indexOf("#");if(t===-1)return new l$(e);if(t===0)return new o$(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new c$(n,r)}}var u$=/\\(\d+)/,jC=/\\(\d+)/g,d$=-1,d2=-2;var Ou=class{constructor(e,t,n,r){Le(this,"$location");Le(this,"id");Le(this,"_nameIsCapturing");Le(this,"_name");Le(this,"_contentNameIsCapturing");Le(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=hh.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=hh.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${n2(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:hh.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:hh.replaceCaptures(this._contentName,e,t)}},h$=class extends Ou{constructor(t,n,r,a,o){super(t,n,r,a);Le(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=o}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!")}},f$=class extends Ou{constructor(t,n,r,a,o){super(t,n,r,null);Le(this,"_match");Le(this,"captures");Le(this,"_cachedCompiledPatterns");this._match=new _u(a,this.id),this.captures=o,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 Su,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},EC=class extends Ou{constructor(t,n,r,a,o){super(t,n,r,a);Le(this,"hasMissingPatterns");Le(this,"patterns");Le(this,"_cachedCompiledPatterns");this.patterns=o.patterns,this.hasMissingPatterns=o.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 Su,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ty=class extends Ou{constructor(t,n,r,a,o,c,u,d,h,m){super(t,n,r,a);Le(this,"_begin");Le(this,"beginCaptures");Le(this,"_end");Le(this,"endHasBackReferences");Le(this,"endCaptures");Le(this,"applyEndPatternLast");Le(this,"hasMissingPatterns");Le(this,"patterns");Le(this,"_cachedCompiledPatterns");this._begin=new _u(o,this.id),this.beginCaptures=c,this._end=new _u(u||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=d,this.applyEndPatternLast=h||!1,this.patterns=m.patterns,this.hasMissingPatterns=m.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 Su;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}},lf=class extends Ou{constructor(t,n,r,a,o,c,u,d,h){super(t,n,r,a);Le(this,"_begin");Le(this,"beginCaptures");Le(this,"whileCaptures");Le(this,"_while");Le(this,"whileHasBackReferences");Le(this,"hasMissingPatterns");Le(this,"patterns");Le(this,"_cachedCompiledPatterns");Le(this,"_cachedCompiledWhilePatterns");this._begin=new _u(o,this.id),this.beginCaptures=c,this.whileCaptures=d,this._while=new _u(u,d2),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 Su;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 Su,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||""),this._cachedCompiledWhilePatterns}},h2=class tr{static createCaptureRule(t,n,r,a,o){return t.registerRule(c=>new h$(n,c,r,a,o))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(a=>{if(t.id=a,t.match)return new f$(t.$vscodeTextmateLocation,t.id,t.name,t.match,tr._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=t2({},r,t.repository));let o=t.patterns;return typeof o>"u"&&t.include&&(o=[{include:t.include}]),new EC(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,tr._compilePatterns(o,n,r))}return t.while?new lf(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,tr._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,tr._compileCaptures(t.whileCaptures||t.captures,n,r),tr._compilePatterns(t.patterns,n,r)):new Ty(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,tr._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,tr._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,tr._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let a=[];if(t){let o=0;for(const c in t){if(c==="$vscodeTextmateLocation")continue;const u=parseInt(c,10);u>o&&(o=u)}for(let c=0;c<=o;c++)a[c]=null;for(const c in t){if(c==="$vscodeTextmateLocation")continue;const u=parseInt(c,10);let d=0;t[c].patterns&&(d=tr.getCompiledRuleId(t[c],n,r)),a[u]=tr.createCaptureRule(n,t[c].$vscodeTextmateLocation,t[c].name,t[c].contentName,d)}}return a}static _compilePatterns(t,n,r){let a=[];if(t)for(let o=0,c=t.length;o<c;o++){const u=t[o];let d=-1;if(u.include){const h=u2(u.include);switch(h.kind){case 0:case 1:d=tr.getCompiledRuleId(r[u.include],n,r);break;case 2:let m=r[h.ruleName];m&&(d=tr.getCompiledRuleId(m,n,r));break;case 3:case 4:const f=h.scopeName,g=h.kind===4?h.ruleName:null,x=n.getExternalGrammar(f,r);if(x)if(g){let w=x.repository[g];w&&(d=tr.getCompiledRuleId(w,n,x.repository))}else d=tr.getCompiledRuleId(x.repository.$self,n,x.repository);break}}else d=tr.getCompiledRuleId(u,n,r);if(d!==-1){const h=n.getRule(d);let m=!1;if((h instanceof EC||h instanceof Ty||h instanceof lf)&&h.hasMissingPatterns&&h.patterns.length===0&&(m=!0),m)continue;a.push(d)}}return{patterns:a,hasMissingPatterns:(t?t.length:0)!==a.length}}},_u=class f2{constructor(t,n){Le(this,"source");Le(this,"ruleId");Le(this,"hasAnchor");Le(this,"hasBackReferences");Le(this,"_anchorCache");if(t&&typeof t=="string"){const r=t.length;let a=0,o=[],c=!1;for(let u=0;u<r;u++)if(t.charAt(u)==="\\"&&u+1<r){const h=t.charAt(u+1);h==="z"?(o.push(t.substring(a,u)),o.push("$(?!\\n)(?<!\\n)"),a=u+2):(h==="A"||h==="G")&&(c=!0),u++}this.hasAnchor=c,a===0?this.source=t:(o.push(t.substring(a,r)),this.source=o.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=u$.test(this.source):this.hasBackReferences=!1}clone(){return new f2(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 jC.lastIndex=0,this.source.replace(jC,(a,o)=>i2(r[parseInt(o,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=[],o,c,u,d;for(o=0,c=this.source.length;o<c;o++)u=this.source.charAt(o),t[o]=u,n[o]=u,r[o]=u,a[o]=u,u==="\\"&&o+1<c&&(d=this.source.charAt(o+1),d==="A"?(t[o+1]="",n[o+1]="",r[o+1]="A",a[o+1]="A"):d==="G"?(t[o+1]="",n[o+1]="G",r[o+1]="",a[o+1]="G"):(t[o+1]=d,n[o+1]=d,r[o+1]=d,a[o+1]=d),o++);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}},Su=class{constructor(){Le(this,"_items");Le(this,"_hasAnchors");Le(this,"_cached");Le(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 NC(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 NC(e,r,this._items.map(a=>a.ruleId))}},NC=class{constructor(e,t,n){Le(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}},xx=class{constructor(e,t){this.languageId=e,this.tokenType=t}},pi,m$=(pi=class{constructor(t,n){Le(this,"_defaultAttributes");Le(this,"_embeddedLanguagesMatcher");Le(this,"_getBasicScopeAttributes",new a2(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new xx(n,r)}));this._defaultAttributes=new xx(t,8),this._embeddedLanguagesMatcher=new p$(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?pi._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(pi.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!")}},Le(pi,"_NULL_SCOPE_METADATA",new xx(0,0)),Le(pi,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),pi),p$=class{constructor(e){Le(this,"values");Le(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>i2(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])}},TC=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function m2(e,t,n,r,a,o,c,u){const d=t.content.length;let h=!1,m=-1;if(c){const x=g$(e,t,n,r,a,o);a=x.stack,r=x.linePos,n=x.isFirstLine,m=x.anchorPosition}const f=Date.now();for(;!h;){if(u!==0&&Date.now()-f>u)return new TC(a,!0);g()}return new TC(a,!1);function g(){const x=x$(e,t,n,r,a,m);if(!x){o.produce(a,d),h=!0;return}const w=x.captureIndices,C=x.matchedRuleId,v=w&&w.length>0?w[0].end>r:!1;if(C===d$){const S=a.getRule(e);o.produce(a,w[0].start),a=a.withContentNameScopesList(a.nameScopesList),Qc(e,t,n,a,o,S.endCaptures,w),o.produce(a,w[0].end);const _=a;if(a=a.parent,m=_.getAnchorPos(),!v&&_.getEnterPos()===r){a=_,o.produce(a,d),h=!0;return}}else{const S=e.getRule(C);o.produce(a,w[0].start);const _=a,b=S.getName(t.content,w),k=a.contentNameScopesList.pushAttributed(b,e);if(a=a.push(C,r,m,w[0].end===d,null,k,k),S instanceof Ty){const E=S;Qc(e,t,n,a,o,E.beginCaptures,w),o.produce(a,w[0].end),m=w[0].end;const T=E.getContentName(t.content,w),L=k.pushAttributed(T,e);if(a=a.withContentNameScopesList(L),E.endHasBackReferences&&(a=a.withEndRule(E.getEndWithResolvedBackReferences(t.content,w))),!v&&_.hasSameRuleAs(a)){a=a.pop(),o.produce(a,d),h=!0;return}}else if(S instanceof lf){const E=S;Qc(e,t,n,a,o,E.beginCaptures,w),o.produce(a,w[0].end),m=w[0].end;const T=E.getContentName(t.content,w),L=k.pushAttributed(T,e);if(a=a.withContentNameScopesList(L),E.whileHasBackReferences&&(a=a.withEndRule(E.getWhileWithResolvedBackReferences(t.content,w))),!v&&_.hasSameRuleAs(a)){a=a.pop(),o.produce(a,d),h=!0;return}}else if(Qc(e,t,n,a,o,S.captures,w),o.produce(a,w[0].end),a=a.pop(),!v){a=a.safePop(),o.produce(a,d),h=!0;return}}w[0].end>r&&(r=w[0].end,n=!1)}}function g$(e,t,n,r,a,o){let c=a.beginRuleCapturedEOL?0:-1;const u=[];for(let d=a;d;d=d.pop()){const h=d.getRule(e);h instanceof lf&&u.push({rule:h,stack:d})}for(let d=u.pop();d;d=u.pop()){const{ruleScanner:h,findOptions:m}=v$(d.rule,e,d.stack.endRule,n,r===c),f=h.findNextMatchSync(t,r,m);if(f){if(f.ruleId!==d2){a=d.stack.pop();break}f.captureIndices&&f.captureIndices.length&&(o.produce(d.stack,f.captureIndices[0].start),Qc(e,t,n,d.stack,o,d.rule.whileCaptures,f.captureIndices),o.produce(d.stack,f.captureIndices[0].end),c=f.captureIndices[0].end,f.captureIndices[0].end>r&&(r=f.captureIndices[0].end,n=!1))}else{a=d.stack.pop();break}}return{stack:a,linePos:r,anchorPosition:c,isFirstLine:n}}function x$(e,t,n,r,a,o){const c=y$(e,t,n,r,a,o),u=e.getInjections();if(u.length===0)return c;const d=b$(u,e,t,n,r,a,o);if(!d)return c;if(!c)return d;const h=c.captureIndices[0].start,m=d.captureIndices[0].start;return m<h||d.priorityMatch&&m===h?d:c}function y$(e,t,n,r,a,o){const c=a.getRule(e),{ruleScanner:u,findOptions:d}=p2(c,e,a.endRule,n,r===o),h=u.findNextMatchSync(t,r,d);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function b$(e,t,n,r,a,o,c){let u=Number.MAX_VALUE,d=null,h,m=0;const f=o.contentNameScopesList.getScopeNames();for(let g=0,x=e.length;g<x;g++){const w=e[g];if(!w.matcher(f))continue;const C=t.getRule(w.ruleId),{ruleScanner:v,findOptions:S}=p2(C,t,null,r,a===c),_=v.findNextMatchSync(n,a,S);if(!_)continue;const b=_.captureIndices[0].start;if(!(b>=u)&&(u=b,d=_.captureIndices,h=_.ruleId,m=w.priority,u===a))break}return d?{priorityMatch:m===-1,captureIndices:d,matchedRuleId:h}:null}function p2(e,t,n,r,a){return{ruleScanner:e.compileAG(t,n,r,a),findOptions:0}}function v$(e,t,n,r,a){return{ruleScanner:e.compileWhileAG(t,n,r,a),findOptions:0}}function Qc(e,t,n,r,a,o,c){if(o.length===0)return;const u=t.content,d=Math.min(o.length,c.length),h=[],m=c[0].end;for(let f=0;f<d;f++){const g=o[f];if(g===null)continue;const x=c[f];if(x.length===0)continue;if(x.start>m)break;for(;h.length>0&&h[h.length-1].endPos<=x.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,x.start):a.produce(r,x.start),g.retokenizeCapturedWithRuleId){const C=g.getName(u,c),v=r.contentNameScopesList.pushAttributed(C,e),S=g.getContentName(u,c),_=v.pushAttributed(S,e),b=r.push(g.retokenizeCapturedWithRuleId,x.start,-1,!1,null,v,_),k=e.createOnigString(u.substring(0,x.end));m2(e,k,n&&x.start===0,x.start,b,a,!1,0),c2(k);continue}const w=g.getName(u,c);if(w!==null){const v=(h.length>0?h[h.length-1].scopes:r.contentNameScopesList).pushAttributed(w,e);h.push(new _$(v,x.end))}}for(;h.length>0;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var _$=class{constructor(e,t){Le(this,"scopes");Le(this,"endPos");this.scopes=e,this.endPos=t}};function S$(e,t,n,r,a,o,c,u){return new C$(e,t,n,r,a,o,c,u)}function AC(e,t,n,r,a){const o=af(t,cf),c=h2.getCompiledRuleId(n,r,a.repository);for(const u of o)e.push({debugSelector:t,matcher:u.matcher,ruleId:c,grammar:a,priority:u.priority})}function cf(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(w$(t[a],r))return n=a+1,!0;return!1})}function w$(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 C$=class{constructor(e,t,n,r,a,o,c,u){Le(this,"_rootId");Le(this,"_lastRuleId");Le(this,"_ruleId2desc");Le(this,"_includedGrammars");Le(this,"_grammarRepository");Le(this,"_grammar");Le(this,"_injections");Le(this,"_basicScopeAttributesProvider");Le(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=o,this._onigLib=u,this._basicScopeAttributesProvider=new m$(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=c,this._grammar=LC(t,null),this._injections=null,this._tokenTypeMatchers=[],a)for(const d of Object.keys(a)){const h=af(d,cf);for(const m of h)this._tokenTypeMatchers.push({matcher:m.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 c in a)AC(t,c,a[c],this,r);const o=this._grammarRepository.injections(n);o&&o.forEach(c=>{const u=this.getExternalGrammar(c);if(u){const d=u.injectionSelector;d&&AC(t,d,u,this,u)}})}return t.sort((a,o)=>a.priority-o.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]=LC(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=h2.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let a;if(!t||t===Ay.NULL){a=!0;const h=this._basicScopeAttributesProvider.getDefaultAttributes(),m=this.themeProvider.getDefaults(),f=no.set(0,h.languageId,h.tokenType,null,m.fontStyle,m.foregroundId,m.backgroundId),g=this.getRule(this._rootId).getName(null,null);let x;g?x=su.createRootAndLookUpScopeName(g,f,this):x=su.createRoot("unknown",f),t=new Ay(null,this._rootId,-1,-1,!1,null,x,x)}else a=!1,t.reset();e=e+`
|
|
97
|
+
`;const o=this.createOnigString(e),c=o.content.length,u=new j$(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),d=m2(this,o,a,0,t,u,!0,r);return c2(o),{lineLength:c,lineTokens:u,ruleStack:d.stack,stoppedEarly:d.stoppedEarly}}};function LC(e,t){return e=U8(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 su=class Ls{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 o of n)a=gx.push(a,o.scopeNames),r=new Ls(r,a,o.encodedTokenAttributes);return r}static createRoot(t,n){return new Ls(null,new gx(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const a=r.getMetadataForScope(t),o=new gx(null,t),c=r.themeProvider.themeMatch(o),u=Ls.mergeAttributes(n,a,c);return new Ls(null,o,u)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Ls.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,o=0,c=0;return r!==null&&(a=r.fontStyle,o=r.foregroundId,c=r.backgroundId),no.set(t,n.languageId,n.tokenType,null,a,o,c)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Ls._pushAttributed(this,t,n);const r=t.split(/ /g);let a=this;for(const o of r)a=Ls._pushAttributed(a,o,n);return a}static _pushAttributed(t,n,r){const a=r.getMetadataForScope(n),o=t.scopePath.push(n),c=r.themeProvider.themeMatch(o),u=Ls.mergeAttributes(t.tokenAttributes,a,c);return new Ls(t,o,u)}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}},ns,Ay=(ns=class{constructor(t,n,r,a,o,c,u,d){Le(this,"_stackElementBrand");Le(this,"_enterPos");Le(this,"_anchorPos");Le(this,"depth");this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=o,this.endRule=c,this.nameScopesList=u,this.contentNameScopesList=d,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=a}equals(t){return t===null?!1:ns._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?su.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(){ns._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,a,o,c,u){return new ns(this,t,n,r,a,o,c,u)}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 ns(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=su.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new ns(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,su.fromExtension(r,n.contentNameScopesList))}},Le(ns,"NULL",new ns(null,0,0,0,!1,null,null,null)),ns),k$=class{constructor(e,t){Le(this,"balancedBracketScopes");Le(this,"unbalancedBracketScopes");Le(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):af(n,cf).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>af(n,cf).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}},j$=class{constructor(e,t,n,r){Le(this,"_emitBinaryTokens");Le(this,"_lineText");Le(this,"_tokens");Le(this,"_binaryTokens");Le(this,"_lastTokenEndIndex");Le(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,o=!1;if((r=this.balancedBracketSelectors)!=null&&r.matchesAlways&&(o=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const c=(e==null?void 0:e.getScopeNames())??[];for(const u of this._tokenTypeOverrides)u.matcher(c)&&(a=no.set(a,0,u.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(c))}if(o&&(a=no.set(a,0,8,o,-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}},E$=class{constructor(e,t){Le(this,"_grammars",new Map);Le(this,"_rawGrammars",new Map);Le(this,"_injectionGrammars",new Map);Le(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 o=this._rawGrammars.get(e);if(!o)return null;this._grammars.set(e,S$(e,o,t,n,r,a,this,this._onigLib))}return this._grammars.get(e)}},N$=class{constructor(t){Le(this,"_options");Le(this,"_syncRegistry");Le(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new E$(sf.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(sf.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 k$(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,a,o){const c=new r$(this._syncRegistry,t);for(;c.Q.length>0;)c.Q.map(u=>this._loadSingleGrammar(u.scopeName)),c.processQueue();return this._grammarForScopeName(t,n,r,a,o)}_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,o=null){return this._syncRegistry.grammarForScopeName(t,n,r,a,o)}},Ly=Ay.NULL;function uf(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[a,o]of Object.entries((t==null?void 0:t.colorReplacements)||{}))typeof o=="string"?n[a]=o:a===r&&Object.assign(n,o);return n}function ca(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function T$(e){return Array.isArray(e)?e:[e]}async function g2(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function om(e){return!e||["plaintext","txt","text","plain"].includes(e)}function x2(e){return e==="ansi"||om(e)}function lm(e){return e==="none"}function y2(e){return lm(e)}const A$=/(\r?\n)/g;function cm(e,t=!1){var o;if(e.length===0)return[["",0]];const n=e.split(A$);let r=0;const a=[];for(let c=0;c<n.length;c+=2){const u=t?n[c]+(n[c+1]||""):n[c];a.push([u,r]),r+=n[c].length,r+=((o=n[c+1])==null?void 0:o.length)||0}return a}const RC={light:"#333333",dark:"#bbbbbb"},DC={light:"#fffffe",dark:"#1e1e1e"},OC="__shiki_resolved";function iv(e){var u,d,h,m,f;if(e!=null&&e[OC])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 g=t.settings?t.settings.find(x=>!x.name&&!x.scope):void 0;(u=g==null?void 0:g.settings)!=null&&u.foreground&&(r=g.settings.foreground),(d=g==null?void 0:g.settings)!=null&&d.background&&(n=g.settings.background),!r&&((h=t==null?void 0:t.colors)!=null&&h["editor.foreground"])&&(r=t.colors["editor.foreground"]),!n&&((m=t==null?void 0:t.colors)!=null&&m["editor.background"])&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?RC.light:RC.dark),n||(n=t.type==="light"?DC.light:DC.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 o=new Map;function c(g){var w;if(o.has(g))return o.get(g);a+=1;const x=`#${a.toString(16).padStart(8,"0").toLowerCase()}`;return(w=t.colorReplacements)!=null&&w[`#${x}`]?c(g):(o.set(g,x),x)}t.settings=t.settings.map(g=>{var v,S;const x=((v=g.settings)==null?void 0:v.foreground)&&!g.settings.foreground.startsWith("#"),w=((S=g.settings)==null?void 0:S.background)&&!g.settings.background.startsWith("#");if(!x&&!w)return g;const C={...g,settings:{...g.settings}};if(x){const _=c(g.settings.foreground);t.colorReplacements[_]=g.settings.foreground,C.settings.foreground=_}if(w){const _=c(g.settings.background);t.colorReplacements[_]=g.settings.background,C.settings.background=_}return C});for(const g of Object.keys(t.colors||{}))if((g==="editor.foreground"||g==="editor.background"||g.startsWith("terminal.ansi"))&&!((f=t.colors[g])!=null&&f.startsWith("#"))){const x=c(t.colors[g]);t.colorReplacements[x]=t.colors[g],t.colors[g]=x}return Object.defineProperty(t,OC,{enumerable:!1,writable:!1,value:!0}),t}async function b2(e){return[...new Set((await Promise.all(e.filter(t=>!x2(t)).map(async t=>await g2(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function v2(e){return(await Promise.all(e.map(async t=>y2(t)?null:iv(await g2(t))))).filter(t=>!!t)}function _2(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 ln(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var L$=class extends N${constructor(t,n,r,a={}){super(t);Le(this,"_resolver");Le(this,"_themes");Le(this,"_langs");Le(this,"_alias");Le(this,"_resolvedThemes",new Map);Le(this,"_resolvedGrammars",new Map);Le(this,"_langMap",new Map);Le(this,"_langGraph",new Map);Le(this,"_textmateThemeCache",new WeakMap);Le(this,"_loadedThemesCache",null);Le(this,"_loadedLanguagesCache",null);this._resolver=t,this._themes=n,this._langs=r,this._alias=a,this._themes.map(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const n=iv(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=sf.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=_2(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){var o,c,u,d;if(this.getGrammar(t.name))return;const n=new Set([...this._langMap.values()].filter(h=>{var m;return(m=h.embeddedLangsLazy)==null?void 0:m.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,(c=(o=this._syncRegistry)==null?void 0:o._injectionGrammars)==null||c.delete(h.scopeName),(d=(u=this._syncRegistry)==null?void 0:u._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,o])=>!o);if(r.length){const a=n.filter(([o,c])=>{var u;return c?(u=c.embeddedLanguages||c.embeddedLangs)==null?void 0:u.some(d=>r.map(([h])=>h).includes(d)):!1}).filter(o=>!r.includes(o));throw new ln(`Missing languages ${r.map(([o])=>`\`${o}\``).join(", ")}, required by ${a.map(([o])=>`\`${o}\``).join(", ")}`)}for(const[a,o]of n)this._resolver.addLanguage(o);for(const[a,o]of n)this.loadLanguage(o)}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))}},R$=class{constructor(e,t){Le(this,"_langs",new Map);Le(this,"_scopeToLang",new Map);Le(this,"_injections",new Map);Le(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 Uc=0;function D$(e){Uc+=1,e.warnings!==!1&&Uc>=10&&Uc%10===0&&console.warn(`[Shiki] ${Uc} 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 ln("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(iv),a=new L$(new R$(e.engine,n),r,n,e.langAlias);let o;function c(_){return _2(_,e.langAlias)}function u(_){v();const b=a.getGrammar(typeof _=="string"?_:_.name);if(!b)throw new ln(`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 ln(`Theme \`${_}\` not found, you may need to load it first`);return b}function h(_){v();const b=d(_);return o!==_&&(a.setTheme(b),o=_),{theme:b,colorMap:a.getColorMap()}}function m(){return v(),a.getLoadedThemes()}function f(){return v(),a.getLoadedLanguages()}function g(..._){v(),a.loadLanguages(_.flat(1))}async function x(..._){return g(await b2(_))}function w(..._){v();for(const b of _.flat(1))a.loadTheme(b)}async function C(..._){return v(),w(await v2(_))}function v(){if(t)throw new ln("Shiki instance has been disposed")}function S(){t||(t=!0,a.dispose(),Uc-=1)}return{setTheme:h,getTheme:d,getLanguage:u,getLoadedThemes:m,getLoadedLanguages:f,resolveLangAlias:c,loadLanguage:x,loadLanguageSync:g,loadTheme:C,loadThemeSync:w,dispose:S,[Symbol.dispose]:S}}async function O$(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([v2(e.themes||[]),b2(e.langs||[]),e.engine]);return D$({...e,themes:t,langs:n,engine:r})}const S2=new WeakMap;function um(e,t){S2.set(e,t)}function wu(e){return S2.get(e)}var dm=class w2{constructor(...t){Le(this,"_stacks",{});Le(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 w2(Object.fromEntries(T$(n).map(r=>[r,Ly])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return I$(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function I$(e){const t=[],n=new Set;function r(a){var c;if(n.has(a))return;n.add(a);const o=(c=a==null?void 0:a.nameScopesList)==null?void 0:c.scopeName;o&&t.push(o),a.parent&&r(a.parent)}return r(e),t}function M$(e,t){if(!(e instanceof dm))throw new ln("Invalid grammar state");return e.getInternalStack(t)}const P$=/,/,B$=/ /;function C2(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(om(e.resolveLangAlias(n.lang||"text"))||lm(r))return cm(t).map(u=>[{content:u[0],offset:u[1]}]);const{theme:a,colorMap:o}=e.setTheme(r),c=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==c.name)throw new ln(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${c.name}"`);if(!n.grammarState.themes.includes(a.name))throw new ln(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return F$(t,c,a,o,n)}function $$(...e){if(e.length===2)return wu(e[1]);const[t,n,r={}]=e,{lang:a="text",theme:o=t.getLoadedThemes()[0]}=r;if(om(a)||lm(o))throw new ln("Plain language does not have grammar state");if(a==="ansi")throw new ln("ANSI language does not have grammar state");const{theme:c,colorMap:u}=t.setTheme(o),d=t.getLanguage(a);return new dm(av(n,d,c,u,r).stateStack,d.name,c.name)}function F$(e,t,n,r,a){const o=av(e,t,n,r,a),c=new dm(o.stateStack,t.name,n.name);return um(o.tokens,c),o.tokens}function av(e,t,n,r,a){const o=uf(n,a),{tokenizeMaxLineLength:c=0,tokenizeTimeLimit:u=500,includeExplanation:d=!1}=a,h=cm(e);let m=a.grammarState?M$(a.grammarState,n.name)??Ly:a.grammarContextCode!=null?av(a.grammarContextCode,t,n,r,{...a,grammarState:void 0,grammarContextCode:void 0}).stateStack:Ly,f=[];const g=[];for(let x=0,w=h.length;x<w;x++){const[C,v]=h[x];if(C===""){f=[],g.push([]);continue}if(c>0&&C.length>=c){f=[],g.push([{content:C,offset:v,color:"",fontStyle:0}]);continue}let S,_,b;d&&d!=="tokenType"&&(S=t.tokenizeLine(C,m,u),_=S.tokens,b=0);const k=t.tokenizeLine2(C,m,u),E=k.tokens.length/2;for(let T=0;T<E;T++){const L=k.tokens[2*T],A=T+1<E?k.tokens[2*T+2]:C.length;if(L===A)continue;const O=k.tokens[2*T+1],M=ca(r[no.getForeground(O)],o),H=no.getFontStyle(O),B={content:C.substring(L,A),offset:v+L,color:M,fontStyle:H};if(d==="tokenType")B.type=no.getTokenType(O);else if(d){const F=[];if(d!=="scopeName")for(const G of n.settings){let V;switch(typeof G.scope){case"string":V=G.scope.split(P$).map(Z=>Z.trim());break;case"object":V=G.scope;break;default:continue}F.push({settings:G,selectors:V.map(Z=>Z.split(B$))})}B.explanation=[];let K=0;for(;L+K<A;){const G=_[b],V=C.substring(G.startIndex,G.endIndex);K+=V.length,B.explanation.push({content:V,scopes:d==="scopeName"?H$(G.scopes):z$(F,G.scopes)}),b+=1}}f.push(B)}g.push(f),f=[],m=k.ruleStack}return{tokens:g,stateStack:m}}function H$(e){return e.map(t=>({scopeName:t}))}function z$(e,t){const n=[];for(let r=0,a=t.length;r<a;r++){const o=t[r];n[r]={scopeName:o,themeMatches:V$(e,o,t.slice(0,r))}}return n}function IC(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function U$(e,t,n){if(!IC(e.at(-1),t))return!1;let r=e.length-2,a=n.length-1;for(;r>=0&&a>=0;)IC(e[r],n[a])&&(r-=1),a-=1;return r===-1}function V$(e,t,n){const r=[];for(const{selectors:a,settings:o}of e)for(const c of a)if(U$(c,t,n)){r.push(o);break}return r}function k2(e,t,n,r=C2){const a=Object.entries(n.themes).filter(h=>h[1]).map(h=>({color:h[0],theme:h[1]})),o=a.map(h=>{const m=r(e,t,{...n,theme:h.theme});return{tokens:m,state:wu(m),theme:typeof h.theme=="string"?h.theme:h.theme.name}}),c=W$(...o.map(h=>h.tokens)),u=c[0].map((h,m)=>h.map((f,g)=>{const x={content:f.content,variants:{},offset:f.offset};return"includeExplanation"in n&&n.includeExplanation&&(x.explanation=f.explanation),c.forEach((w,C)=>{const{content:v,explanation:S,offset:_,...b}=w[m][g];x.variants[a[C].color]=b}),x})),d=o[0].state?new dm(Object.fromEntries(o.map(h=>{var m;return[h.theme,(m=h.state)==null?void 0:m.getInternalStack(h.theme)]})),o[0].state.lang):void 0;return d&&um(u,d),u}function W$(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const a=e.map(d=>d[r]),o=t.map(()=>[]);t.forEach((d,h)=>d.push(o[h]));const c=a.map(()=>0),u=a.map(d=>d[0]);for(;u.every(d=>d);){const d=Math.min(...u.map(h=>h.content.length));for(let h=0;h<n;h++){const m=u[h];m.content.length===d?(o[h].push(m),c[h]+=1,u[h]=a[h][c[h]]):(o[h].push({...m,content:m.content.slice(0,d)}),u[h]={...m,content:m.content.slice(d),offset:m.offset+d})}}}return t}const G$=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Iu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Iu.prototype.normal={};Iu.prototype.property={};Iu.prototype.space=void 0;function j2(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Iu(n,r,t)}function Ry(e){return e.toLowerCase()}class jr{constructor(t,n){this.attribute=n,this.property=t}}jr.prototype.attribute="";jr.prototype.booleanish=!1;jr.prototype.boolean=!1;jr.prototype.commaOrSpaceSeparated=!1;jr.prototype.commaSeparated=!1;jr.prototype.defined=!1;jr.prototype.mustUseProperty=!1;jr.prototype.number=!1;jr.prototype.overloadedBoolean=!1;jr.prototype.property="";jr.prototype.spaceSeparated=!1;jr.prototype.space=void 0;let q$=0;const _t=uo(),Mn=uo(),Dy=uo(),Ke=uo(),rn=uo(),ro=uo(),Mr=uo();function uo(){return 2**++q$}const Oy=Object.freeze(Object.defineProperty({__proto__:null,boolean:_t,booleanish:Mn,commaOrSpaceSeparated:Mr,commaSeparated:ro,number:Ke,overloadedBoolean:Dy,spaceSeparated:rn},Symbol.toStringTag,{value:"Module"})),yx=Object.keys(Oy);class ov extends jr{constructor(t,n,r,a){let o=-1;if(super(t,n),MC(this,"space",a),typeof r=="number")for(;++o<yx.length;){const c=yx[o];MC(this,yx[o],(r&Oy[c])===Oy[c])}}}ov.prototype.defined=!0;function MC(e,t,n){n&&(e[t]=n)}function $l(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const o=new ov(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Ry(r)]=r,n[Ry(o.attribute)]=r}return new Iu(t,n,e.space)}const E2=$l({properties:{ariaActiveDescendant:null,ariaAtomic:Mn,ariaAutoComplete:null,ariaBusy:Mn,ariaChecked:Mn,ariaColCount:Ke,ariaColIndex:Ke,ariaColSpan:Ke,ariaControls:rn,ariaCurrent:null,ariaDescribedBy:rn,ariaDetails:null,ariaDisabled:Mn,ariaDropEffect:rn,ariaErrorMessage:null,ariaExpanded:Mn,ariaFlowTo:rn,ariaGrabbed:Mn,ariaHasPopup:null,ariaHidden:Mn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:rn,ariaLevel:Ke,ariaLive:null,ariaModal:Mn,ariaMultiLine:Mn,ariaMultiSelectable:Mn,ariaOrientation:null,ariaOwns:rn,ariaPlaceholder:null,ariaPosInSet:Ke,ariaPressed:Mn,ariaReadOnly:Mn,ariaRelevant:null,ariaRequired:Mn,ariaRoleDescription:rn,ariaRowCount:Ke,ariaRowIndex:Ke,ariaRowSpan:Ke,ariaSelected:Mn,ariaSetSize:Ke,ariaSort:null,ariaValueMax:Ke,ariaValueMin:Ke,ariaValueNow:Ke,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function N2(e,t){return t in e?e[t]:t}function T2(e,t){return N2(e,t.toLowerCase())}const K$=$l({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ro,acceptCharset:rn,accessKey:rn,action:null,allow:null,allowFullScreen:_t,allowPaymentRequest:_t,allowUserMedia:_t,alpha:_t,alt:null,as:null,async:_t,autoCapitalize:null,autoComplete:rn,autoFocus:_t,autoPlay:_t,blocking:rn,capture:null,charSet:null,checked:_t,cite:null,className:rn,closedBy:null,colorSpace:null,cols:Ke,colSpan:Ke,command:null,commandFor:null,content:null,contentEditable:Mn,controls:_t,controlsList:rn,coords:Ke|ro,crossOrigin:null,data:null,dateTime:null,decoding:null,default:_t,defer:_t,dir:null,dirName:null,disabled:_t,download:Dy,draggable:Mn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:_t,formTarget:null,headers:rn,height:Ke,hidden:Dy,high:Ke,href:null,hrefLang:null,htmlFor:rn,httpEquiv:rn,id:null,imageSizes:null,imageSrcSet:null,inert:_t,inputMode:null,integrity:null,is:null,isMap:_t,itemId:null,itemProp:rn,itemRef:rn,itemScope:_t,itemType:rn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:_t,low:Ke,manifest:null,max:null,maxLength:Ke,media:null,method:null,min:null,minLength:Ke,multiple:_t,muted:_t,name:null,nonce:null,noModule:_t,noValidate:_t,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:_t,optimum:Ke,pattern:null,ping:rn,placeholder:null,playsInline:_t,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:_t,referrerPolicy:null,rel:rn,required:_t,reversed:_t,rows:Ke,rowSpan:Ke,sandbox:rn,scope:null,scoped:_t,seamless:_t,selected:_t,shadowRootClonable:_t,shadowRootCustomElementRegistry:_t,shadowRootDelegatesFocus:_t,shadowRootMode:null,shadowRootSerializable:_t,shape:null,size:Ke,sizes:null,slot:null,span:Ke,spellCheck:Mn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ke,step:null,style:null,tabIndex:Ke,target:null,title:null,translate:null,type:null,typeMustMatch:_t,useMap:null,value:Mn,width:Ke,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:rn,axis:null,background:null,bgColor:null,border:Ke,borderColor:null,bottomMargin:Ke,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:_t,declare:_t,event:null,face:null,frame:null,frameBorder:null,hSpace:Ke,leftMargin:Ke,link:null,longDesc:null,lowSrc:null,marginHeight:Ke,marginWidth:Ke,noResize:_t,noHref:_t,noShade:_t,noWrap:_t,object:null,profile:null,prompt:null,rev:null,rightMargin:Ke,rules:null,scheme:null,scrolling:Mn,standby:null,summary:null,text:null,topMargin:Ke,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ke,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:_t,disablePictureInPicture:_t,disableRemotePlayback:_t,exportParts:ro,part:rn,prefix:null,property:null,results:Ke,security:null,unselectable:null},space:"html",transform:T2}),Y$=$l({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:Mr,accentHeight:Ke,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ke,amplitude:Ke,arabicForm:null,ascent:Ke,attributeName:null,attributeType:null,azimuth:Ke,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ke,by:null,calcMode:null,capHeight:Ke,className:rn,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:Ke,diffuseConstant:Ke,direction:null,display:null,dur:null,divisor:Ke,dominantBaseline:null,download:_t,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ke,enableBackground:null,end:null,event:null,exponent:Ke,externalResourcesRequired:null,fill:null,fillOpacity:Ke,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:ro,g2:ro,glyphName:ro,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ke,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ke,horizOriginX:Ke,horizOriginY:Ke,id:null,ideographic:Ke,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ke,k:Ke,k1:Ke,k2:Ke,k3:Ke,k4:Ke,kernelMatrix:Mr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ke,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:Ke,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:Ke,overlineThickness:Ke,paintOrder:null,panose1:null,path:null,pathLength:Ke,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:rn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ke,pointsAtY:Ke,pointsAtZ:Ke,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Mr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Mr,rev:Mr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Mr,requiredFeatures:Mr,requiredFonts:Mr,requiredFormats:Mr,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:Ke,specularExponent:Ke,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ke,strikethroughThickness:Ke,string:null,stroke:null,strokeDashArray:Mr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ke,strokeOpacity:Ke,strokeWidth:null,style:null,surfaceScale:Ke,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Mr,tabIndex:Ke,tableValues:null,target:null,targetX:Ke,targetY:Ke,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Mr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ke,underlineThickness:Ke,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ke,values:null,vAlphabetic:Ke,vMathematical:Ke,vectorEffect:null,vHanging:Ke,vIdeographic:Ke,version:null,vertAdvY:Ke,vertOriginX:Ke,vertOriginY:Ke,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ke,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:N2}),A2=$l({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()}}),L2=$l({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:T2}),R2=$l({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),X$=/[A-Z]/g,PC=/-[a-z]/g,Q$=/^data[-\w.:]+$/i;function J$(e,t){const n=Ry(t);let r=t,a=jr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Q$.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(PC,eF);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!PC.test(o)){let c=o.replace(X$,Z$);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=ov}return new a(r,t)}function Z$(e){return"-"+e.toLowerCase()}function eF(e){return e.charAt(1).toUpperCase()}const tF=j2([E2,K$,A2,L2,R2],"html"),D2=j2([E2,Y$,A2,L2,R2],"svg"),BC={}.hasOwnProperty;function nF(e,t){const n=t||{};function r(a,...o){let c=r.invalid;const u=r.handlers;if(a&&BC.call(a,e)){const d=String(a[e]);c=BC.call(u,d)?u[d]:r.unknown}if(c)return c.call(this,a,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const rF=/["&'<>`]/g,sF=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,iF=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,aF=/[|\\{}()[\]^$+*?.]/g,$C=new WeakMap;function oF(e,t){if(e=e.replace(t.subset?lF(t.subset):rF,r),t.subset||t.escapeOnly)return e;return e.replace(sF,n).replace(iF,r);function n(a,o,c){return t.format((a.charCodeAt(0)-55296)*1024+a.charCodeAt(1)-56320+65536,c.charCodeAt(o+2),t)}function r(a,o,c){return t.format(a.charCodeAt(0),c.charCodeAt(o+1),t)}}function lF(e){let t=$C.get(e);return t||(t=cF(e),$C.set(e,t)),t}function cF(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(aF,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const uF=/[\dA-Fa-f]/;function dF(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!uF.test(String.fromCharCode(t))?r:r+";"}const hF=/\d/;function fF(e,t,n){const r="&#"+String(e);return n&&t&&!hF.test(String.fromCharCode(t))?r:r+";"}const mF=["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"],bx={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:"€"},pF=["cent","copy","divide","gt","lt","not","para","times"],O2={}.hasOwnProperty,Iy={};let fh;for(fh in bx)O2.call(bx,fh)&&(Iy[bx[fh]]=fh);const gF=/[^\dA-Za-z]/;function xF(e,t,n,r){const a=String.fromCharCode(e);if(O2.call(Iy,a)){const o=Iy[a],c="&"+o;return n&&mF.includes(o)&&!pF.includes(o)&&(!r||t&&t!==61&&gF.test(String.fromCharCode(t)))?c:c+";"}return""}function yF(e,t,n){let r=dF(e,t,n.omitOptionalSemicolons),a;if((n.useNamedReferences||n.useShortestReferences)&&(a=xF(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!a)&&n.useShortestReferences){const o=fF(e,t,n.omitOptionalSemicolons);o.length<r.length&&(r=o)}return a&&(!n.useShortestReferences||a.length<r.length)?a:r}function Sl(e,t){return oF(e,Object.assign({format:yF},t))}const bF=/^>|^->|<!--|-->|--!>|<!-$/g,vF=[">"],_F=["<",">"];function SF(e,t,n,r){return r.settings.bogusComments?"<?"+Sl(e.value,Object.assign({},r.settings.characterReferences,{subset:vF}))+">":"<!--"+e.value.replace(bF,a)+"-->";function a(o){return Sl(o,Object.assign({},r.settings.characterReferences,{subset:_F}))}}function wF(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function FC(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 CF(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function kF(e){return e.join(" ").trim()}const jF=/[ \t\n\f\r]/g;function lv(e){return typeof e=="object"?e.type==="text"?HC(e.value):!1:HC(e)}function HC(e){return e.replace(jF,"")===""}const Hn=M2(1),I2=M2(-1),EF=[];function M2(e){return t;function t(n,r,a){const o=n?n.children:EF;let c=(r||0)+e,u=o[c];if(!a)for(;u&&lv(u);)c+=e,u=o[c];return u}}const NF={}.hasOwnProperty;function P2(e){return t;function t(n,r,a){return NF.call(e,n.tagName)&&e[n.tagName](n,r,a)}}const cv=P2({body:AF,caption:vx,colgroup:vx,dd:OF,dt:DF,head:vx,html:TF,li:RF,optgroup:IF,option:MF,p:LF,rp:zC,rt:zC,tbody:BF,td:UC,tfoot:$F,th:UC,thead:PF,tr:FF});function vx(e,t,n){const r=Hn(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&lv(r.value.charAt(0)))}function TF(e,t,n){const r=Hn(n,t);return!r||r.type!=="comment"}function AF(e,t,n){const r=Hn(n,t);return!r||r.type!=="comment"}function LF(e,t,n){const r=Hn(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 RF(e,t,n){const r=Hn(n,t);return!r||r.type==="element"&&r.tagName==="li"}function DF(e,t,n){const r=Hn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function OF(e,t,n){const r=Hn(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function zC(e,t,n){const r=Hn(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function IF(e,t,n){const r=Hn(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function MF(e,t,n){const r=Hn(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function PF(e,t,n){const r=Hn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function BF(e,t,n){const r=Hn(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function $F(e,t,n){return!Hn(n,t)}function FF(e,t,n){const r=Hn(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function UC(e,t,n){const r=Hn(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const HF=P2({body:VF,colgroup:WF,head:UF,html:zF,tbody:GF});function zF(e){const t=Hn(e,-1);return!t||t.type!=="comment"}function UF(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 VF(e){const t=Hn(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&lv(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function WF(e,t,n){const r=I2(n,t),a=Hn(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&cv(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="col")}function GF(e,t,n){const r=I2(n,t),a=Hn(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&cv(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="tr")}const mh={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 qF(e,t,n,r){const a=r.schema,o=a.space==="svg"?!1:r.settings.omitOptionalTags;let c=a.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const u=[];let d;a.space==="html"&&e.tagName==="svg"&&(r.schema=D2);const h=KF(r,e.properties),m=r.all(a.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=a,m&&(c=!1),(h||!o||!HF(e,t,n))&&(u.push("<",e.tagName,h?" "+h:""),c&&(a.space==="svg"||r.settings.closeSelfClosing)&&(d=h.charAt(h.length-1),(!r.settings.tightSelfClosing||d==="/"||d&&d!=='"'&&d!=="'")&&u.push(" "),u.push("/")),u.push(">")),u.push(m),!c&&(!o||!cv(e,t,n))&&u.push("</"+e.tagName+">"),u.join("")}function KF(e,t){const n=[];let r=-1,a;if(t){for(a in t)if(t[a]!==null&&t[a]!==void 0){const o=YF(e,a,t[a]);o&&n.push(o)}}for(;++r<n.length;){const o=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&o!=='"'&&o!=="'"&&(n[r]+=" ")}return n.join("")}function YF(e,t,n){const r=J$(e.schema,t),a=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,o=e.settings.allowDangerousCharacters?0:1;let c=e.quote,u;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=Sl(r.attribute,Object.assign({},e.settings.characterReferences,{subset:mh.name[a][o]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?CF:kF)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?d:(e.settings.preferUnquoted&&(u=Sl(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:mh.unquoted[a][o]}))),u!==n&&(e.settings.quoteSmart&&FC(n,c)>FC(n,e.alternative)&&(c=e.alternative),u=c+Sl(n,Object.assign({},e.settings.characterReferences,{subset:(c==="'"?mh.single:mh.double)[a][o],attribute:!0}))+c),d+(u&&"="+u))}const XF=["<","&"];function B2(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Sl(e.value,Object.assign({},r.settings.characterReferences,{subset:XF}))}function QF(e,t,n,r){return r.settings.allowDangerousHtml?e.value:B2(e,t,n,r)}function JF(e,t,n,r){return r.all(e)}const ZF=nF("type",{invalid:eH,unknown:tH,handlers:{comment:SF,doctype:wF,element:qF,raw:QF,root:JF,text:B2}});function eH(e){throw new Error("Expected node, not `"+e+"`")}function tH(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const nH={},rH={},sH=[];function iH(e,t){const n=t||nH,r=n.quote||'"',a=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:aH,all:oH,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||G$,characterReferences:n.characterReferences||rH,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?D2:tF,quote:r,alternative:a}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function aH(e,t,n){return ZF(e,t,n,this)}function oH(e){const t=[],n=e&&e.children||sH;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}const VC=/\s+/g;function $2(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(VC)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(VC);for(const a of n)a&&!e.properties.class.includes(a)&&e.properties.class.push(a);return e}const lH=/:?lang=["']([^"']+)["']/g,cH=/(?:```|~~~)([\w-]+)/g,uH=/\\begin\{([\w-]+)\}/g,dH=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function hH(e){const t=cm(e,!0).map(([a])=>a);function n(a){if(a===e.length)return{line:t.length-1,character:t.at(-1).length};let o=a,c=0;for(const u of t){if(o<u.length)break;o-=u.length,c++}return{line:c,character:o}}function r(a,o){let c=0;for(let u=0;u<a;u++)c+=t[u].length;return c+=o,c}return{lines:t,indexToPos:n,posToIndex:r}}function fH(e,t,n){const r=new Set;for(const o of e.matchAll(lH)){const c=o[1].toLowerCase().trim();c&&r.add(c)}for(const o of e.matchAll(cH)){const c=o[1].toLowerCase().trim();c&&r.add(c)}for(const o of e.matchAll(uH)){const c=o[1].toLowerCase().trim();c&&r.add(c)}for(const o of e.matchAll(dH)){const c=o[1].toLowerCase().trim(),u=c.includes("/")?c.split("/").pop():c;u&&r.add(u)}if(!n)return[...r];const a=n.getBundledLanguages();return[...r].filter(o=>o&&a[o])}const mH=["color","background-color"];function pH(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 gH(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 o=n.filter(c=>a.offset<c&&c<a.offset+a.content.length).map(c=>c-a.offset).sort((c,u)=>c-u);return o.length?pH(a,o):a})):e}function xH(e,t,n,r,a="css-vars"){const o={content:e.content,explanation:e.explanation,offset:e.offset},c=t.map(m=>df(e.variants[m])),u=new Set(c.flatMap(m=>Object.keys(m))),d={},h=(m,f)=>{const g=f==="color"?"":f==="background-color"?"-bg":`-${f}`;return n+t[m]+(f==="color"?"":g)};return c.forEach((m,f)=>{for(const g of u){const x=m[g]||"inherit";if(f===0&&r&&mH.includes(g))if(r==="light-dark()"&&c.length>1){const w=t.findIndex(v=>v==="light"),C=t.findIndex(v=>v==="dark");if(w===-1||C===-1)throw new ln('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');d[g]=`light-dark(${c[w][g]||"inherit"}, ${c[C][g]||"inherit"})`,a==="css-vars"&&(d[h(f,g)]=x)}else d[g]=x;else a==="css-vars"&&(d[h(f,g)]=x)}}),o.htmlStyle=d,o}function df(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&sr.Italic&&(t["font-style"]="italic"),e.fontStyle&sr.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&sr.Underline&&n.push("underline"),e.fontStyle&sr.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function My(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function yH(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let o=function(u){if(typeof u=="number"){if(u<0||u>n.source.length)throw new ln(`Invalid decoration offset: ${u}. Code length: ${n.source.length}`);return{...a.indexToPos(u),offset:u}}else{const d=a.lines[u.line];if(d===void 0)throw new ln(`Invalid decoration position ${JSON.stringify(u)}. Lines length: ${a.lines.length}`);let h=u.character;if(h<0&&(h=d.length+h),h<0||h>d.length)throw new ln(`Invalid decoration position ${JSON.stringify(u)}. Line ${u.line} length: ${d.length}`);return{...u,character:h,offset:a.posToIndex(u.line,h)}}};var r=o;const a=hH(n.source),c=(n.options.decorations||[]).map(u=>({...u,start:o(u.start),end:o(u.end)}));bH(c),e.set(n.meta,{decorations:c,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 gH(n,t(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]))},code(n){var m;if(!((m=this.options.decorations)!=null&&m.length))return;const r=t(this),a=[...n.children].filter(f=>f.type==="element"&&f.tagName==="span");if(a.length!==r.converter.lines.length)throw new ln(`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 o(f,g,x,w){const C=a[f];let v="",S=-1,_=-1;if(g===0&&(S=0),x===0&&(_=0),x===Number.POSITIVE_INFINITY&&(_=C.children.length),S===-1||_===-1)for(let k=0;k<C.children.length;k++)v+=F2(C.children[k]),S===-1&&v.length===g&&(S=k+1),_===-1&&v.length===x&&(_=k+1);if(S===-1)throw new ln(`Failed to find start index for decoration ${JSON.stringify(w.start)}`);if(_===-1)throw new ln(`Failed to find end index for decoration ${JSON.stringify(w.end)}`);const b=C.children.slice(S,_);if(!w.alwaysWrap&&b.length===C.children.length)u(C,w,"line");else if(!w.alwaysWrap&&b.length===1&&b[0].type==="element")u(b[0],w,"token");else{const k={type:"element",tagName:"span",properties:{},children:b};u(k,w,"wrapper"),C.children.splice(S,b.length,k)}}function c(f,g){a[f]=u(a[f],g,"line")}function u(f,g,x){var v;const w=g.properties||{},C=g.transform||(S=>S);return f.tagName=g.tagName||"span",f.properties={...f.properties,...w,class:f.properties.class},(v=g.properties)!=null&&v.class&&$2(f,g.properties.class),f=C(f,x)||f,f}const d=[],h=r.decorations.sort((f,g)=>g.start.offset-f.start.offset||f.end.offset-g.end.offset);for(const f of h){const{start:g,end:x}=f;if(g.line===x.line)o(g.line,g.character,x.character,f);else if(g.line<x.line){o(g.line,g.character,Number.POSITIVE_INFINITY,f);for(let w=g.line+1;w<x.line;w++)d.unshift(()=>c(w,f));o(x.line,0,x.character,f)}}d.forEach(f=>f())}}}function bH(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new ln(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const a=e[r],o=n.start.offset<=a.start.offset&&a.start.offset<n.end.offset,c=n.start.offset<a.end.offset&&a.end.offset<=n.end.offset,u=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(o||c||u||d){if(o&&c||u&&d||u&&n.start.offset===n.end.offset||c&&a.start.offset===a.end.offset)continue;throw new ln(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(a.start)} intersect.`)}}}}function F2(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(F2).join(""):""}const vH=[yH()];function hf(e){const t=_H(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...vH]}function _H(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 Ga=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],_x={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function SH(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 WC(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 wH(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)_x[r]&&t.push({type:"setDecoration",value:_x[r]});else if(r<=29){const a=_x[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:Ga[r-30]}});else if(r===38){const a=WC(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:Ga[r-40]}});else if(r===48){const a=WC(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:Ga[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Ga[r-100+8]}})}return t}function CH(){let e=null,t=null,n=new Set;return{parse(r){const a=[];let o=0;do{const c=SH(r,o),u=c.sequence?r.substring(o,c.startPosition):r.substring(o);if(u.length>0&&a.push({value:u,foreground:e,background:t,decorations:new Set(n)}),c.sequence){const d=wH(c.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)}o=c.position}while(o<r.length);return a}}}var kH={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 jH(e=kH){function t(u){return e[u]}function n(u){return`#${u.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<Ga.length;h++)r.push(t(Ga[h]));let u=[0,95,135,175,215,255];for(let h=0;h<6;h++)for(let m=0;m<6;m++)for(let f=0;f<6;f++)r.push(n([u[h],u[m],u[f]]));let d=8;for(let h=0;h<24;h++,d+=10)r.push(n([d,d,d]));return r}function o(u){return a()[u]}function c(u){switch(u.type){case"named":return t(u.name);case"rgb":return n(u.rgb);case"table":return o(u.index)}}return{value:c}}const EH=/#([0-9a-f]{3,8})/i,NH=/var\((--[\w-]+-ansi-[\w-]+)\)/,TH={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 AH(e,t,n){const r=uf(e,n),a=cm(t),o=jH(Object.fromEntries(Ga.map(u=>{var h;const d=`terminal.ansi${u[0].toUpperCase()}${u.substring(1)}`;return[u,((h=e.colors)==null?void 0:h[d])||TH[u]]}))),c=CH();return a.map(u=>c.parse(u[0]).map(d=>{let h,m;d.decorations.has("reverse")?(h=d.background?o.value(d.background):e.bg,m=d.foreground?o.value(d.foreground):e.fg):(h=d.foreground?o.value(d.foreground):e.fg,m=d.background?o.value(d.background):void 0),h=ca(h,r),m=ca(m,r),d.decorations.has("dim")&&(h=LH(h));let f=sr.None;return d.decorations.has("bold")&&(f|=sr.Bold),d.decorations.has("italic")&&(f|=sr.Italic),d.decorations.has("underline")&&(f|=sr.Underline),d.decorations.has("strikethrough")&&(f|=sr.Strikethrough),{content:d.value,offset:u[1],color:h,bgColor:m,fontStyle:f}}))}function LH(e){const t=e.match(EH);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],o=r[1],c=r[2],u=r[3];return`#${a}${a}${o}${o}${c}${c}${Math.round(Number.parseInt(`${u}${u}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const a=r[0],o=r[1],c=r[2];return`#${a}${a}${o}${o}${c}${c}80`}}}const n=e.match(NH);return n?`var(${n[1]}-dim)`:e}function Py(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:a=e.getLoadedThemes()[0]}=n;if(!om(r)&&!lm(a)&&r==="ansi"){const{theme:o}=e.setTheme(a);return AH(o,t,n)}return C2(e,t,n)}function ff(e,t,n){let r,a,o,c,u,d;if("themes"in n){const{defaultColor:h="light",cssVariablePrefix:m="--shiki-",colorsRendering:f="css-vars"}=n,g=Object.entries(n.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,_)=>S.color===h?-1:_.color===h?1:0);if(g.length===0)throw new ln("`themes` option must not be empty");const x=k2(e,t,n,Py);if(d=wu(x),h&&h!=="light-dark()"&&!g.some(S=>S.color===h))throw new ln(`\`themes\` option must contain the defaultColor key \`${h}\``);const w=g.map(S=>e.getTheme(S.theme)),C=g.map(S=>S.color);o=x.map(S=>S.map(_=>xH(_,C,m,h,f))),d&&um(o,d);const v=g.map(S=>uf(S.theme,n));a=GC(g,w,v,m,h,"fg",f),r=GC(g,w,v,m,h,"bg",f),c=`shiki-themes ${w.map(S=>S.name).join(" ")}`,u=h?void 0:[a,r].join(";")}else if("theme"in n){const h=uf(n.theme,n);o=Py(e,t,n);const m=e.getTheme(n.theme);r=ca(m.bg,h),a=ca(m.fg,h),c=m.name,d=wu(o)}else throw new ln("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:a,bg:r,themeName:c,rootStyle:u,grammarState:d}}function GC(e,t,n,r,a,o,c){return e.map((u,d)=>{const h=ca(t[d][o],n[d])||"inherit",m=`${r+u.color}${o==="bg"?"-bg":""}:${h}`;if(d===0&&a){if(a==="light-dark()"&&e.length>1){const f=e.findIndex(x=>x.color==="light"),g=e.findIndex(x=>x.color==="dark");if(f===-1||g===-1)throw new ln('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${ca(t[f][o],n[f])||"inherit"}, ${ca(t[g][o],n[g])||"inherit"});${m}`}return h}return c==="css-vars"?m:null}).filter(u=>!!u).join(";")}const H2=/^\s+$/,RH=/^(\s*)(.*?)(\s*)$/;function mf(e,t,n,r={meta:{},options:n,codeToHast:(a,o)=>mf(e,a,o),codeToTokens:(a,o)=>ff(e,a,o)}){var w,C;let a=t;for(const v of hf(n))a=((w=v.preprocess)==null?void 0:w.call(r,a,n))||a;let{tokens:o,fg:c,bg:u,themeName:d,rootStyle:h,grammarState:m}=ff(e,a,n);const{mergeWhitespaces:f=!0,mergeSameStyleTokens:g=!1}=n;f===!0?o=OH(o):f==="never"&&(o=IH(o)),g&&(o=MH(o));const x={...r,get source(){return a}};for(const v of hf(n))o=((C=v.tokens)==null?void 0:C.call(x,o))||o;return DH(o,{...n,fg:c,bg:u,themeName:d,rootStyle:n.rootStyle===!1?!1:n.rootStyle??h},x,m)}function DH(e,t,n,r=wu(e)){var C,v,S,_;const a=hf(t),o=[],c={type:"root",children:[]},{structure:u="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 m={type:"element",tagName:"pre",properties:h,children:[],data:t.data},f={type:"element",tagName:"code",properties:{},children:o};const g=[],x={...n,structure:u,addClassToHast:$2,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return c},get pre(){return m},get code(){return f},get lines(){return g}};if(e.forEach((b,k)=>{var L,A;k&&(u==="inline"?c.children.push({type:"element",tagName:"br",properties:{},children:[]}):u==="classic"&&o.push({type:"text",value:`
|
|
106
|
+
`}));let E={type:"element",tagName:"span",properties:{class:"line"},children:[]},T=0;for(const O of b){let M={type:"element",tagName:"span",properties:{...O.htmlAttrs},children:[{type:"text",value:O.content}]};const H=My(O.htmlStyle||df(O));H&&(M.properties.style=H);for(const B of a)M=((L=B==null?void 0:B.span)==null?void 0:L.call(x,M,k+1,T,E,O))||M;u==="inline"?c.children.push(M):u==="classic"&&E.children.push(M),T+=O.content.length}if(u==="classic"){for(const O of a)E=((A=O==null?void 0:O.line)==null?void 0:A.call(x,E,k+1))||E;g.push(E),o.push(E)}else u==="inline"&&g.push(E)}),u==="classic"){for(const b of a)f=((C=b==null?void 0:b.code)==null?void 0:C.call(x,f))||f;m.children.push(f);for(const b of a)m=((v=b==null?void 0:b.pre)==null?void 0:v.call(x,m))||m;c.children.push(m)}else if(u==="inline"){const b=[];let k={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const T of c.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=((S=T==null?void 0:T.code)==null?void 0:S.call(x,E))||E;c.children=[];for(let T=0;T<E.children.length;T++){T>0&&c.children.push({type:"element",tagName:"br",properties:{},children:[]});const L=E.children[T];L.type==="element"&&c.children.push(...L.children)}}let w=c;for(const b of a)w=((_=b==null?void 0:b.root)==null?void 0:_.call(x,w))||w;return r&&um(w,r),w}function OH(e){return e.map(t=>{const n=[];let r="",a;return t.forEach((o,c)=>{const u=!(o.fontStyle&&(o.fontStyle&sr.Underline||o.fontStyle&sr.Strikethrough));u&&H2.test(o.content)&&t[c+1]?(a===void 0&&(a=o.offset),r+=o.content):r?(u?n.push({...o,offset:a,content:r+o.content}):n.push({content:r,offset:a},o),a=void 0,r=""):n.push(o)}),n})}function IH(e){return e.map(t=>t.flatMap(n=>{if(H2.test(n.content))return n;const r=n.content.match(RH);if(!r)return n;const[,a,o,c]=r;if(!a&&!c)return n;const u=[{...n,offset:n.offset+a.length,content:o}];return a&&u.unshift({content:a,offset:n.offset}),c&&u.push({content:c,offset:n.offset+a.length+o.length}),u}))}function MH(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),o=My(a.htmlStyle||df(a)),c=My(r.htmlStyle||df(r)),u=a.fontStyle&&(a.fontStyle&sr.Underline||a.fontStyle&sr.Strikethrough),d=r.fontStyle&&(r.fontStyle&sr.Underline||r.fontStyle&sr.Strikethrough);!u&&!d&&o===c?a.content+=r.content:n.push({...r})}return n})}const PH=iH;function BH(e,t,n){var o;const r={meta:{},options:n,codeToHast:(c,u)=>mf(e,c,u),codeToTokens:(c,u)=>ff(e,c,u)};let a=PH(mf(e,t,n,r));for(const c of hf(n))a=((o=c.postprocess)==null?void 0:o.call(r,a,n))||a;return a}async function $H(e){const t=await O$(e);return{getLastGrammarState:(...n)=>$$(t,...n),codeToTokensBase:(n,r)=>Py(t,n,r),codeToTokensWithThemes:(n,r)=>k2(t,n,r),codeToTokens:(n,r)=>ff(t,n,r),codeToHast:(n,r)=>mf(t,n,r),codeToHtml:(n,r)=>BH(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function FH(e){const t=e.langs,n=e.themes,r=e.engine;async function a(o){function c(f){var g;if(typeof f=="string"){if(f=((g=o.langAlias)==null?void 0:g[f])||f,x2(f))return[];const x=t[f];if(!x)throw new ln(`Language \`${f}\` is not included in this bundle. You may want to load it from external source.`);return x}return f}function u(f){if(y2(f))return"none";if(typeof f=="string"){const g=n[f];if(!g)throw new ln(`Theme \`${f}\` is not included in this bundle. You may want to load it from external source.`);return g}return f}const d=(o.themes??[]).map(f=>u(f)),h=(o.langs??[]).map(f=>c(f)),m=await $H({engine:o.engine??r(),...o,themes:d,langs:h});return{...m,loadLanguage(...f){return m.loadLanguage(...f.map(c))},loadTheme(...f){return m.loadTheme(...f.map(u))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return a}function HH(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 zH(e,t){const n=HH(e);async function r(a,o){var d;const c=await n({langs:[o.lang],themes:"theme"in o?[o.theme]:Object.values(o.themes)}),u=await((d=t==null?void 0:t.guessEmbeddedLanguages)==null?void 0:d.call(t,a,o.lang,c));return u&&await c.loadLanguage(...u),c}return{getSingletonHighlighter(a){return n(a)},async codeToHtml(a,o){return(await r(a,o)).codeToHtml(a,o)},async codeToHast(a,o){return(await r(a,o)).codeToHast(a,o)},async codeToTokens(a,o){return(await r(a,o)).codeToTokens(a,o)},async codeToTokensBase(a,o){return(await r(a,o)).codeToTokensBase(a,o)},async codeToTokensWithThemes(a,o){return(await r(a,o)).codeToTokensWithThemes(a,o)},async getLastGrammarState(a,o){return(await n({langs:[o.lang],themes:[o.theme]})).getLastGrammarState(a,o)}}}var UH=Qb({bundledLanguages:()=>sm,bundledLanguagesAlias:()=>Zb,bundledLanguagesBase:()=>Jb,bundledLanguagesInfo:()=>rm,bundledThemes:()=>tv,bundledThemesInfo:()=>ev,codeToHast:()=>U2,codeToHtml:()=>z2,codeToTokens:()=>V2,codeToTokensBase:()=>W2,codeToTokensWithThemes:()=>G2,createHighlighter:()=>hm,getLastGrammarState:()=>K2,getSingletonHighlighter:()=>q2});const hm=FH({langs:sm,themes:tv,engine:()=>(0,e2.createOnigurumaEngine)(se(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:z2,codeToHast:U2,codeToTokens:V2,codeToTokensBase:W2,codeToTokensWithThemes:G2,getSingletonHighlighter:q2,getLastGrammarState:K2}=zH(hm,{guessEmbeddedLanguages:fH}),qC=4294967295;var VH=class{constructor(e,t={}){Le(this,"patterns");Le(this,"options");Le(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(o=>{if(typeof o!="string")return o;const c=r==null?void 0:r.get(o);if(c){if(c instanceof RegExp)return c;if(n)return null;throw c}try{const u=a(o);return r==null||r.set(o,u),u}catch(u){if(r==null||r.set(o,u),n)return null;throw u}})}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,a=[];function o(c,u,d=0){return{index:c,captureIndices:u.indices.map(h=>h==null?{start:qC,end:qC,length:0}:{start:h[0]+d,end:h[1]+d,length:h[1]-h[0]})}}for(let c=0;c<this.regexps.length;c++){const u=this.regexps[c];if(u)try{u.lastIndex=t;const d=u.exec(r);if(!d)continue;if(d.index===t)return o(c,d,0);a.push([c,d,0])}catch(d){if(this.options.forgiving)continue;throw d}}if(a.length){const c=Math.min(...a.map(u=>u[1].index));for(const[u,d,h]of a)if(d.index===c)return o(u,d,h)}return null}};function Fl(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function WH(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const uv=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),qn=String.raw;function Hl(e,t){if(e==null)throw new Error(t??"Value expected");return e}const Y2=qn`\[\^?`,X2=`c.? | C(?:-.?)?|${qn`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${qn`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${qn`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${qn`o\{[^\}]*\}?`}|${qn`\d{1,3}`}`,dv=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,ph=new RegExp(qn`
|
|
107
|
+
\\ (?:
|
|
108
|
+
${X2}
|
|
109
|
+
| [gk]<[^>]*>?
|
|
110
|
+
| [gk]'[^']*'?
|
|
111
|
+
| .
|
|
112
|
+
)
|
|
113
|
+
| \( (?:
|
|
114
|
+
\? (?:
|
|
115
|
+
[:=!>({]
|
|
116
|
+
| <[=!]
|
|
117
|
+
| <[^>]*>
|
|
118
|
+
| '[^']*'
|
|
119
|
+
| ~\|?
|
|
120
|
+
| #(?:[^)\\]|\\.?)*
|
|
121
|
+
| [^:)]*[:)]
|
|
122
|
+
)?
|
|
123
|
+
| \*[^\)]*\)?
|
|
124
|
+
)?
|
|
125
|
+
| (?:${dv.source})+
|
|
126
|
+
| ${Y2}
|
|
127
|
+
| .
|
|
128
|
+
`.replace(/\s+/g,""),"gsu"),Sx=new RegExp(qn`
|
|
129
|
+
\\ (?:
|
|
130
|
+
${X2}
|
|
131
|
+
| .
|
|
132
|
+
)
|
|
133
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
134
|
+
| ${Y2}
|
|
135
|
+
| &&
|
|
136
|
+
| .
|
|
137
|
+
`.replace(/\s+/g,""),"gsu");function GH(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=dz(n.flags),a=[r.extended],o={captureGroup:n.rules.captureGroup,getCurrentModX(){return a.at(-1)},numOpenGroups:0,popModX(){a.pop()},pushModX(f){a.push(f)},replaceCurrentModX(f){a[a.length-1]=f},singleline:n.rules.singleline};let c=[],u;for(ph.lastIndex=0;u=ph.exec(e);){const f=qH(o,e,u[0],ph.lastIndex);f.tokens?c.push(...f.tokens):f.token&&c.push(f.token),f.lastIndex!==void 0&&(ph.lastIndex=f.lastIndex)}const d=[];let h=0;c.filter(f=>f.type==="GroupOpen").forEach(f=>{f.kind==="capturing"?f.number=++h:f.raw==="("&&d.push(f)}),h||d.forEach((f,g)=>{f.kind="capturing",f.number=g+1});const m=h||d.length;return{tokens:c.map(f=>f.type==="EscapedNumber"?fz(f,m):f).flat(),flags:r}}function qH(e,t,n,r){const[a,o]=n;if(n==="["||n==="[^"){const c=KH(t,n,r);return{tokens:c.tokens,lastIndex:c.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(o))return{token:KC(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:sz(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:J2(n)}}if(o==="K")return{token:Z2("keep",n)};if(o==="N"||o==="R")return{token:qa("newline",n,{negate:o==="N"})};if(o==="O")return{token:qa("any",n)};if(o==="X")return{token:qa("text_segment",n)};const c=Q2(n,{inCharClass:!1});return Array.isArray(c)?{tokens:c}:{token:c}}if(a==="("){if(o==="*")return{token:lz(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:oz(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:dl("group",n)};if(n==="(?>")return{token:dl("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:dl(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:dl("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:dl("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:tz(n)}}if(e.getCurrentModX()){if(n==="#"){const c=t.indexOf(`
|
|
138
|
+
`,r);return{lastIndex:c===-1?t.length:c}}if(/^\s$/.test(n)){const c=/\s+/y;return c.lastIndex=r,{lastIndex:c.exec(t)?c.lastIndex:r}}}if(n===".")return{token:qa("dot",n)};if(n==="^"||n==="$"){const c=e.singleline?{"^":qn`\A`,$:qn`\Z`}[n]:n;return{token:KC(c,n)}}return n==="|"?{token:XH(n)}:dv.test(n)?{tokens:mz(n)}:{token:yi(Fl(n),n)}}function KH(e,t,n){const r=[YC(t[1]==="^",t)];let a=1,o;for(Sx.lastIndex=n;o=Sx.exec(e);){const c=o[0];if(c[0]==="["&&c[1]!==":")a++,r.push(YC(c[1]==="^",c));else if(c==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(yi(93,c));else if(a--,r.push(QH(c)),!a)break}else{const u=YH(c);Array.isArray(u)?r.push(...u):r.push(u)}}return{tokens:r,lastIndex:Sx.lastIndex||e.length}}function YH(e){if(e[0]==="\\")return Q2(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!uv.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return qa("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?JH(e):e==="&&"?ZH(e):yi(Fl(e),e)}function Q2(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return az(e);if("dDhHsSwW".includes(n))return cz(e);if(e.startsWith(qn`\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 uz(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const r=e.split(/\\x/).slice(1).map(c=>parseInt(c,16)),a=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),o=new TextEncoder;return[...a].map(c=>{const u=[...o.encode(c)].map(d=>`\\x${d.toString(16)}`).join("");return yi(Fl(c),u)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return yi(hz(e),e);if(XC.has(n))return yi(XC.get(n),e);if(/\d/.test(n))return ez(t,e);if(e==="\\")throw new Error(qn`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return yi(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function XH(e){return{type:"Alternator",raw:e}}function KC(e,t){return{type:"Assertion",kind:e,raw:t}}function J2(e){return{type:"Backreference",raw:e}}function yi(e,t){return{type:"Character",value:e,raw:t}}function QH(e){return{type:"CharacterClassClose",raw:e}}function JH(e){return{type:"CharacterClassHyphen",raw:e}}function ZH(e){return{type:"CharacterClassIntersector",raw:e}}function YC(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function qa(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function Z2(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Hl(n.flags),raw:t}}function ez(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function tz(e){return{type:"GroupClose",raw:e}}function dl(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function nz(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function rz(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function sz(e){return{type:"Subroutine",raw:e}}const iz=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),XC=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function az(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 yi(Fl(t.toUpperCase())-64,e)}function oz(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"),o=JC(n),c=JC(r),u={};if(o&&(u.enable=o),c&&(u.disable=c),e.endsWith(")"))return t.replaceCurrentModX(a),Z2("flags",e,{flags:u});if(e.endsWith(":"))return t.pushModX(a),t.numOpenGroups++,dl("group",e,{...(o||c)&&{flags:u}});throw new Error(`Unexpected flag modifier "${e}"`)}function lz(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 o=a?a.split(",").filter(m=>m!=="").map(m=>/^[+-]?\d+$/.test(m)?+m:m):[],[c,u,d]=o,h=iz.has(n)?n.toLowerCase():"custom";switch(h){case"fail":case"mismatch":case"skip":if(o.length>0)throw new Error(`Named callout arguments not allowed "${o}"`);break;case"error":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(typeof c=="string")throw new Error(`Named callout argument must be a number "${c}"`);break;case"max":if(!o.length||o.length>2)throw new Error(`Named callout must have one or two arguments "${o}"`);if(typeof c=="string"&&!/^[A-Za-z_]\w*$/.test(c))throw new Error(`Named callout argument one must be a tag or number "${c}"`);if(o.length===2&&(typeof u=="number"||!/^[<>X]$/.test(u)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${u}"`);break;case"count":case"total_count":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(o.length===1&&(typeof c=="number"||!/^[<>X]$/.test(c)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${c}"`);break;case"cmp":if(o.length!==3)throw new Error(`Named callout must have three arguments "${o}"`);if(typeof c=="string"&&!/^[A-Za-z_]\w*$/.test(c))throw new Error(`Named callout argument one must be a tag or number "${c}"`);if(typeof u=="number"||!/^(?:[<>!=]=|[<>])$/.test(u))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${u}"`);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 nz(h,r??null,(a==null?void 0:a.split(","))??null,e)}function QC(e){let t=null,n,r;if(e[0]==="{"){const{minStr:a,maxStr:o}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,c=1e5;if(+a>c||o&&+o>c)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+a,r=o===void 0?+a:o===""?1/0:+o,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 rz(t,n,r,e)}function cz(e){const t=e[1].toLowerCase();return qa({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function uz(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return qa("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function JC(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 dz(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 hz(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 fz(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[J2(n)];const o=[],c=a.match(/^[0-7]+|\d/g);for(let u=0;u<c.length;u++){const d=c[u];let h;if(u===0&&d!=="8"&&d!=="9"){if(h=parseInt(d,8),h>127)throw new Error(qn`Octal encoded byte above 177 unsupported "${n}"`)}else h=Fl(d);o.push(yi(h,(u===0?"\\":"")+d))}return o}function mz(e){const t=[],n=new RegExp(dv,"gy");let r;for(;r=n.exec(e);){const a=r[0];if(a[0]==="{"){const o=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(a);if(o){const{min:c,max:u}=o.groups;if(+c>+u&&a.endsWith("?")){n.lastIndex--,t.push(QC(a.slice(0,-1)));continue}}}t.push(QC(a))}return t}function eT(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 pz(e){return gz.has(e.type)}const gz=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function tT(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=GH(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),a=(g,x)=>{const w=r.tokens[o.nextIndex];switch(o.parent=g,o.nextIndex++,w.type){case"Alternator":return ao();case"Assertion":return xz(w);case"Backreference":return yz(w,o);case"Character":return fm(w.value,{useLastValid:!!x.isCheckingRangeEnd});case"CharacterClassHyphen":return bz(w,o,x);case"CharacterClassOpen":return vz(w,o,x);case"CharacterSet":return _z(w,o);case"Directive":return Ez(w.kind,{flags:w.flags});case"GroupOpen":return Sz(w,o,x);case"NamedCallout":return Tz(w.kind,w.tag,w.arguments);case"Quantifier":return wz(w,o);case"Subroutine":return Cz(w,o);default:throw new Error(`Unexpected token type "${w.type}"`)}},o={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},c=Lz(Nz(r.flags));let u=c.body[0];for(;o.nextIndex<r.tokens.length;){const g=a(u,{});g.type==="Alternative"?(c.body.push(g),u=g):u.body.push(g)}const{capturingGroups:d,hasNumberedRef:h,namedGroupsByName:m,subroutines:f}=o;if(h&&m.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:g}of f)if(typeof g=="number"){if(g>d.length)throw new Error("Subroutine uses a group number that's not defined");g&&(d[g-1].isSubroutined=!0)}else if(m.has(g)){if(m.get(g).length>1)throw new Error(qn`Subroutine uses a duplicate group name "\g<${g}>"`);m.get(g)[0].isSubroutined=!0}else throw new Error(qn`Subroutine uses a group name that's not defined "\g<${g}>"`);return c}function xz({kind:e}){return By(Hl({"^":"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===qn`\B`||e===qn`\Y`})}function yz({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),a=(o,c=!1)=>{const u=t.capturingGroups.length;let d=!1;if(o>u)if(t.skipBackrefValidation)d=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,$y(c?u+1-o:o,{orphan:d})};if(n){const o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(o)return a(+o.groups.num,!!o.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 $y(r)}return a(+r)}function bz(e,t,n){const{tokens:r,walk:a}=t,o=t.parent,c=o.body.at(-1),u=r[t.nextIndex];if(!n.isCheckingRangeEnd&&c&&c.type!=="CharacterClass"&&c.type!=="CharacterClassRange"&&u&&u.type!=="CharacterClassOpen"&&u.type!=="CharacterClassClose"&&u.type!=="CharacterClassIntersector"){const d=a(o,{...n,isCheckingRangeEnd:!0});if(c.type==="Character"&&d.type==="Character")return o.body.pop(),jz(c,d);throw new Error("Invalid character class range")}return fm(Fl("-"))}function vz({negate:e},t,n){const{tokens:r,walk:a}=t,o=[Uh()],c=r[t.nextIndex];let u=tk(c);for(;u.type!=="CharacterClassClose";){if(u.type==="CharacterClassIntersector")o.push(Uh()),t.nextIndex++;else{const h=o.at(-1);h.body.push(a(h,n))}u=tk(r[t.nextIndex],c)}const d=Uh({negate:e});return o.length===1?d.body=o[0].body:(d.kind="intersection",d.body=o.map(h=>h.body.length===1?h.body[0]:h)),t.nextIndex++,d}function _z({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:o,unicodePropertyMap:c}=r;if(e==="property"){const u=mm(n);if(uv.has(u)&&!(c!=null&&c.has(u)))e="posix",n=u;else return hl(n,{negate:t,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:o,unicodePropertyMap:c})}return e==="posix"?Az(n,{negate:t}):Fy(e,{negate:t})}function Sz(e,t,n){const{tokens:r,capturingGroups:a,namedGroupsByName:o,skipLookbehindValidation:c,walk:u}=t,d=Rz(e),h=d.type==="AbsenceFunction",m=ek(d),f=m&&d.negate;if(d.type==="CapturingGroup"&&(a.push(d),d.name&&WH(o,d.name,[]).push(d)),h&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let g=nk(r[t.nextIndex]);for(;g.type!=="GroupClose";){if(g.type==="Alternator")d.body.push(ao()),t.nextIndex++;else{const x=d.body.at(-1),w=u(x,{...n,isInAbsenceFunction:n.isInAbsenceFunction||h,isInLookbehind:n.isInLookbehind||m,isInNegLookbehind:n.isInNegLookbehind||f});if(x.body.push(w),(m||n.isInLookbehind)&&!c){const C="Lookbehind includes a pattern not allowed by Oniguruma";if(f||n.isInNegLookbehind){if(ZC(w)||w.type==="CapturingGroup")throw new Error(C)}else if(ZC(w)||ek(w)&&w.negate)throw new Error(C)}}g=nk(r[t.nextIndex])}return t.nextIndex++,d}function wz({kind:e,min:t,max:n},r){const a=r.parent,o=a.body.at(-1);if(!o||!pz(o))throw new Error("Quantifier requires a repeatable token");const c=rT(e,t,n,o);return a.body.pop(),c}function Cz({raw:e},t){const{capturingGroups:n,subroutines:r}=t;let a=e.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(a);if(o){const u=+o.groups.num,d=n.length;if(t.hasNumberedRef=!0,a={"":u,"+":d+u,"-":d+1-u}[o.groups.sign],a<1)throw new Error("Invalid subroutine number")}else a==="0"&&(a=0);const c=sT(a);return r.push(c),c}function kz(e,t){return{type:"AbsenceFunction",kind:e,body:Mu(t==null?void 0:t.body)}}function ao(e){return{type:"Alternative",body:iT(e==null?void 0:e.body)}}function By(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function $y(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function nT(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!Dz(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:Mu(t==null?void 0:t.body)}}function fm(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 Uh(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:iT(e==null?void 0:e.body)}}function jz(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Fy(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 Ez(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Hl(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function Nz(e){return{type:"Flags",...e}}function ms(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:Mu(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:Mu(e==null?void 0:e.body)}}function Tz(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function Az(e,t){const n=!!(t!=null&&t.negate);if(!uv.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function rT(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 Lz(e,t){return{type:"Regex",body:Mu(t==null?void 0:t.body),flags:e}}function sT(e){return{type:"Subroutine",ref:e}}function hl(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(mm(e));if(!r){if(n.normalizeUnknownPropertyNames)r=Oz(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(qn`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function Rz({flags:e,kind:t,name:n,negate:r,number:a}){switch(t){case"absence_repeater":return kz("repeater");case"atomic":return ms({atomic:!0});case"capturing":return nT(a,{name:n});case"group":return ms({flags:e});case"lookahead":case"lookbehind":return Wa({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function Mu(e){if(e===void 0)e=[ao()];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 iT(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 ZC(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function ek(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function Dz(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function Oz(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 mm(e){return e.replace(/[- _]+/g,"").toLowerCase()}function tk(e,t){const n=t;return Hl(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function nk(e){return Hl(e,"Unclosed group")}function iu(e,t,n=null){function r(o,c){for(let u=0;u<o.length;u++){const d=a(o[u],c,u,o);u=Math.max(-1,u+d)}}function a(o,c=null,u=null,d=null){var S,_;let h=0,m=!1;const f={node:o,parent:c,key:u,container:d,root:e,remove(){gh(d).splice(Math.max(0,el(u)+h),1),h--,m=!0},removeAllNextSiblings(){return gh(d).splice(el(u)+1)},removeAllPrevSiblings(){const b=el(u)+h;return h-=b,gh(d).splice(0,Math.max(0,b))},replaceWith(b,k={}){const E=!!k.traverse;d?d[Math.max(0,el(u)+h)]=b:Hl(c,"Can't replace root node")[u]=b,E&&a(b,c,u,d),m=!0},replaceWithMultiple(b,k={}){const E=!!k.traverse;if(gh(d).splice(Math.max(0,el(u)+h),1,...b),h+=b.length-1,E){let T=0;for(let L=0;L<b.length;L++)T+=a(b[L],c,el(u)+L+T,d)}m=!0},skip(){m=!0}},{type:g}=o,x=t["*"],w=t[g],C=typeof x=="function"?x:x==null?void 0:x.enter,v=typeof w=="function"?w:w==null?void 0:w.enter;if(C==null||C(f,n),v==null||v(f,n),!m)switch(g){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(o.body,o);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":a(o.min,o,"min"),a(o.max,o,"max");break;case"Quantifier":a(o.body,o,"body");break;case"Regex":r(o.body,o),a(o.flags,o,"flags");break;default:throw new Error(`Unexpected node type "${g}"`)}return(S=w==null?void 0:w.exit)==null||S.call(w,f,n),(_=x==null?void 0:x.exit)==null||_.call(x,f,n),h}return a(e),e}function gh(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function el(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const Iz=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Mz(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Pz(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const is=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function hv(e,t,n,r){const a=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),o=[!1];let c=0,u="";for(const d of e.matchAll(a)){const{0:h,groups:{$skip:m}}=d;if(!m&&(!r||r===is.DEFAULT==!c)){n instanceof Function?u+=n(d,{context:c?is.CHAR_CLASS:is.DEFAULT,negated:o[o.length-1]}):u+=n;continue}h[0]==="["?(c++,o.push(h[1]==="^")):h==="]"&&c&&(c--,o.pop()),u+=h}return u}function aT(e,t,n,r){hv(e,t,n,r)}function Bz(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 o=0,c;for(;c=a.exec(e);){const{0:u,groups:{$skip:d}}=c;if(!d&&(!r||r===is.DEFAULT==!o))return c;u==="["?o++:u==="]"&&o&&o--,a.lastIndex==c.index&&a.lastIndex++}return null}function xh(e,t,n){return!!Bz(e,t,0,n)}function $z(e,t){const n=/\\?./gsu;n.lastIndex=t;let r=e.length,a=0,o=1,c;for(;c=n.exec(e);){const[u]=c;if(u==="[")a++;else if(a)u==="]"&&a--;else if(u==="(")o++;else if(u===")"&&(o--,!o)){r=c.index;break}}return e.slice(t,r)}const rk=new RegExp(String.raw`(?<noncapturingStart>${Iz})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function Fz(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="(?>",o="(?:(?=(",c=[0],u=[];let d=0,h=0,m=NaN,f;do{f=!1;let g=0,x=0,w=!1,C;for(rk.lastIndex=Number.isNaN(m)?0:m+o.length;C=rk.exec(e);){const{0:v,index:S,groups:{capturingStart:_,noncapturingStart:b}}=C;if(v==="[")g++;else if(g)v==="]"&&g--;else if(v===a&&!w)m=S,w=!0;else if(w&&b)x++;else if(_)w?x++:(d++,c.push(d+h));else if(v===")"&&w){if(!x){h++;const k=d+h;if(e=`${e.slice(0,m)}${o}${e.slice(m+a.length,S)}))<$$${k}>)${e.slice(S+1)}`,f=!0,u.push(k),Mz(n,k),r.size){const E=new Map;r.forEach((T,L)=>{E.set(L>=k?L+1:L,T.map(A=>A>=k?A+1:A))}),r=E}break}x--}}}while(f);return n.push(...u),e=hv(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:g,groups:{backrefNum:x,wrappedBackrefNum:w}})=>{if(x){const C=+x;if(C>c.length-1)throw new Error(`Backref "${g}" greater than number of captures`);return`\\${c[C]}`}return`\\${w}`},is.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const oT=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,wx=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>${oT})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
152
|
+
| \\?.
|
|
153
|
+
`.replace(/\s+/g,""),"gsu");function Hz(e){if(!new RegExp(`${oT}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,a="",o=0,c;for(wx.lastIndex=0;c=wx.exec(e);){const{0:u,index:d,groups:{qBase:h,qMod:m,invalidQ:f}}=c;if(u==="[")o||(r=d),o++;else if(u==="]")o?o--:r=null;else if(!o)if(m==="+"&&a&&!a.startsWith("(")){if(f)throw new Error(`Invalid quantifier "${u}"`);let g=-1;if(/^\{\d+\}$/.test(h))e=Pz(e,d+h.length,m,"");else{if(a===")"||a==="]"){const x=a===")"?n:r;if(x===null)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,x)}(?>${e.slice(x,d)}${h})${e.slice(d+u.length)}`}else e=`${e.slice(0,d-a.length)}(?>${a}${h})${e.slice(d+u.length)}`;g+=4}wx.lastIndex+=g}else u[0]==="("?t.push(d):u===")"&&(n=t.length?t.pop():null);a=u}return{pattern:e}}const rs=String.raw,zz=rs`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Hy=rs`\(\?R=(?<rDepth>[^\)]+)\)|${zz}`,pm=rs`\(\?<(?![=!])(?<captureName>[^>]+)>`,lT=rs`${pm}|(?<unnamed>\()(?!\?)`,Pa=new RegExp(rs`${pm}|${Hy}|\(\?|\\?.`,"gsu"),Cx="Cannot use multiple overlapping recursions";function Uz(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let a=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(Hy,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if(r==="plugin"&&xh(e,rs`\(\?\(DEFINE\)`,is.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const o=[],c=xh(e,rs`\\[1-9]`,is.DEFAULT),u=new Map,d=[];let h=!1,m=0,f=0,g;for(Pa.lastIndex=0;g=Pa.exec(e);){const{0:x,groups:{captureName:w,rDepth:C,gRNameOrNum:v,gRDepth:S}}=g;if(x==="[")m++;else if(m)x==="]"&&m--;else if(C){if(sk(C),h)throw new Error(Cx);if(c)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const _=e.slice(0,g.index),b=e.slice(Pa.lastIndex);if(xh(b,Hy,is.DEFAULT))throw new Error(Cx);const k=+C-1;e=ik(_,b,k,!1,n,o,f),a=ok(a,_,k,o.length,0,f);break}else if(v){sk(S);let _=!1;for(const B of d)if(B.name===v||B.num===+v){if(_=!0,B.hasRecursedWithin)throw new Error(Cx);break}if(!_)throw new Error(rs`Recursive \g cannot be used outside the referenced group "${r==="external"?v:rs`\g<${v}&R=${S}>`}"`);const b=u.get(v),k=$z(e,b);if(c&&xh(k,rs`${pm}|\((?!\?)`,is.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const E=e.slice(b,g.index),T=k.slice(E.length+x.length),L=o.length,A=+S-1,O=ik(E,T,A,!0,n,o,f);a=ok(a,E,A,o.length-L,L,f);const M=e.slice(0,b),H=e.slice(b+k.length);e=`${M}${O}${H}`,Pa.lastIndex+=O.length-x.length-E.length-T.length,d.forEach(B=>B.hasRecursedWithin=!0),h=!0}else if(w)f++,u.set(String(f),Pa.lastIndex),u.set(w,Pa.lastIndex),d.push({num:f,name:w});else if(x[0]==="("){const _=x==="(";_&&(f++,u.set(String(f),Pa.lastIndex)),d.push(_?{num:f}:{})}else x===")"&&d.pop()}return n.push(...o),{pattern:e,captureTransfers:a,hiddenCaptures:n}}function sk(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 ik(e,t,n,r,a,o,c){const u=new Set;r&&aT(e+t,pm,({groups:{captureName:h}})=>{u.add(h)},is.DEFAULT);const d=[n,r?u:null,a,o,c];return`${e}${ak(`(?:${e}`,"forward",...d)}(?:)${ak(`${t})`,"backward",...d)}${t}`}function ak(e,t,n,r,a,o,c){const d=m=>t==="forward"?m+2:n-m+2-1;let h="";for(let m=0;m<n;m++){const f=d(m);h+=hv(e,rs`${lT}|\\k<(?<backref>[^>]+)>`,({0:g,groups:{captureName:x,unnamed:w,backref:C}})=>{if(C&&r&&!r.has(C))return g;const v=`_$${f}`;if(w||x){const S=c+o.length+1;return o.push(S),Vz(a,S),w?g:`(?<${x}${v}>`}return rs`\k<${C}${v}>`},is.DEFAULT)}return h}function Vz(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function ok(e,t,n,r,a,o){if(e.size&&r){let c=0;aT(t,lT,()=>c++,is.DEFAULT);const u=o-c+a,d=new Map;return e.forEach((h,m)=>{const f=(r-c*n)/n,g=c*n,x=m>u+c?m+r:m,w=[];for(const C of h)if(C<=u)w.push(C);else if(C>u+c+f)w.push(C+r);else if(C<=u+c)for(let v=0;v<=n;v++)w.push(C+c*v);else for(let v=0;v<=n;v++)w.push(C+g+f*v);d.set(x,w)}),d}return e}var Fn=String.fromCodePoint,wt=String.raw,bs={},gm=globalThis.RegExp;bs.flagGroups=(()=>{try{new gm("(?i:)")}catch{return!1}return!0})();bs.unicodeSets=(()=>{try{new gm("[[]]","v")}catch{return!1}return!0})();bs.bugFlagVLiteralHyphenIsRange=bs.unicodeSets?(()=>{try{new gm(wt`[\d\-a]`,"v")}catch{return!0}return!1})():!1;bs.bugNestedClassIgnoresNegation=bs.unicodeSets&&new gm("[[^a]]","v").test("a");function pf(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 Cu(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function zy(e,t){return lk[e]>=lk[t]}function Wz(e,t){if(e==null)throw new Error(t??"Value expected");return e}var lk={ES2025:2025,ES2024:2024,ES2018:2018},Gz={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function cT(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!Gz[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=bs.flagGroups?"ES2025":bs.unicodeSets?"ES2024":"ES2018"),t}var qz="[ -\r ]",Kz=new Set([Fn(304),Fn(305)]),oi=wt`[\p{L}\p{M}\p{N}\p{Pc}]`;function uT(e){if(Kz.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),a=Qz.get(n),o=Yz.get(n),c=Xz.get(n);return[...r].length===1&&t.add(r),c&&t.add(c),a&&t.add(a),t.add(n),o&&t.add(o),[...t]}var fv=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=>[mm(e),e])),Yz=new Map([["s",Fn(383)],[Fn(383),"s"]]),Xz=new Map([[Fn(223),Fn(7838)],[Fn(107),Fn(8490)],[Fn(229),Fn(8491)],[Fn(969),Fn(8486)]]),Qz=new Map([Qi(453),Qi(456),Qi(459),Qi(498),...kx(8072,8079),...kx(8088,8095),...kx(8104,8111),Qi(8124),Qi(8140),Qi(8188)]),Jz=new Map([["alnum",wt`[\p{Alpha}\p{Nd}]`],["alpha",wt`\p{Alpha}`],["ascii",wt`\p{ASCII}`],["blank",wt`[\p{Zs}\t]`],["cntrl",wt`\p{Cc}`],["digit",wt`\p{Nd}`],["graph",wt`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",wt`\p{Lower}`],["print",wt`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",wt`[\p{P}\p{S}]`],["space",wt`\p{space}`],["upper",wt`\p{Upper}`],["word",wt`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",wt`\p{AHex}`]]);function Zz(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Qi(e){const t=Fn(e);return[t.toLowerCase(),t]}function kx(e,t){return Zz(e,t).map(n=>Qi(n))}var dT=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function e7(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};hT(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:zy(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};iu(e,t7,r);const a={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},o={currentFlags:a,prevFlags:null,globalFlags:a,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};iu(e,n7,o);const c={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return iu(e,r7,c),e._originMap=o.groupOriginByCopy,e._strategy=r.strategy,e}var t7={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:a}=e;if(a==="repeater"){const o=ms();o.body[0].body.push(Wa({negate:!0,body:r}),hl("Any"));const c=ms();c.body[0].body.push(rT("greedy",0,1/0,o)),n(En(c,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(o=>o.kind==="flags");for(let o=n+1;o<t.body.length;o++){const c=t.body[o];Cu(r,c,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const r=mT(t.get(e));if(r){const a=ms({flags:r});a.body[0].body=e.body,e.body=[En(a,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:a,remove:o,replaceWith:c},u){const{kind:d,negate:h}=e,{asciiWordBoundaries:m,avoidSubclass:f,supportedGNodes:g,wordIsAscii:x}=u;if(d==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${h?"Y":"y"}"`);if(d==="line_end")c(En(Wa({body:[ao({body:[By("string_end")]}),ao({body:[fm(10)]})]}),t));else if(d==="line_start")c(En(li(wt`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(d==="search_start")if(g.has(e))a.flags.sticky=!0,o();else{const w=r[n-1];if(w&&c7(w))c(En(Wa({negate:!0}),t));else{if(f)throw new Error(wt`Uses "\G" in a way that requires a subclass`);c(Ji(By("string_start"),t)),u.strategy="clip_search"}}else if(!(d==="string_end"||d==="string_start"))if(d==="string_end_newline")c(En(li(wt`(?=\n?\z)`),t));else if(d==="word_boundary"){if(!x&&!m){const w=`(?:(?<=${oi})(?!${oi})|(?<!${oi})(?=${oi}))`,C=`(?:(?<=${oi})(?=${oi})|(?<!${oi})(?!${oi}))`;c(En(li(h?C:w),t))}}else throw new Error(`Unexpected assertion kind "${d}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Ex(n)&&(n=jx(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Ex(r)&&(r=jx(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=Uh({body:[e]});n(En(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:a,digitIsAscii:o,spaceIsAscii:c,wordIsAscii:u}){const{kind:d,negate:h,value:m}=e;if(o&&(d==="digit"||m==="digit")){n(Ji(Fy("digit",{negate:h}),t));return}if(c&&(d==="space"||m==="space")){n(En(Nx(li(qz),h),t));return}if(u&&(d==="word"||m==="word")){n(Ji(Fy("word",{negate:h}),t));return}if(d==="any")n(Ji(hl("Any"),t));else if(d==="digit")n(Ji(hl("Nd",{negate:h}),t));else if(d!=="dot")if(d==="text_segment"){if(r==="strict")throw new Error(wt`Use of "\X" requires non-strict accuracy`);const f="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",g=wt`\p{RI}{2}|${f}(?:\u200D${f})*`;n(En(li(wt`(?>\r\n|${a?wt`\p{RGI_Emoji}`:g}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(d==="hex")n(Ji(hl("AHex",{negate:h}),t));else if(d==="newline")n(En(li(h?`[^
|
|
244
|
+
]`:`(?>\r
|
|
245
|
+
?|[
|
|
246
|
+
\v\f
\u2028\u2029])`),t));else if(d==="posix")if(!a&&(m==="graph"||m==="print")){if(r==="strict")throw new Error(`POSIX class "${m}" requires min target ES2024 or non-strict accuracy`);let f={graph:"!-~",print:" -~"}[m];h&&(f=`\0-${Fn(f.codePointAt(0)-1)}${Fn(f.codePointAt(2)+1)}-`),n(En(li(`[${f}]`),t))}else n(En(Nx(li(Jz.get(m)),h),t));else if(d==="property")fv.has(mm(m))||(e.key="sc");else if(d==="space")n(Ji(hl("space",{negate:h}),t));else if(d==="word")n(En(Nx(li(oi),h),t));else throw new Error(`Unexpected character set kind "${d}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:a,removeAllPrevSiblings:o,removeAllNextSiblings:c}){const{kind:u,flags:d}=e;if(u==="flags")if(!d.enable&&!d.disable)r();else{const h=ms({flags:d});h.body[0].body=c(),a(En(h,t),{traverse:!0})}else if(u==="keep"){const h=n.body[0],f=n.body.length===1&&eT(h,{type:"Group"})&&h.body[0].body.length===1?h.body[0]:n;if(t.parent!==f||f.body.length>1)throw new Error(wt`Uses "\K" in a way that's unsupported`);const g=Wa({behind:!0});g.body[0].body=o(),a(En(g,t))}else throw new Error(`Unexpected directive kind "${u}"`)},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(En(Wa({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=ms();t.body[0].body.push(e.body),e.body=En(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,a=!1;for(const o of e.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{const c=gT(o.body);c?(r=!0,Array.isArray(c)?n.push(...c):n.push(c)):a=!0}r&&!a&&n.forEach(o=>t.add(o))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(wt`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Ex(n)&&(n=jx(n,t),e.ref=n)}},n7={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:a}=e;r||n.set(e,[...t.get(a).map(({node:o})=>o)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:a,groupsByName:o,multiplexCapturesToLeftByRef:c,openRefs:u,reffedNodesByReferencer:d}){const h=a.get(e);if(h&&u.has(e.number)){const f=Ji(ck(e.number),t);d.set(f,u.get(e.number)),n(f);return}u.set(e.number,e),c.set(e.number,[]),e.name&&Cu(c,e.name,[]);const m=c.get(e.name??e.number);for(let f=0;f<m.length;f++){const g=m[f];if(h===g.node||h&&h===g.origin||e===g.origin){m.splice(f,1);break}}if(c.get(e.number).push({node:e,origin:h}),e.name&&c.get(e.name).push({node:e,origin:h}),e.name){const f=Cu(o,e.name,new Map);let g=!1;if(h)g=!0;else for(const x of f.values())if(!x.hasDuplicateNameToRemove){g=!0;break}o.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:g})}},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=pf(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:a,ref:o}=e;if(a){let m=t;for(;(m=m.parent)&&!(m.type==="CapturingGroup"&&(m.name===o||m.number===o)););r.reffedNodesByReferencer.set(e,m);return}const c=r.subroutineRefMap.get(o),u=o===0,d=u?ck(0):fT(c,r.groupOriginByCopy,null);let h=d;if(!u){const m=mT(a7(c,g=>g.type==="Group"&&!!g.flags)),f=m?pf(r.globalFlags,m):r.globalFlags;s7(f,r.currentFlags)||(h=ms({flags:o7(f)}),h.body[0].body.push(d))}n(En(h,t),{traverse:!u})}},r7={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const o=r.reffedNodesByReferencer.get(e).filter(c=>i7(c,e));if(!o.length)n(En(Wa({negate:!0}),t));else if(o.length>1){const c=ms({atomic:!0,body:o.reverse().map(u=>ao({body:[$y(u.number)]}))});n(En(c,t))}else e.ref=o[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=nT();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function hT(e){iu(e,{"*"({node:t,parent:n}){t.parent=n}})}function s7(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function i7(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=pT(n.parent);for(const a of r){if(a===n)break;if(a===e||xT(a,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function fT(e,t,n,r){const a=Array.isArray(e)?[]:{};for(const[o,c]of Object.entries(e))o==="parent"?a.parent=Array.isArray(n)?r:n:c&&typeof c=="object"?a[o]=fT(c,t,a,n):(o==="type"&&c==="CapturingGroup"&&t.set(a,t.get(e)??e),a[o]=c);return a}function ck(e){const t=sT(e);return t.isRecursive=!0,t}function a7(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function jx(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 mT(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(a=>{var o,c;(o=r.enable)!=null&&o[a]&&(delete n.disable[a],n.enable[a]=!0),(c=r.disable)!=null&&c[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 o7({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 pT(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function gT(e){const t=e.find(n=>n.kind==="search_start"||u7(n,{negate:!1})||!l7(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=gT(r.body);if(!a)return null;Array.isArray(a)?n.push(...a):n.push(a)}return n}return null}function xT(e,t){const n=pT(e)??[];for(const r of n)if(r===t||xT(r,t))return!0;return!1}function l7({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function c7(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function u7(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&eT(e.body[0],{type:"Assertion",kind:"search_start"})}function Ex(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function li(e,t){const r=tT(e,{...t,unicodePropertyMap:fv}).body;return r.length>1||r[0].body.length>1?ms({body:r}):r[0].body[0]}function Nx(e,t){return e.negate=t,e}function Ji(e,t){return e.parent=t,e}function En(e,t){return hT(e),e.parent=t,e}function d7(e,t){const n=cT(t),r=zy(n.target,"ES2024"),a=zy(n.target,"ES2025"),o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw new Error("Invalid recursionLimit; use 2-20");let c=null,u=null;if(!a){const x=[e.flags.ignoreCase];iu(e,h7,{getCurrentModI:()=>x.at(-1),popModI(){x.pop()},pushModI(w){x.push(w)},setHasCasedChar(){x.at(-1)?c=!0:u=!0}})}const d={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||c)&&!u)};let h=e;const m={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:o,useAppliedIgnoreCase:!!(!a&&c&&u),useFlagMods:a,useFlagV:r,verbose:n.verbose};function f(x){return m.lastNode=h,h=x,Wz(f7[x.type],`Unexpected node type "${x.type}"`)(x,m,f)}const g={pattern:e.body.map(f).join("|"),flags:f(e.flags),options:{...e.options}};return r||(delete g.options.force.v,g.options.disable.v=!0,g.options.unicodeSetsPlugin=null),g._captureTransfers=new Map,g._hiddenCaptures=[],m.captureMap.forEach((x,w)=>{x.hidden&&g._hiddenCaptures.push(w),x.transferTo&&Cu(g._captureTransfers,x.transferTo,[]).push(w)}),g}var h7={"*":{enter({node:e},t){if(dk(e)){const n=t.getCurrentModI();t.pushModI(e.flags?pf({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){dk(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){mv(Fn(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),yT(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&dT.has(e.value)&&t.setHasCasedChar()}},f7={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?wt`\B`:wt`\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:o}=e,c={ignoreCase:t.currentFlags.ignoreCase},u=t.originMap.get(e);return u&&(c.hidden=!0,o>u.number&&(c.transferTo=u.number)),t.captureMap.set(o,c),`(${a?`?<${a}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=Fn(e),r=tl(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&mv(n)){const a=uT(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:o}=e;let{body:c}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");bs.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&c.some(hk)&&(c=[fm(45),...c.filter(h=>!hk(h))]);const u=()=>`[${a?"^":""}${c.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||bs.bugNestedClassIgnoresNegation)&&!a){const m=c.filter(f=>f.type==="CharacterClass"&&f.kind==="union"&&f.negate);if(m.length){const f=ms(),g=f.body[0];return f.parent=o,g.parent=f,c=c.filter(x=>!m.includes(x)),e.body=c,c.length?(e.parent=g,g.body.push(e)):f.body.pop(),m.forEach(x=>{const w=ao({body:[x]});x.parent=w,w.parent=f,f.body.push(w)}),n(f)}}t.inCharClass=!0;const h=u();return t.inCharClass=!1,h}const d=c[0];if(r==="union"&&!a&&d&&((!t.useFlagV||!t.verbose)&&o.kind==="union"&&!(bs.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&o.kind==="intersection"&&c.length===1&&d.type!=="CharacterClassRange"))return c.map(n).join("");if(!t.useFlagV&&o.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return u()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,a={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},o=tl(n,a),c=tl(r,a),u=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const d=yT(e);y7(d).forEach(m=>{u.add(Array.isArray(m)?`${tl(m[0],a)}-${tl(m[1],a)}`:tl(m,a))})}return`${o}-${c}${[...u].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},a){if(e==="dot")return a.currentFlags.dotAll?a.appliedGlobalFlags.dotAll||a.useFlagMods?".":"[^]":wt`[^\n]`;if(e==="digit")return t?wt`\D`:wt`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&dT.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?wt`\P`:wt`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?wt`\W`:wt`\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,o){const c=a.currentFlags;n&&(a.currentFlags=pf(c,n));const u=t.map(o).join("|"),d=!a.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!a.useFlagMods||!n)?u:`(?${b7(e,n,a.useFlagMods)}${u})`;return a.currentFlags=c,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)+v7(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})`:wt`\g<${t}&R=${r}>`}},m7=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),p7=new Set(["-","\\","]","^","["]),g7=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),uk=new Map([[9,wt`\t`],[10,wt`\n`],[11,wt`\v`],[12,wt`\f`],[13,wt`\r`],[8232,wt`\u2028`],[8233,wt`\u2029`],[65279,wt`\uFEFF`]]),x7=new RegExp("^\\p{Cased}$","u");function mv(e){return x7.test(e)}function yT(e,t){const n=!!(t!=null&&t.firstOnly),r=e.min.value,a=e.max.value,o=[];if(r<65&&(a===65535||a>=131071)||r===65536&&a>=131071)return o;for(let c=r;c<=a;c++){const u=Fn(c);if(!mv(u))continue;const d=uT(u).filter(h=>{const m=h.codePointAt(0);return m<r||m>a});if(d.length&&(o.push(...d),n))break}return o}function tl(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(uk.has(e))return uk.get(e);if(e<32||e>126&&e<160||e>262143||t&&_7(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=n?r?g7:p7:m7,o=Fn(e);return(a.has(o)?"\\":"")+o}function y7(e){const t=e.map(a=>a.codePointAt(0)).sort((a,o)=>a-o),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 b7(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:a,disable:o}=t;r=(a!=null&&a.ignoreCase?"i":"")+(a!=null&&a.dotAll?"s":"")+(o?"-":"")+(o!=null&&o.ignoreCase?"i":"")+(o!=null&&o.dotAll?"s":"")}return`${r}:`}function v7({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 dk({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function _7(e){return e>47&&e<58}function hk({type:e,value:t}){return e==="Character"&&t===45}var ta,fi,Ya,na,Xa,ju,Uy,ua,S7=(ua=class extends RegExp{constructor(n,r,a){var t=(...nK)=>(super(...nK),Da(this,ju),Da(this,ta,new Map),Da(this,fi,null),Da(this,Ya),Da(this,na,null),Da(this,Xa,null),Le(this,"rawOptions",{}),this);const o=!!(a!=null&&a.lazyCompile);if(n instanceof RegExp){if(a)throw new Error("Cannot provide options when copying a regexp");const c=n;t(c,r),us(this,Ya,c.source),c instanceof ua&&(us(this,ta,cr(c,ta)),us(this,na,cr(c,na)),us(this,Xa,cr(c,Xa)),this.rawOptions=c.rawOptions)}else{const c={hiddenCaptures:[],strategy:null,transfers:[],...a};t(o?"":n,r),us(this,Ya,n),us(this,ta,C7(c.hiddenCaptures,c.transfers)),us(this,Xa,c.strategy),this.rawOptions=a??{}}o||us(this,fi,this)}get source(){return cr(this,Ya)||"(?:)"}exec(n){if(!cr(this,fi)){const{lazyCompile:o,...c}=this.rawOptions;us(this,fi,new ua(cr(this,Ya),this.flags,c))}const r=this.global||this.sticky,a=this.lastIndex;if(cr(this,Xa)==="clip_search"&&r&&a){this.lastIndex=0;const o=Ag(this,ju,Uy).call(this,n.slice(a));return o&&(w7(o,a,n,this.hasIndices),this.lastIndex+=a),o}return Ag(this,ju,Uy).call(this,n)}},ta=new WeakMap,fi=new WeakMap,Ya=new WeakMap,na=new WeakMap,Xa=new WeakMap,ju=new WeakSet,Uy=function(n){cr(this,fi).lastIndex=this.lastIndex;const r=ww(ua.prototype,this,"exec").call(cr(this,fi),n);if(this.lastIndex=cr(this,fi).lastIndex,!r||!cr(this,ta).size)return r;const a=[...r];r.length=1;let o;this.hasIndices&&(o=[...r.indices],r.indices.length=1);const c=[0];for(let u=1;u<a.length;u++){const{hidden:d,transferTo:h}=cr(this,ta).get(u)??{};if(d?c.push(null):(c.push(r.length),r.push(a[u]),this.hasIndices&&r.indices.push(o[u])),h&&a[u]!==void 0){const m=c[h];if(!m)throw new Error(`Invalid capture transfer to "${m}"`);if(r[m]=a[u],this.hasIndices&&(r.indices[m]=o[u]),r.groups){cr(this,na)||us(this,na,k7(this.source));const f=cr(this,na).get(h);f&&(r.groups[f]=a[u],this.hasIndices&&(r.indices.groups[f]=o[u]))}}}return r},ua);function w7(e,t,n,r){if(e.index+=t,e.input=n,r){const a=e.indices;for(let c=0;c<a.length;c++){const u=a[c];u&&(a[c]=[u[0]+t,u[1]+t])}const o=a.groups;o&&Object.keys(o).forEach(c=>{const u=o[c];u&&(o[c]=[u[0]+t,u[1]+t])})}}function C7(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,a]of t)for(const o of a)Cu(n,o,{}).transferTo=r;return n}function k7(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,a=0,o;for(;o=t.exec(e);){const{0:c,groups:{capture:u,name:d}}=o;c==="["?r++:r?c==="]"&&r--:u&&(a++,d&&n.set(a,d))}return n}function j7(e,t){const n=E7(e,t);return n.options?new S7(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function E7(e,t){const n=cT(t),r=tT(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:fv}),a=e7(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=d7(a,n),c=Uz(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),u=Hz(c.pattern),d=Fz(u.pattern,{captureTransfers:c.captureTransfers,hiddenCaptures:c.hiddenCaptures}),h={pattern:d.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const m=d.hiddenCaptures.sort((w,C)=>w-C),f=Array.from(d.captureTransfers),g=a._strategy,x=h.pattern.length>=n.lazyCompileLength;(m.length||f.length||g||x)&&(h.options={...m.length&&{hiddenCaptures:m},...f.length&&{transfers:f},...g&&{strategy:g},...x&&{lazyCompile:x}})}return h}function bT(e,t){return j7(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function N7(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>bT(n,{target:t.target})),{createScanner(n){return new VH(n,t)},createString(n){return{content:n}}}}XN(Qb({bundledLanguages:()=>sm,bundledLanguagesAlias:()=>Zb,bundledLanguagesBase:()=>Jb,bundledLanguagesInfo:()=>rm,bundledThemes:()=>tv,bundledThemesInfo:()=>ev,codeToHast:()=>U2,codeToHtml:()=>z2,codeToTokens:()=>V2,codeToTokensBase:()=>W2,codeToTokensWithThemes:()=>G2,createHighlighter:()=>hm,createJavaScriptRegexEngine:()=>N7,createOnigurumaEngine:()=>ZN,defaultJavaScriptRegexConstructor:()=>bT,getLastGrammarState:()=>K2,getSingletonHighlighter:()=>q2,loadWasm:()=>rv}),UH);let Tx=null;const au=new Set,yh=new Map,fk=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],T7=["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"],Ax={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 A7(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function vT(){return Tx||(Tx=hm({themes:T7,langs:fk}).then(e=>(fk.forEach(t=>au.add(t)),e))),Tx}async function L7(e){if(au.has(e))return;if(yh.has(e))return yh.get(e);const t=(async()=>{const n=await vT(),r=sm[e];if(r){await n.loadLanguage(r),au.add(e);return}try{const a=await se(()=>import(`shiki/langs/${e}.mjs`),[]);a.default&&(await n.loadLanguage(a.default),au.add(e))}catch(a){console.warn(`Failed to load language ${e}:`,a)}})();yh.set(e,t),await t,yh.delete(e)}const Vc=new Map,R7=50;function D7(e,t,n){return`${e}|${t}|${n}`}async function _T(e,t,n="github-dark-default"){t!=="text"&&!au.has(t)&&await L7(t);const r=D7(e,t,n),a=Vc.get(r);if(a)return a;const c=(await vT()).codeToHtml(e,{lang:t,theme:n,transformers:[A7()]});if(Vc.size>=R7){const u=Vc.keys().next().value;u&&Vc.delete(u)}return Vc.set(r,c),c}const O7={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 xm(e){var a;if(!e)return"text";const t=Au(e),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?O7[r]??"text":"text"}function ST(){const e=Zt(r=>r.currentPreset),t=Zt(r=>r.isCustom),n=Zt(r=>r.basePreset);return I7(e,t,n)}function I7(e,t,n){return t?n&&n!=="system"&&Ax[n]?Ax[n]??"github-dark-default":"github-dark-default":Ax[e]??"github-dark-default"}function wT(e=2e3){const[t,n]=j.useState(!1),r=j.useCallback(async a=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(a);else{const o=document.createElement("textarea");o.value=a,o.style.position="fixed",o.style.left="-9999px",document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o)}n(!0),setTimeout(()=>n(!1),e)}catch(o){console.error("Failed to copy:",o)}},[e]);return{copied:t,copy:r}}const M7=5e3,Jc=new Map,P7=100,B7=20*1024*1024;let $7=B7,Lx=0;function F7(e,t){for(Jc.set(e,t),Lx+=e.length;Jc.size>P7||Lx>$7;){const n=Jc.keys().next().value;if(n===void 0)break;Jc.delete(n),Lx-=n.length}return t}const H7=j.memo(function({language:t,codeString:n,showSyntaxHighlighting:r,deferHighlight:a}){const{copied:o,copy:c}=wT(),[u,d]=j.useState(null),h=ST(),m=j.useRef(n),f=t==="text"||n.length>M7;return j.useEffect(()=>{!r||a||f||(m.current=n,_T(n,t,h).then(g=>{m.current===n&&d(g)}))},[n,t,h,r,a,f]),s.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[s.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:[s.jsx("span",{children:t}),s.jsx("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),c(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:o?s.jsx(Hs,{}):s.jsx(El,{})})]}),r&&u?s.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:u}}):s.jsx(mn,{horizontal:!0,scope:"codeBlocks",children:s.jsx("pre",{className:"my-0 px-4 py-3 font-mono text-sm whitespace-pre-wrap break-word",children:s.jsx("code",{className:`language-${t}`,children:n})})})]})});function z7(e,t,n){const r=e?"text-text-muted":"text-text-heading",a=e?"text-text-secondary":"text-text-bold";return{code({className:o,children:c,...u}){const d=/language-(\w+)/.exec(o||"");if(!d&&!String(c).includes(`
|
|
247
|
+
`)){const g=e?"text-text-muted":"text-text-code";return s.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${g} font-mono text-xs`,...u,children:c})}const m=(d==null?void 0:d[1])||"text",f=String(c).replace(/\n$/,"");return s.jsx(H7,{language:m,codeString:f,showSyntaxHighlighting:t,deferHighlight:n})},p({children:o}){const c=e?"text-text-muted":"text-text-primary";return s.jsx("p",{className:`${c} mb-1.5 last:mb-0 leading-tight break-words`,children:o})},ul({children:o}){return s.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:o})},ol({children:o}){return s.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:o})},li({children:o}){const c=e?"text-text-muted":"text-text-primary";return s.jsx("li",{className:`${c} text-sm list-item`,children:o})},h1({children:o}){return s.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${r}`,children:o})},h2({children:o}){return s.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${r}`,children:o})},h3({children:o}){return s.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${r}`,children:o})},h4({children:o}){return s.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${r}`,children:o})},strong({children:o}){return s.jsx("strong",{className:`font-bold ${a}`,children:o})},em({children:o}){return s.jsx("em",{className:e?"italic text-text-secondary":"italic",children:o})},a({href:o,children:c}){return s.jsx("a",{href:o,className:"text-text-link hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:c})},blockquote({children:o}){const c=e?"text-text-muted":"text-text-secondary";return s.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${c} italic text-sm`,children:o})},table({children:o}){return s.jsx(mn,{horizontal:!0,className:"my-1.5",scope:"codeBlocks",children:s.jsx("table",{className:"min-w-full border border-border",children:o})})},th({children:o}){return s.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:o})},td({children:o}){return s.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:o})},hr(){return s.jsx("hr",{className:"border-border my-2"})},input({checked:o,...c}){return s.jsx("input",{type:"checkbox",checked:o,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...c})}}}const rr=j.memo(function({content:t,className:n="",muted:r=!1,isStreaming:a=!1}){const{showSyntaxHighlighting:o,deferCodeHighlightWhileStreaming:c}=Fs(),u=j.useMemo(()=>a&&c&&kT(t)%2===1,[a,c,t]),d=j.useMemo(()=>z7(r,o,u),[r,o,u]),h=j.useMemo(()=>{const m=U7(t);if(!W7(m)){if(!m.trim())return null;const f=r?"text-text-muted":"text-text-primary";return s.jsx("p",{className:`${f} mb-1.5 last:mb-0 leading-tight break-words whitespace-pre-line`,children:V7(m)})}return a?CT(m,d):G7(m,d,r,o)},[t,a,d,r,o]);return s.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:h})});function U7(e){let t=q7(e);return t=K7(t),t.trimEnd()}function V7(e){const t=e.split(/(https?:\/\/[^\s<>"']+)/g);return t.length===1?e:t.map((n,r)=>/^https?:\/\//.test(n)?s.jsx("a",{href:n,className:"text-text-link hover:underline",target:"_blank",rel:"noopener noreferrer",children:n},r):n)}function W7(e){return e.includes("`")||e.includes("~")||e.includes("<")||/^#{1,6}\s/m.test(e)||/^\s*[-*+]\s/m.test(e)||/^\s*\d+[.)]\s/m.test(e)||/^\s*>\s?/m.test(e)||/^\s*\|.*\|/m.test(e)||/^\s*([-*_])\1{2,}\s*$/m.test(e)||/\[[^\]]*\]\([^)]*\)/.test(e)||/!\[[^\]]*\]/.test(e)||/[*_]/.test(e)||e.includes("&")}function CT(e,t){return s.jsx(o6,{remarkPlugins:[v8],components:t,children:e})}function G7(e,t,n,r){const a=`${n?"m":"n"}|${r?"h":"p"}|${e}`,o=Jc.get(a);if(o!==void 0)return o;const c=CT(e,t);return F7(a,c)}function q7(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 kT(e){var t;return((t=e.match(/```/g))==null?void 0:t.length)??0}function K7(e){if(kT(e)%2===1){const n=e.lastIndexOf("```");return e.slice(n+3).includes(`
|
|
248
|
+
`),e+"\n```"}return e}function jT({isOpen:e,onClose:t,since:n}){const[r,a]=j.useState(null),[o,c]=j.useState(!1),{settings:u,getSetting:d,setSetting:h}=ma(),m=u[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]!=="false";j.useEffect(()=>{e&&d(Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE)},[e,d]),j.useEffect(()=>{if(!e)return;c(!0);const g=n?`/api/changelog?since=${encodeURIComponent(n)}`:"/api/changelog";me(g).then(x=>x.json()).then(x=>{a(x.content)}).catch(()=>{a(`# Changelog
|
|
249
|
+
|
|
250
|
+
Failed to load changelog.`)}).finally(()=>c(!1))},[e,n]);const f=j.useCallback(()=>{const g=m?"false":"true";h(Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,g)},[m,h]);return s.jsx(Et,{isOpen:e,onClose:t,title:"What's New in OpenFox",size:"xl",closeOnBackdropClick:!0,showCloseButton:!0,footer:s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx(xs,{enabled:m,onClick:f}),s.jsx("span",{className:"text-sm text-text-muted",children:"Show changelog on future updates"})]}),children:s.jsx("div",{className:"flex flex-col gap-4 min-h-0",children:o?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"})}):s.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:s.jsx(rr,{content:r??""})})})})}const Y7="#6b7280";function oo(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??Y7}const nl=(e,t)=>t?`${e}?workdir=${encodeURIComponent(t)}`:e,dt=Zn(e=>{const t=async n=>{e({loading:!0});try{const a=await(await me(nl("/api/agents",n))).json();e({defaults:a.defaults??[],userItems:a.userItems??[],projectItems:a.projectItems??[],modelOverrides:a.modelOverrides??{},loading:!1})}catch{e({loading:!1})}};return{defaults:[],userItems:[],projectItems:[],modelOverrides:{},loading:!1,fetchAgents:t,fetchAgent:async(n,r)=>{try{const a=await me(nl(`/api/agents/${n}`,r));return a.ok?await a.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await me(`/api/agents/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createAgent:async(n,r,a)=>{const o=await da("POST",nl("/api/agents",a),{...n,destination:r});return o.success&&await t(a),o},updateAgent:async(n,r,a)=>{const o=await da("PUT",nl(`/api/agents/${n}`,a),r);return o.success&&await t(a),o},deleteAgent:async(n,r)=>{try{const a=await me(nl(`/api/agents/${n}`,r),{method:"DELETE"}),o=await a.json();return a.ok?(e(c=>({userItems:c.userItems.filter(u=>u.id!==n),projectItems:c.projectItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:o.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateAgent:async(n,r,a)=>Ff(nl(`/api/agents/${n}/duplicate`,a),()=>t(a),r)}});function X7({onClose:e}){const[,t]=Nn(),{settings:n,getSetting:r,setSetting:a}=ma(),o=n[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",c=n[Ne.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",u=n[Ne.CACHE_WARMING]==="true",[d,h]=j.useState({openInEditor:o,dynamicPrompt:c,cacheWarming:u}),[m,f]=j.useState({patterns:[],maxRetriesPerTurn:10}),[g,x]=j.useState(""),[w,C]=j.useState(""),[v,S]=j.useState(!1),[_,b,k,E]=fy(),[T,L]=j.useState(!1),[A,O]=j.useState(!1),M=an(I=>I.version),H=bi(I=>I.status),B=bi(I=>I.latest),F=bi(I=>I.check),K=M&&B?{current:M,latest:B}:null,[G,V]=j.useState(!1),Z=dt(I=>I.defaults),J=dt(I=>I.userItems),z=dt(I=>I.fetchAgents),P=[...Z,...J].filter(I=>!I.subagent);j.useEffect(()=>{h({openInEditor:o,dynamicPrompt:c,cacheWarming:u})},[o,c,u]),j.useEffect(()=>{r(Ne.DISPLAY_SHOW_OPEN_IN_EDITOR),r(Ne.LLM_DYNAMIC_SYSTEM_PROMPT),r(Ne.CACHE_WARMING),r(Ne.RETRY_PATTERNS),r(Ne.PROXY_URL)},[r]),j.useEffect(()=>{const I=n[Ne.RETRY_PATTERNS];if(I)try{f(JSON.parse(I))}catch{}},[n]),j.useEffect(()=>{const I=n[Ne.PROXY_URL];I!==void 0&&x(I)},[n]),j.useEffect(()=>{z().catch(()=>{})},[z]),j.useEffect(()=>{r(Ne.DEFAULT_AGENT)},[r]),j.useEffect(()=>{const I=n[Ne.DEFAULT_AGENT];I!==void 0&&(C(I),S(!0))},[n]);const D=j.useCallback(I=>{f(I),a(Ne.RETRY_PATTERNS,JSON.stringify(I))},[a]),U=I=>{x(I),a(Ne.PROXY_URL,I)};function $(){E(async()=>(await me("/api/proxy/test",{method:"POST"})).json())}const te=()=>{const I=!d.openInEditor;h(Q=>({...Q,openInEditor:I})),a(Ne.DISPLAY_SHOW_OPEN_IN_EDITOR,String(I))},q=()=>{const I=!d.dynamicPrompt;h(Q=>({...Q,dynamicPrompt:I})),a(Ne.LLM_DYNAMIC_SYSTEM_PROMPT,String(I))},X=()=>{const I=!d.cacheWarming;h(Q=>({...Q,cacheWarming:I})),a(Ne.CACHE_WARMING,String(I))};function Y(){e(),t("/onboarding")}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-sm font-medium text-text-primary mb-1",children:[H==="available"&&s.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent-primary mr-1.5 align-middle"}),"Updates"]}),s.jsx("p",{className:"text-sm text-text-muted mb-4",children:M?s.jsxs(s.Fragment,{children:["Current version: ",s.jsxs("span",{className:"font-mono",children:["v",M]})]}):"Check for a new OpenFox version."}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ot,{variant:"secondary",onClick:()=>{V(!0),F()},disabled:H==="checking",children:H==="checking"?"Checking…":"Check for Updates"}),G&&H==="upToDate"&&s.jsx("span",{className:"text-sm text-text-muted",children:"Up to date"}),H==="error"&&s.jsx("span",{className:"text-sm text-text-muted",children:"Update check failed"}),H==="available"&&s.jsxs("button",{onClick:()=>L(!0),className:"text-sm text-accent-primary hover:underline",children:["Update to v",B," →"]})]})]}),s.jsx(VE,{isOpen:T,onClose:()=>L(!1),versionInfo:K}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("button",{onClick:()=>O(!0),className:"text-sm text-accent-primary hover:underline",children:"View Changelog →"}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("span",{className:"text-xs text-text-muted",children:"Show on update"}),s.jsx(xs,{enabled:(n[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true",onClick:()=>{const Q=(n[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true"?"false":"true";a(Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,Q)}})]})]}),s.jsx(jT,{isOpen:A,onClose:()=>O(!1)}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Default Agent"}),s.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."}),s.jsxs("select",{value:v?w:"",onChange:I=>{const Q=I.target.value;C(Q),a(Ne.DEFAULT_AGENT,Q)},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&&s.jsx("option",{value:"",children:"Loading…"}),v&&s.jsx("option",{value:"",children:"System default (planner)"}),P.map(I=>s.jsx("option",{value:I.id,children:I.name},I.id))]}),P.length===0&&v&&s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"No agents available. Create one in the Agents modal."})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),s.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Manage providers, workdir and vision fallback."}),s.jsx(ot,{variant:"secondary",onClick:Y,children:"Launch Onboarding"})]}),s.jsx("hr",{className:"border-border"}),s.jsx("div",{children:s.jsx(Rx,{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:te})}),s.jsx("hr",{className:"border-border"}),s.jsx(Rx,{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}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Network"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"HTTP Proxy"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(Ms,{type:"text",value:g,onChange:I=>U(I.target.value),placeholder:"http://proxy:8080",className:"flex-1"}),s.jsx(ot,{variant:"secondary",onClick:$,style:k?{color:"rgb(63, 185, 80)"}:void 0,children:_})]}),b&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:b}),s.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."})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Auto-Retry Patterns"}),s.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.'}),s.jsx(GO,{value:m,onChange:D})]}),s.jsx("hr",{className:"border-border"}),s.jsx(Rx,{title:"Dynamic System Prompt",description:"Rebuild the system prompt on every turn. Recommended value: off.",enabled:d.dynamicPrompt,onToggle:q,boldTitle:!0})]})}function Rx({title:e,description:t,enabled:n,onToggle:r,boldTitle:a}){return s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:`text-sm ${a?"font-medium":""} text-text-primary`,children:e}),s.jsx("div",{className:"text-sm text-text-muted mt-0.5",children:t})]}),s.jsx("div",{className:"flex-shrink-0",children:s.jsx(xs,{enabled:n,onClick:r})})]})}function Q7(e,t){return e===null&&t===null?!0:e===null||t===null?!1:JSON.stringify(e)===JSON.stringify(t)}function J7({label:e,binding:t,defaultBinding:n,isRecording:r,onStartRecording:a,onBindingRecorded:o,onClear:c,onReset:u,onCancelRecording:d}){const h=j.useRef(null),m=j.useRef(0),f=j.useRef("");return j.useEffect(()=>{if(!r)return;const g=new Set(["Control","Shift","Alt","Meta"]);let x=[];const w=v=>{if(v.preventDefault(),v.stopPropagation(),v.key==="Escape"){d();return}if(g.has(v.key)){const b=Date.now();if(v.key===f.current&&b-m.current<400){o({type:"double-press",key:v.key,threshold:300});return}m.current=b,f.current=v.key,v.ctrlKey&&!x.includes("ctrl")&&x.push("ctrl"),v.metaKey&&!x.includes("meta")&&x.push("meta"),v.altKey&&!x.includes("alt")&&x.push("alt"),v.shiftKey&&!x.includes("shift")&&x.push("shift");return}if(x.length>0||v.ctrlKey||v.metaKey||v.altKey||v.shiftKey){const b=[...x];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"),o({type:"chord",key:j1(v),modifiers:b});return}const S=Date.now(),_=j1(v);if(_===f.current&&S-m.current<400){o({type:"double-press",key:_,threshold:300});return}m.current=S,f.current=_},C=v=>{v.key==="Control"&&(x=x.filter(S=>S!=="ctrl")),v.key==="Shift"&&(x=x.filter(S=>S!=="shift")),v.key==="Alt"&&(x=x.filter(S=>S!=="alt")),v.key==="Meta"&&(x=x.filter(S=>S!=="meta"))};return window.addEventListener("keydown",w,!0),window.addEventListener("keyup",C,!0),()=>{window.removeEventListener("keydown",w,!0),window.removeEventListener("keyup",C,!0)}},[r,o,d]),s.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:[s.jsx("span",{className:"text-sm text-text-primary",children:e}),s.jsx("div",{className:"flex items-center gap-2",children:r?s.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):s.jsxs(s.Fragment,{children:[s.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?Eb(t):"None"}),t&&s.jsx("button",{type:"button",onClick:c,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:s.jsx(jb,{className:"w-3.5 h-3.5"})}),!Q7(t,n)&&s.jsx("button",{type:"button",onClick:u,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:s.jsx(Gf,{className:"w-3.5 h-3.5"})})]})})]})}function Z7(){const{settings:e,loading:t,setSetting:n}=ma(),r=e[Ne.KEYBINDINGS],a=t[Ne.KEYBINDINGS]??!1,o=hy(r),[c,u]=j.useState(null),d=[{id:"terminalToggle",label:"Toggle Terminal",binding:o.terminalToggle,defaultBinding:Ds.terminalToggle},{id:"quickAction",label:"Quick Action",binding:o.quickAction,defaultBinding:Ds.quickAction},{id:"modelSelector",label:"Select Model",binding:o.modelSelector,defaultBinding:Ds.modelSelector},{id:"sessionSearch",label:"Search Sessions",binding:o.sessionSearch,defaultBinding:Ds.sessionSearch},{id:"criteriaSidebar",label:"Toggle Criteria Sidebar",binding:o.criteriaSidebar,defaultBinding:Ds.criteriaSidebar},...o.agentSwitching.map((x,w)=>({id:`agentSwitching.${w}`,label:`Switch to Agent ${w+1}`,binding:x,defaultBinding:Ds.agentSwitching[w]??null}))],h=x=>{u(x)},m=j.useCallback((x,w)=>{const C=hy(r);if(x.startsWith("agentSwitching.")){const v=parseInt(x.split(".")[1],10);C.agentSwitching[v]=w}else x==="terminalToggle"?C.terminalToggle=w:x==="quickAction"?C.quickAction=w:x==="modelSelector"?C.modelSelector=w:x==="sessionSearch"?C.sessionSearch=w:x==="criteriaSidebar"&&(C.criteriaSidebar=w);n(Ne.KEYBINDINGS,JSON.stringify(C))},[r,n]),f=j.useCallback(x=>{c&&(u(null),m(c,x))},[c,m]),g=()=>{n(Ne.KEYBINDINGS,JSON.stringify(Ds))};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),s.jsx("button",{type:"button",onClick:g,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?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):s.jsx("div",{className:"space-y-1",children:d.map(x=>s.jsx(J7,{label:x.label,binding:x.binding,defaultBinding:x.defaultBinding,isRecording:c===x.id,onStartRecording:()=>h(x.id),onBindingRecorded:f,onClear:()=>m(x.id,null),onReset:()=>m(x.id,x.defaultBinding),onCancelRecording:()=>u(null)},x.id))})]})}function pv(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 gv(e){switch(e){case"connected":return"●";case"error":return"✕";default:return"○"}}function gf(e){return e>=1e3?`~${(e/1e3).toFixed(1)}K`:`~${e}`}function ET({server:e,expanded:t,onToggleExpand:n,serverToggleEnabled:r,onServerToggle:a,tools:o,onToolToggle:c,statusDot:u,statusColor:d,actions:h,authPanel:m}){var w;const[f,g]=j.useState(new Set),x=e.name;return s.jsxs("div",{className:"rounded border border-border bg-bg-tertiary overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-bg-primary/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 cursor-pointer",onClick:()=>n(x),children:[s.jsx("span",{className:`text-sm ${d}`,children:u}),s.jsx("span",{className:"text-sm font-medium text-text-primary",children:x}),s.jsx("span",{className:"text-xs text-text-muted",children:e.config.transport}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",o.length," tools)"]}),s.jsxs("span",{className:"text-xs text-text-muted",children:[gf(e.estimatedTokens)," tokens"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xs,{enabled:r,onClick:a}),h,s.jsx("span",{className:"text-xs text-text-muted",children:t?"▲":"▼"})]})]}),t&&s.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5",children:[e.config.command&&s.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[e.config.command," ",((w=e.config.args)==null?void 0:w.join(" "))??""]}),e.config.url&&s.jsx("div",{className:"text-xs text-text-muted font-mono",children:e.config.url}),m,o.length===0?s.jsx("div",{className:"text-xs text-text-muted",children:"No tools available"}):s.jsx("div",{className:"space-y-1",children:o.map(C=>s.jsxs("div",{className:"py-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1 mr-2",children:[s.jsx("span",{className:"text-xs text-text-primary font-mono",children:C.name}),C.description&&C.description.length>80?s.jsxs("button",{onClick:()=>{const v=C.name;g(S=>{const _=new Set(S);return _.has(v)?_.delete(v):_.add(v),_})},className:"inline-flex items-center gap-0.5 text-xs text-text-muted hover:text-text-primary transition-colors ml-2",children:[s.jsx("span",{className:"truncate max-w-[300px]",children:C.description}),s.jsx(gn,{rotate:f.has(C.name)?180:0,className:"w-3 h-3 flex-shrink-0"})]}):C.description?s.jsx("span",{className:"text-xs text-text-muted ml-2",children:C.description}):null]}),s.jsx("span",{className:"text-xs text-text-muted mr-2 flex-shrink-0",children:gf(C.estimatedTokens)}),s.jsx(xs,{enabled:C.enabled,onClick:()=>c(C.name)})]}),C.description&&C.description.length>80&&f.has(C.name)&&s.jsx("div",{className:"text-xs text-text-muted mt-1 ml-1",children:C.description})]},C.name))})]})]},x)}function mk(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 pk({formData:e,onChange:t}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Transport"}),s.jsxs("div",{className:"flex gap-1",children:[s.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"}),s.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"?s.jsxs(s.Fragment,{children:[s.jsx(ss,{label:"Command",value:e.command,onChange:n=>t({...e,command:n}),placeholder:"e.g. npx"}),s.jsx(ss,{label:"Arguments",value:e.args,onChange:n=>t({...e,args:n}),placeholder:"space-separated args"}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Environment variables ",s.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),s.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})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(ss,{label:"URL",value:e.url,onChange:n=>t({...e,url:n}),placeholder:"e.g. https://mcp.example.com/mcp"}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Headers ",s.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),s.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})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e.oauth,onChange:n=>t({...e,oauth:n.target.checked}),className:"mt-0.5"}),s.jsxs("span",{className:"text-xs text-text-secondary",children:["Authorize with OAuth",s.jsx("span",{className:"block text-text-muted",children:"For servers that require a sign in rather than a static credential. Expand the server afterwards to authorize."})]})]})]}),s.jsx(ss,{label:"Timeout (seconds)",value:e.timeout,onChange:n=>t({...e,timeout:n}),placeholder:"optional, e.g. 30"})]})}const Dx="px-2 py-1 rounded text-xs font-medium text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors disabled:opacity-50";function eU({serverName:e,onChanged:t}){const[n,r]=j.useState(!1),[a,o]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(""),m=`/api/mcp/servers/${encodeURIComponent(e)}/oauth`,f=async v=>{r(!0),h("");try{await v()}catch(S){h(S instanceof Error?S.message:String(S))}finally{r(!1)}},g=async(v,S)=>{const _=await me(v,{method:"POST",headers:{"Content-Type":"application/json"},...S!==void 0?{body:JSON.stringify(S)}:{}}),b=await _.json();if(!_.ok)throw new Error(b.error??"Request failed");return b},x=()=>f(async()=>{const v=await g(`${m}/start`);if(v.status!=="redirect"){t();return}o(v.redirectUri??""),window.open(v.authorizationUrl,"_blank","noopener,noreferrer")}),w=()=>f(async()=>{await g(`${m}/complete`,{response:c}),u(""),o(""),t()}),C=()=>f(async()=>{if(!(await me(m,{method:"DELETE"})).ok)throw new Error("Could not clear the stored credentials");t()});return s.jsxs("div",{className:"space-y-1.5 py-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:x,disabled:n,className:Dx,children:"Authorize"}),s.jsx("button",{onClick:C,disabled:n,className:Dx,children:"Forget credentials"})]}),a&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"text-xs text-text-muted",children:"A tab opened for you to sign in. If it ends up on a page that will not load, copy the whole address from it and paste it below."}),s.jsx("div",{className:"text-xs text-text-muted font-mono break-all",children:a}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{value:c,onChange:v=>u(v.target.value),placeholder:"paste the callback URL",className:"flex-1 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"}),s.jsx("button",{onClick:w,disabled:n||!c,className:Dx,children:"Finish"})]})]}),d&&s.jsx("div",{className:"text-xs text-accent-error",children:d})]})}function Ox(e,t,n,r=250){const a=j.useRef(!0);j.useEffect(()=>{if(a.current){a.current=!1;return}const o=setTimeout(()=>{n(t,e)},r);return()=>clearTimeout(o)},[e,t,r,n])}function gk({saving:e,saveLabel:t,savingLabel:n,onCancel:r,onSave:a}){return s.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[s.jsx(ot,{variant:"secondary",onClick:r,disabled:e,children:"Cancel"}),s.jsx(ot,{variant:"primary",onClick:a,disabled:e,children:e?n:t})]})}function tU(){const{settings:e,getSetting:t,setSetting:n}=ma(),[r,a]=j.useState(""),[o,c]=j.useState(""),[u,d]=j.useState(""),[h,m]=j.useState("");Ox(o,Ne.SEARCH_TAVILY_API_KEY,n),Ox(u,Ne.SEARCH_SEARXNG_URL,n),Ox(h,Ne.SEARCH_SEARXNG_API_KEY,n);const[f,g,x,w]=fy(),[C,v,S,_]=fy();j.useEffect(()=>{t(Ne.SEARCH_ENGINE),t(Ne.SEARCH_TAVILY_API_KEY),t(Ne.SEARCH_SEARXNG_URL),t(Ne.SEARCH_SEARXNG_API_KEY),t(Ne.TOOLS_USE_RTK),t(Ne.CONFIRM_ON_WORKSPACE_ACTIONS)},[t]),j.useEffect(()=>{e[Ne.SEARCH_ENGINE]!==void 0&&(a(e[Ne.SEARCH_ENGINE]??""),c(e[Ne.SEARCH_TAVILY_API_KEY]??""),d(e[Ne.SEARCH_SEARXNG_URL]??""),m(e[Ne.SEARCH_SEARXNG_API_KEY]??""))},[e]);function b(ae){a(ae),n(Ne.SEARCH_ENGINE,ae)}function k(){w(async()=>(await me("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"tavily",tavilyApiKey:o||void 0})})).json())}function E(){_(async()=>(await me("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"searxng",searxngUrl:u||void 0,searxngApiKey:h||void 0})})).json())}const[T,L]=j.useState("checking");j.useEffect(()=>{me("/api/tools/rtk-check").then(ae=>ae.json()).then(ae=>L(ae.available?"available":"unavailable")).catch(()=>L("unavailable"))},[]);const[A,O]=j.useState([]);j.useEffect(()=>{t(Ne.TOOLS_SHELL),me("/api/tools/shells").then(ae=>ae.json()).then(ae=>O(ae.shells??[])).catch(()=>O([]))},[t]);const M=e[Ne.TOOLS_SHELL]||"cmd",[H,B]=j.useState([]),[F,K]=j.useState(!0),[G,V]=j.useState(!1),[Z,J]=j.useState(null),[z,P]=j.useState(new Set),[D,U]=j.useState({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",oauth:!1,timeout:""}),[$,te]=j.useState(""),[q,X]=j.useState(""),[Y,I]=j.useState(!1),{requestDelete:Q,clearConfirm:ne,isConfirming:re}=Tu(),ie=j.useCallback(async()=>{try{const Ue=((await(await me("/api/mcp/servers")).json()).servers??[]).sort((de,Ae)=>de.name.localeCompare(Ae.name));B(Ue)}catch{}K(!1)},[]);j.useEffect(()=>{ie()},[ie]),j.useEffect(()=>{const ae=()=>ie();return window.addEventListener("mcp-servers-changed",ae),()=>window.removeEventListener("mcp-servers-changed",ae)},[ie]);const pe=ae=>{P(Pe=>{const Ue=new Set(Pe);return Ue.has(ae)?(Ue.delete(ae),Ue):(Ue.add(ae),Ue)})};function ye(){if(D.transport==="stdio"&&!D.command)return"Command is required for stdio transport";if(D.transport==="http"&&!D.url)return"URL is required for HTTP transport";if(D.timeout){const ae=parseFloat(D.timeout);if(isNaN(ae)||ae<=0)return"Timeout must be a positive number"}return null}function Ie(ae){const Pe=ae?{name:D.name,transport:D.transport}:{transport:D.transport};if(D.transport==="stdio"?(Pe.command=D.command,Pe.args=D.args?D.args.split(" ").filter(Boolean):[],Pe.env=mk(D.env)):(Pe.url=D.url,Pe.headers=mk(D.headers),Pe.oauth=D.oauth),D.timeout){const Ue=parseFloat(D.timeout);!isNaN(Ue)&&Ue>0&&(Pe.timeout=Ue)}return Pe}const $e={name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",oauth:!1,timeout:""},Se=async()=>{if(te(""),!D.name){te("Name is required");return}const ae=ye();if(ae){te(ae);return}I(!0);try{const Pe=Ie(!0),Ue=await me("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Pe)});if(!Ue.ok){const de=await Ue.json();throw new Error(de.error??"Failed to add server")}V(!1),U($e),await ie()}catch(Pe){te(Pe instanceof Error?Pe.message:String(Pe))}finally{I(!1)}},Ge=ae=>{var Pe;U({name:ae.name,transport:ae.config.transport,command:ae.config.command??"",args:((Pe=ae.config.args)==null?void 0:Pe.join(" "))??"",env:ae.config.env?Object.entries(ae.config.env).map(([Ue,de])=>`${Ue}=${de}`).join(`
|
|
252
|
+
`):"",url:ae.config.url??"",headers:ae.config.headers?Object.entries(ae.config.headers).map(([Ue,de])=>`${Ue}=${de}`).join(`
|
|
253
|
+
`):"",oauth:ae.config.oauth??!1,timeout:ae.config.timeout!==void 0?String(ae.config.timeout):""}),te(""),J(ae.name)},Je=async()=>{te("");const ae=ye();if(ae){te(ae);return}I(!0);try{const Pe=Ie(!1),Ue=await me(`/api/mcp/servers/${encodeURIComponent(Z)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Pe)});if(!Ue.ok){const de=await Ue.json();throw new Error(de.error??"Failed to update server")}J(null),U($e),await ie()}catch(Pe){te(Pe instanceof Error?Pe.message:String(Pe))}finally{I(!1)}},_e=async ae=>{try{const Pe=await me(`/api/mcp/servers/${encodeURIComponent(ae)}`,{method:"DELETE"});if(!Pe.ok){const Ue=await Pe.json().catch(()=>({}));throw new Error(Ue.error??"Failed to remove server")}ne(),X(""),await ie()}catch(Pe){X(Pe instanceof Error?Pe.message:String(Pe))}},ge=async(ae,Pe,Ue)=>{try{const de=await me(`/api/mcp/servers/${encodeURIComponent(ae)}/tools/${encodeURIComponent(Pe)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ue})});if(!de.ok){const Ae=await de.json().catch(()=>({}));throw new Error(Ae.error??"Failed to toggle tool")}X(""),await ie()}catch(de){X(de instanceof Error?de.message:String(de))}},he=async(ae,Pe)=>{try{const Ue=await me(`/api/mcp/servers/${encodeURIComponent(ae)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:Pe})});if(!Ue.ok){const de=await Ue.json().catch(()=>({}));throw new Error(de.error??"Failed to toggle server")}X(""),await ie()}catch(Ue){X(Ue instanceof Error?Ue.message:String(Ue))}};return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Search Engine"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Configure a web search engine for the web_search tool."}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Engine"}),s.jsx("div",{className:"flex gap-2",children:["","tavily","searxng"].map(ae=>s.jsx("button",{onClick:()=>b(ae),className:`px-3 py-1.5 rounded text-sm border transition-colors ${r===ae?"bg-accent-primary/10 border-accent-primary text-accent-primary":"border-border text-text-muted hover:text-text-primary"}`,children:ae||"Off"},ae))})]}),r==="tavily"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Tavily API Key"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(Ms,{type:"password",value:o,onChange:ae=>c(ae.target.value),placeholder:"tvly-...",className:"flex-1"}),s.jsx(ot,{variant:"secondary",onClick:k,style:x?{color:"rgb(63, 185, 80)"}:void 0,children:f})]}),g&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:g}),s.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Get a free API key at"," ",s.jsx("a",{href:"https://app.tavily.com",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"tavily.com"})]})]}),r==="searxng"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"SearXNG URL"}),s.jsx(Ms,{type:"url",value:u,onChange:ae=>d(ae.target.value),placeholder:"http://localhost:4000",className:"w-full"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs font-medium text-text-primary mb-1",children:["API Key ",s.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),s.jsx(Ms,{type:"password",value:h,onChange:ae=>m(ae.target.value),placeholder:"Optional API key",className:"w-full"})]}),s.jsx(ot,{variant:"secondary",onClick:E,style:S?{color:"rgb(63, 185, 80)"}:void 0,children:C}),v&&s.jsx("p",{className:"text-xs text-red-500",children:v})]})]})]}),A.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Shell"}),s.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."}),s.jsx("div",{className:"flex gap-2",children:A.map(ae=>s.jsxs("button",{onClick:()=>n(Ne.TOOLS_SHELL,ae.id),disabled:!ae.available,title:ae.available?void 0:"Not found on this machine",className:`px-3 py-1.5 rounded text-sm border transition-colors ${M===ae.id?"bg-accent-primary/10 border-accent-primary text-accent-primary":ae.available?"border-border text-text-muted hover:text-text-primary":"border-border text-text-muted opacity-50 cursor-not-allowed"}`,children:[ae.label,!ae.available&&" (not found)"]},ae.id))}),s.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."})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Token Optimization"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Reduce token consumption by filtering command output through RTK. See the"," ",s.jsx("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"README"})," ","for installation."]}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-text-primary",children:"Enable RTK auto-rewrite"}),T==="checking"&&s.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"checking…"}),T==="available"&&s.jsx("span",{className:"text-xs text-accent-success",children:"● installed"}),T==="unavailable"&&s.jsx("span",{className:"text-xs text-accent-error",children:"○ not found"})]})}),s.jsx(xs,{enabled:e[Ne.TOOLS_USE_RTK]==="true",onClick:()=>n(Ne.TOOLS_USE_RTK,e[Ne.TOOLS_USE_RTK]==="true"?"false":"true")})]}),A.length>0&&e[Ne.TOOLS_USE_RTK]==="true"&&M!=="gitbash"&&s.jsx("p",{className:"text-xs text-accent-warning mt-1",children:"RTK only rewrites Unix-style commands — with this shell it will rarely apply and can break some commands. Git Bash is recommended."})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Agent Confirmations"}),s.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."}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx("span",{className:"text-sm text-text-primary",children:"Confirm on workspace & git actions"})}),s.jsx(xs,{enabled:e[Ne.CONFIRM_ON_WORKSPACE_ACTIONS]==="true",onClick:()=>n(Ne.CONFIRM_ON_WORKSPACE_ACTIONS,e[Ne.CONFIRM_ON_WORKSPACE_ACTIONS]==="true"?"false":"true")})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary","data-testid":"mcp-servers-heading",children:"MCP Servers"}),s.jsx(ot,{variant:"primary",size:"sm",onClick:()=>V(!0),children:"+ Add Server"})]}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"MCP servers provide external tools that extend OpenFox's capabilities."}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx("span",{className:"text-sm text-text-primary",children:"Show per-conversation MCP toggle in chat bar"})}),s.jsx(xs,{enabled:e[Ne.FEATURES_PER_SESSION_MCP]==="true",onClick:()=>n(Ne.FEATURES_PER_SESSION_MCP,e[Ne.FEATURES_PER_SESSION_MCP]==="true"?"false":"true")})]}),q&&s.jsx(_l,{message:q}),s.jsx(Tb,{loading:F,hasItems:H.length>0,loadingLabel:"Loading MCP servers...",emptyLabel:"No MCP servers configured.",children:H.map(ae=>{const Pe=z.has(ae.name)?re(ae.name,"delete")?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:de=>{de.stopPropagation(),_e(ae.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"}),s.jsx("button",{onClick:de=>{de.stopPropagation(),ne()},className:"px-2 py-1 rounded text-xs text-text-muted hover:bg-bg-primary transition-colors",children:"Cancel"})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:de=>{de.stopPropagation(),Ge(ae)},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"}),s.jsx("button",{onClick:de=>{de.stopPropagation(),Q(ae.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,Ue=ae.status==="error"&&ae.error?s.jsx("span",{className:"text-xs text-accent-error truncate max-w-[200px]",title:ae.error,children:ae.error}):null;return s.jsx(ET,{server:ae,expanded:z.has(ae.name),onToggleExpand:pe,serverToggleEnabled:!ae.config.disabled,onServerToggle:()=>he(ae.name,!ae.config.disabled),tools:ae.tools,onToolToggle:de=>{var Ae;return ge(ae.name,de,!((Ae=ae.tools.find(ue=>ue.name===de))!=null&&Ae.enabled))},statusDot:gv(ae.status),statusColor:pv(ae.status),authPanel:ae.config.oauth?s.jsx(eU,{serverName:ae.name,onChanged:ie}):null,actions:s.jsxs(s.Fragment,{children:[Ue,Pe]})},ae.name)})}),G&&s.jsx(Et,{isOpen:G,onClose:()=>{V(!1),te("")},title:"Add MCP Server",size:"sm",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(ss,{label:"Name",value:D.name,onChange:ae=>U({...D,name:ae}),placeholder:"e.g. filesystem"}),s.jsx(pk,{formData:D,onChange:U}),$&&s.jsx(_l,{message:$}),s.jsx(gk,{saving:Y,saveLabel:"Add",savingLabel:"Adding...",onCancel:()=>{V(!1),te(""),I(!1),U($e)},onSave:Se})]})}),Z!==null&&s.jsx(Et,{isOpen:!0,onClose:()=>{J(null),te("")},title:`Edit MCP Server: ${Z}`,size:"sm",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(pk,{formData:D,onChange:U}),$&&s.jsx(_l,{message:$}),s.jsx(gk,{saving:Y,saveLabel:"Save",savingLabel:"Saving...",onCancel:()=>{J(null),te(""),I(!1),U($e)},onSave:Je})]})})]})]})}const NT="openfox_user_plugins";function nU(e){const t=e.match(/github\.com\/([^/]+)\/([^/]+?)(?:\/|$)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,"")}:null}async function Ix(e){const t=nU(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 bh(){try{return JSON.parse(localStorage.getItem(NT)??"[]")}catch{return[]}}function xk(e){localStorage.setItem(NT,JSON.stringify(e))}function rU({onAdd:e}){const[t,n]=j.useState(""),[r,a]=j.useState(""),[o,c]=j.useState(!1),u=d=>{d.preventDefault(),!(!t.trim()||!r.trim())&&(e({name:t.trim(),displayName:t.trim(),description:"User-added plugin",githubUrl:r.trim()}),n(""),a(""),c(!0),setTimeout(()=>c(!1),2e3))};return s.jsxs("form",{onSubmit:u,className:"flex gap-2 items-end",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),s.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"})]}),s.jsxs("div",{className:"flex-[2]",children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"GitHub URL"}),s.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"})]}),s.jsx(ot,{type:"submit",variant:"primary",size:"sm",children:o?"Added":"Add"})]})}function sU({plugin:e,initiallyInstalled:t,installedVersion:n,onRemove:r,onOpenFolder:a}){const[o,c]=j.useState(t?"installed":"idle"),[u,d]=j.useState(!1),[h,m]=j.useState(""),[f,g]=j.useState(n),[x,w]=j.useState(!1),[C,v]=j.useState(!1);j.useEffect(()=>{g(n)},[n]);const S=j.useCallback(async()=>{const M=await me("/api/plugins/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({githubUrl:e.githubUrl})}),H=await M.json();if(M.ok)c("installed"),e.latestVersion&&g(e.latestVersion),H.loaded||m(H.loadError??"Plugin installed but failed to load");else throw new Error(H.error??"Install failed")},[e.githubUrl,e.name]),_=async()=>{c("installing"),m("");try{await S()}catch(M){c("error"),m(M instanceof Error?M.message:"Connection error")}},b=()=>{w(!0)},k=async()=>{v(!0);try{(await me(`/api/plugins/${e.name}`,{method:"DELETE"})).ok&&(c("idle"),r(e.name))}catch{}v(!1),w(!1)},E=async()=>{d(!0),m("");try{await S()}catch(M){m(M instanceof Error?M.message:"Update failed")}d(!1)},T=f??n,L=e.latestVersion&&T&&T!=="unknown"&&e.latestVersion!==T,A=o==="installing"?"Installing…":u?"Updating…":o==="installed"?"Installed ✓":"Install",O=o==="installing"||o==="installed"||u;return s.jsxs("div",{className:"border border-border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:e.displayName}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",e.name,")"]})]}),s.jsx("p",{className:"text-xs text-text-muted mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs",children:[e.githubUrl&&s.jsx("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer",className:"text-accent-primary hover:underline",children:"GitHub"}),e.versionLoading?s.jsx("span",{className:"text-text-muted",children:"Loading version…"}):e.latestVersion?s.jsxs("span",{className:"text-text-muted",children:["v",e.latestVersion]}):null,T&&T!=="unknown"&&s.jsxs("span",{className:"text-text-muted",children:["installed: v",T]})]}),o==="error"&&h&&s.jsx("p",{className:"text-xs text-accent-error mt-1",children:h})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1",children:[s.jsxs("div",{className:"flex gap-1",children:[e.githubUrl&&s.jsx(ot,{variant:o==="installed"?"secondary":"primary",size:"sm",onClick:_,disabled:O,children:A}),L&&s.jsx(ot,{variant:"primary",size:"sm",onClick:E,children:"Update"}),o==="installed"&&s.jsx(ot,{variant:"danger",size:"sm",onClick:b,children:"Remove"})]}),o==="installed"&&s.jsx("button",{onClick:()=>a(e.name),className:"text-xs text-accent-primary hover:underline",children:"Open folder"})]})]}),s.jsx(Nl,{isOpen:x,onClose:()=>w(!1),onConfirm:k,title:`Remove "${e.displayName}"?`,message:`Remove the "${e.displayName}" plugin from your installation.`,confirmLabel:"Remove",confirmVariant:"danger",disabled:C})]})}function iU(){const[e,t]=j.useState([]),[n,r]=j.useState([]),[a,o]=j.useState({}),[c,u]=j.useState(!0),[d,h]=j.useState(""),[m,f]=j.useState("");j.useEffect(()=>{let S=!1;Promise.all([me("/api/plugins/registry").then(b=>{if(!b.ok)throw new Error(`HTTP ${b.status}`);return b.json()}),me("/api/plugins/installed").then(b=>b.ok?b.json():{installed:[]})]).then(([b,k])=>{if(S)return;const E={},T=k.installed;for(const H of T)E[H.name]=H.version;o(E);const L=b.plugins.map(H=>({...H,latestVersion:null,versionLoading:!0}));t(L),L.forEach(H=>{Ix(H.githubUrl).then(B=>{S||t(F=>F.map(K=>K.name===H.name?{...K,latestVersion:B,versionLoading:!1}:K))})});const A=new Set(L.map(H=>H.name)),O=bh(),M=[];for(const H of T)!A.has(H.name)&&!O.some(B=>B.name===H.name)&&M.push({name:H.name,displayName:H.name,description:"Found on disk",githubUrl:"",latestVersion:null,versionLoading:!1});M.length>0&&r(H=>[...H,...M])}).catch(b=>{S||h(b instanceof Error?b.message:"Failed to load plugins")}).finally(()=>{S||u(!1)});const _=bh();return _.length>0&&(r(_.map(b=>({...b,latestVersion:null,versionLoading:!0}))),_.forEach(b=>{Ix(b.githubUrl).then(k=>{S||r(E=>E.map(T=>T.name===b.name?{...T,latestVersion:k,versionLoading:!1}:T))})})),()=>{S=!0}},[]);const g=async S=>{try{S?await me(`/api/plugins/${S}/open-folder`):await me("/api/plugins/open-folder")}catch{}},x=j.useCallback(S=>{o(k=>{const E={...k};return delete E[S],E});const _=bh(),b=_.filter(k=>k.name!==S);b.length!==_.length&&xk(b),r(k=>k.filter(E=>E.name!==S))},[]),w=j.useCallback(S=>{if(new Set(e.map(k=>k.name)).has(S.name)){f(`"${S.displayName}" is already listed in the registry and won't be added again.`);return}const b=bh();xk([...b,S]),r(k=>[...k,{...S,latestVersion:null,versionLoading:!0}]),Ix(S.githubUrl).then(k=>{r(E=>E.map(T=>T.name===S.name?{...T,latestVersion:k,versionLoading:!1}:T))})},[e]),C=new Set,v=[...e,...n].filter(S=>C.has(S.name)?!1:(C.add(S.name),!0));return c?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading plugins..."}):s.jsxs("div",{className:"space-y-4",children:[d&&s.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]}),m&&s.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:[s.jsx("span",{children:m}),s.jsx("button",{onClick:()=>f(""),className:"text-text-muted hover:text-text-primary ml-2",children:"×"})]}),s.jsxs("div",{className:"border border-border rounded-lg p-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Add Plugin"}),s.jsx(rU,{onAdd:w})]}),v.length===0&&!d&&s.jsx("div",{className:"text-sm text-text-muted",children:"No plugins found."}),v.map(S=>s.jsx(sU,{plugin:S,initiallyInstalled:S.name in a,installedVersion:a[S.name]??null,onRemove:x,onOpenFolder:g},S.name))]})}function aU({isOpen:e,onClose:t}){const[n,r]=j.useState("instructions"),a=bi(c=>c.status==="available"),o=()=>{try{Vt.send("context.checkDynamic",{})}catch{}t()};return s.jsx(Et,{isOpen:e,onClose:o,title:"Settings",size:"xl",scrollable:!1,children:s.jsxs("div",{"data-global-settings":!0,className:"flex flex-col h-full min-h-0 -m-4",children:[s.jsxs(pt,{horizontal:!0,options:{scrollbars:{visibility:"hidden"}},className:"flex border-b border-border mb-4 flex-shrink-0 px-4 pt-4",children:[s.jsx(Yi,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),s.jsx(Yi,{label:"Tools",active:n==="tools",onClick:()=>r("tools")}),s.jsx(Yi,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),s.jsx(Yi,{label:"Plugins",active:n==="plugins",onClick:()=>r("plugins")}),s.jsx(Yi,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),s.jsx(Yi,{label:"Display",active:n==="display",onClick:()=>r("display")}),s.jsx(Yi,{label:"Keybindings",active:n==="keybindings",onClick:()=>r("keybindings")}),s.jsx(Yi,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced"),showDot:a})]}),s.jsxs(pt,{className:"flex-1 min-h-0 px-4 pb-4",children:[n==="instructions"&&s.jsx(EO,{isOpen:e}),n==="skills"&&s.jsx(jO,{isOpen:e}),n==="plugins"&&s.jsx(iU,{}),n==="notifications"&&s.jsx(gO,{}),n==="display"&&s.jsx(HO,{}),n==="keybindings"&&s.jsx(Z7,{}),n==="tools"&&s.jsx(tU,{}),n==="advanced"&&s.jsx(X7,{onClose:t})]})]})})}function Yi({label:e,active:t,onClick:n,showDot:r}){return s.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&&s.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]})}var Mx={exports:{}},yk;function oU(){return yk||(yk=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(c,u,d){var h=this&&this.__decorate||function(_,b,k,E){var T,L=arguments.length,A=L<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(_,b,k,E);else for(var O=_.length-1;O>=0;O--)(T=_[O])&&(A=(L<3?T(A):L>3?T(b,k,A):T(b,k))||A);return L>3&&A&&Object.defineProperty(b,k,A),A},m=this&&this.__param||function(_,b){return function(k,E){b(k,E,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.AccessibilityManager=void 0;const f=d(9042),g=d(9924),x=d(844),w=d(4725),C=d(2585),v=d(3656);let S=u.AccessibilityManager=class extends x.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 g.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,x.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+=f.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 L=k.lines.get(k.ydisp+T),A=[],O=(L==null?void 0:L.translateToString(!0,void 0,void 0,A))||"",M=(k.ydisp+T+1).toString(),H=this._rowElements[T];H&&(O.length===0?(H.innerText=" ",this._rowColumns.set(H,[0,1])):(H.textContent=O,this._rowColumns.set(H,A)),H.setAttribute("aria-posinset",M),H.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,L;if(b===0?(T=k,L=this._rowElements.pop(),this._rowContainer.removeChild(L)):(T=this._rowElements.shift(),L=k,this._rowContainer.removeChild(T)),T.removeEventListener("focus",this._topBoundaryFocusListener),L.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const A=this._createAccessibilityTreeNode();this._rowElements.unshift(A),this._rowContainer.insertAdjacentElement("afterbegin",A)}else{const A=this._createAccessibilityTreeNode();this._rowElements.push(A),this._rowContainer.appendChild(A)}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 O;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:((O=E.textContent)==null?void 0:O.length)??0}),!this._rowContainer.contains(k.node))return;const T=({node:M,offset:H})=>{const B=M instanceof Text?M.parentNode:M;let F=parseInt(B==null?void 0:B.getAttribute("aria-posinset"),10)-1;if(isNaN(F))return console.warn("row is invalid. Race condition?"),null;const K=this._rowColumns.get(B);if(!K)return console.warn("columns is null. Race condition?"),null;let G=H<K.length?K[H]:K.slice(-1)[0]+1;return G>=this._terminal.cols&&(++F,G=0),{row:F,column:G}},L=T(b),A=T(k);if(L&&A){if(L.row>A.row||L.row===A.row&&L.column>=A.column)throw new Error("invalid range");this._terminal.select(L.column,L.row,(A.row-L.row)*this._terminal.cols-L.column+A.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`}};u.AccessibilityManager=S=h([m(1,C.IInstantiationService),m(2,w.ICoreBrowserService),m(3,w.IRenderService)],S)},3614:(c,u)=>{function d(g){return g.replace(/\r?\n/g,"\r")}function h(g,x){return x?"\x1B[200~"+g+"\x1B[201~":g}function m(g,x,w,C){g=h(g=d(g),w.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(g,!0),x.value=""}function f(g,x,w){const C=w.getBoundingClientRect(),v=g.clientX-C.left-10,S=g.clientY-C.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${v}px`,x.style.top=`${S}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(u,"__esModule",{value:!0}),u.rightClickHandler=u.moveTextAreaUnderMouseCursor=u.paste=u.handlePasteEvent=u.copyHandler=u.bracketTextForPaste=u.prepareTextForTerminal=void 0,u.prepareTextForTerminal=d,u.bracketTextForPaste=h,u.copyHandler=function(g,x){g.clipboardData&&g.clipboardData.setData("text/plain",x.selectionText),g.preventDefault()},u.handlePasteEvent=function(g,x,w,C){g.stopPropagation(),g.clipboardData&&m(g.clipboardData.getData("text/plain"),x,w,C)},u.paste=m,u.moveTextAreaUnderMouseCursor=f,u.rightClickHandler=function(g,x,w,C,v){f(g,x,w),v&&C.rightClickSelect(g),x.value=C.selectionText,x.select()}},7239:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ColorContrastCache=void 0;const h=d(1505);u.ColorContrastCache=class{constructor(){this._color=new h.TwoKeyMap,this._css=new h.TwoKeyMap}setCss(m,f,g){this._css.set(m,f,g)}getCss(m,f){return this._css.get(m,f)}setColor(m,f,g){this._color.set(m,f,g)}getColor(m,f){return this._color.get(m,f)}clear(){this._color.clear(),this._css.clear()}}},3656:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.addDisposableDomListener=void 0,u.addDisposableDomListener=function(d,h,m,f){d.addEventListener(h,m,f);let g=!1;return{dispose:()=>{g||(g=!0,d.removeEventListener(h,m,f))}}}},3551:function(c,u,d){var h=this&&this.__decorate||function(S,_,b,k){var E,T=arguments.length,L=T<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,b):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(S,_,b,k);else for(var A=S.length-1;A>=0;A--)(E=S[A])&&(L=(T<3?E(L):T>3?E(_,b,L):E(_,b))||L);return T>3&&L&&Object.defineProperty(_,b,L),L},m=this&&this.__param||function(S,_){return function(b,k){_(b,k,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.Linkifier=void 0;const f=d(3656),g=d(8460),x=d(844),w=d(2585),C=d(4725);let v=u.Linkifier=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(S,_,b,k,E){super(),this._element=S,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 g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.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,f.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,f.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,f.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,f.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(S){this._lastMouseEvent=S;const _=this._positionFromMouseEvent(S,this._element,this._mouseService);if(!_)return;this._isMouseOut=!1;const b=S.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(S){if(this._activeLine!==S.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(S,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,S)||(this._clearCurrentLink(),this._askForLink(S,!0))}_askForLink(S,_){var k,E;this._activeProviderReplies&&_||((k=this._activeProviderReplies)==null||k.forEach((T=>{T==null||T.forEach((L=>{L.link.dispose&&L.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=S.y);let b=!1;for(const[T,L]of this._linkProviderService.linkProviders.entries())_?(E=this._activeProviderReplies)!=null&&E.get(T)&&(b=this._checkLinkProviderResult(T,S,b)):L.provideLinks(S.y,(A=>{var M,H;if(this._isMouseOut)return;const O=A==null?void 0:A.map((B=>({link:B})));(M=this._activeProviderReplies)==null||M.set(T,O),b=this._checkLinkProviderResult(T,S,b),((H=this._activeProviderReplies)==null?void 0:H.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(S.y,this._activeProviderReplies)}))}_removeIntersectingLinks(S,_){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 L=E[T],A=L.link.range.start.y<S?0:L.link.range.start.x,O=L.link.range.end.y>S?this._bufferService.cols:L.link.range.end.x;for(let M=A;M<=O;M++){if(b.has(M)){E.splice(T--,1);break}b.add(M)}}}}_checkLinkProviderResult(S,_,b){var T;if(!this._activeProviderReplies)return b;const k=this._activeProviderReplies.get(S);let E=!1;for(let L=0;L<S;L++)this._activeProviderReplies.has(L)&&!this._activeProviderReplies.get(L)||(E=!0);if(!E&&k){const L=k.find((A=>this._linkAtPosition(A.link,_)));L&&(b=!0,this._handleNewLink(L))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!b)for(let L=0;L<this._activeProviderReplies.size;L++){const A=(T=this._activeProviderReplies.get(L))==null?void 0:T.find((O=>this._linkAtPosition(O.link,_)));if(A){b=!0,this._handleNewLink(A);break}}return b}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(S){if(!this._currentLink)return;const _=this._positionFromMouseEvent(S,this._element,this._mouseService);_&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,_)&&this._currentLink.link.activate(S,this._currentLink.link.text)}_clearCurrentLink(S,_){this._currentLink&&this._lastMouseEvent&&(!S||!_||this._currentLink.link.range.start.y>=S&&this._currentLink.link.range.end.y<=_)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,x.disposeArray)(this._linkCacheDisposables))}_handleNewLink(S){if(!this._lastMouseEvent)return;const _=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);_&&this._linkAtPosition(S.link,_)&&(this._currentLink=S,this._currentLink.state={decorations:{underline:S.link.decorations===void 0||S.link.decorations.underline,pointerCursor:S.link.decorations===void 0||S.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,S.link,this._lastMouseEvent),S.link.decorations={},Object.defineProperties(S.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(S.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(S,_,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&&S.classList.add("xterm-cursor-pointer")),_.hover&&_.hover(b,_.text)}_fireUnderlineEvent(S,_){const b=S.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(S,_,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&&S.classList.remove("xterm-cursor-pointer")),_.leave&&_.leave(b,_.text)}_linkAtPosition(S,_){const b=S.range.start.y*this._bufferService.cols+S.range.start.x,k=S.range.end.y*this._bufferService.cols+S.range.end.x,E=_.y*this._bufferService.cols+_.x;return b<=E&&E<=k}_positionFromMouseEvent(S,_,b){const k=b.getCoords(S,_,this._bufferService.cols,this._bufferService.rows);if(k)return{x:k[0],y:k[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(S,_,b,k,E){return{x1:S,y1:_,x2:b,y2:k,cols:this._bufferService.cols,fg:E}}};u.Linkifier=v=h([m(1,C.IMouseService),m(2,C.IRenderService),m(3,w.IBufferService),m(4,C.ILinkProviderService)],v)},9042:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.tooMuchOutput=u.promptLabel=void 0,u.promptLabel="Terminal input",u.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(c,u,d){var h=this&&this.__decorate||function(C,v,S,_){var b,k=arguments.length,E=k<3?v:_===null?_=Object.getOwnPropertyDescriptor(v,S):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,v,S,_);else for(var T=C.length-1;T>=0;T--)(b=C[T])&&(E=(k<3?b(E):k>3?b(v,S,E):b(v,S))||E);return k>3&&E&&Object.defineProperty(v,S,E),E},m=this&&this.__param||function(C,v){return function(S,_){v(S,_,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OscLinkProvider=void 0;const f=d(511),g=d(2585);let x=u.OscLinkProvider=class{constructor(C,v,S){this._bufferService=C,this._optionsService=v,this._oscLinkService=S}provideLinks(C,v){var O;const S=this._bufferService.buffer.lines.get(C-1);if(!S)return void v(void 0);const _=[],b=this._optionsService.rawOptions.linkHandler,k=new f.CellData,E=S.getTrimmedLength();let T=-1,L=-1,A=!1;for(let M=0;M<E;M++)if(L!==-1||S.hasContent(M)){if(S.loadCell(M,k),k.hasExtendedAttrs()&&k.extended.urlId){if(L===-1){L=M,T=k.extended.urlId;continue}A=k.extended.urlId!==T}else L!==-1&&(A=!0);if(A||L!==-1&&M===E-1){const H=(O=this._oscLinkService.getLinkData(T))==null?void 0:O.uri;if(H){const B={start:{x:L+1,y:C},end:{x:M+(A||M!==E-1?0:1),y:C}};let F=!1;if(!(b!=null&&b.allowNonHttpProtocols))try{const K=new URL(H);["http:","https:"].includes(K.protocol)||(F=!0)}catch{F=!0}F||_.push({text:H,range:B,activate:(K,G)=>b?b.activate(K,G,B):w(0,G),hover:(K,G)=>{var V;return(V=b==null?void 0:b.hover)==null?void 0:V.call(b,K,G,B)},leave:(K,G)=>{var V;return(V=b==null?void 0:b.leave)==null?void 0:V.call(b,K,G,B)}})}A=!1,k.hasExtendedAttrs()&&k.extended.urlId?(L=M,T=k.extended.urlId):(L=-1,T=-1)}}v(_)}};function w(C,v){if(confirm(`Do you want to navigate to ${v}?
|
|
256
|
+
|
|
257
|
+
WARNING: This link could potentially be dangerous`)){const S=window.open();if(S){try{S.opener=null}catch{}S.location.href=v}else console.warn("Opening link blocked as opener could not be cleared")}}u.OscLinkProvider=x=h([m(0,g.IBufferService),m(1,g.IOptionsService),m(2,g.IOscLinkService)],x)},6193:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.RenderDebouncer=void 0,u.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,m){this._rowCount=m,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:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Terminal=void 0;const h=d(3614),m=d(3656),f=d(3551),g=d(9042),x=d(3730),w=d(1680),C=d(3107),v=d(5744),S=d(2950),_=d(1296),b=d(428),k=d(4269),E=d(5114),T=d(8934),L=d(3230),A=d(9312),O=d(4725),M=d(6731),H=d(8055),B=d(8969),F=d(8460),K=d(844),G=d(6114),V=d(8437),Z=d(2584),J=d(7399),z=d(5941),P=d(9074),D=d(2585),U=d(5435),$=d(4567),te=d(779);class q extends B.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(Y={}){super(Y),this.browser=G,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new K.MutableDisposable),this._onCursorMove=this.register(new F.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new F.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new F.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new F.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new F.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new F.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new F.EventEmitter),this._onBlur=this.register(new F.EventEmitter),this._onA11yCharEmitter=this.register(new F.EventEmitter),this._onA11yTabEmitter=this.register(new F.EventEmitter),this._onWillOpen=this.register(new F.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(P.DecorationService),this._instantiationService.setService(D.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(te.LinkProviderService),this._instantiationService.setService(O.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((I,Q)=>this.refresh(I,Q)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((I=>this._reportWindowsOptions(I)))),this.register(this._inputHandler.onColor((I=>this._handleColorEvent(I)))),this.register((0,F.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,F.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,F.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,F.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((I=>this._afterResize(I.cols,I.rows)))),this.register((0,K.toDisposable)((()=>{var I,Q;this._customKeyEventHandler=void 0,(Q=(I=this.element)==null?void 0:I.parentNode)==null||Q.removeChild(this.element)})))}_handleColorEvent(Y){if(this._themeService)for(const I of Y){let Q,ne="";switch(I.index){case 256:Q="foreground",ne="10";break;case 257:Q="background",ne="11";break;case 258:Q="cursor",ne="12";break;default:Q="ansi",ne="4;"+I.index}switch(I.type){case 0:const re=H.color.toColorRGB(Q==="ansi"?this._themeService.colors.ansi[I.index]:this._themeService.colors[Q]);this.coreService.triggerDataEvent(`${Z.C0.ESC}]${ne};${(0,z.toRgbString)(re)}${Z.C1_ESCAPED.ST}`);break;case 1:if(Q==="ansi")this._themeService.modifyColors((ie=>ie.ansi[I.index]=H.channels.toColor(...I.color)));else{const ie=Q;this._themeService.modifyColors((pe=>pe[ie]=H.channels.toColor(...I.color)))}break;case 2:this._themeService.restoreColor(I.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(Y){Y?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance($.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(Y){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Z.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var Y;return(Y=this.textarea)==null?void 0:Y.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 Y=this.buffer.ybase+this.buffer.y,I=this.buffer.lines.get(Y);if(!I)return;const Q=Math.min(this.buffer.x,this.cols-1),ne=this._renderService.dimensions.css.cell.height,re=I.getWidth(Q),ie=this._renderService.dimensions.css.cell.width*re,pe=this.buffer.y*this._renderService.dimensions.css.cell.height,ye=Q*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ye+"px",this.textarea.style.top=pe+"px",this.textarea.style.width=ie+"px",this.textarea.style.height=ne+"px",this.textarea.style.lineHeight=ne+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,m.addDisposableDomListener)(this.element,"copy",(I=>{this.hasSelection()&&(0,h.copyHandler)(I,this._selectionService)})));const Y=I=>(0,h.handlePasteEvent)(I,this.textarea,this.coreService,this.optionsService);this.register((0,m.addDisposableDomListener)(this.textarea,"paste",Y)),this.register((0,m.addDisposableDomListener)(this.element,"paste",Y)),G.isFirefox?this.register((0,m.addDisposableDomListener)(this.element,"mousedown",(I=>{I.button===2&&(0,h.rightClickHandler)(I,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,m.addDisposableDomListener)(this.element,"contextmenu",(I=>{(0,h.rightClickHandler)(I,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),G.isLinux&&this.register((0,m.addDisposableDomListener)(this.element,"auxclick",(I=>{I.button===1&&(0,h.moveTextAreaUnderMouseCursor)(I,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,m.addDisposableDomListener)(this.textarea,"keyup",(Y=>this._keyUp(Y)),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"keydown",(Y=>this._keyDown(Y)),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"keypress",(Y=>this._keyPress(Y)),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionupdate",(Y=>this._compositionHelper.compositionupdate(Y)))),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,m.addDisposableDomListener)(this.textarea,"input",(Y=>this._inputEvent(Y)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(Y){var Q;if(!Y)throw new Error("Terminal requires a parent element.");if(Y.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((Q=this.element)==null?void 0:Q.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=Y.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"),Y.appendChild(this.element);const I=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),I.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,m.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),I.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),G.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,Y.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(O.ICoreBrowserService,this._coreBrowserService),this.register((0,m.addDisposableDomListener)(this.textarea,"focus",(ne=>this._handleTextAreaFocus(ne)))),this.register((0,m.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(O.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(M.ThemeService),this._instantiationService.setService(O.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(k.CharacterJoinerService),this._instantiationService.setService(O.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(L.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(O.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(S.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(T.MouseService),this._instantiationService.setService(O.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(f.Linkifier,this.screenElement)),this.element.appendChild(I);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(w.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(A.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(O.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,m.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(C.BufferDecorationRenderer,this.screenElement)),this.register((0,m.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 Y=this,I=this.element;function Q(ie){const pe=Y._mouseService.getMouseReportCoords(ie,Y.screenElement);if(!pe)return!1;let ye,Ie;switch(ie.overrideType||ie.type){case"mousemove":Ie=32,ie.buttons===void 0?(ye=3,ie.button!==void 0&&(ye=ie.button<3?ie.button:3)):ye=1&ie.buttons?0:4&ie.buttons?1:2&ie.buttons?2:3;break;case"mouseup":Ie=0,ye=ie.button<3?ie.button:3;break;case"mousedown":Ie=1,ye=ie.button<3?ie.button:3;break;case"wheel":if(Y._customWheelEventHandler&&Y._customWheelEventHandler(ie)===!1||Y.viewport.getLinesScrolled(ie)===0)return!1;Ie=ie.deltaY<0?0:1,ye=4;break;default:return!1}return!(Ie===void 0||ye===void 0||ye>4)&&Y.coreMouseService.triggerMouseEvent({col:pe.col,row:pe.row,x:pe.x,y:pe.y,button:ye,action:Ie,ctrl:ie.ctrlKey,alt:ie.altKey,shift:ie.shiftKey})}const ne={mouseup:null,wheel:null,mousedrag:null,mousemove:null},re={mouseup:ie=>(Q(ie),ie.buttons||(this._document.removeEventListener("mouseup",ne.mouseup),ne.mousedrag&&this._document.removeEventListener("mousemove",ne.mousedrag)),this.cancel(ie)),wheel:ie=>(Q(ie),this.cancel(ie,!0)),mousedrag:ie=>{ie.buttons&&Q(ie)},mousemove:ie=>{ie.buttons||Q(ie)}};this.register(this.coreMouseService.onProtocolChange((ie=>{ie?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(ie)),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&ie?ne.mousemove||(I.addEventListener("mousemove",re.mousemove),ne.mousemove=re.mousemove):(I.removeEventListener("mousemove",ne.mousemove),ne.mousemove=null),16&ie?ne.wheel||(I.addEventListener("wheel",re.wheel,{passive:!1}),ne.wheel=re.wheel):(I.removeEventListener("wheel",ne.wheel),ne.wheel=null),2&ie?ne.mouseup||(ne.mouseup=re.mouseup):(this._document.removeEventListener("mouseup",ne.mouseup),ne.mouseup=null),4&ie?ne.mousedrag||(ne.mousedrag=re.mousedrag):(this._document.removeEventListener("mousemove",ne.mousedrag),ne.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,m.addDisposableDomListener)(I,"mousedown",(ie=>{if(ie.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(ie))return Q(ie),ne.mouseup&&this._document.addEventListener("mouseup",ne.mouseup),ne.mousedrag&&this._document.addEventListener("mousemove",ne.mousedrag),this.cancel(ie)}))),this.register((0,m.addDisposableDomListener)(I,"wheel",(ie=>{if(!ne.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(ie)===!1)return!1;if(!this.buffer.hasScrollback){const pe=this.viewport.getLinesScrolled(ie);if(pe===0)return;const ye=Z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(ie.deltaY<0?"A":"B");let Ie="";for(let $e=0;$e<Math.abs(pe);$e++)Ie+=ye;return this.coreService.triggerDataEvent(Ie,!0),this.cancel(ie,!0)}return this.viewport.handleWheel(ie)?this.cancel(ie):void 0}}),{passive:!1})),this.register((0,m.addDisposableDomListener)(I,"touchstart",(ie=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(ie),this.cancel(ie)}),{passive:!0})),this.register((0,m.addDisposableDomListener)(I,"touchmove",(ie=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(ie)?void 0:this.cancel(ie)}),{passive:!1}))}refresh(Y,I){var Q;(Q=this._renderService)==null||Q.refreshRows(Y,I)}updateCursorStyle(Y){var I;(I=this._selectionService)!=null&&I.shouldColumnSelect(Y)?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(Y,I,Q=0){var ne;Q===1?(super.scrollLines(Y,I,Q),this.refresh(0,this.rows-1)):(ne=this.viewport)==null||ne.scrollLines(Y)}paste(Y){(0,h.paste)(Y,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(Y){this._customKeyEventHandler=Y}attachCustomWheelEventHandler(Y){this._customWheelEventHandler=Y}registerLinkProvider(Y){return this._linkProviderService.registerLinkProvider(Y)}registerCharacterJoiner(Y){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const I=this._characterJoinerService.register(Y);return this.refresh(0,this.rows-1),I}deregisterCharacterJoiner(Y){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(Y)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(Y){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+Y)}registerDecoration(Y){return this._decorationService.registerDecoration(Y)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(Y,I,Q){this._selectionService.setSelection(Y,I,Q)}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 Y;(Y=this._selectionService)==null||Y.clearSelection()}selectAll(){var Y;(Y=this._selectionService)==null||Y.selectAll()}selectLines(Y,I){var Q;(Q=this._selectionService)==null||Q.selectLines(Y,I)}_keyDown(Y){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(Y)===!1)return!1;const I=this.browser.isMac&&this.options.macOptionIsMeta&&Y.altKey;if(!I&&!this._compositionHelper.keydown(Y))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;I||Y.key!=="Dead"&&Y.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const Q=(0,J.evaluateKeyboardEvent)(Y,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(Y),Q.type===3||Q.type===2){const ne=this.rows-1;return this.scrollLines(Q.type===2?-ne:ne),this.cancel(Y,!0)}return Q.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,Y)||(Q.cancel&&this.cancel(Y,!0),!Q.key||!!(Y.key&&!Y.ctrlKey&&!Y.altKey&&!Y.metaKey&&Y.key.length===1&&Y.key.charCodeAt(0)>=65&&Y.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(Q.key!==Z.C0.ETX&&Q.key!==Z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:Q.key,domEvent:Y}),this._showCursor(),this.coreService.triggerDataEvent(Q.key,!0),!this.optionsService.rawOptions.screenReaderMode||Y.altKey||Y.ctrlKey?this.cancel(Y,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(Y,I){const Q=Y.isMac&&!this.options.macOptionIsMeta&&I.altKey&&!I.ctrlKey&&!I.metaKey||Y.isWindows&&I.altKey&&I.ctrlKey&&!I.metaKey||Y.isWindows&&I.getModifierState("AltGraph");return I.type==="keypress"?Q:Q&&(!I.keyCode||I.keyCode>47)}_keyUp(Y){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(Y)===!1||((function(I){return I.keyCode===16||I.keyCode===17||I.keyCode===18})(Y)||this.focus(),this.updateCursorStyle(Y),this._keyPressHandled=!1)}_keyPress(Y){let I;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(Y)===!1)return!1;if(this.cancel(Y),Y.charCode)I=Y.charCode;else if(Y.which===null||Y.which===void 0)I=Y.keyCode;else{if(Y.which===0||Y.charCode===0)return!1;I=Y.which}return!(!I||(Y.altKey||Y.ctrlKey||Y.metaKey)&&!this._isThirdLevelShift(this.browser,Y)||(I=String.fromCharCode(I),this._onKey.fire({key:I,domEvent:Y}),this._showCursor(),this.coreService.triggerDataEvent(I,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(Y){if(Y.data&&Y.inputType==="insertText"&&(!Y.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const I=Y.data;return this.coreService.triggerDataEvent(I,!0),this.cancel(Y),!0}return!1}resize(Y,I){Y!==this.cols||I!==this.rows?super.resize(Y,I):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(Y,I){var Q,ne;(Q=this._charSizeService)==null||Q.measure(),(ne=this.viewport)==null||ne.syncScrollArea(!0)}clear(){var Y;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 I=1;I<this.rows;I++)this.buffer.lines.push(this.buffer.getBlankLine(V.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(Y=this.viewport)==null||Y.reset(),this.refresh(0,this.rows-1)}}reset(){var I,Q;this.options.rows=this.rows,this.options.cols=this.cols;const Y=this._customKeyEventHandler;this._setup(),super.reset(),(I=this._selectionService)==null||I.reset(),this._decorationService.reset(),(Q=this.viewport)==null||Q.reset(),this._customKeyEventHandler=Y,this.refresh(0,this.rows-1)}clearTextureAtlas(){var Y;(Y=this._renderService)==null||Y.clearTextureAtlas()}_reportFocus(){var Y;(Y=this.element)!=null&&Y.classList.contains("focus")?this.coreService.triggerDataEvent(Z.C0.ESC+"[I"):this.coreService.triggerDataEvent(Z.C0.ESC+"[O")}_reportWindowsOptions(Y){if(this._renderService)switch(Y){case U.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const I=this._renderService.dimensions.css.canvas.width.toFixed(0),Q=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Z.C0.ESC}[4;${Q};${I}t`);break;case U.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const ne=this._renderService.dimensions.css.cell.width.toFixed(0),re=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Z.C0.ESC}[6;${re};${ne}t`)}}cancel(Y,I){if(this.options.cancelEvents||I)return Y.preventDefault(),Y.stopPropagation(),!1}}u.Terminal=q},9924:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.TimeBasedDebouncer=void 0,u.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,m){this._rowCount=m,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 f=Date.now();if(f-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=f,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=f-this._lastRefreshMs,x=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),x)}}_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(c,u,d){var h=this&&this.__decorate||function(S,_,b,k){var E,T=arguments.length,L=T<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,b):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(S,_,b,k);else for(var A=S.length-1;A>=0;A--)(E=S[A])&&(L=(T<3?E(L):T>3?E(_,b,L):E(_,b))||L);return T>3&&L&&Object.defineProperty(_,b,L),L},m=this&&this.__param||function(S,_){return function(b,k){_(b,k,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.Viewport=void 0;const f=d(3656),g=d(4725),x=d(8460),w=d(844),C=d(2585);let v=u.Viewport=class extends w.Disposable{constructor(S,_,b,k,E,T,L,A){super(),this._viewportElement=S,this._scrollArea=_,this._bufferService=b,this._optionsService=k,this._charSizeService=E,this._renderService=T,this._coreBrowserService=L,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 x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((O=>this._activeBuffer=O.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((O=>this._renderDimensions=O))),this._handleThemeChange(A.colors),this.register(A.onChangeColors((O=>this._handleThemeChange(O)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(S){this._viewportElement.style.backgroundColor=S.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(S){if(S)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 S=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==S&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=S),this._refreshAnimationFrame=null}syncScrollArea(S=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(S);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(S)}_handleScroll(S){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 S=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(S*(this._smoothScrollState.target-this._smoothScrollState.origin)),S<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(S,_){const b=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(_<0&&this._viewportElement.scrollTop!==0||_>0&&b<this._lastRecordedBufferHeight)||(S.cancelable&&S.preventDefault(),!1)}handleWheel(S){const _=this._getPixelsScrolled(S);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(S,_))}scrollLines(S){if(S!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const _=S*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:S,suppressScrollEvent:!1})}_getPixelsScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let _=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_LINE?_*=this._currentRowHeight:S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(_*=this._currentRowHeight*this._bufferService.rows),_}getBufferElements(S,_){var A;let b,k="";const E=[],T=_??this._bufferService.buffer.lines.length,L=this._bufferService.buffer.lines;for(let O=S;O<T;O++){const M=L.get(O);if(!M)continue;const H=(A=L.get(O+1))==null?void 0:A.isWrapped;if(k+=M.translateToString(!H),!H||O===L.length-1){const B=document.createElement("div");B.textContent=k,E.push(B),k.length>0&&(b=B),k=""}}return{bufferElements:E,cursorElement:b}}getLinesScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let _=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(_/=this._currentRowHeight+0,this._wheelPartialScroll+=_,_=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(_*=this._bufferService.rows),_}_applyScrollModifier(S,_){const b=this._optionsService.rawOptions.fastScrollModifier;return b==="alt"&&_.altKey||b==="ctrl"&&_.ctrlKey||b==="shift"&&_.shiftKey?S*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:S*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(S){this._lastTouchY=S.touches[0].pageY}handleTouchMove(S){const _=this._lastTouchY-S.touches[0].pageY;return this._lastTouchY=S.touches[0].pageY,_!==0&&(this._viewportElement.scrollTop+=_,this._bubbleScroll(S,_))}};u.Viewport=v=h([m(2,C.IBufferService),m(3,C.IOptionsService),m(4,g.ICharSizeService),m(5,g.IRenderService),m(6,g.ICoreBrowserService),m(7,g.IThemeService)],v)},3107:function(c,u,d){var h=this&&this.__decorate||function(C,v,S,_){var b,k=arguments.length,E=k<3?v:_===null?_=Object.getOwnPropertyDescriptor(v,S):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,v,S,_);else for(var T=C.length-1;T>=0;T--)(b=C[T])&&(E=(k<3?b(E):k>3?b(v,S,E):b(v,S))||E);return k>3&&E&&Object.defineProperty(v,S,E),E},m=this&&this.__param||function(C,v){return function(S,_){v(S,_,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.BufferDecorationRenderer=void 0;const f=d(4725),g=d(844),x=d(2585);let w=u.BufferDecorationRenderer=class extends g.Disposable{constructor(C,v,S,_,b){super(),this._screenElement=C,this._bufferService=v,this._coreBrowserService=S,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,g.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 S=C.options.x??0;return S&&S>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 S=this._decorationElements.get(C);S||(S=this._createElement(C),C.element=S,this._decorationElements.set(C,S),this._container.appendChild(S),C.onDispose((()=>{this._decorationElements.delete(C),S.remove()}))),S.style.top=v*this._renderService.dimensions.css.cell.height+"px",S.style.display=this._altBufferIsActive?"none":"block",C.onRenderEmitter.fire(S)}}_refreshXPosition(C,v=C.element){if(!v)return;const S=C.options.x??0;(C.options.anchor||"left")==="right"?v.style.right=S?S*this._renderService.dimensions.css.cell.width+"px":"":v.style.left=S?S*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()}};u.BufferDecorationRenderer=w=h([m(1,x.IBufferService),m(2,f.ICoreBrowserService),m(3,x.IDecorationService),m(4,f.IRenderService)],w)},5871:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ColorZoneStore=void 0,u.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,m){return h>=d.startBufferLine-this._linePadding[m||"full"]&&h<=d.endBufferLine+this._linePadding[m||"full"]}_addLineToZone(d,h){d.startBufferLine=Math.min(d.startBufferLine,h),d.endBufferLine=Math.max(d.endBufferLine,h)}}},5744:function(c,u,d){var h=this&&this.__decorate||function(b,k,E,T){var L,A=arguments.length,O=A<3?k:T===null?T=Object.getOwnPropertyDescriptor(k,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(b,k,E,T);else for(var M=b.length-1;M>=0;M--)(L=b[M])&&(O=(A<3?L(O):A>3?L(k,E,O):L(k,E))||O);return A>3&&O&&Object.defineProperty(k,E,O),O},m=this&&this.__param||function(b,k){return function(E,T){k(E,T,b)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OverviewRulerRenderer=void 0;const f=d(5871),g=d(4725),x=d(844),w=d(2585),C={full:0,left:0,center:0,right:0},v={full:0,left:0,center:0,right:0},S={full:0,left:0,center:0,right:0};let _=u.OverviewRulerRenderer=class extends x.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,k,E,T,L,A,O){var H;super(),this._viewportElement=b,this._screenElement=k,this._bufferService=E,this._decorationService=T,this._renderService=L,this._optionsService=A,this._coreBrowserService=O,this._colorZoneStore=new f.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(),(H=this._viewportElement.parentElement)==null||H.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,x.toDisposable)((()=>{var B;(B=this._canvas)==null||B.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(),S.full=0,S.left=0,S.center=v.left,S.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(S[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})))}};u.OverviewRulerRenderer=_=h([m(2,w.IBufferService),m(3,w.IDecorationService),m(4,g.IRenderService),m(5,w.IOptionsService),m(6,g.ICoreBrowserService)],_)},2950:function(c,u,d){var h=this&&this.__decorate||function(C,v,S,_){var b,k=arguments.length,E=k<3?v:_===null?_=Object.getOwnPropertyDescriptor(v,S):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(C,v,S,_);else for(var T=C.length-1;T>=0;T--)(b=C[T])&&(E=(k<3?b(E):k>3?b(v,S,E):b(v,S))||E);return k>3&&E&&Object.defineProperty(v,S,E),E},m=this&&this.__param||function(C,v){return function(S,_){v(S,_,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CompositionHelper=void 0;const f=d(4725),g=d(2585),x=d(2584);let w=u.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(C,v,S,_,b,k){this._textarea=C,this._compositionView=v,this._bufferService=S,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 S;this._isSendingComposition=!1,v.start+=this._dataAlreadySent.length,S=this._isComposing?this._textarea.value.substring(v.start,v.end):this._textarea.value.substring(v.start),S.length>0&&this._coreService.triggerDataEvent(S,!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,S=v.replace(C,"");this._dataAlreadySent=S,v.length>C.length?this._coreService.triggerDataEvent(S,!0):v.length<C.length?this._coreService.triggerDataEvent(`${x.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),S=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=S+"px",this._compositionView.style.lineHeight=S+"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)}}};u.CompositionHelper=w=h([m(2,g.IBufferService),m(3,g.IOptionsService),m(4,g.ICoreService),m(5,f.IRenderService)],w)},9806:(c,u)=>{function d(h,m,f){const g=f.getBoundingClientRect(),x=h.getComputedStyle(f),w=parseInt(x.getPropertyValue("padding-left")),C=parseInt(x.getPropertyValue("padding-top"));return[m.clientX-g.left-w,m.clientY-g.top-C]}Object.defineProperty(u,"__esModule",{value:!0}),u.getCoords=u.getCoordsRelativeToElement=void 0,u.getCoordsRelativeToElement=d,u.getCoords=function(h,m,f,g,x,w,C,v,S){if(!w)return;const _=d(h,m,f);return _?(_[0]=Math.ceil((_[0]+(S?C/2:0))/C),_[1]=Math.ceil(_[1]/v),_[0]=Math.min(Math.max(_[0],1),g+(S?1:0)),_[1]=Math.min(Math.max(_[1],1),x),_):void 0}},9504:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.moveToCellSequence=void 0;const h=d(2584);function m(v,S,_,b){const k=v-f(v,_),E=S-f(S,_),T=Math.abs(k-E)-(function(L,A,O){let M=0;const H=L-f(L,O),B=A-f(A,O);for(let F=0;F<Math.abs(H-B);F++){const K=g(L,A)==="A"?-1:1,G=O.buffer.lines.get(H+K*F);G!=null&&G.isWrapped&&M++}return M})(v,S,_);return C(T,w(g(v,S),b))}function f(v,S){let _=0,b=S.buffer.lines.get(v),k=b==null?void 0:b.isWrapped;for(;k&&v>=0&&v<S.rows;)_++,b=S.buffer.lines.get(--v),k=b==null?void 0:b.isWrapped;return _}function g(v,S){return v>S?"A":"B"}function x(v,S,_,b,k,E){let T=v,L=S,A="";for(;T!==_||L!==b;)T+=k?1:-1,k&&T>E.cols-1?(A+=E.buffer.translateBufferLineToString(L,!1,v,T),T=0,v=0,L++):!k&&T<0&&(A+=E.buffer.translateBufferLineToString(L,!1,0,v+1),T=E.cols-1,v=T,L--);return A+E.buffer.translateBufferLineToString(L,!1,v,T)}function w(v,S){const _=S?"O":"[";return h.C0.ESC+_+v}function C(v,S){v=Math.floor(v);let _="";for(let b=0;b<v;b++)_+=S;return _}u.moveToCellSequence=function(v,S,_,b){const k=_.buffer.x,E=_.buffer.y;if(!_.buffer.hasScrollback)return(function(A,O,M,H,B,F){return m(O,H,B,F).length===0?"":C(x(A,O,A,O-f(O,B),!1,B).length,w("D",F))})(k,E,0,S,_,b)+m(E,S,_,b)+(function(A,O,M,H,B,F){let K;K=m(O,H,B,F).length>0?H-f(H,B):O;const G=H,V=(function(Z,J,z,P,D,U){let $;return $=m(z,P,D,U).length>0?P-f(P,D):J,Z<z&&$<=P||Z>=z&&$<P?"C":"D"})(A,O,M,H,B,F);return C(x(A,K,M,G,V==="C",B).length,w(V,F))})(k,E,v,S,_,b);let T;if(E===S)return T=k>v?"D":"C",C(Math.abs(k-v),w(T,b));T=E>S?"D":"C";const L=Math.abs(E-S);return C((function(A,O){return O.cols-A})(E>S?v:k,_)+(L-1)*_.cols+1+((E>S?k:v)-1),w(T,b))}},1296:function(c,u,d){var h=this&&this.__decorate||function(F,K,G,V){var Z,J=arguments.length,z=J<3?K:V===null?V=Object.getOwnPropertyDescriptor(K,G):V;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")z=Reflect.decorate(F,K,G,V);else for(var P=F.length-1;P>=0;P--)(Z=F[P])&&(z=(J<3?Z(z):J>3?Z(K,G,z):Z(K,G))||z);return J>3&&z&&Object.defineProperty(K,G,z),z},m=this&&this.__param||function(F,K){return function(G,V){K(G,V,F)}};Object.defineProperty(u,"__esModule",{value:!0}),u.DomRenderer=void 0;const f=d(3787),g=d(2550),x=d(2223),w=d(6171),C=d(6052),v=d(4725),S=d(8055),_=d(8460),b=d(844),k=d(2585),E="xterm-dom-renderer-owner-",T="xterm-rows",L="xterm-fg-",A="xterm-bg-",O="xterm-focus",M="xterm-selection";let H=1,B=u.DomRenderer=class extends b.Disposable{constructor(F,K,G,V,Z,J,z,P,D,U,$,te,q){super(),this._terminal=F,this._document=K,this._element=G,this._screenElement=V,this._viewportElement=Z,this._helperContainer=J,this._linkifier2=z,this._charSizeService=D,this._optionsService=U,this._bufferService=$,this._coreBrowserService=te,this._themeService=q,this._terminalClass=H++,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,w.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=P.createInstance(f.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 g.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 F=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*F,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*F),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/F),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/F),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 G of this._rowElements)G.style.width=`${this.dimensions.css.canvas.width}px`,G.style.height=`${this.dimensions.css.cell.height}px`,G.style.lineHeight=`${this.dimensions.css.cell.height}px`,G.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const K=`${this._terminalSelector} .${T} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=K,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(F){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let K=`${this._terminalSelector} .${T} { color: ${F.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;K+=`${this._terminalSelector} .${T} .xterm-dim { color: ${S.color.multiplyOpacity(F.foreground,.5).css};}`,K+=`${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 G=`blink_underline_${this._terminalClass}`,V=`blink_bar_${this._terminalClass}`,Z=`blink_block_${this._terminalClass}`;K+=`@keyframes ${G} { 50% { border-bottom-style: hidden; }}`,K+=`@keyframes ${V} { 50% { box-shadow: none; }}`,K+=`@keyframes ${Z} { 0% { background-color: ${F.cursor.css}; color: ${F.cursorAccent.css}; } 50% { background-color: inherit; color: ${F.cursor.css}; }}`,K+=`${this._terminalSelector} .${T}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${G} 1s step-end infinite;}${this._terminalSelector} .${T}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${V} 1s step-end infinite;}${this._terminalSelector} .${T}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${Z} 1s step-end infinite;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block { background-color: ${F.cursor.css}; color: ${F.cursorAccent.css};}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${F.cursor.css} !important; color: ${F.cursorAccent.css} !important;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${F.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${F.cursor.css} inset;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${F.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,K+=`${this._terminalSelector} .${M} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${M} div { position: absolute; background-color: ${F.selectionBackgroundOpaque.css};}${this._terminalSelector} .${M} div { position: absolute; background-color: ${F.selectionInactiveBackgroundOpaque.css};}`;for(const[J,z]of F.ansi.entries())K+=`${this._terminalSelector} .${L}${J} { color: ${z.css}; }${this._terminalSelector} .${L}${J}.xterm-dim { color: ${S.color.multiplyOpacity(z,.5).css}; }${this._terminalSelector} .${A}${J} { background-color: ${z.css}; }`;K+=`${this._terminalSelector} .${L}${x.INVERTED_DEFAULT_COLOR} { color: ${S.color.opaque(F.background).css}; }${this._terminalSelector} .${L}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${S.color.multiplyOpacity(S.color.opaque(F.background),.5).css}; }${this._terminalSelector} .${A}${x.INVERTED_DEFAULT_COLOR} { background-color: ${F.foreground.css}; }`,this._themeStyleElement.textContent=K}_setDefaultSpacing(){const F=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${F}px`,this._rowFactory.defaultSpacing=F}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(F,K){for(let G=this._rowElements.length;G<=K;G++){const V=this._document.createElement("div");this._rowContainer.appendChild(V),this._rowElements.push(V)}for(;this._rowElements.length>K;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(F,K){this._refreshRowElements(F,K),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(O),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(O),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(F,K,G){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(F,K,G),this.renderRows(0,this._bufferService.rows-1),!F||!K)return;this._selectionRenderModel.update(this._terminal,F,K,G);const V=this._selectionRenderModel.viewportStartRow,Z=this._selectionRenderModel.viewportEndRow,J=this._selectionRenderModel.viewportCappedStartRow,z=this._selectionRenderModel.viewportCappedEndRow;if(J>=this._bufferService.rows||z<0)return;const P=this._document.createDocumentFragment();if(G){const D=F[0]>K[0];P.appendChild(this._createSelectionElement(J,D?K[0]:F[0],D?F[0]:K[0],z-J+1))}else{const D=V===J?F[0]:0,U=J===Z?K[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(J,D,U));const $=z-J-1;if(P.appendChild(this._createSelectionElement(J+1,0,this._bufferService.cols,$)),J!==z){const te=Z===z?K[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(z,0,te))}}this._selectionContainer.appendChild(P)}_createSelectionElement(F,K,G,V=1){const Z=this._document.createElement("div"),J=K*this.dimensions.css.cell.width;let z=this.dimensions.css.cell.width*(G-K);return J+z>this.dimensions.css.canvas.width&&(z=this.dimensions.css.canvas.width-J),Z.style.height=V*this.dimensions.css.cell.height+"px",Z.style.top=F*this.dimensions.css.cell.height+"px",Z.style.left=`${J}px`,Z.style.width=`${z}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 F of this._rowElements)F.replaceChildren()}renderRows(F,K){const G=this._bufferService.buffer,V=G.ybase+G.y,Z=Math.min(G.x,this._bufferService.cols-1),J=this._optionsService.rawOptions.cursorBlink,z=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let D=F;D<=K;D++){const U=D+G.ydisp,$=this._rowElements[D],te=G.lines.get(U);if(!$||!te)break;$.replaceChildren(...this._rowFactory.createRow(te,U,U===V,z,P,Z,J,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${E}${this._terminalClass}`}_handleLinkHover(F){this._setCellUnderline(F.x1,F.x2,F.y1,F.y2,F.cols,!0)}_handleLinkLeave(F){this._setCellUnderline(F.x1,F.x2,F.y1,F.y2,F.cols,!1)}_setCellUnderline(F,K,G,V,Z,J){G<0&&(F=0),V<0&&(K=0);const z=this._bufferService.rows-1;G=Math.max(Math.min(G,z),0),V=Math.max(Math.min(V,z),0),Z=Math.min(Z,this._bufferService.cols);const P=this._bufferService.buffer,D=P.ybase+P.y,U=Math.min(P.x,Z-1),$=this._optionsService.rawOptions.cursorBlink,te=this._optionsService.rawOptions.cursorStyle,q=this._optionsService.rawOptions.cursorInactiveStyle;for(let X=G;X<=V;++X){const Y=X+P.ydisp,I=this._rowElements[X],Q=P.lines.get(Y);if(!I||!Q)break;I.replaceChildren(...this._rowFactory.createRow(Q,Y,Y===D,te,q,U,$,this.dimensions.css.cell.width,this._widthCache,J?X===G?F:0:-1,J?(X===V?K:Z)-1:-1))}}};u.DomRenderer=B=h([m(7,k.IInstantiationService),m(8,v.ICharSizeService),m(9,k.IOptionsService),m(10,k.IBufferService),m(11,v.ICoreBrowserService),m(12,v.IThemeService)],B)},3787:function(c,u,d){var h=this&&this.__decorate||function(T,L,A,O){var M,H=arguments.length,B=H<3?L:O===null?O=Object.getOwnPropertyDescriptor(L,A):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(T,L,A,O);else for(var F=T.length-1;F>=0;F--)(M=T[F])&&(B=(H<3?M(B):H>3?M(L,A,B):M(L,A))||B);return H>3&&B&&Object.defineProperty(L,A,B),B},m=this&&this.__param||function(T,L){return function(A,O){L(A,O,T)}};Object.defineProperty(u,"__esModule",{value:!0}),u.DomRendererRowFactory=void 0;const f=d(2223),g=d(643),x=d(511),w=d(2585),C=d(8055),v=d(4725),S=d(4269),_=d(6171),b=d(3734);let k=u.DomRendererRowFactory=class{constructor(T,L,A,O,M,H,B){this._document=T,this._characterJoinerService=L,this._optionsService=A,this._coreBrowserService=O,this._coreService=M,this._decorationService=H,this._themeService=B,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(T,L,A){this._selectionStart=T,this._selectionEnd=L,this._columnSelectMode=A}createRow(T,L,A,O,M,H,B,F,K,G,V){const Z=[],J=this._characterJoinerService.getJoinedCharacters(L),z=this._themeService.colors;let P,D=T.getNoBgTrimmedLength();A&&D<H+1&&(D=H+1);let U=0,$="",te=0,q=0,X=0,Y=!1,I=0,Q=!1,ne=0;const re=[],ie=G!==-1&&V!==-1;for(let pe=0;pe<D;pe++){T.loadCell(pe,this._workCell);let ye=this._workCell.getWidth();if(ye===0)continue;let Ie=!1,$e=pe,Se=this._workCell;if(J.length>0&&pe===J[0][0]){Ie=!0;const Ze=J.shift();Se=new S.JoinedCellData(this._workCell,T.translateToString(!0,Ze[0],Ze[1]),Ze[1]-Ze[0]),$e=Ze[1]-1,ye=Se.getWidth()}const Ge=this._isCellInSelection(pe,L),Je=A&&pe===H,_e=ie&&pe>=G&&pe<=V;let ge=!1;this._decorationService.forEachDecorationAtCell(pe,L,void 0,(Ze=>{ge=!0}));let he=Se.getChars()||g.WHITESPACE_CELL_CHAR;if(he===" "&&(Se.isUnderline()||Se.isOverline())&&(he=" "),ne=ye*F-K.get(he,Se.isBold(),Se.isItalic()),P){if(U&&(Ge&&Q||!Ge&&!Q&&Se.bg===te)&&(Ge&&Q&&z.selectionForeground||Se.fg===q)&&Se.extended.ext===X&&_e===Y&&ne===I&&!Je&&!Ie&&!ge){Se.isInvisible()?$+=g.WHITESPACE_CELL_CHAR:$+=he,U++;continue}U&&(P.textContent=$),P=this._document.createElement("span"),U=0,$=""}else P=this._document.createElement("span");if(te=Se.bg,q=Se.fg,X=Se.extended.ext,Y=_e,I=ne,Q=Ge,Ie&&H>=pe&&H<=$e&&(H=pe),!this._coreService.isCursorHidden&&Je&&this._coreService.isCursorInitialized){if(re.push("xterm-cursor"),this._coreBrowserService.isFocused)B&&re.push("xterm-cursor-blink"),re.push(O==="bar"?"xterm-cursor-bar":O==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(M)switch(M){case"outline":re.push("xterm-cursor-outline");break;case"block":re.push("xterm-cursor-block");break;case"bar":re.push("xterm-cursor-bar");break;case"underline":re.push("xterm-cursor-underline")}}if(Se.isBold()&&re.push("xterm-bold"),Se.isItalic()&&re.push("xterm-italic"),Se.isDim()&&re.push("xterm-dim"),$=Se.isInvisible()?g.WHITESPACE_CELL_CHAR:Se.getChars()||g.WHITESPACE_CELL_CHAR,Se.isUnderline()&&(re.push(`xterm-underline-${Se.extended.underlineStyle}`),$===" "&&($=" "),!Se.isUnderlineColorDefault()))if(Se.isUnderlineColorRGB())P.style.textDecorationColor=`rgb(${b.AttributeData.toColorRGB(Se.getUnderlineColor()).join(",")})`;else{let Ze=Se.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&Se.isBold()&&Ze<8&&(Ze+=8),P.style.textDecorationColor=z.ansi[Ze].css}Se.isOverline()&&(re.push("xterm-overline"),$===" "&&($=" ")),Se.isStrikethrough()&&re.push("xterm-strikethrough"),_e&&(P.style.textDecoration="underline");let ae=Se.getFgColor(),Pe=Se.getFgColorMode(),Ue=Se.getBgColor(),de=Se.getBgColorMode();const Ae=!!Se.isInverse();if(Ae){const Ze=ae;ae=Ue,Ue=Ze;const lt=Pe;Pe=de,de=lt}let ue,Fe,Xe,it=!1;switch(this._decorationService.forEachDecorationAtCell(pe,L,void 0,(Ze=>{Ze.options.layer!=="top"&&it||(Ze.backgroundColorRGB&&(de=50331648,Ue=Ze.backgroundColorRGB.rgba>>8&16777215,ue=Ze.backgroundColorRGB),Ze.foregroundColorRGB&&(Pe=50331648,ae=Ze.foregroundColorRGB.rgba>>8&16777215,Fe=Ze.foregroundColorRGB),it=Ze.options.layer==="top")})),!it&&Ge&&(ue=this._coreBrowserService.isFocused?z.selectionBackgroundOpaque:z.selectionInactiveBackgroundOpaque,Ue=ue.rgba>>8&16777215,de=50331648,it=!0,z.selectionForeground&&(Pe=50331648,ae=z.selectionForeground.rgba>>8&16777215,Fe=z.selectionForeground)),it&&re.push("xterm-decoration-top"),de){case 16777216:case 33554432:Xe=z.ansi[Ue],re.push(`xterm-bg-${Ue}`);break;case 50331648:Xe=C.channels.toColor(Ue>>16,Ue>>8&255,255&Ue),this._addStyle(P,`background-color:#${E((Ue>>>0).toString(16),"0",6)}`);break;default:Ae?(Xe=z.foreground,re.push(`xterm-bg-${f.INVERTED_DEFAULT_COLOR}`)):Xe=z.background}switch(ue||Se.isDim()&&(ue=C.color.multiplyOpacity(Xe,.5)),Pe){case 16777216:case 33554432:Se.isBold()&&ae<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ae+=8),this._applyMinimumContrast(P,Xe,z.ansi[ae],Se,ue,void 0)||re.push(`xterm-fg-${ae}`);break;case 50331648:const Ze=C.channels.toColor(ae>>16&255,ae>>8&255,255&ae);this._applyMinimumContrast(P,Xe,Ze,Se,ue,Fe)||this._addStyle(P,`color:#${E(ae.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(P,Xe,z.foreground,Se,ue,Fe)||Ae&&re.push(`xterm-fg-${f.INVERTED_DEFAULT_COLOR}`)}re.length&&(P.className=re.join(" "),re.length=0),Je||Ie||ge?P.textContent=$:U++,ne!==this.defaultSpacing&&(P.style.letterSpacing=`${ne}px`),Z.push(P),pe=$e}return P&&U&&(P.textContent=$),Z}_applyMinimumContrast(T,L,A,O,M,H){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,_.treatGlyphAsBackgroundColor)(O.getCode()))return!1;const B=this._getContrastCache(O);let F;if(M||H||(F=B.getColor(L.rgba,A.rgba)),F===void 0){const K=this._optionsService.rawOptions.minimumContrastRatio/(O.isDim()?2:1);F=C.color.ensureContrastRatio(M||L,H||A,K),B.setColor((M||L).rgba,(H||A).rgba,F??null)}return!!F&&(this._addStyle(T,`color:${F.css}`),!0)}_getContrastCache(T){return T.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(T,L){T.setAttribute("style",`${T.getAttribute("style")||""}${L};`)}_isCellInSelection(T,L){const A=this._selectionStart,O=this._selectionEnd;return!(!A||!O)&&(this._columnSelectMode?A[0]<=O[0]?T>=A[0]&&L>=A[1]&&T<O[0]&&L<=O[1]:T<A[0]&&L>=A[1]&&T>=O[0]&&L<=O[1]:L>A[1]&&L<O[1]||A[1]===O[1]&&L===A[1]&&T>=A[0]&&T<O[0]||A[1]<O[1]&&L===O[1]&&T<O[0]||A[1]<O[1]&&L===A[1]&&T>=A[0])}};function E(T,L,A){for(;T.length<A;)T=L+T;return T}u.DomRendererRowFactory=k=h([m(1,v.ICharacterJoinerService),m(2,w.IOptionsService),m(3,v.ICoreBrowserService),m(4,w.ICoreService),m(5,w.IDecorationService),m(6,v.IThemeService)],k)},2550:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.WidthCache=void 0,u.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 m=d.createElement("span");m.classList.add("xterm-char-measure-element");const f=d.createElement("span");f.classList.add("xterm-char-measure-element"),f.style.fontWeight="bold";const g=d.createElement("span");g.classList.add("xterm-char-measure-element"),g.style.fontStyle="italic";const x=d.createElement("span");x.classList.add("xterm-char-measure-element"),x.style.fontWeight="bold",x.style.fontStyle="italic",this._measureElements=[m,f,g,x],this._container.appendChild(m),this._container.appendChild(f),this._container.appendChild(g),this._container.appendChild(x),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,m,f){d===this._font&&h===this._fontSize&&m===this._weight&&f===this._weightBold||(this._font=d,this._fontSize=h,this._weight=m,this._weightBold=f,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${m}`,this._measureElements[1].style.fontWeight=`${f}`,this._measureElements[2].style.fontWeight=`${m}`,this._measureElements[3].style.fontWeight=`${f}`,this.clear())}get(d,h,m){let f=0;if(!h&&!m&&d.length===1&&(f=d.charCodeAt(0))<256){if(this._flat[f]!==-9999)return this._flat[f];const w=this._measure(d,0);return w>0&&(this._flat[f]=w),w}let g=d;h&&(g+="B"),m&&(g+="I");let x=this._holey.get(g);if(x===void 0){let w=0;h&&(w|=1),m&&(w|=2),x=this._measure(d,w),x>0&&this._holey.set(g,x)}return x}_measure(d,h){const m=this._measureElements[h];return m.textContent=d.repeat(32),m.offsetWidth/32}}},2223:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.TEXT_BASELINE=u.DIM_OPACITY=u.INVERTED_DEFAULT_COLOR=void 0;const h=d(6114);u.INVERTED_DEFAULT_COLOR=257,u.DIM_OPACITY=.5,u.TEXT_BASELINE=h.isFirefox||h.isLegacyEdge?"bottom":"ideographic"},6171:(c,u)=>{function d(m){return 57508<=m&&m<=57558}function h(m){return m>=128512&&m<=128591||m>=127744&&m<=128511||m>=128640&&m<=128767||m>=9728&&m<=9983||m>=9984&&m<=10175||m>=65024&&m<=65039||m>=129280&&m<=129535||m>=127462&&m<=127487}Object.defineProperty(u,"__esModule",{value:!0}),u.computeNextVariantOffset=u.createRenderDimensions=u.treatGlyphAsBackgroundColor=u.allowRescaling=u.isEmoji=u.isRestrictedPowerlineGlyph=u.isPowerlineGlyph=u.throwIfFalsy=void 0,u.throwIfFalsy=function(m){if(!m)throw new Error("value must not be falsy");return m},u.isPowerlineGlyph=d,u.isRestrictedPowerlineGlyph=function(m){return 57520<=m&&m<=57527},u.isEmoji=h,u.allowRescaling=function(m,f,g,x){return f===1&&g>Math.ceil(1.5*x)&&m!==void 0&&m>255&&!h(m)&&!d(m)&&!(function(w){return 57344<=w&&w<=63743})(m)},u.treatGlyphAsBackgroundColor=function(m){return d(m)||(function(f){return 9472<=f&&f<=9631})(m)},u.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}}}},u.computeNextVariantOffset=function(m,f,g=0){return(m-(2*Math.round(f)-g))%(2*Math.round(f))}},6052:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.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(m,f,g,x=!1){if(this.selectionStart=f,this.selectionEnd=g,!f||!g||f[0]===g[0]&&f[1]===g[1])return void this.clear();const w=m.buffers.active.ydisp,C=f[1]-w,v=g[1]-w,S=Math.max(C,0),_=Math.min(v,m.rows-1);S>=m.rows||_<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=x,this.viewportStartRow=C,this.viewportEndRow=v,this.viewportCappedStartRow=S,this.viewportCappedEndRow=_,this.startCol=f[0],this.endCol=g[0])}isCellSelected(m,f,g){return!!this.hasSelection&&(g-=m.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?f>=this.startCol&&g>=this.viewportCappedStartRow&&f<this.endCol&&g<=this.viewportCappedEndRow:f<this.startCol&&g>=this.viewportCappedStartRow&&f>=this.endCol&&g<=this.viewportCappedEndRow:g>this.viewportStartRow&&g<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&g===this.viewportStartRow&&f>=this.startCol&&f<this.endCol||this.viewportStartRow<this.viewportEndRow&&g===this.viewportEndRow&&f<this.endCol||this.viewportStartRow<this.viewportEndRow&&g===this.viewportStartRow&&f>=this.startCol)}}u.createSelectionRenderModel=function(){return new d}},456:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.SelectionModel=void 0,u.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(c,u,d){var h=this&&this.__decorate||function(_,b,k,E){var T,L=arguments.length,A=L<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(_,b,k,E);else for(var O=_.length-1;O>=0;O--)(T=_[O])&&(A=(L<3?T(A):L>3?T(b,k,A):T(b,k))||A);return L>3&&A&&Object.defineProperty(b,k,A),A},m=this&&this.__param||function(_,b){return function(k,E){b(k,E,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CharSizeService=void 0;const f=d(2585),g=d(8460),x=d(844);let w=u.CharSizeService=class extends x.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 g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new S(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())}};u.CharSizeService=w=h([m(2,f.IOptionsService)],w);class C extends x.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 S 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(c,u,d){var h=this&&this.__decorate||function(S,_,b,k){var E,T=arguments.length,L=T<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,b):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(S,_,b,k);else for(var A=S.length-1;A>=0;A--)(E=S[A])&&(L=(T<3?E(L):T>3?E(_,b,L):E(_,b))||L);return T>3&&L&&Object.defineProperty(_,b,L),L},m=this&&this.__param||function(S,_){return function(b,k){_(b,k,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CharacterJoinerService=u.JoinedCellData=void 0;const f=d(3734),g=d(643),x=d(511),w=d(2585);class C extends f.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()]}}u.JoinedCellData=C;let v=u.CharacterJoinerService=class TT{constructor(_){this._bufferService=_,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.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,L=0,A=0,O=b.getFg(0),M=b.getBg(0);for(let H=0;H<b.getTrimmedLength();H++)if(b.loadCell(H,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==O||this._workCell.bg!==M){if(H-T>1){const B=this._getJoinedRanges(E,A,L,b,T);for(let F=0;F<B.length;F++)k.push(B[F])}T=H,A=L,O=this._workCell.fg,M=this._workCell.bg}L+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-T>1){const H=this._getJoinedRanges(E,A,L,b,T);for(let B=0;B<H.length;B++)k.push(H[B])}return k}_getJoinedRanges(_,b,k,E,T){const L=_.substring(b,k);let A=[];try{A=this._characterJoiners[0].handler(L)}catch(O){console.error(O)}for(let O=1;O<this._characterJoiners.length;O++)try{const M=this._characterJoiners[O].handler(L);for(let H=0;H<M.length;H++)TT._mergeRanges(A,M[H])}catch(M){console.error(M)}return this._stringRangesToCellRanges(A,E,T),A}_stringRangesToCellRanges(_,b,k){let E=0,T=!1,L=0,A=_[E];if(A){for(let O=k;O<this._bufferService.cols;O++){const M=b.getWidth(O),H=b.getString(O).length||g.WHITESPACE_CELL_CHAR.length;if(M!==0){if(!T&&A[0]<=L&&(A[0]=O,T=!0),A[1]<=L){if(A[1]=O,A=_[++E],!A)break;A[0]<=L?(A[0]=O,T=!0):T=!1}L+=H}}A&&(A[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),_}};u.CharacterJoinerService=v=h([m(0,w.IBufferService)],v)},5114:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CoreBrowserService=void 0;const h=d(844),m=d(8460),f=d(3656);class g extends h.Disposable{constructor(C,v,S){super(),this._textarea=C,this._window=v,this.mainDocument=S,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new x(this._window),this._onDprChange=this.register(new m.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new m.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((_=>this._screenDprMonitor.setWindow(_)))),this.register((0,m.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}}u.CoreBrowserService=g;class x extends h.Disposable{constructor(C){super(),this._parentWindow=C,this._windowResizeListener=this.register(new h.MutableDisposable),this._onDprChange=this.register(new m.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,f.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:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.LinkProviderService=void 0;const h=d(844);class m extends h.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,h.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(g){return this.linkProviders.push(g),{dispose:()=>{const x=this.linkProviders.indexOf(g);x!==-1&&this.linkProviders.splice(x,1)}}}}u.LinkProviderService=m},8934:function(c,u,d){var h=this&&this.__decorate||function(w,C,v,S){var _,b=arguments.length,k=b<3?C:S===null?S=Object.getOwnPropertyDescriptor(C,v):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(w,C,v,S);else for(var E=w.length-1;E>=0;E--)(_=w[E])&&(k=(b<3?_(k):b>3?_(C,v,k):_(C,v))||k);return b>3&&k&&Object.defineProperty(C,v,k),k},m=this&&this.__param||function(w,C){return function(v,S){C(v,S,w)}};Object.defineProperty(u,"__esModule",{value:!0}),u.MouseService=void 0;const f=d(4725),g=d(9806);let x=u.MouseService=class{constructor(w,C){this._renderService=w,this._charSizeService=C}getCoords(w,C,v,S,_){return(0,g.getCoords)(window,w,C,v,S,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,_)}getMouseReportCoords(w,C){const v=(0,g.getCoordsRelativeToElement)(window,w,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])}}};u.MouseService=x=h([m(0,f.IRenderService),m(1,f.ICharSizeService)],x)},3230:function(c,u,d){var h=this&&this.__decorate||function(_,b,k,E){var T,L=arguments.length,A=L<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(_,b,k,E);else for(var O=_.length-1;O>=0;O--)(T=_[O])&&(A=(L<3?T(A):L>3?T(b,k,A):T(b,k))||A);return L>3&&A&&Object.defineProperty(b,k,A),A},m=this&&this.__param||function(_,b){return function(k,E){b(k,E,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.RenderService=void 0;const f=d(6193),g=d(4725),x=d(8460),w=d(844),C=d(7226),v=d(2585);let S=u.RenderService=class extends w.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(_,b,k,E,T,L,A,O){super(),this._rowCount=_,this._charSizeService=E,this._renderer=this.register(new w.MutableDisposable),this._pausedResizeTask=new C.DebouncedIdleTask,this._observerDisposable=this.register(new w.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 x.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new x.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new x.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new x.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new f.RenderDebouncer(((M,H)=>this._renderRows(M,H)),A),this.register(this._renderDebouncer),this.register(A.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(L.onResize((()=>this._fullRefresh()))),this.register(L.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(L.cols,L.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(L.buffer.y,L.buffer.y,!0)))),this.register(O.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(A.window,b),this.register(A.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,w.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()}};u.RenderService=S=h([m(2,v.IOptionsService),m(3,g.ICharSizeService),m(4,v.IDecorationService),m(5,v.IBufferService),m(6,g.ICoreBrowserService),m(7,g.IThemeService)],S)},9312:function(c,u,d){var h=this&&this.__decorate||function(A,O,M,H){var B,F=arguments.length,K=F<3?O:H===null?H=Object.getOwnPropertyDescriptor(O,M):H;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")K=Reflect.decorate(A,O,M,H);else for(var G=A.length-1;G>=0;G--)(B=A[G])&&(K=(F<3?B(K):F>3?B(O,M,K):B(O,M))||K);return F>3&&K&&Object.defineProperty(O,M,K),K},m=this&&this.__param||function(A,O){return function(M,H){O(M,H,A)}};Object.defineProperty(u,"__esModule",{value:!0}),u.SelectionService=void 0;const f=d(9806),g=d(9504),x=d(456),w=d(4725),C=d(8460),v=d(844),S=d(6114),_=d(4841),b=d(511),k=d(2585),E=" ",T=new RegExp(E,"g");let L=u.SelectionService=class extends v.Disposable{constructor(A,O,M,H,B,F,K,G,V){super(),this._element=A,this._screenElement=O,this._linkifier=M,this._bufferService=H,this._coreService=B,this._mouseService=F,this._optionsService=K,this._renderService=G,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 x.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 A=this._model.finalSelectionStart,O=this._model.finalSelectionEnd;return!(!A||!O||A[0]===O[0]&&A[1]===O[1])}get selectionText(){const A=this._model.finalSelectionStart,O=this._model.finalSelectionEnd;if(!A||!O)return"";const M=this._bufferService.buffer,H=[];if(this._activeSelectionMode===3){if(A[0]===O[0])return"";const B=A[0]<O[0]?A[0]:O[0],F=A[0]<O[0]?O[0]:A[0];for(let K=A[1];K<=O[1];K++){const G=M.translateBufferLineToString(K,!0,B,F);H.push(G)}}else{const B=A[1]===O[1]?O[0]:void 0;H.push(M.translateBufferLineToString(A[1],!0,A[0],B));for(let F=A[1]+1;F<=O[1]-1;F++){const K=M.lines.get(F),G=M.translateBufferLineToString(F,!0);K!=null&&K.isWrapped?H[H.length-1]+=G:H.push(G)}if(A[1]!==O[1]){const F=M.lines.get(O[1]),K=M.translateBufferLineToString(O[1],!0,0,O[0]);F&&F.isWrapped?H[H.length-1]+=K:H.push(K)}}return H.map((B=>B.replace(T," "))).join(S.isWindows?`\r
|
|
258
|
+
`:`
|
|
259
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(A){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),S.isLinux&&A&&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(A){const O=this._getMouseBufferCoords(A),M=this._model.finalSelectionStart,H=this._model.finalSelectionEnd;return!!(M&&H&&O)&&this._areCoordsInSelection(O,M,H)}isCellInSelection(A,O){const M=this._model.finalSelectionStart,H=this._model.finalSelectionEnd;return!(!M||!H)&&this._areCoordsInSelection([A,O],M,H)}_areCoordsInSelection(A,O,M){return A[1]>O[1]&&A[1]<M[1]||O[1]===M[1]&&A[1]===O[1]&&A[0]>=O[0]&&A[0]<M[0]||O[1]<M[1]&&A[1]===M[1]&&A[0]<M[0]||O[1]<M[1]&&A[1]===O[1]&&A[0]>=O[0]}_selectWordAtCursor(A,O){var B,F;const M=(F=(B=this._linkifier.currentLink)==null?void 0:B.link)==null?void 0:F.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 H=this._getMouseBufferCoords(A);return!!H&&(this._selectWordAt(H,O),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(A,O){this._model.clearSelection(),A=Math.max(A,0),O=Math.min(O,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,A],this._model.selectionEnd=[this._bufferService.cols,O],this.refresh(),this._onSelectionChange.fire()}_handleTrim(A){this._model.handleTrim(A)&&this.refresh()}_getMouseBufferCoords(A){const O=this._mouseService.getCoords(A,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(O)return O[0]--,O[1]--,O[1]+=this._bufferService.buffer.ydisp,O}_getMouseEventScrollAmount(A){let O=(0,f.getCoordsRelativeToElement)(this._coreBrowserService.window,A,this._screenElement)[1];const M=this._renderService.dimensions.css.canvas.height;return O>=0&&O<=M?0:(O>M&&(O-=M),O=Math.min(Math.max(O,-50),50),O/=50,O/Math.abs(O)+Math.round(14*O))}shouldForceSelection(A){return S.isMac?A.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:A.shiftKey}handleMouseDown(A){if(this._mouseDownTimeStamp=A.timeStamp,(A.button!==2||!this.hasSelection)&&A.button===0){if(!this._enabled){if(!this.shouldForceSelection(A))return;A.stopPropagation()}A.preventDefault(),this._dragScrollAmount=0,this._enabled&&A.shiftKey?this._handleIncrementalClick(A):A.detail===1?this._handleSingleClick(A):A.detail===2?this._handleDoubleClick(A):A.detail===3&&this._handleTripleClick(A),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(A){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(A))}_handleSingleClick(A){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(A)?3:0,this._model.selectionStart=this._getMouseBufferCoords(A),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const O=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);O&&O.length!==this._model.selectionStart[0]&&O.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(A){this._selectWordAtCursor(A,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(A){const O=this._getMouseBufferCoords(A);O&&(this._activeSelectionMode=2,this._selectLineAt(O[1]))}shouldColumnSelect(A){return A.altKey&&!(S.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(A){if(A.stopImmediatePropagation(),!this._model.selectionStart)return;const O=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(A),!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(A),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 H=M.lines.get(this._model.selectionEnd[1]);H&&H.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}O&&O[0]===this._model.selectionEnd[0]&&O[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 A=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(A.ydisp+this._bufferService.rows,A.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=A.ydisp),this.refresh()}}_handleMouseUp(A){const O=A.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&O<500&&A.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const M=this._mouseService.getCoords(A,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(M&&M[0]!==void 0&&M[1]!==void 0){const H=(0,g.moveToCellSequence)(M[0]-1,M[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(H,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const A=this._model.finalSelectionStart,O=this._model.finalSelectionEnd,M=!(!A||!O||A[0]===O[0]&&A[1]===O[1]);M?A&&O&&(this._oldSelectionStart&&this._oldSelectionEnd&&A[0]===this._oldSelectionStart[0]&&A[1]===this._oldSelectionStart[1]&&O[0]===this._oldSelectionEnd[0]&&O[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(A,O,M)):this._oldHasSelection&&this._fireOnSelectionChange(A,O,M)}_fireOnSelectionChange(A,O,M){this._oldSelectionStart=A,this._oldSelectionEnd=O,this._oldHasSelection=M,this._onSelectionChange.fire()}_handleBufferActivate(A){this.clearSelection(),this._trimListener.dispose(),this._trimListener=A.activeBuffer.lines.onTrim((O=>this._handleTrim(O)))}_convertViewportColToCharacterIndex(A,O){let M=O;for(let H=0;O>=H;H++){const B=A.loadCell(H,this._workCell).getChars().length;this._workCell.getWidth()===0?M--:B>1&&O!==H&&(M+=B-1)}return M}setSelection(A,O,M){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[A,O],this._model.selectionStartLength=M,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(A){this._isClickInSelection(A)||(this._selectWordAtCursor(A,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(A,O,M=!0,H=!0){if(A[0]>=this._bufferService.cols)return;const B=this._bufferService.buffer,F=B.lines.get(A[1]);if(!F)return;const K=B.translateBufferLineToString(A[1],!1);let G=this._convertViewportColToCharacterIndex(F,A[0]),V=G;const Z=A[0]-G;let J=0,z=0,P=0,D=0;if(K.charAt(G)===" "){for(;G>0&&K.charAt(G-1)===" ";)G--;for(;V<K.length&&K.charAt(V+1)===" ";)V++}else{let te=A[0],q=A[0];F.getWidth(te)===0&&(J++,te--),F.getWidth(q)===2&&(z++,q++);const X=F.getString(q).length;for(X>1&&(D+=X-1,V+=X-1);te>0&&G>0&&!this._isCharWordSeparator(F.loadCell(te-1,this._workCell));){F.loadCell(te-1,this._workCell);const Y=this._workCell.getChars().length;this._workCell.getWidth()===0?(J++,te--):Y>1&&(P+=Y-1,G-=Y-1),G--,te--}for(;q<F.length&&V+1<K.length&&!this._isCharWordSeparator(F.loadCell(q+1,this._workCell));){F.loadCell(q+1,this._workCell);const Y=this._workCell.getChars().length;this._workCell.getWidth()===2?(z++,q++):Y>1&&(D+=Y-1,V+=Y-1),V++,q++}}V++;let U=G+Z-J+P,$=Math.min(this._bufferService.cols,V-G+J+z-P-D);if(O||K.slice(G,V).trim()!==""){if(M&&U===0&&F.getCodePoint(0)!==32){const te=B.lines.get(A[1]-1);if(te&&F.isWrapped&&te.getCodePoint(this._bufferService.cols-1)!==32){const q=this._getWordAt([this._bufferService.cols-1,A[1]-1],!1,!0,!1);if(q){const X=this._bufferService.cols-q.start;U-=X,$+=X}}}if(H&&U+$===this._bufferService.cols&&F.getCodePoint(this._bufferService.cols-1)!==32){const te=B.lines.get(A[1]+1);if(te!=null&&te.isWrapped&&te.getCodePoint(0)!==32){const q=this._getWordAt([0,A[1]+1],!1,!1,!0);q&&($+=q.length)}}return{start:U,length:$}}}_selectWordAt(A,O){const M=this._getWordAt(A,O);if(M){for(;M.start<0;)M.start+=this._bufferService.cols,A[1]--;this._model.selectionStart=[M.start,A[1]],this._model.selectionStartLength=M.length}}_selectToWordAt(A){const O=this._getWordAt(A,!0);if(O){let M=A[1];for(;O.start<0;)O.start+=this._bufferService.cols,M--;if(!this._model.areSelectionValuesReversed())for(;O.start+O.length>this._bufferService.cols;)O.length-=this._bufferService.cols,M++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?O.start:O.start+O.length,M]}}_isCharWordSeparator(A){return A.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(A.getChars())>=0}_selectLineAt(A){const O=this._bufferService.buffer.getWrappedRangeForLine(A),M={start:{x:0,y:O.first},end:{x:this._bufferService.cols-1,y:O.last}};this._model.selectionStart=[0,O.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,_.getRangeLength)(M,this._bufferService.cols)}};u.SelectionService=L=h([m(3,k.IBufferService),m(4,k.ICoreService),m(5,w.IMouseService),m(6,k.IOptionsService),m(7,w.IRenderService),m(8,w.ICoreBrowserService)],L)},4725:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ILinkProviderService=u.IThemeService=u.ICharacterJoinerService=u.ISelectionService=u.IRenderService=u.IMouseService=u.ICoreBrowserService=u.ICharSizeService=void 0;const h=d(8343);u.ICharSizeService=(0,h.createDecorator)("CharSizeService"),u.ICoreBrowserService=(0,h.createDecorator)("CoreBrowserService"),u.IMouseService=(0,h.createDecorator)("MouseService"),u.IRenderService=(0,h.createDecorator)("RenderService"),u.ISelectionService=(0,h.createDecorator)("SelectionService"),u.ICharacterJoinerService=(0,h.createDecorator)("CharacterJoinerService"),u.IThemeService=(0,h.createDecorator)("ThemeService"),u.ILinkProviderService=(0,h.createDecorator)("LinkProviderService")},6731:function(c,u,d){var h=this&&this.__decorate||function(L,A,O,M){var H,B=arguments.length,F=B<3?A:M===null?M=Object.getOwnPropertyDescriptor(A,O):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(L,A,O,M);else for(var K=L.length-1;K>=0;K--)(H=L[K])&&(F=(B<3?H(F):B>3?H(A,O,F):H(A,O))||F);return B>3&&F&&Object.defineProperty(A,O,F),F},m=this&&this.__param||function(L,A){return function(O,M){A(O,M,L)}};Object.defineProperty(u,"__esModule",{value:!0}),u.ThemeService=u.DEFAULT_ANSI_COLORS=void 0;const f=d(7239),g=d(8055),x=d(8460),w=d(844),C=d(2585),v=g.css.toColor("#ffffff"),S=g.css.toColor("#000000"),_=g.css.toColor("#ffffff"),b=g.css.toColor("#000000"),k={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};u.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const L=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],A=[0,95,135,175,215,255];for(let O=0;O<216;O++){const M=A[O/36%6|0],H=A[O/6%6|0],B=A[O%6];L.push({css:g.channels.toCss(M,H,B),rgba:g.channels.toRgba(M,H,B)})}for(let O=0;O<24;O++){const M=8+10*O;L.push({css:g.channels.toCss(M,M,M),rgba:g.channels.toRgba(M,M,M)})}return L})());let E=u.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(L){super(),this._optionsService=L,this._contrastCache=new f.ColorContrastCache,this._halfContrastCache=new f.ColorContrastCache,this._onChangeColors=this.register(new x.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:v,background:S,cursor:_,cursorAccent:b,selectionForeground:void 0,selectionBackgroundTransparent:k,selectionBackgroundOpaque:g.color.blend(S,k),selectionInactiveBackgroundTransparent:k,selectionInactiveBackgroundOpaque:g.color.blend(S,k),ansi:u.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(L={}){const A=this._colors;if(A.foreground=T(L.foreground,v),A.background=T(L.background,S),A.cursor=T(L.cursor,_),A.cursorAccent=T(L.cursorAccent,b),A.selectionBackgroundTransparent=T(L.selectionBackground,k),A.selectionBackgroundOpaque=g.color.blend(A.background,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundTransparent=T(L.selectionInactiveBackground,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundOpaque=g.color.blend(A.background,A.selectionInactiveBackgroundTransparent),A.selectionForeground=L.selectionForeground?T(L.selectionForeground,g.NULL_COLOR):void 0,A.selectionForeground===g.NULL_COLOR&&(A.selectionForeground=void 0),g.color.isOpaque(A.selectionBackgroundTransparent)&&(A.selectionBackgroundTransparent=g.color.opacity(A.selectionBackgroundTransparent,.3)),g.color.isOpaque(A.selectionInactiveBackgroundTransparent)&&(A.selectionInactiveBackgroundTransparent=g.color.opacity(A.selectionInactiveBackgroundTransparent,.3)),A.ansi=u.DEFAULT_ANSI_COLORS.slice(),A.ansi[0]=T(L.black,u.DEFAULT_ANSI_COLORS[0]),A.ansi[1]=T(L.red,u.DEFAULT_ANSI_COLORS[1]),A.ansi[2]=T(L.green,u.DEFAULT_ANSI_COLORS[2]),A.ansi[3]=T(L.yellow,u.DEFAULT_ANSI_COLORS[3]),A.ansi[4]=T(L.blue,u.DEFAULT_ANSI_COLORS[4]),A.ansi[5]=T(L.magenta,u.DEFAULT_ANSI_COLORS[5]),A.ansi[6]=T(L.cyan,u.DEFAULT_ANSI_COLORS[6]),A.ansi[7]=T(L.white,u.DEFAULT_ANSI_COLORS[7]),A.ansi[8]=T(L.brightBlack,u.DEFAULT_ANSI_COLORS[8]),A.ansi[9]=T(L.brightRed,u.DEFAULT_ANSI_COLORS[9]),A.ansi[10]=T(L.brightGreen,u.DEFAULT_ANSI_COLORS[10]),A.ansi[11]=T(L.brightYellow,u.DEFAULT_ANSI_COLORS[11]),A.ansi[12]=T(L.brightBlue,u.DEFAULT_ANSI_COLORS[12]),A.ansi[13]=T(L.brightMagenta,u.DEFAULT_ANSI_COLORS[13]),A.ansi[14]=T(L.brightCyan,u.DEFAULT_ANSI_COLORS[14]),A.ansi[15]=T(L.brightWhite,u.DEFAULT_ANSI_COLORS[15]),L.extendedAnsi){const O=Math.min(A.ansi.length-16,L.extendedAnsi.length);for(let M=0;M<O;M++)A.ansi[M+16]=T(L.extendedAnsi[M],u.DEFAULT_ANSI_COLORS[M+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(L){this._restoreColor(L),this._onChangeColors.fire(this.colors)}_restoreColor(L){if(L!==void 0)switch(L){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[L]=this._restoreColors.ansi[L]}else for(let A=0;A<this._restoreColors.ansi.length;++A)this._colors.ansi[A]=this._restoreColors.ansi[A]}modifyColors(L){L(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(L,A){if(L!==void 0)try{return g.css.toColor(L)}catch{}return A}u.ThemeService=E=h([m(0,C.IOptionsService)],E)},6349:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CircularList=void 0;const h=d(8460),m=d(844);class f extends m.Disposable{constructor(x){super(),this._maxLength=x,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(x){if(this._maxLength===x)return;const w=new Array(x);for(let C=0;C<Math.min(x,this.length);C++)w[C]=this._array[this._getCyclicIndex(C)];this._array=w,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let w=this._length;w<x;w++)this._array[w]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,w){this._array[this._getCyclicIndex(x)]=w}push(x){this._array[this._getCyclicIndex(this._length)]=x,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(x,w,...C){if(w){for(let v=x;v<this._length-w;v++)this._array[this._getCyclicIndex(v)]=this._array[this._getCyclicIndex(v+w)];this._length-=w,this.onDeleteEmitter.fire({index:x,amount:w})}for(let v=this._length-1;v>=x;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(x+v)]=C[v];if(C.length&&this.onInsertEmitter.fire({index:x,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(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,w,C){if(!(w<=0)){if(x<0||x>=this._length)throw new Error("start argument out of range");if(x+C<0)throw new Error("Cannot shift elements in list beyond index 0");if(C>0){for(let S=w-1;S>=0;S--)this.set(x+S+C,this.get(x+S));const v=x+w+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<w;v++)this.set(x+v+C,this.get(x+v))}}_getCyclicIndex(x){return(this._startIndex+x)%this._maxLength}}u.CircularList=f},1439:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.clone=void 0,u.clone=function d(h,m=5){if(typeof h!="object")return h;const f=Array.isArray(h)?[]:{};for(const g in h)f[g]=m<=1?h[g]:h[g]&&d(h[g],m-1);return f}},8055:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.contrastRatio=u.toPaddedHex=u.rgba=u.rgb=u.css=u.color=u.channels=u.NULL_COLOR=void 0;let d=0,h=0,m=0,f=0;var g,x,w,C,v;function S(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)}u.NULL_COLOR={css:"#00000000",rgba:0},(function(b){b.toCss=function(k,E,T,L){return L!==void 0?`#${S(k)}${S(E)}${S(T)}${S(L)}`:`#${S(k)}${S(E)}${S(T)}`},b.toRgba=function(k,E,T,L=255){return(k<<24|E<<16|T<<8|L)>>>0},b.toColor=function(k,E,T,L){return{css:b.toCss(k,E,T,L),rgba:b.toRgba(k,E,T,L)}}})(g||(u.channels=g={})),(function(b){function k(E,T){return f=Math.round(255*T),[d,h,m]=v.toChannels(E.rgba),{css:g.toCss(d,h,m,f),rgba:g.toRgba(d,h,m,f)}}b.blend=function(E,T){if(f=(255&T.rgba)/255,f===1)return{css:T.css,rgba:T.rgba};const L=T.rgba>>24&255,A=T.rgba>>16&255,O=T.rgba>>8&255,M=E.rgba>>24&255,H=E.rgba>>16&255,B=E.rgba>>8&255;return d=M+Math.round((L-M)*f),h=H+Math.round((A-H)*f),m=B+Math.round((O-B)*f),{css:g.toCss(d,h,m),rgba:g.toRgba(d,h,m)}},b.isOpaque=function(E){return(255&E.rgba)==255},b.ensureContrastRatio=function(E,T,L){const A=v.ensureContrastRatio(E.rgba,T.rgba,L);if(A)return g.toColor(A>>24&255,A>>16&255,A>>8&255)},b.opaque=function(E){const T=(255|E.rgba)>>>0;return[d,h,m]=v.toChannels(T),{css:g.toCss(d,h,m),rgba:T}},b.opacity=k,b.multiplyOpacity=function(E,T){return f=255&E.rgba,k(E,f*T/255)},b.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(x||(u.color=x={})),(function(b){let k,E;try{const T=document.createElement("canvas");T.width=1,T.height=1;const L=T.getContext("2d",{willReadFrequently:!0});L&&(k=L,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),m=parseInt(T.slice(3,4).repeat(2),16),g.toColor(d,h,m);case 5:return d=parseInt(T.slice(1,2).repeat(2),16),h=parseInt(T.slice(2,3).repeat(2),16),m=parseInt(T.slice(3,4).repeat(2),16),f=parseInt(T.slice(4,5).repeat(2),16),g.toColor(d,h,m,f);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 L=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(L)return d=parseInt(L[1]),h=parseInt(L[2]),m=parseInt(L[3]),f=Math.round(255*(L[5]===void 0?1:parseFloat(L[5]))),g.toColor(d,h,m,f);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,m,f]=k.getImageData(0,0,1,1).data,f!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:g.toRgba(d,h,m,f),css:T}}})(w||(u.css=w={})),(function(b){function k(E,T,L){const A=E/255,O=T/255,M=L/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(O<=.03928?O/12.92:Math.pow((O+.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||(u.rgb=C={})),(function(b){function k(T,L,A){const O=T>>24&255,M=T>>16&255,H=T>>8&255;let B=L>>24&255,F=L>>16&255,K=L>>8&255,G=_(C.relativeLuminance2(B,F,K),C.relativeLuminance2(O,M,H));for(;G<A&&(B>0||F>0||K>0);)B-=Math.max(0,Math.ceil(.1*B)),F-=Math.max(0,Math.ceil(.1*F)),K-=Math.max(0,Math.ceil(.1*K)),G=_(C.relativeLuminance2(B,F,K),C.relativeLuminance2(O,M,H));return(B<<24|F<<16|K<<8|255)>>>0}function E(T,L,A){const O=T>>24&255,M=T>>16&255,H=T>>8&255;let B=L>>24&255,F=L>>16&255,K=L>>8&255,G=_(C.relativeLuminance2(B,F,K),C.relativeLuminance2(O,M,H));for(;G<A&&(B<255||F<255||K<255);)B=Math.min(255,B+Math.ceil(.1*(255-B))),F=Math.min(255,F+Math.ceil(.1*(255-F))),K=Math.min(255,K+Math.ceil(.1*(255-K))),G=_(C.relativeLuminance2(B,F,K),C.relativeLuminance2(O,M,H));return(B<<24|F<<16|K<<8|255)>>>0}b.blend=function(T,L){if(f=(255&L)/255,f===1)return L;const A=L>>24&255,O=L>>16&255,M=L>>8&255,H=T>>24&255,B=T>>16&255,F=T>>8&255;return d=H+Math.round((A-H)*f),h=B+Math.round((O-B)*f),m=F+Math.round((M-F)*f),g.toRgba(d,h,m)},b.ensureContrastRatio=function(T,L,A){const O=C.relativeLuminance(T>>8),M=C.relativeLuminance(L>>8);if(_(O,M)<A){if(M<O){const F=k(T,L,A),K=_(O,C.relativeLuminance(F>>8));if(K<A){const G=E(T,L,A);return K>_(O,C.relativeLuminance(G>>8))?F:G}return F}const H=E(T,L,A),B=_(O,C.relativeLuminance(H>>8));if(B<A){const F=k(T,L,A);return B>_(O,C.relativeLuminance(F>>8))?H:F}return H}},b.reduceLuminance=k,b.increaseLuminance=E,b.toChannels=function(T){return[T>>24&255,T>>16&255,T>>8&255,255&T]}})(v||(u.rgba=v={})),u.toPaddedHex=S,u.contrastRatio=_},8969:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CoreTerminal=void 0;const h=d(844),m=d(2585),f=d(4348),g=d(7866),x=d(744),w=d(7302),C=d(6975),v=d(8460),S=d(1753),_=d(1480),b=d(7994),k=d(9282),E=d(5435),T=d(5981),L=d(2660);let A=!1;class O extends h.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new v.EventEmitter),this._onScroll.event((H=>{var B;(B=this._onScrollApi)==null||B.fire(H.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(H){for(const B in H)this.optionsService.options[B]=H[B]}constructor(H){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 f.InstantiationService,this.optionsService=this.register(new w.OptionsService(H)),this._instantiationService.setService(m.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(x.BufferService)),this._instantiationService.setService(m.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(m.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(C.CoreService)),this._instantiationService.setService(m.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(S.CoreMouseService)),this._instantiationService.setService(m.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(_.UnicodeService)),this._instantiationService.setService(m.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(b.CharsetService),this._instantiationService.setService(m.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(L.OscLinkService),this._instantiationService.setService(m.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((B=>{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((B=>{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(((B,F)=>this._inputHandler.parse(B,F)))),this.register((0,v.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(H,B){this._writeBuffer.write(H,B)}writeSync(H,B){this._logService.logLevel<=m.LogLevelEnum.WARN&&!A&&(this._logService.warn("writeSync is unreliable and will be removed soon."),A=!0),this._writeBuffer.writeSync(H,B)}input(H,B=!0){this.coreService.triggerDataEvent(H,B)}resize(H,B){isNaN(H)||isNaN(B)||(H=Math.max(H,x.MINIMUM_COLS),B=Math.max(B,x.MINIMUM_ROWS),this._bufferService.resize(H,B))}scroll(H,B=!1){this._bufferService.scroll(H,B)}scrollLines(H,B,F){this._bufferService.scrollLines(H,B,F)}scrollPages(H){this.scrollLines(H*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(H){const B=H-this._bufferService.buffer.ydisp;B!==0&&this.scrollLines(B)}registerEscHandler(H,B){return this._inputHandler.registerEscHandler(H,B)}registerDcsHandler(H,B){return this._inputHandler.registerDcsHandler(H,B)}registerCsiHandler(H,B){return this._inputHandler.registerCsiHandler(H,B)}registerOscHandler(H,B){return this._inputHandler.registerOscHandler(H,B)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let H=!1;const B=this.optionsService.rawOptions.windowsPty;B&&B.buildNumber!==void 0&&B.buildNumber!==void 0?H=B.backend==="conpty"&&B.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(H=!0),H?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const H=[];H.push(this.onLineFeed(k.updateWindowsModeWrappedState.bind(null,this._bufferService))),H.push(this.registerCsiHandler({final:"H"},(()=>((0,k.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,h.toDisposable)((()=>{for(const B of H)B.dispose()}))}}}u.CoreTerminal=O},8460:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.runAndSubscribe=u.forwardEvent=u.EventEmitter=void 0,u.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 m=[];for(let f=0;f<this._listeners.length;f++)m.push(this._listeners[f]);for(let f=0;f<m.length;f++)m[f].call(void 0,d,h)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},u.forwardEvent=function(d,h){return d((m=>h.fire(m)))},u.runAndSubscribe=function(d,h){return h(void 0),d((m=>h(m)))}},5435:function(c,u,d){var h=this&&this.__decorate||function(J,z,P,D){var U,$=arguments.length,te=$<3?z:D===null?D=Object.getOwnPropertyDescriptor(z,P):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")te=Reflect.decorate(J,z,P,D);else for(var q=J.length-1;q>=0;q--)(U=J[q])&&(te=($<3?U(te):$>3?U(z,P,te):U(z,P))||te);return $>3&&te&&Object.defineProperty(z,P,te),te},m=this&&this.__param||function(J,z){return function(P,D){z(P,D,J)}};Object.defineProperty(u,"__esModule",{value:!0}),u.InputHandler=u.WindowsOptionsReportType=void 0;const f=d(2584),g=d(7116),x=d(2015),w=d(844),C=d(482),v=d(8437),S=d(8460),_=d(643),b=d(511),k=d(3734),E=d(2585),T=d(1480),L=d(6242),A=d(6351),O=d(5941),M={"(":0,")":1,"*":2,"+":3,"-":1,".":2},H=131072;function B(J,z){if(J>24)return z.setWinLines||!1;switch(J){case 1:return!!z.restoreWin;case 2:return!!z.minimizeWin;case 3:return!!z.setWinPosition;case 4:return!!z.setWinSizePixels;case 5:return!!z.raiseWin;case 6:return!!z.lowerWin;case 7:return!!z.refreshWin;case 8:return!!z.setWinSizeChars;case 9:return!!z.maximizeWin;case 10:return!!z.fullscreenWin;case 11:return!!z.getWinState;case 13:return!!z.getWinPosition;case 14:return!!z.getWinSizePixels;case 15:return!!z.getScreenSizePixels;case 16:return!!z.getCellSizePixels;case 18:return!!z.getWinSizeChars;case 19:return!!z.getScreenSizeChars;case 20:return!!z.getIconTitle;case 21:return!!z.getWinTitle;case 22:return!!z.pushTitle;case 23:return!!z.popTitle;case 24:return!!z.setWinLines}return!1}var F;(function(J){J[J.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",J[J.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(F||(u.WindowsOptionsReportType=F={}));let K=0;class G extends w.Disposable{getAttrData(){return this._curAttrData}constructor(z,P,D,U,$,te,q,X,Y=new x.EscapeSequenceParser){super(),this._bufferService=z,this._charsetService=P,this._coreService=D,this._logService=U,this._optionsService=$,this._oscLinkService=te,this._coreMouseService=q,this._unicodeService=X,this._parser=Y,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 S.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new S.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new S.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new S.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new S.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new S.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new S.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new S.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new S.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new S.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new S.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new S.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new S.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((I=>this._activeBuffer=I.activeBuffer))),this._parser.setCsiHandlerFallback(((I,Q)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(I),params:Q.toArray()})})),this._parser.setEscHandlerFallback((I=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(I)})})),this._parser.setExecuteHandlerFallback((I=>{this._logService.debug("Unknown EXECUTE code: ",{code:I})})),this._parser.setOscHandlerFallback(((I,Q,ne)=>{this._logService.debug("Unknown OSC code: ",{identifier:I,action:Q,data:ne})})),this._parser.setDcsHandlerFallback(((I,Q,ne)=>{Q==="HOOK"&&(ne=ne.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(I),action:Q,payload:ne})})),this._parser.setPrintHandler(((I,Q,ne)=>this.print(I,Q,ne))),this._parser.registerCsiHandler({final:"@"},(I=>this.insertChars(I))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(I=>this.scrollLeft(I))),this._parser.registerCsiHandler({final:"A"},(I=>this.cursorUp(I))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(I=>this.scrollRight(I))),this._parser.registerCsiHandler({final:"B"},(I=>this.cursorDown(I))),this._parser.registerCsiHandler({final:"C"},(I=>this.cursorForward(I))),this._parser.registerCsiHandler({final:"D"},(I=>this.cursorBackward(I))),this._parser.registerCsiHandler({final:"E"},(I=>this.cursorNextLine(I))),this._parser.registerCsiHandler({final:"F"},(I=>this.cursorPrecedingLine(I))),this._parser.registerCsiHandler({final:"G"},(I=>this.cursorCharAbsolute(I))),this._parser.registerCsiHandler({final:"H"},(I=>this.cursorPosition(I))),this._parser.registerCsiHandler({final:"I"},(I=>this.cursorForwardTab(I))),this._parser.registerCsiHandler({final:"J"},(I=>this.eraseInDisplay(I,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(I=>this.eraseInDisplay(I,!0))),this._parser.registerCsiHandler({final:"K"},(I=>this.eraseInLine(I,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(I=>this.eraseInLine(I,!0))),this._parser.registerCsiHandler({final:"L"},(I=>this.insertLines(I))),this._parser.registerCsiHandler({final:"M"},(I=>this.deleteLines(I))),this._parser.registerCsiHandler({final:"P"},(I=>this.deleteChars(I))),this._parser.registerCsiHandler({final:"S"},(I=>this.scrollUp(I))),this._parser.registerCsiHandler({final:"T"},(I=>this.scrollDown(I))),this._parser.registerCsiHandler({final:"X"},(I=>this.eraseChars(I))),this._parser.registerCsiHandler({final:"Z"},(I=>this.cursorBackwardTab(I))),this._parser.registerCsiHandler({final:"`"},(I=>this.charPosAbsolute(I))),this._parser.registerCsiHandler({final:"a"},(I=>this.hPositionRelative(I))),this._parser.registerCsiHandler({final:"b"},(I=>this.repeatPrecedingCharacter(I))),this._parser.registerCsiHandler({final:"c"},(I=>this.sendDeviceAttributesPrimary(I))),this._parser.registerCsiHandler({prefix:">",final:"c"},(I=>this.sendDeviceAttributesSecondary(I))),this._parser.registerCsiHandler({final:"d"},(I=>this.linePosAbsolute(I))),this._parser.registerCsiHandler({final:"e"},(I=>this.vPositionRelative(I))),this._parser.registerCsiHandler({final:"f"},(I=>this.hVPosition(I))),this._parser.registerCsiHandler({final:"g"},(I=>this.tabClear(I))),this._parser.registerCsiHandler({final:"h"},(I=>this.setMode(I))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(I=>this.setModePrivate(I))),this._parser.registerCsiHandler({final:"l"},(I=>this.resetMode(I))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(I=>this.resetModePrivate(I))),this._parser.registerCsiHandler({final:"m"},(I=>this.charAttributes(I))),this._parser.registerCsiHandler({final:"n"},(I=>this.deviceStatus(I))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(I=>this.deviceStatusPrivate(I))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(I=>this.softReset(I))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(I=>this.setCursorStyle(I))),this._parser.registerCsiHandler({final:"r"},(I=>this.setScrollRegion(I))),this._parser.registerCsiHandler({final:"s"},(I=>this.saveCursor(I))),this._parser.registerCsiHandler({final:"t"},(I=>this.windowOptions(I))),this._parser.registerCsiHandler({final:"u"},(I=>this.restoreCursor(I))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(I=>this.insertColumns(I))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(I=>this.deleteColumns(I))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(I=>this.selectProtected(I))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(I=>this.requestMode(I,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(I=>this.requestMode(I,!1))),this._parser.setExecuteHandler(f.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(f.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(f.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(f.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(f.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(f.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(f.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(f.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(f.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(f.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(f.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(f.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new L.OscHandler((I=>(this.setTitle(I),this.setIconName(I),!0)))),this._parser.registerOscHandler(1,new L.OscHandler((I=>this.setIconName(I)))),this._parser.registerOscHandler(2,new L.OscHandler((I=>this.setTitle(I)))),this._parser.registerOscHandler(4,new L.OscHandler((I=>this.setOrReportIndexedColor(I)))),this._parser.registerOscHandler(8,new L.OscHandler((I=>this.setHyperlink(I)))),this._parser.registerOscHandler(10,new L.OscHandler((I=>this.setOrReportFgColor(I)))),this._parser.registerOscHandler(11,new L.OscHandler((I=>this.setOrReportBgColor(I)))),this._parser.registerOscHandler(12,new L.OscHandler((I=>this.setOrReportCursorColor(I)))),this._parser.registerOscHandler(104,new L.OscHandler((I=>this.restoreIndexedColor(I)))),this._parser.registerOscHandler(110,new L.OscHandler((I=>this.restoreFgColor(I)))),this._parser.registerOscHandler(111,new L.OscHandler((I=>this.restoreBgColor(I)))),this._parser.registerOscHandler(112,new L.OscHandler((I=>this.restoreCursorColor(I)))),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 I in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:I},(()=>this.selectCharset("("+I))),this._parser.registerEscHandler({intermediates:")",final:I},(()=>this.selectCharset(")"+I))),this._parser.registerEscHandler({intermediates:"*",final:I},(()=>this.selectCharset("*"+I))),this._parser.registerEscHandler({intermediates:"+",final:I},(()=>this.selectCharset("+"+I))),this._parser.registerEscHandler({intermediates:"-",final:I},(()=>this.selectCharset("-"+I))),this._parser.registerEscHandler({intermediates:".",final:I},(()=>this.selectCharset("."+I))),this._parser.registerEscHandler({intermediates:"/",final:I},(()=>this.selectCharset("/"+I)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((I=>(this._logService.error("Parsing error: ",I),I))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new A.DcsHandler(((I,Q)=>this.requestStatusString(I,Q))))}_preserveStack(z,P,D,U){this._parseStack.paused=!0,this._parseStack.cursorStartX=z,this._parseStack.cursorStartY=P,this._parseStack.decodedLength=D,this._parseStack.position=U}_logSlowResolvingAsync(z){this._logService.logLevel<=E.LogLevelEnum.WARN&&Promise.race([z,new Promise(((P,D)=>setTimeout((()=>D("#SLOW_TIMEOUT")),5e3)))]).catch((P=>{if(P!=="#SLOW_TIMEOUT")throw P;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(z,P){let D,U=this._activeBuffer.x,$=this._activeBuffer.y,te=0;const q=this._parseStack.paused;if(q){if(D=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,P))return this._logSlowResolvingAsync(D),D;U=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,z.length>H&&(te=this._parseStack.position+H)}if(this._logService.logLevel<=E.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof z=="string"?` "${z}"`:` "${Array.prototype.map.call(z,(I=>String.fromCharCode(I))).join("")}"`),typeof z=="string"?z.split("").map((I=>I.charCodeAt(0))):z),this._parseBuffer.length<z.length&&this._parseBuffer.length<H&&(this._parseBuffer=new Uint32Array(Math.min(z.length,H))),q||this._dirtyRowTracker.clearRange(),z.length>H)for(let I=te;I<z.length;I+=H){const Q=I+H<z.length?I+H:z.length,ne=typeof z=="string"?this._stringDecoder.decode(z.substring(I,Q),this._parseBuffer):this._utf8Decoder.decode(z.subarray(I,Q),this._parseBuffer);if(D=this._parser.parse(this._parseBuffer,ne))return this._preserveStack(U,$,ne,I),this._logSlowResolvingAsync(D),D}else if(!q){const I=typeof z=="string"?this._stringDecoder.decode(z,this._parseBuffer):this._utf8Decoder.decode(z,this._parseBuffer);if(D=this._parser.parse(this._parseBuffer,I))return this._preserveStack(U,$,I,0),this._logSlowResolvingAsync(D),D}this._activeBuffer.x===U&&this._activeBuffer.y===$||this._onCursorMove.fire();const X=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),Y=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);Y<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(Y,this._bufferService.rows-1),Math.min(X,this._bufferService.rows-1))}print(z,P,D){let U,$;const te=this._charsetService.charset,q=this._optionsService.rawOptions.screenReaderMode,X=this._bufferService.cols,Y=this._coreService.decPrivateModes.wraparound,I=this._coreService.modes.insertMode,Q=this._curAttrData;let ne=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&D-P>0&&ne.getWidth(this._activeBuffer.x-1)===2&&ne.setCellFromCodepoint(this._activeBuffer.x-1,0,1,Q);let re=this._parser.precedingJoinState;for(let ie=P;ie<D;++ie){if(U=z[ie],U<127&&te){const $e=te[String.fromCharCode(U)];$e&&(U=$e.charCodeAt(0))}const pe=this._unicodeService.charProperties(U,re);$=T.UnicodeService.extractWidth(pe);const ye=T.UnicodeService.extractShouldJoin(pe),Ie=ye?T.UnicodeService.extractWidth(re):0;if(re=pe,q&&this._onA11yChar.fire((0,C.stringFromCodePoint)(U)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+$-Ie>X){if(Y){const $e=ne;let Se=this._activeBuffer.x-Ie;for(this._activeBuffer.x=Ie,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),Ie>0&&ne instanceof v.BufferLine&&ne.copyCellsFrom($e,Se,0,Ie,!1);Se<X;)$e.setCellFromCodepoint(Se++,0,1,Q)}else if(this._activeBuffer.x=X-1,$===2)continue}if(ye&&this._activeBuffer.x){const $e=ne.getWidth(this._activeBuffer.x-1)?1:2;ne.addCodepointToCell(this._activeBuffer.x-$e,U,$);for(let Se=$-Ie;--Se>=0;)ne.setCellFromCodepoint(this._activeBuffer.x++,0,0,Q)}else if(I&&(ne.insertCells(this._activeBuffer.x,$-Ie,this._activeBuffer.getNullCell(Q)),ne.getWidth(X-1)===2&&ne.setCellFromCodepoint(X-1,_.NULL_CELL_CODE,_.NULL_CELL_WIDTH,Q)),ne.setCellFromCodepoint(this._activeBuffer.x++,U,$,Q),$>0)for(;--$;)ne.setCellFromCodepoint(this._activeBuffer.x++,0,0,Q)}this._parser.precedingJoinState=re,this._activeBuffer.x<X&&D-P>0&&ne.getWidth(this._activeBuffer.x)===0&&!ne.hasContent(this._activeBuffer.x)&&ne.setCellFromCodepoint(this._activeBuffer.x,0,1,Q),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(z,P){return z.final!=="t"||z.prefix||z.intermediates?this._parser.registerCsiHandler(z,P):this._parser.registerCsiHandler(z,(D=>!B(D.params[0],this._optionsService.rawOptions.windowOptions)||P(D)))}registerDcsHandler(z,P){return this._parser.registerDcsHandler(z,new A.DcsHandler(P))}registerEscHandler(z,P){return this._parser.registerEscHandler(z,P)}registerOscHandler(z,P){return this._parser.registerOscHandler(z,new L.OscHandler(P))}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 z;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&&((z=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&z.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);P.hasWidth(this._activeBuffer.x)&&!P.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const z=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-z),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(z=this._bufferService.cols-1){this._activeBuffer.x=Math.min(z,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(z,P){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=z,this._activeBuffer.y=this._activeBuffer.scrollTop+P):(this._activeBuffer.x=z,this._activeBuffer.y=P),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(z,P){this._restrictCursor(),this._setCursor(this._activeBuffer.x+z,this._activeBuffer.y+P)}cursorUp(z){const P=this._activeBuffer.y-this._activeBuffer.scrollTop;return P>=0?this._moveCursor(0,-Math.min(P,z.params[0]||1)):this._moveCursor(0,-(z.params[0]||1)),!0}cursorDown(z){const P=this._activeBuffer.scrollBottom-this._activeBuffer.y;return P>=0?this._moveCursor(0,Math.min(P,z.params[0]||1)):this._moveCursor(0,z.params[0]||1),!0}cursorForward(z){return this._moveCursor(z.params[0]||1,0),!0}cursorBackward(z){return this._moveCursor(-(z.params[0]||1),0),!0}cursorNextLine(z){return this.cursorDown(z),this._activeBuffer.x=0,!0}cursorPrecedingLine(z){return this.cursorUp(z),this._activeBuffer.x=0,!0}cursorCharAbsolute(z){return this._setCursor((z.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(z){return this._setCursor(z.length>=2?(z.params[1]||1)-1:0,(z.params[0]||1)-1),!0}charPosAbsolute(z){return this._setCursor((z.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(z){return this._moveCursor(z.params[0]||1,0),!0}linePosAbsolute(z){return this._setCursor(this._activeBuffer.x,(z.params[0]||1)-1),!0}vPositionRelative(z){return this._moveCursor(0,z.params[0]||1),!0}hVPosition(z){return this.cursorPosition(z),!0}tabClear(z){const P=z.params[0];return P===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:P===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(z){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=z.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(z){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=z.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(z){const P=z.params[0];return P===1&&(this._curAttrData.bg|=536870912),P!==2&&P!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(z,P,D,U=!1,$=!1){const te=this._activeBuffer.lines.get(this._activeBuffer.ybase+z);te.replaceCells(P,D,this._activeBuffer.getNullCell(this._eraseAttrData()),$),U&&(te.isWrapped=!1)}_resetBufferLine(z,P=!1){const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+z);D&&(D.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),P),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+z),D.isWrapped=!1)}eraseInDisplay(z,P=!1){let D;switch(this._restrictCursor(this._bufferService.cols),z.params[0]){case 0:for(D=this._activeBuffer.y,this._dirtyRowTracker.markDirty(D),this._eraseInBufferLine(D++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);D<this._bufferService.rows;D++)this._resetBufferLine(D,P);this._dirtyRowTracker.markDirty(D);break;case 1:for(D=this._activeBuffer.y,this._dirtyRowTracker.markDirty(D),this._eraseInBufferLine(D,0,this._activeBuffer.x+1,!0,P),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(D+1).isWrapped=!1);D--;)this._resetBufferLine(D,P);this._dirtyRowTracker.markDirty(0);break;case 2:for(D=this._bufferService.rows,this._dirtyRowTracker.markDirty(D-1);D--;)this._resetBufferLine(D,P);this._dirtyRowTracker.markDirty(0);break;case 3:const U=this._activeBuffer.lines.length-this._bufferService.rows;U>0&&(this._activeBuffer.lines.trimStart(U),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-U,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-U,0),this._onScroll.fire(0))}return!0}eraseInLine(z,P=!1){switch(this._restrictCursor(this._bufferService.cols),z.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,P);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,P)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(z){this._restrictCursor();let P=z.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=this._activeBuffer.ybase+this._activeBuffer.y,U=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-U+1;for(;P--;)this._activeBuffer.lines.splice($-1,1),this._activeBuffer.lines.splice(D,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(z){this._restrictCursor();let P=z.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=this._activeBuffer.ybase+this._activeBuffer.y;let U;for(U=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-U;P--;)this._activeBuffer.lines.splice(D,1),this._activeBuffer.lines.splice(U,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(z){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.insertCells(this._activeBuffer.x,z.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(z){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.deleteCells(this._activeBuffer.x,z.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(z){let P=z.params[0]||1;for(;P--;)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(z){let P=z.params[0]||1;for(;P--;)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(z){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=z.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);U.deleteCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData())),U.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(z){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=z.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);U.insertCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData())),U.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(z){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=z.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);U.insertCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData())),U.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(z){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=z.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);U.deleteCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData())),U.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(z){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(z.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(z){const P=this._parser.precedingJoinState;if(!P)return!0;const D=z.params[0]||1,U=T.UnicodeService.extractWidth(P),$=this._activeBuffer.x-U,te=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString($),q=new Uint32Array(te.length*D);let X=0;for(let I=0;I<te.length;){const Q=te.codePointAt(I)||0;q[X++]=Q,I+=Q>65535?2:1}let Y=X;for(let I=1;I<D;++I)q.copyWithin(Y,0,X),Y+=X;return this.print(q,0,Y),!0}sendDeviceAttributesPrimary(z){return z.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(f.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(f.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(z){return z.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(f.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(f.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(z.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(f.C0.ESC+"[>83;40003;0c")),!0}_is(z){return(this._optionsService.rawOptions.termName+"").indexOf(z)===0}setMode(z){for(let P=0;P<z.length;P++)switch(z.params[P]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(z){for(let P=0;P<z.length;P++)switch(z.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.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(z){for(let P=0;P<z.length;P++)switch(z.params[P]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(z){for(let P=0;P<z.length;P++)switch(z.params[P]){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(),z.params[P]===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(z,P){const D=this._coreService.decPrivateModes,{activeProtocol:U,activeEncoding:$}=this._coreMouseService,te=this._coreService,{buffers:q,cols:X}=this._bufferService,{active:Y,alt:I}=q,Q=this._optionsService.rawOptions,ne=ye=>ye?1:2,re=z.params[0];return ie=re,pe=P?re===2?4:re===4?ne(te.modes.insertMode):re===12?3:re===20?ne(Q.convertEol):0:re===1?ne(D.applicationCursorKeys):re===3?Q.windowOptions.setWinLines?X===80?2:X===132?1:0:0:re===6?ne(D.origin):re===7?ne(D.wraparound):re===8?3:re===9?ne(U==="X10"):re===12?ne(Q.cursorBlink):re===25?ne(!te.isCursorHidden):re===45?ne(D.reverseWraparound):re===66?ne(D.applicationKeypad):re===67?4:re===1e3?ne(U==="VT200"):re===1002?ne(U==="DRAG"):re===1003?ne(U==="ANY"):re===1004?ne(D.sendFocus):re===1005?4:re===1006?ne($==="SGR"):re===1015?4:re===1016?ne($==="SGR_PIXELS"):re===1048?1:re===47||re===1047||re===1049?ne(Y===I):re===2004?ne(D.bracketedPasteMode):0,te.triggerDataEvent(`${f.C0.ESC}[${P?"":"?"}${ie};${pe}$y`),!0;var ie,pe}_updateAttrColor(z,P,D,U,$){return P===2?(z|=50331648,z&=-16777216,z|=k.AttributeData.fromColorRGB([D,U,$])):P===5&&(z&=-50331904,z|=33554432|255&D),z}_extractColor(z,P,D){const U=[0,0,-1,0,0,0];let $=0,te=0;do{if(U[te+$]=z.params[P+te],z.hasSubParams(P+te)){const q=z.getSubParams(P+te);let X=0;do U[1]===5&&($=1),U[te+X+1+$]=q[X];while(++X<q.length&&X+te+1+$<U.length);break}if(U[1]===5&&te+$>=2||U[1]===2&&te+$>=5)break;U[1]&&($=1)}while(++te+P<z.length&&te+$<U.length);for(let q=2;q<U.length;++q)U[q]===-1&&(U[q]=0);switch(U[0]){case 38:D.fg=this._updateAttrColor(D.fg,U[1],U[3],U[4],U[5]);break;case 48:D.bg=this._updateAttrColor(D.bg,U[1],U[3],U[4],U[5]);break;case 58:D.extended=D.extended.clone(),D.extended.underlineColor=this._updateAttrColor(D.extended.underlineColor,U[1],U[3],U[4],U[5])}return te}_processUnderline(z,P){P.extended=P.extended.clone(),(!~z||z>5)&&(z=1),P.extended.underlineStyle=z,P.fg|=268435456,z===0&&(P.fg&=-268435457),P.updateExtended()}_processSGR0(z){z.fg=v.DEFAULT_ATTR_DATA.fg,z.bg=v.DEFAULT_ATTR_DATA.bg,z.extended=z.extended.clone(),z.extended.underlineStyle=0,z.extended.underlineColor&=-67108864,z.updateExtended()}charAttributes(z){if(z.length===1&&z.params[0]===0)return this._processSGR0(this._curAttrData),!0;const P=z.length;let D;const U=this._curAttrData;for(let $=0;$<P;$++)D=z.params[$],D>=30&&D<=37?(U.fg&=-50331904,U.fg|=16777216|D-30):D>=40&&D<=47?(U.bg&=-50331904,U.bg|=16777216|D-40):D>=90&&D<=97?(U.fg&=-50331904,U.fg|=16777224|D-90):D>=100&&D<=107?(U.bg&=-50331904,U.bg|=16777224|D-100):D===0?this._processSGR0(U):D===1?U.fg|=134217728:D===3?U.bg|=67108864:D===4?(U.fg|=268435456,this._processUnderline(z.hasSubParams($)?z.getSubParams($)[0]:1,U)):D===5?U.fg|=536870912:D===7?U.fg|=67108864:D===8?U.fg|=1073741824:D===9?U.fg|=2147483648:D===2?U.bg|=134217728:D===21?this._processUnderline(2,U):D===22?(U.fg&=-134217729,U.bg&=-134217729):D===23?U.bg&=-67108865:D===24?(U.fg&=-268435457,this._processUnderline(0,U)):D===25?U.fg&=-536870913:D===27?U.fg&=-67108865:D===28?U.fg&=-1073741825:D===29?U.fg&=2147483647:D===39?(U.fg&=-67108864,U.fg|=16777215&v.DEFAULT_ATTR_DATA.fg):D===49?(U.bg&=-67108864,U.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):D===38||D===48||D===58?$+=this._extractColor(z,$,U):D===53?U.bg|=1073741824:D===55?U.bg&=-1073741825:D===59?(U.extended=U.extended.clone(),U.extended.underlineColor=-1,U.updateExtended()):D===100?(U.fg&=-67108864,U.fg|=16777215&v.DEFAULT_ATTR_DATA.fg,U.bg&=-67108864,U.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",D);return!0}deviceStatus(z){switch(z.params[0]){case 5:this._coreService.triggerDataEvent(`${f.C0.ESC}[0n`);break;case 6:const P=this._activeBuffer.y+1,D=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${f.C0.ESC}[${P};${D}R`)}return!0}deviceStatusPrivate(z){if(z.params[0]===6){const P=this._activeBuffer.y+1,D=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${f.C0.ESC}[?${P};${D}R`)}return!0}softReset(z){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(z){const P=z.params[0]||1;switch(P){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 D=P%2==1;return this._optionsService.options.cursorBlink=D,!0}setScrollRegion(z){const P=z.params[0]||1;let D;return(z.length<2||(D=z.params[1])>this._bufferService.rows||D===0)&&(D=this._bufferService.rows),D>P&&(this._activeBuffer.scrollTop=P-1,this._activeBuffer.scrollBottom=D-1,this._setCursor(0,0)),!0}windowOptions(z){if(!B(z.params[0],this._optionsService.rawOptions.windowOptions))return!0;const P=z.length>1?z.params[1]:0;switch(z.params[0]){case 14:P!==2&&this._onRequestWindowsOptionsReport.fire(F.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(F.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${f.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:P!==0&&P!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),P!==0&&P!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:P!==0&&P!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),P!==0&&P!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(z){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(z){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(z){return this._windowTitle=z,this._onTitleChange.fire(z),!0}setIconName(z){return this._iconName=z,!0}setOrReportIndexedColor(z){const P=[],D=z.split(";");for(;D.length>1;){const U=D.shift(),$=D.shift();if(/^\d+$/.exec(U)){const te=parseInt(U);if(Z(te))if($==="?")P.push({type:0,index:te});else{const q=(0,O.parseColor)($);q&&P.push({type:1,index:te,color:q})}}}return P.length&&this._onColor.fire(P),!0}setHyperlink(z){const P=z.split(";");return!(P.length<2)&&(P[1]?this._createHyperlink(P[0],P[1]):!P[0]&&this._finishHyperlink())}_createHyperlink(z,P){this._getCurrentLinkId()&&this._finishHyperlink();const D=z.split(":");let U;const $=D.findIndex((te=>te.startsWith("id=")));return $!==-1&&(U=D[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:U,uri:P}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(z,P){const D=z.split(";");for(let U=0;U<D.length&&!(P>=this._specialColors.length);++U,++P)if(D[U]==="?")this._onColor.fire([{type:0,index:this._specialColors[P]}]);else{const $=(0,O.parseColor)(D[U]);$&&this._onColor.fire([{type:1,index:this._specialColors[P],color:$}])}return!0}setOrReportFgColor(z){return this._setOrReportSpecialColor(z,0)}setOrReportBgColor(z){return this._setOrReportSpecialColor(z,1)}setOrReportCursorColor(z){return this._setOrReportSpecialColor(z,2)}restoreIndexedColor(z){if(!z)return this._onColor.fire([{type:2}]),!0;const P=[],D=z.split(";");for(let U=0;U<D.length;++U)if(/^\d+$/.exec(D[U])){const $=parseInt(D[U]);Z($)&&P.push({type:2,index:$})}return P.length&&this._onColor.fire(P),!0}restoreFgColor(z){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(z){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(z){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,g.DEFAULT_CHARSET),!0}selectCharset(z){return z.length!==2?(this.selectDefaultCharset(),!0):(z[0]==="/"||this._charsetService.setgCharset(M[z[0]],g.CHARSETS[z[1]]||g.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 z=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,z,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(z){return this._charsetService.setgLevel(z),!0}screenAlignmentPattern(){const z=new b.CellData;z.content=4194373,z.fg=this._curAttrData.fg,z.bg=this._curAttrData.bg,this._setCursor(0,0);for(let P=0;P<this._bufferService.rows;++P){const D=this._activeBuffer.ybase+this._activeBuffer.y+P,U=this._activeBuffer.lines.get(D);U&&(U.fill(z),U.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(z,P){const D=this._bufferService.buffer,U=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${f.C0.ESC}${$}${f.C0.ESC}\\`),!0))(z==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:z==='"p'?'P1$r61;1"p':z==="r"?`P1$r${D.scrollTop+1};${D.scrollBottom+1}r`:z==="m"?"P1$r0m":z===" q"?`P1$r${{block:2,underline:4,bar:6}[U.cursorStyle]-(U.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(z,P){this._dirtyRowTracker.markRangeDirty(z,P)}}u.InputHandler=G;let V=class{constructor(J){this._bufferService=J,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(J){J<this.start?this.start=J:J>this.end&&(this.end=J)}markRangeDirty(J,z){J>z&&(K=J,J=z,z=K),J<this.start&&(this.start=J),z>this.end&&(this.end=z)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Z(J){return 0<=J&&J<256}V=h([m(0,E.IBufferService)],V)},844:(c,u)=>{function d(h){for(const m of h)m.dispose();h.length=0}Object.defineProperty(u,"__esModule",{value:!0}),u.getDisposeArrayDisposable=u.disposeArray=u.toDisposable=u.MutableDisposable=u.Disposable=void 0,u.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 m=this._disposables.indexOf(h);m!==-1&&this._disposables.splice(m,1)}},u.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(h){var m;this._isDisposed||h===this._value||((m=this._value)==null||m.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}},u.toDisposable=function(h){return{dispose:h}},u.disposeArray=d,u.getDisposeArrayDisposable=function(h){return{dispose:()=>d(h)}}},1505:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.FourKeyMap=u.TwoKeyMap=void 0;class d{constructor(){this._data={}}set(m,f,g){this._data[m]||(this._data[m]={}),this._data[m][f]=g}get(m,f){return this._data[m]?this._data[m][f]:void 0}clear(){this._data={}}}u.TwoKeyMap=d,u.FourKeyMap=class{constructor(){this._data=new d}set(h,m,f,g,x){this._data.get(h,m)||this._data.set(h,m,new d),this._data.get(h,m).set(f,g,x)}get(h,m,f,g){var x;return(x=this._data.get(h,m))==null?void 0:x.get(f,g)}clear(){this._data.clear()}}},6114:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.isChromeOS=u.isLinux=u.isWindows=u.isIphone=u.isIpad=u.isMac=u.getSafariVersion=u.isSafari=u.isLegacyEdge=u.isFirefox=u.isNode=void 0,u.isNode=typeof process<"u"&&"title"in process;const d=u.isNode?"node":navigator.userAgent,h=u.isNode?"node":navigator.platform;u.isFirefox=d.includes("Firefox"),u.isLegacyEdge=d.includes("Edge"),u.isSafari=/^((?!chrome|android).)*safari/i.test(d),u.getSafariVersion=function(){if(!u.isSafari)return 0;const m=d.match(/Version\/(\d+)/);return m===null||m.length<2?0:parseInt(m[1])},u.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(h),u.isIpad=h==="iPad",u.isIphone=h==="iPhone",u.isWindows=["Windows","Win16","Win32","WinCE"].includes(h),u.isLinux=h.indexOf("Linux")>=0,u.isChromeOS=/\bCrOS\b/.test(d)},6106:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.SortedList=void 0;let d=0;u.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 m=this._getKey(h);if(m===void 0||(d=this._search(m),d===-1)||this._getKey(this._array[d])!==m)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])===m);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,m){if(this._array.length!==0&&(d=this._search(h),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===h))do m(this._array[d]);while(++d<this._array.length&&this._getKey(this._array[d])===h)}values(){return[...this._array].values()}_search(h){let m=0,f=this._array.length-1;for(;f>=m;){let g=m+f>>1;const x=this._getKey(this._array[g]);if(x>h)f=g-1;else{if(!(x<h)){for(;g>0&&this._getKey(this._array[g-1])===h;)g--;return g}m=g+1}}return m}}},7226:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DebouncedIdleTask=u.IdleTaskQueue=u.PriorityTaskQueue=void 0;const h=d(6114);class m{constructor(){this._tasks=[],this._i=0}enqueue(x){this._tasks.push(x),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(x){this._idleCallback=void 0;let w=0,C=0,v=x.timeRemaining(),S=0;for(;this._i<this._tasks.length;){if(w=Date.now(),this._tasks[this._i]()||this._i++,w=Math.max(1,Date.now()-w),C=Math.max(w,C),S=x.timeRemaining(),1.5*C>S)return v-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(v-w))}ms`),void this._start();v=S}this.clear()}}class f extends m{_requestCallback(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const w=Date.now()+x;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}u.PriorityTaskQueue=f,u.IdleTaskQueue=!h.isNode&&"requestIdleCallback"in window?class extends m{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:f,u.DebouncedIdleTask=class{constructor(){this._queue=new u.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.updateWindowsModeWrappedState=void 0;const h=d(643);u.updateWindowsModeWrappedState=function(m){const f=m.buffer.lines.get(m.buffer.ybase+m.buffer.y-1),g=f==null?void 0:f.get(m.cols-1),x=m.buffer.lines.get(m.buffer.ybase+m.buffer.y);x&&g&&(x.isWrapped=g[h.CHAR_DATA_CODE_INDEX]!==h.NULL_CELL_CODE&&g[h.CHAR_DATA_CODE_INDEX]!==h.WHITESPACE_CELL_CODE)}},3734:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ExtendedAttrs=u.AttributeData=void 0;class d{constructor(){this.fg=0,this.bg=0,this.extended=new h}static toColorRGB(f){return[f>>>16&255,f>>>8&255,255&f]}static fromColorRGB(f){return(255&f[0])<<16|(255&f[1])<<8|255&f[2]}clone(){const f=new d;return f.fg=this.fg,f.bg=this.bg,f.extended=this.extended.clone(),f}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}}u.AttributeData=d;class h{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(f){this._ext=f}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(f){this._ext&=-469762049,this._ext|=f<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(f){this._ext&=-67108864,this._ext|=67108863&f}get urlId(){return this._urlId}set urlId(f){this._urlId=f}get underlineVariantOffset(){const f=(3758096384&this._ext)>>29;return f<0?4294967288^f:f}set underlineVariantOffset(f){this._ext&=536870911,this._ext|=f<<29&3758096384}constructor(f=0,g=0){this._ext=0,this._urlId=0,this._ext=f,this._urlId=g}clone(){return new h(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}u.ExtendedAttrs=h},9092:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Buffer=u.MAX_BUFFER_SIZE=void 0;const h=d(6349),m=d(7226),f=d(3734),g=d(8437),x=d(4634),w=d(511),C=d(643),v=d(4863),S=d(7116);u.MAX_BUFFER_SIZE=4294967295,u.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=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=S.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,C.WHITESPACE_CELL_CHAR,C.WHITESPACE_CELL_WIDTH,C.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new m.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 f.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 f.ExtendedAttrs),this._whitespaceCell}getBlankLine(_,b){return new g.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>u.MAX_BUFFER_SIZE?u.MAX_BUFFER_SIZE:b}fillViewportRows(_){if(this.lines.length===0){_===void 0&&(_=g.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(g.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 A=0;A<this.lines.length;A++)E+=+this.lines.get(A).resize(_,k);let L=0;if(this._rows<b)for(let A=this._rows;A<b;A++)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 g.BufferLine(_,k)):this.ybase>0&&this.lines.length<=this.ybase+this.y+L+1?(this.ybase--,L++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(_,k)));else for(let A=this._rows;A>b;A--)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 A=this.lines.length-T;A>0&&(this.lines.trimStart(A),this.ybase=Math.max(this.ybase-A,0),this.ydisp=Math.max(this.ydisp-A,0),this.savedY=Math.max(this.savedY-A,0)),this.lines.maxLength=T}this.x=Math.min(this.x,_-1),this.y=Math.min(this.y,b-1),L&&(this.y+=L),this.savedX=Math.min(this.savedX,_-1),this.scrollTop=0}if(this.scrollBottom=b-1,this._isReflowEnabled&&(this._reflow(_,b),this._cols>_))for(let L=0;L<this.lines.length;L++)E+=+this.lines.get(L).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,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,_,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(k.length>0){const E=(0,x.reflowLargerCreateNewLayout)(this.lines,k);(0,x.reflowLargerApplyNewLayout)(this.lines,E.layout),this._reflowLargerAdjustViewport(_,b,E.countRemoved)}}_reflowLargerAdjustViewport(_,b,k){const E=this.getNullCell(g.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 g.BufferLine(_,E))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-k,0)}_reflowSmaller(_,b){const k=this.getNullCell(g.DEFAULT_ATTR_DATA),E=[];let T=0;for(let L=this.lines.length-1;L>=0;L--){let A=this.lines.get(L);if(!A||!A.isWrapped&&A.getTrimmedLength()<=_)continue;const O=[A];for(;A.isWrapped&&L>0;)A=this.lines.get(--L),O.unshift(A);const M=this.ybase+this.y;if(M>=L&&M<L+O.length)continue;const H=O[O.length-1].getTrimmedLength(),B=(0,x.reflowSmallerGetNewLineLengths)(O,this._cols,_),F=B.length-O.length;let K;K=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+F):Math.max(0,this.lines.length-this.lines.maxLength+F);const G=[];for(let D=0;D<F;D++){const U=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);G.push(U)}G.length>0&&(E.push({start:L+O.length+T,newLines:G}),T+=G.length),O.push(...G);let V=B.length-1,Z=B[V];Z===0&&(V--,Z=B[V]);let J=O.length-F-1,z=H;for(;J>=0;){const D=Math.min(z,Z);if(O[V]===void 0)break;if(O[V].copyCellsFrom(O[J],z-D,Z-D,D,!0),Z-=D,Z===0&&(V--,Z=B[V]),z-=D,z===0){J--;const U=Math.max(J,0);z=(0,x.getWrappedLineTrimmedLength)(O,U,this._cols)}}for(let D=0;D<O.length;D++)B[D]<_&&O[D].setCell(B[D],k);let P=F-K;for(;P-- >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+F,this.ybase+b-1)}if(E.length>0){const L=[],A=[];for(let V=0;V<this.lines.length;V++)A.push(this.lines.get(V));const O=this.lines.length;let M=O-1,H=0,B=E[H];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+T);let F=0;for(let V=Math.min(this.lines.maxLength-1,O+T-1);V>=0;V--)if(B&&B.start>M+F){for(let Z=B.newLines.length-1;Z>=0;Z--)this.lines.set(V--,B.newLines[Z]);V++,L.push({index:M+1,amount:B.newLines.length}),F+=B.newLines.length,B=E[++H]}else this.lines.set(V,A[M--]);let K=0;for(let V=L.length-1;V>=0;V--)L[V].index+=K,this.lines.onInsertEmitter.fire(L[V]),K+=L[V].amount;const G=Math.max(0,O+T-this.lines.maxLength);G>0&&this.lines.onTrimEmitter.fire(G)}}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:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferLine=u.DEFAULT_ATTR_DATA=void 0;const h=d(3734),m=d(511),f=d(643),g=d(482);u.DEFAULT_ATTR_DATA=Object.freeze(new h.AttributeData);let x=0;class w{constructor(v,S,_=!1){this.isWrapped=_,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*v);const b=S||m.CellData.fromCharData([0,f.NULL_CELL_CHAR,f.NULL_CELL_WIDTH,f.NULL_CELL_CODE]);for(let k=0;k<v;++k)this.setCell(k,b);this.length=v}get(v){const S=this._data[3*v+0],_=2097151&S;return[this._data[3*v+1],2097152&S?this._combined[v]:_?(0,g.stringFromCodePoint)(_):"",S>>22,2097152&S?this._combined[v].charCodeAt(this._combined[v].length-1):_]}set(v,S){this._data[3*v+1]=S[f.CHAR_DATA_ATTR_INDEX],S[f.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[v]=S[1],this._data[3*v+0]=2097152|v|S[f.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*v+0]=S[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[f.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 S=this._data[3*v+0];return 2097152&S?this._combined[v].charCodeAt(this._combined[v].length-1):2097151&S}isCombined(v){return 2097152&this._data[3*v+0]}getString(v){const S=this._data[3*v+0];return 2097152&S?this._combined[v]:2097151&S?(0,g.stringFromCodePoint)(2097151&S):""}isProtected(v){return 536870912&this._data[3*v+2]}loadCell(v,S){return x=3*v,S.content=this._data[x+0],S.fg=this._data[x+1],S.bg=this._data[x+2],2097152&S.content&&(S.combinedData=this._combined[v]),268435456&S.bg&&(S.extended=this._extendedAttrs[v]),S}setCell(v,S){2097152&S.content&&(this._combined[v]=S.combinedData),268435456&S.bg&&(this._extendedAttrs[v]=S.extended),this._data[3*v+0]=S.content,this._data[3*v+1]=S.fg,this._data[3*v+2]=S.bg}setCellFromCodepoint(v,S,_,b){268435456&b.bg&&(this._extendedAttrs[v]=b.extended),this._data[3*v+0]=S|_<<22,this._data[3*v+1]=b.fg,this._data[3*v+2]=b.bg}addCodepointToCell(v,S,_){let b=this._data[3*v+0];2097152&b?this._combined[v]+=(0,g.stringFromCodePoint)(S):2097151&b?(this._combined[v]=(0,g.stringFromCodePoint)(2097151&b)+(0,g.stringFromCodePoint)(S),b&=-2097152,b|=2097152):b=S|4194304,_&&(b&=-12582913,b|=_<<22),this._data[3*v+0]=b}insertCells(v,S,_){if((v%=this.length)&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,_),S<this.length-v){const b=new m.CellData;for(let k=this.length-v-S-1;k>=0;--k)this.setCell(v+S+k,this.loadCell(v+k,b));for(let k=0;k<S;++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,S,_){if(v%=this.length,S<this.length-v){const b=new m.CellData;for(let k=0;k<this.length-v-S;++k)this.setCell(v+k,this.loadCell(v+S+k,b));for(let k=this.length-S;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,S,_,b=!1){if(b)for(v&&this.getWidth(v-1)===2&&!this.isProtected(v-1)&&this.setCellFromCodepoint(v-1,0,1,_),S<this.length&&this.getWidth(S-1)===2&&!this.isProtected(S)&&this.setCellFromCodepoint(S,0,1,_);v<S&&v<this.length;)this.isProtected(v)||this.setCell(v,_),v++;else for(v&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,_),S<this.length&&this.getWidth(S-1)===2&&this.setCellFromCodepoint(S,0,1,_);v<S&&v<this.length;)this.setCell(v++,_)}resize(v,S){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,S)}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,S=!1){if(S)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 S in v._combined)this._combined[S]=v._combined[S];this._extendedAttrs={};for(const S in v._extendedAttrs)this._extendedAttrs[S]=v._extendedAttrs[S];this.isWrapped=v.isWrapped}clone(){const v=new w(0);v._data=new Uint32Array(this._data),v.length=this.length;for(const S in this._combined)v._combined[S]=this._combined[S];for(const S in this._extendedAttrs)v._extendedAttrs[S]=this._extendedAttrs[S];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,S,_,b,k){const E=v._data;if(k)for(let L=b-1;L>=0;L--){for(let A=0;A<3;A++)this._data[3*(_+L)+A]=E[3*(S+L)+A];268435456&E[3*(S+L)+2]&&(this._extendedAttrs[_+L]=v._extendedAttrs[S+L])}else for(let L=0;L<b;L++){for(let A=0;A<3;A++)this._data[3*(_+L)+A]=E[3*(S+L)+A];268435456&E[3*(S+L)+2]&&(this._extendedAttrs[_+L]=v._extendedAttrs[S+L])}const T=Object.keys(v._combined);for(let L=0;L<T.length;L++){const A=parseInt(T[L],10);A>=S&&(this._combined[A-S+_]=v._combined[A])}}translateToString(v,S,_,b){S=S??0,_=_??this.length,v&&(_=Math.min(_,this.getTrimmedLength())),b&&(b.length=0);let k="";for(;S<_;){const E=this._data[3*S+0],T=2097151&E,L=2097152&E?this._combined[S]:T?(0,g.stringFromCodePoint)(T):f.WHITESPACE_CELL_CHAR;if(k+=L,b)for(let A=0;A<L.length;++A)b.push(S);S+=E>>22||1}return b&&b.push(S),k}}u.BufferLine=w},4841:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.getRangeLength=void 0,u.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:(c,u)=>{function d(h,m,f){if(m===h.length-1)return h[m].getTrimmedLength();const g=!h[m].hasContent(f-1)&&h[m].getWidth(f-1)===1,x=h[m+1].getWidth(0)===2;return g&&x?f-1:f}Object.defineProperty(u,"__esModule",{value:!0}),u.getWrappedLineTrimmedLength=u.reflowSmallerGetNewLineLengths=u.reflowLargerApplyNewLayout=u.reflowLargerCreateNewLayout=u.reflowLargerGetLinesToRemove=void 0,u.reflowLargerGetLinesToRemove=function(h,m,f,g,x){const w=[];for(let C=0;C<h.length-1;C++){let v=C,S=h.get(++v);if(!S.isWrapped)continue;const _=[h.get(C)];for(;v<h.length&&S.isWrapped;)_.push(S),S=h.get(++v);if(g>=C&&g<v){C+=_.length-1;continue}let b=0,k=d(_,b,m),E=1,T=0;for(;E<_.length;){const A=d(_,E,m),O=A-T,M=f-k,H=Math.min(O,M);_[b].copyCellsFrom(_[E],T,k,H,!1),k+=H,k===f&&(b++,k=0),T+=H,T===A&&(E++,T=0),k===0&&b!==0&&_[b-1].getWidth(f-1)===2&&(_[b].copyCellsFrom(_[b-1],f-1,k++,1,!1),_[b-1].setCell(f-1,x))}_[b].replaceCells(k,f,x);let L=0;for(let A=_.length-1;A>0&&(A>b||_[A].getTrimmedLength()===0);A--)L++;L>0&&(w.push(C+_.length-L),w.push(L)),C+=_.length-1}return w},u.reflowLargerCreateNewLayout=function(h,m){const f=[];let g=0,x=m[g],w=0;for(let C=0;C<h.length;C++)if(x===C){const v=m[++g];h.onDeleteEmitter.fire({index:C-w,amount:v}),C+=v-1,w+=v,x=m[++g]}else f.push(C);return{layout:f,countRemoved:w}},u.reflowLargerApplyNewLayout=function(h,m){const f=[];for(let g=0;g<m.length;g++)f.push(h.get(m[g]));for(let g=0;g<f.length;g++)h.set(g,f[g]);h.length=m.length},u.reflowSmallerGetNewLineLengths=function(h,m,f){const g=[],x=h.map(((S,_)=>d(h,_,m))).reduce(((S,_)=>S+_));let w=0,C=0,v=0;for(;v<x;){if(x-v<f){g.push(x-v);break}w+=f;const S=d(h,C,m);w>S&&(w-=S,C++);const _=h[C].getWidth(w-1)===2;_&&w--;const b=_?f-1:f;g.push(b),v+=b}return g},u.getWrappedLineTrimmedLength=d},5295:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferSet=void 0;const h=d(8460),m=d(844),f=d(9092);class g extends m.Disposable{constructor(w,C){super(),this._optionsService=w,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 f.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new f.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(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),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(w,C){this._normal.resize(w,C),this._alt.resize(w,C),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}u.BufferSet=g},511:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CellData=void 0;const h=d(482),m=d(643),f=d(3734);class g extends f.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new f.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const C=new g;return C.setFromCharData(w),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(w){this.fg=w[m.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(w[m.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(w[m.CHAR_DATA_CHAR_INDEX].length===2){const v=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=v&&v<=56319){const S=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=S&&S<=57343?this.content=1024*(v-55296)+S-56320+65536|w[m.CHAR_DATA_WIDTH_INDEX]<<22:C=!0}else C=!0}else this.content=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[m.CHAR_DATA_WIDTH_INDEX]<<22;C&&(this.combinedData=w[m.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[m.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}u.CellData=g},643:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.WHITESPACE_CELL_CODE=u.WHITESPACE_CELL_WIDTH=u.WHITESPACE_CELL_CHAR=u.NULL_CELL_CODE=u.NULL_CELL_WIDTH=u.NULL_CELL_CHAR=u.CHAR_DATA_CODE_INDEX=u.CHAR_DATA_WIDTH_INDEX=u.CHAR_DATA_CHAR_INDEX=u.CHAR_DATA_ATTR_INDEX=u.DEFAULT_EXT=u.DEFAULT_ATTR=u.DEFAULT_COLOR=void 0,u.DEFAULT_COLOR=0,u.DEFAULT_ATTR=256|u.DEFAULT_COLOR<<9,u.DEFAULT_EXT=0,u.CHAR_DATA_ATTR_INDEX=0,u.CHAR_DATA_CHAR_INDEX=1,u.CHAR_DATA_WIDTH_INDEX=2,u.CHAR_DATA_CODE_INDEX=3,u.NULL_CELL_CHAR="",u.NULL_CELL_WIDTH=1,u.NULL_CELL_CODE=0,u.WHITESPACE_CELL_CHAR=" ",u.WHITESPACE_CELL_WIDTH=1,u.WHITESPACE_CELL_CODE=32},4863:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Marker=void 0;const h=d(8460),m=d(844);class f{get id(){return this._id}constructor(x){this.line=x,this.isDisposed=!1,this._disposables=[],this._id=f._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,m.disposeArray)(this._disposables),this._disposables.length=0)}register(x){return this._disposables.push(x),x}}u.Marker=f,f._nextId=1},7116:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DEFAULT_CHARSET=u.CHARSETS=void 0,u.CHARSETS={},u.DEFAULT_CHARSET=u.CHARSETS.B,u.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:"≥","{":"π","|":"≠","}":"£","~":"·"},u.CHARSETS.A={"#":"£"},u.CHARSETS.B=void 0,u.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},u.CHARSETS.C=u.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},u.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},u.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},u.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},u.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},u.CHARSETS.E=u.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},u.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},u.CHARSETS.H=u.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},u.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(c,u)=>{var d,h,m;Object.defineProperty(u,"__esModule",{value:!0}),u.C1_ESCAPED=u.C1=u.C0=void 0,(function(f){f.NUL="\0",f.SOH="",f.STX="",f.ETX="",f.EOT="",f.ENQ="",f.ACK="",f.BEL="\x07",f.BS="\b",f.HT=" ",f.LF=`
|
|
260
|
+
`,f.VT="\v",f.FF="\f",f.CR="\r",f.SO="",f.SI="",f.DLE="",f.DC1="",f.DC2="",f.DC3="",f.DC4="",f.NAK="",f.SYN="",f.ETB="",f.CAN="",f.EM="",f.SUB="",f.ESC="\x1B",f.FS="",f.GS="",f.RS="",f.US="",f.SP=" ",f.DEL=""})(d||(u.C0=d={})),(function(f){f.PAD="",f.HOP="",f.BPH="",f.NBH="",f.IND="",f.NEL="
",f.SSA="",f.ESA="",f.HTS="",f.HTJ="",f.VTS="",f.PLD="",f.PLU="",f.RI="",f.SS2="",f.SS3="",f.DCS="",f.PU1="",f.PU2="",f.STS="",f.CCH="",f.MW="",f.SPA="",f.EPA="",f.SOS="",f.SGCI="",f.SCI="",f.CSI="",f.ST="",f.OSC="",f.PM="",f.APC=""})(h||(u.C1=h={})),(function(f){f.ST=`${d.ESC}\\`})(m||(u.C1_ESCAPED=m={}))},7399:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.evaluateKeyboardEvent=void 0;const h=d(2584),m={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:["'",'"']};u.evaluateKeyboardEvent=function(f,g,x,w){const C={type:0,cancel:!1,key:void 0},v=(f.shiftKey?1:0)|(f.altKey?2:0)|(f.ctrlKey?4:0)|(f.metaKey?8:0);switch(f.keyCode){case 0:f.key==="UIKeyInputUpArrow"?C.key=g?h.C0.ESC+"OA":h.C0.ESC+"[A":f.key==="UIKeyInputLeftArrow"?C.key=g?h.C0.ESC+"OD":h.C0.ESC+"[D":f.key==="UIKeyInputRightArrow"?C.key=g?h.C0.ESC+"OC":h.C0.ESC+"[C":f.key==="UIKeyInputDownArrow"&&(C.key=g?h.C0.ESC+"OB":h.C0.ESC+"[B");break;case 8:C.key=f.ctrlKey?"\b":h.C0.DEL,f.altKey&&(C.key=h.C0.ESC+C.key);break;case 9:if(f.shiftKey){C.key=h.C0.ESC+"[Z";break}C.key=h.C0.HT,C.cancel=!0;break;case 13:C.key=f.altKey?h.C0.ESC+h.C0.CR:h.C0.CR,C.cancel=!0;break;case 27:C.key=h.C0.ESC,f.altKey&&(C.key=h.C0.ESC+h.C0.ESC),C.cancel=!0;break;case 37:if(f.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"D",C.key===h.C0.ESC+"[1;3D"&&(C.key=h.C0.ESC+(x?"b":"[1;5D"))):C.key=g?h.C0.ESC+"OD":h.C0.ESC+"[D";break;case 39:if(f.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"C",C.key===h.C0.ESC+"[1;3C"&&(C.key=h.C0.ESC+(x?"f":"[1;5C"))):C.key=g?h.C0.ESC+"OC":h.C0.ESC+"[C";break;case 38:if(f.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"A",x||C.key!==h.C0.ESC+"[1;3A"||(C.key=h.C0.ESC+"[1;5A")):C.key=g?h.C0.ESC+"OA":h.C0.ESC+"[A";break;case 40:if(f.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"B",x||C.key!==h.C0.ESC+"[1;3B"||(C.key=h.C0.ESC+"[1;5B")):C.key=g?h.C0.ESC+"OB":h.C0.ESC+"[B";break;case 45:f.shiftKey||f.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":g?h.C0.ESC+"OH":h.C0.ESC+"[H";break;case 35:C.key=v?h.C0.ESC+"[1;"+(v+1)+"F":g?h.C0.ESC+"OF":h.C0.ESC+"[F";break;case 33:f.shiftKey?C.type=2:f.ctrlKey?C.key=h.C0.ESC+"[5;"+(v+1)+"~":C.key=h.C0.ESC+"[5~";break;case 34:f.shiftKey?C.type=3:f.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(!f.ctrlKey||f.shiftKey||f.altKey||f.metaKey)if(x&&!w||!f.altKey||f.metaKey)!x||f.altKey||f.ctrlKey||f.shiftKey||!f.metaKey?f.key&&!f.ctrlKey&&!f.altKey&&!f.metaKey&&f.keyCode>=48&&f.key.length===1?C.key=f.key:f.key&&f.ctrlKey&&(f.key==="_"&&(C.key=h.C0.US),f.key==="@"&&(C.key=h.C0.NUL)):f.keyCode===65&&(C.type=1);else{const S=m[f.keyCode],_=S==null?void 0:S[f.shiftKey?1:0];if(_)C.key=h.C0.ESC+_;else if(f.keyCode>=65&&f.keyCode<=90){const b=f.ctrlKey?f.keyCode-64:f.keyCode+32;let k=String.fromCharCode(b);f.shiftKey&&(k=k.toUpperCase()),C.key=h.C0.ESC+k}else if(f.keyCode===32)C.key=h.C0.ESC+(f.ctrlKey?h.C0.NUL:" ");else if(f.key==="Dead"&&f.code.startsWith("Key")){let b=f.code.slice(3,4);f.shiftKey||(b=b.toLowerCase()),C.key=h.C0.ESC+b,C.cancel=!0}}else f.keyCode>=65&&f.keyCode<=90?C.key=String.fromCharCode(f.keyCode-64):f.keyCode===32?C.key=h.C0.NUL:f.keyCode>=51&&f.keyCode<=55?C.key=String.fromCharCode(f.keyCode-51+27):f.keyCode===56?C.key=h.C0.DEL:f.keyCode===219?C.key=h.C0.ESC:f.keyCode===220?C.key=h.C0.FS:f.keyCode===221&&(C.key=h.C0.GS)}return C}},482:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Utf8ToUtf32=u.StringToUtf32=u.utf32ToString=u.stringFromCodePoint=void 0,u.stringFromCodePoint=function(d){return d>65535?(d-=65536,String.fromCharCode(55296+(d>>10))+String.fromCharCode(d%1024+56320)):String.fromCharCode(d)},u.utf32ToString=function(d,h=0,m=d.length){let f="";for(let g=h;g<m;++g){let x=d[g];x>65535?(x-=65536,f+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):f+=String.fromCharCode(x)}return f},u.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(d,h){const m=d.length;if(!m)return 0;let f=0,g=0;if(this._interim){const x=d.charCodeAt(g++);56320<=x&&x<=57343?h[f++]=1024*(this._interim-55296)+x-56320+65536:(h[f++]=this._interim,h[f++]=x),this._interim=0}for(let x=g;x<m;++x){const w=d.charCodeAt(x);if(55296<=w&&w<=56319){if(++x>=m)return this._interim=w,f;const C=d.charCodeAt(x);56320<=C&&C<=57343?h[f++]=1024*(w-55296)+C-56320+65536:(h[f++]=w,h[f++]=C)}else w!==65279&&(h[f++]=w)}return f}},u.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(d,h){const m=d.length;if(!m)return 0;let f,g,x,w,C=0,v=0,S=0;if(this.interim[0]){let k=!1,E=this.interim[0];E&=(224&E)==192?31:(240&E)==224?15:7;let T,L=0;for(;(T=63&this.interim[++L])&&L<4;)E<<=6,E|=T;const A=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,O=A-L;for(;S<O;){if(S>=m)return 0;if(T=d[S++],(192&T)!=128){S--,k=!0;break}this.interim[L++]=T,E<<=6,E|=63&T}k||(A===2?E<128?S--:h[C++]=E:A===3?E<2048||E>=55296&&E<=57343||E===65279||(h[C++]=E):E<65536||E>1114111||(h[C++]=E)),this.interim.fill(0)}const _=m-4;let b=S;for(;b<m;){for(;!(!(b<_)||128&(f=d[b])||128&(g=d[b+1])||128&(x=d[b+2])||128&(w=d[b+3]));)h[C++]=f,h[C++]=g,h[C++]=x,h[C++]=w,b+=4;if(f=d[b++],f<128)h[C++]=f;else if((224&f)==192){if(b>=m)return this.interim[0]=f,C;if(g=d[b++],(192&g)!=128){b--;continue}if(v=(31&f)<<6|63&g,v<128){b--;continue}h[C++]=v}else if((240&f)==224){if(b>=m)return this.interim[0]=f,C;if(g=d[b++],(192&g)!=128){b--;continue}if(b>=m)return this.interim[0]=f,this.interim[1]=g,C;if(x=d[b++],(192&x)!=128){b--;continue}if(v=(15&f)<<12|(63&g)<<6|63&x,v<2048||v>=55296&&v<=57343||v===65279)continue;h[C++]=v}else if((248&f)==240){if(b>=m)return this.interim[0]=f,C;if(g=d[b++],(192&g)!=128){b--;continue}if(b>=m)return this.interim[0]=f,this.interim[1]=g,C;if(x=d[b++],(192&x)!=128){b--;continue}if(b>=m)return this.interim[0]=f,this.interim[1]=g,this.interim[2]=x,C;if(w=d[b++],(192&w)!=128){b--;continue}if(v=(7&f)<<18|(63&g)<<12|(63&x)<<6|63&w,v<65536||v>1114111)continue;h[C++]=v}}return C}}},225:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.UnicodeV6=void 0;const h=d(1480),m=[[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]],f=[[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 g;u.UnicodeV6=class{constructor(){if(this.version="6",!g){g=new Uint8Array(65536),g.fill(1),g[0]=0,g.fill(0,1,32),g.fill(0,127,160),g.fill(2,4352,4448),g[9001]=2,g[9002]=2,g.fill(2,11904,42192),g[12351]=1,g.fill(2,44032,55204),g.fill(2,63744,64256),g.fill(2,65040,65050),g.fill(2,65072,65136),g.fill(2,65280,65377),g.fill(2,65504,65511);for(let x=0;x<m.length;++x)g.fill(0,m[x][0],m[x][1]+1)}}wcwidth(x){return x<32?0:x<127?1:x<65536?g[x]:(function(w,C){let v,S=0,_=C.length-1;if(w<C[0][0]||w>C[_][1])return!1;for(;_>=S;)if(v=S+_>>1,w>C[v][1])S=v+1;else{if(!(w<C[v][0]))return!0;_=v-1}return!1})(x,f)?0:x>=131072&&x<=196605||x>=196608&&x<=262141?2:1}charProperties(x,w){let C=this.wcwidth(x),v=C===0&&w!==0;if(v){const S=h.UnicodeService.extractWidth(w);S===0?v=!1:S>C&&(C=S)}return h.UnicodeService.createPropertyValue(0,C,v)}}},5981:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.WriteBuffer=void 0;const h=d(8460),m=d(844);class f extends m.Disposable{constructor(x){super(),this._action=x,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(x,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=x.length,this._writeBuffer.push(x),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(x,w){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+=x.length,this._writeBuffer.push(x),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w)}_innerWrite(x=0,w=!0){const C=x||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const v=this._writeBuffer[this._bufferOffset],S=this._action(v,w);if(S){const b=k=>Date.now()-C>=12?setTimeout((()=>this._innerWrite(0,k))):this._innerWrite(C,k);return void S.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()}}u.WriteBuffer=f},5941:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.toRgbString=u.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 m(f,g){const x=f.toString(16),w=x.length<2?"0"+x:x;switch(g){case 4:return x[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}u.parseColor=function(f){if(!f)return;let g=f.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const x=d.exec(g);if(x){const w=x[1]?15:x[4]?255:x[7]?4095:65535;return[Math.round(parseInt(x[1]||x[4]||x[7]||x[10],16)/w*255),Math.round(parseInt(x[2]||x[5]||x[8]||x[11],16)/w*255),Math.round(parseInt(x[3]||x[6]||x[9]||x[12],16)/w*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),h.exec(g)&&[3,6,9,12].includes(g.length))){const x=g.length/3,w=[0,0,0];for(let C=0;C<3;++C){const v=parseInt(g.slice(x*C,x*C+x),16);w[C]=x===1?v<<4:x===2?v:x===3?v>>4:v>>8}return w}},u.toRgbString=function(f,g=16){const[x,w,C]=f;return`rgb:${m(x,g)}/${m(w,g)}/${m(C,g)}`}},5770:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.PAYLOAD_LIMIT=void 0,u.PAYLOAD_LIMIT=1e7},6351:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DcsHandler=u.DcsParser=void 0;const h=d(482),m=d(8742),f=d(5770),g=[];u.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(w,C){this._handlers[w]===void 0&&(this._handlers[w]=[]);const v=this._handlers[w];return v.push(C),{dispose:()=>{const S=v.indexOf(C);S!==-1&&v.splice(S,1)}}}clearHandler(w){this._handlers[w]&&delete this._handlers[w]}setHandlerFallback(w){this._handlerFb=w}reset(){if(this._active.length)for(let w=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;w>=0;--w)this._active[w].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(w,C){if(this.reset(),this._ident=w,this._active=this._handlers[w]||g,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(w,C,v){if(this._active.length)for(let S=this._active.length-1;S>=0;S--)this._active[S].put(w,C,v);else this._handlerFb(this._ident,"PUT",(0,h.utf32ToString)(w,C,v))}unhook(w,C=!0){if(this._active.length){let v=!1,S=this._active.length-1,_=!1;if(this._stack.paused&&(S=this._stack.loopPosition-1,v=C,_=this._stack.fallThrough,this._stack.paused=!1),!_&&v===!1){for(;S>=0&&(v=this._active[S].unhook(w),v!==!0);S--)if(v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!1,v;S--}for(;S>=0;S--)if(v=this._active[S].unhook(!1),v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!0,v}else this._handlerFb(this._ident,"UNHOOK",w);this._active=g,this._ident=0}};const x=new m.Params;x.addParam(0),u.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=x,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():x,this._data="",this._hitLimit=!1}put(w,C,v){this._hitLimit||(this._data+=(0,h.utf32ToString)(w,C,v),this._data.length>f.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let C=!1;if(this._hitLimit)C=!1;else if(w&&(C=this._handler(this._data,this._params),C instanceof Promise))return C.then((v=>(this._params=x,this._data="",this._hitLimit=!1,v)));return this._params=x,this._data="",this._hitLimit=!1,C}}},2015:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.EscapeSequenceParser=u.VT500_TRANSITION_TABLE=u.TransitionTable=void 0;const h=d(844),m=d(8742),f=d(6242),g=d(6351);class x{constructor(S){this.table=new Uint8Array(S)}setDefault(S,_){this.table.fill(S<<4|_)}add(S,_,b,k){this.table[_<<8|S]=b<<4|k}addMany(S,_,b,k){for(let E=0;E<S.length;E++)this.table[_<<8|S[E]]=b<<4|k}}u.TransitionTable=x;const w=160;u.VT500_TRANSITION_TABLE=(function(){const v=new x(4095),S=Array.apply(null,Array(256)).map(((L,A)=>A)),_=(L,A)=>S.slice(L,A),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(w,0,2,0),v.add(w,8,5,8),v.add(w,6,0,6),v.add(w,11,0,11),v.add(w,13,13,13),v})();class C extends h.Disposable{constructor(S=u.VT500_TRANSITION_TABLE){super(),this._transitions=S,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new m.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 f.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(S,_=[64,126]){let b=0;if(S.prefix){if(S.prefix.length>1)throw new Error("only one byte as prefix supported");if(b=S.prefix.charCodeAt(0),b&&60>b||b>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(S.intermediates){if(S.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let E=0;E<S.intermediates.length;++E){const T=S.intermediates.charCodeAt(E);if(32>T||T>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");b<<=8,b|=T}}if(S.final.length!==1)throw new Error("final must be a single byte");const k=S.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(S){const _=[];for(;S;)_.push(String.fromCharCode(255&S)),S>>=8;return _.reverse().join("")}setPrintHandler(S){this._printHandler=S}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(S,_){const b=this._identifier(S,[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(S){this._escHandlers[this._identifier(S,[48,126])]&&delete this._escHandlers[this._identifier(S,[48,126])]}setEscHandlerFallback(S){this._escHandlerFb=S}setExecuteHandler(S,_){this._executeHandlers[S.charCodeAt(0)]=_}clearExecuteHandler(S){this._executeHandlers[S.charCodeAt(0)]&&delete this._executeHandlers[S.charCodeAt(0)]}setExecuteHandlerFallback(S){this._executeHandlerFb=S}registerCsiHandler(S,_){const b=this._identifier(S);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(S){this._csiHandlers[this._identifier(S)]&&delete this._csiHandlers[this._identifier(S)]}setCsiHandlerFallback(S){this._csiHandlerFb=S}registerDcsHandler(S,_){return this._dcsParser.registerHandler(this._identifier(S),_)}clearDcsHandler(S){this._dcsParser.clearHandler(this._identifier(S))}setDcsHandlerFallback(S){this._dcsParser.setHandlerFallback(S)}registerOscHandler(S,_){return this._oscParser.registerHandler(S,_)}clearOscHandler(S){this._oscParser.clearHandler(S)}setOscHandlerFallback(S){this._oscParser.setHandlerFallback(S)}setErrorHandler(S){this._errorHandler=S}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(S,_,b,k,E){this._parseStack.state=S,this._parseStack.handlers=_,this._parseStack.handlerPos=b,this._parseStack.transition=k,this._parseStack.chunkPos=E}parse(S,_,b){let k,E=0,T=0,L=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,L=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 A=this._parseStack.handlers;let O=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(b===!1&&O>-1){for(;O>=0&&(k=A[O](this._params),k!==!0);O--)if(k instanceof Promise)return this._parseStack.handlerPos=O,k}this._parseStack.handlers=[];break;case 4:if(b===!1&&O>-1){for(;O>=0&&(k=A[O](),k!==!0);O--)if(k instanceof Promise)return this._parseStack.handlerPos=O,k}this._parseStack.handlers=[];break;case 6:if(E=S[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=S[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,L=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let A=L;A<_;++A){switch(E=S[A],T=this._transitions.table[this.currentState<<8|(E<160?E:w)],T>>4){case 2:for(let F=A+1;;++F){if(F>=_||(E=S[F])<32||E>126&&E<w){this._printHandler(S,A,F),A=F-1;break}if(++F>=_||(E=S[F])<32||E>126&&E<w){this._printHandler(S,A,F),A=F-1;break}if(++F>=_||(E=S[F])<32||E>126&&E<w){this._printHandler(S,A,F),A=F-1;break}if(++F>=_||(E=S[F])<32||E>126&&E<w){this._printHandler(S,A,F),A=F-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:A,code:E,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const O=this._csiHandlers[this._collect<<8|E];let M=O?O.length-1:-1;for(;M>=0&&(k=O[M](this._params),k!==!0);M--)if(k instanceof Promise)return this._preserveStack(3,O,M,T,A),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(++A<_&&(E=S[A])>47&&E<60);A--;break;case 9:this._collect<<=8,this._collect|=E;break;case 10:const H=this._escHandlers[this._collect<<8|E];let B=H?H.length-1:-1;for(;B>=0&&(k=H[B](),k!==!0);B--)if(k instanceof Promise)return this._preserveStack(4,H,B,T,A),k;B<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 F=A+1;;++F)if(F>=_||(E=S[F])===24||E===26||E===27||E>127&&E<w){this._dcsParser.put(S,A,F),A=F-1;break}break;case 14:if(k=this._dcsParser.unhook(E!==24&&E!==26),k)return this._preserveStack(6,[],0,T,A),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 F=A+1;;F++)if(F>=_||(E=S[F])<32||E>127&&E<w){this._oscParser.put(S,A,F),A=F-1;break}break;case 6:if(k=this._oscParser.end(E!==24&&E!==26),k)return this._preserveStack(5,[],0,T,A),k;E===27&&(T|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&T}}}u.EscapeSequenceParser=C},6242:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.OscHandler=u.OscParser=void 0;const h=d(5770),m=d(482),f=[];u.OscParser=class{constructor(){this._state=0,this._active=f,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,x){this._handlers[g]===void 0&&(this._handlers[g]=[]);const w=this._handlers[g];return w.push(x),{dispose:()=>{const C=w.indexOf(x);C!==-1&&w.splice(C,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=f}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=f,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||f,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,x,w){if(this._active.length)for(let C=this._active.length-1;C>=0;C--)this._active[C].put(g,x,w);else this._handlerFb(this._id,"PUT",(0,m.utf32ToString)(g,x,w))}start(){this.reset(),this._state=1}put(g,x,w){if(this._state!==3){if(this._state===1)for(;x<w;){const C=g[x++];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&&w-x>0&&this._put(g,x,w)}}end(g,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,C=this._active.length-1,v=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,w=x,v=this._stack.fallThrough,this._stack.paused=!1),!v&&w===!1){for(;C>=0&&(w=this._active[C].end(g),w!==!0);C--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!1,w;C--}for(;C>=0;C--)if(w=this._active[C].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",g);this._active=f,this._id=-1,this._state=0}}},u.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,x,w){this._hitLimit||(this._data+=(0,m.utf32ToString)(g,x,w),this._data.length>h.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let x=!1;if(this._hitLimit)x=!1;else if(g&&(x=this._handler(this._data),x instanceof Promise))return x.then((w=>(this._data="",this._hitLimit=!1,w)));return this._data="",this._hitLimit=!1,x}}},8742:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Params=void 0;const d=2147483647;class h{static fromArray(f){const g=new h;if(!f.length)return g;for(let x=Array.isArray(f[0])?1:0;x<f.length;++x){const w=f[x];if(Array.isArray(w))for(let C=0;C<w.length;++C)g.addSubParam(w[C]);else g.addParam(w)}return g}constructor(f=32,g=32){if(this.maxLength=f,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(f),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(f),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const f=new h(this.maxLength,this.maxSubParamsLength);return f.params.set(this.params),f.length=this.length,f._subParams.set(this._subParams),f._subParamsLength=this._subParamsLength,f._subParamsIdx.set(this._subParamsIdx),f._rejectDigits=this._rejectDigits,f._rejectSubDigits=this._rejectSubDigits,f._digitIsSub=this._digitIsSub,f}toArray(){const f=[];for(let g=0;g<this.length;++g){f.push(this.params[g]);const x=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-x>0&&f.push(Array.prototype.slice.call(this._subParams,x,w))}return f}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(f){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(f<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=f>d?d:f}}addSubParam(f){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(f<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=f>d?d:f,this._subParamsIdx[this.length-1]++}}hasSubParams(f){return(255&this._subParamsIdx[f])-(this._subParamsIdx[f]>>8)>0}getSubParams(f){const g=this._subParamsIdx[f]>>8,x=255&this._subParamsIdx[f];return x-g>0?this._subParams.subarray(g,x):null}getSubParamsAll(){const f={};for(let g=0;g<this.length;++g){const x=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-x>0&&(f[g]=this._subParams.slice(x,w))}return f}addDigit(f){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const x=this._digitIsSub?this._subParams:this.params,w=x[g-1];x[g-1]=~w?Math.min(10*w+f,d):f}}u.Params=h},5741:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.AddonManager=void 0,u.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 m={instance:h,dispose:h.dispose,isDisposed:!1};this._addons.push(m),h.dispose=()=>this._wrappedAddonDispose(m),h.activate(d)}_wrappedAddonDispose(d){if(d.isDisposed)return;let h=-1;for(let m=0;m<this._addons.length;m++)if(this._addons[m]===d){h=m;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:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferApiView=void 0;const h=d(3785),m=d(511);u.BufferApiView=class{constructor(f,g){this._buffer=f,this.type=g}init(f){return this._buffer=f,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(f){const g=this._buffer.lines.get(f);if(g)return new h.BufferLineApiView(g)}getNullCell(){return new m.CellData}}},3785:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferLineApiView=void 0;const h=d(511);u.BufferLineApiView=class{constructor(m){this._line=m}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(m,f){if(!(m<0||m>=this._line.length))return f?(this._line.loadCell(m,f),f):this._line.loadCell(m,new h.CellData)}translateToString(m,f,g){return this._line.translateToString(m,f,g)}}},8285:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferNamespaceApi=void 0;const h=d(8771),m=d(8460),f=d(844);class g extends f.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new m.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)}}u.BufferNamespaceApi=g},7975:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ParserApi=void 0,u.ParserApi=class{constructor(d){this._core=d}registerCsiHandler(d,h){return this._core.registerCsiHandler(d,(m=>h(m.toArray())))}addCsiHandler(d,h){return this.registerCsiHandler(d,h)}registerDcsHandler(d,h){return this._core.registerDcsHandler(d,((m,f)=>h(m,f.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:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.UnicodeApi=void 0,u.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(c,u,d){var h=this&&this.__decorate||function(v,S,_,b){var k,E=arguments.length,T=E<3?S:b===null?b=Object.getOwnPropertyDescriptor(S,_):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(v,S,_,b);else for(var L=v.length-1;L>=0;L--)(k=v[L])&&(T=(E<3?k(T):E>3?k(S,_,T):k(S,_))||T);return E>3&&T&&Object.defineProperty(S,_,T),T},m=this&&this.__param||function(v,S){return function(_,b){S(_,b,v)}};Object.defineProperty(u,"__esModule",{value:!0}),u.BufferService=u.MINIMUM_ROWS=u.MINIMUM_COLS=void 0;const f=d(8460),g=d(844),x=d(5295),w=d(2585);u.MINIMUM_COLS=2,u.MINIMUM_ROWS=1;let C=u.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(v){super(),this.isUserScrolling=!1,this._onResize=this.register(new f.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new f.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(v.rawOptions.cols||0,u.MINIMUM_COLS),this.rows=Math.max(v.rawOptions.rows||0,u.MINIMUM_ROWS),this.buffers=this.register(new x.BufferSet(v,this))}resize(v,S){this.cols=v,this.rows=S,this.buffers.resize(v,S),this._onResize.fire({cols:v,rows:S})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(v,S=!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,S),this._cachedBlankLine=b),b.isWrapped=S;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,S,_){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&&(S||this._onScroll.fire(b.ydisp))}};u.BufferService=C=h([m(0,w.IOptionsService)],C)},7994:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CharsetService=void 0,u.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(c,u,d){var h=this&&this.__decorate||function(b,k,E,T){var L,A=arguments.length,O=A<3?k:T===null?T=Object.getOwnPropertyDescriptor(k,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(b,k,E,T);else for(var M=b.length-1;M>=0;M--)(L=b[M])&&(O=(A<3?L(O):A>3?L(k,E,O):L(k,E))||O);return A>3&&O&&Object.defineProperty(k,E,O),O},m=this&&this.__param||function(b,k){return function(E,T){k(E,T,b)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CoreMouseService=void 0;const f=d(2585),g=d(8460),x=d(844),w={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,S={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 _=u.CoreMouseService=class extends x.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 g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const E of Object.keys(w))this.addProtocol(E,w[E]);for(const E of Object.keys(S))this.addEncoding(E,S[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}};u.CoreMouseService=_=h([m(0,f.IBufferService),m(1,f.ICoreService)],_)},6975:function(c,u,d){var h=this&&this.__decorate||function(_,b,k,E){var T,L=arguments.length,A=L<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(_,b,k,E);else for(var O=_.length-1;O>=0;O--)(T=_[O])&&(A=(L<3?T(A):L>3?T(b,k,A):T(b,k))||A);return L>3&&A&&Object.defineProperty(b,k,A),A},m=this&&this.__param||function(_,b){return function(k,E){b(k,E,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CoreService=void 0;const f=d(1439),g=d(8460),x=d(844),w=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 S=u.CoreService=class extends x.Disposable{constructor(_,b,k){super(),this._bufferService=_,this._logService=b,this._optionsService=k,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,f.clone)(C),this.decPrivateModes=(0,f.clone)(v)}reset(){this.modes=(0,f.clone)(C),this.decPrivateModes=(0,f.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(_))}};u.CoreService=S=h([m(0,w.IBufferService),m(1,w.ILogService),m(2,w.IOptionsService)],S)},9074:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DecorationService=void 0;const h=d(8055),m=d(8460),f=d(844),g=d(6106);let x=0,w=0;class C extends f.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((_=>_==null?void 0:_.marker.line)),this._onDecorationRegistered=this.register(new m.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new m.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,f.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 L of this._decorations.getKeyIterator(b))E=L.options.x??0,T=E+(L.options.width??1),_>=E&&_<T&&(!k||(L.options.layer??"bottom")===k)&&(yield L)}forEachDecorationAtCell(_,b,k,E){this._decorations.forEachByKey(b,(T=>{x=T.options.x??0,w=x+(T.options.width??1),_>=x&&_<w&&(!k||(T.options.layer??"bottom")===k)&&E(T)}))}}u.DecorationService=C;class v extends f.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 m.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new m.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:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.InstantiationService=u.ServiceCollection=void 0;const h=d(2585),m=d(8343);class f{constructor(...x){this._entries=new Map;for(const[w,C]of x)this.set(w,C)}set(x,w){const C=this._entries.get(x);return this._entries.set(x,w),C}forEach(x){for(const[w,C]of this._entries.entries())x(w,C)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}u.ServiceCollection=f,u.InstantiationService=class{constructor(){this._services=new f,this._services.set(h.IInstantiationService,this)}setService(g,x){this._services.set(g,x)}getService(g){return this._services.get(g)}createInstance(g,...x){const w=(0,m.getServiceDependencies)(g).sort(((S,_)=>S.index-_.index)),C=[];for(const S of w){const _=this._services.get(S.id);if(!_)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${S.id}.`);C.push(_)}const v=w.length>0?w[0].index:x.length;if(x.length!==v)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${v+1} conflicts with ${x.length} static arguments`);return new g(...x,...C)}}},7866:function(c,u,d){var h=this&&this.__decorate||function(v,S,_,b){var k,E=arguments.length,T=E<3?S:b===null?b=Object.getOwnPropertyDescriptor(S,_):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(v,S,_,b);else for(var L=v.length-1;L>=0;L--)(k=v[L])&&(T=(E<3?k(T):E>3?k(S,_,T):k(S,_))||T);return E>3&&T&&Object.defineProperty(S,_,T),T},m=this&&this.__param||function(v,S){return function(_,b){S(_,b,v)}};Object.defineProperty(u,"__esModule",{value:!0}),u.traceCall=u.setTraceLogger=u.LogService=void 0;const f=d(844),g=d(2585),x={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let w,C=u.LogService=class extends f.Disposable{get logLevel(){return this._logLevel}constructor(v){super(),this._optionsService=v,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=x[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(v){for(let S=0;S<v.length;S++)typeof v[S]=="function"&&(v[S]=v[S]())}_log(v,S,_){this._evalLazyOptionalParams(_),v.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+S,..._)}trace(v,...S){var _;this._logLevel<=g.LogLevelEnum.TRACE&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.trace.bind(this._optionsService.options.logger))??console.log,v,S)}debug(v,...S){var _;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.debug.bind(this._optionsService.options.logger))??console.log,v,S)}info(v,...S){var _;this._logLevel<=g.LogLevelEnum.INFO&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.info.bind(this._optionsService.options.logger))??console.info,v,S)}warn(v,...S){var _;this._logLevel<=g.LogLevelEnum.WARN&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.warn.bind(this._optionsService.options.logger))??console.warn,v,S)}error(v,...S){var _;this._logLevel<=g.LogLevelEnum.ERROR&&this._log(((_=this._optionsService.options.logger)==null?void 0:_.error.bind(this._optionsService.options.logger))??console.error,v,S)}};u.LogService=C=h([m(0,g.IOptionsService)],C),u.setTraceLogger=function(v){w=v},u.traceCall=function(v,S,_){if(typeof _.value!="function")throw new Error("not supported");const b=_.value;_.value=function(...k){if(w.logLevel!==g.LogLevelEnum.TRACE)return b.apply(this,k);w.trace(`GlyphRenderer#${b.name}(${k.map((T=>JSON.stringify(T))).join(", ")})`);const E=b.apply(this,k);return w.trace(`GlyphRenderer#${b.name} return`,E),E}}},7302:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.OptionsService=u.DEFAULT_OPTIONS=void 0;const h=d(8460),m=d(844),f=d(6114);u.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:f.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class x extends m.Disposable{constructor(C){super(),this._onOptionChange=this.register(new h.EventEmitter),this.onOptionChange=this._onOptionChange.event;const v={...u.DEFAULT_OPTIONS};for(const S in C)if(S in v)try{const _=C[S];v[S]=this._sanitizeAndValidateOption(S,_)}catch(_){console.error(_)}this.rawOptions=v,this.options={...v},this._setupOptions(),this.register((0,m.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(C,v){return this.onOptionChange((S=>{S===C&&v(this.rawOptions[C])}))}onMultipleOptionChange(C,v){return this.onOptionChange((S=>{C.indexOf(S)!==-1&&v()}))}_setupOptions(){const C=S=>{if(!(S in u.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);return this.rawOptions[S]},v=(S,_)=>{if(!(S in u.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);_=this._sanitizeAndValidateOption(S,_),this.rawOptions[S]!==_&&(this.rawOptions[S]=_,this._onOptionChange.fire(S))};for(const S in this.rawOptions){const _={get:C.bind(this,S),set:v.bind(this,S)};Object.defineProperty(this.options,S,_)}}_sanitizeAndValidateOption(C,v){switch(C){case"cursorStyle":if(v||(v=u.DEFAULT_OPTIONS[C]),!(function(S){return S==="block"||S==="underline"||S==="bar"})(v))throw new Error(`"${v}" is not a valid value for ${C}`);break;case"wordSeparator":v||(v=u.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof v=="number"&&1<=v&&v<=1e3)break;v=g.includes(v)?v:u.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}}u.OptionsService=x},2660:function(c,u,d){var h=this&&this.__decorate||function(x,w,C,v){var S,_=arguments.length,b=_<3?w:v===null?v=Object.getOwnPropertyDescriptor(w,C):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(x,w,C,v);else for(var k=x.length-1;k>=0;k--)(S=x[k])&&(b=(_<3?S(b):_>3?S(w,C,b):S(w,C))||b);return _>3&&b&&Object.defineProperty(w,C,b),b},m=this&&this.__param||function(x,w){return function(C,v){w(C,v,x)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OscLinkService=void 0;const f=d(2585);let g=u.OscLinkService=class{constructor(x){this._bufferService=x,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(x){const w=this._bufferService.buffer;if(x.id===void 0){const k=w.addMarker(w.ybase+w.y),E={data:x,id:this._nextId++,lines:[k]};return k.onDispose((()=>this._removeMarkerFromLink(E,k))),this._dataByLinkId.set(E.id,E),E.id}const C=x,v=this._getEntryIdKey(C),S=this._entriesWithId.get(v);if(S)return this.addLineToLink(S.id,w.ybase+w.y),S.id;const _=w.addMarker(w.ybase+w.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(x,w){const C=this._dataByLinkId.get(x);if(C&&C.lines.every((v=>v.line!==w))){const v=this._bufferService.buffer.addMarker(w);C.lines.push(v),v.onDispose((()=>this._removeMarkerFromLink(C,v)))}}getLinkData(x){var w;return(w=this._dataByLinkId.get(x))==null?void 0:w.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,w){const C=x.lines.indexOf(w);C!==-1&&(x.lines.splice(C,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.id)))}};u.OscLinkService=g=h([m(0,f.IBufferService)],g)},8343:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.createDecorator=u.getServiceDependencies=u.serviceRegistry=void 0;const d="di$target",h="di$dependencies";u.serviceRegistry=new Map,u.getServiceDependencies=function(m){return m[h]||[]},u.createDecorator=function(m){if(u.serviceRegistry.has(m))return u.serviceRegistry.get(m);const f=function(g,x,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(C,v,S){v[d]===v?v[h].push({id:C,index:S}):(v[h]=[{id:C,index:S}],v[d]=v)})(f,g,w)};return f.toString=()=>m,u.serviceRegistry.set(m,f),f}},2585:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.IDecorationService=u.IUnicodeService=u.IOscLinkService=u.IOptionsService=u.ILogService=u.LogLevelEnum=u.IInstantiationService=u.ICharsetService=u.ICoreService=u.ICoreMouseService=u.IBufferService=void 0;const h=d(8343);var m;u.IBufferService=(0,h.createDecorator)("BufferService"),u.ICoreMouseService=(0,h.createDecorator)("CoreMouseService"),u.ICoreService=(0,h.createDecorator)("CoreService"),u.ICharsetService=(0,h.createDecorator)("CharsetService"),u.IInstantiationService=(0,h.createDecorator)("InstantiationService"),(function(f){f[f.TRACE=0]="TRACE",f[f.DEBUG=1]="DEBUG",f[f.INFO=2]="INFO",f[f.WARN=3]="WARN",f[f.ERROR=4]="ERROR",f[f.OFF=5]="OFF"})(m||(u.LogLevelEnum=m={})),u.ILogService=(0,h.createDecorator)("LogService"),u.IOptionsService=(0,h.createDecorator)("OptionsService"),u.IOscLinkService=(0,h.createDecorator)("OscLinkService"),u.IUnicodeService=(0,h.createDecorator)("UnicodeService"),u.IDecorationService=(0,h.createDecorator)("DecorationService")},1480:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.UnicodeService=void 0;const h=d(8460),m=d(225);class f{static extractShouldJoin(x){return(1&x)!=0}static extractWidth(x){return x>>1&3}static extractCharKind(x){return x>>3}static createPropertyValue(x,w,C=!1){return(16777215&x)<<3|(3&w)<<1|(C?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new h.EventEmitter,this.onChange=this._onChange.event;const x=new m.UnicodeV6;this.register(x),this._active=x.version,this._activeProvider=x}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(x){if(!this._providers[x])throw new Error(`unknown Unicode version "${x}"`);this._active=x,this._activeProvider=this._providers[x],this._onChange.fire(x)}register(x){this._providers[x.version]=x}wcwidth(x){return this._activeProvider.wcwidth(x)}getStringCellWidth(x){let w=0,C=0;const v=x.length;for(let S=0;S<v;++S){let _=x.charCodeAt(S);if(55296<=_&&_<=56319){if(++S>=v)return w+this.wcwidth(_);const E=x.charCodeAt(S);56320<=E&&E<=57343?_=1024*(_-55296)+E-56320+65536:w+=this.wcwidth(E)}const b=this.charProperties(_,C);let k=f.extractWidth(b);f.extractShouldJoin(b)&&(k-=f.extractWidth(C)),w+=k,C=b}return w}charProperties(x,w){return this._activeProvider.charProperties(x,w)}}u.UnicodeService=f}},r={};function a(c){var u=r[c];if(u!==void 0)return u.exports;var d=r[c]={exports:{}};return n[c].call(d.exports,d,d.exports,a),d.exports}var o={};return(()=>{var c=o;Object.defineProperty(c,"__esModule",{value:!0}),c.Terminal=void 0;const u=a(9042),d=a(3236),h=a(844),m=a(5741),f=a(8285),g=a(7975),x=a(7090),w=["cols","rows"];class C extends h.Disposable{constructor(S){super(),this._core=this.register(new d.Terminal(S)),this._addonManager=this.register(new m.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(S){if(w.includes(S))throw new Error(`Option "${S}" 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 g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new x.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 f.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const S=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:S.applicationCursorKeys,applicationKeypadMode:S.applicationKeypad,bracketedPasteMode:S.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:_,originMode:S.origin,reverseWraparoundMode:S.reverseWraparound,sendFocusMode:S.sendFocus,wraparoundMode:S.wraparound}}get options(){return this._publicOptions}set options(S){for(const _ in S)this._publicOptions[_]=S[_]}blur(){this._core.blur()}focus(){this._core.focus()}input(S,_=!0){this._core.input(S,_)}resize(S,_){this._verifyIntegers(S,_),this._core.resize(S,_)}open(S){this._core.open(S)}attachCustomKeyEventHandler(S){this._core.attachCustomKeyEventHandler(S)}attachCustomWheelEventHandler(S){this._core.attachCustomWheelEventHandler(S)}registerLinkProvider(S){return this._core.registerLinkProvider(S)}registerCharacterJoiner(S){return this._checkProposedApi(),this._core.registerCharacterJoiner(S)}deregisterCharacterJoiner(S){this._checkProposedApi(),this._core.deregisterCharacterJoiner(S)}registerMarker(S=0){return this._verifyIntegers(S),this._core.registerMarker(S)}registerDecoration(S){return this._checkProposedApi(),this._verifyPositiveIntegers(S.x??0,S.width??0,S.height??0),this._core.registerDecoration(S)}hasSelection(){return this._core.hasSelection()}select(S,_,b){this._verifyIntegers(S,_,b),this._core.select(S,_,b)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(S,_){this._verifyIntegers(S,_),this._core.selectLines(S,_)}dispose(){super.dispose()}scrollLines(S){this._verifyIntegers(S),this._core.scrollLines(S)}scrollPages(S){this._verifyIntegers(S),this._core.scrollPages(S)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(S){this._verifyIntegers(S),this._core.scrollToLine(S)}clear(){this._core.clear()}write(S,_){this._core.write(S,_)}writeln(S,_){this._core.write(S),this._core.write(`\r
|
|
261
|
+
`,_)}paste(S){this._core.paste(S)}refresh(S,_){this._verifyIntegers(S,_),this._core.refresh(S,_)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(S){this._addonManager.loadAddon(this,S)}static get strings(){return u}_verifyIntegers(...S){for(const _ of S)if(_===1/0||isNaN(_)||_%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...S){for(const _ of S)if(_&&(_===1/0||isNaN(_)||_%1!=0||_<0))throw new Error("This API only accepts positive integers")}}c.Terminal=C})(),o})()))})(Mx)),Mx.exports}var lU=oU();/**
|
|
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 cU=2,uU=1,dU=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 f;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:((f=this._terminal.options.overviewRuler)==null?void 0:f.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),c={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},u=c.top+c.bottom,d=c.right+c.left,h=r-u,m=a-d-t;return{cols:Math.max(cU,Math.floor(m/e.css.cell.width)),rows:Math.max(uU,Math.floor(h/e.css.cell.height))}}};function hU({sessionId:e,onClose:t,onEscape:n,autoFocus:r}){const a=j.useRef(null),o=j.useRef(e),c=j.useRef(null),u=j.useRef(null),d=fs(f=>f.writeSession),h=fs(f=>f.resizeSession),m=Bt(f=>f.settings[Ne.DISPLAY_TERMINAL_FONT]??$h);return j.useEffect(()=>{o.current=e},[e]),j.useEffect(()=>{Bt.getState().getSetting(Ne.DISPLAY_TERMINAL_FONT)},[]),j.useEffect(()=>{if(!n)return;const f=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),n())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]),j.useEffect(()=>{if(!a.current)return;const f=new lU.Terminal({fontFamily:m,fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),g=new dU;f.loadAddon(g),c.current={term:f,fitAddon:g},a.current.addEventListener("keydown",v=>{v.key==="Escape"&&n&&(v.preventDefault(),v.stopPropagation(),n())}),f.open(a.current);const x=a.current.querySelector(".xterm");x&&(x.style.padding="8px"),g.fit(),r&&setTimeout(()=>{f.focus()},150);const w=new ResizeObserver(()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{requestAnimationFrame(()=>{var S;g.fit&&g.fit();const v=(S=c.current)==null?void 0:S.term;v&&v.cols>0&&v.rows>0&&h(o.current,v.cols,v.rows)})},100)});w.observe(a.current),f.onData(v=>{if(v==="\x1B"&&n){n();return}d(o.current,v)}),f.onKey(v=>{v.key==="\x1B"&&n&&(v.domEvent.stopPropagation(),n())});const C=Vt.subscribe(v=>{const S=v.payload;if(v.type==="terminal.output"&&(S==null?void 0:S.sessionId)===o.current){const _=S==null?void 0:S.data;_&&f.write(_)}});return()=>{C(),w.disconnect(),u.current&&clearTimeout(u.current),f.dispose(),c.current=null}},[e,d,h]),j.useEffect(()=>{const f=c.current;if(!f)return;f.term.options.fontFamily=m,f.fitAddon.fit();const{cols:g,rows:x}=f.term;g>0&&x>0&&h(o.current,g,x)},[m,h]),s.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[s.jsx("div",{}),s.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:s.jsx(jb,{})})]}),s.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:f=>{f.key==="Escape"&&n&&(f.preventDefault(),f.stopPropagation(),n())}})]})}const AT="openfox-chat-textarea";function ku(e){if(!Gt())return;const t=document.getElementById(AT);t&&(e===void 0?t.focus():t.focus({preventScroll:e}))}function fU(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 mU({isOpen:e,onClose:t}){const n=fs(C=>C.createSession),r=fs(C=>C.killSession),a=fs(C=>C.sessions),o=fs(C=>C.setWorkdir),c=fs(C=>C.fetchSessions),u=Pt(C=>C.currentProject),d=Oe(C=>C.currentSession),[h,m]=j.useState(!0),f=j.useRef(null),g=j.useRef(!1),x=j.useRef(!1),w=j.useCallback(()=>{t()},[t]);return j.useEffect(()=>{const C=(d==null?void 0:d.workspace)??(u==null?void 0:u.workdir);C&&o(C)},[d==null?void 0:d.workspace,u==null?void 0:u.workdir,o]),j.useEffect(()=>{e?(m(!0),c(u==null?void 0:u.id).finally(()=>m(!1))):ku()},[e,c,u==null?void 0:u.id]),j.useEffect(()=>{e&&a.length===0&&!h&&!x.current&&(x.current=!0,n(void 0,(d==null?void 0:d.projectId)??(u==null?void 0:u.id)))},[e,a.length,h,n,d==null?void 0:d.projectId,u==null?void 0:u.id]),j.useEffect(()=>{e?(g.current=!0,setTimeout(()=>{var C;Gt()&&((C=f.current)==null||C.focus()),setTimeout(()=>{g.current=!1},200)},100)):x.current=!1},[e]),j.useEffect(()=>{if(!e)return;const C=v=>{g.current||v.key==="Escape"&&(v.preventDefault(),t())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,t]),e?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:w}),s.jsxs("div",{ref:f,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(),w())},children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>n(void 0,(d==null?void 0:d.projectId)??(u==null?void 0:u.id)),className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New terminal",children:s.jsx(eO,{})}),s.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:s.jsx(Ss,{})})]})]}),s.jsx(pt,{className:"flex-1 min-h-0 p-2",children:h?s.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):a.length===0?s.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:s.jsxs("div",{className:"text-center",children:[s.jsx("p",{className:"mb-4",children:"No terminal sessions"}),s.jsx("button",{onClick:()=>n(void 0,(d==null?void 0:d.projectId)??(u==null?void 0:u.id)),className:"px-4 py-2 bg-accent-primary/25 text-text-primary rounded hover:bg-accent-primary/40 transition-colors",children:"Create Terminal"})]})}):s.jsx("div",{className:`grid ${fU(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(C=>s.jsx(hU,{sessionId:C.id,onClose:()=>r(C.id),onEscape:w,autoFocus:a.length===1&&Gt()},C.id))})})]})]}):null}function ho({items:e,footerItems:t=[],trigger:n,minWidth:r="120px",align:a="left",isOpen:o,onOpenChange:c,labelActionClassName:u}){const[d,h]=j.useState(!1),m=o!==void 0,f=m?o:d,g=G=>{if(m){const V=typeof G=="function"?G(d):G;c==null||c(V)}else h(G)},[x,w]=j.useState(null),C=j.useRef(null),v=j.useRef(null),[S,_]=j.useState(0),b=j.useRef(0),k=j.useMemo(()=>[...e,...t],[e,t]),E=j.useRef(k),T=j.useCallback(()=>{if(!C.current)return;const G=C.current.getBoundingClientRect(),V=200,Z=Number.parseInt(r,10)||120,z=window.innerHeight-G.bottom<V;w({top:z?G.top-V-4:G.bottom+4,left:a==="right"?G.right-Z:G.left,alignToTop:z})},[a,r]);j.useEffect(()=>{E.current=k},[k]),j.useEffect(()=>{function G(V){if(v.current){const Z=V.target;v.current.contains(Z)||g(!1)}}return f&&document.addEventListener("mousedown",G),()=>{document.removeEventListener("mousedown",G)}},[f]),j.useEffect(()=>{f&&T()},[f,T]),j.useEffect(()=>{if(!f)return;setTimeout(()=>{var V;(V=v.current)==null||V.focus()},0);function G(V){const Z=E.current,J=Z.filter(P=>!L(P)),z=A(b.current,Z);switch(V.key){case"ArrowDown":if(V.preventDefault(),V.stopPropagation(),z<J.length-1){const P=O(b.current+1,Z);b.current=P,_(P)}break;case"ArrowUp":if(V.preventDefault(),V.stopPropagation(),z>0){const P=M(b.current-1,Z);b.current=P,_(P)}break;case"Enter":V.preventDefault(),V.stopPropagation(),H(b.current,Z);break;case"Escape":V.preventDefault(),V.stopPropagation(),g(!1);break}}return window.addEventListener("keydown",G,!0),()=>window.removeEventListener("keydown",G,!0)},[f,k]);function L(G){var J;const V=G.label;return V?String(((J=V.props)==null?void 0:J.className)??"").includes("cursor-default"):!1}function A(G,V){let Z=0;for(let J=0;J<G;J++){const z=V[J];z&&!L(z)&&Z++}return Z}function O(G,V){for(let Z=G;Z<V.length;Z++){const J=V[Z];if(J&&!L(J))return Z}return G}function M(G,V){for(let Z=G;Z>=0;Z--){const J=V[Z];if(J&&!L(J))return Z}return G}function H(G,V){var J;const Z=V[G];!Z||L(Z)||((J=Z.onClick)==null||J.call(Z),Z.href&&(window.history.pushState(null,"",Z.href),window.dispatchEvent(new PopStateEvent("popstate"))),g(!1))}j.useEffect(()=>{f&&(_(k.findIndex(G=>!L(G))),b.current=k.findIndex(G=>!L(G)))},[f,k]);const B=G=>{G.stopPropagation(),f||T(),g(!f)};function F(G,V,Z,J){const P=!L(G)&&J===S,D=s.jsxs(s.Fragment,{children:[G.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:G.icon}),s.jsx("span",{className:"min-w-0",children:G.label})]}),$=V!==Z-1?"border-b border-border":"",q=`px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${G.danger?"text-accent-error hover:bg-accent-error/10":P?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"}`,X=G.href?s.jsx(ir,{href:G.href,onClick:Y=>{var I;(I=G.onClick)==null||I.call(G,Y),g(!1)},onAuxClick:()=>g(!1),className:`w-full ${q}`,children:D}):s.jsx("button",{onClick:Y=>{var I;(I=G.onClick)==null||I.call(G,Y),G.closeOnClick!==!1&&g(!1)},className:`w-full ${q}`,children:D});return G.labelAction?s.jsxs("div",{className:`flex items-center gap-1 pr-1 ${$} ${u??""}`,children:[X,s.jsx("span",{className:"flex-shrink-0",children:G.labelAction})]},J):s.jsx("div",{className:$,children:X},J)}const K=x&&s.jsxs("div",{ref:v,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${x.alignToTop?"mb-1":"mt-1"}`,style:{top:x.top,left:x.left,minWidth:r},tabIndex:-1,children:[s.jsx(pt,{className:"max-h-[60vh]",children:e.map((G,V)=>F(G,V,e.length,V))}),t.length>0&&s.jsx("div",{className:"border-t border-border",children:t.map((G,V)=>F(G,V,t.length,e.length+V))})]});return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative",children:s.jsx("div",{ref:C,onClick:B,children:n})}),f&&wi.createPortal(K,document.body)]})}function pU(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 LT({isOpen:e,onClose:t,path:n,onRetry:r}){const[a,o]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(null);j.useEffect(()=>{e&&m()},[e]);const m=async()=>{try{const k=await(await me("/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})}},f=j.useCallback(async b=>{o(!0),u(null);try{const E=await(await me("/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?u("Failed to fix permissions: "+(E.error||"Unknown error")):u(`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){u("Failed to fix permissions: "+(k instanceof Error?k.message:"Unknown error"))}finally{o(!1)}},[n,r,t]),g=(d==null?void 0:d.userInGroup)??!1,x=(d==null?void 0:d.groupHasWrite)??!1,w=(d==null?void 0:d.sudoAvailable)??!1,C=(d==null?void 0:d.groupName)??"",v=g&&!x,S=!g&&x,_=!g&&!x;return s.jsx(Et,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"text-sm text-text-secondary",children:[s.jsx("p",{children:v?s.jsxs(s.Fragment,{children:["The group ",s.jsx("strong",{children:C})," doesn't have write access:"]}):S?s.jsxs(s.Fragment,{children:["You're not a member of group ",s.jsx("strong",{children:C}),":"]}):s.jsxs(s.Fragment,{children:["You're not a member of group ",s.jsx("strong",{children:C})," and it doesn't have write access:"]})}),s.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),c?s.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:c}):d?s.jsxs("div",{className:"flex flex-col gap-2",children:[v&&s.jsxs(s.Fragment,{children:[s.jsx(ot,{type:"button",variant:"primary",onClick:()=>f("group"),disabled:a||!w,className:"w-full",children:a?"Granting access...":"Extend group permissions"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),S&&s.jsxs(s.Fragment,{children:[s.jsx(ot,{type:"button",variant:"primary",onClick:()=>f("join_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER"]})]}),_&&s.jsxs(s.Fragment,{children:[s.jsx(ot,{type:"button",variant:"primary",onClick:()=>f("join_group_and_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group & grant write permissions"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER",s.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!w&&!c&&s.jsxs("div",{className:"text-xs text-text-secondary",children:[s.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),s.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),s.jsx("div",{className:"flex justify-end",children:s.jsx(ot,{type:"button",variant:"secondary",onClick:t,disabled:a,children:"Cancel"})})]}):null]})})}function RT({isOpen:e,onClose:t}){const[,n]=Nn(),r=Pt(E=>E.listProjects),[a,o]=j.useState(""),[c,u]=j.useState(null),[d,h]=j.useState(!1),[m,f]=j.useState(""),[g,x]=j.useState(null),w=j.useRef(null);j.useEffect(()=>{e&&(me("/api/config").then(E=>E.json()).then(E=>{E.workdir&&f(E.workdir)}),o(""),u(null),h(!1),x(null),setTimeout(()=>{var E;Gt()&&((E=w.current)==null||E.focus())},100))},[e]);const C=j.useCallback(async E=>{E.preventDefault();const T=pU(a);if(!T.valid){u(T.error);return}const L=`${m}/${a}`;await _(L)},[a,n,t,m]),v=j.useCallback(()=>{x(null)},[]),S=j.useCallback(async()=>{const E=`${m}/${a}`;await _(E)},[m,a,n,t,x,u,h]);async function _(E){h(!0),u(null),x(null);try{const T=await me("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,workdir:E})});if(!T.ok){const O=await T.json().catch(()=>({}));if(O.code==="EACCES"){x(E),h(!1);return}throw new Error(O.error||"Failed to create project")}const A=(await T.json()).project;t(),await r(),n(`/p/${A.id}`)}catch(T){u(T instanceof Error?T.message:"Failed to create project"),h(!1)}}const b=j.useCallback(()=>{o(""),u(null),t()},[t]),k=a?`${m}/${a}`:"";return s.jsxs(s.Fragment,{children:[s.jsx(Et,{isOpen:e,onClose:b,title:"Create New Project",size:"sm",children:s.jsxs("form",{onSubmit:C,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),s.jsx(Ms,{ref:w,id:"project-name",value:a,onChange:E=>{o(E.target.value),u(null)},placeholder:"my-project",disabled:d,"data-testid":"create-project-name-input",className:"w-full"}),a&&s.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",s.jsx("span",{className:"font-mono",children:k})]}),c&&s.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:c})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(ot,{type:"button",variant:"secondary",onClick:b,disabled:d,children:"Cancel"}),s.jsx(ot,{type:"submit",variant:"primary",disabled:d||!a.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:d?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Hr,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),g&&s.jsx(LT,{isOpen:!!g,onClose:v,path:g,onRetry:S})]})}function DT(){return an(e=>e.workdir)}function bk({projects:e,currentProject:t}){const[,n]=Nn(),r=Pt(v=>v.loadProject),a=Pt(v=>v.toggleStar),o=Pt(v=>v.createProject),c=Pt(v=>v.listProjects),[u,d]=j.useState(!1),[h,m]=j.useState(!1),f=DT(),g=j.useCallback(async v=>{const S=Au(v),_=await o(S,v);return _&&"id"in _?(await c(),m(!1),n(`/p/${_.id}`),!0):!1},[o,c,n]),w=j.useMemo(()=>{const v=e.filter(_=>_.isStarred).sort((_,b)=>_.name.localeCompare(b.name)),S=e.filter(_=>!_.isStarred).sort((_,b)=>_.name.localeCompare(b.name));return[...v,...S]},[e]).map(v=>({label:s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.jsx("span",{className:"truncate flex-1",children:v.name}),s.jsx("button",{onClick:S=>{S.stopPropagation(),S.preventDefault(),S.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?s.jsx(pu,{className:"w-3.5 h-3.5 text-yellow-500"}):s.jsx(qf,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:v.id===(t==null?void 0:t.id)?s.jsx(Hs,{}):void 0,href:`/p/${v.id}`,closeOnClick:!0,onClick:()=>{r(v.id)}})),C=[{label:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Cr,{className:"w-4 h-4"}),s.jsx("span",{children:"Open Project"})]}),onClick:()=>m(!0)},{label:s.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[s.jsx(Hr,{className:"w-4 h-4"}),s.jsx("span",{children:"New Project"})]}),onClick:()=>d(!0)}];return s.jsxs(s.Fragment,{children:[s.jsx(ho,{items:w,footerItems:C,trigger:s.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)??s.jsx("span",{className:"text-text-muted",children:"Select project..."}),s.jsx(gn,{})]}),minWidth:"250px"}),u&&s.jsx(RT,{isOpen:u,onClose:()=>d(!1)}),h&&s.jsx(Qf,{initialPath:f??void 0,onSelect:g,onClose:()=>m(!1)})]})}function OT(e){const t=new Date(e),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.getDay()],a=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),c=String(t.getDate()).padStart(2,"0");return`${r} ${a}/${o}/${c}`}function ym(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function IT(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()),o=Math.floor((r.getTime()-a.getTime())/(1e3*60*60*24)),c=ym(e);if(o===0)return`today ${c}`;if(o===1)return`yesterday ${c}`;if(o<7)return`${o} days ago ${c}`;{const u=t.getFullYear(),d=String(t.getMonth()+1).padStart(2,"0"),h=String(t.getDate()).padStart(2,"0");return`${u}/${d}/${h} ${c}`}}function MT(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 gU(e){const{year:t,month:n,day:r}=MT(e);return`${t}-${n}-${r}`}function PT(e){const t=new Map;for(const a of e){const o=gU(a.updatedAt);t.has(o)||t.set(o,[]),t.get(o).push(a)}for(const[a,o]of t)o.sort((c,u)=>{const d=new Date(c.updatedAt).getTime();return new Date(u.updatedAt).getTime()-d});const n=Array.from(t.keys()).sort((a,o)=>o.localeCompare(a)),r=new Map;for(const a of n)r.set(a,t.get(a));return r}function xU(e){const{year:t,month:n,day:r}=MT(e);return`${t}/${n}/${r} ${ym(e)}`}function xf(e,t){return e.length<=t?e:e.substring(0,t)+"..."}function yU({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:a}){var w;const o=Oe(C=>C.loadSession),c=Oe(C=>C.toggleFavorite),u=50,d=e.filter(C=>C.projectId===t.id).slice(0,15),h=d.filter(C=>C.isFavorite),m=d.filter(C=>!C.isFavorite),f=j.useMemo(()=>{const C=[];C.push({label:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Hr,{className:"w-4 h-4 text-accent-primary"}),s.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});const v=(_,b)=>{C.push({label:s.jsxs("div",{className:"min-w-[160px]",children:[s.jsx("div",{className:"truncate text-sm",children:xf(_.title??_.id.slice(0,8),u)}),b&&s.jsx("div",{className:"text-text-muted text-xs",children:ym(_.updatedAt)})]}),icon:_.id===(n==null?void 0:n.id)?s.jsx(Hs,{}):void 0,href:`/p/${t.id}/s/${_.id}`,onClick:()=>{o(_.id)},labelAction:s.jsx("button",{onClick:()=>c(_.id,!_.isFavorite),className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:_.isFavorite?"Unfavorite session":"Favorite session",children:_.isFavorite?s.jsx(pu,{className:"w-3.5 h-3.5 text-yellow-500"}):s.jsx(qf,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})})},S=_=>{const b=PT(_);for(const[k,E]of b){const T=E[0];if(T){C.push({label:s.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:OT(T.updatedAt)}),onClick:()=>{}});for(const L of E)v(L,!0)}}};if(h.length>0)for(const _ of h)v(_,!1);return S(m),C},[t.id,h,m,n==null?void 0:n.id]),g=((w=n==null?void 0:n.metadata)==null?void 0:w.title)??(n?n.id.slice(0,8):null),x=g?xf(g,u):"No session selected";return s.jsx(ho,{items:f,isOpen:r,onOpenChange:a,trigger:s.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:g??"","data-testid":"header-session-dropdown",children:[x,s.jsx(gn,{})]}),minWidth:"280px",labelActionClassName:"pr-3"})}function bU({items:e,trigger:t,isActive:n=!1}){const[r,a]=j.useState(!1),o=j.useRef(null);return j.useEffect(()=>{function c(u){o.current&&!o.current.contains(u.target)&&a(!1)}if(r)return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]),s.jsxs("div",{className:"relative",ref:o,children:[s.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"?s.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,s.jsx(gn,{className:"w-3 h-3 text-text-muted flex-shrink-0 transition-transform",rotate:r?180:0})]}),r&&e.length>0&&s.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((c,u)=>{const d=c.label&&typeof c.label=="object"&&c.label.type===ir?c.label:null;if(d){const h=d.props.href||"";return s.jsxs(ir,{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:[c.icon,d.props.children]},u)}return c.href?s.jsxs("a",{href:c.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[c.icon,c.label]},u):s.jsxs("button",{type:"button",onClick:()=>{var h;(h=c.onClick)==null||h.call(c),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:[c.icon,c.label]},u)})})]})}function vU({currentProject:e,sessions:t,currentSession:n,projectIdFromUrl:r}){if(!(e!=null&&e.id)||e.id!==r)return null;const a=t.filter(c=>c.projectId===e.id).sort((c,u)=>new Date(u.updatedAt).getTime()-new Date(c.updatedAt).getTime()).slice(0,5),o=[{label:s.jsxs(ir,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[s.jsx(Hr,{className:"w-3 h-3 text-accent-primary"}),s.jsx("span",{className:"text-sm",children:"New Session"})]})},...a.map(c=>({label:s.jsx(ir,{href:`/p/${e.id}/s/${c.id}`,className:"flex items-center gap-2 truncate text-sm",children:s.jsx("span",{children:xf(c.title??c.id.slice(0,8),50)})}),icon:c.id===(n==null?void 0:n.id)?s.jsx(Hs,{className:"w-3 h-3"}):void 0})),{label:s.jsxs(ir,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[s.jsx(K3,{className:"w-3 h-3"}),s.jsx("span",{className:"text-sm",children:"Projects"})]})}];return s.jsx(bU,{items:o,trigger:s.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function BT(){const e=dt(a=>a.defaults),t=dt(a=>a.userItems),n=dt(a=>a.projectItems),r=dt(a=>a.fetchAgents);return{agents:[...e,...t,...n],fetchAgents:r}}function $T({projectName:e,children:t}){return s.jsxs("span",{className:"inline-flex items-center gap-1.5 min-w-0",children:[s.jsx("span",{className:"truncate max-w-[240px] font-normal text-text-muted",title:e,children:e}),s.jsx(Y3,{className:"w-3 h-3 text-text-muted shrink-0"}),s.jsx("span",{className:"truncate",children:t})]})}function _U({task:e,projectId:t,agents:n,queuePosition:r,onEdit:a,onMove:o,onMoveUp:c,onMoveDown:u,onDuplicate:d,onDelete:h,onDragStart:m,onDropOnCard:f,onOpenSession:g}){const[x,w]=j.useState(!1),C=n.find(E=>E.id===e.agentId),v=e.agentId?oo(n,e.agentId):void 0,S=e.attachments.filter(E=>E.mimeType.startsWith("image/")),_=e.activeSessionId??e.sessionIds[e.sessionIds.length-1],b=[{label:"Edit",icon:s.jsx(_b,{className:"w-3.5 h-3.5"}),onClick:()=>a(e)},{label:"History & evidence",icon:s.jsx(Vf,{className:"w-3.5 h-3.5"}),onClick:()=>w(E=>!E)},{label:s.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:"Move to…"}),onClick:()=>{}},{label:"To Do",onClick:()=>o(e,"todo")},{label:"In Progress",onClick:()=>o(e,"in_progress")},{label:"Done",onClick:()=>o(e,"done")},{label:"Move up",icon:s.jsx(vb,{className:"w-3.5 h-3.5"}),onClick:()=>c(e)},{label:"Move down",icon:s.jsx(gn,{className:"w-3.5 h-3.5"}),onClick:()=>u(e)}],k=[{label:"Duplicate",icon:s.jsx(El,{className:"w-3.5 h-3.5"}),onClick:()=>d(e)},{label:"Delete",icon:s.jsx(Si,{className:"w-3.5 h-3.5"}),danger:!0,onClick:()=>h(e)}];return s.jsxs("div",{draggable:!0,onClick:()=>a(e),onDragStart:E=>{E.dataTransfer.effectAllowed="move",m(e)},onDragOver:E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},onDrop:E=>{E.preventDefault(),f(e)},className:`group relative cursor-pointer bg-bg-tertiary border border-border rounded-lg p-2.5 hover:border-accent-primary/40 transition-colors ${e.status==="in_progress"?"ring-1 ring-inset ring-accent-primary/20":""}`,children:[e.status==="in_progress"&&s.jsxs("span",{className:`mb-1.5 inline-flex items-center gap-1 text-xs font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded ${e.runState==="running"?"bg-emerald-500/15 text-emerald-400":"bg-amber-500/15 text-amber-400"}`,children:[e.runState==="running"?s.jsx(Wf,{className:"w-2.5 h-2.5"}):s.jsx(EE,{className:"w-2.5 h-2.5"}),e.runState==="running"?"Running":`Queued${r!==void 0?` · ${r}`:""}`]}),s.jsx("p",{className:"pr-8 text-sm text-text-primary leading-relaxed line-clamp-3 break-words whitespace-pre-wrap",children:e.prompt}),s.jsx("div",{className:"absolute top-2 right-2",onClick:E=>E.stopPropagation(),children:s.jsx(ho,{items:b,footerItems:k,minWidth:"176px",align:"right",trigger:s.jsx("button",{type:"button",className:"p-1 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Task actions","aria-label":`Actions for ${e.prompt.slice(0,40)}`,children:s.jsx(Sb,{className:"w-4 h-4"})})})}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.attachments.length>0&&s.jsxs("span",{className:"text-xs text-text-muted flex items-center gap-1",title:`${e.attachments.length} attachment(s)`,children:["📎 ",e.attachments.length]}),S.length>0&&s.jsx("span",{className:"flex -space-x-1",children:S.slice(0,3).map(E=>s.jsx("img",{src:E.data,alt:"",className:"w-6 h-6 rounded object-cover ring-2 ring-bg-tertiary"},E.id))}),e.model&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bg-secondary border border-border text-text-muted truncate max-w-36",title:e.model,children:e.model}),C&&s.jsxs("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bg-secondary border border-border flex items-center gap-1",style:{color:v},children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:v}}),C.name]}),_&&s.jsxs(ir,{href:`/p/${t}/s/${_}`,onClick:E=>{E.stopPropagation(),g==null||g(_)},className:"ml-auto text-xs px-1.5 py-1 rounded bg-accent-primary/10 text-accent-primary hover:bg-accent-primary/20 flex items-center gap-1",children:["Open session ",s.jsx(Cb,{className:"w-2.5 h-2.5"})]})]}),x&&e.auditTrail.length>0&&s.jsxs("div",{className:"mt-2 pt-2 border-t border-border space-y-1",children:[s.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted",children:"History"}),e.auditTrail.map(E=>s.jsxs("div",{className:"text-xs text-text-muted leading-relaxed",children:[s.jsx("span",{className:"text-text-primary",children:E.action}),E.detail&&s.jsxs("span",{children:[" — ",E.detail]}),s.jsxs("span",{className:"text-text-muted/70",children:[" ","· ",E.actor,E.actorName&&E.actorName!==E.actor?` (${E.actorName})`:""," ·"," ",new Date(E.timestamp).toLocaleString()]})]},E.id))]})]})}function SU({title:e,accentClass:t,hint:n,tasks:r,projectId:a,agents:o,queuePositionOf:c,headerAction:u,footer:d,onEdit:h,onMove:m,onMoveUp:f,onMoveDown:g,onDuplicate:x,onDelete:w,onDragStart:C,onDropOnColumn:v,onDropOnCard:S,onOpenSession:_}){return s.jsxs("section",{onDragOver:b=>{b.preventDefault(),b.dataTransfer.dropEffect="move"},onDrop:b=>{b.preventDefault(),v()},className:"flex flex-col min-w-64 w-72 max-w-72 bg-bg-secondary/60 border border-border rounded-lg overflow-hidden",children:[s.jsxs("header",{className:`flex items-center gap-2 min-h-[51px] px-3 py-2 border-b border-border ${t}`,children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 text-left",children:[s.jsx("span",{className:"text-sm font-semibold uppercase tracking-wide text-text-primary",children:e}),s.jsx("span",{className:"text-xs text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded-full",children:r.length})]}),u]}),n&&s.jsx("p",{className:"px-3 pt-2 text-sm text-text-muted italic",children:n}),s.jsxs("div",{className:"p-2 space-y-2 overflow-y-auto flex-1 min-h-24",children:[r.map(b=>s.jsx(_U,{task:b,projectId:a,agents:o,queuePosition:c(b),onEdit:h,onMove:m,onMoveUp:f,onMoveDown:g,onDuplicate:x,onDelete:w,onDragStart:C,onDropOnCard:S,onOpenSession:_},b.id)),r.length===0&&s.jsx("div",{className:"text-sm text-text-muted text-center py-6 border border-dashed border-border rounded-lg",children:"Empty"})]}),d&&s.jsx("div",{className:"border-t border-border",children:d})]})}const wU={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},CU="M6 18L18 6M6 6l12 12";function Pu({onClick:e,className:t="",size:n="md",variant:r="default","aria-label":a,title:o="Close"}){const c=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 s.jsx(Yf,{onClick:e,icon:CU,iconSize:wU[n],className:`${c} ${t}`,title:o,...a!==void 0?{"aria-label":a}:{}})}const kU=["text/"],jU=["application/json","application/xml","application/yaml","application/x-yaml","application/javascript","application/xhtml+xml","application/x-sh","image/svg+xml"];function Vh(e){return e.startsWith("image/")}function FT(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function xv(e){return jU.includes(e)||kU.some(t=>e.startsWith(t))}function xl(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function HT(e){const t=e.lastIndexOf(".");return t<=0||t>=e.length-1?"FILE":e.slice(t+1).toUpperCase()}const EU={"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 NU(e){var t;return EU[e]||((t=e.split("/")[1])==null?void 0:t.split("+")[0])||"file"}function TU(e){return Vh(e)||xv(e)||e==="application/pdf"}function yv({attachment:e,onRemove:t}){const n=HT(e.filename);return s.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[s.jsx(Pu,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),FT(e.mimeType)?s.jsx("img",{src:e.data,alt:e.description||e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}):s.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}),s.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),s.jsx("div",{className:"text-[10px] text-text-muted",children:xl(e.size)})]})}function AU(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function LU(e,t){const n=t.toLowerCase(),r=(e.name??"").toLowerCase(),a=e.id.toLowerCase(),o=a.replace(/-/g," ");return r.includes(n)||a.includes(n)||o.includes(n)}function vk(e){return e.models.some(n=>n.selected)?e.models.filter(n=>n.selected):e.models}function zT({providerId:e,modelConfig:t,isActive:n,isDefault:r,disabled:a,hasSession:o,settingDefault:c,highlighted:u,onModelClick:d,onSetDefault:h,onEditModel:m}){var f;return s.jsxs("div",{className:`flex items-center px-4 py-1.5 text-sm transition-colors group ${u?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${a?"opacity-50 cursor-wait":""} ${n?"text-accent-primary":"text-text-secondary"}`,children:[s.jsx("button",{type:"button",onClick:()=>d(e,t.id),disabled:a,className:"flex-1 truncate text-left",children:t.name??((f=t.id.split("/").pop())==null?void 0:f.replace(/-/g," "))??t.id}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 ml-2",children:[s.jsx("span",{className:"text-xs text-text-muted",children:AU(t.contextWindow)}),o&&h&&s.jsx("button",{type:"button",onClick:g=>h(g,e,t.id),disabled:c,className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors disabled:opacity-40",title:r?"Default model":"Set as default model",children:r?s.jsx(pu,{className:"w-3.5 h-3.5 text-accent-warning"}):s.jsx(qf,{className:"w-3.5 h-3.5 text-text-muted hover:text-accent-warning"})}),m&&s.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),m(e,t)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:s.jsx(_b,{className:"w-3 h-3 text-text-muted"})}),n&&s.jsx("span",{className:"text-accent-success flex-shrink-0",title:"Session model",children:s.jsx(Hs,{className:"w-3.5 h-3.5"})})]})]})}function UT({providers:e,onSelect:t,onEscape:n,extraItemCount:r=0}){const[a,o]=j.useState(""),[c,u]=j.useState(-1),d=j.useRef(null),h=j.useRef(null),m=j.useMemo(()=>a.trim()?e.map(w=>({provider:w,models:vk(w).filter(C=>LU(C,a))})).filter(w=>w.models.length>0):e.map(w=>({provider:w,models:vk(w)})),[e,a]),f=j.useMemo(()=>m.flatMap(w=>w.models.map(C=>({providerId:w.provider.id,modelConfig:C}))),[m]),g=f.length+r;return j.useEffect(()=>{g<=1?u(-1):c>=g?u(g-1):c<0&&a.trim()&&u(0)},[g,c,a]),j.useEffect(()=>{c>=0&&d.current&&d.current.scrollIntoView({block:"nearest"})},[c]),{searchQuery:a,setSearchQuery:o,highlightedIndex:c,setHighlightedIndex:u,visibleGroups:m,flatItems:f,totalNavItems:g,handleSearchKeyDown:w=>{switch(w.key){case"Escape":w.preventDefault(),n==null||n();break;case"ArrowDown":w.preventDefault(),g>0&&u(C=>C<g-1?C+1:0);break;case"ArrowUp":w.preventDefault(),g>0&&u(C=>C>0?C-1:g-1);break;case"Home":w.preventDefault(),u(0);break;case"End":w.preventDefault(),u(g-1);break;case"Enter":if(w.preventDefault(),c>=0&&c<f.length){const C=f[c];C&&t(C.providerId,C.modelConfig.id)}break}},highlightedRef:d,inputRef:h}}function bv({providers:e,value:t,onChange:n,defaultLabel:r="Default (global model)"}){var T;const[a,o]=j.useState(!1),c=j.useRef(null),u=j.useRef(null),[d,h]=j.useState({}),m=t==null?void 0:t.split("/").slice(1).join("/"),f=m?((T=m.split("/").pop())==null?void 0:T.replace(/-/g," "))??m:void 0,{searchQuery:g,setSearchQuery:x,highlightedIndex:w,setHighlightedIndex:C,visibleGroups:v,flatItems:S,handleSearchKeyDown:_,highlightedRef:b,inputRef:k}=UT({providers:e,onSelect:(L,A)=>{n(`${L}/${A}`),o(!1)},onEscape:()=>o(!1)}),E=j.useCallback(()=>{if(!a||!u.current)return;const L=u.current.getBoundingClientRect();h({position:"fixed",top:`${L.bottom+4}px`,left:`${L.left}px`,width:`${Math.max(L.width,288)}px`})},[a]);return j.useEffect(()=>(E(),window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}),[E]),j.useEffect(()=>{if(!a)return;function L(O){var M;c.current&&!c.current.contains(O.target)&&!((M=O.target)!=null&&M.closest("[data-model-picker-dropdown]"))&&(o(!1),x(""),C(-1))}const A=setTimeout(()=>{document.addEventListener("mousedown",L)},0);return()=>{clearTimeout(A),document.removeEventListener("mousedown",L)}},[a,x,C]),j.useEffect(()=>{var L;a?(E(),Gt()&&((L=k.current)==null||L.focus())):(x(""),C(-1))},[a,x,C,k,E]),s.jsxs("div",{className:"relative",ref:c,children:[s.jsxs("button",{ref:u,type:"button",onClick:()=>o(!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:[s.jsx("span",{className:f?"text-text-primary":"text-text-muted",children:f??r}),s.jsx(gn,{className:`w-3 h-3 text-text-muted transition-transform ${a?"rotate-180":""}`})]}),a&&typeof document<"u"&&wi.createPortal(s.jsx("div",{"data-model-picker-dropdown":!0,className:"z-50",style:d,children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg flex flex-col max-h-80",children:[s.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[s.jsx(_i,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("input",{ref:k,type:"text",value:g,onInput:L=>{x(L.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"})]}),s.jsxs(pt,{className:"flex-1",children:[s.jsx("button",{type:"button",onClick:()=>{n(void 0),o(!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(L=>s.jsxs("div",{children:[s.jsx("div",{className:"px-4 py-1.5 text-xs font-medium text-text-muted uppercase tracking-wider bg-bg-tertiary/50",children:L.provider.name}),L.models.map(A=>{const M=S.findIndex(B=>B.providerId===L.provider.id&&B.modelConfig.id===A.id)===w,H=t===`${L.provider.id}/${A.id}`;return s.jsx("div",{ref:M?b:void 0,children:s.jsx(zT,{providerId:L.provider.id,modelConfig:A,isActive:H,highlighted:M,onModelClick:(B,F)=>{n(`${B}/${F}`),o(!1)}})},`${L.provider.id}/${A.id}`)})]},L.provider.id)),v.length===0&&g.trim()&&s.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No models match your search"})]})]})}),document.body)]})}function RU(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(`
|
|
275
|
+
`)||r.includes(" ")?null:{query:r,startIndex:0}}const vv={builtin:"Built-in",user:"Global",project:"Project"};function yf(e,t){const n=e.filter(r=>r.id===t);if(n.length!==0)return n.find(r=>r.scope==="project")??n.find(r=>r.scope==="user")??n.find(r=>r.scope==="builtin")}function Vy(e,t,n){return n!=="auto"?e.find(r=>r.id===t&&r.scope===n)??yf(e,t):yf(e,t)}const VT=j.forwardRef(function({text:t,cursorPos:n,workflows:r,commands:a,onSelect:o},c){const u=RU(t,n),[d,h]=j.useState(0),m=j.useRef(null),f=j.useRef([]),g=j.useRef(0),x=j.useRef([]);j.useEffect(()=>{g.current=d},[d]),j.useEffect(()=>{x.current=C});const w=(u==null?void 0:u.query)??"",C=(()=>{if(!u)return[];const S=w.toLowerCase(),_=r.filter(k=>k.id.toLowerCase().includes(S)||k.name.toLowerCase().includes(S)).map(k=>({type:"workflow",id:k.id,name:k.name,scope:k.scope,paramCount:(k.parameters??[]).length})),b=a.filter(k=>k.id.toLowerCase().includes(S)||k.name.toLowerCase().includes(S)).map(k=>({type:"command",id:k.id,name:k.name,paramCount:0}));return[..._,...b]})();j.useEffect(()=>{h(0),g.current=0},[C.length]);const v=j.useCallback(S=>{if(!u||C.length===0)return!1;switch(S.key){case"ArrowDown":return S.preventDefault(),h(_=>{var k;const b=Math.min(_+1,C.length-1);return(k=f.current[b])==null||k.scrollIntoView({block:"nearest"}),b}),!0;case"ArrowUp":return S.preventDefault(),h(_=>{var k;const b=Math.max(_-1,0);return(k=f.current[b])==null||k.scrollIntoView({block:"nearest"}),b}),!0;case"Enter":case"Tab":{const _=C[g.current];return _?(S.preventDefault(),o(_,u.startIndex),!0):!1}case"Escape":return S.preventDefault(),!0}return!1},[u,C,o]);return j.useImperativeHandle(c,()=>({handleKeyDown:v}),[v]),!u||C.length===0?null:s.jsx("div",{ref:m,className:"absolute bottom-full left-0 right-0 mb-2 z-50",role:"listbox",children:s.jsx(pt,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:s.jsx("div",{children:C.map((S,_)=>s.jsxs("button",{ref:b=>{f.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:()=>{u&&o(S,u.startIndex)},children:[s.jsxs("span",{className:`font-medium ${S.type==="workflow"?"text-accent-primary":"text-accent-warning"}`,children:["/",S.id]}),s.jsx("span",{className:"truncate flex-1",children:S.name}),S.type==="workflow"&&s.jsx("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded whitespace-nowrap",children:vv[S.scope]}),S.paramCount>0&&s.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded",children:[S.paramCount," param",S.paramCount>1?"s":""]})]},`${S.type}-${S.id}-${S.type==="workflow"?S.scope:""}`))})})})});function DU(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(`
|
|
276
|
+
`)||a.includes(" ")?null:{query:a,startIndex:r}}const WT=j.forwardRef(function({text:t,cursorPos:n,workdir:r,onSelect:a},o){const c=DU(t,n),[u,d]=j.useState([]),[h,m]=j.useState(!1),[f,g]=j.useState(0),x=j.useRef(null),w=j.useRef([]),C=j.useRef(0),v=j.useRef([]);j.useEffect(()=>{C.current=f},[f]),j.useEffect(()=>{v.current=u},[u]),j.useEffect(()=>{if(!c){d([]);return}const b=setTimeout(()=>{S(c.query)},150);return()=>clearTimeout(b)},[c==null?void 0:c.query,r]);const S=async b=>{m(!0);try{const k=new URLSearchParams({q:b});r&&k.set("workdir",r);const T=await(await me(`/api/files?${k.toString()}`)).json();d(T),g(0),C.current=0}catch(k){console.error("File search failed:",k),d([])}finally{m(!1)}},_=j.useCallback(b=>{if(!c)return!1;switch(b.key){case"ArrowDown":return b.preventDefault(),g(k=>{var T;const E=Math.min(k+1,v.current.length-1);return w.current[E]&&((T=w.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(),g(k=>{var T;const E=Math.max(k-1,0);return w.current[E]&&((T=w.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],c.startIndex),!0):!1}case"Escape":return b.preventDefault(),d([]),!0}return!1},[c,a]);return j.useImperativeHandle(o,()=>({handleKeyDown:_}),[_]),j.useEffect(()=>{if(!c)return;const b=k=>{x.current&&!x.current.contains(k.target)&&d([])};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[c]),c?h?s.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:s.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg",children:s.jsx("div",{className:"p-4 text-center",children:s.jsx(fa,{size:"sm"})})})}):u.length===0?null:s.jsx("div",{ref:x,className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:s.jsx(pt,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:s.jsx("ul",{children:u.map((b,k)=>s.jsxs("li",{ref:E=>{w.current[k]=E},className:`px-3 py-2 cursor-pointer flex items-center gap-2 text-sm ${k===f?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{c&&a(b,c.startIndex)},children:[b.type==="directory"?s.jsx(Cr,{className:"w-4 h-4 shrink-0"}):s.jsx("span",{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"truncate",children:b.path})]},b.path))})})}):null}),_k=e=>Symbol.iterator in e,Sk=e=>"entries"in e,wk=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[a,o]of n)if(!r.has(a)||!Object.is(o,r.get(a)))return!1;return!0},OU=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let a=n.next(),o=r.next();for(;!a.done&&!o.done;){if(!Object.is(a.value,o.value))return!1;a=n.next(),o=r.next()}return!!a.done&&!!o.done};function IU(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:_k(e)&&_k(t)?Sk(e)&&Sk(t)?wk(e,t):OU(e,t):wk({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function GT(e){const t=ps.useRef(void 0);return n=>{const r=e(n);return IU(t.current,r)?t.current:t.current=r}}const Ba=e=>e?`?workdir=${encodeURIComponent(e)}`:"",Px=e=>e?`&scope=${e}`:"",lo=e=>[...e.defaults,...e.userItems,...e.projectItems],bm=()=>Wt(GT(lo)),Wt=Zn((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],setWorkdir:n=>e({workdir:n}),fetchTemplateVariables:async()=>{try{const r=await(await me("/api/workflows/template-variables")).json();e({templateVariables:r.variables??[]})}catch{}},fetchWorkflows:async n=>{e({loading:!0});try{const a=await(await me(`/api/workflows${Ba(n??t().workdir)}`)).json();e({defaults:a.defaults??[],userItems:a.userItems??[],projectItems:a.projectItems??[],activeWorkflowId:a.activeWorkflowId??"default",loading:!1})}catch{e({loading:!1})}},fetchWorkflow:async(n,r,a)=>{try{const o=await me(`/api/workflows/${n}${Ba(r??t().workdir)}${Px(a)}`);return o.ok?await o.json():null}catch{return null}},fetchDefaultContent:async(n,r)=>{try{const a=await me(`/api/workflows/defaults/${n}${Ba(r??t().workdir)}`);return a.ok?await a.json():null}catch{return null}},createWorkflow:async(n,r,a)=>{const o=a??t().workdir,c=await da("POST",`/api/workflows${Ba(o)}`,{...n,destination:r});return c.success&&await t().fetchWorkflows(o),c},updateWorkflow:async(n,r,a,o)=>{const c=a??t().workdir,u=await da("PUT",`/api/workflows/${n}${Ba(c)}${Px(o)}`,r);return u.success&&await t().fetchWorkflows(c),u},deleteWorkflow:async(n,r,a)=>{try{const o=await me(`/api/workflows/${n}${Ba(a??t().workdir)}${Px(r)}`,{method:"DELETE"}),c=await o.json();return o.ok?(e(u=>({...r==="user"?{userItems:u.userItems.filter(d=>d.id!==n)}:{},...r==="project"?{projectItems:u.projectItems.filter(d=>d.id!==n)}:{}})),{success:!0}):{success:!1,error:c.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateWorkflow:async(n,r,a)=>{const o=a??t().workdir;return Ff(`/api/workflows/${n}/duplicate${Ba(o)}`,()=>t().fetchWorkflows(o),r)}}));async function MU(e,t,n){t({loading:!0});try{const a=await(await me(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const rl=(e,t)=>t?`${e}?workdir=${encodeURIComponent(t)}`:e,fn=Zn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async n=>{await MU(rl("/api/commands",n),e,!0)},fetchCommand:async(n,r)=>{try{const a=await me(rl(`/api/commands/${n}`,r));return a.ok?await a.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await me(`/api/commands/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createCommand:async(n,r,a)=>{const o=await da("POST",rl("/api/commands",a),{...n,destination:r});return o.success&&await t().fetchCommands(a),o},updateCommand:async(n,r,a)=>{const o=await da("PUT",rl(`/api/commands/${n}`,a),r);return o.success&&await t().fetchCommands(a),o},deleteCommand:async(n,r)=>{try{const a=await me(rl(`/api/commands/${n}`,r),{method:"DELETE"}),o=await a.json();return a.ok?(e(c=>({userItems:c.userItems.filter(u=>u.id!==n),projectItems:c.projectItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:o.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateCommand:async(n,r,a)=>Ff(rl(`/api/commands/${n}/duplicate`,a),()=>t().fetchCommands(a),r)}));function Gn(e,t){const n=new Set(t.map(r=>r.id));return[...e.filter(r=>!n.has(r.id)),...t]}function Wy(e,t){if(!t)return e;const n=e.toLowerCase(),r=t.toLowerCase(),a=new Array(e.length).fill(!1),o=n.indexOf(r);if(o>=0)for(let m=o;m<o+r.length;m++)a[m]=!0;else{let m=0;for(let f=0;f<e.length&&m<r.length;f++)n[f]===r[m]&&(a[f]=!0,m++)}const c=Array.from(e),u=[];let d="",h=a[0]??!1;for(let m=0;m<c.length;m++){const f=c[m]??"";a[m]===h?d+=f:(u.push(h?s.jsx("span",{className:"font-semibold text-accent-primary",children:d},u.length):d),d=f,h=a[m]??!1)}return u.push(h?s.jsx("span",{className:"font-semibold text-accent-primary",children:d},u.length):d),s.jsx(s.Fragment,{children:u})}function aa(e,t){if(!t)return!0;const n=t.toLowerCase().split(/\s+/),r=e.toLowerCase().split(/\s+/);return n.every(a=>{for(const o of r){let c=0;for(let u=0;u<o.length&&c<a.length;u++)o[u]===a[c]&&c++;if(c===a.length)return!0}return!1})}function qT(e,t,n,r,a){switch(e.key){case"ArrowDown":e.preventDefault(),n(o=>Math.min(o+1,t));break;case"ArrowUp":e.preventDefault(),n(o=>Math.max(o-1,0));break;case"Enter":e.preventDefault(),r();break;case"Escape":e.preventDefault(),a();break}}function bf(e,t,n,r){const a=e.slice(0,n),o=e.slice(t);return{newText:`${a}${r}${o}`,newCursorPos:n+r.length}}function vf(e,t){e&&(e.selectionStart=t,e.selectionEnd=t,e.focus())}function KT(e){if(e.type==="workflow"){const r=lo(Wt.getState()).find(a=>a.id===e.id&&a.scope===e.scope);return((r==null?void 0:r.parameters)??[]).map(a=>a.id)}const t=fn.getState(),n=Gn(Gn(t.defaults,t.userItems),t.projectItems).find(r=>r.id===e.id);return(n==null?void 0:n.paramNames)??[]}const PU={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function BU(e,t={}){const n={...PU,...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(),o=WU(a),c=`data:${e.type};base64,${o}`,u=await YT(c);return{dataUrl:c,mimeType:e.type,size:e.size,width:u.width,height:u.height}}return await $U(e,n)}async function $U(e,t){const n=await HU(e),r=await YT(n),{width:a,height:o}=FU(r.width,r.height,t.maxWidth,t.maxHeight),c=zU();c.width=a,c.height=o;const u=c.getContext("2d");if(!u)throw new Error("Failed to get canvas context");u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(r,0,0,a,o);let d=t.quality,h="";for(let f=0;f<10&&(h=c.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,d),!(Ck(h)<=t.maxSizeBytes||d<=.3));f++)d-=.1;const m=Ck(h);return{dataUrl:h,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:m,width:a,height:o}}function FU(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 HU(e){return new Promise((t,n)=>{const r=VU(),a=new r;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function YT(e){return new Promise((t,n)=>{const r=UU(),a=new r;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function zU(){var t;const e=_v();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function UU(){const e=_v();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function VU(){const e=_v();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function _v(){return globalThis}function WU(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 Ck(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}const kk=50*1024*1024,jk=1024*1024,GU=["image/png","image/jpeg","image/gif"];function qU(e){return e==="application/pdf"}function KU(e){return GU.includes(e.type)}async function YU(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 Gy(e,t,n){try{if(xv(e.type)){if(e.size>jk){n(`Text file too large (${xl(e.size)}). Maximum is ${xl(jk)}.`);return}const r=await e.text(),a={id:Mh(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}else if(Vh(e.type)||qU(e.type)){if(e.size>kk){const r=Vh(e.type)?"Image":"PDF";n(`${r} file too large (${xl(e.size)}). Maximum is ${xl(kk)}.`);return}if(Vh(e.type)&&KU(e)){const r=await BU(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),a={id:Mh(),filename:e.name||"unnamed-file",mimeType:r.mimeType,size:r.size,data:r.dataUrl};t(a)}else{const r=await YU(e),a={id:Mh(),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)}}const XU="openfox:task-draft";function QU({projectId:e,initialTask:t,onClose:n,onSaved:r}){var Je;const a=!!t,o=Ht(_e=>_e.createTask),c=Ht(_e=>_e.updateTask),u=Ht(_e=>_e.lastError),{agents:d,fetchAgents:h}=BT(),m=d.filter(_e=>!_e.subagent),f=an(_e=>_e.providers),x=(Je=Pt(_e=>_e.projects).find(_e=>_e.id===e))==null?void 0:Je.workdir;j.useEffect(()=>{h()},[h]);const w=`${XU}:${e}:${(t==null?void 0:t.id)??"new"}`,[C,v]=j.useState(()=>(t==null?void 0:t.prompt)??""),[S,_]=j.useState(()=>(t==null?void 0:t.attachments)??[]),[b,k]=j.useState(()=>(t==null?void 0:t.agentId)??void 0),[E,T]=j.useState(()=>t==null?void 0:t.providerId),[L,A]=j.useState(()=>t==null?void 0:t.model),[O,M]=j.useState(null),[H,B]=j.useState(!1),[F,K]=j.useState([]),G=j.useRef(null),V=j.useRef(null),Z=j.useRef(null),J=j.useRef(null),z=j.useRef(0),P=j.useRef([]),[D,U]=j.useState(!1);j.useEffect(()=>{if(x)return;let _e=!1;return me(`/api/projects/${e}`).then(ge=>ge.ok?ge.json():null).then(ge=>{var he;!_e&&((he=ge==null?void 0:ge.project)!=null&&he.workdir)&&Pt.setState({currentProject:ge.project})}).catch(()=>{}),()=>{_e=!0}},[e,x]),j.useEffect(()=>{try{const _e=localStorage.getItem(w);if(_e){const ge=JSON.parse(_e);ge.prompt&&v(ge.prompt)}}catch{}},[]),j.useEffect(()=>{const _e=setTimeout(()=>{try{localStorage.setItem(w,JSON.stringify({prompt:C}))}catch{}},300);return()=>clearTimeout(_e)},[C,w]);const $=j.useCallback(_e=>{for(const ge of Array.from(_e))Gy(ge,he=>_(ae=>[...ae,he]),he=>M(he))},[]),te=_e=>{_e.clipboardData.files.length>0&&$(_e.clipboardData.files)},q=_e=>{_e.preventDefault()},X=_e=>{_e.preventDefault(),_e.dataTransfer.files.length>0&&$(_e.dataTransfer.files)},Y=_e=>{P.current.push(_e),P.current.length>50&&P.current.shift(),U(!0)},I=_e=>{_e!==C&&(Y(C),v(_e))},Q=()=>{var ge;const _e=P.current.pop();_e!==void 0&&(v(_e),U(P.current.length>0),(ge=G.current)==null||ge.focus())},ne=j.useCallback((_e,ge)=>{const{newText:he,newCursorPos:ae}=bf(C,z.current,ge,`/${_e.id} `);Y(C),v(he),z.current=ae,vf(G.current,ae),K(KT(_e))},[C]),re=j.useCallback((_e,ge)=>{const ae=_e.type==="directory"?"/":" ",{newText:Pe,newCursorPos:Ue}=bf(C,z.current,ge,`@${_e.path}${ae}`);Y(C),v(Pe),z.current=Ue,vf(G.current,Ue)},[C]),ie=async()=>{const _e=C.trim().length>0,ge=S.length>0;if(!_e&&!ge){M("Add a prompt or an attachment");return}B(!0),M(null);const he={prompt:C,...S.length>0?{attachments:S}:{},...a?{agentId:b??null}:b?{agentId:b}:{},...a&&(t!=null&&t.providerId)&&!E?{providerId:null}:E?{providerId:E}:{},...a&&(t!=null&&t.model)&&!L?{model:null}:L?{model:L}:{}},ae=a?await c(e,t.id,he):await o(e,he);if(B(!1),ae){try{localStorage.removeItem(w)}catch{}r(ae)}else M(u??"Could not save the task")},pe=_e=>{var ge,he;if(!((ge=J.current)!=null&&ge.handleKeyDown(_e))&&!((he=Z.current)!=null&&he.handleKeyDown(_e))){if(_e.key==="z"&&(_e.metaKey||_e.ctrlKey)){_e.preventDefault(),Q();return}_e.key==="Enter"&&!_e.shiftKey&&!_e.nativeEvent.isComposing&&(_e.preventDefault(),ie())}},ye=lo(Wt.getState()),Ie=(()=>{const _e=fn.getState();return Gn(Gn(_e.defaults,_e.userItems),_e.projectItems)})(),$e=(()=>{if(F.length===0)return 0;const _e=C.match(/\/(\w+)\s+(.*)$/),he=(_e?_e[2].trim().split(/\s+/):[]).filter(Boolean).length;return F[he]?F.length-he:0})(),Se=E&&L?`${E}/${L}`:void 0,Ge=a&&t.status==="in_progress"&&t.runState==="running";return s.jsxs(Et,{isOpen:!0,onClose:n,title:a?"Edit task":"New task",size:"lg",showCloseButton:!0,footer:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-sm text-text-muted truncate",children:Ge?"This task is already in progress — changes apply to the next run.":"Enter to save · Shift+Enter for a new line"}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(ot,{onClick:n,children:"Cancel"}),s.jsx(ot,{variant:"primary",onClick:()=>void ie(),disabled:H,children:H?"Saving…":a?"Save changes":"Create task"})]})]}),children:[Ge&&s.jsx("div",{className:"mb-3 px-3 py-2 rounded bg-accent-primary/10 border border-accent-primary/30 text-sm text-text-primary",children:"This task is already in progress — changes apply to the next run."}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-muted mb-1",children:"Prompt"}),s.jsxs("div",{className:"relative",onDragOver:q,onDrop:X,children:[s.jsx("textarea",{ref:G,value:C,onChange:_e=>I(_e.target.value),onSelect:_e=>{z.current=_e.currentTarget.selectionStart},onPaste:te,onKeyDown:pe,rows:6,placeholder:"Describe the task. Slash commands (/cmd) and workflows resolve exactly as in chat when the task launches.",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary outline-none focus:border-accent-primary resize-y min-h-32"}),s.jsx(WT,{ref:Z,text:C,cursorPos:z.current,workdir:x,onSelect:re}),s.jsx(VT,{ref:J,text:C,cursorPos:z.current,workflows:ye,commands:Ie,onSelect:ne}),F.length>0&&$e>0&&s.jsxs("div",{className:"absolute top-2 right-14 text-xs text-text-muted bg-bg-secondary/90 border border-border rounded px-2 py-1",children:[$e," required param",$e>1?"s":""," — tab through after the command"]}),s.jsxs("div",{className:"absolute bottom-2 right-2 flex items-center gap-1",children:[s.jsx("button",{type:"button",onClick:Q,disabled:!D,className:"p-1.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary transition-colors disabled:opacity-40 disabled:hover:bg-transparent",title:"Undo (Ctrl+Z)",children:"↩︎"}),s.jsx("button",{type:"button",onClick:()=>{var _e;return(_e=V.current)==null?void 0:_e.click()},className:"p-1.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary transition-colors",title:"Attach files",children:s.jsx(wE,{})})]}),s.jsx("input",{ref:V,type:"file",multiple:!0,className:"hidden",onChange:_e=>{_e.target.files&&$(_e.target.files),_e.target.value=""}})]})]}),S.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:S.map(_e=>s.jsx(yv,{attachment:_e,onRemove:ge=>_(he=>he.filter(ae=>ae.id!==ge))},_e.id))}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-muted mb-1",children:"Agent"}),s.jsxs("select",{value:b??"",onChange:_e=>k(_e.target.value||void 0),className:"w-full px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary outline-none focus:border-accent-primary",children:[s.jsx("option",{value:"",children:"Default agent"}),m.map(_e=>s.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-muted mb-1",children:"Model"}),s.jsx(bv,{providers:f,value:Se,onChange:_e=>{if(_e){const ge=_e.indexOf("/");T(_e.slice(0,ge)),A(_e.slice(ge+1))}else T(void 0),A(void 0)}})]})]}),O&&s.jsx("div",{className:"text-sm text-accent-error",children:O})]})]})}const JU=()=>`gate_${crypto.randomUUID().slice(0,8)}`;function ZU({projectId:e,onClose:t}){const n=Ht(x=>x.gates),r=Ht(x=>x.loadGates),a=Ht(x=>x.setGateConfig),[o,c]=j.useState([]),[u,d]=j.useState(!1);j.useEffect(()=>{r(e)},[e,r]),j.useEffect(()=>{c(n)},[n]);const h=(x,w)=>{c(C=>C.map((v,S)=>S===x?{...v,...w}:v))},m=()=>{c(x=>[...x,{id:JU(),name:"",description:"",required:!0,variant:"done"}])},f=x=>{c(w=>w.filter((C,v)=>v!==x))},g=async()=>{const x=o.filter(w=>w.name.trim().length>0).map((w,C)=>({...w,id:w.id||`gate_${C}`,name:w.name.trim()}));d(!0),await a(e,x),d(!1),t()};return s.jsx(Et,{isOpen:!0,onClose:t,title:"Definition of Done",size:"lg",footer:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("p",{className:"text-sm text-text-muted",children:["Gates define what a task must carry before it may enter ",s.jsx("strong",{children:"Done"}),". Values are set by you or the agent, each recorded with actor + timestamp."]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(ot,{onClick:t,children:"Cancel"}),s.jsx(ot,{variant:"primary",onClick:()=>void g(),disabled:u,children:u?"Saving…":"Save gates"})]})]}),children:s.jsxs("div",{className:"space-y-3",children:[o.length===0&&s.jsx("p",{className:"text-sm text-text-muted",children:"No gates configured — any task can move straight to Done. Add a gate like “all green” (every criterion passes with evidence) or “commit” (work committed with a commit reference)."}),o.map((x,w)=>s.jsxs("div",{className:"border border-border rounded-lg p-3 space-y-2 bg-bg-tertiary/40",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ms,{type:"text",value:x.name,onChange:C=>h(w,{name:C.target.value}),placeholder:"Gate name, e.g. “all green” or “commit”",className:"flex-1 text-sm"}),s.jsx("button",{type:"button",onClick:()=>f(w),className:"p-1.5 rounded hover:bg-accent-error/10 text-text-muted hover:text-accent-error transition-colors",title:"Remove gate",children:s.jsx(Si,{className:"w-4 h-4"})})]}),s.jsx("textarea",{value:x.description,onChange:C=>h(w,{description:C.target.value}),rows:2,placeholder:"What counts as acceptable proof? e.g. “every acceptance criterion passes with evidence, or work is committed with a commit SHA”",className:"w-full px-2.5 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary outline-none focus:border-accent-primary resize-y"}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-text-muted",children:[s.jsxs("label",{className:"flex items-center gap-1.5",children:[s.jsx("input",{type:"checkbox",checked:x.required,onChange:C=>h(w,{required:C.target.checked})}),"Required"]}),s.jsxs("label",{className:"flex items-center gap-1.5",children:[s.jsx("input",{type:"radio",name:`variant-${x.id}`,checked:x.variant==="done",onChange:()=>h(w,{variant:"done"})}),"Blocks Done"]}),s.jsxs("label",{className:"flex items-center gap-1.5",children:[s.jsx("input",{type:"radio",name:`variant-${x.id}`,checked:x.variant==="ready",onChange:()=>h(w,{variant:"ready"})}),"Definition of ready (blocks In Progress)"]})]})]},x.id)),s.jsxs(ot,{onClick:m,children:[s.jsx(Hr,{className:"w-3.5 h-3.5 mr-1 inline-block"})," Add gate"]})]})})}function vm({isOpen:e,onClose:t,projectId:n}){const[,r]=Nn(),a=Ht(I=>I.tasks),o=Ht(I=>I.settings),c=Ht(I=>I.loadBoard),u=Ht(I=>I.loadGates),d=Ht(I=>I.moveTask),h=Ht(I=>I.reorderTask),m=Ht(I=>I.deleteTask),f=Ht(I=>I.duplicateTask),g=Ht(I=>I.setSettings),x=Ht(I=>I.lastError),w=Pt(I=>I.projects.find(Q=>Q.id===n)),{agents:C,fetchAgents:v}=BT(),[S,_]=j.useState(null),[b,k]=j.useState(!1),[E,T]=j.useState(""),[L,A]=j.useState(null),O=j.useRef(null);j.useEffect(()=>{e&&(c(n),u(n),v())},[e,n,c,u,v]);const M=j.useMemo(()=>{if(!E.trim())return a;const I=E.toLowerCase();return a.filter(Q=>Q.prompt.toLowerCase().includes(I))},[a,E]),H=j.useMemo(()=>{const I=M.filter(re=>re.status==="todo").sort((re,ie)=>re.position-ie.position),Q=M.filter(re=>re.status==="in_progress").sort((re,ie)=>re.runState==="running"!=(ie.runState==="running")?re.runState==="running"?-1:1:re.position-ie.position),ne=M.filter(re=>re.status==="done").sort((re,ie)=>re.position-ie.position);return{todo:I,in_progress:Q,done:ne}},[M]),B=j.useMemo(()=>{const I=a.filter(ne=>ne.status==="in_progress"&&ne.runState==="queued").sort((ne,re)=>ne.position-re.position),Q=new Map;return I.forEach((ne,re)=>Q.set(ne.id,re+1)),Q},[a]),F=j.useMemo(()=>a.filter(I=>I.status==="in_progress"&&I.runState==="running").length,[a]),K=j.useMemo(()=>a.filter(I=>I.status==="in_progress"&&I.runState==="queued").length,[a]),G=j.useCallback(I=>{if(I.runState==="queued")return I.queuePosition!==void 0?I.queuePosition:B.get(I.id)},[B]),V=j.useCallback(async(I,Q)=>{const ne=await d(n,I.id,Q);ne!=null&&ne.sessionId&&r(`/p/${n}/s/${ne.sessionId}`)},[d,n,r]),Z=j.useCallback(async I=>{const Q=O.current;O.current=null,Q&&Q.task.status!==I&&await V(Q.task,I)},[V]),J=j.useCallback(async I=>{const Q=O.current;if(O.current=null,!Q||Q.task.id===I.task.id)return;const ne=H[I.task.status].findIndex(re=>re.id===I.task.id);ne<0||(Q.task.status===I.task.status?await h(n,Q.task.id,I.task.status,ne):(await V(Q.task,I.task.status),await h(n,Q.task.id,I.task.status,ne)))},[H,h,n,V]),z=j.useCallback(I=>{const Q=H[I.status].findIndex(ne=>ne.id===I.id);Q>0&&h(n,I.id,I.status,Q-1)},[H,h,n]),P=j.useCallback(I=>{const Q=H[I.status].findIndex(ne=>ne.id===I.id);Q>=0&&Q<H[I.status].length-1&&h(n,I.id,I.status,Q+1)},[H,h,n]),D=j.useCallback(I=>{f(n,I.id)},[f,n]),U=j.useCallback(async()=>{L&&(await m(n,L.id),A(null))},[L,m,n]),$=I=>{const Q=Ht.getState().settings.slotLimit,ne=Math.max(1,Math.min(10,Q+I));ne!==Q&&g(n,{slotLimit:ne})},te=()=>{const I=Ht.getState().settings.queuePaused;g(n,{queuePaused:!I})},q={projectId:n,agents:C,queuePositionOf:G,onEdit:I=>_({mode:"edit",task:I}),onMove:(I,Q)=>void V(I,Q),onMoveUp:z,onMoveDown:P,onDuplicate:D,onDelete:I=>A(I),onDragStart:I=>{O.current={task:I}},onOpenSession:()=>t()},X=I=>{const Q={todo:{title:"To Do",accentClass:"border-t-2 border-t-blue-500/60"},in_progress:{title:"In Progress",accentClass:"border-t-2 border-t-amber-500/60",hint:"Moving a task here starts it automatically."},done:{title:"Done",accentClass:"border-t-2 border-t-emerald-500/60"}}[I];return s.jsx(SU,{title:Q.title,accentClass:Q.accentClass,hint:"hint"in Q?Q.hint:void 0,tasks:H[I],headerAction:I==="todo"?s.jsxs(ot,{variant:"primary",onClick:()=>_({mode:"create"}),children:[s.jsx(Hr,{className:"w-4 h-4 mr-1 inline-block"})," New Task"]}):I==="done"?s.jsx(ot,{onClick:()=>k(!0),children:"Gates"}):void 0,footer:I==="in_progress"?Y:void 0,onDropOnColumn:()=>void Z(I),onDropOnCard:ne=>void J({task:ne}),...q},I)},Y=s.jsxs("div",{className:"px-3 py-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-sm font-medium text-text-muted",children:"Parallel slots"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>$(-1),disabled:o.slotLimit<=1,"aria-label":"Decrease slot limit",className:"w-7 h-7 rounded-md bg-bg-tertiary border border-border text-text-primary text-lg leading-none hover:bg-border disabled:opacity-40 disabled:hover:bg-bg-tertiary transition-colors",children:"−"}),s.jsx("span",{className:"w-9 text-center text-sm font-semibold text-text-primary tabular-nums",title:"Parallel-slot limit",children:o.slotLimit}),s.jsx("button",{type:"button",onClick:()=>$(1),disabled:o.slotLimit>=10,"aria-label":"Increase slot limit",className:"w-7 h-7 rounded-md bg-bg-tertiary border border-border text-text-primary text-lg leading-none hover:bg-border disabled:opacity-40 disabled:hover:bg-bg-tertiary transition-colors",children:"+"})]})]}),s.jsx("div",{className:"pt-3 border-t border-border/70",children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"min-w-0 flex-1 truncate text-sm text-text-muted",title:"Active tasks / limit",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 shrink-0"}),s.jsx("strong",{className:"text-text-primary tabular-nums",children:F})," / ",o.slotLimit," running"]}),K>0&&s.jsxs("span",{className:"ml-2 inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0"}),s.jsx("strong",{className:"text-text-primary tabular-nums",children:K})," queued"]})]}),s.jsxs(ot,{size:"sm",onClick:te,className:`shrink-0 flex items-center gap-1 whitespace-nowrap border ${o.queuePaused?"border-amber-400/40 text-amber-400 hover:bg-amber-400/10":"border-border text-text-muted hover:bg-bg-tertiary"}`,title:o.queuePaused?"Resume auto-launch of queued tasks":"Pause auto-launch of queued tasks",children:[o.queuePaused?s.jsx(Wf,{className:"w-3 h-3"}):s.jsx(EE,{className:"w-3 h-3"}),o.queuePaused?"Resume":"Pause"]})]})})]});return s.jsxs(s.Fragment,{children:[s.jsxs(Et,{isOpen:e,onClose:t,title:s.jsx($T,{projectName:(w==null?void 0:w.name)??n,children:"Tasks"}),size:"full",showCloseButton:!0,closeOnBackdropClick:!0,scrollable:!1,headerRight:s.jsx("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:s.jsxs("div",{className:"relative flex-1 min-w-0 sm:min-w-64",children:[s.jsx(_i,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-text-muted"}),s.jsx(Ms,{type:"text",value:E,onChange:I=>T(I.target.value),placeholder:"Search tasks…",className:"pl-7 pr-2 w-full text-sm"})]})}),children:[x&&s.jsxs("div",{className:"mb-2 px-3 py-2 rounded bg-accent-error/10 border border-accent-error/30 text-sm text-accent-error flex items-center justify-between",children:[s.jsx("span",{children:x}),s.jsx("button",{type:"button",onClick:()=>Ht.setState({lastError:null}),className:"text-sm underline",children:"Dismiss"})]}),s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2 h-full",children:[X("todo"),X("in_progress"),X("done")]})]}),S&&s.jsx(QU,{projectId:n,initialTask:S.mode==="edit"?S.task:null,onClose:()=>_(null),onSaved:()=>_(null)}),b&&s.jsx(ZU,{projectId:n,onClose:()=>k(!1)}),L&&s.jsx(Nl,{isOpen:!0,onClose:()=>A(null),onConfirm:()=>void U(),title:"Delete task?",message:`“${L.prompt.slice(0,60)}” will be removed from the board. Its sessions and history stay untouched.`,confirmLabel:"Delete task",confirmVariant:"danger"})]})}function e9({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=j.useState(!1),[a,o]=j.useState(!1),[c,u]=j.useState(!!document.fullscreenElement),[d,h]=Nn(),[m,f]=j.useState(!1),g=Ht(V=>V.counts.running),x=Ht(V=>V.loadCounts),w=Ht(V=>V.activeProjectId),C=Ht(V=>V.lastAutoLaunch),v=Ht(V=>V.clearAutoLaunch);j.useEffect(()=>{const V=()=>u(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",V),()=>document.removeEventListener("fullscreenchange",V)},[]);const S=d.startsWith("/p/"),_=/^\/p\/[^/]+\/s\/[^/]+$/.test(d),b=gE(),k=Oe(V=>V.openSessionIds.length),E=Oe(V=>V.currentSession),T=Oe(V=>V.sessions),L=Pt(V=>V.currentProject),A=Pt(V=>V.projects),O=an(V=>V.startAutoRefresh),M=an(V=>V.stopAutoRefresh),H=fs(V=>V.setOpen),B=fs(V=>V.isOpen),F=bi(V=>V.status==="available"),K=bi(V=>V.check);j.useEffect(()=>{bi.getState().status==="idle"&&K()},[K]),j.useEffect(()=>{const V=()=>o(!0);return window.addEventListener("open-session-dropdown",V),()=>window.removeEventListener("open-session-dropdown",V)},[]);const G=Nu();return gu(G.terminalToggle,()=>{fs.getState().toggleOpen()},{capture:!0}),j.useEffect(()=>{L!=null&&L.id&&w!==L.id&&x(L.id)},[L==null?void 0:L.id,w,x]),j.useEffect(()=>(O(),()=>M()),[O,M]),s.jsxs("header",{className:"h-8 bg-secondary border-b border-border flex items-center justify-between px-2",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&_||e&&b?s.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:b?"Toggle split view control panel":"Toggle session list","aria-label":b?"Toggle split view control panel":"Toggle session list",children:s.jsx(cy,{})}):null,s.jsx(ir,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),!b&&L&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),s.jsx("span",{className:"hidden md:inline",children:s.jsx(bk,{projects:A,currentProject:L})}),s.jsx("span",{className:"md:hidden",children:s.jsx(vU,{currentProject:L,sessions:T,currentSession:E,projectIdFromUrl:S&&d.split("/")[2]||null},L==null?void 0:L.id)}),s.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),s.jsx("span",{className:"hidden md:inline",children:s.jsx(yU,{sessions:T,currentProject:L,currentSession:E,isOpen:a,onOpenChange:o})})]}),!b&&!L&&s.jsx("span",{className:"hidden md:inline",children:s.jsx(bk,{projects:A})})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!b&&s.jsx("button",{onClick:()=>{const V=E==null?void 0:E.id;_&&V&&Oe.getState().openPane(V,{focus:!0}),h("/split-view")},className:"p-2.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted hover:text-text-primary",title:"Open split view","aria-label":"Open split view",children:s.jsx(mu,{className:"w-4 h-4"})}),b&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1 text-xs text-text-muted px-1.5",title:"Split view active","data-testid":"split-indicator",children:[s.jsx(mu,{className:"w-3.5 h-3.5"}),k]}),s.jsx("button",{onClick:()=>{Oe.getState().exitSplitView(),h("/")},className:"p-2.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted hover:text-text-primary",title:"Exit split view","aria-label":"Exit split view",children:s.jsx(Ss,{className:"w-4 h-4"})})]}),_&&s.jsx("button",{onClick:()=>{var V,Z,J;document.fullscreenElement?(V=document.exitFullscreen)==null||V.call(document):(J=(Z=document.documentElement).requestFullscreen)==null||J.call(Z)},className:"max-sm:block hidden p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:c?"Exit fullscreen":"Enter fullscreen",children:c?s.jsx(Q3,{}):s.jsx(J3,{})}),S&&s.jsxs("button",{onClick:()=>f(!0),className:"relative p-2.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted hover:text-text-primary",title:"Project tasks","aria-label":"Open project tasks",children:[s.jsx(Kf,{className:"w-4 h-4"}),g>0&&s.jsx("span",{className:"absolute top-0.5 right-0.5 min-w-3.5 h-3.5 px-0.5 rounded-full bg-accent-success text-white text-[9px] font-semibold flex items-center justify-center",children:g>99?"99+":g})]}),S&&s.jsx("button",{onClick:()=>H(!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:s.jsx(rO,{})}),S&&L&&s.jsx("button",{onClick:()=>me(`/api/projects/${L.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:s.jsx(Cr,{className:"w-4 h-4"})}),s.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:F?"Settings — update available":"Settings",children:[s.jsx(jE,{}),F&&s.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),s.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:s.jsx(Z3,{})}),t&&_&&s.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:G.criteriaSidebar?`Toggle criteria sidebar (${Eb(G.criteriaSidebar)})`:"Toggle criteria sidebar",children:s.jsx(cy,{})})]}),s.jsx(aU,{isOpen:n,onClose:()=>r(!1)}),s.jsx(mU,{isOpen:B,onClose:()=>H(!1)}),L&&s.jsx(vm,{isOpen:m,onClose:()=>f(!1),projectId:L.id}),C&&s.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg bg-bg-secondary border border-border shadow-xl text-sm text-text-primary",children:[s.jsxs("span",{children:["“",C.taskTitle,"” auto-launched — a slot freed up."]}),s.jsxs("button",{type:"button",onClick:()=>{const V=C.sessionId,Z=C.projectId;v(),h(`/p/${Z}/s/${V}`)},className:"flex items-center gap-1 px-2.5 py-1 rounded bg-accent-primary/25 hover:bg-accent-primary/40 font-medium transition-colors",children:["Open session ",s.jsx(Uf,{className:"w-3 h-3"})]}),s.jsx("button",{type:"button",onClick:v,className:"text-xs text-text-muted underline",children:"Dismiss"})]})]})}function XT({onCancel:e,onSave:t,saving:n,saveDisabled:r,cancelLabel:a="Cancel",saveLabel:o=n?"Saving...":"Save"}){return s.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[s.jsx(ot,{variant:"secondary",onClick:e,children:a}),s.jsx(ot,{variant:"primary",onClick:t,disabled:r??n,children:o})]})}const vh=Zn()(e=>({config:null,loading:!1,fetchConfig:async t=>{e({loading:!0});try{const r=await(await me(`/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 me(`/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})}})),t9=["/","/etc","/bin","/sbin","/lib","/lib64","/usr","/var","/opt","/root","/run","/tmp","/home","/mnt","/media"],n9=["/proc/","/sys/","/dev/","/boot/","/etc/","/lost+found/"],QT=/^[a-zA-Z]:$/;function r9(e,t=t9,n=n9){if(!e)return null;const r=e.replace(/[\\/]+$/,"")||"/";if(QT.test(r)||t.includes(r))return"exact";for(const a of n)if(r.startsWith(a))return"virtual_fs";return null}function JT(e){const t=e.replace(/[\\/]+$/,"");return t?QT.test(t)?`${t}\\`:t:"/"}function s9(e,t){const n=JT(e);return/[\\/]$/.test(n)?`${n}${t}`:`${n}/${t}`}function ZT({isOpen:e,onClose:t,project:n}){const r=Pt(Ce=>Ce.updateProject),a=vh(Ce=>Ce.config),o=vh(Ce=>Ce.loading),c=vh(Ce=>Ce.fetchConfig),u=vh(Ce=>Ce.saveConfig),d=dt(Ce=>Ce.defaults),h=dt(Ce=>Ce.userItems),m=dt(Ce=>Ce.projectItems),f=dt(Ce=>Ce.fetchAgents),g={builtin:d.filter(Ce=>!Ce.subagent),user:h.filter(Ce=>!Ce.subagent),project:m.filter(Ce=>!Ce.subagent)},x=Gn(Gn(g.builtin,g.user),g.project),w=[{label:"Project",agents:g.project},{label:"User",agents:g.user},{label:"Built-in",agents:g.builtin}],C=w.map(Ce=>({label:Ce.label,agents:Ce.agents.filter(nt=>!w.slice(0,w.indexOf(Ce)).some(tt=>tt.agents.some(ht=>ht.id===nt.id)))})),v=()=>{try{Vt.send("context.checkDynamic",{})}catch{}t()},[S,_]=j.useState(n.customInstructions??""),[b,k]=j.useState(n.dangerLevel??""),[E,T]=j.useState(n.defaultAgent??""),[L,A]=j.useState(!1),[O,M]=j.useState(!1),[H,B]=j.useState(!1),[F,K]=j.useState(!1),[G,V]=j.useState(null),Z=E!==""&&!x.some(Ce=>Ce.id===E),[J,z]=j.useState(""),[P,D]=j.useState(!1),[U,$]=j.useState(""),[te,q]=j.useState(!1),[X,Y]=j.useState(""),[I,Q]=j.useState(!1),[ne,re]=j.useState(!1),[ie,pe]=j.useState([]),[ye,Ie]=j.useState(""),[$e,Se]=j.useState({}),[Ge,Je]=j.useState(!1),[_e,ge]=j.useState(new Set),he=L||O||H||P||te||Ge;j.useEffect(()=>{e&&(_(n.customInstructions??""),k(n.dangerLevel??""),T(n.defaultAgent??""),A(!1),M(!1),B(!1),D(!1),q(!1),Je(!1),ge(new Set),c(n.workdir),f(n.workdir).catch(()=>{}))},[e,n,c,f]),j.useEffect(()=>{a!=null&&a.setup&&a.setup.length>0?z(a.setup.join(" && ")):z(""),$((a==null?void 0:a.rootDir)??""),Se((a==null?void 0:a.mcpOverrides)??{})},[a]);const ae=hu(Ce=>Ce.servers),Pe=Ce=>$e[Ce]??{},Ue=Ce=>{var ht;const nt=Pe(Ce);if(nt.disabled!==void 0)return nt.disabled;const tt=ae.find(Lt=>Lt.name===Ce);return!!((ht=tt==null?void 0:tt.config)!=null&&ht.disabled)},de=(Ce,nt)=>{var ht;return((ht=Pe(Ce).disabledTools)==null?void 0:ht.includes(nt))??!1},Ae=Ce=>{Se(nt=>({...nt,[Ce]:{...nt[Ce],disabled:!Ue(Ce)}})),Je(!0)},ue=(Ce,nt)=>{Se(tt=>{const ht=tt[Ce]??{},Lt=ht.disabledTools??[],qt=Lt.includes(nt)?Lt.filter(bn=>bn!==nt):[...Lt,nt];return{...tt,[Ce]:{...ht,disabledTools:qt.length>0?qt:void 0}}}),Je(!0)},Fe=Ce=>{ge(nt=>{if(nt.has(Ce)){const ht=new Set(nt);return ht.delete(Ce),ht}const tt=new Set(nt);return tt.add(Ce),tt})},Xe=Ce=>{_(Ce.target.value),A(!0)},it=Ce=>{k(Ce),M(!0)},Ze=Ce=>{z(Ce.target.value),D(!0)},lt=Ce=>{$(Ce.target.value),q(!0)},gt=j.useCallback(async()=>{const nt={customInstructions:S||null,dangerLevel:b===""?null:b};if(H&&(nt.defaultAgent=E===""?null:E),await r(n.id,nt),P||te||Ge){const tt=J.trim()?J.split("&&").map(Lt=>Lt.trim()).filter(Boolean):[],ht={};P&&(ht.setup=tt),te&&(ht.rootDir=U.trim()),Object.keys($e).length>0&&(ht.mcpOverrides=$e),await u(n.workdir,ht)}A(!1),M(!1),B(!1),D(!1),q(!1),Je(!1),v()},[n.id,b,S,E,H,J,U,$e,P,te,Ge,r,u,n.workdir,v]),De=async()=>{const Ce=U.trim(),nt=(a==null?void 0:a.rootDir)??"";if(Ce){const tt=r9(Ce);if(tt==="exact"){const ht=JT(Ce);V(`Cannot use "${ht}" directly as workspace root. Use a subdirectory like "${s9(Ce,n.name)}" instead.`);return}if(tt==="virtual_fs"){V(`Cannot use paths under "${Ce}" for workspaces.`);return}}if(!te||!Ce||Ce===nt){K(!0),V(null);try{await gt()}catch(tt){V(tt instanceof Error?tt.message:"Failed to save settings")}finally{K(!1)}return}Y(Ce),K(!0),V(null);try{const tt=await me(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:Ce,workdir:n.workdir,projectName:n.name})});if(!tt.ok){const Lt=await tt.json().catch(()=>({}));V((Lt==null?void 0:Lt.error)??"Failed to validate workspace root directory");return}const ht=await tt.json();if(!ht.exists){Ie(ht.resolvedPath),Q(!0);return}if(ht.workspaces&&ht.workspaces.length>0){pe(ht.workspaces),re(!0);return}V(null),await gt()}catch(tt){V(tt instanceof Error?tt.message:"Failed to validate settings")}finally{K(!1)}},Re=async()=>{Q(!1),K(!0);try{const Ce=await me(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:X,workdir:n.workdir,projectName:n.name,createIfMissing:!0})});if(!Ce.ok){const tt=await Ce.json().catch(()=>({}));V((tt==null?void 0:tt.error)??"Failed to create directory"),K(!1);return}const nt=await Ce.json();if(nt.workspaces&&nt.workspaces.length>0){pe(nt.workspaces),re(!0),K(!1);return}await gt()}catch(Ce){V(Ce instanceof Error?Ce.message:"Failed to create directory")}finally{K(!1)}},ke=async()=>{re(!1),K(!0),V(null);try{await gt()}catch(Ce){V(Ce instanceof Error?Ce.message:"Failed to save settings")}finally{K(!1)}},We=()=>{Q(!1),re(!1),_(n.customInstructions??""),k(n.dangerLevel??""),T(n.defaultAgent??""),A(!1),M(!1),B(!1),D(!1),q(!1),v()};return s.jsxs(Et,{isOpen:e,onClose:We,title:s.jsx($T,{projectName:n.name,children:"Settings"}),size:"lg",footer:s.jsx(XT,{onCancel:We,onSave:De,saving:F,saveDisabled:!he||F}),children:[s.jsxs("div",{className:"flex flex-col gap-5 -mt-1",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Danger Level"}),s.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."}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit",children:[s.jsx("button",{type:"button",onClick:()=>it(""),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${b===""?"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"}),s.jsx("button",{type:"button",onClick:()=>it("normal"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${b==="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"}),s.jsx("button",{type:"button",onClick:()=>it("dangerous"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${b==="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"})]})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"project-default-agent",className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Agent"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:'Default agent for new sessions in this project. Choose "Use system default" to follow the global default agent. Existing sessions are not affected.'}),s.jsxs("select",{id:"project-default-agent",value:E,onChange:Ce=>{T(Ce.target.value),B(!0)},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",disabled:F,children:[s.jsx("option",{value:"",children:"Use system default"}),Z&&s.jsxs("option",{value:E,children:[E," (missing agent)"]}),C.map(({label:Ce,agents:nt})=>nt.length>0&&s.jsx("optgroup",{label:Ce,children:nt.map(tt=>s.jsx("option",{value:tt.id,children:tt.name},tt.id))},Ce))]}),Z&&s.jsxs("p",{className:"text-xs text-red-400 mt-1",children:['The stored default agent "',E,'" no longer exists. Pick another agent to restore a valid default.']}),x.length===0&&s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"No agents available. Create one in the Agents modal."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),s.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),s.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."}),s.jsx("textarea",{value:S,onChange:Xe,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:F})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Setup Command"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Command(s) to run after creating a workspace (shared clone). Use"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"&&"})," to chain multiple commands. Example:"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"npm install --prefer-offline"})]}),o&&s.jsx("div",{className:"text-xs text-text-muted mb-2",children:"Loading config..."}),s.jsx("input",{type:"text",value:J,onChange:Ze,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:o||F})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Root Directory"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Override the default workspace location. Leave empty to use the global directory"," ",s.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."]}),s.jsx("input",{type:"text",value:U,onChange:lt,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:o||F})]}),ae.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"MCP Servers"}),s.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."}),s.jsx("div",{className:"space-y-2",children:ae.map(Ce=>{const nt=Ue(Ce.name);return s.jsx(ET,{server:Ce,expanded:_e.has(Ce.name),onToggleExpand:Fe,serverToggleEnabled:!nt,onServerToggle:()=>Ae(Ce.name),tools:Ce.tools.map(tt=>({...tt,enabled:!de(Ce.name,tt.name)})),onToolToggle:tt=>ue(Ce.name,tt),statusDot:gv(nt?"disabled":Ce.status),statusColor:pv(nt?"disabled":Ce.status)},Ce.name)})})]}),G&&s.jsx("div",{className:"text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded px-3 py-2",children:G})]}),I&&s.jsxs(Et,{isOpen:I,onClose:()=>Q(!1),title:"Directory not found",size:"md",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>Q(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:Re,className:"px-4 py-2 text-sm font-medium rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:"Create"})]}),children:[s.jsxs("p",{className:"text-sm text-text-primary",children:["The directory ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:ye})," does not exist."]}),s.jsx("p",{className:"text-sm text-text-muted mt-2",children:"Would you like to create it?"})]}),ne&&s.jsxs(Et,{isOpen:ne,onClose:()=>re(!1),title:"Orphaned workspaces",size:"md",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>re(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:ke,className:"px-4 py-2 text-sm font-medium rounded bg-red-500 text-white hover:opacity-90 transition-colors",children:"Confirm change"})]}),children:[s.jsxs("p",{className:"text-sm text-text-primary",children:[ie.length," existing workspace(s) will not be migrated and will become inaccessible:"]}),s.jsx("ul",{className:"mt-2 space-y-1",children:ie.map(Ce=>s.jsx("li",{className:"text-sm font-mono text-text-muted",children:Ce.name},Ce.name))}),s.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."})]})]})}function eA({initialWidth:e,minWidth:t,maxWidth:n,direction:r}){const[a,o]=j.useState(e),[c,u]=j.useState(!1),d=j.useRef({startX:0,startWidth:e}),h=j.useCallback(m=>{m.preventDefault(),m.stopPropagation(),d.current={startX:m.clientX,startWidth:a},u(!0)},[a]);return j.useEffect(()=>{if(!c)return;const m=w=>{const{startX:C,startWidth:v}=d.current,S=w.clientX-C,_=r==="left"?v+S:v-S;o(Math.max(t,Math.min(n,_)))},f=()=>{u(!1)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",f);const g=document.body.style.userSelect,x=document.body.style.cursor;return document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",f),document.body.style.userSelect=g,document.body.style.cursor=x}},[c,r,t,n]),{width:a,isResizing:c,handleMouseDown:h}}function tA({side:e,onMouseDown:t,className:n=""}){return s.jsx("div",{role:"separator","aria-orientation":"vertical",onMouseDown:t,className:`absolute top-0 bottom-0 w-1 z-20 cursor-col-resize hover:bg-accent-primary/30 transition-colors ${e==="left"?"left-0 -ml-0.5":"right-0 -mr-0.5"} ${n}`})}function nA({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=Nn(),[a,o]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(null),[m,f]=j.useState(""),[g,x]=j.useState(!1),w=Oe(ge=>ge.sessions),C=Oe(ge=>ge.currentSession),v=Oe(ge=>ge.unreadSessionIds),S=Oe(ge=>ge.deleteSession),_=Oe(ge=>ge.deleteAllSessions),b=Oe(ge=>ge.loadMoreSessions),k=Oe(ge=>ge.sessionsHasMore),E=Oe(ge=>ge.sessionsPaginationLoading),T=Oe(ge=>ge.sessionsWithPendingConfirmations),L=Oe(ge=>ge.pendingPathConfirmations),A=Oe(ge=>ge.toggleFavorite),O=Pt(ge=>ge.currentProject),[M,H]=j.useState(""),[B,F]=j.useState(-1),K=j.useRef(null),G=j.useRef(null),{width:V,handleMouseDown:Z}=eA({initialWidth:300,minWidth:200,maxWidth:600,direction:"left"}),J=j.useRef(!1),z=Nu();gu(z.sessionSearch,()=>{var ge;if(t&&document.activeElement===K.current){n==null||n();return}t||(J.current=!0,n==null||n()),Gt()&&((ge=K.current)==null||ge.focus())});const P=j.useRef(null),D=j.useCallback(()=>{k&&!E&&O&&b(O.id)},[k,E,O,b]);j.useEffect(()=>{if(!P.current||!k)return;const ge=new IntersectionObserver(he=>{const ae=he[0];ae&&ae.isIntersecting&&D()},{threshold:.1});return ge.observe(P.current),()=>ge.disconnect()},[k,D]);const U=w.filter(ge=>ge.projectId===(O==null?void 0:O.id)),[$,te]=j.useMemo(()=>{const ge=[],he=[];for(const ae of U)ae.isFavorite?ge.push(ae):he.push(ae);return[ge,he]},[U]),q=ge=>M?ge.filter(he=>{var Ue;const ae=he.title??"",Pe=(((Ue=he.recentUserPrompts)==null?void 0:Ue.map(de=>de.content))??[]).join(" ");return aa(ae,M)||aa(Pe,M)}):ge,X=j.useMemo(()=>q($),[$,M]),Y=j.useMemo(()=>q(te),[te,M]),I=[...X,...Y],Q=M.length>0,ne=Q&&I.length===0;j.useEffect(()=>{F(I.length>0?0:-1)},[I.length]),j.useEffect(()=>{var he;if(B<0)return;const ge=(he=G.current)==null?void 0:he.querySelector(`[data-sidx="${B}"]`);ge==null||ge.scrollIntoView({block:"nearest"})},[B]);const re=(ge,he)=>{he==null||he.stopPropagation(),u(ge)},ie=()=>{c&&(S(c),(C==null?void 0:C.id)===c&&r(`/p/${e}`),u(null))},pe=(ge,he)=>{he==null||he.stopPropagation();const ae=w.find(Ue=>Ue.id===ge),Pe=(ae==null?void 0:ae.title)??ge.slice(0,6);f(Pe),h(ge)},ye=()=>{if(!d||m.trim()==="")return;const ge=Oe.getState().renameSession;ge(d,m.trim()),h(null),f("")},Ie=()=>{x(!0)},$e=()=>{_(e),r(`/p/${e}`),x(!1)},Se=(ge,he)=>{A(ge,!he)},Ge=ge=>{if(!J.current)return;ge.target.closest('a[href*="/s/"]')&&(J.current=!1,n==null||n())},Je=()=>{var ge;H(""),Gt()&&((ge=K.current)==null||ge.focus())},_e=ge=>{var he;switch(ge.key){case"Escape":H(""),(he=K.current)==null||he.blur();break;case"ArrowDown":ge.preventDefault(),F(ae=>ae<I.length-1?ae+1:ae);break;case"ArrowUp":ge.preventDefault(),F(ae=>ae>0?ae-1:0);break;case"Enter":{ge.preventDefault();const ae=I[B];ae&&(r(`/p/${e}/s/${ae.id}`),J.current&&(J.current=!1,n==null||n()));break}}};return s.jsxs(s.Fragment,{children:[t&&n&&s.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),(()=>{const ge=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[s.jsx(ir,{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"}),s.jsx(ho,{items:[{label:"Edit project settings",onClick:()=>o(!0)},{label:"Delete all sessions",onClick:Ie,danger:!0}],trigger:s.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:s.jsx(Sb,{})})}),n&&s.jsx(Pu,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),s.jsxs("div",{className:"px-4 py-2 border-b border-border",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(_i,{className:"absolute left-2.5 w-3.5 h-3.5 text-text-muted pointer-events-none"}),s.jsx("input",{ref:K,type:"text",value:M,onChange:he=>H(he.target.value),onKeyDown:_e,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"}),M&&s.jsx("button",{type:"button",onClick:Je,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:s.jsx(Ss,{className:"w-3.5 h-3.5"})})]}),Q&&!ne&&s.jsxs("div",{className:"mt-1 text-xs text-text-muted px-1",children:[I.length," ",I.length===1?"match":"matches"]})]}),O&&s.jsx(ZT,{isOpen:a,onClose:()=>o(!1),project:O}),s.jsx(Nl,{isOpen:c!==null,onClose:()=>u(null),onConfirm:ie,title:"Delete session?",message:"This session will be permanently deleted.",confirmLabel:"Delete session",confirmVariant:"danger"}),s.jsx(Nl,{isOpen:g,onClose:()=>x(!1),onConfirm:$e,title:"Delete all sessions?",message:"Delete all sessions in this project? This cannot be undone.",confirmLabel:"Delete all",confirmVariant:"danger"}),s.jsx(Et,{isOpen:d!==null,onClose:()=>{h(null),f("")},title:"Rename session",size:"sm",footer:s.jsx(XT,{onCancel:()=>{h(null),f("")},onSave:ye,saving:!1,saveDisabled:m.trim()==="",saveLabel:"Rename"}),children:s.jsx("input",{type:"text",value:m,onChange:he=>f(he.target.value),onKeyDown:he=>{he.key==="Enter"&&ye()},onFocus:he=>he.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:Gt()})}),s.jsx(pt,{className:"flex-1",children:I.length===0?s.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:Q?"No matching sessions":"No sessions"}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"divide-y divide-border",ref:G,onClick:Ge,children:i9(X,Y,C,v,re,pe,Se,e,T,L,M,B)}),E&&s.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),s.jsx("div",{ref:P,className:"h-px"})]})})]});return s.jsxs("aside",{className:`
|
|
277
|
+
${t?"md:w-[var(--sidebar-w)] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden md:border-r-0"}
|
|
278
|
+
md:relative md:h-auto md:translate-x-0
|
|
279
|
+
|
|
280
|
+
fixed z-50 h-[calc(100vh-32px)]
|
|
281
|
+
w-[300px] bg-secondary border-r border-border flex flex-col
|
|
282
|
+
transition-transform duration-300 ease-in-out
|
|
283
|
+
${t?"translate-x-0":"-translate-x-full"}
|
|
284
|
+
`,style:{"--sidebar-w":`${V}px`},children:[ge,t&&s.jsx(tA,{side:"right",onMouseDown:Z,className:"hidden md:block"})]})})()]})}function i9(e,t,n,r,a,o,c,u,d,h,m,f){let g=0;const x=C=>{const v=g++,S=(n==null?void 0:n.id)===C.id,_=v===f,b=r.includes(C.id),k=C.isRunning,E=C.isFavorite,T=d.includes(C.id)||S&&h.length>0;return s.jsx("div",{"data-sidx":v,className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${S?"bg-bg-tertiary":""} ${_?"bg-accent-primary/10":""}`,children:s.jsxs(ir,{href:`/p/${u}/s/${C.id}`,className:`block ${S?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[s.jsxs("div",{className:"flex justify-between items-center mb-1",children:[s.jsx("span",{className:`font-medium truncate text-sm ${S?"text-accent-primary":"text-text-primary"}`,children:m?Wy(C.title??C.id.slice(0,6),m):C.title??C.id.slice(0,6)}),s.jsx("div",{className:"flex items-center gap-1",children:s.jsx(ho,{items:[{label:E?"Remove from favorites":"Add to favorites",icon:E?s.jsx(pu,{className:"w-3.5 h-3.5 text-amber-400"}):s.jsx(qf,{className:"w-3.5 h-3.5"}),onClick:()=>c(C.id,E)},{label:"Rename session",onClick:L=>o(C.id,L)},{label:"Delete session",onClick:L=>a(C.id,L),danger:!0}],trigger:s.jsx("button",{onClick:L=>{L.preventDefault()},className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:s.jsx(Sb,{})})})})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[T?s.jsx("span",{title:"Awaiting confirmation",children:s.jsx(kb,{className:"w-3 h-3 text-red-400 flex-shrink-0"})}):k?s.jsx(tO,{}):b&&!S?s.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,!E&&s.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:ym(C.updatedAt)}),s.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[C.messageCount," messages"]})]})]})},C.id)},w=C=>{const v=PT(C);return Array.from(v).map(([S,_])=>{const b=_[0];return b?s.jsxs("div",{children:[s.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:OT(b.updatedAt)}),_.map(k=>x(k))]},S):null})};return s.jsxs(s.Fragment,{children:[e.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"px-4 py-2 bg-bg-tertiary/50 text-text-primary text-xs font-semibold flex items-center gap-1",children:[s.jsx(pu,{className:"w-3 h-3 text-amber-400"}),"Favorites"]}),e.map(C=>x(C))]}),t.length>0&&w(t)]})}const Ek=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"];function a9(){var c;const e=Pt(u=>u.currentProject),t=Oe(u=>u.currentSession),n=zf(),r=j.useRef(0),a=j.useRef(null);j.useEffect(()=>(n?(a.current||(r.current=0),a.current=window.setInterval(()=>{r.current=(r.current+1)%Ek.length,o()},150),o()):(a.current&&(clearInterval(a.current),a.current=null),o()),()=>{a.current&&(clearInterval(a.current),a.current=null)}),[n,e,t]);const o=()=>{var m;const d=(m=t==null?void 0:t.metadata)==null?void 0:m.title,h=n?`${Ek[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"&&((c=t==null?void 0:t.metadata)!=null&&c.title)&&window.document.documentElement.setAttribute("data-session-title",t.metadata.title),null}const o9={idle:"Idle",plan:"Plan",build:"Build",verification:"Verify",blocked:"Blocked",done:"Done"};function l9(){const[,e]=Nn(),t=Oe(d=>d.sessions),n=Oe(d=>d.sessionsWithPendingConfirmations),r=Pt(d=>d.projects),a=j.useMemo(()=>new Map(r.map(d=>[d.id,d])),[r]),o=j.useMemo(()=>t.filter(d=>d.isRunning||n.includes(d.id)||d.phase==="blocked").sort((d,h)=>new Date(h.updatedAt).getTime()-new Date(d.updatedAt).getTime()),[t,n]),c=()=>{const d=o.map(h=>h.id);d.length!==0&&(Oe.getState().enterSplitView(d,d[0]),e("/split-view"))},u=d=>{Oe.getState().openPane(d,{focus:!0}),e("/split-view")};return o.length===0?null:s.jsxs("div",{className:"mb-6 md:mb-8",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-semibold uppercase tracking-wide text-text-muted",children:"Currently running"}),s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-emerald-400 font-medium",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),o.length]})]}),o.length>1&&s.jsxs(ot,{variant:"primary",size:"sm",onClick:c,className:"flex items-center gap-1.5",children:[s.jsx(mu,{className:"w-3.5 h-3.5"}),"Open split view"]})]}),s.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:s.jsx("ul",{className:"divide-y divide-border",children:o.map(d=>{const h=a.get(d.projectId),m=n.includes(d.id);return s.jsxs("li",{className:"flex items-center gap-3 px-3 md:px-4 py-2.5",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${d.isRunning?"bg-emerald-400 animate-pulse":"bg-amber-400"}`,title:m?"Waiting for your input":d.isRunning?"Running":"Needs attention"}),s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-accent-primary shrink-0 max-w-[90px] truncate",children:(h==null?void 0:h.name)??d.projectId.slice(0,10)}),s.jsx("button",{type:"button",onClick:()=>e(`/p/${d.projectId}/s/${d.id}`),className:"text-sm text-text-primary truncate flex-1 min-w-0 text-left hover:underline",title:d.title??d.id,children:d.title??d.id.slice(0,8)}),s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-text-muted shrink-0",children:o9[d.phase]??d.phase}),m&&s.jsx("span",{className:"text-[10px] text-amber-400 shrink-0",title:"Pending confirmation",children:"Needs you"}),s.jsx("span",{className:"text-xs text-text-muted shrink-0 hidden sm:inline",children:IT(d.updatedAt)}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx(ot,{variant:"secondary",size:"sm",onClick:()=>e(`/p/${d.projectId}/s/${d.id}`),children:"Open"}),s.jsxs(ot,{variant:"secondary",size:"sm",onClick:()=>u(d.id),title:"Add to split view",className:"flex items-center gap-1",children:[s.jsx(mu,{className:"w-3.5 h-3.5"}),"Split"]})]})]},d.id)})})})]})}function rA({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const a=()=>{r(),t()};return s.jsx(Nl,{isOpen:e,onClose:t,onConfirm:a,title:"Delete Project",confirmLabel:"Delete",confirmVariant:"danger",message:s.jsxs(s.Fragment,{children:["This will permanently delete the project"," ",s.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 c9({isOpen:e,onClose:t}){const[,n]=Nn(),[r,a]=j.useState(!1),o=DT(),[c,u]=j.useState(!1),d=Pt(A=>A.projects),h=Pt(A=>A.createProject),m=Pt(A=>A.listProjects),f=Pt(A=>A.deleteProject),[g,x]=j.useState(null),[w,C]=j.useState(null);j.useEffect(()=>{e&&m()},[e,m]);const v=A=>{n(`/p/${A}`),t()},S=(A,O)=>{O.stopPropagation(),x(A)},_=()=>{g&&(f(g.id),x(null))},b=async A=>E(A);function k(A){return A!=null&&typeof A=="object"&&"error"in A&&A.error!=null&&typeof A.error=="object"&&"code"in A.error&&A.error.code==="EACCES"}async function E(A){const O=Au(A),M=await h(O,A);return m(),k(M)?(C(M.error.path||A),!1):M&&"id"in M?(n(`/p/${M.id}`),t(),!0):!1}const T=j.useCallback(()=>{C(null)},[]),L=j.useCallback(async()=>{const A=w;C(null),A&&await E(A)},[w]);return e?s.jsxs(Et,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:s.jsx("div",{className:"flex justify-end gap-2",children:s.jsx(ot,{variant:"secondary",onClick:t,children:"Close"})}),children:[s.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[s.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:[s.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:s.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),s.jsx(pt,{className:"flex-1",children:d.length===0?s.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[s.jsx("p",{className:"mb-2",children:"No recent projects"}),s.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):s.jsx("div",{className:"divide-y divide-border",children:d.map(A=>s.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[s.jsxs("button",{onClick:()=>v(A.id),className:"flex-1 flex items-center gap-3 text-left",children:[s.jsx(Cr,{className:"w-5 h-5 text-accent-primary"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"font-medium truncate",children:A.name}),s.jsx("div",{className:"text-xs text-text-muted truncate",children:Ab(A.workdir,32)})]})]}),s.jsx("button",{onClick:O=>S(A,O),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:s.jsx(Si,{className:"w-4 h-4"})})]},A.id))})})]}),s.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:s.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[s.jsx(ot,{variant:"primary",onClick:()=>u(!0),children:"Select existing project"}),s.jsx(ot,{variant:"secondary",onClick:()=>a(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),r&&s.jsx(RT,{isOpen:r,onClose:()=>a(!1)}),g&&s.jsx(rA,{isOpen:!0,onClose:()=>x(null),projectName:g.name,onConfirm:_}),c&&s.jsx(Qf,{initialPath:o??void 0,onSelect:A=>{b(A)},onClose:()=>u(!1)}),w&&s.jsx(LT,{isOpen:!0,onClose:T,path:w,onRetry:L})]}):null}const u9=[{key:"todo",label:"To Do",color:"text-blue-400"},{key:"queued",label:"Queued",color:"text-amber-400"},{key:"running",label:"Running",color:"text-emerald-400"},{key:"done",label:"Done",color:"text-text-muted"}];function d9({counts:e}){return!e||e.todo+e.queued+e.running+e.done===0?null:s.jsx("span",{className:"flex items-center gap-1.5",children:u9.map(n=>{const r=e[n.key];return r===0?null:s.jsxs("span",{title:n.label,className:`flex items-center gap-1 ${n.color}`,children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current"}),r]},n.key)})})}function h9(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,o]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(null),m=j.useRef(null),f=Oe(D=>D.searchSessions??D.sessions),g=Oe(D=>D.searchSessions!==null),x=Pt(D=>D.projects),w=Pt(D=>D.loading),C=Pt(D=>D.listProjects),v=Oe(D=>D.listHomeSessions),S=Oe(D=>D.ensureFullSessionList),_=Pt(D=>D.deleteProject),b=Oe(D=>D.connectionStatus),k=Ht(D=>D.summaries),E=Ht(D=>D.loadSummaries);j.useEffect(()=>{b==="connected"&&(C(),v())},[b,C,v]);const T=x.map(D=>D.id).sort().join(",");j.useEffect(()=>{T&&E(T.split(","))},[T,E]),j.useEffect(()=>{const D=setTimeout(()=>u(a),150);return()=>clearTimeout(D)},[a]),j.useEffect(()=>{c&&!g&&S()},[c,g,S]);const{matchCount:L,filteredSessionIds:A,relevanceScores:O,matchTypes:M,promptSnippets:H}=j.useMemo(()=>{if(!c)return{matchCount:0,filteredSessionIds:null,relevanceScores:null,matchTypes:null,promptSnippets:null};const D=new Map(x.map(X=>[X.id,X])),U=new Map,$=new Map,te=new Map,q=f.filter(X=>{var ye;const Y=D.get(X.projectId),I=(Y==null?void 0:Y.name)??"",Q=X.title??"",ne=((ye=X.recentUserPrompts)==null?void 0:ye.map(Ie=>Ie.content))??[],re=ne.join(" ");let ie=0,pe="";if(aa(Q,c)&&(ie+=10,pe="title"),aa(re,c)){ie+=3,pe=pe==="title"?"title":"prompts";const Ie=ne.find($e=>aa($e,c));if(Ie){const $e=Ie.toLowerCase().indexOf(c.toLowerCase());if($e>=0){const Se=Math.max(0,$e-30),Ge=Math.min(Ie.length,$e+c.length+30);te.set(X.id,(Se>0?"…":"")+Ie.slice(Se,Ge)+(Ge<Ie.length?"…":""))}else te.set(X.id,Ie.slice(0,80)+(Ie.length>80?"…":""))}}return aa(I,c)&&(ie+=1,pe=pe||"project"),U.set(X.id,ie),$.set(X.id,pe),ie>0});return{matchCount:q.length,filteredSessionIds:new Set(q.map(X=>X.id)),relevanceScores:U,matchTypes:$,promptSnippets:te}},[f,c,x]),B=j.useMemo(()=>{const D=new Map;for(const U of f){const $=new Date(U.updatedAt).getTime(),te=D.get(U.projectId)??0;$>te&&D.set(U.projectId,$)}return D},[f]),F=j.useMemo(()=>{const D=new Map;for(const U of f){const $=D.get(U.projectId);$?$.push(U):D.set(U.projectId,[U])}for(const[,U]of D)U.sort(($,te)=>new Date(te.updatedAt).getTime()-new Date($.updatedAt).getTime());return D},[f]),K=j.useMemo(()=>{let D=x;return c&&A&&(D=x.filter(U=>{const $=F.get(U.id);return $==null?void 0:$.some(te=>A.has(te.id))})),[...D].sort((U,$)=>{const te=B.get(U.id)??new Date(U.updatedAt).getTime();return(B.get($.id)??new Date($.updatedAt).getTime())-te})},[x,F,c,A,B]),G=j.useCallback(D=>{const U=F.get(D);return U?c&&A&&O?U.filter($=>A.has($.id)).sort(($,te)=>{const q=(O.get(te.id)??0)-(O.get($.id)??0);return q!==0?q:new Date(te.updatedAt).getTime()-new Date($.updatedAt).getTime()}):U.slice(0,5):[]},[F,c,A,O]),V=()=>{t(!0)},Z=()=>{var D;o(""),u(""),Gt()&&((D=m.current)==null||D.focus())},J=D=>{var U;D.key==="Escape"&&(Z(),(U=m.current)==null||U.blur())},z=c.length>0,P=z&&L===0;return s.jsxs(pt,{className:"flex-1 flex flex-col bg-primary",children:[s.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[s.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),s.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ir,{href:"/split-view",className:"inline-flex items-center gap-1.5 rounded font-medium transition-colors bg-bg-secondary border border-border text-text-primary hover:bg-bg-tertiary px-3 py-1.5 text-sm",children:[s.jsx(mu,{className:"w-4 h-4"}),"Open split view"]}),s.jsx(ot,{variant:"primary",onClick:V,children:"Open Project"})]})]}),s.jsx(l9,{}),f.length>0&&s.jsxs("div",{className:"mb-4 md:mb-6 relative",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(_i,{className:"absolute left-3 w-4 h-4 text-text-muted pointer-events-none"}),s.jsx("input",{ref:m,type:"text",value:a,onChange:D=>o(D.target.value),onKeyDown:J,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&&s.jsx("button",{type:"button",onClick:Z,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:s.jsx(Ss,{className:"w-4 h-4"})})]}),z&&!P&&s.jsxs("div",{className:"mt-1.5 text-xs text-text-muted px-1",children:[L," ",L===1?"match":"matches"]})]}),P?s.jsxs("div",{className:"text-center py-16 text-text-muted",children:[s.jsx(_i,{className:"w-10 h-10 mx-auto mb-4 opacity-40"}),s.jsxs("p",{className:"text-lg",children:["No sessions matching ",s.jsxs("span",{className:"text-text-primary font-medium",children:["“",c,"”"]})]}),s.jsx("p",{className:"mt-2 text-sm",children:"Try a different keyword or clear the search"})]}):K.map(D=>{const U=G(D.id);return s.jsx("div",{className:"mb-6 md:mb-8",children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[s.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[s.jsxs(ir,{href:`/p/${D.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[s.jsx(Cr,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),s.jsx("span",{className:"text-text-primary font-semibold",children:D.name})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs(ot,{variant:"secondary",size:"sm",onClick:()=>h(D.id),title:`Tasks for ${D.name}`,"aria-label":`Tasks for ${D.name}`,className:"flex items-center gap-1.5",children:[s.jsx(Kf,{className:"w-4 h-4"}),s.jsx("span",{children:"Tasks"}),s.jsx(d9,{counts:k[D.id]})]}),s.jsx(ir,{href:`/p/${D.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"})]}),s.jsx("button",{type:"button",onClick:()=>r({id:D.id,name:D.name}),className:"p-1.5 rounded text-text-muted hover:text-accent-error hover:bg-accent-error/10 transition-colors",title:"Delete project",children:s.jsx(Si,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"divide-y divide-border",children:U.length>0?U.map($=>{const te=x.find(I=>$.projectId===I.id),q=te?`/p/${te.id}/s/${$.id}`:"#",X=$.title??$.id.slice(0,8),Y=M==null?void 0:M.get($.id);return s.jsx(ir,{href:q,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-muted truncate",children:z&&Y==="title"?Wy(X,c):X}),z&&Y&&Y!=="title"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1",children:[s.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:Y==="prompts"?"prompts":"project"}),Y==="prompts"&&(H==null?void 0:H.get($.id))&&s.jsx("span",{className:"text-[11px] text-text-muted truncate max-w-[250px]",children:Wy(H.get($.id),c)})]})]})}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx("span",{className:"text-text-muted text-xs",children:IT($.updatedAt)}),s.jsxs("span",{className:"text-text-muted text-xs",children:[$.messageCount," msgs"]})]})]})},$.id)}):s.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},D.id)}),!z&&K.length===0&&!w&&s.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),w&&s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(fa,{})})]}),e&&s.jsx(c9,{isOpen:e,onClose:()=>t(!1)}),d&&s.jsx(vm,{isOpen:!0,onClose:()=>h(null),projectId:d}),n&&s.jsx(rA,{isOpen:!0,onClose:()=>r(null),projectName:n.name,onConfirm:()=>_(n.id)})]})}function f9(){const[,e]=Dl("/p/:projectId/new"),[,t]=Nn(),n=e==null?void 0:e.projectId,r=Oe(c=>c.createSession),a=Oe(c=>c.resetPendingSessionCreate),o=j.useCallback(async()=>{if(!n)return;const c=await r(n);c?(t(`/p/${n}/s/${c.id}`),a()):(t(`/p/${n}`),a())},[n,r,t,a]);return j.useEffect(()=>{o()},[o]),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(fa,{})})}function m9(){const e=Pt(t=>t.currentProject);return s.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),s.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),s.jsxs("div",{className:"flex flex-col gap-3",children:[e&&s.jsx(ir,{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"}),s.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const sA=j.createContext(null),p9=sA.Provider;function Er(){const e=j.useContext(sA),t=Oe(n=>{var r;return n.focusedSessionId??((r=n.currentSession)==null?void 0:r.id)??null});return e||t}function cn(e,t,n,r){return Oe(a=>{var o,c;if(e){const u=(o=a.panes)==null?void 0:o[e];return u?t(u):((c=a.currentSession)==null?void 0:c.id)===e?n(a):r}return n(a)})}function zl(){const e=Er(),t=cn(e,r=>r.contextState??null,r=>r.contextState,null),n=cn(e,r=>r.session??null,r=>r.currentSession,null);return{sessionId:e,contextState:t,currentSession:n}}function iA(){const e=Er(),t=Oe(n=>n.queueUpdate);return j.useCallback(n=>{n?e&&t(e):Vt.send("context.applyDynamic",{...e?{sessionId:e}:{}})},[e,t])}const Wc=e=>Math.round(e*10)/10;function g9(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function qy(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function x9(e){return`${e.providerId}::${e.model}`}function y9(e){return`${e.providerName} > ${e.model}`}function Nk(e){let t=0,n=0,r=0,a=0,o=0,c=0;const u=[],d=[];let h=0;for(const[g,x]of e.entries()){const w=x.stats,C=qy(w);t+=w.totalTime,n+=w.toolTime,r+=w.prefillTokens,a+=w.generationTokens;const v=w.prefillSpeed>0?w.prefillTokens/w.prefillSpeed:0,S=w.generationSpeed>0?w.generationTokens/w.generationSpeed:0;o+=v,c+=S,u.push({messageId:x.id,timestamp:x.timestamp,...C,mode:w.mode,responseIndex:g+1,prefillTokens:w.prefillTokens,generationTokens:w.generationTokens,prefillSpeed:w.prefillSpeed,generationSpeed:w.generationSpeed,totalTime:w.totalTime,aiTime:w.totalTime-w.toolTime,toolTime:w.toolTime});const _=w.llmCalls??[];for(const b of _)h+=1,d.push({messageId:x.id,timestamp:b.timestamp??x.timestamp,providerId:b.providerId,providerName:b.providerName,backend:b.backend,model:b.model,mode:w.mode,responseIndex:g+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 m=o>0?Wc(r/o):0,f=c>0?Wc(a/c):0;return{totalTime:Wc(t),aiTime:Wc(t-n),toolTime:Wc(n),prefillTokens:r,generationTokens:a,avgPrefillSpeed:m,avgGenerationSpeed:f,responseCount:e.length,llmCallCount:d.length,dataPoints:u,callDataPoints:d}}function aA(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null&&g9(a.stats)).sort((a,o)=>new Date(a.timestamp).getTime()-new Date(o.timestamp).getTime());if(t.length===0)return null;const n=new Map;for(const a of t){const o=x9(qy(a.stats)),c=n.get(o)??[];n.set(o,[...c,a])}const r=Array.from(n.entries()).map(([a,o])=>{const c=qy(o[0].stats),u=Nk(o);return{...c,key:a,label:y9(c),...u}});return{...Nk(t),modelGroups:r}}function b9(e){return j.useMemo(()=>aA(e),[e])}function Sv(){var o;const{sessionId:e,currentSession:t}=zl(),n=cn(e,c=>c.gitStatus,c=>c.gitStatus,null),[r,a]=j.useState(!0);return j.useEffect(()=>{t!=null&&t.workdir&&a(!1)},[t==null?void 0:t.workdir]),{branch:(n==null?void 0:n.branch)??null,diff:{files:((o=n==null?void 0:n.diff)==null?void 0:o.files)??[],loading:r,error:null}}}function Al(e){return e.toLocaleString("en-US").replace(/,/g," ")}function Tk(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function Ps(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 c=Math.floor(t/60),u=t%60;return`${c}m ${u}s`}const n=Math.floor(t/3600),r=t%3600,a=Math.floor(r/60),o=r%60;return`${n}h ${a}m ${o}s`}const Ak=Object.assign(Object.create(null),{criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"}),Lk=Object.assign(Object.create(null),{criteria:"criteria",review_findings:"review findings",todos:"tasks"});function wl(e){return Object.hasOwn(Ak,e)?Ak[e]:e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function v9(e){return Object.hasOwn(Lk,e)?Lk[e]:e.replace(/_/g," ")}const Rk=["▁","▂","▃","▄","▅","▆","▇","█"];function _9(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 S9(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 w9(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((g,x)=>g.x-x.x),r=n[0].x,a=n[n.length-1].x,o=Math.min(...n.map(g=>g.y)),c=Math.max(...n.map(g=>g.y)),{minY:u,maxY:d}=S9(o,c),h=Math.max(0,u),m=Array.from({length:t},()=>" "),f=new Map;for(const g of n){const x=a===r?0:Math.round((g.x-r)/(a-r)*(t-1)),w=f.get(x)??[];f.set(x,[...w,g.y])}for(const[g,x]of f){const w=Math.max(...x);m[g]=Rk[_9(w,u,d)]??Rk[0]}return{blocks:m.join(""),minX:r,maxX:a,minY:h,maxY:d}}function Dk(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function Ok({data:e,width:t=60,height:n=78,label:r,xLabel:a,yLabel:o,showAxes:c=!0,formatY:u=Dk,formatX:d=Dk}){const h=j.useMemo(()=>{const m=w9(e,t),f=Math.max(t*6,240),g=10,x=8,C=[...e].sort((b,k)=>b.x-k.x).map(b=>{const k=m.maxX===m.minX?f/2:g+(b.x-m.minX)/(m.maxX-m.minX)*(f-g*2),E=m.maxY===m.minY?n/2:x+(m.maxY-b.y)/(m.maxY-m.minY)*(n-x*2);return{...b,cx:k,cy:E,leftPercent:k/f*100,topPercent:E/n*100}}),v=C.map((b,k)=>`${k===0?"M":"L"} ${b.cx.toFixed(1)} ${b.cy.toFixed(1)}`).join(" "),_=[m.maxY,(m.maxY+m.minY)/2,m.minY].map(b=>({value:b,y:m.maxY===m.minY?n/2:x+(m.maxY-b)/(m.maxY-m.minY)*(n-x*2)}));return{...m,chartWidth:f,points:C,path:v,gridLines:_}},[e,n,t]);return e.length===0?s.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[r&&s.jsx("div",{className:"mb-1",children:r}),s.jsx("div",{children:"No data"})]}):s.jsxs("div",{className:"font-mono text-xs",children:[r&&s.jsx("div",{className:"text-text-secondary mb-2",children:r}),s.jsxs("div",{className:"flex gap-3",children:[c&&s.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:h.gridLines.map(m=>s.jsx("span",{children:u(m.value)},`${m.value}-${m.y}`))}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsxs("div",{className:"relative h-[78px]",children:[s.jsxs("svg",{viewBox:`0 0 ${h.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[h.gridLines.map(m=>s.jsx("line",{x1:"0",x2:h.chartWidth,y1:m.y,y2:m.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${m.y}`)),h.points.map(m=>s.jsx("line",{x1:m.cx,x2:m.cx,y1:n-4,y2:m.cy,stroke:"currentColor",className:"text-border/40"},`guide-${m.cx}-${m.cy}`)),h.points.length>1&&s.jsx("path",{d:h.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),h.points.map(m=>s.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${m.leftPercent}%`,top:`${m.topPercent}%`},title:`${d(m.x)} -> ${u(m.y)}`,children:s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:s.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${m.x}-${m.y}`))]})})]}),c&&s.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[s.jsx("span",{className:"w-12"}),s.jsxs("span",{className:"flex-1 flex justify-between",children:[s.jsx("span",{children:d(h.minX)}),s.jsx("span",{children:a}),s.jsx("span",{children:d(h.maxX)})]})]}),o&&c&&s.jsx("div",{className:"text-text-muted mt-1 text-center",children:o})]})}function C9({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 o=e.map(u=>({x:u.x,y:u.ppSpeed})),c=e.map(u=>({x:u.x,y:u.tgSpeed}));return s.jsxs("div",{className:"space-y-5",children:[s.jsx(Ok,{data:o,width:a,label:t,xLabel:r}),s.jsx(Ok,{data:c,width:a,label:n,xLabel:r})]})}function k9(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,o)=>a.callIndex-o.callIndex);return{...n,callCount:r.length,calls:r,isExpandable:r.length>1}})}function j9(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 E9(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 N9(e){return e.callDataPoints.length>0?E9(e):j9(e)}function so(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function Zc(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function T9(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${so(t)} ctx`:`${so(t)}-${so(n)} ctx`}function _f(e){return`${Zc(e)} t/s`}function oA(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function A9(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 L9({isOpen:e,onClose:t,stats:n}){const r=j.useRef(null),[a,o]=j.useState({}),[c,u]=j.useState(()=>{var w;return((w=n.modelGroups[0])==null?void 0:w.key)??""});j.useEffect(()=>{var w;n.modelGroups.some(C=>C.key===c)||u(((w=n.modelGroups[0])==null?void 0:w.key)??"")},[c,n.modelGroups]);const d=j.useMemo(()=>n.modelGroups.find(w=>w.key===c)??n.modelGroups[0],[c,n.modelGroups]),h=j.useMemo(()=>d?k9(d):[],[d]),m=j.useMemo(()=>d?N9(d):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[d]),f=j.useCallback(w=>{o(C=>({...C,[w]:!C[w]}))},[]),g=j.useCallback(()=>{if(!d)return;const w=A9(d);navigator.clipboard.writeText(JSON.stringify(w,null,2)).catch(C=>console.error("Failed to copy:",C))},[d]),x=j.useCallback(async()=>{if(r.current)try{const w=(await se(async()=>{const{default:S}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:S}},[])).default,C=await w(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(w){console.error("Failed to export PNG:",w),g()}},[g]);return s.jsx(Et,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:s.jsxs("div",{ref:r,className:"space-y-6",children:[s.jsx("section",{children:s.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(w=>s.jsx("button",{onClick:()=>u(w.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${w.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:w.label,children:w.label},w.key))})}),d&&s.jsxs("section",{children:[s.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[s.jsx(ci,{label:"AI Time",value:Ps(d.aiTime)}),s.jsx(ci,{label:"Total Time",value:Ps(d.totalTime)}),s.jsx(ci,{label:"Tool Time",value:Ps(d.toolTime)}),s.jsx(ci,{label:"Responses",value:d.responseCount.toString()}),s.jsx(ci,{label:"LLM Calls",value:d.llmCallCount.toString()})]}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[s.jsx(ci,{label:"Prefill Tokens",value:so(d.prefillTokens),subValue:`@ ${Zc(d.avgPrefillSpeed)} tok/s`}),s.jsx(ci,{label:"Gen Tokens",value:so(d.generationTokens),subValue:`@ ${Zc(d.avgGenerationSpeed)} tok/s`}),s.jsx(ci,{label:"Avg PP Speed",value:`${Zc(d.avgPrefillSpeed)}`,subValue:"tok/s"}),s.jsx(ci,{label:"Avg TG Speed",value:`${Zc(d.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),d&&m.points.length>1&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:g,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),s.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:"Save PNG"})]})]}),s.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:s.jsx(C9,{data:m.points,width:50,prefillLabel:m.prefillLabel,generationLabel:m.generationLabel,xLabel:m.xLabel})})]}),d&&s.jsxs("section",{children:[s.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",d.responseCount," responses)"]}),s.jsx(pt,{className:"bg-bg-tertiary/30 rounded",children:s.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[s.jsxs("colgroup",{children:[s.jsx("col",{className:"w-[7%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[10%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[11%]"}),s.jsx("col",{className:"w-[2%]"})]}),s.jsx("thead",{children:s.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[s.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),s.jsx("th",{className:"px-2 py-2"})]})}),s.jsx("tbody",{children:h.map((w,C)=>s.jsxs(j.Fragment,{children:[s.jsx(R9,{row:w,index:C,isExpanded:a[w.messageId]??!1,onToggle:w.isExpandable?()=>f(w.messageId):void 0}),(a[w.messageId]??!1)&&w.calls.map((v,S)=>s.jsx(D9,{dataPoint:v,index:S},`${v.messageId}-${v.callIndex}`))]},w.messageId))})]})})]})]})})}function ci({label:e,value:t,subValue:n}){return s.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[s.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),s.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&s.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function R9({row:e,index:t,isExpanded:n,onToggle:r}){const a=e.calls.length>0?T9(e.calls.map(o=>o.promptTokens)):`${so(e.prefillTokens)} ctx`;return s.jsxs("tr",{onClick:r,className:`${t%2===0?"bg-bg-tertiary/20":""} ${r?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[s.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:oA(e.timestamp)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Ps(e.totalTime)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:a.replace(/ ctx$/,"")}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:_f(e.prefillSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:_f(e.generationSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function D9({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return s.jsxs(s.Fragment,{children:[s.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[s.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]}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:oA(e.timestamp)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Ps(e.totalTime)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:so(e.promptTokens)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:_f(e.prefillSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:_f(e.generationSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),s.jsx("td",{className:"px-2 py-2"})]}),n&&s.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:s.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:s.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&s.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&s.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&s.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&s.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const O9={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"}},lA=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function I9(e){return O9[e]??{icon:"○",color:"text-text-muted"}}function wv(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const Ul=j.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:r,color:a}=I9(t);return s.jsx("span",{className:`${a} ${n}`,children:r})});function Sf({entries:e,title:t}){const n=j.useMemo(()=>e.reduce((r,a)=>(r[a.status]=(r[a.status]??0)+1,r),{}),[e]);return s.jsxs("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center justify-between",children:[s.jsx("span",{children:t}),Object.keys(n).length>0&&s.jsx("span",{className:"font-normal text-xs flex items-center gap-1.5",children:lA.map(r=>{const a=n[r];return a?s.jsxs("span",{className:"flex items-center gap-0.5",children:[s.jsx(Ul,{status:r}),s.jsx("span",{children:a})]},r):null})})]})}const cA=j.memo(function({entries:t,title:n,onClearAll:r}){const[a,o]=j.useState(!1),c=j.useCallback(()=>{o(!1),r==null||r()},[r]);return t.length===0?null:s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[n&&s.jsx("div",{className:"px-1.5 py-1 border-b border-border bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:n})}),s.jsx("div",{className:"bg-primary",children:t.map((u,d)=>s.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${d>0?"border-t border-border":""}`,children:[s.jsx(Ul,{status:u.status}),s.jsxs("div",{className:"flex-1 min-w-0 text-xs truncate",children:[s.jsxs("span",{className:"text-text-muted",children:["[",u.id,"]"]})," ",wv(u.description)]})]},u.id??d))}),r&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:s.jsxs("button",{onClick:()=>o(!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:[s.jsx(Si,{className:"w-3 h-3"}),"Clear all"]})}),a&&s.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:s.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[s.jsx("span",{className:"text-xs text-accent-error",children:"Clear all?"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:c,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),s.jsx("button",{onClick:()=>o(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})})]})]})}),M9={criteria:["pending","completed","passed","failed"],todos:["pending","in_progress","completed"],review_findings:["open","resolved","dismissed"]},P9=["pending","completed","failed","dismissed"];function B9(e){return M9[e]??P9}function $9(e,t){const n=t.indexOf(e);return n===-1?t[0]??"pending":t[(n+1)%t.length]??"pending"}function uA({entries:e,sessionId:t,metadataKey:n,title:r,isOpen:a,onClose:o}){const[c,u]=j.useState(e),[d,h]=j.useState(null),[m,f]=j.useState(""),[g,x]=j.useState(!1),[w,C]=j.useState(""),v=j.useRef(null),S=j.useRef(null),_=j.useCallback(()=>{const B=S.current;B&&(B.style.height="auto",B.style.height=B.scrollHeight+"px")},[]);j.useEffect(()=>{u(e)},[e]),j.useEffect(()=>{var B;d&&(_(),Gt()&&((B=S.current)==null||B.focus()))},[d,_]),j.useEffect(()=>{var B;g&&Gt()&&((B=v.current)==null||B.focus())},[g]);const b=j.useCallback(B=>{u(B),me(`/api/sessions/${t}/metadata/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:B})}).catch(F=>console.error(`Failed to sync ${n}:`,F))},[t,n]),k=j.useCallback(B=>{const F=B9(n),K=c.map(G=>G.id===B?{...G,status:$9(G.status,F)}:G);b(K)},[c,n,b]),E=j.useCallback((B,F)=>{h(B),f(F)},[]),T=j.useCallback((B,F,K)=>{var Z;const G=(F.trim()||((Z=K.find(J=>J.id===B))==null?void 0:Z.description))??"",V=K.map(J=>J.id===B?{...J,description:G}:J);b(V)},[b]),L=j.useCallback(()=>{d&&(T(d,m,c),h(null))},[d,m,c,T]),A=j.useCallback(B=>{B.key==="Enter"&&L(),B.key==="Escape"&&(B.stopPropagation(),h(null))},[L]),O=j.useCallback(B=>{b(c.filter(F=>F.id!==B))},[c,b]),M=j.useCallback(()=>{const B=w.trim();if(!B)return;const F=c.map(G=>Number(G.id)).filter(G=>Number.isInteger(G)&&G>=0),K=String(Math.max(-1,...F)+1);b([...c,{id:K,description:B,status:"pending"}]),C("")},[w,c,b]),H=j.useCallback(B=>{B.key==="Enter"&&(B.preventDefault(),M()),B.key==="Escape"&&(x(!1),C(""))},[M]);return s.jsxs(Et,{isOpen:a,onClose:o,title:r,size:"full",showCloseButton:!0,closeOnEscape:!0,children:[s.jsxs("ul",{className:"space-y-1",children:[c.map((B,F)=>{const K=d===B.id,G=s.jsxs("button",{onClick:()=>E(B.id,B.description),className:"text-sm text-text-primary text-left hover:text-accent-primary transition-colors w-full cursor-pointer",title:"Click to edit",children:[s.jsxs("span",{className:"text-text-muted",children:["[",B.id,"]"]})," ",s.jsx("span",{children:wv(B.description)})]}),V=K?s.jsx("textarea",{ref:S,value:m,onChange:Z=>{f(Z.target.value),_()},onBlur:L,onKeyDown:A,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}):G;return s.jsxs("li",{className:`flex items-start gap-2 px-2 py-1.5 ${F>0?"border-t border-border":""}`,children:[s.jsx("button",{onClick:()=>k(B.id),className:"flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity mt-0.5",title:"Click to cycle status",children:s.jsx(Ul,{status:B.status})}),s.jsx("div",{className:"flex-1 min-w-0",children:V}),s.jsx("button",{onClick:()=>O(B.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:s.jsx("span",{className:"flex",children:s.jsx(Ss,{className:"w-4 h-4"})})})]},B.id)}),c.length===0&&s.jsx("p",{className:"text-sm text-text-muted italic text-center py-4",children:"No entries yet."})]}),s.jsx("div",{className:"mt-4 pt-3 border-t border-border",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight",children:"○"}),s.jsx("input",{ref:v,value:w,onChange:B=>C(B.target.value),onKeyDown:H,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"}),s.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:[s.jsx(Hr,{className:"w-4 h-4"}),"Add"]})]})})]})}const F9={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function H9(e,t){await me(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function _h({id:e,agents:t}){const n=oo(t,e),r=t.find(a=>a.id===e);return s.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${n}20`,color:n},children:(r==null?void 0:r.name)??e})}function z9({id:e}){const t=Wt(c=>c.defaults),n=Wt(c=>c.userItems),a=j.useMemo(()=>[...t,...n],[t,n]).find(c=>c.id===e),o=(a==null?void 0:a.color)??"#3b82f6";return s.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${o}20`,color:o},children:(a==null?void 0:a.name)??e})}function dA({entries:e,sessionId:t}){const[n,r]=j.useState(e),[a,o]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(""),[m,f]=j.useState(""),[g,x]=j.useState(!1),[w,C]=j.useState(!1),v=dt(J=>J.defaults),S=dt(J=>J.userItems),_=dt(J=>J.projectItems),b=j.useMemo(()=>[...v,...S,..._],[v,S,_]),k=j.useRef(null),E=j.useRef(null);j.useEffect(()=>{r(e)},[e]),j.useEffect(()=>{var J;a&&Gt()&&((J=k.current)==null||J.focus())},[a]),j.useEffect(()=>{var J;c&&Gt()&&((J=E.current)==null||J.focus())},[c]);const T=j.useCallback(J=>{r(J),H9(t,J)},[t]),L=j.useCallback(J=>{var $;const z=J.map(te=>te.trim()).filter(Boolean);if(z.length===0)return;const P=n.map(te=>Number(te.id)).filter(te=>Number.isInteger(te)&&te>=0),D=Math.max(-1,...P)+1,U=z.map((te,q)=>({id:String(D+q),description:te,status:"pending"}));T([...n,...U]),h(""),Gt()&&(($=k.current)==null||$.focus())},[n,T]),A=j.useCallback(()=>{L([d])},[L,d]),O=j.useCallback(J=>{const z=J.clipboardData.getData("text/plain").split(/\r\n|\r|\n/);z.length<2||(J.preventDefault(),L(z))},[L]),M=j.useCallback(()=>{o(!1),h("")},[]),H=j.useCallback((J,z)=>{u(J),f(z)},[]),B=j.useCallback(()=>{if(!c)return;const J=m.trim(),z=n.map(P=>P.id===c?{...P,description:J||P.description}:P);T(z),u(null)},[c,m,n,T]),F=j.useCallback(J=>{const z=n.map(P=>P.id===J?{...P,status:F9[P.status]??"pending"}:P);T(z)},[n,T]),K=j.useCallback(J=>{T(n.filter(z=>z.id!==J))},[n,T]),G=j.useCallback(()=>{T([]),x(!1)},[T]),V=j.useCallback(J=>{J.key==="Enter"&&(J.preventDefault(),A()),J.key==="Escape"&&M()},[A,M]),Z=j.useCallback(J=>{J.key==="Enter"&&B(),J.key==="Escape"&&u(null)},[B]);return s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[s.jsxs("div",{className:"bg-primary",children:[n.length===0&&!a&&s.jsxs("div",{className:"px-1.5 py-2 text-xs text-text-muted italic text-center",children:["No criteria yet."," ",s.jsx("button",{onClick:()=>C(!0),className:"text-accent-primary hover:underline not-italic cursor-pointer",children:"Learn more"})]}),n.map((J,z)=>{const P=J.status,D=c===J.id;return s.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${z>0?"border-t border-border":""}`,children:[s.jsx("button",{onClick:()=>F(J.id),className:"text-xs leading-tight flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",title:`Status: ${J.status} (click to cycle)`,children:s.jsx(Ul,{status:P})}),s.jsx("div",{className:"flex-1 min-w-0",children:D?s.jsx("input",{ref:E,value:m,onChange:U=>f(U.target.value),onBlur:B,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"}):s.jsxs("button",{onClick:()=>H(J.id,J.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:["[",J.id,"] ",wv(J.description)]})}),s.jsx("button",{onClick:()=>K(J.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:s.jsx(Ss,{className:"w-4 h-4"})})]},J.id)})]}),a&&s.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-text-muted text-xs leading-tight flex-shrink-0",children:"○"}),s.jsx("input",{ref:k,value:d,onChange:J=>h(J.target.value),onKeyDown:V,onPaste:O,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"})]})}),s.jsxs("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:[a?s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:A,className:"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add criterion",children:[s.jsx(Hr,{className:"w-3 h-3"}),"Add"]}),s.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"})]}):s.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"Add criterion",children:[s.jsx(Hr,{className:"w-3 h-3"}),"Add"]}),n.length>0&&(g?s.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[s.jsx("span",{className:"text-xs text-accent-error",children:"Clear all criteria?"}),s.jsx("button",{onClick:G,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),s.jsx("button",{onClick:()=>x(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]}):s.jsxs("button",{onClick:()=>x(!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:[s.jsx(Si,{className:"w-3 h-3"}),"Clear all"]})),s.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:s.jsx(Vf,{className:"w-3 h-3"})})]}),s.jsx(Et,{isOpen:w,onClose:()=>C(!1),title:"About Acceptance Criteria",size:"md",children:s.jsxs("div",{className:"space-y-3 text-sm text-text-secondary",children:[s.jsx("p",{children:"Each criterion defines a specific requirement that needs to be met."}),s.jsxs("p",{children:["To use this feature, start in ",s.jsx(_h,{id:"planner",agents:b})," mode and",s.jsxs("strong",{className:"text-text-primary",children:[" ","ask the agent to define acceptance criteria that matches your goal"]}),". Then launch the ",s.jsx(z9,{id:"default"})," builtin workflow to launch the automation part."]}),s.jsx("p",{children:"This workflow will automatically:"}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsxs("li",{children:["Launch the ",s.jsx(_h,{id:"builder",agents:b}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),s.jsxs("li",{children:["Then launch the ",s.jsx(_h,{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."]}),s.jsxs("li",{children:["Launch a ",s.jsx(_h,{id:"code_reviewer",agents:b})," subagent, that will analyze the code to provide actionable feedback to the main agent."]})]}),s.jsx("div",{className:"bg-bg-tertiary rounded p-3 space-y-1.5",children:s.jsx("p",{children:"This lets smaller models follow complex plans to completion and improves the chances that nothing from your plan is missed."})})]})})]})}function hA({isOpen:e,onClose:t}){const n=nr(C=>C.config),r=nr(C=>C.saveConfig),[a,o]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(!1),[m,f]=j.useState(!1),[g,x]=j.useState(!1);j.useEffect(()=>{e&&(o((n==null?void 0:n.command)??""),u((n==null?void 0:n.url)??""),h((n==null?void 0:n.hotReload)??!1),f((n==null?void 0:n.disableInspect)??!1))},[e,n]);const w=async()=>{!a.trim()||!c.trim()||(x(!0),await r({command:a.trim(),url:c.trim(),hotReload:d,disableInspect:m}),x(!1),t())};return s.jsx(Et,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),s.jsx("input",{className:"input w-full",type:"text",value:a,onChange:C=>o(C.target.value),placeholder:"npm run dev"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),s.jsx("input",{className:"input w-full",type:"text",value:c,onChange:C=>u(C.target.value),placeholder:"http://localhost:3000"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"hotReload",checked:d,onChange:C=>h(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),s.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"disableInspect",checked:m,onChange:C=>f(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),s.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),s.jsx("button",{className:"btn btn-primary",onClick:w,disabled:g||!a.trim()||!c.trim(),children:g?"Saving...":"Save"})]})]})})}const Ik={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"},U9={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"},Mk={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},V9="text-text-primary";function W9(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let r=0,a="text-text-primary",o;try{for(;(o=n.exec(e))!==null;){if(o.index>r){const h=e.slice(r,o.index);h&&t.push({text:h,className:a})}const c=o[1];if(!c)continue;const u=c.split(";").map(Number);if(u.length===0||u[0]===0){a="text-text-primary";continue}const d=[];for(const h of u)if(h>=30&&h<=37){const m=Ik[h];m&&d.push(m)}else if(h>=40&&h<=47){const m=U9[h];m&&d.push(m)}else if(h>=90&&h<=97){const m=Ik[h];m&&d.push(m)}else if(h in Mk){const m=Mk[h];m&&d.push(m)}else h===39?d.push(V9):h===49&&(a=a.split(" ").filter(m=>!m.startsWith("bg-")).join(" "));d.length>0&&(a=d.join(" ")),r=n.lastIndex}if(r<e.length){const c=e.slice(r);c&&t.push({text:c,className:a})}return t}catch(c){return console.warn("ANSI parsing failed, stripping codes:",c),[{text:G9(e),className:"text-text-primary"}]}}function G9(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function wf(e){const t=W9(e),n=[];return t.forEach((r,a)=>{const o=r.text.split(`
|
|
285
|
+
`);o.forEach((c,u)=>{n.push(ps.createElement("span",{key:`${a}-${u}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},c)),u<o.length-1&&n.push(ps.createElement("br",{key:`${a}-${u}-br`}))})}),n.length===1?n[0]:n}function fA({logs:e,preRef:t,preClassName:n="text-sm font-mono",scrollAreaRef:r,onScrollbarGesture:a}){return s.jsx(pt,{ref:r,options:{overflow:{x:"scroll",y:"scroll"}},className:n,onScrollbarGesture:a,children:s.jsx("pre",{ref:t,className:"contents",children:e.length===0?s.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((o,c)=>o.type==="marker"?s.jsx(j.Fragment,{children:s.jsx("hr",{className:"border-t border-border my-1"})},c):s.jsx("span",{className:o.stream==="stderr"?"text-accent-warning":"",children:wf(o.content)},c))})})}function Cv({isActive:e,onToggle:t,className:n,style:r}){return s.jsxs("button",{type:"button",onClick:()=>t(!e),className:n,style:r,children:[e?s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):s.jsx(gn,{className:"w-3 h-3"}),e?"live":"scroll to bottom"]})}const q9=100,K9=6,Y9=1500,mA=(e,t)=>e==="down"?!1:t!==null&&t<=K9,Bu=(e,t,n)=>{const r=j.useRef(!0),a=j.useRef(null),o=j.useRef(!1),c=j.useRef(0),u=j.useRef(!1),d=j.useRef(0),[h,m]=j.useState(!0),f=j.useCallback(()=>{if(n)return n();const b=e.current;return b instanceof HTMLElement?b:null},[n,e]),g=j.useCallback(b=>{b||(d.current+=1),r.current=b,m(b)},[]),x=j.useCallback(()=>{g(!1)},[g]),w=j.useCallback(()=>{if(!r.current)return;const b=f();b&&(u.current=!0,b.scrollTop=b.scrollHeight,requestAnimationFrame(()=>{requestAnimationFrame(()=>{u.current=!1})}),c.current=Date.now())},[f]),C=j.useCallback((b,k)=>{b==="down"&&(o.current=!0);const E=mA(b,k);g(E),E&&(c.current=Date.now()),b==="up"&&(o.current=!1)},[g]),v=j.useRef(null);j.useEffect(()=>{if(t!=null&&t.id)return v.current!==null&&(cancelAnimationFrame(v.current),v.current=null),g(!0),c.current=Date.now(),v.current=requestAnimationFrame(()=>{requestAnimationFrame(()=>{w(),v.current=null})}),()=>{v.current!==null&&(cancelAnimationFrame(v.current),v.current=null)}},[t==null?void 0:t.id,g,w]),j.useEffect(()=>{const b=f();if(!b)return;const k=()=>{const B=d.current;requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(B!==d.current)return;b.scrollHeight-b.scrollTop-b.offsetHeight<q9&&(c.current=Date.now(),g(!0))})})},E=B=>{if(B.deltaY>0){k();return}x()},T=B=>{B.touches[0]&&(a.current=B.touches[0].clientY)},L=B=>{if(a.current===null)return;const F=B.touches[0];if(!F)return;if(F.clientY-a.current>0){x();return}k()},A=()=>{o.current||u.current||Date.now()-c.current<=Y9||g(!1)},O=B=>{if(!(B.ctrlKey||B.metaKey||B.altKey)){if(B.key==="ArrowUp"||B.key==="PageUp"||B.key==="Home"){x();return}(B.key==="ArrowDown"||B.key==="PageDown"||B.key==="End")&&k()}},M=new MutationObserver(()=>{r.current&&requestAnimationFrame(w)}),H=setInterval(()=>{r.current&&w()},1e3);return b.addEventListener("wheel",E,{passive:!0}),b.addEventListener("touchstart",T,{passive:!0}),b.addEventListener("touchmove",L,{passive:!0}),b.addEventListener("scroll",A,{passive:!0}),b.addEventListener("keydown",O),b.tabIndex=-1,M.observe(b,{childList:!0,subtree:!0,characterData:!0}),()=>{b.removeEventListener("wheel",E),b.removeEventListener("touchstart",T),b.removeEventListener("touchmove",L),b.removeEventListener("scroll",A),b.removeEventListener("keydown",O),M.disconnect(),clearInterval(H)}},[t==null?void 0:t.id,f,w,g,x]);const S=j.useCallback(()=>{g(!0),w()},[g,w]),_=j.useCallback(b=>{g(b),b&&w()},[g,w]);return{force_scroll_to_bottom:S,isAutoScrollActive:h,setAutoScroll:_,handleScrollbarGesture:C}},$u=e=>j.useCallback(()=>{var t,n;return((n=(t=e.current)==null?void 0:t.osInstance())==null?void 0:n.elements().viewport)??null},[e]),kv=j.memo(function({title:t,subtitle:n,logs:r,onClose:a,onClear:o,onInsertMarker:c,preClassName:u}){const d=j.useRef(null),h=$u(d),{isAutoScrollActive:m,setAutoScroll:f,handleScrollbarGesture:g}=Bu(d,null,h);return s.jsxs(Et,{isOpen:!0,onClose:a,title:t,size:"full",scrollable:!1,headerRight:s.jsx(Cv,{isActive:m,onToggle:f,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:s.jsxs("div",{className:"flex items-center gap-2",children:[c&&s.jsxs("button",{onClick:c,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:[s.jsx(Hr,{className:"w-3.5 h-3.5"}),"Marker"]}),o&&s.jsxs("button",{onClick:o,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:[s.jsx(Si,{className:"w-3.5 h-3.5"}),"Clear"]})]}),children:[n&&s.jsxs("div",{className:"subtitle-strip flex items-start gap-2 px-2 py-1.5 mb-2 bg-bg-tertiary rounded text-[11px] font-mono text-text-secondary whitespace-pre-wrap break-all border border-border",children:[s.jsx("span",{className:"text-text-muted flex-shrink-0 select-none",children:"Command:"}),s.jsx("span",{children:n})]}),s.jsx(pt,{ref:d,className:"flex-1 -m-4 p-4",onScrollbarGesture:g,children:s.jsx(fA,{logs:r,preClassName:u})})]})}),X9=j.memo(function({logs:t,anchorRef:n,isHiding:r,isAutoScrollActive:a,onSetAutoScroll:o}){const[c,u]=j.useState(null),d=j.useRef(null),h=j.useRef(o);h.current=o;const m=j.useCallback((g,x)=>{o(mA(g,x))},[o]),f=j.useCallback(()=>{var g,x;return((x=(g=d.current)==null?void 0:g.osInstance())==null?void 0:x.elements().viewport)??null},[]);return j.useEffect(()=>{var x;const g=(x=n.current)==null?void 0:x.getBoundingClientRect();g&&u({bottom:window.innerHeight-g.bottom,right:window.innerWidth-g.right,width:g.width,height:g.height})},[n]),j.useEffect(()=>{const g=f();if(!g)return;const x=w=>{if(w.deltaY<0){h.current(!1);return}w.deltaY>0&&requestAnimationFrame(()=>requestAnimationFrame(()=>{g.scrollHeight-g.scrollTop-g.offsetHeight<100&&h.current(!0)}))};return g.addEventListener("wheel",x,{passive:!0}),()=>g.removeEventListener("wheel",x)},[f]),j.useEffect(()=>{const g=f();g&&a&&(g.scrollTop=g.scrollHeight)},[t,a,c,f]),s.jsx("div",{className:`relative ${c?"":"hidden"}`,children:s.jsx(pt,{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:m,style:c?{bottom:c.bottom,right:c.right,width:c.width*2,maxHeight:c.height*3,transformOrigin:"bottom right",transform:r?"scale(0.01)":"scale(1)",opacity:r?0:1}:void 0,children:s.jsx("pre",{className:"text-sm font-mono",children:t.map((g,x)=>s.jsx("span",{className:g.stream==="stderr"?"text-accent-warning":"",children:wf(g.content)},x))})})})}),pA=j.memo(function({workdir:t,compact:n,onExpand:r,onConfigure:a}){const o=nr(D=>D.setWorkdir),c=nr(D=>D.status),u=nr(D=>D.config),d=nr(D=>D.logs),h=nr(D=>D.start),m=nr(D=>D.stop),f=nr(D=>D.fetchLogs),g=nr(D=>D.clearLogs),x=nr(D=>D.insertMarker),w=()=>{window.confirm("Clear all dev server logs?")&&g()},[C,v]=j.useState(!1),[S,_]=j.useState(!1),[b,k]=j.useState(!1),[E,T]=j.useState(!1),L=j.useRef(null),A=j.useRef(null),O=j.useCallback(()=>{var D,U;return((U=(D=A.current)==null?void 0:D.osInstance())==null?void 0:U.elements().viewport)??null},[]),{isAutoScrollActive:M,setAutoScroll:H,handleScrollbarGesture:B}=Bu(A,null,O),F=j.useRef(null),K=j.useRef(null),G=j.useRef(null),V=()=>{const D=c==null?void 0:c.inspectProxyPort;if(!D){c!=null&&c.url&&window.open(c.url,"_blank");return}const U=`${window.location.protocol}//${window.location.hostname}:${D}`;window.open(U,"_blank")},Z=(c==null?void 0:c.state)??"off",J=u!==null,z=Z==="running"||Z==="warning";j.useEffect(()=>{o(t??null)},[t,o]),j.useEffect(()=>{z&&f()},[z,f]);const P=()=>{z?m():h()};return s.jsxs("div",{className:`space-y-3 ${n?"":"mt-2 pt-3 border-t border-border"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.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"}`}),s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),s.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:s.jsx(CE,{})})]}),J?s.jsx(s.Fragment,{children:Z==="running"||Z==="warning"?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:P,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:[s.jsx(kb,{}),"Stop"]}),(c==null?void 0:c.url)&&s.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:c.url,children:[s.jsx(Cb,{}),"Open"]})]}):s.jsx("button",{onClick:P,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"})}):s.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"}),s.jsxs("div",{ref:G,className:`relative ${J&&z?"":"hidden"}`,onMouseEnter:()=>{!J||!z||n||(K.current&&clearTimeout(K.current),F.current=setTimeout(()=>{k(!0),T(!1)},500))},onMouseLeave:()=>{F.current&&clearTimeout(F.current),T(!0),K.current=setTimeout(()=>k(!1),150)},children:[s.jsx(fA,{logs:d,preRef:L,preClassName:"text-sm bg-bg-primary p-2 rounded max-h-[200px] border border-border",scrollAreaRef:A,onScrollbarGesture:B}),J&&z&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"absolute bottom-1 right-1 z-50 flex items-center gap-1",children:[!n&&(b||E)&&s.jsx(Cv,{isActive:M,onToggle:H,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"}),s.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)&&G.current&&wi.createPortal(s.jsx(X9,{logs:d,anchorRef:G,isHiding:E,isAutoScrollActive:M,onSetAutoScroll:H}),document.body)]})]}),!a&&s.jsx(hA,{isOpen:C,onClose:()=>v(!1)}),S&&s.jsx(kv,{title:"Dev Server Logs",logs:d,onClose:()=>_(!1),onClear:w,onInsertMarker:x})]})}),Q9=j.memo(function({sessionId:t}){const n=eu(x=>x.processes),r=eu(x=>x.stopProcess),[a,o]=j.useState(null),[c,u]=j.useState([]),d=n.filter(x=>x.status!=="exited"),h=d.filter(x=>x.status==="running").length;if(n.length===0)return null;const m=x=>{switch(x){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"}},f=x=>{const w=eu.getState().logs[x]??[];u(w.map(C=>({content:C.content,stream:C.stream}))),o(x)},g=x=>{t&&r(x,t)};return s.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",h," running)"]})]})}),s.jsx("div",{className:"space-y-2",children:d.map(x=>s.jsx("div",{className:"border border-border rounded p-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${m(x.status)}`}),s.jsx("span",{className:"text-sm text-text-primary truncate",title:x.name,children:x.name}),s.jsxs("span",{className:"text-xs text-text-muted",children:["[",x.status,"]"]})]}),s.jsxs("div",{className:"flex gap-1 ml-2",children:[s.jsx("button",{onClick:()=>f(x.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"}),s.jsx("button",{onClick:()=>g(x.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"})]})]})},x.id))}),a&&(()=>{const x=d.find(w=>w.id===a);return s.jsx(kv,{title:(x==null?void 0:x.name)??"",subtitle:x==null?void 0:x.command,logs:c,onClose:()=>{o(null),u([])}})})()]})});function gA(){return an.getState().platform??null}function xA(e){const t=e.replace(/\\/g,"/");return encodeURI(t).replace(/#/g,"%23").replace(/\?/g,"%3F")}function yA(e,t,n){const r=gA(),a=e.startsWith("/")||e.match(/^[a-zA-Z]:[/\\]/)?e:n?`${n.replace(/\\/g,"/").replace(/\/$/,"")}/${e}`:e,o=xA(a);if(r!=null&&r.isWSL&&r.wslDistro)return`${`vscode://vscode-remote/wsl+${r.wslDistro}${o}`}:${t??1}`;const c=`vscode://file/${o}`;return t?`${c}:${t}`:c}function J9(e){const t=gA(),n=xA(e.replace(/\\/g,"/"));return t!=null&&t.isWSL&&t.wslDistro?`vscode://vscode-remote/wsl+${t.wslDistro}${n}`:`vscode://file/${n}`}function Z9({file:e,showEditorLink:t,workdir:n}){const r=Ab(e.path,28),a=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",o=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"",c=t&&n?yA(e.path,void 0,n):void 0,u=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`truncate ${a}`,title:e.path,children:r}),o&&s.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:o})]});return c?s.jsx("a",{href:c,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:u}):s.jsx("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:u})}function eV(){const{diff:e}=Sv(),t=Bt(a=>a.settings[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",{currentSession:n}=zl(),r=(n==null?void 0:n.workspace)??(n==null?void 0:n.workdir);return e.loading?s.jsx("div",{className:"mt-3",children:s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[s.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),s.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?s.jsx("div",{className:"mt-3",children:s.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):s.jsx(pt,{className:"mt-3 max-h-[150px]",children:s.jsx("div",{className:"pr-1",children:e.files.map((a,o)=>s.jsx(Z9,{file:a,showEditorLink:t,workdir:r},o))})})}function bA(e){const[t,n]=j.useState(!1),[r,a]=j.useState(null),[o,c]=j.useState(!1),[u,d]=j.useState(""),h=j.useCallback(()=>{t||e()},[t,e]),m=u.trim().length>0&&!t,f=j.useCallback(()=>{a(null),n(!1),d(""),c(!0)},[]);return{busy:t,setBusy:n,error:r,setError:a,loading:o,setLoading:c,newName:u,setNewName:d,handleClose:h,canCreate:m,resetState:f}}function vA({isOpen:e,onClose:t,title:n,busy:r,loading:a,children:o}){const c=s.jsx("div",{className:"flex gap-2 justify-end",children:s.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 s.jsx(Et,{isOpen:e,onClose:t,title:n,size:"md",footer:c,children:a||r?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(fa,{})}):o})}function _A({icon:e,title:t,placeholder:n,buttonLabel:r,value:a,onChange:o,onCreate:c,canCreate:u,busy:d}){return s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:t}),s.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:[s.jsx("span",{className:"w-4 h-4 shrink-0 text-text-muted flex items-center",children:e}),s.jsx("input",{type:"text",value:a,onChange:h=>o(h.target.value),onKeyDown:h=>{h.key==="Enter"&&u&&c()},placeholder:n,className:"flex-1 bg-transparent text-sm text-text-primary outline-none font-mono placeholder-text-muted"})]}),s.jsx("button",{onClick:c,disabled:!u||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 SA({isOpen:e,onClose:t,projectId:n,sessionId:r,currentWorkspace:a,currentBranch:o}){const c=Oe(F=>F.loadSession),{busy:u,setBusy:d,error:h,setError:m,loading:f,setLoading:g,newName:x,setNewName:w,handleClose:C,canCreate:v,resetState:S}=bA(t),[_,b]=j.useState([]),[k,E]=j.useState(null),[T,L]=j.useState(null),[A,O]=j.useState(!1);j.useEffect(()=>{e&&(S(),E(null),L(null),O(!1),me(`/api/projects/${n}/workspaces`).then(F=>F.json()).then(F=>{b(F.workspaces),g(!1)}).catch(()=>{b([]),g(!1)}))},[e,n,S,g]);const M=j.useCallback(async F=>{m(null),d(!0);try{const K=await me(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:F})});if(!K.ok){const G=await K.json().catch(()=>({error:"Failed to switch workspace"}));m(G.error),d(!1);return}await c(r,!0),t()}catch(K){m(K instanceof Error?K.message:"Failed to switch workspace"),d(!1)}},[r,c,t,m,d]),H=j.useCallback(async(F,K)=>{m(null),L(null),O((K==null?void 0:K.force)===!0),d(!0);try{const G=await me(`/api/sessions/${r}/delete-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:F,force:(K==null?void 0:K.force)===!0})});if(!G.ok){const J=await G.json().catch(()=>({error:"Failed to delete workspace"}));m(J.error),J.conflictingSessionIds&&L(J.conflictingSessionIds),O(!1),d(!1);return}E(null),O(!1),await c(r,!0);const Z=await(await me(`/api/projects/${n}/workspaces`)).json();b(Z.workspaces),d(!1),g(!1)}catch(G){m(G instanceof Error?G.message:"Failed to delete workspace"),O(!1),d(!1)}},[r,n,c,m,d]),B=j.useCallback(async()=>{m(null),d(!0);try{const F=await me(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:x.trim()})});if(!F.ok){const K=await F.json().catch(()=>({error:"Failed to create workspace"}));m(K.error),d(!1);return}await c(r),t()}catch(F){m(F instanceof Error?F.message:"Failed to create workspace"),d(!1)}},[x,r,c,t,m,d]);return s.jsx(vA,{isOpen:e,onClose:C,title:"Switch Workspace",busy:u,loading:f,children:s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Workspaces"}),s.jsxs(pt,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2 mb-4",children:[s.jsxs("button",{onClick:()=>M("original"),disabled:u,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:[s.jsx(Cr,{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:"original"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:o??"unknown"}),!a&&s.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),_.slice().sort((F,K)=>F.name===a?-1:K.name===a?1:F.name.localeCompare(K.name)).map(F=>s.jsx("div",{className:"group relative",children:k===F.name?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded bg-accent-error/10",children:[s.jsxs("span",{className:"text-xs text-accent-error",children:["Delete ",F.name,"?"]}),s.jsx("button",{onClick:()=>H(F.name),disabled:u,className:"ml-auto text-xs px-2 py-0.5 rounded bg-accent-error text-white hover:opacity-90",children:"Confirm"}),s.jsx("button",{onClick:()=>E(null),disabled:u,className:"text-xs px-2 py-0.5 rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary",children:"Cancel"})]}):s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>{!u&&F.name!==a&&M(F.name)},disabled:u||F.name===a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${F.name===a?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"} ${u?"opacity-70":""}`,children:[s.jsx(Cr,{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:F.name}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:F.branch??"unknown"}),F.name===a&&s.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),F.name!==a&&!u&&s.jsx("button",{onClick:K=>{K.stopPropagation(),m(null),L(null),E(F.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:"✕"})]})},F.path))]}),s.jsx(_A,{icon:s.jsx(Cr,{}),title:"Create new workspace",placeholder:"workspace name",buttonLabel:"Create Workspace",value:x,onChange:w,onCreate:B,canCreate:v,busy:u}),h&&s.jsxs("div",{className:"mt-3 text-sm bg-accent-error/10 p-2 rounded",role:"alert",children:[s.jsx("p",{className:"text-accent-error",children:h}),T&&T.length>0&&s.jsxs("div",{className:"mt-2 space-y-1",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Conflicting sessions:"}),s.jsx("ul",{className:"space-y-0.5",children:T.map(F=>s.jsx("li",{children:s.jsx(ir,{href:`/p/${n}/s/${F}`,className:"text-xs font-mono text-accent-primary hover:underline break-all",children:F})},F))}),s.jsx("button",{onClick:()=>H(k??"",{force:!0}),disabled:u||!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:A?"Processing...":"Force Delete (switch other sessions to original)"})]})]})]})})}function wA({isOpen:e,onClose:t,sessionId:n}){const r=Oe(L=>L.loadSession),{busy:a,setBusy:o,error:c,setError:u,loading:d,setLoading:h,newName:m,setNewName:f,handleClose:g,canCreate:x,resetState:w}=bA(t),[C,v]=j.useState([]),[S,_]=j.useState(""),[b,k]=j.useState("");j.useEffect(()=>{e&&(w(),_(""),v([]),k(""),me(`/api/sessions/${n}/branches`).then(L=>L.json()).then(L=>{v(L.branches),k(L.defaultBranch??""),h(!1)}).catch(()=>{v([]),h(!1)}))},[e,n,w,h]);const E=j.useCallback(async L=>{u(null),o(!0);try{const A=await me(`/api/sessions/${n}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:L})});if(!A.ok){const O=await A.json().catch(()=>({error:"Failed to switch branch"}));u(O.error),o(!1);return}await r(n,!0),t()}catch(A){u(A instanceof Error?A.message:"Failed to switch branch"),o(!1)}},[n,r,t,u,o]),T=j.useCallback(async()=>{u(null),o(!0);try{const L={name:m.trim()};S&&(L.sourceBranch=S);const A=await me(`/api/sessions/${n}/checkout-new`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L)});if(!A.ok){const O=await A.json().catch(()=>({error:"Failed to create branch"}));u(O.error),o(!1);return}await r(n),t()}catch(L){u(L instanceof Error?L.message:"Failed to create branch"),o(!1)}},[m,S,n,r,t,u,o]);return s.jsx(vA,{isOpen:e,onClose:g,title:"Switch Branch",busy:a,loading:d,children:s.jsxs("div",{children:[C.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Branches"}),s.jsx(pt,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2",children:C.map(L=>s.jsxs("button",{onClick:()=>{L.current||E(L.name)},disabled:a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${L.current?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"}`,children:[s.jsx(eo,{className:"w-3.5 h-3.5 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:L.name}),L.current&&s.jsx("span",{className:"ml-auto text-xs text-text-muted",children:"(current)"}),!L.current&&s.jsx("span",{className:"ml-auto text-xs text-accent-primary",children:"Switch"})]},L.name))})]}),s.jsx(_A,{icon:s.jsx(eo,{}),title:"Create new branch",placeholder:"feature/my-branch",buttonLabel:"Create Branch",value:m,onChange:f,onCreate:T,canCreate:x,busy:a}),m.trim()&&s.jsxs("div",{className:"mt-2",children:[s.jsxs("label",{className:"text-xs text-text-muted mb-1 block",children:["From branch (optional — defaults to ",b||"project default",")"]}),s.jsxs("div",{className:"relative",children:[s.jsx(eo,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-muted pointer-events-none"}),s.jsx("input",{type:"text",value:S,onChange:L=>_(L.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"})]})]}),c&&s.jsx("p",{className:"mt-3 text-sm text-accent-error bg-accent-error/10 p-2 rounded",children:c})]})})}function CA({workspaceName:e,branch:t,workdir:n,showEditorLink:r,sessionId:a,projectId:o,onEditWorkspace:c,onEditBranch:u}){const[d,h]=j.useState(!1),[m,f]=j.useState(!1);return t===null?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r&&n?s.jsxs("a",{href:J9(n),className:"flex items-center gap-2 min-w-0 flex-1 no-underline group",title:"Open workspace in VSCode",children:[s.jsx(Cr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary group-hover:text-accent-primary transition-colors",children:e})]}):s.jsxs(s.Fragment,{children:[s.jsx(Cr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary",children:e})]}),s.jsx("button",{onClick:()=>{c?c():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"})]}),s.jsx("div",{className:"h-px bg-border"}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(eo,{}),s.jsx("span",{className:"truncate text-text-secondary",children:t}),s.jsx("button",{onClick:()=>{u?u():f(!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"})]})]}),s.jsx(eV,{}),!c&&s.jsx(SA,{isOpen:d,onClose:()=>h(!1),projectId:o,sessionId:a,currentWorkspace:e,currentBranch:t}),!u&&s.jsx(wA,{isOpen:m,onClose:()=>f(!1),sessionId:a})]})}function tV(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function nV(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function jv({percent:e,dangerZone:t=!1,size:n="md",className:r=""}){const a=n==="sm"?"w-12":"w-20",o=n==="sm"?"h-1":"h-1.5";return s.jsx("div",{className:`${o} bg-bg-tertiary rounded-full overflow-hidden ${a} ${r}`,children:s.jsx("div",{className:`h-full transition-all duration-300 ${nV(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function rV({dangerZone:e,size:t="md"}){return e?s.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function sV({code:e,variant:t}){const n=t==="inline"?"span":t==="block-nowrap"?"div":"pre";return s.jsx(n,{className:"language-",children:s.jsx("code",{className:"language-",children:e})})}const Ll=j.memo(function({code:t,language:n,variant:r,showLineNumbers:a=!1,startLine:o=1}){const{showSyntaxHighlighting:c}=Fs(),[u,d]=j.useState(null),h=ST(),m=j.useRef(t);if(j.useEffect(()=>{c&&(m.current=t,_T(t,n,h).then(g=>{m.current===t&&d(g)}))},[t,n,h,c]),!c||!u)return s.jsx(sV,{code:t,variant:r});if(r==="inline")return s.jsx("span",{dangerouslySetInnerHTML:{__html:u}});const f=a?"":"shiki-plain";return s.jsx("div",{className:f,style:{"--shiki-start":o},dangerouslySetInnerHTML:{__html:u}})});function kA({src:e,alt:t,isOpen:n,onClose:r}){return n?s.jsx(Et,{isOpen:n,onClose:r,title:"",size:"full",children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})})}):null}const Cf=j.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 s.jsx("div",{className:`border-l-[3px] ${r}`,children:s.jsx("div",{className:`min-w-0 py-3 ${a}`,children:s.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:n})})})}),iV=j.memo(function({oldString:t,newString:n,filePath:r}){const a=j.useMemo(()=>xm(r),[r]),o=t.length>0,c=n.length>0;return!o&&!c?s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):s.jsxs("div",{className:"rounded overflow-hidden border border-border",children:[o&&s.jsx(Cf,{type:"removed",children:s.jsx(Ll,{code:t,language:a,variant:"block",showLineNumbers:!0})}),c&&s.jsx(Cf,{type:"added",children:s.jsx(Ll,{code:n,language:a,variant:"block",showLineNumbers:!0})})]})}),aV=j.memo(function({content:t,filePath:n}){const r=j.useMemo(()=>xm(n),[n]);return s.jsx(mn,{className:"rounded border border-border max-h-[45vh]",children:s.jsx(Cf,{type:"added",children:s.jsx(Ll,{code:t,language:r,variant:"block",showLineNumbers:!0})})})}),oV=j.memo(function({regions:t,filePath:n}){const r=j.useMemo(()=>xm(n),[n]);return t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):s.jsx("div",{className:"space-y-2",children:t.map((a,o)=>s.jsx(cV,{region:a,language:r},o))})});function lV(e){const t=[];function n(r,a,o){const c=t[t.length-1];c&&c.type===r&&c.startLine+c.lines.length===a?c.lines.push(o):t.push({type:r,startLine:a,lines:[o]})}for(const r of e.beforeContext)n("context",r.lineNumber,r.content);for(const r of e.edits){const a=r.oldContent.split(`
|
|
286
|
+
`);for(let c=0;c<a.length;c++)n("removed",r.startLine+c,a[c]);const o=r.newContent.split(`
|
|
287
|
+
`);for(let c=0;c<o.length;c++)n("added",r.startLine+c,o[c])}for(const r of e.afterContext)n("context",r.lineNumber,r.content);return t}const cV=j.memo(function({region:t,language:n}){const r=lV(t);return s.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((a,o)=>s.jsx(uV,{section:a,language:n},o))})}),uV=j.memo(function({section:t,language:n}){const r=t.lines.join(`
|
|
288
|
+
`);return t.type==="context"?s.jsx("div",{children:s.jsx("div",{className:"min-w-0 py-3",children:s.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:s.jsx(Ll,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):s.jsx(Cf,{type:t.type,children:s.jsx(Ll,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function Pk(e){return e.split(`
|
|
289
|
+
`).filter(t=>!t.startsWith(`
|
|
290
|
+
[`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+\|/,"")).join(`
|
|
291
|
+
`)}const dV=j.memo(function({result:t,metadata:n,filePath:r}){const[a,o]=j.useState(!1),c=j.useMemo(()=>xm(r),[r]),u=n==null?void 0:n.mimeType,d=n==null?void 0:n.base64Data;if(u!=null&&u.startsWith("image/")&&d){const w=`data:${u};base64,${d}`;return s.jsxs(s.Fragment,{children:[s.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:()=>o(!0),children:s.jsx("img",{src:w,alt:r,className:"max-w-full max-h-[45vh] object-contain"})}),s.jsx(kA,{src:w,alt:r,isOpen:a,onClose:()=>o(!1)})]})}if(!t)return s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});const h=t;if(c==="markdown"){const w=Pk(h);return s.jsx(mn,{className:"rounded border border-border max-h-[45vh] p-2",children:s.jsx(rr,{content:w})})}const m=Pk(h),f=h.split(`
|
|
292
|
+
`)[0],g=f==null?void 0:f.match(/^(\d+)\|/),x=g?parseInt(g[1],10):1;return s.jsx(mn,{className:"rounded border border-border max-h-[45vh]",children:s.jsx(Ll,{code:m,language:c,variant:"block",showLineNumbers:!0,startLine:x})})});function hV({type:e,content:t}){const n=e==="added"?"diff-added-bg":e==="removed"?"diff-removed-bg":"bg-transparent",r=e==="added"?"+":e==="removed"?"-":" ";return s.jsxs("div",{className:`${n} px-2`,children:[s.jsx("span",{className:"select-none text-text-muted w-6 inline-block",children:r}),s.jsx("span",{className:"whitespace-pre-wrap break-words",children:t||" "})]})}function fV({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?s.jsx("div",{className:"py-8 text-center text-text-muted",children:"No changes detected."}):s.jsxs("div",{children:[s.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Changes:"}),s.jsx("div",{className:"font-mono text-xs leading-5",children:t.map((r,a)=>s.jsx(hV,{type:r.type,content:r.content},a))})]})}function Ev({isOpen:e,onClose:t,isRunning:n,onApply:r}){const a=Er(),[o,c]=j.useState(null),[u,d]=j.useState(!1),h=j.useRef(null),m=j.useCallback(()=>{d(!0);const f=Vt.send("context.applyDynamic.preview",{...a?{sessionId:a}:{}});h.current=f;const g=Vt.subscribe(x=>{if(x.id===f&&x.type==="context.preview"){const w=x.payload;c(w.diff??[]),d(!1),h.current=null,g()}});setTimeout(()=>{h.current===f&&(d(!1),h.current=null,g())},5e3)},[]);return j.useEffect(()=>{e&&(c(null),d(!0),m())},[e,m]),s.jsxs(Et,{isOpen:e,onClose:t,title:"Update system prompt",size:"lg",children:[s.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&&s.jsxs(s.Fragment,{children:[" ","Since the session is currently running, the update will be queued and applied at the start of the next turn."]})]}),u?s.jsx("div",{className:"py-8 text-center text-text-muted",children:"Loading diff..."}):o&&o.length>0?s.jsx(pt,{className:"max-h-[60vh] border border-border rounded-lg",children:s.jsx(fV,{diff:o})}):s.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."}),s.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[s.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"}),s.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 jA({variant:e="popover",onUpdateSystemPrompt:t}){const{sessionId:n,contextState:r,currentSession:a}=zl(),o=Oe(A=>A.compactContext),c=iA(),[u,d]=j.useState(!1),[h,m]=j.useState(!1);if(!r||!a)return null;const{currentTokens:f,maxTokens:g,compactionCount:x,dangerZone:w,dynamicContextChanged:C}=r,v=Math.round(f/g*100),S=a.isRunning,_=()=>{c(S),d(!1)},b=e==="sidebar",k=s.jsxs("span",{className:tV(v,w),children:[Al(f)," / ",Al(g)," (",v,"%)"]}),E=s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(jv,{percent:v,dangerZone:w,className:"flex-1"}),s.jsx(rV,{dangerZone:w}),x>0&&s.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[x,"x"]})]}),T=s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>m(!h),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:s.jsx(kE,{})}),h&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>m(!1)}),s.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:[s.jsx("button",{onClick:()=>{!S&&n&&o(n),m(!1)},disabled:S,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:S?"Cannot compact while running":"Compact context",children:s.jsx("span",{className:w?"text-accent-error":"",children:"Compact"})}),C&&s.jsx("button",{onClick:()=>{m(!1),t?t():d(!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:s.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]})]})]}),L=t?null:s.jsx(Ev,{isOpen:u,onClose:()=>d(!1),isRunning:S,onApply:_});return b?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start gap-2 mb-4",children:[s.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[s.jsx("div",{className:"text-sm",children:k}),E]}),s.jsx("div",{className:"shrink-0 pt-0.5",children:T})]}),L]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("div",{className:"flex items-center justify-between text-sm",children:k}),E]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("button",{onClick:()=>{!S&&n&&o(n)},disabled:S,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:S?"Cannot compact while running":"Compact context",children:s.jsx("span",{className:w?"text-accent-error":"",children:"Compact"})}),C&&s.jsx("button",{onClick:()=>{t?t():d(!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:s.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]}),L]})}function Bk({messages:e,workdir:t}){var _,b,k;const[n,r]=j.useState(!1),[a,o]=j.useState(!1),[c,u]=j.useState(null),d=b9(e),{branch:h}=Sv(),m=an(E=>E.version),{currentSession:f}=zl(),g=Au((f==null?void 0:f.workspace)??"")||null,x=Bt(E=>E.settings[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",w=bi(E=>E.status),C=bi(E=>E.check),[v,S]=j.useState(!1);return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx(jA,{variant:"sidebar"}),d&&s.jsxs("div",{className:"mb-4",children:[s.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:s.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[s.jsx("span",{className:"text-text-secondary",children:Ps(d.aiTime)}),s.jsx("span",{className:"w-px h-3 bg-border"}),s.jsx("span",{className:"text-text-secondary",children:Tk(d.avgPrefillSpeed)}),s.jsx("span",{children:"pp"}),s.jsx("span",{className:"w-px h-3 bg-border"}),s.jsx("span",{className:"text-text-secondary",children:Tk(d.avgGenerationSpeed)}),s.jsx("span",{children:"tg"})]})}),s.jsx(L9,{isOpen:n,onClose:()=>r(!1),stats:d})]}),s.jsx(pt,{className:"flex flex-col flex-1 px-4 -mx-4 pb-4",children:s.jsxs("div",{children:[s.jsx("button",{onClick:()=>u("criteria"),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(Sf,{entries:((_=f==null?void 0:f.metadataEntries)==null?void 0:_.criteria)??[],title:"Acceptance Criteria"})}),f&&s.jsx(dA,{entries:((b=f==null?void 0:f.metadataEntries)==null?void 0:b.criteria)??[],sessionId:f.id}),f&&(()=>{const E=["review_findings","todos"],T=f.metadataEntries??{},L=E.filter(O=>O in T),A=Object.keys(T).filter(O=>O!=="criteria"&&!E.includes(O)).sort();return[...L,...A].filter(O=>{var M;return(((M=T[O])==null?void 0:M.length)??0)>0}).map(O=>s.jsxs("div",{className:"mt-6",children:[s.jsx("button",{onClick:()=>u(O),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(Sf,{entries:T[O],title:wl(O)})}),s.jsx(cA,{entries:T[O],onClearAll:async()=>{try{await me(`/api/sessions/${f.id}/metadata/${O}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:[]})})}catch(M){console.error(`Failed to clear ${O}:`,M)}}})]},O))})()]})}),s.jsx(CA,{workspaceName:g??"original",branch:h,workdir:t,showEditorLink:x,sessionId:(f==null?void 0:f.id)??"",projectId:(f==null?void 0:f.projectId)??""}),s.jsx(pA,{workdir:t}),s.jsx(Q9,{sessionId:f==null?void 0:f.id}),m&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[s.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",s.jsxs("span",{className:"font-mono",children:["v",m]}),s.jsx("button",{onClick:()=>{S(!0),C(!0)},disabled:w==="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:s.jsx(Gf,{className:`w-3 h-3 ${w==="checking"?"animate-spin":""}`})})]}),w==="available"&&s.jsx("button",{onClick:()=>o(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"}),v&&w==="upToDate"&&s.jsx("div",{className:"mt-1",children:"Up to date"}),w==="error"&&s.jsx("div",{className:"mt-1",children:"Update check failed"})]}),s.jsx(VE,{isOpen:a,onClose:()=>o(!1),versionInfo:null}),s.jsx(uA,{isOpen:c!==null,onClose:()=>u(null),entries:((k=f==null?void 0:f.metadataEntries)==null?void 0:k[c??""])??[],sessionId:(f==null?void 0:f.id)??"",metadataKey:c??"",title:wl(c??"")})]})}function mV({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r,sessionId:a}){const o=cn(a,d=>d.session??null,d=>d.currentSession,null),{width:c,handleMouseDown:u}=eA({initialWidth:320,minWidth:240,maxWidth:600,direction:"right"});return s.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&s.jsx("div",{className:"absolute @md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),s.jsxs("div",{className:"flex h-full",children:[s.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?s.jsxs("aside",{className:"hidden @md:block shrink-0 border-l border-border bg-secondary relative",style:{width:c},children:[s.jsx(tA,{side:"left",onMouseDown:u}),s.jsx(pt,{className:"h-full p-4",children:s.jsx(Bk,{messages:r,workdir:(o==null?void 0:o.workspace)??(o==null?void 0:o.workdir)})})]}):s.jsx("aside",{className:"hidden @md:block w-0 shrink-0 overflow-hidden border-l-0"}),s.jsx("aside",{className:`
|
|
293
|
+
@md:hidden
|
|
294
|
+
bg-secondary
|
|
295
|
+
transition-all duration-300 ease-in-out
|
|
296
|
+
absolute right-0 top-0 h-full z-50
|
|
297
|
+
${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
|
|
298
|
+
`,children:s.jsx("div",{className:"h-full p-4",children:s.jsx(pt,{className:"h-full",children:s.jsx(Bk,{messages:r,workdir:(o==null?void 0:o.workspace)??(o==null?void 0:o.workdir)})})})})]})]})}function pV(){const{sessionId:e,contextState:t,currentSession:n}=zl(),r=Oe(C=>C.pendingUpdate),a=Oe(C=>C.triggerPendingUpdate),o=iA(),[c,u]=j.useState(!1),[d,h]=j.useState(!1),m=j.useRef(!1),f=j.useRef(!1);if(j.useEffect(()=>{t!=null&&t.dynamicContextChanged&&!m.current&&u(!1),m.current=(t==null?void 0:t.dynamicContextChanged)??!1},[t==null?void 0:t.dynamicContextChanged]),j.useEffect(()=>{const C=(n==null?void 0:n.isRunning)??!1;f.current&&!C&&r&&r===e&&a(),f.current=C},[n==null?void 0:n.isRunning,r,e,a]),!t||!n)return null;const{dynamicContextChanged:g}=t,x=n.isRunning,w=()=>{o(x),u(!0),h(!1)};return s.jsxs(s.Fragment,{children:[g&&!c&&s.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent-warning/10 border-b border-accent-warning/30",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 text-sm text-text-secondary",children:[s.jsx("span",{children:"System prompt has changed —"}),s.jsx("button",{onClick:()=>h(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),s.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:s.jsx(Ss,{})})]})}),s.jsx(Ev,{isOpen:d,onClose:()=>h(!1),isRunning:x,onApply:w})]})}function gV({stats:e,onClose:t}){var u;const n=dt(d=>d.defaults),r=dt(d=>d.userItems),o=[...n,...r].find(d=>d.id===e.mode),c=(o==null?void 0:o.name)??e.mode;return s.jsx(Et,{isOpen:!0,onClose:t,title:"Turn Stats",size:"md",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex items-center gap-3",children:s.jsxs("p",{className:"text-xs text-text-muted",children:[e.model," · ",c]})}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[s.jsx(Sh,{label:"Total Time",value:Ps(e.totalTime)}),s.jsx(Sh,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),s.jsx(Sh,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),s.jsx(Sh,{label:"LLM Calls",value:String(((u=e.llmCalls)==null?void 0:u.length)??1)})]}),e.llmCalls&&e.llmCalls.length>0&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-secondary mb-2",children:"LLM Calls"}),e.llmCalls.map((d,h)=>s.jsxs("div",{className:"bg-bg-tertiary/30 rounded p-3 mb-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("span",{className:"text-xs text-text-muted",children:["Call ",h+1]}),s.jsxs("span",{className:"text-xs text-text-muted",children:[d.ttft.toFixed(2),"s TTFT · ",d.completionTime.toFixed(2),"s gen"]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-text-muted",children:"Tokens:"})," ",s.jsxs("span",{className:"text-text-primary",children:[d.promptTokens," → ",d.completionTokens]})]}),s.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[d.temperature!==void 0&&s.jsx(wh,{label:"temp",value:d.temperature.toFixed(2)}),d.topP!==void 0&&s.jsx(wh,{label:"topP",value:d.topP.toFixed(2)}),d.topK!==void 0&&s.jsx(wh,{label:"topK",value:String(d.topK)}),d.maxTokens!==void 0&&s.jsx(wh,{label:"maxTok",value:String(d.maxTokens)})]})]})]},h))]})]})})}function Sh({label:e,value:t}){return s.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[s.jsx("div",{className:"text-xs text-text-muted",children:e}),s.jsx("div",{className:"text-lg font-semibold text-text-primary",children:t})]})}function wh({label:e,value:t}){return s.jsxs("span",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-primary",children:[s.jsxs("span",{className:"text-text-muted",children:[e,":"]})," ",t]})}const xV=j.memo(function({content:t,variant:n="default"}){return n==="labeled"?s.jsxs("div",{className:"text-text-muted text-sm italic feed-item",children:[s.jsx("span",{className:"text-text-thinking",children:"thinking:"}),s.jsx(mn,{horizontal:!0,className:"ml-1.5 mt-0.5",children:s.jsx(rr,{content:t})})]}):s.jsx(mn,{horizontal:!0,className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item",children:s.jsx(rr,{content:t,muted:!0})})});function EA({tool:e,className:t="w-4 h-4 text-text-muted flex-shrink-0"}){return e==="glob"||e==="grep"?s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"?s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"?s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})}):s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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 yV={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"}},$k=j.memo(function({diagnostics:t}){if(t.length===0)return null;const n=t.filter(o=>o.severity==="error"),r=t.filter(o=>o.severity==="warning"),a=t.filter(o=>o.severity==="info"||o.severity==="hint");return s.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[s.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[s.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&s.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),r.length>0&&s.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[r.length," warning",r.length!==1?"s":""]}),a.length>0&&s.jsxs("span",{className:"text-xs text-text-muted",children:[a.length," info"]})]}),s.jsx(mn,{className:"max-h-48",children:t.map((o,c)=>{const u=yV[o.severity];return s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${u.bg} border-b border-border last:border-b-0`,children:[s.jsx("span",{className:`${u.color} text-xs flex-shrink-0 w-4 text-center`,children:u.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",o.range.start.line+1,":",o.range.start.character+1]}),o.code&&s.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",o.code,"]"]})]}),s.jsx("div",{className:"text-xs text-text-primary break-words",children:o.message})]})]},c)})})]})}),bV=j.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:a,status:o,result:c,error:u,durationMs:d}){const h=j.useRef(null),[m,f]=j.useState(0),g=$u(h),{setAutoScroll:x,force_scroll_to_bottom:w,handleScrollbarGesture:C}=Bu(h,null,g);j.useEffect(()=>{o==="pending"?x(!0):(w(),x(!1))},[o,x,w]),j.useEffect(()=>{if(o!=="pending"||!r)return;const b=setInterval(()=>{f(Date.now()-r)},100);return()=>clearInterval(b)},[o,r]);const v=n/1e3,S=o==="pending"?m/1e3:(d??0)/1e3,_=o==="pending"?(a==null?void 0:a.map(b=>b.content).join(""))??"":c??"";return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[s.jsx("span",{className:"text-text-muted flex-shrink-0",children:"$"}),s.jsx("code",{className:"text-text-primary break-all",children:t})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted flex-shrink-0",children:[o==="pending"&&s.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),o==="interrupted"&&s.jsx("span",{className:"text-red-400",children:"interrupted"}),s.jsxs("span",{className:o==="pending"?"text-text-secondary":"text-text-muted",children:[S.toFixed(1),"s / ",v,"s"]})]})]}),o==="pending"&&s.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:s.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,m/n*100)}%`}})}),(_||o==="pending")&&s.jsx(pt,{ref:h,onScrollbarGesture:C,className:`text-xs bg-bg-primary p-2 rounded max-h-64 ${o==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:o==="pending"&&a?a.map((b,k)=>s.jsx("span",{className:b.stream==="stderr"?"text-accent-warning":"",children:wf(b.content)},k)):wf(_)}),o==="error"&&u&&s.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:u})]})}),Gc=j.memo(function({className:t=""}){return s.jsx("div",{className:`text-[10px] text-accent-warning ${t}`,children:"Output truncated"})});function NA(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:s.jsx(pt,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:e})})}}}const vV=j.memo(function({result:t,action:n}){const r=NA(t,"DevServerView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?_V(a):SV(a)});function _V(e){if(!e.logs)return s.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"});const t=e.logs.split(`
|
|
299
|
+
`);return s.jsxs("div",{className:"space-y-2",children:[s.jsx(mn,{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 s.jsx("div",{className:a?"text-accent-warning":"",children:a?n.slice(9):n},r)})}),e.hasMore&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",e.limit," of ",e.total," lines"]})]})}function SV(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 s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"State:"}),s.jsx("span",{className:`font-medium ${a}`,children:t})]}),n&&n!=="undefined"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"URL:"}),s.jsx("a",{href:n,className:"text-accent-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:n})]}),r&&s.jsx("div",{className:"text-accent-error bg-accent-error/10 p-2 rounded",children:r})]})}const wV=j.memo(function({result:t,action:n}){const r=NA(t,"BackgroundProcessView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?CV(a):n==="list"?kV(a):n==="status"?jV(a):n==="start"||n==="stop"?EV(a):s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"text-accent-warning",children:["Unknown action: ",n]}),s.jsx(mn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})]})});function CV(e){const t=e.lines,n=e.hasMore,r=e.totalLines;return!t||t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(mn,{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] break-words",children:t.map((a,o)=>s.jsx("div",{className:a.stream==="stderr"?"text-accent-warning":"",children:a.content},o))}),n&&r!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",t.length," of ",r," lines"]})]})}function kV(e){const t=e.processes,n=e.currentCount,r=e.maxPerSession;return!t||t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic",children:"No background processes"}):s.jsxs("div",{className:"space-y-2",children:[t.map(a=>s.jsx(TA,{process:a},a.id)),n!=null&&r!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:[n," of ",r," slots used"]})]})}function jV(e){const t=e.process,n=e.uptime;return t?s.jsxs("div",{className:"space-y-2",children:[s.jsx(TA,{process:t}),n!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Uptime: ",NV(n)]})]}):s.jsx("div",{className:"text-xs text-text-muted italic",children:"Process not found"})}function EV(e){const t=e.processId,n=e.name,r=e.pid,a=e.status,o=a==="running"?"text-accent-success":"text-text-muted";return s.jsxs("div",{className:"space-y-2 text-xs",children:[n&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"Name:"}),s.jsx("span",{className:"font-medium",children:n})]}),t&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"ID:"}),s.jsx("span",{className:"font-mono",children:t})]}),r!=null&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"PID:"}),s.jsx("span",{className:"font-mono",children:r})]}),a&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"Status:"}),s.jsx("span",{className:`font-medium ${o}`,children:a})]})]})}function TA({process:e}){const t=e.status==="running"?"text-accent-success":(e.status==="exited","text-text-muted");return s.jsxs("div",{className:"border border-border rounded p-2 space-y-1 text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"font-medium",children:e.name}),s.jsx("span",{className:`${t}`,children:e.status})]}),e.pid!=null&&s.jsxs("div",{className:"text-text-muted",children:["PID: ",s.jsx("span",{className:"font-mono",children:e.pid})]}),e.command&&s.jsx("div",{className:"text-text-muted font-mono truncate",children:e.command})]})}function NV(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 TV=j.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return s.jsx(mn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})}switch(n){case"list":return AV(r);case"switch":case"delete":return LV(r);default:return s.jsx(mn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})}});function AV(e){const t=e.workspaces??[];return t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic",children:"No workspaces found"}):s.jsxs("div",{className:"space-y-1 text-xs",children:[s.jsx("div",{className:"text-text-muted mb-1",children:"Workspaces:"}),t.map(n=>s.jsxs("div",{className:"flex items-center gap-2 font-mono",children:[s.jsx("span",{className:n.active?"text-accent-success":"text-text-muted",children:n.active?"●":"○"}),s.jsx("span",{className:n.active?"text-text-primary font-medium":"text-text-secondary",children:n.name}),n.branch&&s.jsxs("span",{className:"text-text-muted",children:["· ",n.branch]}),n.active&&s.jsx("span",{className:"text-[10px] text-accent-primary",children:"(current)"})]},n.name))]})}function Bx({label:e,value:t,mono:n}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-text-muted",children:[e,":"]}),s.jsx("span",{className:n?"font-mono text-accent-primary":"text-text-primary",children:t})]})}function LV(e){return s.jsxs("div",{className:"space-y-2 text-xs",children:[e.message&&s.jsx("div",{className:"text-text-primary",children:e.message}),e.workspace&&s.jsx(Bx,{label:"Name",value:e.workspace,mono:!0}),e.path&&s.jsx(Bx,{label:"Path",value:e.path,mono:!0}),e.branch&&s.jsx(Bx,{label:"Branch",value:e.branch,mono:!0})]})}const RV={todo:{label:"To Do",className:"bg-accent-warning/10 text-accent-warning border-accent-warning/30"},in_progress:{label:"In Progress",className:"bg-accent-primary/10 text-accent-primary border-accent-primary/30"},done:{label:"Done",className:"bg-accent-success/10 text-accent-success border-accent-success/30"}},DV=new Set(["get","create","edit","move","set_gate_value","duplicate","reorder"]),OV=j.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return s.jsx($x,{result:t})}if(n==="list")return s.jsx(mn,{className:"max-h-[60vh]",children:s.jsx(IV,{data:r})});if(n==="set_gates"){const a=r.gates;return s.jsx(mn,{className:"max-h-[60vh]",children:s.jsx(MV,{gates:Array.isArray(a)?a:[]})})}if(n==="delete"){const a=r.message;return typeof a=="string"&&a.trim()!==""?s.jsx("div",{className:"text-xs text-text-primary",children:a}):s.jsx($x,{result:t})}return DV.has(n)?s.jsx(mn,{className:"max-h-[60vh]",children:s.jsx(AA,{task:RA(r)})}):s.jsx($x,{result:t})});function $x({result:e}){return s.jsx(mn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:e})})}function IV({data:e}){const t=(e.tasks??[]).map(RA),n=e.gates??[],r=t.filter(u=>u.status==="todo"),a=t.filter(u=>u.status==="in_progress"),o=t.filter(u=>u.status==="done"),c=t.filter(u=>u.status!=="todo"&&u.status!=="in_progress"&&u.status!=="done");return s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"text-text-muted",children:["Task board · ",t.length," task",t.length===1?"":"s",n.length>0&&s.jsxs("span",{children:[" — Gates: ",n.map(u=>`${u.name} (${u.required?"required":"optional"})`).join(", ")]})]}),t.length===0?s.jsx("div",{className:"text-text-muted italic",children:"No tasks on the board"}):s.jsxs(s.Fragment,{children:[s.jsx(Ch,{title:"To Do",tasks:r}),s.jsx(Ch,{title:"In Progress",tasks:a}),s.jsx(Ch,{title:"Done",tasks:o}),s.jsx(Ch,{title:"Other",tasks:c})]})]})}function Ch({title:e,tasks:t}){return t.length===0?null:s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"text-text-muted",children:[e," · ",t.length]}),t.map(n=>s.jsx(AA,{task:n},n.id))]})}function AA({task:e}){const t=RV[e.status]??{label:e.status,className:"bg-bg-tertiary text-text-secondary border-border"};return s.jsxs("div",{className:"rounded-md border border-border bg-bg-tertiary px-2.5 py-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:`inline-flex items-center rounded border px-1.5 py-0.5 text-[10px] font-medium ${t.className}`,children:t.label}),e.runState==="running"&&s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-accent-success/40 bg-accent-success/10 px-1.5 py-0.5 text-[10px] font-medium text-accent-success",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success animate-pulse"}),"Running"]}),e.runState==="queued"&&s.jsxs("span",{className:"inline-flex items-center rounded border border-accent-warning/40 bg-accent-warning/10 px-1.5 py-0.5 text-[10px] font-medium text-accent-warning",children:["Queued · #",e.queuePosition??1]})]}),s.jsx("p",{className:"mt-1 text-sm text-text-primary leading-snug break-words whitespace-pre-wrap line-clamp-3",children:e.prompt}),s.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-text-muted",children:[e.boundSession&&s.jsxs("span",{children:["Bound: ",e.boundSession]}),e.model&&s.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-secondary border border-border",children:e.model}),e.attachments!==void 0&&e.attachments>0&&s.jsxs("span",{children:[e.attachments," attachment",e.attachments===1?"":"s"]}),e.gates.map(n=>s.jsxs("span",{className:"font-mono px-1.5 py-0.5 rounded border border-border bg-bg-secondary",children:[n.gateId,": ",n.value]},n.gateId))]})]})}function MV({gates:e}){return s.jsxs("div",{className:"space-y-1 text-xs",children:[s.jsx("div",{className:"text-text-muted mb-1",children:"Gate configuration"}),e.length===0?s.jsx("div",{className:"text-text-muted italic",children:"No gates configured"}):e.map(t=>s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"font-mono text-accent-primary shrink-0",children:t.id}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"text-text-primary",children:[t.name," ",s.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 rounded border border-border bg-bg-tertiary text-[10px]",children:t.required?"required":"optional"}),t.variant&&s.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 rounded border border-border bg-bg-tertiary text-[10px]",children:t.variant})]}),t.description&&s.jsx("div",{className:"text-text-muted",children:t.description})]})]},t.id))]})}function LA(e){return typeof e=="object"&&e!==null?e:null}function Xi(e){return typeof e=="string"?e:""}function Fk(e){return typeof e=="number"?e:void 0}function PV(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const r=LA(n);if(!r)continue;const a=Object.keys(r).find(c=>c!=="actor"&&c!=="timestamp");if(!a)continue;const o=r[a];typeof o=="string"&&t.push({gateId:a,value:o})}return t}function RA(e){const t=LA(e)??{},n=Xi(t.runState),r=Fk(t.queuePosition),a=Fk(t.attachments);return{id:Xi(t.id),prompt:Xi(t.prompt),status:Xi(t.status),...n?{runState:n}:{},...r!==void 0?{queuePosition:r}:{},...Xi(t.boundSession)?{boundSession:Xi(t.boundSession)}:{},...Xi(t.model)?{model:Xi(t.model)}:{},...a!==void 0?{attachments:a}:{},gates:PV(t.gateValues)}}function BV(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 $V({confirmation:e}){const t=Er(),n=Oe(f=>f.confirmPath),r=Oe(f=>f.switchDangerLevel),{title:a,description:o}=BV(e.reason),c=e.reason==="sensitive_file"||e.reason==="both",u=c?"border-red-500/50":"border-amber-500/50",d=c?"bg-red-500/10":"bg-amber-500/10",h=e.reason==="git_no_verify",m=()=>{t&&(r(t,"dangerous"),n(t,e.callId,!0,!1))};return s.jsxs("div",{className:`border ${u} ${d} rounded p-3 my-2`,children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(uy,{}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:`text-sm font-medium ${c?"text-red-400":"text-amber-400"}`,children:a}),s.jsx("div",{className:"text-xs text-text-muted",children:o})]})]}),s.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[s.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),s.jsx(pt,{className:"bg-bg-primary rounded p-2 mb-3 max-h-24",children:s.jsx("ul",{className:"space-y-0.5",children:e.paths.map((f,g)=>s.jsx("li",{className:`text-xs font-mono ${c?"text-red-300":"text-amber-300"} break-all`,children:f},g))})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>t&&n(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"}),s.jsx("button",{onClick:()=>t&&n(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"}),s.jsx("button",{onClick:m,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 FV(e,t){if(e==="read_file"){const r=String(t.path??""),a=t.offset,o=t.limit,c=[];return a!==void 0&&a!==1&&c.push(`offset=${a}`),o!==void 0&&c.push(`limit=${o}`),c.length>0?`${r} [${c.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??"");if(e==="project_tasks"){const r=String(t.action??""),a=t.taskId?String(t.taskId):"";let o=a?`${r}: ${a}`:r;return r==="move"&&t.to&&(o+=` → ${String(t.to)}`),r==="set_gate_value"&&t.gateId&&(o+=` (${String(t.gateId)})`),o}const n=JSON.stringify(t);return n.length>50?n.slice(0,50)+"...":n}function Hk(e,t,n){var a;const r=FV(e,t);if(e==="read_file"&&n){const o=n.format,c=n.pageCount;if(o==="pdf"&&c!=null)return`${r} (PDF, ${c}p)`;if(o==="image")return`${r} (image)`}if(e==="web_fetch"&&n){const o=n.contentType;if(o){const c=((a=o.split(";")[0])==null?void 0:a.trim())??"";if(c&&c!=="text/html")return`${r} (${c})`}}return r}function HV(e){return JSON.stringify(e,null,2)}const zk={ssh:"SSH",scp:"SCP",sftp:"SFTP",mosh:"MOSH"},zV=new Set(["-C","--close-from","-D","--chdir","-g","--group","-h","--host","-p","--prompt","-R","--chroot","-T","--command-timeout","-u","--user"]),UV=new Set(["-C","--chdir","-S","--split-string","-u","--unset"]),VV=new Set(["-p","-f","-d","-P"]);function Uk(e){return e.split(/[\\/]/).pop()??e}function WV(e){const t=[];let n=null,r=!1;for(let a=0;a<e.length;a+=1){const o=e[a];if(r){r=!1;continue}if(o==="\\"&&n!=="'"){r=!0;continue}if(o==="'"||o==='"'){n=n===o?null:n===null?o:n;continue}if(n)continue;if(o==="#"&&(a===0||/\s|[;&|(){}]/.test(e[a-1])))break;if(o!=="<"||e[a-1]==="<"||e[a+1]!=="<"||e[a+2]==="<")continue;let c=a+2;const u=e[c]==="-";for(u&&(c+=1);/\s/.test(e[c]??"");)c+=1;let d="",h=null,m=!1,f=!0;for(;c<e.length;){const g=e[c];if(!h&&/\s|[;&|(){}<>]/.test(g))break;if(g==="'"||g==='"'){f=!1,h===g?(h=null,m=!1):h===null&&(h=g),c+=1;continue}if(!h&&g==="$"&&e[c+1]==="'"){f=!1,m=!0,h="'",c+=2;continue}if(g==="\\"&&c+1<e.length){if(f=!1,m){const x=e.slice(c).match(/^\\(?:x([0-9A-Fa-f]{1,2})|([0-7]{1,3})|([abefnrtv\\'"?]))/);if(x){x[1]?d+=String.fromCharCode(Number.parseInt(x[1],16)):x[2]?d+=String.fromCharCode(Number.parseInt(x[2],8)):d+={a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
300
|
+
`,r:"\r",t:" ",v:"\v"}[x[3]]??x[3],c+=x[0].length;continue}}(h!=='"'||["$","`",'"',"\\",`
|
|
301
|
+
`].includes(e[c+1]))&&(c+=1)}d+=e[c],c+=1}d&&t.push({delimiter:d,stripTabs:u,expandable:f}),a=c}return t}function GV(e){const t=e.split(`
|
|
302
|
+
`),n=[],r=[],a=[];for(const o of t){if(a.length>0){const c=a[0],u=c.stripTabs?o.replace(/^\t+/,""):o;u===c.delimiter?a.shift():c.expandable&&r.push(u);continue}n.push(o),a.push(...WV(o))}return{command:n.join(`
|
|
303
|
+
`),expandableBodies:r}}function Vk(e,t=!0){const n=[];let r=null,a=!1,o=!1,c=!1;for(let u=0;u<e.length;u+=1){const d=e[u];if(o){(d===`
|
|
304
|
+
`||d==="\r")&&(o=!1);continue}if(a){a=!1;continue}if(d==="\\"&&r!=="'"){c=!0,a=!0;continue}if(d==="'"){c=!0,r=r==="'"?null:r===null?"'":r;continue}if(d==='"'){c=!0,r=r==='"'?null:r===null?'"':r;continue}if(r!=="'"){if(!r&&/\s|[;&|(){}]/.test(d)?c=!1:d!=="#"&&(c=!0),t&&d==="#"&&!c){o=!0;continue}if(d==="`"){const h=e.indexOf("`",u+1);h!==-1&&(n.push(e.slice(u+1,h)),u=h);continue}if(d==="$"&&e[u+1]==="("&&e[u+2]!=="("){let h=1,m=null,f=!1;for(let g=u+2;g<e.length;g+=1){const x=e[g];if(f){f=!1;continue}if(x==="\\"&&m!=="'"){f=!0;continue}if(x==="'"||x==='"'){m=m===x?null:m===null?x:m;continue}if(!m&&(x==="("&&(h+=1),x===")"&&(h-=1),h===0)){n.push(e.slice(u+2,g)),u=g;break}}}}}return n}function qV(e){const t=[];let n="",r=!1,a=null,o=!1,c=!1;const u=()=>{r&&t.push(n),n="",r=!1};for(let d=0;d<e.length;d+=1){const h=e[d];if(c){(h===`
|
|
305
|
+
`||h==="\r")&&(c=!1,t.at(-1)!==";"&&t.push(";"));continue}if(o){r=!0,n+=h,o=!1;continue}if(h==="\\"&&a!=="'"){o=!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 m=1;const f=d;for(let g=d+3;g<e.length-1;g+=1)if(e.slice(g,g+2)==="(("&&(m+=1),e.slice(g,g+2)==="))"&&(m-=1),m===0){r=!0,n+=e.slice(f,g+2),d=g+1;break}continue}if(h==="#"&&!r){c=!0;continue}if(/\s/.test(h)){u(),(h===`
|
|
306
|
+
`||h==="\r")&&t.push(";");continue}if(h===";"||h==="|"||h==="&"||h==="("||h===")"||h==="{"||h==="}"){u(),e[d+1]===h&&(d+=1),t.push(h);continue}r=!0,n+=h}return o&&(n+="\\"),u(),t}function sl(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 ts(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=Uk(e[n]??"").toLowerCase();if(r==="env"){for(let c=n+1;c<e.length;c+=1){const u=e[c];if(u==="-S"||u==="--split-string"){const h=e[c+1];return h?Ka(h,t+1):null}const d=u.match(/^--split-string=(.*)$/s);if(d)return Ka(d[1],t+1)}for(n=sl(e,n+1,UV);n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;return ts(e.slice(n),t+1)}if(r==="sudo")return n=sl(e,n+1,zV),ts(e.slice(n),t+1);if(r==="sshpass")return n=sl(e,n+1,VV),ts(e.slice(n),t+1);if(r==="nix"){const c=e[n+1];if(c==="shell"||c==="develop"){for(let u=n+2;u<e.length;u+=1)if(e[u]==="-c"||e[u]==="--command")return Ka(e.slice(u+1).join(" "),t+1);return null}if(c==="run"){for(let u=n+2;u<e.length;u+=1)if(e[u]==="--"){for(let d=n+2;d<u;d+=1){const h=e[d],m=h.indexOf("#");if(m!==-1){const f=Uk(h.slice(m+1).split("@")[0]),g=zk[f.toLowerCase()];if(g)return g}}return null}return null}return null}const a=r,o=zk[a];if(o)return o;if(a==="command"){if(e.slice(n+1).some(u=>u==="-v"||u==="-V"))return null;const c=sl(e,n+1,new Set);return ts(e.slice(c),t+1)}if(a==="setsid"||a==="nohup"){const c=sl(e,n+1,new Set);return ts(e.slice(c),t+1)}if(a==="timeout"){const c=sl(e,n+1,new Set(["-k","--kill-after","-s","--signal"]));return ts(e.slice(c+1),t+1)}if(a==="bash"||a==="sh"||a==="zsh"||a==="fish")for(let c=n+1;c<e.length;c+=1){const u=e[c];if(u!=="--"){if(/^-[^-]*n/.test(u))return null;if(/^-[^-]*c/.test(u)){const d=e[c+1]==="--"?2:1,h=e[c+d];return h?Ka(h,t+1):null}if(!u.startsWith("-"))break}}return null}function Ka(e,t=0){if(t>8)return null;const{command:n,expandableBodies:r}=GV(e),a=[...Vk(n),...r.flatMap(f=>Vk(f,!1))];for(const f of a){const g=Ka(f,t+1);if(g)return g}const o=qV(n);let c=[];const u=new Set([";","|","&","(",")","{","}"]),d=new Set(["then","do","else","elif","if","while","until"]);let h=!1,m=!1;for(const f of o){if(f==="for"||f==="select"){const g=ts(c,t);if(g)return g;c=[],h=!0;continue}if(f==="case"){const g=ts(c,t);if(g)return g;c=[],m=!0;continue}if(h){f==="do"&&(h=!1);continue}if(m&&f===")"){c=[];continue}if(u.has(f)){const g=ts(c,t);if(g)return g;c=[]}else if(d.has(f)){const g=ts(c,t);if(g)return g;c=[]}else if(f==="fi"||f==="done"||f==="esac"){const g=ts(c,t);if(g)return g;c=[],f==="esac"&&(m=!1)}else c.push(f)}return ts(c,t)}function KV(e,t){return e!=="run_command"||typeof t.command!="string"?null:Ka(t.command)}const YV=[],XV=600;function QV(e,t,n){let r=(e==null?void 0:e.length)??0;if(t)for(const o of t)r+=o.content.length;const a=n.content;return typeof a=="string"&&(r+=a.length),r}const JV={dev_server:vV,workspace:TV,project_tasks:OV,background_process:wV},ZV={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}},eW=j.memo(function({tool:t,args:n,status:r,variant:a="compact",forceCompact:o,result:c,error:u,durationMs:d,diagnostics:h,editContext:m,startedAt:f,streamingOutput:g,metadata:x,truncated:w,callId:C}){var H;const{collapseLargeToolCalls:v}=Fs(),S=!o&&(!v||r==="pending"||QV(c,g,n)<XV),[_,b]=j.useState(S),k=ZV[r],E=KV(t,n),T=Bt(B=>B.settings[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",L=t==="edit_file"?(H=m==null?void 0:m.regions[0])==null?void 0:H.startLine:t==="read_file"?(()=>{const B=c==null?void 0:c.split(`
|
|
307
|
+
`)[0],F=B==null?void 0:B.match(/^(\d+): /);return F?parseInt(F[1],10):void 0})():void 0,A=Er(),O=cn(A,B=>B.pendingPathConfirmations,B=>B.pendingPathConfirmations,YV),M=C?O.find(B=>B.callId===C||B.callId.startsWith(C+"-"))??null:null;return t==="step_done"?s.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:[s.jsx("span",{className:`${k.color} ${k.animate?"animate-pulse":""}`,children:k.icon}),s.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t})]}):a==="compact"?s.jsxs("div",{className:`flex items-center gap-1.5 text-xs rounded px-2 py-1.5 border ${E?"border-text-thinking/60 bg-text-thinking/10":"border-transparent bg-secondary"}`,children:[s.jsx(EA,{tool:t}),s.jsx("span",{className:"text-accent-primary font-medium",children:t}),s.jsx("span",{className:"text-text-muted truncate flex-1",children:Hk(t,n,x)}),s.jsx("span",{className:`${k.color} ${k.animate?"animate-pulse":""}`,children:r==="pending"?"...":"done"})]}):s.jsxs("div",{className:`border rounded overflow-hidden my-1 min-w-0 ${E?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:[s.jsxs("button",{className:`w-full flex items-center gap-1.5 p-2 text-left ${E?"bg-text-thinking/10 hover:bg-text-thinking/15":"bg-secondary hover:bg-secondary/80"}`,onClick:()=>b(!_),children:[s.jsx("span",{className:`${k.color} ${k.animate?"animate-pulse":""}`,children:k.icon}),s.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),s.jsx("span",{className:"text-text-muted text-xs flex-1 truncate",children:Hk(t,n,x)}),s.jsx("span",{className:"text-text-muted text-xs",children:_?"▼":"▶"})]}),_&&s.jsxs("div",{className:`p-2 border-t space-y-2 min-w-0 ${E?"border-text-thinking/40 bg-text-thinking/5":"border-border bg-primary"}`,children:[t==="run_command"&&s.jsx(bV,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:f,streamingOutput:g,status:r,result:c,error:u,durationMs:d}),t==="edit_file"&&r==="success"&&s.jsxs(s.Fragment,{children:[m&&m.regions.length>0?s.jsx(oV,{regions:m.regions,filePath:String(n.path??"")}):s.jsx(iV,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),h&&h.length>0&&s.jsx($k,{diagnostics:h})]}),t==="write_file"&&r==="success"&&s.jsxs(s.Fragment,{children:[s.jsx(aV,{content:String(n.content??""),filePath:String(n.path??"")}),h&&h.length>0&&s.jsx($k,{diagnostics:h})]}),t==="read_file"&&r==="success"&&s.jsx(dV,{result:c,metadata:x,filePath:String(n.path??"")}),t==="return_value"&&(()=>{const B=(g==null?void 0:g.map(K=>K.content).join(""))??"",F=r==="pending"&&B?B:String(n.content??"");return s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),s.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:s.jsx(rr,{content:F})})]})})(),t==="call_sub_agent"&&s.jsxs("div",{children:[s.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:[String(n.subAgentType??"Sub-Agent")," Prompt"]}),s.jsx(mn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(rr,{content:String(n.prompt??"")})})]}),t==="web_search"&&r==="success"&&s.jsxs("div",{children:[s.jsx(mn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(rr,{content:c??""})}),w&&s.jsx(Gc,{className:"mt-1"})]}),t==="load_skill"&&r==="success"&&s.jsxs("div",{children:[s.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:["Skill: ",String(n.skillId??"")]}),s.jsx(mn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(rr,{content:c??""})}),w&&s.jsx(Gc,{className:"mt-1"})]}),t==="web_fetch"&&r==="success"&&s.jsxs("div",{className:"space-y-2",children:[!!(x!=null&&x.url)&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[s.jsx("span",{children:"Source:"}),s.jsx("a",{href:String(x.url),className:"text-accent-primary hover:underline truncate",target:"_blank",rel:"noopener noreferrer",children:String(x.url)}),!!(x!=null&&x.contentType)&&s.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["(",String(x.contentType),")"]}),(x==null?void 0:x.pageCount)!=null&&s.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["· ",String(x.pageCount)," pages"]})]}),s.jsx(mn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(rr,{content:c??""})}),w&&s.jsx(Gc,{})]}),(()=>{const B=JV[t];return!B||r!=="success"||!c?null:s.jsx(B,{result:c,action:String(n.action??"")})})(),t==="mcp_config"&&r==="success"&&s.jsxs("div",{children:[s.jsx(mn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(rr,{content:c??""})}),w&&s.jsx(Gc,{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!=="project_tasks"&&t!=="background_process"&&t!=="mcp_config"&&t!=="step_done"&&s.jsxs(s.Fragment,{children:[Object.keys(n).length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),s.jsx(mn,{horizontal:!0,children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:HV(n)})})]}),r==="success"&&c!==void 0&&s.jsxs("div",{children:[s.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",d!==void 0&&` (${d}ms)`,":"]}),s.jsx(mn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:c||"No output"})}),w&&s.jsx(Gc,{className:"mt-1"})]})]}),(E||r==="success"&&d!==void 0&&(t==="run_command"||t==="edit_file"||t==="write_file"||t==="read_file"))&&s.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")&&s.jsxs("span",{children:["Completed in ",(d/1e3).toFixed(2),"s"]}),s.jsx("span",{className:"flex-1"}),T&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String((x==null?void 0:x.path)??n.path??"")&&s.jsx("a",{href:yA(String((x==null?void 0:x.path)??n.path),L),className:"text-accent-primary hover:underline",children:"Open in VSCode"}),E&&s.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 · ",E]})]}),r==="error"&&u&&t!=="run_command"&&s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error break-words",children:u})]}),M&&s.jsx($V,{confirmation:M})]})]})}),tW={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 nW(e,t){const n=tW[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const a=JSON.parse(t).key;if(a){const o=v9(a);return`${n} ${o}`}}catch{}return n}function rW(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 sW=j.memo(function({name:t,arguments:n}){let a=nW(t,n)+"...",o=null;if(t==="run_command"&&n){const c=rW(n);c&&(a=c,o=Ka(c))}return s.jsx("div",{className:`border rounded overflow-hidden my-1 min-w-0 animate-pulse ${o?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:s.jsxs("div",{className:`flex items-center gap-1.5 p-2 ${o?"bg-text-thinking/10":"bg-bg-tertiary"}`,children:[s.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),s.jsx(EA,{tool:t}),s.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),t==="run_command"&&n?s.jsx("code",{className:"text-text-muted text-xs flex-1 truncate",children:a}):s.jsx("span",{className:"text-text-muted text-xs flex-1",children:a})]})})}),iW={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},aW=j.memo(function({todos:t}){return Array.isArray(t)?t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic my-1",children:"No tasks"}):s.jsxs("div",{className:"my-1 rounded border border-border bg-bg-tertiary overflow-hidden",children:[s.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Tasks"})}),s.jsx("div",{children:t.map((n,r)=>{const a=iW[n.status];return s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${r>0?"border-t border-border":""}`,children:[s.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)??"○"}),s.jsx("span",{className:`text-sm leading-tight ${n.status==="completed"?"text-text-muted":"text-text-primary"}`,children:n.content})]},r)})})]}):s.jsx("div",{className:"text-xs text-accent-warning italic my-1",children:"⚠️ Invalid todos data"})});function oW(e){if(e==null)return;if(typeof e=="string"){const n=e.split(",").map(r=>r.trim()).filter(r=>r.length>0);return n.length>0?n.map(r=>({value:r,label:r})):void 0}if(!Array.isArray(e))return;const t=[];for(const n of e){if(typeof n=="string"){const r=n.trim();r.length>0&&t.push({value:r,label:r});continue}if(n!=null&&typeof n=="object"){const r=n,a=r.label,o=r.value;if(typeof a=="string"&&a.trim().length>0){const c=a.trim(),u=typeof o=="string"&&o.length>0?o:c,d=r.description,h={value:u,label:c};typeof d=="string"&&d.length>0&&(h.description=d),t.push(h)}}}return t.length>0?t:void 0}function lW({toolCall:e}){var T;const t=Er(),n=B3(t),r=Oe(L=>L.answerQuestion),[a,o]=j.useState(""),c=j.useRef(null),u=j.useRef(null),d=n.find(L=>L.callId===e.id),h=e.arguments.question??(d==null?void 0:d.question)??"",m=e.arguments.type??(d==null?void 0:d.type)??"text",f=e.arguments.options??(d==null?void 0:d.options)??void 0,g=oW(f),x=e.result!==void 0,w=d!==void 0&&!x,C=((T=e.result)==null?void 0:T.output)??"",v=C==="[user skipped]";j.useEffect(()=>{w&&Gt()&&c.current&&c.current.focus()},[w]),j.useEffect(()=>{w&&u.current&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[w]);const S=j.useCallback(()=>{!d||!t||r(t,d.callId,a)},[d,a,r,t]),_=j.useCallback(()=>{!d||!t||r(t,d.callId,"",!0)},[d,r,t]),b=j.useCallback(L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),S()),L.key==="Escape"&&!L.shiftKey&&(L.preventDefault(),_())},[S,_]),k=j.useCallback(L=>{!d||!t||r(t,d.callId,L)},[d,r,t]),E="px-3 py-1.5 text-xs font-medium rounded transition-colors";return s.jsxs("div",{ref:u,className:"my-1",children:[s.jsx("div",{className:"text-sm text-text-primary",children:h}),w&&s.jsx("div",{className:"mt-2 border border-border rounded overflow-hidden",children:s.jsx("div",{className:"p-3 bg-primary space-y-2",children:m==="confirm"?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>k("yes"),className:`${E} flex-1 bg-accent-success/20 hover:bg-accent-success/30 text-accent-success border border-accent-success/30`,children:"Yes"}),s.jsx("button",{onClick:()=>k("no"),className:`${E} flex-1 bg-accent-error/20 hover:bg-accent-error/30 text-accent-error border border-accent-error/30`,children:"No"}),s.jsx("button",{onClick:_,className:`${E} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]}):m==="choice"&&g!==void 0&&g.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex flex-col gap-1.5",children:g.map((L,A)=>s.jsxs("button",{onClick:()=>k(L.value),className:`${E} text-left w-full bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary border border-border hover:border-accent-primary/50`,children:[s.jsx("span",{className:"block font-medium",children:L.label}),L.description!==void 0&&s.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:L.description})]},A))}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("textarea",{ref:c,value:a,onChange:L=>o(L.target.value),onKeyDown:b,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}),s.jsx("button",{onClick:S,disabled:!a.trim(),className:`${E} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send"}),s.jsx("button",{onClick:_,className:`${E} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("textarea",{ref:c,value:a,onChange:L=>o(L.target.value),onKeyDown:b,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:Gt()}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:_,className:`${E} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"}),s.jsx("button",{onClick:S,disabled:!a.trim(),className:`${E} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send Answer"})]})]})})}),x&&s.jsx("div",{className:"mt-1 flex items-center gap-2",children:s.jsx("span",{className:`text-xs ${v?"text-amber-400":"text-accent-success"}`,children:v?"Skipped":`Answered: ${C}`})})]})}const Wk={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"}},cW=new Set(["get","list","schema"]),uW=j.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const r=new Map((n==null?void 0:n.map(u=>[u.id,u]))??[]),a=t.some(u=>u.name==="session_metadata"),o=t.flatMap(u=>cW.has(String(u.arguments.action))?hW(u):[dW(u,r)]),c=(()=>{if(!a)return"Acceptance Criteria";const u=new Set(t.map(d=>d.arguments.key).filter(Boolean));if(u.size===1){const d=u.values().next().value;return d?wl(d):"Session Data"}return"Session Data"})();return s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[s.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:c})}),s.jsx("div",{className:"bg-primary",children:o.map((u,d)=>s.jsx("div",{className:`flex items-start gap-2 px-2 py-1.5 ${d>0?"border-t border-border":""}`,children:u.node},u.key))})]})});function dW(e,t){return{key:e.id,node:s.jsx(fW,{tc:e,criteriaMap:t})}}function hW(e){var n,r;const t=(n=e.result)==null?void 0:n.output;if(e.result&&!e.result.success)return[{key:`${e.id}-error`,node:s.jsx("span",{className:"text-text-muted text-sm",children:e.result.error??"Read failed."})}];if(!((r=e.result)!=null&&r.success)||!t)return[{key:`${e.id}-empty`,node:s.jsx("span",{className:"text-text-muted text-sm",children:"No output."})}];if(e.arguments.action==="get")try{const a=JSON.parse(t);if(Array.isArray(a))return a.map((o,c)=>({key:`${e.id}-${c}`,node:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(rr,{content:`[${o.id}] ${o.description}`})})]})}))}catch{}if(e.arguments.action==="schema"){const a=e.arguments.key;return[{key:e.id,node:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-accent-success text-sm leading-tight flex-shrink-0",children:"✓"}),s.jsx("div",{className:"flex-1 min-w-0 text-sm",children:a?`Schema loaded for '${a}' metadata`:"Schema loaded."})]})}]}return[{key:e.id,node:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(rr,{content:t})})]})}]}function fW({tc:e,criteriaMap:t}){const n=e.arguments.action,r=e.arguments,a=e.name==="session_metadata",o=n==="remove",c=r.id,u=r.description,d=c?t.get(c):void 0,m=a?`${(n&&{add:"Added",update:"Updated",remove:"Removed",complete:"Completed",pass:"Passed",fail:"Failed"}[n])??"Managed"} item`:"Criterion updated",f=u??(d==null?void 0:d.description)??(o&&c?`[${c}]`:m),g=r.reason,x=n==="fail";return s.jsxs(s.Fragment,{children:[a?s.jsx(Ul,{status:r.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const w=n&&Wk[n]?Wk[n]:{icon:"○",color:"text-text-muted"};return s.jsx("span",{className:`${w.color} text-sm leading-tight flex-shrink-0`,children:w.icon})})(),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:o?"line-through text-text-muted":"",children:s.jsx(rr,{content:f})}),g&&s.jsxs("div",{className:`mt-1 text-sm ${x?"text-accent-error":"text-text-muted"}`,children:[s.jsx("span",{className:"text-text-muted",children:"└ "}),'"',g,'"']})]})]})}function mW(e){return e==="criterion"||e==="session_metadata"}const pW="[interrupted by user]";function gW(e){if(!e)return"pending";const t=e.output??"";return!e.success&&t.trimEnd().endsWith(pW)?"interrupted":e.success?"success":"error"}async function DA(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 xW({items:e,position:t,onClose:n}){const r=j.useRef(null),[a,o]=j.useState(-1);if(j.useEffect(()=>{t&&o(-1)},[t]),j.useEffect(()=>{var m;if(!t)return;function d(f){r.current&&!r.current.contains(f.target)&&n()}function h(f){var g;switch(f.key){case"Escape":f.preventDefault(),n();break;case"ArrowDown":f.preventDefault(),o(x=>x<e.length-1?x+1:0);break;case"ArrowUp":f.preventDefault(),o(x=>x>0?x-1:e.length-1);break;case"Enter":f.preventDefault(),(g=e[a])==null||g.onClick(),n();break}}return document.addEventListener("mousedown",d),window.addEventListener("keydown",h,!0),window.addEventListener("blur",n),(m=r.current)==null||m.focus(),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",h,!0),window.removeEventListener("blur",n)}},[t,e,a,n]),!t)return null;let c=Math.min(t.x,window.innerWidth-190),u=Math.min(t.y,window.innerHeight-100);return c=Math.max(8,c),u=Math.max(8,u),wi.createPortal(s.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:c,top:u},children:s.jsx(pt,{className:"max-h-[60vh]",onMouseLeave:()=>o(-1),children:e.map((d,h)=>s.jsxs("button",{onClick:()=>{d.onClick(),n()},onMouseEnter:()=>o(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&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:d.icon}),d.label]},h))})}),document.body)}function OA(){const[e,t]=j.useState(null);return{onContextMenu:j.useCallback((a,o)=>{var u;if(!o||(u=window.getSelection())!=null&&u.toString())return;const c=a.target instanceof Element?a.target:null;c!=null&&c.closest("a")||(a.preventDefault(),t({x:a.clientX,y:a.clientY}))},[]),contextMenu:a=>s.jsx(xW,{position:e,onClose:()=>t(null),items:a})}}function yW(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"&&mW(a.toolCall.name)?n.push(a.toolCall):(r(),t.push(a));return r(),t}function bW(e,t){if(e.segments&&e.segments.length>0)return vW(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 vW(e,t,n,r,a){const o=[],c=new Map(t.map(u=>[u.id,u]));for(const u of e)switch(u.type){case"text":o.push({type:"text",content:u.content});break;case"thinking":u.content&&u.content.trim().length>0&&o.push({type:"thinking",content:u.content});break;case"tool_call":{const d=c.get(u.toolCallId);d&&o.push({type:"tool_call",toolCall:d});break}}for(const u of n)o.push({type:"preparing_tool_call",preparing:u});return a&&r&&o.push({type:"stats",stats:r}),o}const Nv=j.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:a=!0,sessionId:o}){const c=Oe(T=>{var L,A;return(A=(L=T.currentSession)==null?void 0:L.metadataEntries)==null?void 0:A.criteria}),u=dt(T=>T.defaults),d=dt(T=>T.userItems),h=[...u,...d],m=bW(t,n),f=r?m:m.filter(T=>T.type!=="thinking"),g=yW(f),[x,w]=j.useState(!1),[C,v]=j.useState(null),[,S]=Nn(),{onContextMenu:_,contextMenu:b}=OA();if(g.length===0)return null;const k=()=>{DA(t.content)},E=async()=>{if(!o||x)return;w(!0),v(null);const T=await dE(o,t.id);w(!1),T!=null&&T.session?S(`/p/${T.session.projectId}/s/${T.session.id}`):v("Failed to fork session")};return s.jsxs("div",{className:"feed-item",onContextMenu:T=>_(T,!!o),children:[s.jsxs("div",{className:"min-w-0",children:[C&&s.jsx("p",{className:"text-xs text-accent-error mb-1 ml-0.5",children:C}),g.map((T,L)=>{switch(T.type){case"thinking":return s.jsx(xV,{content:T.content},L);case"text":return s.jsx("div",{className:"prose prose-sm prose-invert max-w-none feed-item",children:s.jsx(rr,{content:T.content,isStreaming:t.isStreaming})},L);case"preparing_tool_call":return s.jsx(sW,{name:T.preparing.name,arguments:T.preparing.arguments},`preparing-${T.preparing.index}`);case"tool_call":{const A=T.toolCall,O=A.result;if(A.name==="ask_user")return s.jsx(lW,{toolCall:A},L);if(A.name==="todo_write"){const H=A.arguments.todos,B=Array.isArray(H)?H:[];return s.jsx(aW,{todos:B},L)}const M=gW(O);return s.jsx(eW,{tool:A.name,args:A.arguments,status:M,variant:"expandable",forceCompact:!a,result:O==null?void 0:O.output,error:O==null?void 0:O.error,durationMs:O==null?void 0:O.durationMs,diagnostics:O==null?void 0:O.diagnostics,editContext:O==null?void 0:O.editContext,startedAt:A.startedAt,streamingOutput:A.streamingOutput,metadata:O==null?void 0:O.metadata,truncated:(O==null?void 0:O.truncated)??!1,callId:A.id},L)}case"criteria_group":return s.jsx(uW,{toolCalls:T.toolCalls,criteria:c},L);case"stats":{const A=T.stats;if(!A||"error"in A)return null;const O=A.model.split("/").pop()??A.model,M=oo(h,A.mode),H=h.find(G=>G.id===A.mode),B=(H==null?void 0:H.name)??A.mode,F=G=>G>=1e3?`${(G/1e3).toFixed(1)}k`:G.toString(),K=G=>G>=1e3?`${(G/1e3).toFixed(1)}k`:G.toFixed(1);return s.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted",children:[s.jsx("span",{className:"flex-1 h-px bg-border"}),s.jsx("span",{className:"text-text-secondary",children:O}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{style:{color:M},children:B}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{children:Ps(A.totalTime)}),A.toolTime>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[Ps(A.toolTime)," tools"]})]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[F(A.prefillTokens)," @ ",K(A.prefillSpeed)," pp"]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[F(A.generationTokens)," @ ",K(A.generationSpeed)," tg"]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("button",{type:"button",className:"text-text-muted hover:text-text-secondary transition-colors",title:"View detailed stats",onClick:()=>{const G=new CustomEvent("open-turn-stats",{detail:{stats:A}});window.dispatchEvent(G)},children:s.jsx(Vf,{className:"w-3 h-3"})}),s.jsx("span",{className:"flex-1 h-px bg-border"})]},L)}}}),t.partial&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[s.jsx(uy,{}),s.jsx("span",{children:"Aborted"})]}),t.completeReason==="truncated"&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-text-truncated mt-1",children:[s.jsx(uy,{}),s.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]}),b([{label:"Copy",icon:s.jsx(El,{className:"w-4 h-4"}),onClick:()=>k()},{label:"Fork session from here",icon:s.jsx(eo,{className:"w-4 h-4"}),onClick:()=>void E()}])]})});function kf(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 _W(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const SW=j.memo(function({data:t}){var a;const n=bm(),r=(t.workflowId?(a=yf(n,t.workflowId))==null?void 0:a.color:void 0)??t.workflowColor??"#8b949e";return s.jsxs("div",{"data-testid":"task-completed-card",className:"feed-item rounded p-3 border",style:{borderColor:kf(r,.3),backgroundColor:kf(r,.08)},children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(nO,{color:r}),s.jsx("span",{className:"text-sm font-medium",style:{color:r},children:t.workflowName??"Task Completed"})]}),s.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-2",children:[s.jsx(qc,{label:"Iterations",value:String(t.iterations)}),s.jsx(qc,{label:"Total time",value:Ps(t.totalTimeSeconds)}),s.jsx(qc,{label:"Tool calls",value:String(t.totalToolCalls)}),s.jsx(qc,{label:"Tokens",value:_W(t.totalTokensGenerated)}),s.jsx(qc,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function qc({label:e,value:t}){return s.jsxs("div",{className:"bg-bg-primary/50 rounded px-2 py-1",children:[s.jsx("div",{className:"text-sm text-text-muted",children:e}),s.jsx("div",{className:"text-sm text-text-primary font-medium",children:t})]})}const wW=j.memo(function({data:t}){var a;const n=bm(),r=((a=yf(n,t.workflowId))==null?void 0:a.color)??t.workflowColor??"#6b7280";return s.jsxs("div",{className:"feed-item flex items-center gap-2 px-3 py-2 rounded border",style:{borderColor:kf(r,.3),backgroundColor:kf(r,.08)},children:[s.jsx(Wf,{className:"w-3 h-3 shrink-0",color:r}),s.jsx("span",{className:"text-sm font-medium",style:{color:r},children:t.workflowName}),s.jsx("span",{className:"text-text-muted text-sm",children:"started"})]})});function CW({attachments:e,messageId:t}){const[n,r]=j.useState(null),a=Oe(m=>m.visionFallbackByMessage),o=Oe(m=>m.messages),c=j.useMemo(()=>{const m=o.findIndex(f=>f.id===t);if(m===-1)return null;for(let f=m+1;f<o.length;f++){const g=o[f];if(g&&g.role==="assistant")return g.id}return null},[o,t]),u=m=>{r(m)},d=()=>{r(null)},h=m=>{const f=`${t}-${m}`;if(a[f])return a[f];if(c){const g=`${c}-${m}`;return a[g]}return null};return e.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(m=>{const f=h(m.id);return FT(m.mimeType)?s.jsxs("div",{className:"relative inline-block",children:[s.jsxs("button",{onClick:()=>u(m.data),className:"group relative inline-block",title:(f==null?void 0:f.type)==="done"&&f.description||m.description||m.filename,disabled:(f==null?void 0:f.type)==="start",children:[s.jsx("img",{src:m.data,alt:(f==null?void 0:f.type)==="done"&&f.description||m.description||m.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(f==null?void 0:f.type)==="start"&&s.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:s.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(f==null?void 0:f.type)==="done"&&f.description&&s.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[f.description.slice(0,200),f.description.length>200?"...":""]})]},m.id):s.jsxs("div",{className:"inline-flex items-start gap-3 p-3 bg-bg-tertiary rounded-lg border border-border max-w-[300px]",children:[s.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:HT(m.filename)}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-xs text-text-primary truncate font-medium",title:m.filename,children:m.filename}),s.jsx("div",{className:"text-[10px] text-text-muted",children:xl(m.size)}),xv(m.mimeType)&&m.data&&s.jsxs("div",{className:"mt-1.5 text-[10px] text-text-muted leading-relaxed line-clamp-3 font-mono break-all",children:[m.data.slice(0,200),m.data.length>200?"...":""]})]})]},m.id)})}),n&&s.jsx(kA,{src:n,alt:"Attached image",isOpen:!0,onClose:d})]})}function kW({message:e}){const[t,n]=j.useState(!1);if(e.messageKind!=="auto-prompt")return null;const r=e.metadata,a=(r==null?void 0:r.color)??"#6b7280",o=(r==null?void 0:r.type)??"agent",c=o==="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)??""}`,task:"🗂 task"}[o]??"injected",h=o==="workflow"||o==="subagent";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[s.jsx("span",{className:"flex-1 h-px bg-border"}),s.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h?"":"cursor-pointer"}`,style:{backgroundColor:a},onClick:()=>!h&&n(!0)}),s.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:a},onClick:()=>!h&&n(!0),children:c}),s.jsx("span",{children:"·"}),s.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",onClick:()=>!h&&n(!0),children:d}),s.jsx("span",{className:"flex-1 h-px bg-border"})]}),h&&s.jsx("div",{className:"flex justify-center feed-item mb-4",children:s.jsx(pt,{horizontal:!0,className:"max-w-[75%] rounded p-3 bg-bg-tertiary/50 text-text-secondary text-sm",style:{borderLeft:`3px solid ${a}`},children:s.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:e.content})})}),s.jsx(Et,{isOpen:t,onClose:()=>n(!1),title:`${c} Prompt`,size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:a}}),s.jsx("span",{className:"text-sm text-text-primary font-medium",children:c}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",o,")"]})]}),s.jsx("div",{className:"h-full min-h-96",children:s.jsx(pt,{horizontal:!0,className:"h-full min-h-96",children:s.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})})})]})})]})}const Ky="openfox:feed-reveal",jf="openfox:autoscroll-rearm";function jW({message:e,messageId:t,sessionId:n}){const r=e.messageKind==="auto-prompt",a=e.messageKind==="command",o=e.isSystemGenerated,c=Oe(D=>D.loadSession),[,u]=Nn(),[d,h]=j.useState(!1),[m,f]=j.useState(!1),[g,x]=j.useState(!1),[w,C]=j.useState(e.content),[v,S]=j.useState(e.attachments??[]),[_,b]=j.useState(!1),[k,E]=j.useState(!1),[T,L]=j.useState(null),[A,O]=j.useState(null),M=j.useRef(null),{onContextMenu:H,contextMenu:B}=OA(),F=j.useCallback(()=>{const D=M.current;D&&(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)},[]),K=async()=>{try{await DA(e.content),f(!0),window.setTimeout(()=>f(!1),1500)}catch{}},G=async()=>{if(!n||!t||k)return;E(!0),L(null);const D=await dE(n,t);if(E(!1),D!=null&&D.session){const U=D.session.projectId;u(`/p/${U}/s/${D.session.id}`)}else L("Failed to fork session")},V=async()=>{if(!n||!t||_)return;b(!0),O(null);const D=await o1(n,t);b(!1),D?(window.dispatchEvent(new CustomEvent(jf)),c(n,!0)):O("Failed to replay")},Z=async()=>{if(!n||!t||!w.trim()||_)return;b(!0),O(null);const D=await o1(n,t,w,v);b(!1),D?(window.dispatchEvent(new CustomEvent(jf)),c(n,!0),x(!1)):O("Failed to send")},J=()=>{C(e.content),S(e.attachments??[]),x(!1),O(null)},P=`flex items-center gap-0.5 self-end transition-[visibility,opacity] focus-within:visible focus-within:opacity-100 ${d&&!g&&!_?"visible opacity-100":"invisible opacity-0"}`;return s.jsxs("div",{className:"flex justify-end items-start gap-1.5 feed-item",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onContextMenu:D=>H(D,!!n&&!!t),children:[!o&&s.jsxs("div",{className:P,children:[s.jsx("button",{onClick:()=>{K()},title:"Copy",disabled:_,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:m?s.jsx(Hs,{className:"w-3.5 h-3.5 text-accent-success"}):s.jsx(El,{className:"w-3.5 h-3.5"})}),n&&t&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{O(null),C(e.content),S(e.attachments??[]),x(!0)},title:"Edit & resend",disabled:_,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:s.jsx(_b,{className:"w-3.5 h-3.5"})}),s.jsx("button",{onClick:()=>{V()},title:"Replay",disabled:_,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:s.jsx(Gf,{className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:`max-w-[75%] ${g?"w-full":""} rounded p-2 ${o?"bg-bg-system border border-border-system":"bg-accent-primary/15 text-text-primary"}`,children:[o&&s.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:a?"Command":r?"Auto":"System"}),g?s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("textarea",{ref:D=>{M.current=D,D&&(D.style.height="auto",D.style.height=`${D.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:w,onChange:D=>{C(D.target.value),F()},onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),Z()),D.key==="Escape"&&J()},disabled:_,autoFocus:Gt()}),v.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(D=>s.jsx(yv,{attachment:D,onRemove:U=>S($=>$.filter(te=>te.id!==U))},D.id))}),A&&s.jsx("p",{className:"text-xs text-accent-error",children:A}),s.jsxs("div",{className:"flex justify-end gap-1.5",children:[s.jsx("button",{onClick:J,disabled:_,className:"px-4 py-1.5 rounded text-sm bg-bg-tertiary/50 text-text-muted hover:bg-bg-tertiary hover:text-text-primary transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Cancel"}),s.jsx("button",{onClick:()=>{Z()},disabled:_||!w.trim(),className:"px-4 py-1.5 rounded text-sm bg-accent-primary/20 text-accent-primary font-medium hover:bg-accent-primary/30 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:"Send"})]})]}):s.jsxs(s.Fragment,{children:[(A||T)&&s.jsx("p",{className:"text-xs text-accent-error mb-1",children:A??T}),s.jsx("div",{className:`whitespace-pre-wrap break-words text-sm ${o?"text-text-system":""}`,children:e.content}),e.attachments&&e.attachments.length>0&&s.jsx(CW,{attachments:e.attachments,messageId:e.id})]})]}),B([{label:"Copy",icon:s.jsx(El,{className:"w-4 h-4"}),onClick:()=>void K()},{label:"Fork session from here",icon:s.jsx(eo,{className:"w-4 h-4"}),onClick:()=>void G()}])]})}const IA=j.memo(function({message:t,isLastAssistantMessage:n=!1,messageId:r,sessionId:a}){const o=t.role==="user",c=t.role==="assistant",u=t.role==="system",d=t.role==="tool";if(c)return s.jsx(Nv,{message:t,showStats:n});if(u&&t.isCompacted)return s.jsxs("div",{className:"feed-item bg-bg-tertiary/50 border border-border rounded p-2",children:[s.jsx("div",{className:"text-text-muted text-xs mb-0.5",children:"[Compacted]"}),s.jsx("div",{className:"text-text-secondary text-xs whitespace-pre-wrap",children:t.content.replace(`[COMPACTED HISTORY]
|
|
308
|
+
`,"")})]});if(d)return s.jsxs("div",{className:"feed-item bg-bg-tertiary/30 border-l-2 border-accent-primary rounded-r p-2",children:[s.jsxs("div",{className:"text-accent-primary text-xs mb-0.5",children:["Tool: ",t.toolName]}),s.jsx(mn,{horizontal:!0,className:"max-h-32",children:s.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 s.jsx(wW,{data:h})}catch{}if(t.messageKind==="task-completed")try{const h=JSON.parse(t.content);return s.jsx(SW,{data:h})}catch{}return t.messageKind==="context-reset"?s.jsxs("div",{className:"flex items-center gap-4 mb-6 text-text-muted text-xs uppercase tracking-wide",children:[s.jsx("div",{className:"flex-1 border-t border-border"}),s.jsx("span",{children:t.content}),s.jsx("div",{className:"flex-1 border-t border-border"})]}):t.messageKind==="auto-prompt"&&t.isSystemGenerated?s.jsx(kW,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?s.jsx("div",{className:"flex justify-end feed-item",children:s.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-bg-system border border-border-system",children:[s.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:"System"}),s.jsx("div",{className:"whitespace-pre-wrap break-words text-sm text-text-system italic",children:t.content})]})}):o?s.jsx(jW,{message:t,messageId:r,sessionId:a}):s.jsx("div",{className:"flex justify-start feed-item",children:s.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:s.jsx(rr,{content:t.content})})})}),EW={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function NW(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function Gk(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function TW({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:r,dangerZone:a}=e,o=Math.round(t/n*100);return s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[s.jsxs("span",{className:Gk(o,a),children:[Al(t),"/",Al(n)]}),s.jsxs("span",{className:Gk(o,a),children:["(",o,"%)"]}),s.jsx(jv,{percent:o,dangerZone:a,size:"sm"}),a&&s.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),r>0&&s.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[r,"x"]})]})}const AW=j.memo(function({messages:t,subAgentType:n,subAgentId:r,isStreaming:a}){const o=j.useRef(null),c=j.useRef(null),[u,d]=j.useState(!1),h=dt(O=>O.defaults),m=dt(O=>O.userItems),f=[...h,...m],g=Oe(O=>O.subAgentContextStates[r]),{showThinking:x,showVerboseToolOutput:w}=Fs(),C=$u(c),{isAutoScrollActive:v,setAutoScroll:S,handleScrollbarGesture:_}=Bu(c,null,C),b=j.useCallback(()=>{const O=!u;d(O),O&&setTimeout(()=>{var M;(M=o.current)==null||M.scrollIntoView({block:"start",behavior:"smooth"})},220)},[u]),k=f.find(O=>O.id===n),E=(k==null?void 0:k.name)??EW[n]??n,T=oo(f,n),L=NW(T),A=t.filter(O=>O.role!=="tool");return s.jsxs("div",{ref:o,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[s.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:L,children:[s.jsx("span",{className:"text-xs font-medium",children:E}),s.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:g&&s.jsx(TW,{contextState:g})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5",onClick:()=>S(!v),children:[s.jsx("span",{className:`w-1 h-1 rounded-full ${v?"bg-accent-success":"border border-text-muted"}`}),"live"]}),s.jsxs("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary",onClick:b,children:[u?"▼":"▶"," Expand"]})]})]}),s.jsx(pt,{ref:c,className:`${u?"max-h-[calc(100vh-10rem)]":"max-h-80"} p-2 transition-[max-height] duration-200`,onScrollbarGesture:_,children:A.map(O=>O.role==="assistant"?s.jsx(Nv,{message:O,showStats:!0,showThinking:x,showVerboseToolOutput:w},O.id):s.jsx(IA,{message:O,isLastAssistantMessage:!1},O.id))})]})}),LW={contentVisibility:"auto",containIntrinsicSize:"auto 200px"},RW={contentVisibility:"auto",containIntrinsicSize:"160px",minHeight:"160px"},kh=30,Fx=20,DW=10,OW=5;function jh(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 MA=j.memo(function({displayItems:t,highlightedMessageId:n=null,sessionId:r,scrollContainerRef:a,showThinking:o=!0,showVerboseToolOutput:c=!0,showStats:u=!0,showAgentDefinitions:d=!0,showWorkflowBars:h=!0}){const m=t.length,{feedVirtualization:f}=Fs(),[g,x]=j.useState(()=>Math.max(0,m-kh)),w=j.useRef(null),C=j.useRef(t.length),v=j.useRef(!1),S=f?g:0,_=f?LW:void 0;j.useEffect(()=>{f&&(x(Math.max(0,t.length-kh)),v.current=!1)},[r]),j.useEffect(()=>{const E=C.current;C.current=t.length,f&&t.length-E>=OW&&!v.current&&x(Math.max(0,t.length-kh))},[t.length,f]),j.useEffect(()=>{f&&g>0&&g>=t.length&&x(Math.max(0,t.length-kh))},[t.length,g,f]),j.useEffect(()=>{if(!f||g<=0||typeof IntersectionObserver>"u")return;const E=w.current;if(!E)return;const T=new IntersectionObserver(L=>{L.some(A=>A.isIntersecting)&&x(A=>Math.max(0,A-Fx))},{rootMargin:"0px 0px 300px 0px"});return T.observe(E),()=>T.disconnect()},[g,f]);const b=j.useRef(g);b.current=g,j.useEffect(()=>{var A,O;if(!f)return;const E=a==null?void 0:a.current;if(!E)return;const T=(O=(A=E.osInstance)==null?void 0:A.call(E))==null?void 0:O.elements().viewport;if(!T)return;const L=()=>{if(T.scrollTop>4){v.current=!0;return}b.current>0&&x(M=>Math.max(0,M-Fx))};return T.addEventListener("scroll",L,{passive:!0}),()=>T.removeEventListener("scroll",L)},[a,f]),j.useEffect(()=>{var L,A;if(!f||g<=0||!v.current)return;const E=a==null?void 0:a.current,T=(A=(L=E==null?void 0:E.osInstance)==null?void 0:L.call(E))==null?void 0:A.elements().viewport;T&&T.scrollTop<=4&&x(O=>Math.max(0,O-Fx))},[g,a,f]),j.useEffect(()=>{if(!f)return;const E=T=>{var A;const L=(A=T.detail)==null?void 0:A.index;typeof L=="number"&&x(O=>Math.min(O,Math.max(0,L-DW)))};return window.addEventListener(Ky,E),()=>window.removeEventListener(Ky,E)},[f]);const k=t.slice(S);return s.jsxs(s.Fragment,{children:[S>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-xs text-text-muted","data-testid":"feed-unmounted-hint",children:["Scroll up to load ",S," older item",S!==1?"s":""]}),Array.from({length:S},(E,T)=>s.jsx("div",{"data-item-index":T,"data-placeholder":!0,style:RW},`ph-${T}`)),s.jsx("div",{ref:w,"data-testid":"feed-sentinel",style:{height:1}})]}),k.map((E,T)=>{const L=S+T;if(E.type==="context-divider")return s.jsxs("div",{"data-item-index":L,className:"flex items-center gap-2 feed-item px-2 @md:px-4",children:[s.jsx("div",{className:"flex-1 border-t border-border"}),s.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),s.jsx("div",{className:"flex-1 border-t border-border"})]},jh(E));if(E.type==="subagent"){const H=E.messages.some(B=>B.isStreaming);return s.jsx("div",{"data-item-index":L,className:"px-2 @md:px-4",style:_,children:s.jsx(AW,{messages:E.messages,subAgentType:E.subAgentType,subAgentId:E.subAgentId,isStreaming:H})},jh(E))}const A=E.message;if(A.role==="assistant")return s.jsx("div",{"data-item-index":L,className:"px-2 @md:px-4",style:_,children:s.jsx(Nv,{message:A,showStats:u,showThinking:o,showVerboseToolOutput:c,sessionId:r??void 0})},jh(E));const O=!d&&A.messageKind==="auto-prompt",M=!h&&(A.messageKind==="workflow-started"||A.messageKind==="task-completed");return O||M?null:s.jsx("div",{"data-item-index":L,className:"px-2 @md:px-4",style:_,children:s.jsx("div",{"data-message-id":A.id,className:n===A.id?"rounded animate-highlight-fade":void 0,children:s.jsx(IA,{message:A,messageId:A.id,sessionId:r??void 0,isLastAssistantMessage:!1})})},jh(E))})]})});function _m(e,t,n=!0){j.useEffect(()=>{if(!n)return;const r=a=>{var o;(o=e.current)!=null&&o.contains(a.target)||t()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t,n])}const Hx=[];function IW({retry:e}){const[t]=j.useState(Date.now()),[n,r]=j.useState(Date.now());j.useEffect(()=>{const c=setInterval(()=>r(Date.now()),250);return()=>clearInterval(c)},[]);const a=Math.max(0,Math.ceil((e.retryInMs-(n-t))/1e3)),o=a>0?` — next try in ${a}s…`:"…";return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-full bg-bg-tertiary/60 border border-border text-xs text-text-secondary",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-primary animate-pulse"}),s.jsxs("span",{children:["LLM call failed — retrying “",e.stepName,"” (attempt ",e.attempt,")",o]})]})}const MW=j.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r,onLaunchWorkflow:a,onScrollToTop:o,hiddenCount:c=0,onScrollbarGesture:u,emptyState:d}){const h=Er(),m=cn(h,Q=>{var ne,re;return((re=(ne=Q.session)==null?void 0:ne.metadataEntries)==null?void 0:re.criteria)??Hx},Q=>{var ne,re;return((re=(ne=Q.currentSession)==null?void 0:ne.metadataEntries)==null?void 0:re.criteria)??Hx},Hx),f=cn(h,Q=>{var ne;return((ne=Q.session)==null?void 0:ne.id)??null},Q=>{var ne;return((ne=Q.currentSession)==null?void 0:ne.id)??null},null),g=cn(h,Q=>{var ne;return((ne=Q.session)==null?void 0:ne.phase)??null},Q=>{var ne;return((ne=Q.currentSession)==null?void 0:ne.phase)??null},null),x=cn(h,Q=>Q.error??null,Q=>Q.error,null),w=Oe(Q=>Q.clearError),C=zf(h),v=cn(h,Q=>Q.activeWorkflowExecution??null,Q=>Q.activeWorkflowExecution,null),S=Oe(Q=>Q.continueWorkflow),_=Oe(Q=>Q.retryWorkflowStep),b=Oe(Q=>Q.workflowRetry),{showThinking:k,showVerboseToolOutput:E,showStats:T,showAgentDefinitions:L,showWorkflowBars:A}=Fs(),O=bm(),M=m.some(Q=>Q.status==="pending"),H=g==="done",B=t.some(Q=>Q.type==="message"&&Q.message.role==="assistant"),F=(v==null?void 0:v.status)==="running"||(v==null?void 0:v.status)==="waiting",K=M&&!C&&B&&!H&&!F,G=(v==null?void 0:v.status)==="waiting"&&!C,V=cn(h,Q=>{var ne;return((ne=Q.session)==null?void 0:ne.projectId)??void 0},Q=>{var ne;return(ne=Q.currentSession)==null?void 0:ne.projectId},void 0),[Z,J]=j.useState(!1),[z,P]=j.useState(!1),[D,U]=j.useState(!1),$=$u(n);j.useLayoutEffect(()=>{const Q=$();Q&&P(Q.scrollHeight>Q.clientHeight+1)},[$,t]),j.useEffect(()=>{const Q=$();if(!Q)return;const ne=()=>U(Q.scrollTop>4);return ne(),Q.addEventListener("scroll",ne,{passive:!0}),()=>Q.removeEventListener("scroll",ne)},[$]);const te=()=>{if(!V||!f)return;J(!1),window.open(`/p/${V}/s/${f}/readonly`,"_blank")||J(!0)},[q,X]=j.useState(!1),Y=j.useCallback(Q=>{q||!h||(X(!0),S(h,Q),setTimeout(()=>X(!1),5e3))},[q,S,h]),I=j.useCallback(()=>{var Q;o==null||o(),(Q=$())==null||Q.scrollTo({top:0,behavior:"smooth"})},[$,o]);return s.jsxs("div",{className:"relative flex-1 min-w-0 group",children:[s.jsx(pt,{ref:n,"data-testid":"chat-scroll-container",className:"absolute inset-0 bg-primary",onScrollbarGesture:u,children:s.jsxs("div",{className:"flex min-h-full flex-col",children:[s.jsxs("div",{className:"pt-4",children:[c>0&&s.jsxs("div",{className:"px-2 @md:px-4 pb-2 space-y-1",children:[s.jsxs("button",{onClick:te,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:[c," older item",c!==1?"s":""," hidden — View full history"]}),Z&&s.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Popup blocked."," ",s.jsx("a",{href:V&&f?`/p/${V}/s/${f}/readonly`:"#",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-text-primary",children:"Open manually"})]})]}),s.jsx(MA,{displayItems:t,highlightedMessageId:r,sessionId:f,scrollContainerRef:n,showThinking:k,showVerboseToolOutput:E,showStats:T,showAgentDefinitions:L,showWorkflowBars:A})]}),t.length===0&&d&&s.jsx("div",{className:"flex flex-1 items-center justify-center px-2 @md:px-4 py-4",children:d}),s.jsxs("div",{className:"px-2 @md:px-4 pb-4",children:[b&&C&&s.jsx("div",{className:"flex justify-center feed-item","data-testid":"workflow-retry-indicator",children:s.jsx(IW,{retry:b},b.attempt)}),x&&s.jsx("div",{className:"feed-item bg-text-tool-error/10 border border-text-tool-error/50 rounded p-2",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-text-tool-error text-sm font-medium",children:x.code}),s.jsx("div",{className:"text-text-tool-error/80 text-xs mt-0.5",children:x.message})]}),s.jsx(Pu,{onClick:w,className:"text-text-tool-error hover:text-text-tool-error/80 p-0.5",size:"sm"})]})}),(v==null?void 0:v.status)==="blocked"&&v.currentStepId&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:s.jsx("button",{onClick:()=>f&&_(f),disabled:C,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:C?"⏳ Resuming...":"↻ Retry step"})}),G&&v&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:(v.pendingChoices&&v.pendingChoices.length>0?v.pendingChoices:[{id:void 0,label:`▶ Continue ${v.workflowName} (${v.currentStepName??"..."})`,goto:"",nextStepName:void 0}]).map(Q=>s.jsx("button",{onClick:()=>Y(Q.id),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...":Q.id==="continue"?`▶ Continue ${v.workflowName} (${Q.nextStepName??v.currentStepName??"..."})`:Q.label},Q.id??"continue"))}),K&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:O.map(Q=>{const ne=Q.color??"#3b82f6",re=parseInt(ne.slice(1,3),16),ie=parseInt(ne.slice(3,5),16),pe=parseInt(ne.slice(5,7),16),ye=`rgba(${re},${ie},${pe},0.12)`,Ie=`rgba(${re},${ie},${pe},0.22)`,$e=`rgba(${re},${ie},${pe},0.25)`;return s.jsx(PW,{workflowName:Q.name,scope:Q.scope,color:ne,bg:ye,bgHover:Ie,border:$e,subGroups:Q.subGroups,onLaunch:Se=>a(Q.id,Se,void 0,Q.scope)},`${Q.id}-${Q.scope}`)})})]})]})}),z&&D&&s.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:s.jsxs("button",{type:"button",onClick:I,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:[s.jsx(vb,{className:"w-3 h-3"}),"scroll to top"]})})]})});function PW({workflowName:e,scope:t,color:n,bg:r,bgHover:a,border:o,subGroups:c,onLaunch:u}){const[d,h]=j.useState(!1),m=j.useRef(null);_m(m,()=>h(!1),d);const f=c&&c.length>0;return s.jsxs("div",{className:"relative flex",children:[s.jsxs("button",{onClick:()=>u(),"data-testid":"workflow-run-button",className:`px-4 py-1.5 text-sm font-medium transition-colors ${f?"rounded-l":"rounded"}`,style:{backgroundColor:r,color:n,border:`1px solid ${o}`,...f?{borderRight:"none"}:{}},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=a},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=r},children:["▶ ",e," ",s.jsx("span",{className:"text-[10px] font-normal opacity-70 whitespace-nowrap",children:vv[t]})]}),f&&s.jsxs("div",{ref:m,className:"relative flex",children:[s.jsx("button",{onClick:()=>h(!d),className:"px-2.5 py-1.5 rounded-r text-sm font-medium transition-colors flex items-center",style:{backgroundColor:r,color:n,border:`1px solid ${o}`},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=a},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=r},children:"⋮"}),d&&s.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:[s.jsx("button",{onClick:()=>{u(),h(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Full workflow"}),s.jsx("div",{className:"border-t border-border/50"}),c.map(g=>s.jsx("button",{onClick:()=>{u(g),h(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:g},g))]})]})]})}function BW(){const e=Oe(r=>r.connectionStatus),t=Oe(r=>r.reconnect);if(e==="connected")return null;const n=e==="reconnecting";return s.jsxs("div",{className:`
|
|
309
|
+
flex items-center justify-between px-4 py-2
|
|
310
|
+
text-sm font-medium
|
|
311
|
+
${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"}
|
|
312
|
+
`,children:[s.jsx("div",{className:"flex items-center gap-2",children:n?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"150ms"}}),s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"300ms"}})]}),s.jsx("span",{children:"Reconnecting to server..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(sO,{}),s.jsx("span",{children:"Connection lost"})]})}),s.jsx("button",{onClick:()=>t(),disabled:n,className:`
|
|
313
|
+
px-3 py-1 rounded text-xs font-medium
|
|
314
|
+
transition-colors
|
|
315
|
+
${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"}
|
|
316
|
+
`,children:n?"Reconnecting...":"Reconnect"})]})}function $W(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function FW({onClick:e}){return s.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:s.jsx(wb,{})})}function PA({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){const a=fn(he=>he.defaults),o=fn(he=>he.userItems),c=fn(he=>he.projectItems),u=fn(he=>he.loading),d=fn(he=>he.fetchCommands),h=fn(he=>he.fetchCommand),m=fn(he=>he.fetchDefaultContent),f=fn(he=>he.createCommand),g=fn(he=>he.updateCommand),x=fn(he=>he.deleteCommand),[w,C]=j.useState(null),[v,S]=j.useState(null),{view:_,editingId:b,formError:k,saving:E,formData:T,setView:L,setEditingId:A,setFormError:O,setFormData:M,setSaving:H}=IE(),{requestDelete:B,clearConfirm:F,isConfirming:K}=Tu(),G=j.useRef(!1),V=dt(he=>he.defaults),Z=dt(he=>he.userItems),J=dt(he=>he.fetchAgents),P=[...V,...Z].filter(he=>!he.subagent),D=j.useRef(d),U=j.useRef(J),$=j.useRef(h),te=j.useRef(m),q=j.useRef(r),X=j.useRef(n),Y=j.useRef(L),I=j.useRef(A),Q=j.useRef(O),ne=j.useRef(F);j.useEffect(()=>{D.current=d,U.current=J,$.current=h,te.current=m,q.current=r,X.current=n,Y.current=L,I.current=A,Q.current=O,ne.current=F}),j.useEffect(()=>{if(e)if(D.current(q.current),U.current(q.current),G.current||(ne.current(),G.current=!0),X.current){const he=a.some(ae=>ae.id===X.current);Y.current("edit"),I.current(X.current),Q.current(""),he?te.current(X.current).then(ae=>{ae&&M({name:ae.metadata.name+" (copy)",id:`${X.current}-copy-${Date.now()}`,prompt:ae.prompt,agentMode:ae.metadata.agentMode??"",isDefault:!0,destination:"user"})}):$.current(X.current,q.current).then(ae=>{ae&&M({name:ae.metadata.name,id:ae.metadata.id,prompt:ae.prompt,agentMode:ae.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else Y.current("list"),I.current(null);else G.current=!1},[e]);const re=async he=>{C(he);const ae=await m(he);S((ae==null?void 0:ae.prompt)??null)},ie=async he=>{if(a.some(Pe=>Pe.id===he)){const Pe=await m(he);Pe&&(A(null),M({name:`${Pe.metadata.name} (copy)`,id:`${he}-copy-${Date.now()}`,prompt:Pe.prompt,agentMode:Pe.metadata.agentMode??"",isDefault:!0,destination:"user"}),O(""),L("edit"))}else{const Pe=await h(he,r);Pe&&(A(null),M({name:`${Pe.metadata.name} (copy)`,id:`${he}-copy-${Date.now()}`,prompt:Pe.prompt,agentMode:Pe.metadata.agentMode??"",isDefault:!1,destination:"user"}),O(""),L("edit"))}},pe=()=>{M({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),A(null),L("edit")},ye=async he=>{const ae=await h(he,r);ae&&(A(he),M({name:ae.metadata.name,id:ae.metadata.id,prompt:ae.prompt,agentMode:ae.metadata.agentMode??"",isDefault:!1,destination:"user"}),O(""),L("edit"))},Ie=async he=>{await x(he,r),F()},$e=async()=>{const he=b??T.id;if(!he||!T.name||!T.prompt){O("Name and message are required.");return}H(!0),O("");const ae={metadata:{id:he,name:T.name,...T.agentMode?{agentMode:T.agentMode}:{}},prompt:T.prompt},Pe=b?await g(b,ae,r):await f(ae,T.destination,r);if(H(!1),!Pe.success){O(Pe.error??"Failed to save command.");return}n?t():L("list")},Se=()=>{n?t():(L("list"),C(null),S(null))},Ge=he=>{M(ae=>({...ae,name:he})),(!b||T.isDefault)&&M(ae=>({...ae,id:$W(he)}))},Je=()=>{C(null),S(null),L("list")},_e=()=>{w&&(C(null),L("edit"),A(w),m(w).then(he=>{he&&M({name:`${he.metadata.name} (copy)`,id:`${w}-copy-${Date.now()}`,prompt:he.prompt,agentMode:he.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(w){const he=a.find(ae=>ae.id===w);return s.jsx(Et,{isOpen:e,onClose:Je,title:`Default: ${(he==null?void 0:he.name)??w}`,size:"xl",children:s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[s.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),s.jsx("span",{className:"font-mono",children:w})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),s.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:he==null?void 0:he.name})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Agent Mode"}),s.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-muted",children:(he==null?void 0:he.agentMode)||"None"})]})]}),s.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),s.jsx("textarea",{value:v??"",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"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[s.jsx(ot,{variant:"secondary",onClick:Je,children:"Close"}),s.jsx(ot,{variant:"primary",onClick:_e,children:"Duplicate & Customize"})]})]})})}if(_==="edit")return s.jsx(Et,{isOpen:e,onClose:Se,title:b?"Edit Command":"New Command",size:"xl",footer:s.jsx(AE,{onCancel:Se,onSave:$e,saving:E,saveDisabled:!T.name||!T.prompt}),children:s.jsxs("div",{className:"flex flex-col h-full",children:[k&&s.jsx(_l,{message:k}),s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsx(OE,{name:T.name,id:T.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!b&&!T.isDefault,onNameChange:Ge,onIdChange:he=>M(ae=>({...ae,id:he}))}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",s.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),s.jsxs("select",{value:T.agentMode,onChange:he=>M(ae=>({...ae,agentMode:he.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:[s.jsx("option",{value:"",children:"None (keep current mode)"}),P.map(he=>s.jsx("option",{value:he.id,children:he.name},he.id))]})]}),!b&&s.jsx(Xf,{value:T.destination,onChange:he=>M(ae=>({...ae,destination:he}))})]}),s.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),s.jsx("textarea",{value:T.prompt,onChange:he=>M(ae=>({...ae,prompt:he.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 ge=he=>he.map(ae=>s.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[s.jsx("div",{className:"min-w-0 flex-1 mr-3",children:s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"text-text-primary text-sm font-medium",children:ae.name})})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(vi,{onClick:()=>ye(ae.id)}),s.jsx(xu,{onClick:()=>ie(ae.id)}),K(ae.id,"delete")?s.jsx(Jh,{onConfirm:()=>Ie(ae.id),onCancel:F}):s.jsx(Zh,{onClick:()=>B(ae.id)})]})]},ae.id));return s.jsxs(Et,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[s.jsx(DE,{description:"Commands are pre-defined messages you can send with a single click.",onNew:pe}),s.jsxs(Tb,{loading:u,hasItems:a.length>0||o.length>0||c.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[a.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),s.jsx("div",{className:"space-y-2",children:a.map(he=>s.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[s.jsx("div",{className:"min-w-0 flex-1 mr-3",children:s.jsx("span",{className:"text-text-primary text-sm font-medium",children:he.name})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(FW,{onClick:()=>re(he.id)}),s.jsx(xu,{onClick:()=>ie(he.id)})]})]},he.id))})]}),o.length>0&&s.jsx(RE,{children:ge(o)}),c.length>0&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),s.jsx("div",{className:"space-y-2",children:ge(c)})]})]})]})}function HW({title:e,defaultOpen:t=!1,children:n,className:r=""}){return s.jsxs("details",{className:`group ${r}`,open:t,children:[s.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:[s.jsx(gn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),e]}),s.jsx("div",{className:"mt-2 space-y-2",children:n})]})}const $a=150,ui=54,Eh=80,ds=30,il=70,qk=100,Fa=50,Nh=50,Kk=4,BA={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},$A=[{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)"}],zW=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"},{value:"user",label:"User (pause)"}];function Tv(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 UW(e,t,n,r){const a=Nh+Fa+$a+qk+$a+Fa+Nh,o=a/2,c=Nh+Fa+$a/2,u=Nh+Fa+$a+qk+$a/2,d=[],h=[],m=new Map,f=e.filter(G=>G.type==="agent"||G.type==="shell"||G.type==="user"),g=e.filter(G=>G.type==="sub_agent"),x=g.length>0,w=x?c:o,C=f.length>0?u:o,v=Fa+ds/2;d.push({id:"$start",type:"terminal",label:"Start",cx:w,cy:v,w:Eh,h:ds}),m.set("$start",{cx:w,cy:v,w:Eh,h:ds});const S=G=>{d.push({id:"$done",type:"terminal",label:"Done",cx:w,cy:G,w:Eh,h:ds}),m.set("$done",{cx:w,cy:G,w:Eh,h:ds})};if(e.length===0){const G=v+ds/2+il*2+ds/2;return S(G),{nodes:d,edges:h,width:a,height:G+ds/2+Fa,posMap:m}}const _=v+ds/2+il,b=(G,V)=>{G.forEach((Z,J)=>{const z=_+J*(ui+il)+ui/2,{name:P,color:D}=Tv(Z,r);d.push({id:Z.id,type:"step",label:P,color:D,cx:V,cy:z,w:$a,h:ui}),m.set(Z.id,{cx:V,cy:z,w:$a,h:ui})})};b(f,w),b(g,C);const k=f.length>0?_+(f.length-1)*(ui+il)+ui/2:v,E=x?_+(g.length-1)*(ui+il)+ui/2:v,T=Math.max(k,E)+ui/2+il+ds/2;S(T);const L=[];t&&m.has(t)&&L.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let A=0;for(const G of e)G.transitions.forEach((V,Z)=>{var $;if(!V.goto||!m.has(V.goto))return;const J=m.get(G.id),z=m.get(V.goto),P=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(","))??"?"}]`:BA[V.when.type]??V.when.type,D=G.id===V.goto;let U;D?U="back":z.cy>J.cy+1?U="down":z.cy<J.cy-1?U="back":U="same",L.push({from:G.id,to:V.goto,label:P,edgeKey:`${G.id}:${Z}`,direction:U,backEdgeIndex:U==="back"?A++:0})});const O=new Map,M=new Map,H=new Map,B=new Map;for(const G of L)G.direction==="down"&&(O.set(G.from,(O.get(G.from)??0)+1),M.set(G.to,(M.get(G.to)??0)+1));const F=new Map,K=new Map;for(const G of L){if(G.direction!=="same")continue;const V=[G.from,G.to].sort().join("|");F.set(V,(F.get(V)??0)+1)}for(const G of L){if(G.direction==="back"||G.direction==="same"){let U=0;if(G.direction==="same"){const $=[G.from,G.to].sort().join("|");U=K.get($)??0,K.set($,U+1)}h.push({...G,fromPort:0,toPort:0,sameEdgeIndex:U});continue}const V=O.get(G.from)??1,Z=M.get(G.to)??1,J=H.get(G.from)??0,z=B.get(G.to)??0;H.set(G.from,J+1),B.set(G.to,z+1);const P=V===1?0:-.6+1.2*J/(V-1),D=Z===1?0:-.6+1.2*z/(Z-1);h.push({...G,fromPort:P,toPort:D,sameEdgeIndex:0})}return{nodes:d,edges:h,width:a,height:T+ds/2+Fa,posMap:m}}function VW({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:a,agentTypes:o,isReadOnly:c,onSelectNode:u,onSelectEdge:d,onRemoveStep:h,onCreateTransition:m,onReconnectTo:f,onReconnectFrom:g,onDeleteTransition:x}){const w=j.useRef(null),C=j.useRef(!1),[v,S]=j.useState(null),[_,b]=j.useState(null),[k,E]=j.useState(null),{nodes:T,edges:L,width:A,height:O,posMap:M}=j.useMemo(()=>UW(e,t,a,o),[e,t,a,o]),H=j.useCallback(q=>{var ne;const X=w.current;if(!X)return{x:0,y:0};const Y=X.createSVGPoint();Y.x=q.clientX,Y.y=q.clientY;const I=(ne=X.getScreenCTM())==null?void 0:ne.inverse();if(!I)return{x:0,y:0};const Q=Y.matrixTransform(I);return{x:Q.x,y:Q.y}},[]),B=j.useCallback(q=>!q||!_||q==="$start"?!1:_.type==="reconnect-from"?q!=="$done":!0,[_]),F=j.useCallback((q,X)=>{if(c)return;q.stopPropagation(),q.preventDefault();const Y=H(q);b({type:"new",fromNodeId:X,mouseX:Y.x,mouseY:Y.y})},[H,c]),K=j.useCallback((q,X)=>{if(c)return;q.stopPropagation(),q.preventDefault();const Y=H(q);b({type:"reconnect-to",fromNodeId:X.from,edgeKey:X.edgeKey,mouseX:Y.x,mouseY:Y.y})},[H,c]),G=j.useCallback((q,X)=>{if(c)return;q.stopPropagation(),q.preventDefault();const Y=H(q);b({type:"reconnect-from",fromNodeId:X.from,fixedTargetId:X.to,edgeKey:X.edgeKey,mouseX:Y.x,mouseY:Y.y})},[H,c]),V=j.useCallback(q=>{if(!_)return;const X=H(q);b(Y=>Y?{...Y,mouseX:X.x,mouseY:X.y}:null)},[_,H]),Z=j.useCallback(()=>{_&&(C.current=!0,k&&B(k)&&(_.type==="new"?m(_.fromNodeId,k):_.type==="reconnect-to"?f(_.edgeKey,k):_.type==="reconnect-from"&&g(_.edgeKey,k)),b(null),E(null))},[_,k,B,m,f,g]),J=j.useCallback(()=>{if(C.current){C.current=!1;return}u(null),d(null)},[u,d]);j.useEffect(()=>{if(c)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(),x(r),d(null))};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[c,r,x,d]);const z=q=>{const X=M.get(q.from),Y=M.get(q.to);if(!X||!Y)return null;let I,Q,ne,re="middle",ie,pe;if(q.direction==="down"){const ye=X.cx+q.fromPort*(X.w/2-10),Ie=X.cy+X.h/2,$e=Y.cx+q.toPort*(Y.w/2-10),Se=Y.cy-Y.h/2,Ge=Se-Ie,Je=$e-ye;I=`M ${ye} ${Ie} C ${ye} ${Ie+Ge*.4}, ${$e-Je*.2} ${Se-Ge*.1}, ${$e} ${Se}`,Q=ye+($e-ye)*.5,ne=Ie+Ge*.6,ie={x:ye,y:Ie},pe={x:$e,y:Se}}else if(q.direction==="back"){const ye=q.from===q.to,Ie=X.cx>=A/2,$e=q.backEdgeIndex*16,Se=Ie?A-20-$e:20+$e;if(ye){const Ge=X.cx>=A/2,Je=30+q.backEdgeIndex*14,_e=X.cy-X.h/2,ge=Ge?X.cx+X.w/2:X.cx-X.w/2,he=Ge?ge+Je:ge-Je,ae=X.cx+(Ge?X.w/4:-X.w/4),Pe=_e-20-q.backEdgeIndex*10;I=`M ${ge} ${X.cy} C ${he} ${X.cy}, ${he} ${Pe}, ${ae} ${_e}`,Q=he+10,ne=Pe+4,re="middle",ie={x:ge,y:X.cy},pe={x:ae,y:_e}}else{const Ge=Ie?X.cx+X.w/2:X.cx-X.w/2,Je=Y.cx+(Ie?Y.w/4:-Y.w/4),_e=Math.min(X.cy,Y.cy)-Y.h/2-18-q.backEdgeIndex*14;I=`M ${Ge} ${X.cy} L ${Se} ${X.cy} L ${Se} ${_e} L ${Je} ${_e} L ${Je} ${Y.cy-Y.h/2}`,Q=Se,ne=(X.cy+_e)/2,re=Ie?"start":"end",ie={x:Ge,y:X.cy},pe={x:Je,y:Y.cy-Y.h/2}}}else{const ye=Y.cx>X.cx,Ie=q.sameEdgeIndex===0?-12:12,$e=ye?X.cx+X.w/2:X.cx-X.w/2,Se=ye?Y.cx-Y.w/2:Y.cx+Y.w/2,Ge=X.cy+Ie,Je=Y.cy+Ie,_e=($e+Se)/2;I=`M ${$e} ${Ge} C ${_e} ${Ge}, ${_e} ${Je}, ${Se} ${Je}`,Q=_e,ne=(Ge+Je)/2-6,ie={x:$e,y:Ge},pe={x:Se,y:Je}}return{path:I,labelX:Q,labelY:ne,labelAnchor:re,fromPt:ie,toPt:pe}},P=(q,X)=>{const Y=z(q);if(!Y)return null;const{path:I,labelX:Q,labelY:ne,labelAnchor:re}=Y,ie=r===q.edgeKey,pe=q.label&&q.label!=="otherwise";return s.jsxs("g",{children:[s.jsx("path",{d:I,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:ye=>{ye.stopPropagation(),c||d(ie?null:q.edgeKey)}}),s.jsx("path",{d:I,fill:"none",stroke:ie?"#58a6ff":"#484f58",strokeWidth:ie?2.2:1.2,markerEnd:ie?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),pe&&s.jsx("text",{x:Q+(re==="start"?5:re==="end"?-5:0),y:ne+3,textAnchor:re,className:"text-[8px]",fill:ie?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:q.label})]},X)},D=()=>{if(!r||_)return null;const q=L.find(ne=>ne.edgeKey===r);if(!q)return null;const X=z(q);if(!X)return null;const{fromPt:Y,toPt:I}=X,Q=6;return s.jsxs(s.Fragment,{children:[q.edgeKey!=="start"&&s.jsx("circle",{cx:Y.x,cy:Y.y,r:Q,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ne=>G(ne,q)}),s.jsx("circle",{cx:I.x,cy:I.y,r:Q,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ne=>K(ne,q)})]})},U=()=>{if(!_)return null;let q,X,Y,I;if(_.type==="reconnect-from"){const re=M.get(_.fixedTargetId);if(!re)return null;q=_.mouseX,X=_.mouseY,Y=re.cx,I=re.cy-re.h/2}else{const re=M.get(_.fromNodeId);if(!re)return null;q=re.cx,X=re.cy+re.h/2,Y=_.mouseX,I=_.mouseY}const Q=I-X,ne=Math.abs(Q)>10?`M ${q} ${X} C ${q} ${X+Q*.4}, ${Y} ${I-Q*.4}, ${Y} ${I}`:`M ${q} ${X} L ${Y} ${I}`;return s.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,Y=(_==null?void 0:_.fromNodeId)===q.id;return s.jsx("circle",{cx:q.cx,cy:X,r:Kk,fill:Y?"#58a6ff":"#1c2128",stroke:Y?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:Y?1:.5,className:"cursor-crosshair",onMouseDown:I=>F(I,q.id)})},te=q=>{const X=q.cy-q.h/2,Y=_&&k===q.id&&B(q.id);return s.jsx("circle",{cx:q.cx,cy:X,r:Kk,fill:Y?"#3fb950":"#1c2128",stroke:Y?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:Y?1:.5})};return s.jsxs("svg",{ref:w,viewBox:`0 0 ${A} ${O}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:V,onMouseUp:Z,onClick:J,children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),s.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),L.map((q,X)=>P(q,X)),T.map(q=>{const X=n===q.id,Y=q.cx-q.w/2,I=q.cy-q.h/2,Q=v===q.id,ne=_&&k===q.id&&B(q.id);if(q.type==="terminal"){const ie=q.id==="$start",pe=ie?"#58a6ff":"#3fb950",ye=ie,Ie=!ie;return s.jsxs("g",{onClick:$e=>{$e.stopPropagation(),ie&&!c&&d("start")},className:ie&&!c?"cursor-pointer":void 0,children:[ne&&s.jsx("rect",{x:Y-3,y:I-3,width:q.w+6,height:q.h+6,rx:q.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),ie&&r==="start"&&s.jsx("rect",{x:Y-3,y:I-3,width:q.w+6,height:q.h+6,rx:q.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),s.jsx("rect",{x:Y,y:I,width:q.w,height:q.h,rx:q.h/2,fill:pe,fillOpacity:.08,stroke:pe,strokeOpacity:.4,strokeWidth:1.5}),s.jsx("text",{x:q.cx,y:q.cy+4,textAnchor:"middle",fill:pe,className:"text-[10px] font-medium",pointerEvents:"none",children:q.label}),ye&&$(q),Ie&&te(q)]},q.id)}const re=q.color??"#6b7280";return s.jsxs("g",{onClick:ie=>{ie.stopPropagation(),c||u(X?null:q.id)},onMouseEnter:()=>S(q.id),onMouseLeave:()=>S(null),className:c?void 0:"cursor-pointer",children:[ne&&s.jsx("rect",{x:Y-3,y:I-3,width:q.w+6,height:q.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),X&&s.jsx("rect",{x:Y-3,y:I-3,width:q.w+6,height:q.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),s.jsx("rect",{x:Y,y:I,width:q.w,height:q.h,rx:10,fill:re,fillOpacity:.08,stroke:re,strokeOpacity:.6,strokeWidth:X?2:1.5}),s.jsx("text",{x:q.cx,y:q.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:q.label}),!c&&$(q),!c&&te(q),Q&&!_&&!c&&s.jsxs("g",{onClick:ie=>{ie.stopPropagation(),h(q.id)},className:"cursor-pointer",children:[s.jsx("circle",{cx:Y+q.w-2,cy:I+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),s.jsx("line",{x1:Y+q.w-5,y1:I-1,x2:Y+q.w+1,y2:I+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),s.jsx("line",{x1:Y+q.w+1,y1:I-1,x2:Y+q.w-5,y2:I+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},q.id)}),_&&T.map(q=>B(q.id)?s.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),U(),D()]})}const Th="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",Kc="block text-[11px] text-text-secondary mb-0.5";function WW({formName:e,formId:t,formDescription:n,formMaxIterations:r,formColor:a,isReadOnly:o,onNameChange:c,onDescriptionChange:u,onMaxIterationsChange:d,onColorChange:h}){return s.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[s.jsxs("div",{className:"min-w-[140px]",children:[s.jsx("label",{className:Kc,children:"Name"}),s.jsx("input",{value:e,onChange:m=>c(m.target.value),placeholder:"Workflow name",className:`${Th} ${o?"opacity-50":""}`,readOnly:o})]}),s.jsxs("div",{className:"min-w-[100px]",children:[s.jsx("label",{className:Kc,children:"ID"}),s.jsx("input",{value:t,readOnly:!0,className:`${Th} font-mono opacity-50`})]}),s.jsxs("div",{className:"flex-1 min-w-[140px]",children:[s.jsx("label",{className:Kc,children:"Description"}),s.jsx("input",{value:n,onChange:m=>!o&&u(m.target.value),readOnly:o,placeholder:"What does this workflow do?",className:`${Th} ${o?"opacity-50":""}`})]}),s.jsxs("div",{className:"w-20",children:[s.jsx("label",{className:Kc,children:"Max Iter."}),s.jsx("input",{type:"number",value:r,onChange:m=>!o&&d(Number(m.target.value)),readOnly:o,className:`${Th} font-mono ${o?"opacity-50":""}`})]}),s.jsxs("div",{children:[s.jsx("label",{className:Kc,children:"Color"}),s.jsx("input",{type:"color",value:a,onChange:m=>!o&&h(m.target.value),disabled:o,className:`w-8 h-8 rounded border border-border bg-transparent ${o?"opacity-50":"cursor-pointer"}`})]})]})}function GW({name:e,id:t,color:n,description:r,isBuiltIn:a,actions:o}){return s.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:n}}),s.jsx("span",{className:"text-text-primary text-sm font-medium",children:e}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:t}),a&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),r&&s.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:r})]}),s.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 ml-3",children:o})]})}function zx({title:e,items:t,renderActions:n}){return t.length===0?null:s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),s.jsx("div",{className:"space-y-2",children:t.map(r=>s.jsx(GW,{name:r.name,id:r.id,color:r.color??"#3b82f6",description:r.description,actions:n(r)},r.id))})]})}const Ha="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",Ux="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",Ns="block text-[11px] text-text-secondary mb-0.5";function Vx({variables:e,onInsert:t}){return e.length===0?null:s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(n=>s.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 qW({step:e,isEntry:t,agentTypes:n,transitionCount:r,templateVariables:a,onUpdate:o,onRemove:c,onSetEntry:u}){const{color:d,name:h}=Tv(e,n);return s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:d+"20",color:d},children:h}),t&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[!t&&s.jsx("button",{onClick:u,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),s.jsx("button",{onClick:c,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Name"}),s.jsx("input",{value:e.name,onChange:m=>o({...e,name:m.target.value}),placeholder:"Step name",className:Ha})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Type"}),s.jsx("select",{value:e.type,onChange:m=>{const f=m.target.value,g=f==="sub_agent"?"verification":"build";if(f==="agent"){const x=n.find(w=>!w.subagent);o({...e,type:f,phase:g,agentId:(x==null?void 0:x.id)??"builder",name:(x==null?void 0:x.name)??"Agent"})}else if(f==="sub_agent"){const x=n.find(w=>w.subagent);o({...e,type:f,phase:g,subAgentType:(x==null?void 0:x.id)??"",name:(x==null?void 0:x.name)??"Sub-Agent"})}else o(f==="user"?{...e,type:f,phase:g,name:"User"}:{...e,type:f,phase:g,name:"Shell"})},className:Ux,children:zW.map(m=>s.jsx("option",{value:m.value,children:m.label},m.value))})]}),e.type==="agent"&&s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Agent Type"}),s.jsx("select",{value:e.agentId??"builder",onChange:m=>{const f=n.find(g=>g.id===m.target.value);o({...e,agentId:m.target.value,name:(f==null?void 0:f.name)??m.target.value})},className:Ux,children:n.filter(m=>!m.subagent).map(m=>s.jsx("option",{value:m.id,children:m.name},m.id))})]}),e.type==="sub_agent"&&s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Sub-Agent Type"}),s.jsxs("select",{value:e.subAgentType??"",onChange:m=>{const f=n.find(g=>g.id===m.target.value);o({...e,subAgentType:m.target.value,name:(f==null?void 0:f.name)??m.target.value})},className:Ux,children:[s.jsx("option",{value:"",children:"— select —"}),n.filter(m=>m.subagent).map(m=>s.jsx("option",{value:m.id,children:m.name},m.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Prompt"}),s.jsx("textarea",{value:e.prompt??"",onChange:m=>o({...e,prompt:m.target.value||void 0}),rows:6,className:`${Ha} resize-y text-xs`,placeholder:"Injected on first entry..."}),s.jsx(Vx,{variables:a,onInsert:m=>o({...e,prompt:(e.prompt??"")+`{{${m}}}`})})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Nudge Prompt"}),s.jsx("textarea",{value:e.nudgePrompt??"",onChange:m=>o({...e,nudgePrompt:m.target.value||void 0}),rows:6,className:`${Ha} resize-y text-xs`,placeholder:"Injected on re-entry..."}),s.jsx(Vx,{variables:a,onInsert:m=>o({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${m}}}`})})]})]}),e.type==="shell"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Command"}),s.jsx("textarea",{value:e.command??"",onChange:m=>o({...e,command:m.target.value}),rows:3,className:`${Ha} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),s.jsx(Vx,{variables:a,onInsert:m=>o({...e,command:(e.command??"")+`{{${m}}}`})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Timeout (ms)"}),s.jsx("input",{type:"number",value:e.timeout??6e4,onChange:m=>o({...e,timeout:Number(m.target.value)}),className:`${Ha} font-mono text-xs`})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Success Codes"}),s.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:m=>o({...e,successExitCodes:m.target.value.split(",").map(f=>Number(f.trim())).filter(f=>!isNaN(f))}),className:`${Ha} font-mono text-xs`})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ns,children:"Sub-group"}),s.jsx("input",{value:e.subGroup??"",onChange:m=>o({...e,subGroup:m.target.value||void 0}),placeholder:"e.g. build, verify, review",className:Ha})]}),s.jsx("div",{className:"pt-1 border-t border-border/50",children:s.jsxs("p",{className:"text-text-muted text-[10px]",children:[r," outgoing transition",r!==1?"s":""," — drag from the bottom port to connect."]})})]})}const al="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",Yk="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",za="block text-[11px] text-text-secondary mb-0.5";function KW({fromLabel:e,toLabel:t,condition:n,subGroup:r,fromStep:a,agentTypes:o,transitionIndex:c,totalTransitions:u,onUpdateCondition:d,onUpdateSubGroup:h,onDelete:m,onMoveUp:f,onMoveDown:g}){var C;const x=a&&(a.type==="sub_agent"||a.type==="agent")?o.find(v=>v.id===(a.type==="sub_agent"?a.subAgentType:a.agentId)):void 0,w=(x==null?void 0:x.results)&&x.results.length>0;return s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:["#",c+1]}),u>1&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[s.jsx("button",{onClick:f,disabled:c===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:s.jsx(gn,{className:"w-3 h-3",rotate:180})}),s.jsx("button",{onClick:g,disabled:c===u-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:s.jsx(gn,{className:"w-3 h-3"})})]})]}),s.jsx("button",{onClick:m,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[s.jsx("span",{className:"font-medium text-text-primary",children:e}),s.jsx(Uf,{}),s.jsx("span",{className:"font-medium text-text-primary",children:t})]}),s.jsxs("div",{children:[s.jsx("label",{className:za,children:"Condition"}),s.jsx("select",{value:n.type,onChange:v=>{d(v.target.value==="step_result"?{type:"step_result",result:"success"}:{type:v.target.value})},className:Yk,children:$A.map(v=>s.jsx("option",{value:v.value,children:v.label},v.value))})]}),n.type==="step_result"&&s.jsxs("div",{children:[s.jsx("label",{className:za,children:"Result"}),w?s.jsx("select",{value:n.result??x.results[0],onChange:v=>{d({type:"step_result",result:v.target.value})},className:Yk,children:x.results.map(v=>s.jsx("option",{value:v,children:v},v))}):s.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:al})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:za,children:"Metadata Key"}),s.jsx("input",{type:"text",value:n.key??"",onChange:v=>d({...n,key:v.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:al})]}),s.jsxs("div",{children:[s.jsx("label",{className:za,children:"Field"}),s.jsx("input",{type:"text",value:n.field??"",onChange:v=>d({...n,field:v.target.value}),placeholder:"e.g. status",className:al})]}),n.type==="metadata_all_match"?s.jsxs("div",{children:[s.jsx("label",{className:za,children:"Value"}),s.jsx("input",{type:"text",value:n.value??"",onChange:v=>d({...n,value:v.target.value}),placeholder:"e.g. passed, resolved",className:al})]}):s.jsxs("div",{children:[s.jsx("label",{className:za,children:"Values (comma-separated)"}),s.jsx("input",{type:"text",value:((C=n.values)==null?void 0:C.join(", "))??"",onChange:v=>d({...n,values:v.target.value.split(",").map(S=>S.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:al})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:za,children:"Sub-group"}),s.jsx("input",{type:"text",value:r??"",onChange:v=>h(v.target.value||void 0),placeholder:"e.g. build, verify",className:al})]}),(a==null?void 0:a.type)==="user"&&s.jsxs("div",{className:"pt-1 border-t border-border/50 space-y-1",children:[s.jsx("p",{className:"text-text-muted text-[10px]",children:'On a user step, each "Step result is..." transition becomes a choice button; "Always" becomes a Continue button.'}),n.type==="step_result"&&a.transitions.filter(v=>v.when.type==="step_result"&&v.when.result===n.result).length>1&&s.jsxs("p",{className:"text-accent-warning text-[10px]",children:['Duplicate result "',n.result,'" — only the first matching transition is reachable.']}),n.type==="step_result"&&n.result==="continue"&&s.jsx("p",{className:"text-accent-warning text-[10px]",children:'"continue" is reserved for the "Always" Continue button — rename this result.'}),n.type==="always"&&a.transitions.some((v,S)=>S>c&&v.when.type==="step_result")&&s.jsx("p",{className:"text-accent-warning text-[10px]",children:'This "Always" transition comes before one or more choice transitions — those choice buttons are unreachable. Move it to the end.'}),n.type==="always"&&a.transitions.filter(v=>v.when.type==="always").length>1&&s.jsx("p",{className:"text-accent-warning text-[10px]",children:'Multiple "Always" transitions — only the first is reachable.'})]}),s.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function YW(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function XW(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const Yc="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",Xk="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",ol="block text-[11px] text-text-secondary mb-0.5",Qk=[];function FA({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){var xt,It;const a=Wt(Ee=>Ee.defaults),o=Wt(Ee=>Ee.userItems),c=Wt(Ee=>Ee.projectItems),u=Wt(Ee=>Ee.loading),d=Wt(Ee=>Ee.templateVariables),h=Wt(Ee=>Ee.fetchWorkflows),m=Wt(Ee=>Ee.fetchWorkflow),f=Wt(Ee=>Ee.fetchDefaultContent),g=Wt(Ee=>Ee.fetchTemplateVariables),x=Wt(Ee=>Ee.createWorkflow),w=Wt(Ee=>Ee.updateWorkflow),C=Wt(Ee=>Ee.deleteWorkflow),{requestDelete:v,clearConfirm:S,isConfirming:_}=Tu(),[b,k]=j.useState("list"),[E,T]=j.useState(null),[L,A]=j.useState(void 0),[O,M]=j.useState(!1),[H,B]=j.useState(null),[F,K]=j.useState(null),[G,V]=j.useState(""),[Z,J]=j.useState(""),[z,P]=j.useState(""),[D,U]=j.useState("1.0.0"),[$,te]=j.useState("#3b82f6"),[q,X]=j.useState(""),[Y,I]=j.useState(50),[Q,ne]=j.useState(Qk),[re,ie]=j.useState({type:"always"}),[pe,ye]=j.useState([]),[Ie,$e]=j.useState("user"),[Se,Ge]=j.useState(""),[Je,_e]=j.useState(!1),ge=dt(Ee=>Ee.defaults),he=dt(Ee=>Ee.userItems),ae=dt(Ee=>Ee.projectItems),Pe=j.useMemo(()=>[...ge,...he,...ae],[ge,he,ae]),Ue=dt(Ee=>Ee.fetchAgents),[de]=j.useState(null);j.useEffect(()=>{e&&(h(r),g(),Ue(),B(null),K(null),n?a.some(Te=>Te.id===n)?f(n,r).then(Te=>{Te&&Ae({...Te,metadata:{...Te.metadata,name:Te.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):m(n,r).then(Te=>{Te&&Ae(Te,{editingId:n,isReadOnly:!1})}):(k("list"),T(null),M(!1)))},[e,h,m,f,g,n,r]);const Ae=(Ee,Te)=>{V(Ee.metadata.name),J(Ee.metadata.id),P(Ee.metadata.description),U(Ee.metadata.version),te(Ee.metadata.color??"#3b82f6"),X(Ee.entryStep),I(Ee.settings.maxIterations),ne(Ee.steps),ie(Ee.startCondition??{type:"always"}),ye(Ee.metadata.parameters??[]),Ge(""),(Te==null?void 0:Te.editingId)!==void 0&&T(Te.editingId),(Te==null?void 0:Te.isReadOnly)!==void 0&&M(Te.isReadOnly),(Te==null?void 0:Te.selectedNodeKey)!==void 0&&B(null),(Te==null?void 0:Te.selectedEdgeKey)!==void 0&&K(null),k("edit")},ue=async(Ee,Te)=>{A(Te);const He=await m(Ee,r,Te);He&&Ae(He,{editingId:Ee,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},Fe=async()=>{var bt;const Ee=E??Z;if(!Ee||!G)return Ge("Name is required."),!1;if(Q.length===0)return Ge("Add at least one step."),!1;const Te=pe.find(jt=>!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(jt.id));if(Te)return Ge(`Invalid parameter ID "${Te.id}". Use letters, digits, and underscores only.`),!1;let He=q;if(!He||!Q.some(jt=>jt.id===He)){if(He=((bt=Q.find(jt=>jt.id))==null?void 0:bt.id)??"",!He)return Ge("All steps need an ID."),!1;X(He)}_e(!0),Ge("");const et={metadata:{id:Ee,name:G,description:z,version:D||"1.0.0",color:$,...pe.length>0?{parameters:pe}:{}},entryStep:He,settings:{maxIterations:Y},steps:Q,startCondition:re},st=E?await w(E,et,r,L):await x(et,Ie,r);return _e(!1),st.success?(E||T(Ee),!0):(Ge(st.error??"Failed to save."),!1)},Xe=async()=>{await Fe()},it=async()=>{await Fe()&&(n?t():k("list"))},Ze=()=>{n?t():k("list")},lt=Ee=>{V(Ee),E||J(YW(Ee))},gt=async(Ee,Te)=>a.some(et=>et.id===Ee)?await f(Ee,r):await m(Ee,r,Te),De=async(Ee,Te)=>{const He=await gt(Ee,Te);He&&Ae({...He,metadata:{...He.metadata,name:He.metadata.name+" (copy)",id:`${Ee}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},Re=()=>{T(null),A(void 0),V(""),J(""),P(""),U("1.0.0"),te("#3b82f6"),X(""),I(50),ne(structuredClone(Qk)),ie({type:"always"}),ye([]),$e("user"),Ge(""),B(null),K(null),M(!1),k("edit")},ke=async(Ee,Te)=>{await C(Ee,Te,r),S()},We=j.useCallback(Ee=>{B(Ee),K(null)},[]),Ce=j.useCallback(Ee=>{K(Ee),B(null)},[]),nt=H!==null?Number(H):-1,tt=nt>=0?Q[nt]??null:null,ht=j.useCallback(Ee=>{ne(Te=>Te.map((He,et)=>et===nt?Ee:He))},[nt]),Lt=re.type==="step_result"?`${re.result}`:re.type==="metadata_all_match"?`${re.key??"?"}=${re.value??"?"}`:re.type==="metadata_all_in"?`${re.key??"?"} in [${((xt=re.values)==null?void 0:xt.join(","))??"?"}]`:BA[re.type]??re.type,qt=()=>{const Ee=Q.length,Te=XW(Q),He=Pe.find(et=>!et.subagent);ne([...Q,{id:Te,name:(He==null?void 0:He.name)??"Agent",type:"agent",phase:"build",agentId:(He==null?void 0:He.id)??"builder",transitions:[]}]),q||X(Te),We(String(Ee))},bn=j.useCallback((Ee,Te)=>{Ee==="$start"?(X(Te),Ce("start")):ne(He=>{const et=He.find(bt=>bt.id===Ee),st=et?et.transitions.length:0;return Ce(`${Ee}:${st}`),He.map(bt=>bt.id===Ee?{...bt,transitions:[...bt.transitions,{when:{type:"always"},goto:Te}]}:bt)})},[Ce]),vn=Ee=>{if(Ee==="start")return null;const Te=Ee.lastIndexOf(":"),He=Ee.slice(0,Te),et=parseInt(Ee.slice(Te+1));return{stepId:He,transIdx:et}},xn=j.useCallback((Ee,Te)=>{const He=vn(Ee);He&&ne(et=>et.map(st=>st.id===He.stepId?{...st,transitions:st.transitions.map((bt,jt)=>jt===He.transIdx?Te(bt):bt)}:st))},[]),hr=j.useCallback((Ee,Te)=>{if(Ee==="start"){X(Te);return}xn(Ee,He=>({...He,goto:Te}))},[xn]),ve=j.useCallback((Ee,Te)=>{const He=vn(Ee);He&&(ne(et=>{const st=et.find(jt=>jt.id===He.stepId);if(!st)return et;const bt=st.transitions[He.transIdx];return bt?et.map(jt=>jt.id===He.stepId?{...jt,transitions:jt.transitions.filter((Pn,Cn)=>Cn!==He.transIdx)}:jt.id===Te?{...jt,transitions:[...jt.transitions,bt]}:jt):et}),K(null))},[]),rt=j.useCallback(Ee=>{if(Ee==="start"){X(""),K(null);return}const Te=vn(Ee);Te&&(ne(He=>He.map(et=>et.id===Te.stepId?{...et,transitions:et.transitions.filter((st,bt)=>bt!==Te.transIdx)}:et)),K(null))},[]),Qe=j.useCallback((Ee,Te)=>{if(Ee==="start"){ie(Te);return}xn(Ee,He=>({...He,when:Te}))},[xn]),Ve=j.useCallback((Ee,Te)=>{Ee!=="start"&&xn(Ee,He=>({...He,subGroup:Te||void 0}))},[xn]),le=Ee=>Tv(Ee,Pe).name,Ye=()=>{if(!F)return null;if(F==="start"){const Pn=Q.find(Cn=>Cn.id===q);return{type:"start",fromLabel:"Start",toLabel:Pn?le(Pn):"(none)",condition:re}}const Ee=F.lastIndexOf(":"),Te=F.slice(0,Ee),He=parseInt(F.slice(Ee+1)),et=Q.find(Pn=>Pn.id===Te);if(!et)return null;const st=et.transitions[He];if(!st)return null;const bt=Q.find(Pn=>Pn.id===st.goto),jt=st.goto==="$done"?"Done":bt?le(bt):st.goto;return{type:"step",fromLabel:le(et),toLabel:jt,condition:st.when,subGroup:st.subGroup}};if(b==="edit"){const Ee=Ye();return s.jsxs(Et,{isOpen:e,onClose:Ze,title:O?G:E?"Edit Workflow":"New Workflow",size:"full",children:[Se&&s.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:Se}),s.jsx(WW,{formName:G,formId:Z,formDescription:z,formMaxIterations:Y,formColor:$,isReadOnly:O,onNameChange:lt,onDescriptionChange:P,onMaxIterationsChange:I,onColorChange:te}),!O&&s.jsx("div",{className:"mb-3 pb-3 border-b border-border",children:s.jsxs(HW,{title:`Parameters (${pe.length})`,children:[pe.map((Te,He)=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{value:Te.id,onChange:et=>{const st=[...pe];st[He]={...Te,id:et.target.value},ye(st)},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"}),s.jsx("input",{value:Te.label,onChange:et=>{const st=[...pe];st[He]={...Te,label:et.target.value},ye(st)},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"}),s.jsx("input",{value:Te.description??"",onChange:et=>{const st=[...pe];st[He]={...Te,description:et.target.value||void 0},ye(st)},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"}),s.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-text-muted whitespace-nowrap",children:[s.jsx("input",{type:"checkbox",checked:Te.required??!1,onChange:et=>{const st=[...pe];st[He]={...Te,required:et.target.checked||void 0},ye(st)},className:"rounded border-border"}),"Req."]}),s.jsxs("div",{className:"flex gap-0.5",children:[s.jsx("button",{onClick:()=>{He!==0&&ye(pe.map((et,st)=>st===He?{...pe[He-1],position:st}:st===He-1?{...pe[He],position:st}:{...et,position:st}))},disabled:He===0,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move up","aria-label":`Move ${Te.label||Te.id} up`,children:"▲"}),s.jsx("button",{onClick:()=>{He!==pe.length-1&&ye(pe.map((et,st)=>st===He?{...pe[He+1],position:st}:st===He+1?{...pe[He],position:st}:{...et,position:st}))},disabled:He===pe.length-1,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move down","aria-label":`Move ${Te.label||Te.id} down`,children:"▼"})]}),s.jsx("button",{onClick:()=>ye(pe.filter((et,st)=>st!==He)),className:"p-1 text-text-muted hover:text-accent-error transition-colors",title:"Remove parameter",children:"✕"})]},Te.id)),s.jsx("button",{onClick:()=>{const Te=`param_${pe.length+1}`;ye([...pe,{id:Te,label:"",description:"",required:!1}])},className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:"+ Add parameter"})]})}),!E&&!O&&s.jsx(Xf,{value:Ie,onChange:$e}),s.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[s.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[s.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),!O&&s.jsx("button",{onClick:qt,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),s.jsxs(pt,{className:"flex-1 min-h-0 p-2",children:[s.jsx(VW,{steps:Q,entryStep:q,selectedNodeId:(tt==null?void 0:tt.id)??null,selectedEdgeKey:F,startConditionLabel:Lt,agentTypes:Pe,isReadOnly:O,onSelectNode:Te=>{if(Te===null){We(null);return}const He=Q.findIndex(et=>et.id===Te);We(He>=0?String(He):null)},onSelectEdge:Ce,onRemoveStep:Te=>{var et;const He=Q.findIndex(st=>st.id===Te);if(ne(st=>st.filter(bt=>bt.id!==Te)),nt===He&&We(null),q===Te){const st=Q.filter(bt=>bt.id!==Te);X(((et=st[0])==null?void 0:et.id)??"")}},onCreateTransition:bn,onReconnectTo:hr,onReconnectFrom:ve,onDeleteTransition:rt}),Q.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[s.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),s.jsx("button",{onClick:qt,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"})]})]})]}),s.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[s.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:s.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),s.jsx(pt,{className:"p-3 flex-1 min-h-0",children:O&&(Ee||tt)?s.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):Ee?Ee.type==="start"?s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),q&&s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[s.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),s.jsx(Uf,{}),s.jsx("span",{className:"text-text-primary font-medium",children:Ee.toLabel})]}),s.jsxs("div",{children:[s.jsx("label",{className:ol,children:"Activation Condition"}),s.jsx("select",{value:re.type,onChange:Te=>ie(Te.target.value==="step_result"?{type:"step_result",result:"success"}:Te.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:Te.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:Te.target.value}),className:Xk,children:$A.map(Te=>s.jsx("option",{value:Te.value,children:Te.label},Te.value))})]}),re.type==="step_result"&&s.jsxs("div",{children:[s.jsx("label",{className:ol,children:"Result"}),q&&(()=>{const Te=Q.find(bt=>bt.id===q),He=Te&&(Te.type==="sub_agent"||Te.type==="agent")?Pe.find(bt=>bt.id===(Te.type==="sub_agent"?Te.subAgentType:Te.agentId)):void 0,et=(He==null?void 0:He.results)&&He.results.length>0,st=(He==null?void 0:He.results)??[];return et?s.jsx("select",{value:re.result??st[0],onChange:bt=>ie({type:"step_result",result:bt.target.value}),className:Xk,children:st.map(bt=>s.jsx("option",{value:bt,children:bt},bt))}):s.jsx("input",{type:"text",value:re.result??"success",onChange:bt=>ie({type:"step_result",result:bt.target.value}),placeholder:"e.g. success, passed, failed",className:Yc})})()]}),(re.type==="metadata_all_match"||re.type==="metadata_all_in")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:ol,children:"Metadata Key"}),s.jsx("input",{type:"text",value:re.key??"",onChange:Te=>ie({...re,key:Te.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Yc})]}),s.jsxs("div",{children:[s.jsx("label",{className:ol,children:"Field"}),s.jsx("input",{type:"text",value:re.field??"",onChange:Te=>ie({...re,field:Te.target.value}),placeholder:"e.g. status",className:Yc})]}),re.type==="metadata_all_match"?s.jsxs("div",{children:[s.jsx("label",{className:ol,children:"Value"}),s.jsx("input",{type:"text",value:re.value??"",onChange:Te=>ie({...re,value:Te.target.value}),placeholder:"e.g. passed, resolved",className:Yc})]}):s.jsxs("div",{children:[s.jsx("label",{className:ol,children:"Values (comma-separated)"}),s.jsx("input",{type:"text",value:((It=re.values)==null?void 0:It.join(", "))??"",onChange:Te=>ie({...re,values:Te.target.value.split(",").map(He=>He.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Yc})]})]}),s.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 Te=vn(F),He=Te==null?void 0:Te.stepId,et=(Te==null?void 0:Te.transIdx)??0,st=He?Q.find(jt=>jt.id===He):void 0,bt=(st==null?void 0:st.transitions.length)??0;return s.jsx(KW,{fromLabel:Ee.fromLabel,toLabel:Ee.toLabel,condition:Ee.condition,subGroup:"subGroup"in Ee?Ee.subGroup:void 0,fromStep:Ee.type==="step"?Q.find(jt=>jt.id===Ee.fromLabel):void 0,agentTypes:Pe,transitionIndex:et,totalTransitions:bt,onUpdateCondition:jt=>Qe(F,jt),onUpdateSubGroup:jt=>Ve(F,jt),onDelete:()=>rt(F),onMoveUp:()=>{ne(jt=>{const Pn=jt.find(Tn=>Tn.id===He);if(!Pn||et===0)return jt;const Cn=[...Pn.transitions];return[Cn[et-1],Cn[et]]=[Cn[et],Cn[et-1]],jt.map(Tn=>Tn.id===He?{...Tn,transitions:Cn}:Tn)}),K(`${He}:${et-1}`)},onMoveDown:()=>{ne(jt=>{const Pn=jt.find(Tn=>Tn.id===He);if(!Pn||et===Pn.transitions.length-1)return jt;const Cn=[...Pn.transitions];return[Cn[et],Cn[et+1]]=[Cn[et+1],Cn[et]],jt.map(Tn=>Tn.id===He?{...Tn,transitions:Cn}:Tn)}),K(`${He}:${et+1}`)}})})():tt?s.jsx(qW,{step:tt,isEntry:tt.id===q,agentTypes:Pe,transitionCount:tt.transitions.length,templateVariables:d,onUpdate:ht,onRemove:()=>{var Te;if(tt&&(ne(Q.filter((He,et)=>et!==nt)),We(null),q===tt.id)){const He=Q.filter((et,st)=>st!==nt);X(((Te=He[0])==null?void 0:Te.id)??"")}},onSetEntry:()=>X(tt.id)}):s.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",s.jsx("br",{}),"Drag from a port to connect."]})})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[s.jsx(ot,{variant:"secondary",onClick:Ze,children:"Close"}),O?s.jsx(ot,{variant:"primary",onClick:()=>{V(G+" (copy)"),J(`${E}-copy-${Date.now()}`),T(null),M(!1)},children:"Duplicate & Customize"}):s.jsxs(s.Fragment,{children:[s.jsx(ot,{variant:"primary",onClick:Xe,children:"Save"}),s.jsx(ot,{variant:"primary",onClick:it,children:"Save & Close"})]})]})]})}return s.jsx(Et,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:s.jsx(LE,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:Re,loading:u,hasItems:a.length>0||o.length>0||c.length>0,children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(zx,{title:"Built-in",items:a,renderActions:Ee=>s.jsx(s.Fragment,{children:s.jsx(vi,{onClick:()=>De(Ee.id),children:s.jsx(wb,{})})})}),s.jsx(zx,{title:"Custom",items:o,renderActions:Ee=>s.jsxs(s.Fragment,{children:[s.jsx(vi,{onClick:()=>ue(Ee.id,"user"),children:s.jsx("span",{className:"text-[10px]",children:"Edit"})}),s.jsx(xu,{onClick:()=>De(Ee.id,"user")}),_(`user:${Ee.id}`,"delete")?s.jsx(Jh,{onConfirm:()=>ke(Ee.id,"user"),onCancel:S}):s.jsx(Zh,{onClick:()=>v(`user:${Ee.id}`)})]})}),c.length>0&&s.jsx(zx,{title:"Project",items:c,renderActions:Ee=>s.jsxs(s.Fragment,{children:[s.jsx(vi,{onClick:()=>ue(Ee.id,"project"),children:s.jsx("span",{className:"text-[10px]",children:"Edit"})}),s.jsx(xu,{onClick:()=>De(Ee.id,"project")}),_(`project:${Ee.id}`,"delete")?s.jsx(Jh,{onConfirm:()=>ke(Ee.id,"project"),onCancel:S}):s.jsx(Zh,{onClick:()=>v(`project:${Ee.id}`)})]})})]})})})}function QW(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function JW({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:a,onCloseCompleteAction:o,textareaContent:c,onSearchMessages:u,onToggleAutoScroll:d,isAutoScrollActive:h}){const[,m]=Nn(),f=fn(q=>q.fetchCommands),g=Wt(q=>q.fetchWorkflows),x=dt(q=>q.fetchAgents),w=fn(q=>q.defaults),C=fn(q=>q.userItems),v=fn(q=>q.projectItems),S=Wt(q=>q.defaults),_=Wt(q=>q.userItems),b=Wt(q=>q.projectItems),k=dt(q=>q.defaults),E=dt(q=>q.userItems),T=dt(q=>q.projectItems),L=Er(),A=cn(L,q=>{var X;return((X=q.session)==null?void 0:X.mode)??null},q=>{var X;return((X=q.currentSession)==null?void 0:X.mode)??null},null),O=cn(L,q=>{var X;return((X=q.session)==null?void 0:X.dangerLevel)??"normal"},q=>{var X;return((X=q.currentSession)==null?void 0:X.dangerLevel)??"normal"},"normal"),M=Oe(q=>q.switchMode),H=Oe(q=>q.switchDangerLevel),B=cn(L,q=>{var X;return((X=q.session)==null?void 0:X.projectId)??null},q=>{var X;return((X=q.currentSession)==null?void 0:X.projectId)??null},null),F=cn(L,q=>{var X;return((X=q.session)==null?void 0:X.workdir)??void 0},q=>{var X;return(X=q.currentSession)==null?void 0:X.workdir},void 0),K=j.useRef(void 0),[G,V]=j.useState(""),[Z,J]=j.useState(0),z=j.useRef(null),P=j.useRef(!1);j.useEffect(()=>{e&&(P.current=!0)},[e]),j.useEffect(()=>{if(e){f(F),g(F),x(F),V(""),J(0);const q=setTimeout(()=>{var X;Gt()&&((X=z.current)==null||X.focus())},50);return()=>clearTimeout(q)}},[e,f,g,x,F]),j.useEffect(()=>{var q;!e&&P.current&&(n==null||n(),(q=K.current)==null||q.call(K),K.current=void 0)},[e,n]);const U=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const q=B??QW(window.location.pathname);q&&m(`/p/${q}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{K.current=o,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),u==null||u()}},{id:"toggle-autoscroll",name:h?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),d==null||d(!h)}},...Gn(Gn(k,E),T).filter(q=>!q.subagent&&q.id!==A).map(q=>({id:q.id,name:q.name,prefix:"Agent > Switch to",action:()=>L&&M(L,q.id)})),...Gn(Gn(w,C),v).map(q=>({id:q.id,name:q.name,prefix:"Command > Launch",action:()=>r(q.id,c)})),...Gn(Gn(S,_),b).map(q=>({id:q.id,name:q.name,prefix:"Workflow > Run",action:()=>a(q.id,q.scope)})),...["normal","dangerous"].filter(q=>q!==O).map(q=>({id:q,name:q.charAt(0).toUpperCase()+q.slice(1),prefix:"Mode > Switch to",action:()=>L&&H(L,q)}))].filter(q=>aa(`${q.prefix} ${q.name}`,G)),$=U.length-1,te=q=>{qT(q,$,J,()=>{var X;(X=U[Z])==null||X.action(),t()},t)};return e?wi.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),s.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[s.jsx("input",{ref:z,type:"text",value:G,onChange:q=>{V(q.target.value),J(0)},onKeyDown:te,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),s.jsx(Nb,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),s.jsx(pt,{className:"max-h-[60vh] p-2",children:U.length===0?s.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:w.length+C.length+S.length+_.length>0?"No matches":"No agents, commands, or workflows yet"}):U.map((q,X)=>s.jsxs("button",{type:"button",onClick:()=>{q.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${X===Z?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:[s.jsxs("span",{className:"text-text-muted font-normal",children:[q.prefix," "]}),s.jsx("span",{children:q.name})]},q.id))})]})]}),document.body):null}const HA="openfox-message-search-filters",ZW=[{key:"user",label:"User prompts"},{key:"thinking",label:"Thinking"},{key:"response",label:"Responses"}];function eG(){try{const e=localStorage.getItem(HA);if(e){const t=JSON.parse(e);return new Set(t)}}catch{}return new Set(["user","thinking","response"])}function tG(e){localStorage.setItem(HA,JSON.stringify([...e]))}function nG(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 rG(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(),o=String(t.getMonth()+1).padStart(2,"0"),c=String(t.getDate()).padStart(2,"0"),u=String(t.getHours()).padStart(2,"0"),d=String(t.getMinutes()).padStart(2,"0");return`${a}/${o}/${c} ${u}:${d}`}function sG(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 iG(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 aG(e){var n,r;if(e.type!=="message")return s.jsx(C1,{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())?s.jsx(aO,{className:"w-3.5 h-3.5"}):s.jsx(C1,{className:"w-3.5 h-3.5"}):s.jsx(iO,{className:"w-3.5 h-3.5"})}function Jk(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 o=a.slice(0,200);return o.length<a.length?`${o}...`:o}return e.type==="subagent"?`Sub-agent: ${e.subAgentType}`:""}function oG({isOpen:e,onClose:t,displayItems:n,onNavigate:r}){const[a,o]=j.useState(""),[c,u]=j.useState(0),[d,h]=j.useState(eG),m=j.useRef(null),f=j.useRef(null),g=j.useRef(null),x=E=>{h(T=>{const L=new Set(T);return L.has(E)?L.delete(E):L.add(E),tG(L),L})},w=j.useMemo(()=>n.filter(E=>{var T,L;return!(E.type==="context-divider"||E.type==="message"&&(E.message.messageKind==="auto-prompt"||E.message.role==="assistant"&&!((T=E.message.content)!=null&&T.trim())&&!((L=E.message.thinkingContent)!=null&&L.trim())))}),[n]),C=j.useMemo(()=>w.filter(E=>{const T=nG(E);return!(T&&!d.has(T))}),[w,d]),v=j.useMemo(()=>a?w.filter(E=>{const T=Jk(E);return aa(T,a)}):C,[C,a]),S=v.length-1;j.useEffect(()=>{if(e){o(""),u(0);const E=setTimeout(()=>{var T;Gt()&&((T=m.current)==null||T.focus())},50);return()=>clearTimeout(E)}},[e]),j.useEffect(()=>{var E;if(e&&f.current){const T=(E=f.current.osInstance())==null?void 0:E.elements().viewport;T&&(T.scrollTop=T.scrollHeight)}},[e]),j.useEffect(()=>{g.current&&g.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[c]);const _=E=>{qT(E,S,u,()=>{const T=v[c];if(T){const L=n.indexOf(T);L>=0&&r(L),t()}},t)},b=E=>{const T=n.indexOf(E);T>=0&&r(T),t()},k=E=>n.indexOf(E);return e?wi.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),s.jsxs("div",{className:"relative w-full max-w-lg bg-bg-secondary border border-border rounded shadow-xl",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[s.jsx(_i,{}),s.jsx("input",{ref:m,type:"text",value:a,onChange:E=>{o(E.target.value),u(0)},onKeyDown:_,placeholder:"Search timeline...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),s.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:s.jsx(Ss,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"flex gap-1.5 px-4 py-2 border-b border-border",children:ZW.map(E=>{const T=d.has(E.key);return s.jsx("button",{type:"button",onClick:()=>x(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)})}),s.jsx(pt,{ref:f,className:"max-h-[60vh] p-2",children:v.length===0?s.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 L=k(E),A=aG(E),O=Jk(E),M=iG(E),H=sG(E),B=E.type==="message"&&E.message.role==="user";return s.jsx("button",{ref:T===c?g:null,type:"button",onClick:()=>b(E),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${T===c?"bg-accent-primary/20 text-text-primary":B?"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:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[s.jsx("span",{className:"flex-shrink-0",children:A}),s.jsx("span",{className:`truncate flex-1 ${M}`,children:O})]}),H&&s.jsx("span",{className:"text-text-muted text-xs shrink-0",children:rG(H)})]})},`${L}-${E.type}`)})})]})]}),document.body):null}function zA(e){const t=new Set,n=[],r=/\{\{(\w+)\}\}/g;let a;for(;(a=r.exec(e))!==null;){const o=a[1];t.has(o)||(t.add(o),n.push(o))}return n}function lG(e,t,n){const r=e.trim();if(!r.startsWith("/"))return null;const a=r.slice(1).split(/\s+/),o=a[0];if(!o)return null;const c=a.slice(1),u={},d=t.find(h=>h.id===o);return d?(d.parameters&&d.parameters.length>0?[...d.parameters].sort((m,f)=>(m.position??0)-(f.position??0)).forEach((m,f)=>{c[f]!==void 0&&(u[m.id]=c[f])}):c.forEach((h,m)=>{u[String(m)]=h}),{workflowId:o,params:u}):n&&n.find(m=>m.id===o)?(c.forEach((m,f)=>{u[String(f)]=m}),{commandId:o,params:u}):null}function cG({history:e,selectedIndex:t,onSelect:n,onEscape:r,onNavigate:a}){const o=j.useRef(null),c=j.useRef(null);j.useEffect(()=>{var h;c.current&&((h=o.current)!=null&&h.getElement())&&c.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[t]);const u=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 s.jsx(pt,{ref:o,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg max-h-64",onKeyDown:u,children:e.map((h,m)=>s.jsxs("div",{ref:m===t?c:null,role:"listitem",onClick:()=>d(h.content),className:`
|
|
317
|
+
p-2 rounded cursor-pointer transition-colors
|
|
318
|
+
${m===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
|
|
319
|
+
`,children:[s.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[h.formattedTimestamp,h.sessionName&&s.jsxs(s.Fragment,{children:[" | ",s.jsx("span",{className:"text-accent-primary font-medium",children:h.sessionName})]})]}),s.jsx("div",{className:"text-sm text-text-primary mt-1",children:h.trimmedContent})]},h.id))})}function uG(){const e=P3(),t=e?"bg-amber-400":"bg-accent-primary";return s.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("span",{className:"flex gap-0.5",children:[s.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"0ms"}}),s.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"150ms"}}),s.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"300ms"}})]}),s.jsx("span",{className:"text-text-secondary",children:e?"Running... (abort in progress)":"Running"})]}),!e&&s.jsx("span",{className:"text-text-muted hidden sm:inline",children:"esc to interrupt"})]})}function dG(){const e=Er(),t=cn(e,u=>u.activeWorkflowExecution??null,u=>u.activeWorkflowExecution,null),n=Oe(u=>u.exitWorkflow),[r,a]=j.useState(!1);j.useEffect(()=>{a(!1)},[t==null?void 0:t.id]);const o=j.useCallback(()=>{r||!e||(a(!0),n(e))},[r,n,e]);if(!t||t.status!=="running"&&t.status!=="waiting")return null;const c=t.workflowColor&&/^#[0-9a-fA-F]{6}$/.test(t.workflowColor)?t.workflowColor:"#3b82f6";return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs border-b border-border",children:[s.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:c}}),s.jsx("span",{className:"font-medium text-text-primary truncate",children:t.workflowName}),t.currentStepName&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{className:"text-text-muted truncate",children:t.currentStepName})]}),s.jsx("div",{className:"ml-auto shrink-0",children:s.jsx("button",{onClick:o,disabled:r,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:r?"Exiting...":"✕ Exit"})})]})}function UA(e,t){const n=Oe(c=>c.sendMessage),r=Oe(c=>c.launchWorkflow),a=j.useCallback((c,u,d)=>{e(!0),t&&n(t,c,u,d)},[e,n,t]),o=j.useCallback((c,u,d,h,m,f="auto")=>{e(!0),t&&r(t,c,u,d,h,m,f)},[e,r,t]);return{sendMessage:a,launchWorkflow:o}}function hG({children:e}){return wi.createPortal(e,document.body)}function fG(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 mG({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:r,onOpenWorkflowsManager:a,onAttach:o,textareaContent:c,attachments:u}){const[d,h]=j.useState(!1),[m,f]=j.useState("commands"),[g,x]=j.useState(""),[w,C]=j.useState(0),[v,S]=j.useState(null),[_,b]=j.useState(null),k=j.useRef(null),E=j.useRef(null),T=fn(U=>U.defaults),L=fn(U=>U.userItems),A=fn(U=>U.projectItems),O=fn(U=>U.fetchCommands),M=Wt(U=>U.fetchWorkflows),H=Oe(U=>{var $;return($=U.currentSession)==null?void 0:$.workdir}),B=Gn(Gn(T,L),A),F=bm();j.useEffect(()=>{d&&(m==="commands"?O(H):m==="workflows"&&M(H))},[d,m,O,M,H]),j.useEffect(()=>{d&&(x(""),C(0),requestAnimationFrame(()=>{var U;Gt()&&((U=k.current)==null||U.focus())}))},[d,m]),j.useEffect(()=>{if(!d)return;const U=$=>{var te;(te=E.current)!=null&&te.contains($.target)||h(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[d]);const K=U=>{switch(U.key){case"ArrowDown":U.preventDefault(),C($=>{const q=(m==="commands"?B:F).filter(X=>{const Y=g.toLowerCase();return!Y||X.name.toLowerCase().includes(Y)});return Math.min($+1,q.length-1)});break;case"ArrowUp":U.preventDefault(),C($=>Math.max($-1,0));break;case"Enter":U.preventDefault();break;case"Escape":U.preventDefault(),h(!1);break}},G=U=>{x(U),C(0)},V=B.filter(U=>!g||U.name.toLowerCase().includes(g.toLowerCase())),Z=F.filter(U=>!g||U.name.toLowerCase().includes(g.toLowerCase())),J=async U=>{const $=await fn.getState().fetchCommand(U,H);$&&e($.prompt,$.metadata.agentMode,c,u),h(!1)},z=(U,$)=>{t(U,$),h(!1)},P=(U,$)=>{$.stopPropagation(),h(!1),S(U)},D=(U,$)=>{$.stopPropagation(),h(!1),b(U)};return s.jsxs("div",{ref:E,className:"relative",children:[s.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:s.jsx(kE,{className:"w-4 h-4"})}),d&&s.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:[s.jsxs("div",{className:"flex border-b border-border",children:[s.jsx("button",{type:"button",onClick:()=>{f("commands"),x(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="commands"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Commands"}),s.jsx("button",{type:"button",onClick:()=>{f("workflows"),x(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="workflows"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Workflows"}),s.jsx("button",{type:"button",onClick:()=>f("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),m!=="attach"&&s.jsx("div",{className:"p-2 border-b border-border",children:s.jsx("input",{ref:k,value:g,onChange:U=>G(U.target.value),onKeyDown:K,placeholder:m==="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"})}),s.jsx(pt,{className:"max-h-64 p-1",children:m==="commands"?V.length===0?s.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:B.length===0?"No commands yet":"No matches"}):V.map((U,$)=>s.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${$===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[s.jsx("button",{type:"button",onClick:()=>J(U.id),className:"flex-1 text-left",children:s.jsx("div",{className:"text-sm text-text-primary font-medium",children:U.name})}),s.jsx(vi,{className:"opacity-0 group-hover:opacity-100",onClick:te=>P(U.id,te)})]},U.id)):m==="workflows"?Z.length===0?s.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:F.length===0?"No workflows yet":"No matches"}):Z.map((U,$)=>{const te=fG(U),q=U.color??"#3b82f6";return s.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${$===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[s.jsxs("button",{type:"button",onClick:()=>z(U.id,U.scope),className:"flex-1 text-left flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:q}}),s.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:U.name}),s.jsx("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded whitespace-nowrap",children:vv[U.scope]}),te!==null&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:te?"#22c55e":"#6b7280"},title:te?"Entry condition met":"Entry condition not met"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[U.subGroups&&U.subGroups.length>0&&s.jsx(pG,{subGroups:U.subGroups,onSelect:X=>{h(!1),n(U.id,X,U.scope)}}),s.jsx(vi,{className:"opacity-0 group-hover:opacity-100",onClick:X=>D(U.id,X)})]})]},`${U.id}-${U.scope}`)}):s.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>{o(),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:[s.jsx(wE,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-medium",children:"Attach file"})]}),s.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),m!=="attach"&&s.jsx("div",{className:"border-t border-border p-1",children:s.jsx("button",{type:"button",onClick:()=>{h(!1),m==="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:m==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),s.jsx(PA,{isOpen:!!v,onClose:()=>S(null),initialEditId:v,projectDir:H}),s.jsx(FA,{isOpen:!!_,onClose:()=>b(null),initialEditId:_})]})}function pG({subGroups:e,onSelect:t}){const[n,r]=j.useState(!1),[a,o]=j.useState({top:0,right:0}),c=j.useRef(null),u=j.useRef(null);_m(u,()=>r(!1),n);const d=h=>{if(h.stopPropagation(),!n&&c.current){const m=c.current.getBoundingClientRect();o({top:m.bottom+4,right:window.innerWidth-m.right})}r(!n)};return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:c,type:"button",onClick:d,className:"p-1 rounded text-text-muted hover:text-text-primary transition-colors",title:"Sub-groups",children:"⋮"}),n&&s.jsx(hG,{children:s.jsx("div",{ref:u,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=>s.jsx("button",{type:"button",onClick:m=>{m.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 gG({messages:e,onCancel:t}){return e.length===0?null:s.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:e.map(n=>s.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:[s.jsxs("span",{className:"font-medium",children:[n.mode==="asap"?"ASAP":"Queue",":"]}),s.jsx("span",{className:"truncate max-w-[200px]",children:n.content}),s.jsx(Pu,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function xG({agent:e,isBuiltIn:t,isConfirmingDelete:n,alwaysAllowedNames:r,model:a,onView:o,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h}){var g;const m=e.allowedTools.filter(x=>!(r!=null&&r.has(x))),f=a?(g=a.split("/").pop())==null?void 0:g.replace(/-/g," "):void 0;return s.jsxs(BE,{isBuiltIn:t,isConfirmingDelete:n,onView:o,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:e.color??"#6b7280"}}),s.jsx("span",{className:"text-text-primary text-sm font-medium",children:e.name}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:e.id}),t&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"}),f&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-accent-primary/10 text-accent-primary",children:f})]}),e.description&&s.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[m.slice(0,5).map(x=>s.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:x},x)),m.length>5&&s.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",m.length-5," more"]})]})]})}function Zk({title:e,agentTitle:t="Agents",subagentTitle:n="Sub-agents",agents:r,subagents:a,isBuiltIn:o,alwaysAllowedNames:c,modelOverrides:u,onView:d,onDuplicate:h,onEdit:m,onDelete:f,onCancelDelete:g,isConfirmingDelete:x}){if(r.length===0&&a.length===0)return null;const w=C=>s.jsx(xG,{agent:C,model:u==null?void 0:u[C.id],isBuiltIn:o,isConfirmingDelete:(x==null?void 0:x(C.id))??!1,alwaysAllowedNames:c,onView:()=>d(C.id),onEdit:m?()=>m(C.id):void 0,onDuplicate:()=>h(C.id),onDelete:o?void 0:()=>f==null?void 0:f(C.id),onCancelDelete:o?void 0:()=>g==null?void 0:g(C.id)},C.id);return s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),r.length>0&&s.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:t}),s.jsxs("div",{className:"space-y-2",children:[r.map(w),a.length>0&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:n}),s.jsx("div",{className:"space-y-2",children:a.map(w)})]})]})]})}function yG(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),c=n.slice(r+1).split(",").filter(Boolean);t.set(a,new Set(c))}}return t}function Ah(e){const t=[];for(const[n,r]of e)r.size===0?t.push(n):t.push(`${n}:${[...r].join(",")}`);return t}function bG({formName:e,formId:t,formDescription:n,formSubagent:r,formTools:a,formColor:o,formModel:c,formPrompt:u,formError:d,isReadOnly:h,availableTools:m,providers:f,onNameChange:g,onIdChange:x,onDescriptionChange:w,onSubagentChange:C,onToolsChange:v,onColorChange:S,onModelChange:_,onPromptChange:b}){const k=yG(a),E=m.filter(M=>!(r&&M.topLevelOnly)&&!M.isMcp),T=m.filter(M=>M.isMcp&&!(r&&M.topLevelOnly)),L=new Map;for(const M of T){const H=M.mcpServer??M.name,B=L.get(H)??[];B.push(M),L.set(H,B)}const A=(M,H)=>{const B=new Map(k),F=B.get(M)||new Set,K=new Set(F);K.has(H)?K.delete(H):K.add(H),K.size===0?B.set(M,new Set):B.set(M,K),v(Ah(B))},O=M=>{const H=new Map(k);H.has(M)?H.delete(M):H.set(M,new Set),v(Ah(H))};return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"space-y-3",children:[d&&s.jsx(_l,{message:d}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(ss,{label:"Name",value:e,onChange:g,placeholder:"My Agent",readOnly:h}),s.jsx(ss,{label:"ID",value:t,onChange:x,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(ss,{label:"Description",value:n,onChange:w,placeholder:"What this agent does",readOnly:h}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),s.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[s.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"}),s.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"}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),s.jsx("input",{type:"color",value:o,onChange:M=>!h&&S(M.target.value),disabled:h,className:"w-6 h-6 rounded cursor-pointer border border-border bg-transparent"})]})]})]})]}),!h&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Model override"}),s.jsx(bv,{providers:f,value:c,onChange:_,defaultLabel:"Default (global model)"}),s.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)."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Tools"}),s.jsx(pt,{className:"flex flex-wrap gap-1.5 p-2 bg-bg-tertiary border border-border rounded max-h-32",children:E.map(M=>{const H=k.has(M.name),B=M.actions.length>0,F=k.get(M.name)||new Set;return B?h?s.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:[s.jsx("span",{children:M.name}),s.jsx("span",{className:"text-[10px]",children:"*"})]},M.name):s.jsx(ho,{trigger:s.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${H?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} cursor-pointer`,children:[s.jsx("span",{children:M.name}),F.size>0&&s.jsx("span",{className:"text-[10px]",children:"*"})]}),minWidth:"160px",items:[...M.actions.map(K=>({label:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${M.name}-${K}`,children:[s.jsx("input",{type:"checkbox",id:`${M.name}-${K}`,checked:F.has(K),onChange:()=>A(M.name,K),disabled:h,className:"w-3 h-3 rounded accent-accent-primary"}),s.jsx("span",{children:K})]}),closeOnClick:!1})),{label:H?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(H)O(M.name);else{const K=new Map(k);K.set(M.name,new Set(M.actions)),v(Ah(K))}}}]},M.name):s.jsx("button",{onClick:()=>!h&&O(M.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${H?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none":"cursor-pointer"}`,children:s.jsx("span",{children:M.name})},M.name)})})]}),L.size>0&&(()=>{const M=new Set(T.map(G=>G.name)),H=k.has("__mcp_none__"),B=[...k.keys()].some(G=>M.has(G)),F=H?"none":B?"partial":"all",K=G=>{const V=new Map(k);for(const Z of V.keys())(Z==="__mcp_none__"||M.has(Z))&&V.delete(Z);if(G==="none"&&V.set("__mcp_none__",new Set),G==="partial")for(const Z of M)V.set(Z,new Set);v(Ah(V))};return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["MCP Tools ",s.jsx("span",{className:"text-text-muted font-normal",children:"— from connected MCP servers"})]}),s.jsxs("div",{className:"bg-bg-tertiary border border-border rounded overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-4 px-3 py-1.5",children:["all","none","partial"].map(G=>s.jsxs("label",{className:`flex items-center gap-1.5 text-xs cursor-pointer ${h?"pointer-events-none opacity-60":""}`,children:[s.jsx("input",{type:"radio",name:"mcp-mode",checked:F===G,onChange:()=>K(G),disabled:h,className:"w-3 h-3 accent-accent-primary"}),s.jsxs("span",{className:F===G?"text-text-primary font-medium":"text-text-muted",children:[G.charAt(0).toUpperCase()+G.slice(1),G==="partial"&&M.size>0&&s.jsxs("span",{className:"ml-1 text-text-muted font-normal",children:["(",[...k.keys()].filter(V=>M.has(V)).length,"/",M.size,")"]})]})]},G))}),F==="partial"&&(()=>{const[G,V]=j.useState(""),[Z,J]=j.useState(0),z=j.useRef(null),P=$=>{var q;const te=(q=z.current)==null?void 0:q.querySelector(`[data-idx="${$}"]`);te==null||te.scrollIntoView({block:"nearest"})};j.useEffect(()=>{P(Z)},[Z]);const D=G?T.filter($=>$.name.toLowerCase().includes(G.toLowerCase())):T,U=$=>{$.key==="ArrowDown"?($.preventDefault(),J(te=>Math.min(te+1,D.length-1))):$.key==="ArrowUp"?($.preventDefault(),J(te=>Math.max(te-1,0))):$.key==="Enter"&&D[Z]&&($.preventDefault(),O(D[Z].name))};return s.jsxs("div",{children:[s.jsx("div",{className:"px-3 py-2 border-b border-border",children:s.jsx("input",{type:"text",value:G,onChange:$=>{V($.target.value),J(0)},onKeyDown:U,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"})}),s.jsx(pt,{className:"max-h-60",children:s.jsxs("div",{ref:z,children:[D.map(($,te)=>{const q=k.has($.name),X=te===Z;return s.jsxs("div",{"data-idx":te,className:`flex items-center justify-between px-3 py-1.5 transition-colors ${X?"bg-bg-primary":"hover:bg-bg-primary/30"}`,onMouseEnter:()=>J(te),children:[s.jsx("span",{className:`text-xs font-mono ${q?"text-text-primary":"text-text-muted"}`,children:$.name}),s.jsx(xs,{enabled:q,onClick:()=>O($.name),label:$.name})]},$.name)}),D.length===0&&s.jsx("div",{className:"px-3 py-2 text-xs text-text-muted",children:"No MCP tools match your search."})]})})]})})()]})]})})()]}),s.jsxs("div",{className:"flex-1 min-h-[150px] pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),s.jsx("textarea",{value:u,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 vG(e){const t=e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"");return t?`custom-${t}`:""}function _G({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){const a=dt(ke=>ke.defaults),o=dt(ke=>ke.userItems),c=dt(ke=>ke.projectItems),u=dt(ke=>ke.loading),d=dt(ke=>ke.fetchAgents),h=dt(ke=>ke.fetchAgent),m=dt(ke=>ke.fetchDefaultContent),f=dt(ke=>ke.createAgent),g=dt(ke=>ke.updateAgent),x=dt(ke=>ke.deleteAgent),[w,C]=j.useState("list"),[v,S]=j.useState(null),[_,b]=j.useState(!1),[k,E]=j.useState(""),[T,L]=j.useState(""),[A,O]=j.useState(""),[M,H]=j.useState(!1),[B,F]=j.useState([]),[K,G]=j.useState("#6b7280"),[V,Z]=j.useState(void 0),[J,z]=j.useState(""),[P,D]=j.useState("user"),[U,$]=j.useState(""),[te,q]=j.useState(!1),[X,Y]=j.useState(!1),[I,Q]=j.useState(null),ne=Er(),[re,ie]=j.useState([]),[pe,ye]=j.useState(new Set),{requestDelete:Ie,clearConfirm:$e,isConfirming:Se}=Tu(),Ge=ke=>{E(ke.metadata.name),L(ke.metadata.id),O(ke.metadata.description),H(ke.metadata.subagent),F(ke.metadata.allowedTools),G(ke.metadata.color??"#6b7280"),z(ke.prompt),$(""),Y(!0),me(`/api/agents/${ke.metadata.id}/model`).then(We=>We.json()).then(We=>{We.providerId&&We.model?Z(`${We.providerId}/${We.model}`):Z(void 0)}).catch(()=>Z(void 0)).finally(()=>Y(!1))},Je=(ke,We,Ce)=>{E(ke.metadata.name+" (copy)"),L(`${We}-copy-${Date.now()}`),O(ke.metadata.description),H(ke.metadata.subagent),F(ke.metadata.allowedTools),G(ke.metadata.color??"#6b7280"),z(ke.prompt),$(""),S(null),b(!1),C("edit")},_e=(ke,We)=>{Ge(ke),S(We),b(!0),C("edit")};j.useEffect(()=>{e&&(d(r),me("/api/tools").then(ke=>ke.json()).then(ke=>{const We=ke.tools||[];ye(new Set(We.filter(Ce=>Ce.alwaysAllowed).map(Ce=>Ce.name))),ie(We.filter(Ce=>!Ce.alwaysAllowed))}).catch(()=>{ie([]),ye(new Set)}),n?a.some(We=>We.id===n)?m(n).then(We=>{We&&Je(We,n)}):h(n,r).then(We=>{We&&(Ge(We),S(n),b(!1),C("edit"))}):(C("list"),S(null),b(!1)))},[e,d,h,m,n,r]);const ge=async ke=>{if(a.some(Ce=>Ce.id===ke)){const Ce=await m(ke);if(!Ce)return;_e(Ce,ke)}else{const Ce=await h(ke,r);if(!Ce)return;_e(Ce,ke)}},he=async ke=>{let We=await m(ke);We||(We=await h(ke,r)),We&&Je(We,ke)},ae=()=>{S(null),E(""),L(""),O(""),H(!1),F(["read_file"]),G("#6b7280"),z(""),D("user"),$(""),b(!1),C("edit")},Pe=async ke=>{const We=await h(ke,r);We&&(Ge(We),S(ke),b(!1),C("edit"))},Ue=ke=>{Q(ke)},de=async ke=>{await x(ke,r)},Ae=async()=>{var Lt;const ke=v??T;if(!ke||!k||!J){$("Name and prompt are required.");return}q(!0),$("");const We={metadata:{id:ke,name:k,description:A,subagent:M,allowedTools:B.filter(qt=>!pe.has(qt)),color:K},prompt:J},Ce=v?await g(v,We,r):await f(We,P,r);if(!Ce.success){q(!1),$(Ce.error??"Failed to save agent.");return}await VA(v??T,V),await d(r);const nt=v??T,tt=ne,ht=tt?((Lt=Oe.getState().panes[tt])==null?void 0:Lt.session)??null:Oe.getState().currentSession;if((ht==null?void 0:ht.mode)===nt&&V&&tt){const{providerId:qt,model:bn}=Av(V);Oe.getState().setSessionProvider(tt,qt,bn)}q(!1),n?t():C("list")},ue=()=>{n?t():(C("list"),b(!1))},Fe=ke=>{E(ke),v||L(vG(ke))},Xe=dt(ke=>ke.modelOverrides),it=a.filter(ke=>ke.subagent),Ze=a.filter(ke=>!ke.subagent),lt=o.filter(ke=>ke.subagent),gt=o.filter(ke=>!ke.subagent),De=c.filter(ke=>ke.subagent),Re=c.filter(ke=>!ke.subagent);return w==="edit"?s.jsxs(s.Fragment,{children:[s.jsxs(Et,{isOpen:e,onClose:ue,title:_?`${k}`:v?"Edit Agent":"New Agent",size:"xl",footer:_?s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{onClick:()=>{E(k+" (copy)"),L(`${v}-copy-${Date.now()}`),S(null),b(!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"})}):s.jsx(AE,{onCancel:ue,onSave:Ae,saving:te,saveDisabled:!k||!J||X}),children:[!v&&!_&&s.jsx(Xf,{value:P,onChange:D}),s.jsx(bG,{formName:k,formId:T,formDescription:A,formSubagent:M,formTools:B,formColor:K,formModel:V,formPrompt:J,formError:U,isReadOnly:_,availableTools:re,providers:an.getState().providers,onNameChange:Fe,onIdChange:L,onDescriptionChange:O,onSubagentChange:ke=>{H(ke),ke&&F(We=>We.filter(Ce=>{var nt;return!((nt=re.find(tt=>tt.name===Ce))!=null&&nt.topLevelOnly)}))},onToolsChange:F,onColorChange:G,onModelChange:Z,onPromptChange:z})]}),s.jsx(ej,{agentId:I,onClose:()=>Q(null),onSaved:()=>d(r)})]}):s.jsxs(s.Fragment,{children:[s.jsx(Et,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:s.jsx(LE,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:ae,loading:u,hasItems:a.length>0||o.length>0||c.length>0,children:s.jsxs("div",{className:"space-y-4",children:[a.length>0&&s.jsx(Zk,{title:"Built-in",agents:Ze,subagents:it,isBuiltIn:!0,alwaysAllowedNames:pe,modelOverrides:Xe,onView:ge,onEdit:Ue,onDuplicate:he}),(gt.length>0||lt.length>0||Re.length>0||De.length>0)&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Custom"}),s.jsx("div",{className:"ml-3 space-y-3",children:[{title:"Global",agents:gt,subagents:lt},{title:"Project",agents:Re,subagents:De}].map(ke=>(ke.agents.length>0||ke.subagents.length>0)&&s.jsx(Zk,{title:ke.title,agents:ke.agents,subagents:ke.subagents,isBuiltIn:!1,alwaysAllowedNames:pe,modelOverrides:Xe,isConfirmingDelete:We=>Se(We,"delete"),onView:ge,onDuplicate:he,onEdit:Pe,onDelete:We=>{Se(We,"delete")?(de(We),$e()):Ie(We)},onCancelDelete:$e},ke.title))})]})]})})}),s.jsx(ej,{agentId:I,onClose:()=>Q(null),onSaved:()=>d(r)})]})}function Av(e){const t=e.indexOf("/");return t>0?{providerId:e.substring(0,t),model:e.substring(t+1)}:{providerId:e,model:e}}async function VA(e,t){if(t){const{providerId:n,model:r}=Av(t);await me(`/api/agents/${e}/model`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})})}else await me(`/api/agents/${e}/model`,{method:"DELETE"})}function ej({agentId:e,onClose:t,onSaved:n}){const[r,a]=j.useState(void 0),[o,c]=j.useState(!1),[u,d]=j.useState(!1),[h,m]=j.useState(null),f=dt(b=>b.defaults),g=dt(b=>b.userItems),x=dt(b=>b.projectItems),w=[...f,...g,...x],C=e?w.find(b=>b.id===e):void 0,v=an(b=>b.providers),S=Er();j.useEffect(()=>{e&&(c(!0),me(`/api/agents/${e}/model`).then(b=>b.json()).then(b=>{a(b.providerId&&b.model?`${b.providerId}/${b.model}`:void 0)}).catch(()=>a(void 0)).finally(()=>c(!1)))},[e]);const _=async()=>{var b;if(e){d(!0),m(null);try{await VA(e,r);const k=S,E=k?((b=Oe.getState().panes[k])==null?void 0:b.session)??null:Oe.getState().currentSession;if((E==null?void 0:E.mode)===e&&r&&k){const{providerId:T,model:L}=Av(r);Oe.getState().setSessionProvider(k,T,L)}n(),t()}catch{m("Failed to save. Please try again.")}d(!1)}};return s.jsx(Et,{isOpen:!!e,onClose:t,title:`Model — ${(C==null?void 0:C.name)??e??""}`,size:"md",children:s.jsxs("div",{className:"space-y-4 p-2",children:[s.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."}),o?s.jsx("div",{className:"text-sm text-text-muted py-2",children:"Loading..."}):s.jsx(bv,{providers:v,value:r,onChange:a,defaultLabel:"Default (global model)"}),h&&s.jsx("p",{className:"text-xs text-red-500",children:h}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx("button",{onClick:t,className:"px-4 py-1.5 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),s.jsx("button",{onClick:_,disabled:u,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:u?"Saving...":"Save"})]})]})})}function SG(){const e=Er(),t=cn(e,E=>{var T;return((T=E.session)==null?void 0:T.mode)??null},E=>{var T;return((T=E.currentSession)==null?void 0:T.mode)??null},null),n=cn(e,E=>{var T;return((T=E.session)==null?void 0:T.workdir)??void 0},E=>{var T;return(T=E.currentSession)==null?void 0:T.workdir},void 0),r=Oe(E=>E.switchMode),a=dt(E=>E.defaults),o=dt(E=>E.userItems),c=dt(E=>E.projectItems),u=dt(E=>E.fetchAgents),d=[...a,...o,...c],[h,m]=j.useState(!1),[f,g]=j.useState(!1),[x,w]=j.useState(null),C=j.useRef(null);j.useEffect(()=>{u(n)},[u,n]),_m(C,()=>m(!1));const v=Nu();if(!t)return null;const S=d.filter(E=>!E.subagent),_=S.find(E=>E.id===t),b=(_==null?void 0:_.name)??t,k=oo(d,t);return s.jsxs("div",{className:"relative",ref:C,children:[s.jsxs("button",{type:"button",onClick:()=>m(!h),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[s.jsx("span",{className:"text-sm font-medium",style:{color:k},children:b}),s.jsx(gn,{className:`w-3 h-3 text-text-muted transition-transform ${h?"rotate-180":""}`})]}),h&&S.length>0&&s.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:[S.map((E,T)=>{const L=E.id===t,A=oo(d,E.id),O=v.agentSwitching[T],M=O?Eb(O):null;return s.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors group ${L?"bg-bg-tertiary":"hover:bg-bg-tertiary cursor-pointer"}`,children:[s.jsxs("button",{type:"button",onClick:()=>{!L&&e&&r(e,E.id),m(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",style:{color:A},children:E.name}),L&&s.jsx(Hs,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),M&&s.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:M})]},E.id)}),s.jsx("div",{className:"border-t border-border p-1",children:s.jsx("button",{type:"button",onClick:()=>{m(!1),g(!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..."})})]}),s.jsx(_G,{isOpen:f,onClose:()=>{g(!1),w(null)},initialEditId:x,projectDir:n})]})}function wG(){const e=Er(),t=cn(e,r=>{var a;return((a=r.session)==null?void 0:a.dangerLevel)??"normal"},r=>{var a;return((a=r.currentSession)==null?void 0:a.dangerLevel)??"normal"},"normal"),n=Oe(r=>r.switchDangerLevel);return e?s.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[s.jsx("button",{type:"button",onClick:()=>n(e,"normal"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${t==="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"}),s.jsx("button",{type:"button",onClick:()=>n(e,"dangerous"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${t==="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"})]}):null}function tj({value:e,onChange:t}){return s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Query params ",s.jsx("span",{className:"text-text-muted",children:"(optional JSON)"})]}),s.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 CG=[8080,11434,8e3,1234];function Yy(e){if(e!=null&&e.length)return e.includes("medium")?"medium":e[0]}function WA(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 kG({model:e,modelConfigs:t,autoConfigState:n,testResults:r,onUpdateConfig:a,onRunAutoConfig:o,onTestParams:c,onShowRaw:u}){var d,h,m,f,g,x,w,C,v,S,_,b,k,E,T,L,A,O,M,H,B,F,K,G,V,Z,J,z,P,D,U,$,te,q,X,Y,I,Q,ne,re,ie,pe,ye,Ie,$e;return s.jsxs("div",{className:"px-4 pb-4 border-t border-border pt-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>o(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"&&s.jsx("span",{className:"text-sm text-accent-success font-medium",children:"Configured ✓"}),n.progress[e.id]==="error"&&s.jsx("span",{className:"text-sm text-red-500 font-medium",children:"Failed ✗"})]}),s.jsxs("div",{className:"flex gap-3 items-end",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Context window (tokens)"}),s.jsx("input",{type:"number",value:((d=t[e.id])==null?void 0:d.contextWindow)??e.contextWindow,onChange:Se=>a(e.id,{contextWindow:parseInt(Se.target.value)||e.contextWindow}),className:"w-32 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),s.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary pb-1",children:[s.jsx("input",{type:"checkbox",checked:((h=t[e.id])==null?void 0:h.supportsVision)??!1,onChange:Se=>a(e.id,{supportsVision:Se.target.checked}),className:"accent-accent-primary"})," ","Supports vision"]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>c(e.id,"thinking"),disabled:(m=r[e.id+"-thinking"])==null?void 0:m.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:(f=r[e.id+"-thinking"])!=null&&f.loading?"Testing...":"Test thinking"}),((g=r[e.id+"-thinking"])==null?void 0:g.result)&&s.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((x=r[e.id+"-thinking"])==null?void 0:x.error)&&s.jsx("span",{className:"text-xs text-red-500",title:(w=r[e.id+"-thinking"])==null?void 0:w.error,children:"Fail"}),((C=r[e.id+"-thinking"])==null?void 0:C.result)&&s.jsx("button",{onClick:()=>u(r[e.id+"-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>c(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:(S=r[e.id+"-non-thinking"])!=null&&S.loading?"Testing...":"Test non-thinking"}),((_=r[e.id+"-non-thinking"])==null?void 0:_.result)&&s.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((b=r[e.id+"-non-thinking"])==null?void 0:b.error)&&s.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)&&s.jsx("button",{onClick:()=>u(r[e.id+"-non-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]})]}),s.jsxs("details",{className:"group",children:[s.jsxs("summary",{className:"text-xs text-text-muted cursor-pointer hover:text-text-secondary list-none flex items-center gap-1 select-none",children:[s.jsx(gn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),"Advanced: thinking & non-thinking params"]}),s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:((T=t[e.id])==null?void 0:T.thinkingEnabled)??!1,onChange:Se=>a(e.id,{thinkingEnabled:Se.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),s.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Thinking"})]}),((L=t[e.id])==null?void 0:L.thinkingEnabled)&&s.jsxs("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-primary/30",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Reasoning effort"}),(A=e.reasoningEfforts)!=null&&A.length?s.jsx("select",{"aria-label":"Reasoning effort",value:((O=t[e.id])==null?void 0:O.thinkingLevel)??Yy(e.reasoningEfforts),onChange:Se=>a(e.id,{thinkingLevel:Se.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(Se=>s.jsx("option",{value:Se,children:Se},Se))}):s.jsx("input",{type:"text","aria-label":"Reasoning effort",value:((M=t[e.id])==null?void 0:M.thinkingLevel)??"",onChange:Se=>a(e.id,{thinkingLevel:Se.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),s.jsx(tj,{value:(H=t[e.id])==null?void 0:H.thinkingQueryParams,onChange:Se=>a(e.id,{thinkingQueryParams:Se})})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:((B=t[e.id])==null?void 0:B.nonThinkingEnabled)??!1,onChange:Se=>a(e.id,{nonThinkingEnabled:Se.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),s.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Non-thinking"})]}),((F=t[e.id])==null?void 0:F.nonThinkingEnabled)&&s.jsx("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:s.jsx(tj,{value:(K=t[e.id])==null?void 0:K.nonThinkingQueryParams,onChange:Se=>a(e.id,{nonThinkingQueryParams:Se})})})]}),s.jsxs("div",{className:"border-t border-border pt-3 mt-3",children:[s.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Sampling parameters"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Temperature"}),s.jsx("input",{type:"number",step:"0.1",value:((G=t[e.id])==null?void 0:G.temperature)??"",onChange:Se=>a(e.id,{temperature:Se.target.value?parseFloat(Se.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"}),((J=t[e.id])==null?void 0:J.defaultTemperature)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(z=t[e.id])==null?void 0:z.defaultTemperature]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top P"}),s.jsx("input",{type:"number",step:"0.05",value:((P=t[e.id])==null?void 0:P.topP)??"",onChange:Se=>a(e.id,{topP:Se.target.value?parseFloat(Se.target.value):void 0}),placeholder:((U=(D=t[e.id])==null?void 0:D.defaultTopP)==null?void 0:U.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&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(te=t[e.id])==null?void 0:te.defaultTopP]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top K"}),s.jsx("input",{type:"number",value:((q=t[e.id])==null?void 0:q.topK)??"",onChange:Se=>a(e.id,{topK:Se.target.value?parseInt(Se.target.value):void 0}),placeholder:((Y=(X=t[e.id])==null?void 0:X.defaultTopK)==null?void 0:Y.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((I=t[e.id])==null?void 0:I.defaultTopK)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Q=t[e.id])==null?void 0:Q.defaultTopK]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Max tokens"}),s.jsx("input",{type:"number",value:((ne=t[e.id])==null?void 0:ne.maxTokens)??"",onChange:Se=>a(e.id,{maxTokens:Se.target.value?parseInt(Se.target.value):void 0}),placeholder:((ie=(re=t[e.id])==null?void 0:re.defaultMaxTokens)==null?void 0:ie.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((pe=t[e.id])==null?void 0:pe.defaultMaxTokens)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(ye=t[e.id])==null?void 0:ye.defaultMaxTokens]})]})]})]}),s.jsx("div",{className:"pt-3 border-t border-border",children:s.jsx(jG,{value:(Ie=t[e.id])==null?void 0:Ie.compactionThreshold,maxTokens:(($e=t[e.id])==null?void 0:$e.contextWindow)??e.contextWindow,onChange:Se=>a(e.id,{compactionThreshold:Se})})})]})]})}function jG({value:e,maxTokens:t,onChange:n}){const o=Math.min(95,Math.floor((t-5e3)/t*100)),c=Math.min(o,Math.ceil(15e3/t*100)),u=Math.min(e??.85,o/100),[d,h]=j.useState(Math.round(u*100));j.useEffect(()=>{const f=Math.min(e??.85,o/100);h(Math.round(f*100))},[e,o]);const m=Math.floor(t*(d/100));return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Auto-compaction threshold"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono text-xs text-text-primary",children:[d,"% · ",Al(m)]}),s.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"})]})]}),s.jsx("input",{"aria-label":"Auto-compaction threshold",type:"range",min:c,max:o,step:"1",value:d,onChange:f=>h(Number(f.target.value)),onMouseUp:()=>n(d/100),onTouchEnd:()=>n(d/100),onBlur:()=>n(d/100),onKeyUp:()=>n(d/100),className:"w-full"}),s.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:["Minimum ",Al(15e3)," tokens · maximum ",o,"% · default 85%"]})]})}function GA({isOpen:e,onClose:t,onSave:n,initialStep:r=1,editProvider:a,editModelId:o}){const[c,u]=j.useState(r),[d,h]=j.useState(""),[m,f]=j.useState(""),[g,x]=j.useState("unknown"),[w,C]=j.useState(""),[v,S]=j.useState(!1),[_,b]=j.useState(),[k,E]=j.useState(),[T,L]=j.useState(!1),[A,O]=j.useState(null),[M,H]=j.useState([]),[B,F]=j.useState(null),[K,G]=j.useState(!1),[V,Z]=j.useState(""),[J,z]=j.useState(!0),[P,D]=j.useState({}),[U,$]=j.useState({loading:!1,progress:{}}),[te,q]=j.useState({}),[X,Y]=j.useState(null),[I,Q]=j.useState(new Set),[ne,re]=j.useState(""),[ie,pe]=j.useState(null),[ye,Ie]=j.useState("disconnected"),[$e,Se]=j.useState(!1),[Ge,Je]=j.useState(null),[_e,ge]=j.useState([]),[he,ae]=j.useState(!1),[Pe,Ue]=j.useState(!1),[de,Ae]=j.useState(""),[ue,Fe]=j.useState(null),Xe=j.useRef(null),it=j.useRef(!1),Ze=j.useRef(null),lt=j.useRef(null);j.useEffect(()=>{c===1&&e&&requestAnimationFrame(()=>{var ve;Gt()&&((ve=Ze.current)==null||ve.focus())})},[c,e]),j.useEffect(()=>()=>{Xe.current!==null&&window.clearTimeout(Xe.current)},[]),j.useEffect(()=>{e&&me("/api/provider-presets").then(async ve=>ve.ok?await ve.json():{presets:[]}).then(ve=>ge(ve.presets)).catch(()=>ge([]))},[e]);function gt(ve,rt){D(Qe=>({...Qe,[ve]:{...Qe[ve],...rt}}))}function De(ve){Q(rt=>new Set(rt).add(ve.id)),D(rt=>({...rt,[ve.id]:{contextWindow:ve.contextWindow,...rt[ve.id]}}))}function Re(ve){if(!ve.trim())return M;const rt=ve.toLowerCase().split(/\s+/).filter(Boolean);return M.filter(Qe=>rt.every(Ve=>Qe.id.toLowerCase().includes(Ve)))}function ke(){const ve=de.trim();if(!ve){Fe("Enter a model name");return}const rt=Ye=>Ye.toLowerCase().replace(/[-_\s:.]+/g,""),Qe=rt(ve),Ve=M.find(Ye=>rt(Ye.id)===Qe);if(Ve){De(Ve),Fe(`"${Ve.id}" is already in the list`),Ae(""),!_&&U.progress[Ve.id]!=="probing"&&qt(Ve.id);return}const le={id:ve,contextWindow:2e5};H(Ye=>[...Ye,le]),Q(Ye=>new Set(Ye).add(le.id)),D(Ye=>({...Ye,[le.id]:{contextWindow:le.contextWindow,thinkingEnabled:!0}})),F(le.id),Ae(""),Fe(null),O(null)}j.useEffect(()=>{var ve,rt;if(e)if(u(r),h((a==null?void 0:a.name)??""),f((a==null?void 0:a.url)??""),x((a==null?void 0:a.backend)??"unknown"),C((a==null?void 0:a.apiKey)??""),S((a==null?void 0:a.isLocal)??!1),b(a==null?void 0:a.authAdapter),E(a==null?void 0:a.transportAdapter),O(null),Z((a==null?void 0:a.thinkingField)??""),z((a==null?void 0:a.sendReasoningInMessages)??!0),q({}),Y(null),pe(null),Ie("disconnected"),Je(null),ae(!1),Ue(!1),Ae(""),Fe(null),(ve=a==null?void 0:a.models)!=null&&ve.length){const Qe={},Ve=new Set;for(const le of a.models)Qe[le.id]={contextWindow:le.contextWindow,supportsVision:le.supportsVision,thinkingEnabled:le.thinkingEnabled,thinkingLevel:le.thinkingLevel??Yy(le.reasoningEfforts),nonThinkingEnabled:le.nonThinkingEnabled,thinkingQueryParams:le.thinkingQueryParams,nonThinkingQueryParams:le.nonThinkingQueryParams,defaultTemperature:le.defaultTemperature,defaultTopP:le.defaultTopP,defaultTopK:le.defaultTopK,defaultMaxTokens:le.defaultMaxTokens,temperature:le.temperature,topP:le.topP,topK:le.topK,maxTokens:le.maxTokens,compactionThreshold:le.compactionThreshold},le.selected&&Ve.add(le.id);if(Ve.size===0)for(const le of a.models)Ve.add(le.id);Q(Ve),D(Qe),H(a.models),F(o??((rt=a.models[0])==null?void 0:rt.id)??null)}else H([]),D({}),F(null),Q(new Set)},[e,r,a==null?void 0:a.id,o]),j.useEffect(()=>{const ve=!!_;c===2&&m&&M.length===0&&!T&&!A&&(!ve||ye==="connected")&&Lt(m)},[c,ye]),j.useEffect(()=>{!e||!_||!(a!=null&&a.id)||Ce(a.id)},[e,k,a==null?void 0:a.id]),j.useEffect(()=>{if(!Ge)return;const ve=(a==null?void 0:a.id)??ie;if(!ve)return;let rt=!1;const Qe=async()=>{const le=await Ce(ve);rt||le!=="connected"||(Je(null),ae(!1),Ue(!1),await Lt(m))};Qe();const Ve=window.setInterval(()=>void Qe(),2e3);return()=>{rt=!0,window.clearInterval(Ve)}},[Ge,ie,a==null?void 0:a.id]);async function We(){if(a!=null&&a.id)return a.id;if(ie)return ie;const ve=await me("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d||"Provider",url:m,backend:g,authAdapter:_,transportAdapter:k,isLocal:!1,models:[]})});if(!ve.ok)throw new Error("Unable to create provider");const rt=await ve.json();return pe(rt.provider.id),rt.provider.id}async function Ce(ve){const rt=await me(`/api/provider-auth/${ve}/status`);if(!rt.ok)return"error";const Qe=await rt.json(),Ve=Qe.state==="connected"?"connected":Qe.state==="pending"?"pending":Qe.state==="error"?"error":"disconnected";return Ie(Ve),Ve}async function nt(){Se(!0),Ie("pending");try{const ve=await We(),rt=await me(`/api/provider-auth/${ve}/login`,{method:"POST"});if(!rt.ok)throw new Error("Unable to start provider sign-in");const Qe=await rt.json();Je(Qe)}catch{Ie("error")}finally{Se(!1)}}async function tt(){var ve;Ge!=null&&Ge.userCode&&(await((ve=navigator.clipboard)==null?void 0:ve.writeText(Ge.userCode)),Xe.current!==null&&window.clearTimeout(Xe.current),Ue(!1),requestAnimationFrame(()=>Ue(!0)),Xe.current=window.setTimeout(()=>{Ue(!1),Xe.current=null},1500))}function ht(){Ge&&(window.open(Ge.directUrl??Ge.verificationUrl,"_blank","noopener,noreferrer"),ae(!0))}async function Lt(ve){var rt,Qe;L(!0),O(null),H([]);try{const Ve=new URLSearchParams({url:ve});w&&Ve.set("apiKey",w),g&&Ve.set("backend",g);const le=k?await me(`/api/providers/${await We()}/models`):await me(`/api/providers/models?${Ve.toString()}`);if(le.ok){const Ye=await le.json();if((rt=Ye.models)!=null&&rt.length){H(Ye.models),F(((Qe=Ye.models[0])==null?void 0:Qe.id)??null);const xt={};for(const It of Ye.models)xt[It.id]={contextWindow:It.contextWindow,thinkingEnabled:!0,thinkingLevel:Yy(It.reasoningEfforts),defaultTemperature:It.defaultTemperature,defaultTopP:It.defaultTopP,defaultTopK:It.defaultTopK,defaultMaxTokens:It.defaultMaxTokens};D(xt),Ye.models.length===1&&(Q(new Set([Ye.models[0].id])),F(Ye.models[0].id),qt(Ye.models[0].id))}}else{const Ye=await le.json();O(Ye.error??`Failed to fetch models from ${ve}`)}}catch(Ve){O(`Failed to fetch models from ${ve}: ${Ve instanceof Error?Ve.message:"Unknown error"}`)}L(!1)}async function qt(ve){$(rt=>({loading:!0,progress:{...rt.progress,[ve]:"probing"}}));try{const rt=await me("/api/providers/auto-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:m,apiKey:w||void 0,backend:g||"unknown",models:[{id:ve}]})});if(!rt.ok){const Ve=await rt.json();throw new Error(Ve.error??"Auto-config failed")}const Qe=await rt.json();for(const Ve of Qe.models){const le={};Ve.contextSource!=="default"&&(le.contextWindow=Ve.contextWindow,le.supportsVision=Ve.supportsVision),Ve.thinkingConfig&&(le.thinkingEnabled=!0,le.thinkingQueryParams=JSON.stringify(Ve.thinkingConfig)),Ve.nonThinkingConfig&&(le.nonThinkingEnabled=!0,le.nonThinkingQueryParams=JSON.stringify(Ve.nonThinkingConfig)),gt(Ve.id,le),$(Ye=>({...Ye,progress:{...Ye.progress,[Ve.id]:"done"}}))}}catch(rt){console.error("Auto-config error:",rt),$(Qe=>({...Qe,progress:{...Qe.progress,[ve]:"error"}}))}finally{$(rt=>({...rt,loading:!1}))}}async function bn(ve,rt){const Qe=ve+"-"+rt;q(Ve=>({...Ve,[Qe]:{loading:!0}}));try{const Ve=P[ve],le=await me("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:m,providerId:(a==null?void 0:a.id)??ie??void 0,transportAdapter:k,model:ve,apiKey:w||void 0,backend:g||"unknown",thinkingField:V||void 0,mode:rt,modelConfig:{temperature:Ve==null?void 0:Ve.temperature,topP:Ve==null?void 0:Ve.topP,topK:Ve==null?void 0:Ve.topK,maxTokens:Ve==null?void 0:Ve.maxTokens,supportsVision:Ve==null?void 0:Ve.supportsVision,thinkingEnabled:Ve==null?void 0:Ve.thinkingEnabled,thinkingLevel:Ve==null?void 0:Ve.thinkingLevel,nonThinkingEnabled:Ve==null?void 0:Ve.nonThinkingEnabled,thinkingQueryParams:Ve==null?void 0:Ve.thinkingQueryParams,nonThinkingQueryParams:Ve==null?void 0:Ve.nonThinkingQueryParams}})}),Ye=await le.json();le.ok?q(xt=>({...xt,[Qe]:{loading:!1,result:JSON.stringify(Ye,null,2),message:Ye.message}})):q(xt=>({...xt,[Qe]:{loading:!1,error:Ye.error??"Test failed"}}))}catch(Ve){q(le=>({...le,[Qe]:{loading:!1,error:Ve instanceof Error?Ve.message:"Request failed"}}))}}function vn(){H([]),D({}),$({loading:!1,progress:{}}),q({}),Y(null),Q(new Set),re(""),Ae(""),Fe(null)}function xn(){ie&&!it.current&&me(`/api/providers/${ie}`,{method:"DELETE"}).catch(ve=>{console.warn("Failed to clean up draft provider",ve)}),t()}function hr(){const ve=d||"Provider",rt=(a==null?void 0:a.id)??ie??`temp-${Date.now()}`;n({id:rt,name:ve,url:m,backend:g||"unknown",apiKey:w||void 0,isLocal:v,thinkingField:V||void 0,sendReasoningInMessages:J,authAdapter:_,transportAdapter:k,models:M.map(Qe=>{var Ve,le,Ye,xt,It,Ee,Te,He,et,st,bt,jt,Pn,Cn,Tn,fo;return{id:Qe.id,name:Qe.name,apiModelId:Qe.apiModelId,requestBody:Qe.requestBody,reasoningEfforts:Qe.reasoningEfforts,contextWindow:((Ve=P[Qe.id])==null?void 0:Ve.contextWindow)??Qe.contextWindow,selected:I.has(Qe.id)||void 0,supportsVision:(le=P[Qe.id])==null?void 0:le.supportsVision,thinkingEnabled:(Ye=P[Qe.id])==null?void 0:Ye.thinkingEnabled,thinkingLevel:(xt=P[Qe.id])==null?void 0:xt.thinkingLevel,nonThinkingEnabled:(It=P[Qe.id])==null?void 0:It.nonThinkingEnabled,thinkingQueryParams:(Ee=P[Qe.id])==null?void 0:Ee.thinkingQueryParams,nonThinkingQueryParams:(Te=P[Qe.id])==null?void 0:Te.nonThinkingQueryParams,temperature:(He=P[Qe.id])==null?void 0:He.temperature,topP:(et=P[Qe.id])==null?void 0:et.topP,topK:(st=P[Qe.id])==null?void 0:st.topK,maxTokens:(bt=P[Qe.id])==null?void 0:bt.maxTokens,defaultMaxTokens:(jt=P[Qe.id])==null?void 0:jt.defaultMaxTokens,defaultTemperature:(Pn=P[Qe.id])==null?void 0:Pn.defaultTemperature,defaultTopP:(Cn=P[Qe.id])==null?void 0:Cn.defaultTopP,defaultTopK:(Tn=P[Qe.id])==null?void 0:Tn.defaultTopK,compactionThreshold:(fo=P[Qe.id])==null?void 0:fo.compactionThreshold}})}),it.current=!0,t()}return e?s.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:[s.jsxs(pt,{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[85vh] shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[s.jsx("h3",{className:"text-lg font-semibold text-text-primary",children:a?"Edit Provider":"Add Provider"}),s.jsx("button",{onClick:xn,className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsx("div",{className:"flex gap-1.5 px-6 pt-4",children:[1,2].map(ve=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${ve<c?"bg-accent-success":ve===c?"bg-accent-primary":"bg-border"}`},ve))}),c===1&&s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Inference engine"}),s.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[_e.map(ve=>s.jsx("button",{type:"button",onClick:()=>{h(ve.defaults.name??ve.name),f(ve.defaults.url),x(ve.defaults.backend),S(!1),C(""),b(ve.authAdapter),E(ve.transportAdapter),O(null),vn()},className:`p-2 rounded border text-center text-sm transition-colors ${k&&k===ve.transportAdapter?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:ve.name},ve.id)),s.jsx("button",{type:"button",onClick:()=>{x("unknown"),S(!1),b(void 0),E(void 0),O(null),vn()},className:`p-2 rounded border text-center text-sm transition-colors ${g==="unknown"?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:"Other"},"other"),CG.map(ve=>{const rt={8e3:"vllm",11434:"ollama",8080:"llamacpp",1234:"lmstudio"},Qe={8e3:"vLLM",11434:"Ollama",8080:"llama.cpp",1234:"LM Studio"};return s.jsx("button",{type:"button",onClick:()=>{h(Ve=>Ve||(Qe[ve]??"")),f(Ve=>Ve||`http://localhost:${ve}`),x(rt[ve]??""),S(!0),b(void 0),E(void 0),O(null),vn()},className:`p-2 rounded border text-center text-sm transition-colors ${g===rt[ve]?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:Qe[ve]??`localhost:${ve}`},ve)})]})]}),!_&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider URL"}),s.jsx("input",{ref:Ze,type:"text",value:m,"data-testid":"provider-modal-url",onChange:ve=>{f(ve.target.value),O(null),H([]),D({})},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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name"}),s.jsx("input",{type:"text",autoComplete:"off",value:d,onChange:ve=>h(ve.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"})]}),!_&&s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-text-secondary mb-1",children:["API key ",s.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),s.jsx("input",{type:"text",autoComplete:"off",value:w,onChange:ve=>C(ve.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"})]}),!_&&s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:v,onChange:ve=>S(ve.target.checked),className:"w-4 h-4 rounded border-border bg-bg-primary accent-accent-primary"}),s.jsx("span",{className:"text-sm text-text-secondary",children:"This is a local provider"})]})]}),c===2&&s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Test & Configure Models"}),s.jsx("button",{type:"button",onClick:()=>G(!0),className:"p-1.5 text-text-muted hover:text-text-primary rounded transition-colors",title:"Provider-level defaults",children:s.jsx(jE,{className:"w-4 h-4"})})]}),!!_&&s.jsxs("div",{className:"rounded-lg border border-border bg-bg-primary p-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Connect provider"}),s.jsx("p",{className:"mt-1 text-xs text-text-muted",children:"Connect this provider before choosing available models."})]}),ye==="connected"?s.jsx("span",{className:"text-sm font-medium text-accent-success",children:"Connected ✓"}):s.jsx("button",{type:"button",onClick:()=>void nt(),disabled:$e||ye==="pending",className:"rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary disabled:opacity-50",children:$e||ye==="pending"?"Connecting...":ye==="error"?"Retry":"Connect"})]}),Ge&&s.jsx("div",{className:"mt-4 border-t border-border pt-4",children:Ge.mode!=="browser"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Use this code to complete authorization:"}),s.jsx("button",{type:"button",onClick:()=>void tt(),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"}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>void tt(),className:"flex-1 rounded-lg border border-border px-3 py-2 text-sm text-text-primary",children:Pe?"Copied":"Copy code"}),s.jsx("button",{type:"button",onClick:ht,className:"flex-1 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:he?"Reopen authorization":"Open authorization"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-xs text-text-muted mb-3",children:Ge.instructions}),s.jsx("button",{type:"button",onClick:ht,className:"w-full rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:he?"Reopen authorization":"Open authorization"})]})})]}),T&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[s.jsx("span",{className:"w-4 h-4 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),"Fetching models..."]}),A&&s.jsxs("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-500 border border-red-500/20",children:[s.jsx("p",{children:A}),s.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["URL: ",m]}),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("button",{onClick:()=>Lt(m),className:"text-xs text-accent-primary hover:underline",children:"Retry"}),s.jsx("button",{onClick:()=>{vn(),u(1)},className:"text-xs text-accent-primary hover:underline",children:"Edit URL"}),!_&&s.jsx("button",{onClick:()=>{var ve;return(ve=lt.current)==null?void 0:ve.focus()},className:"text-xs text-accent-primary hover:underline",children:"Add model manually"})]})]}),g&&(!_||ye==="connected")&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Add model manually"}),s.jsx("p",{className:"text-xs text-text-muted mb-2",children:A?"Can't discover models automatically? Enter the model name to use:":"Enter a model name manually if it does not appear in the list above:"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{ref:lt,type:"text",value:de,onChange:ve=>{Ae(ve.target.value),ue&&Fe(null)},onKeyDown:ve=>{ve.key==="Enter"&&(ve.preventDefault(),ke())},placeholder:"model-name","data-testid":"provider-modal-manual-model-input",className:"flex-1 px-3 py-1.5 bg-bg-primary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),s.jsx("button",{type:"button",onClick:ke,"data-testid":"provider-modal-manual-model-add",className:"px-3 py-1.5 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 transition-colors",children:"Add"})]}),ue&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:ue})]}),M.length>0&&g&&(!_||ye==="connected")&&s.jsxs(s.Fragment,{children:[I.size>0&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("h4",{className:"text-sm font-medium text-text-primary mb-1",children:["Selected Models (",I.size,")"]}),s.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Only selected models will appear in the model selector."}),s.jsx("div",{className:"space-y-2",children:M.filter(ve=>I.has(ve.id)).map(ve=>{var rt;return s.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[s.jsxs("div",{onClick:()=>F(B===ve.id?null:ve.id),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-tertiary transition-colors cursor-pointer",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-sm font-medium text-text-primary",children:ve.name??ve.id.split("/").pop()}),s.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[(((rt=P[ve.id])==null?void 0:rt.contextWindow)??ve.contextWindow).toLocaleString()," ctx"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[U.progress[ve.id]==="probing"?s.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}):U.progress[ve.id]==="done"?s.jsx("span",{className:"text-xs text-accent-success font-medium",children:"Configured ✓"}):U.progress[ve.id]==="error"?s.jsx("span",{className:"text-xs text-red-500 font-medium",children:"Failed ✗"}):_?null:s.jsx("button",{onClick:Qe=>{Qe.stopPropagation(),qt(ve.id)},className:"text-xs text-accent-primary hover:underline",children:"Auto-config"}),M.length>1&&s.jsx("button",{onClick:Qe=>{Qe.stopPropagation();const Ve=new Set(I);Ve.delete(ve.id),Q(Ve),B===ve.id&&F(null)},className:"text-xs text-red-500 hover:text-red-400 px-2 py-1 rounded hover:bg-red-500/10",children:"Remove"}),s.jsx(gn,{className:`w-4 h-4 text-text-muted transition-transform ${B===ve.id?"rotate-180":""}`})]})]}),B===ve.id&&s.jsx(kG,{model:ve,modelConfigs:P,autoConfigState:U,testResults:te,onUpdateConfig:gt,onRunAutoConfig:qt,onTestParams:bn,onShowRaw:Y})]},ve.id)})})]}),M.length>1&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Available Models"}),I.size===0&&s.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."}),s.jsxs("div",{className:"relative mb-2",children:[s.jsx("input",{type:"text",value:ne,onChange:ve=>re(ve.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&&s.jsx("button",{onClick:()=>re(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary text-sm",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("p",{className:"text-xs text-text-muted",children:["Showing ",Re(ne).length," of ",M.length," models"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>{const ve=new Set(I),rt=Re(ne);for(const Qe of rt)ve.add(Qe.id);if(Q(ve),D(Qe=>{const Ve={...Qe};for(const le of rt)Ve[le.id]={contextWindow:le.contextWindow,...Ve[le.id]};return Ve}),!_)for(const Qe of rt)U.progress[Qe.id]!=="probing"&&U.progress[Qe.id]!=="done"&&qt(Qe.id)},className:"text-xs text-accent-primary hover:underline",children:"Select all"}),s.jsx("button",{onClick:()=>{const ve=new Set(I),rt=Re(ne);for(const Qe of rt)ve.delete(Qe.id);Q(ve)},className:"text-xs text-text-muted hover:text-text-secondary",children:"Deselect all"})]})]}),s.jsxs(pt,{className:"space-y-1 max-h-48 border border-border rounded-lg bg-bg-primary",children:[Re(ne).map(ve=>{var Qe;const rt=I.has(ve.id);return s.jsxs("div",{role:"checkbox","aria-checked":rt,tabIndex:0,className:`flex items-center gap-3 px-4 py-2 hover:bg-bg-tertiary transition-colors cursor-pointer ${rt?"bg-accent-primary/5":""}`,onClick:()=>{if(rt){const Ve=new Set(I);Ve.delete(ve.id),Q(Ve)}else De(ve),_||qt(ve.id)},onKeyDown:Ve=>{(Ve.key==="Enter"||Ve.key===" ")&&(Ve.preventDefault(),Ve.currentTarget.click())},children:[s.jsx("input",{type:"checkbox",checked:rt,onChange:()=>{},className:"w-4 h-4 rounded border-border accent-accent-primary pointer-events-none"}),s.jsx("span",{className:"text-sm text-text-primary flex-1 truncate",children:ve.name??ve.id.split("/").pop()}),s.jsxs("span",{className:"text-xs text-text-muted flex-shrink-0",children:[(((Qe=P[ve.id])==null?void 0:Qe.contextWindow)??ve.contextWindow).toLocaleString()," ctx"]}),U.progress[ve.id]==="probing"&&s.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin flex-shrink-0"}),U.progress[ve.id]==="done"&&s.jsx("span",{className:"text-xs text-accent-success flex-shrink-0",children:"✓"}),U.progress[ve.id]==="error"&&s.jsx("span",{className:"text-xs text-red-500 flex-shrink-0",children:"✗"})]},ve.id)}),Re(ne).length===0&&s.jsxs("div",{className:"px-4 py-6 text-center text-sm text-text-muted",children:["No models match “",ne,"”"]})]})]})]})]}),s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-border",children:[s.jsx("div",{children:c>1&&s.jsx("button",{onClick:()=>{c===2&&vn(),u(c-1)},className:"text-sm text-text-muted hover:text-text-secondary transition-colors",children:"← Back"})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:xn,className:"px-4 py-2 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),c===1?s.jsx("button",{onClick:()=>u(2),disabled:!m,"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"}):s.jsx("button",{onClick:hr,disabled:U.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:U.loading?"Configuring...":"Save Provider"})]})]})]}),K&&s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:ve=>{ve.target===ve.currentTarget&&G(!1)},children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[480px] shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[s.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Provider-Level Defaults"}),s.jsx("button",{onClick:()=>G(!1),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"These apply to all models unless overridden per-model."}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Non-thinking mode params"}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Thinking mode params"}),s.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"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Thinking response field ",s.jsx("span",{className:"text-text-muted",children:"(override)"})]}),s.jsx("input",{type:"text",value:V,onChange:ve=>Z(ve.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"}),s.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)."})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:J,onChange:ve=>z(ve.target.checked),className:"rounded border-border bg-bg-primary text-accent-primary focus:ring-accent-primary"}),s.jsx("span",{className:"text-sm text-text-secondary",children:"Send reasoning in messages"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:"When disabled, strips reasoning/thinking content from assistant messages sent to this provider"})]})]}),s.jsx("div",{className:"flex justify-end px-6 py-4 border-t border-border",children:s.jsx("button",{onClick:()=>G(!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&&s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:ve=>{ve.target===ve.currentTarget&&Y(null)},children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[80vh] shadow-2xl flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border shrink-0",children:[s.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Raw Response"}),s.jsx("button",{onClick:()=>Y(null),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsx(pt,{horizontal:!0,children:s.jsx("pre",{className:"px-6 py-4 text-xs text-text-secondary font-mono whitespace-pre-wrap break-all",children:X})})]})})]}):null}function nj({activeProvider:e,shortModelName:t,agentOverrideActive:n,agentColor:r,agentName:a}){return s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-sm text-accent-primary flex items-center gap-1",children:[n&&s.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?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"hidden @sm:inline",children:[e.name," • "]}),t]}):t]}),s.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 EG(){var Ve;const[,e]=Nn(),t=Er(),n=cn(t,le=>le.session??null,le=>le.currentSession,null),r=Oe(le=>le.setSessionProvider),[a,o]=j.useState(!1),[c,u]=j.useState([]),[d,h]=j.useState(null),m=j.useRef(null),[f,g]=j.useState(null),[x,w]=j.useState(!1),[C,v]=j.useState({}),[S,_]=j.useState(null),[b,k]=j.useState(null),[E,T]=j.useState(!1),L=j.useRef(null),[A,O]=j.useState(!1),M=j.useRef(new Set),H=an(le=>le.providers),B=an(le=>le.activeProviderId),F=an(le=>le.defaultModelSelection),K=an(le=>le.activating),G=an(le=>le.activateProvider),V=an(le=>le.refreshModel),Z=an(le=>le.refreshProviderModels),J=an(le=>le.setDefaultModel),z=an(le=>le.fetchConfig),P=Nu();gu(P.modelSelector,()=>o(le=>!le));const D=(n==null?void 0:n.providerId)??null,U=(n==null?void 0:n.providerModel)??null,$=(F==null?void 0:F.split("/")[0])??null,te=(F==null?void 0:F.split("/").slice(1).join("/"))??null,q=dt(le=>le.defaults),X=dt(le=>le.userItems),Y=dt(le=>le.modelOverrides),I=n==null?void 0:n.mode,Q=I?q.find(le=>le.id===I)??X.find(le=>le.id===I):void 0,ne=I?Y[I]??void 0:void 0,re=ne?ne.split("/")[0]??null:null,ie=ne?ne.split("/").slice(1).join("/")??null:null,pe=I?oo([...q,...X],I):void 0,ye=!!ne,Ie=re??D??$,$e=ie??U??te,Se=$e?((Ve=$e.split("/").pop())==null?void 0:Ve.replace(/-/g," "))??$e:"No model",[Ge,Je]=j.useState(!1);j.useEffect(()=>{function le(Ye){m.current&&!m.current.contains(Ye.target)&&(o(!1),u([]),M.current=new Set)}return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[]),j.useEffect(()=>()=>{L.current!==null&&window.clearTimeout(L.current)},[]),j.useEffect(()=>{a||(ht(""),qt(-1))},[a]),j.useEffect(()=>{var le;a&&Gt()&&((le=ve.current)==null||le.focus())},[a]),j.useEffect(()=>{if(a){const le=H.map(Ye=>Ye.id);u(le),H.filter(Ye=>!!Ye.authAdapter).forEach(Ye=>void Fe(Ye.id)),le.forEach(Ye=>{M.current.has(Ye)||(M.current.add(Ye),Pe(Ye))})}},[a,H]),j.useEffect(()=>{if(!b)return;let le=!1;const Ye=async()=>{const It=await Fe(b.providerId);le||It==="connected"&&(k(null),T(!1),O(!1),await z(),M.current.delete(b.providerId),await Pe(b.providerId))};Ye();const xt=window.setInterval(()=>void Ye(),2e3);return()=>{le=!0,window.clearInterval(xt)}},[b]);const _e=H.find(le=>le.id===Ie),ge=(_e==null?void 0:_e.status)==="disconnected",he=(le,Ye)=>n?n.providerId===le&&n.providerModel===Ye:!1,ae=(le,Ye)=>F?F===`${le}/${Ye}`:!1,Pe=async le=>{h(le);try{await Z(le)}catch{}finally{h(null)}},Ue=le=>{c.includes(le.id)?u(c.filter(Ye=>Ye!==le.id)):(u([...c,le.id]),Pe(le.id))},de=async le=>{if(le.id===B){Ue(le);return}n&&t?(r(t,le.id,void 0),o(!1),u([])):await G(le.id)&&(o(!1),u([]))},Ae=le=>{Ue(le)},ue=async(le,Ye)=>{le.stopPropagation(),M.current.delete(Ye),await Pe(Ye)},Fe=async le=>{const Ye=await me(`/api/provider-auth/${le}/status`);if(!Ye.ok)return"error";const xt=await Ye.json();return v(It=>({...It,[le]:xt.state})),xt.state},Xe=async(le,Ye)=>{le.stopPropagation(),_(Ye),v(xt=>({...xt,[Ye]:"pending"})),T(!1),O(!1);try{const xt=await me(`/api/provider-auth/${Ye}/login`,{method:"POST"});if(!xt.ok)throw new Error("Unable to start provider sign-in");const It=await xt.json();k({providerId:Ye,...It})}catch{v(xt=>({...xt,[Ye]:"error"}))}finally{_(null)}},it=async()=>{var le;b!=null&&b.userCode&&(await((le=navigator.clipboard)==null?void 0:le.writeText(b.userCode)),L.current!==null&&window.clearTimeout(L.current),T(!1),requestAnimationFrame(()=>T(!0)),L.current=window.setTimeout(()=>{T(!1),L.current=null},1500))},Ze=()=>{b&&(window.open(b.directUrl??b.verificationUrl,"_blank","noopener,noreferrer"),O(!0))},lt=()=>{k(null),T(!1),O(!1)},gt=async(le,Ye)=>{le.stopPropagation(),_(Ye);try{if(!(await me(`/api/provider-auth/${Ye}/logout`,{method:"POST"})).ok)throw new Error("Unable to disconnect provider account");v(It=>({...It,[Ye]:"disconnected"})),await z()}finally{_(null)}},De=(le,Ye)=>{g({providerId:le,model:Ye}),w(!0)},Re=f?H.find(le=>le.id===f.providerId):void 0,ke=()=>{g(null),w(!1)},We=async le=>{try{if(!(await me(`/api/providers/${le.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(WA(le))})).ok)throw new Error("Failed to update provider");await an.getState().fetchConfig()}catch{}g(null),w(!1)},Ce=async(le,Ye)=>{if(I&&ne&&ne!==`${le}/${Ye}`&&(me(`/api/agents/${I}/model`,{method:"DELETE"}).catch(()=>{}),dt.setState(It=>{const Ee={...It.modelOverrides};return delete Ee[I],{modelOverrides:Ee}})),n&&t){Oe.setState(It=>({...It,currentSession:It.currentSession?{...It.currentSession,providerId:le,providerModel:Ye}:null})),r(t,le,Ye),u([]),o(!1),ku();return}await G(le)&&(u([]),o(!1),ku())},nt=async(le,Ye,xt)=>{le.stopPropagation(),Je(!0);try{await J(Ye,xt)}catch{}finally{Je(!1)}},{searchQuery:tt,setSearchQuery:ht,highlightedIndex:Lt,setHighlightedIndex:qt,visibleGroups:bn,flatItems:vn,handleSearchKeyDown:xn,highlightedRef:hr,inputRef:ve}=UT({providers:H,onSelect:Ce,onEscape:()=>o(!1),extraItemCount:1}),rt=Lt===vn.length,Qe=le=>{if(le.key==="Enter"&&Lt===vn.length){le.preventDefault(),e("/onboarding"),o(!1);return}xn(le)};return H.length===0?s.jsxs("button",{type:"button",onClick:()=>V(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:ge?"LLM server is offline. Click to retry.":Se??"Click to refresh model",children:[ge?s.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):s.jsx(nj,{activeProvider:_e,shortModelName:Se,agentOverrideActive:ye,agentColor:pe,agentName:Q==null?void 0:Q.name}),s.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):s.jsxs("div",{className:"relative",ref:m,children:[s.jsxs("button",{type:"button",onClick:()=>o(!a),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:[ge?s.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):s.jsx(nj,{activeProvider:_e,shortModelName:Se,agentOverrideActive:ye,agentColor:pe,agentName:Q==null?void 0:Q.name}),s.jsx(gn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:a?180:0})]}),a&&s.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:[s.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[s.jsx(_i,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("input",{ref:ve,type:"text",value:tt,onInput:le=>{ht(le.currentTarget.value),qt(-1)},onKeyDown:Qe,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),s.jsx(pt,{className:"flex-1 min-h-0",children:s.jsxs("div",{children:[bn.map(le=>{const Ye=tt.trim().length>0||c.includes(le.provider.id);return s.jsxs("div",{children:[s.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${le.provider.id===Ie?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${K?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[s.jsxs("div",{onClick:()=>!K&&de(le.provider),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[s.jsx("span",{className:`text-sm font-medium truncate ${le.provider.id===Ie?"text-accent-primary":"text-text-primary"}`,children:le.provider.name}),s.jsx("span",{className:"text-xs text-text-muted truncate",children:le.provider.backend!=="unknown"&&hE(le.provider.backend)})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!!le.provider.authAdapter&&(C[le.provider.id]==="connected"||le.provider.credentialRef?s.jsx("button",{type:"button",onClick:xt=>gt(xt,le.provider.id),disabled:S===le.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"}):s.jsx("button",{type:"button",onClick:xt=>Xe(xt,le.provider.id),disabled:S===le.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:S===le.provider.id?"Starting…":C[le.provider.id]==="error"||C[le.provider.id]==="expired"?"Retry":"Connect"})),le.provider.id===Ie?s.jsx("span",{className:"text-accent-success",title:"Active provider",children:s.jsx(Hs,{className:"w-4 h-4"})}):s.jsx("span",{className:"w-4"}),s.jsx("button",{type:"button",onClick:xt=>{xt.stopPropagation(),ue(xt,le.provider.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:s.jsx(Gf,{className:`w-4 h-4 ${d===le.provider.id?"animate-spin":""} ${le.provider.id===B?"text-accent-primary":"text-text-muted"}`})}),s.jsx("button",{type:"button",onClick:xt=>{xt.stopPropagation(),Ae(le.provider)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:s.jsx(gn,{className:`w-4 h-4 transition-transform ${Ye?"rotate-180":""} ${le.provider.id===B?"text-accent-primary":"text-text-muted"}`})})]})]}),Ye&&s.jsx(pt,{className:"bg-bg-primary border-t border-border max-h-40",children:d===le.provider.id?s.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):le.models.length>0?le.models.map(xt=>{const Ee=vn.findIndex(Te=>Te.providerId===le.provider.id&&Te.modelConfig.id===xt.id)===Lt;return s.jsx("div",{ref:Ee?hr:void 0,children:s.jsx(zT,{providerId:le.provider.id,modelConfig:xt,isActive:he(le.provider.id,xt.id),isDefault:ae(le.provider.id,xt.id),disabled:d==="activating",hasSession:!!n,settingDefault:Ge,highlighted:Ee,onModelClick:Ce,onSetDefault:nt,onEditModel:De})},`${le.provider.id}/${xt.id}`)}):s.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},le.provider.id)}),bn.length===0&&tt.trim()&&s.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No models match your search"})]})}),s.jsx("div",{className:`border-t border-border px-3 py-2 ${rt?"bg-bg-tertiary":""} flex-shrink-0`,children:s.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),b&&s.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:le=>{le.target===le.currentTarget&<()},children:s.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border bg-bg-secondary p-6 shadow-2xl",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"provider-device-title",className:"text-lg font-semibold text-text-primary",children:"Connect provider"}),s.jsx("p",{className:"mt-1 text-sm text-text-muted",children:"Follow the provider instructions to complete authorization."})]}),s.jsx("button",{type:"button",onClick:lt,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:"×"})]}),b.mode!=="browser"?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:it,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:b.userCode??"Continue"}),s.jsx("div",{className:"mt-3 text-center text-xs text-text-muted",children:E?"Copied to clipboard":"Click the code to copy it"}),s.jsxs("div",{className:"mt-6 flex gap-3",children:[s.jsx("button",{type:"button",onClick:it,className:"flex-1 rounded-lg border border-border px-4 py-2 text-sm text-text-primary hover:bg-bg-tertiary",children:E?"Copied":"Copy code"}),s.jsx("button",{type:"button",onClick:Ze,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:A?"Reopen authorization":"Open authorization"})]}),s.jsx("p",{className:"mt-4 text-center text-xs text-text-muted",children:A?"If the browser blocked or closed the tab, reopen authorization.":"OpenFox stays open while you complete authorization in the other tab."})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"mt-6 text-sm text-text-secondary leading-relaxed bg-bg-primary p-4 rounded-lg border border-border",children:b.instructions}),s.jsx("div",{className:"mt-6 flex gap-3",children:s.jsx("button",{type:"button",onClick:Ze,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:A?"Reopen authorization":"Open authorization"})})]})]})}),f&&x&&s.jsx(GA,{isOpen:!0,onClose:ke,onSave:We,initialStep:2,editProvider:{id:f.providerId,name:(Re==null?void 0:Re.name)??"",url:(Re==null?void 0:Re.url)??"",backend:(Re==null?void 0:Re.backend)??"unknown",apiKey:Re==null?void 0:Re.apiKey,isLocal:Re==null?void 0:Re.isLocal,thinkingField:Re==null?void 0:Re.thinkingField,sendReasoningInMessages:Re==null?void 0:Re.sendReasoningInMessages,authAdapter:Re==null?void 0:Re.authAdapter,transportAdapter:Re==null?void 0:Re.transportAdapter,models:Re==null?void 0:Re.models},editModelId:f.model.id})]})}function NG(){const e=hu(k=>k.servers),t=hu(k=>k.fetchServers),n=Oe(k=>k.currentSession),r=n==null?void 0:n.id,[a,o]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(new Set),[m,f]=j.useState(new Set),g=j.useRef(null),x=j.useCallback(async()=>{if(r)try{const k=await me(`/api/sessions/${r}/mcp/overrides`);if(k.ok){const E=await k.json();f(new Set(E.disabledServers??[]))}}catch{}},[r]),w=j.useCallback(async()=>{await t(),await x()},[t,x]);j.useEffect(()=>{const k=()=>w();return window.addEventListener("mcp-servers-changed",k),()=>window.removeEventListener("mcp-servers-changed",k)},[w]),j.useEffect(()=>{x()},[x]),j.useEffect(()=>{a&&x()},[a,x]),_m(g,()=>o(!1));const C=k=>m.has(k.name),v=e.filter(k=>k.status==="connected"&&!C(k)),S=v.length,_=v.reduce((k,E)=>k+E.estimatedTokens,0),b=async(k,E)=>{if(r){u(null),h(T=>new Set(T).add(k));try{const T=new Set(m);E?T.add(k):T.delete(k);const L=await me(`/api/sessions/${r}/mcp/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabledServers:Array.from(T)})});if(!L.ok){const A=await L.json().catch(()=>({}));throw new Error(A.error??"Toggle failed")}f(T),await t()}catch(T){u(T instanceof Error?T.message:String(T))}finally{h(T=>{const L=new Set(T);return L.delete(k),L})}}};return s.jsxs("div",{className:"relative",ref:g,children:[s.jsxs("button",{type:"button",onClick:()=>o(!a),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:S>0?`${S} MCP server(s) active`:"No MCP server active",children:[s.jsx("span",{className:"text-sm text-accent-primary whitespace-nowrap",children:S>0?`● ${S} MCP (${gf(_)})`:"MCP"}),s.jsx(gn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:a?180:0})]}),a&&s.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:[s.jsx(pt,{className:"flex-1 min-h-0",children:e.length===0?s.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 s.jsx("div",{children:s.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-bg-tertiary",children:[s.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx("span",{className:`text-sm ${pv(E?"disabled":k.status)}`,children:gv(E?"disabled":k.status)}),s.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:k.name})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted ml-3.5",children:[s.jsxs("span",{children:[k.tools.length," tools"]}),k.estimatedTokens>0&&s.jsxs("span",{children:[gf(k.estimatedTokens)," tokens"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[T&&s.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"..."}),s.jsx(xs,{enabled:!E,onClick:()=>b(k.name,!E)})]})]})},k.name)})}),s.jsx("div",{className:"border-t border-border px-3 py-2 flex-shrink-0",children:c?s.jsx("div",{className:"text-xs text-accent-error",children:c}):s.jsxs("span",{className:"text-xs text-text-muted",children:[e.length," server(s) configured"]})})]})]})}const rj=24,sj=200;function TG({input:e,setInput:t,attachments:n,setAttachments:r,dragOver:a,setDragOver:o,errorMessage:c,setErrorMessage:u,scrollToBottom:d,sessionId:h,showHistory:m,history:f,selectedIndex:g,openHistory:x,closeHistory:w,navigateUp:C,navigateDown:v,selectCurrent:S,isAutoScrollActive:_,setAutoScroll:b,onOpenMessageSearch:k,onOpenCommandsModal:E,onOpenWorkflowsModal:T,onSelectWorkflow:L,onSelectWorkflowWithSubGroup:A,onSendCommand:O,clearInput:M}){const H=j.useRef(null),B=j.useRef(null),F=j.useRef(0),K=j.useRef(null),G=j.useRef(null),V=zf(h),Z=Oe(ue=>ue.stopGeneration),J=Oe(ue=>ue.cancelQueued),z=M3(h),P=cn(h,ue=>ue.restoredInput??null,ue=>ue.restoredInput,null),D=Oe(ue=>ue.clearRestoredInput),U=cn(h,ue=>{var Fe;return((Fe=ue.session)==null?void 0:Fe.workdir)??void 0},ue=>{var Fe;return(Fe=ue.currentSession)==null?void 0:Fe.workdir},void 0),$=cn(h,ue=>ue.session??null,ue=>ue.currentSession,null),te=j.useRef(!1),q=j.useRef(void 0),X=j.useRef(!1),[Y,I]=j.useState([]),Q=j.useRef(null),{sendMessage:ne,launchWorkflow:re}=UA(b,h);j.useEffect(()=>{q.current!==U&&(q.current=U,Wt.getState().fetchWorkflows(U),fn.getState().fetchCommands(U))},[U]),j.useEffect(()=>{e||I([])},[e]),j.useEffect(()=>{var ue;P!==null&&(t(P),D(h),Gt()&&((ue=H.current)==null||ue.focus()))},[P,t,D]);const ie=j.useCallback(()=>{const ue=H.current;if(ue){if(ue.style.height="auto",!e){ue.style.height=`${rj}px`;return}ue.style.height=`${Math.min(sj,ue.scrollHeight)}px`}},[e]);j.useEffect(()=>{if(!h)return;const ue=`openfox:draft:${h}`,Fe=localStorage.getItem(ue);Fe!==null&&t(Fe)},[h,t]),j.useEffect(()=>{var ue;Gt()&&((ue=H.current)==null||ue.focus()),ie()},[h,ie]),j.useEffect(()=>{if(!h)return;const ue=`openfox:draft:${h}`,Fe=setTimeout(()=>{e?localStorage.setItem(ue,e):localStorage.removeItem(ue)},500);return()=>clearTimeout(Fe)},[h,e]),j.useEffect(()=>{ie()},[e,ie]),j.useEffect(()=>{var it;const ue=(it=H.current)==null?void 0:it.parentElement;if(!ue||typeof ResizeObserver>"u")return;let Fe=ue.clientWidth;const Xe=new ResizeObserver(()=>{const Ze=ue.clientWidth;Ze!==Fe&&(Fe=Ze,ie())});return Xe.observe(ue),()=>Xe.disconnect()},[ie]),j.useEffect(()=>{const ue=H.current;if(!ue)return;const Fe=async Xe=>{var lt;if(document.activeElement!==ue)return;const it=(lt=Xe.clipboardData)==null?void 0:lt.items;if(!it)return;const Ze=[];for(const gt of Array.from(it)){let De=gt.getAsFile();if(De&&TU(De.type)){if(Xe.preventDefault(),!De.name){const Re=NU(De.type);De=new File([De],`pasted-file.${Re}`,{type:De.type})}await Gy(De,Re=>Ze.push(Re),u)}}Ze.length>0&&r(gt=>[...gt,...Ze])};return ue.addEventListener("paste",Fe),()=>ue.removeEventListener("paste",Fe)},[r,u]);const pe=ue=>{ue.preventDefault(),!(!e.trim()&&n.length===0)&&he()},ye=ue=>{var Fe,Xe;if(!((Fe=G.current)!=null&&Fe.handleKeyDown(ue))&&!((Xe=K.current)!=null&&Xe.handleKeyDown(ue))){if(m)switch(ue.key){case"Enter":{ue.preventDefault();const it=S();it&&(t(it),w());return}case"Escape":ue.preventDefault(),w(),V&&h&&Z(h);return;case"ArrowUp":ue.preventDefault(),C();return;case"ArrowDown":ue.preventDefault(),v();return}if(ue.key==="ArrowUp"&&e.trim()===""&&!m){ue.preventDefault(),x();return}ue.key==="Enter"&&!ue.shiftKey&&(ue.preventDefault(),pe(ue))}};async function Ie(ue,Fe,Xe){const it=[];for(const Ze of Array.from(ue))await Gy(Ze,lt=>it.push(lt),Xe);it.length>0&&Fe(Ze=>[...Ze,...it])}const $e=j.useCallback(async ue=>{const Fe=ue.target.files;!Fe||Fe.length===0||(u(null),await Ie(Fe,r,u),B.current&&(B.current.value=""))},[r,u]),Se=j.useCallback(ue=>{var Fe;(Fe=ue.dataTransfer.types)!=null&&Fe.includes("Files")&&(ue.preventDefault(),ue.stopPropagation(),o(!0))},[o]),Ge=j.useCallback(ue=>{ue.preventDefault(),ue.stopPropagation(),o(!1)},[o]),Je=j.useCallback(async ue=>{ue.preventDefault(),ue.stopPropagation(),o(!1),u(null);const Fe=ue.dataTransfer.files;!Fe||Fe.length===0||await Ie(Fe,r,u)},[r,o,u]),_e=j.useCallback(ue=>{r(n.filter(Fe=>Fe.id!==ue))},[n,r]),ge=j.useCallback(()=>{var ue;(ue=B.current)==null||ue.click()},[]),he=()=>{if(X.current||!e.trim()&&n.length===0)return;if(X.current=!0,d==null||d(),e.trim().startsWith("/")){const Fe=lo(Wt.getState()),Xe=fn.getState(),it=Gn(Gn(Xe.defaults,Xe.userItems),Xe.projectItems),Ze=lG(e,Fe,it);if(Ze!=null&&Ze.workflowId){const lt=Q.current,gt=lt&<.id===Ze.workflowId?lt.scope:"auto";Q.current=null;const De=Vy(Fe,Ze.workflowId,gt),Re=((De==null?void 0:De.parameters)??[]).filter(ke=>ke.required&&!(ke.id in Ze.params));if(Re.length>0){const ke=Re.map(We=>We.label||We.id).join(", ");u(`Missing required parameter${Re.length>1?"s":""}: ${ke}`),X.current=!1;return}re(void 0,void 0,Ze.workflowId,void 0,Ze.params,gt),M(),X.current=!1;return}if(Ze!=null&&Ze.commandId){Xe.fetchCommand(Ze.commandId,U).then(lt=>{if(lt){const gt=zA(lt.prompt),De={};for(const[ke,We]of Object.entries(Ze.params)){const Ce=parseInt(ke,10),nt=gt[Ce];nt&&(De[nt]=We)}let Re=lt.prompt;for(const[ke,We]of Object.entries(De))Re=Re.replaceAll(`{{${ke}}}`,We);O(Re,lt.metadata.agentMode),M()}X.current=!1});return}}ne(e,n),M(),X.current=!1},ae=j.useCallback((ue,Fe)=>{const it=ue.type==="directory"?"/":" ",{newText:Ze,newCursorPos:lt}=bf(e,F.current,Fe,`@${ue.path}${it}`);t(Ze),F.current=lt,vf(H.current,lt)},[e,t]),Pe=j.useCallback((ue,Fe)=>{const{newText:Xe,newCursorPos:it}=bf(e,F.current,Fe,`/${ue.id} `);t(Xe),F.current=it,vf(H.current,it),ue.type==="workflow"&&(Q.current={id:ue.id,scope:ue.scope}),I(KT(ue))},[e,t]),Ue=j.useCallback(ue=>{const Fe=ue.target.value;t(Fe),m&&w(),F.current=ue.target.selectionStart;const Xe=Q.current;if(Xe){const it=Fe.match(/^\/(\S+)/),Ze=it?it[1]:void 0;(!Ze||Ze!==Xe.id)&&(Q.current=null)}Y.length>0&&(!Fe.startsWith("/")||!Fe.includes(" "))&&I([]),!te.current&&h&&Fe&&$&&($.messageCount??0)===0&&(te.current=!0,me(`/api/sessions/${h}/warmup`,{method:"POST"}).catch(()=>{}))},[t,m,w,h,$,Y]),de=j.useCallback(ue=>{F.current=ue.target.selectionStart},[]),Ae=j.useCallback(ue=>{F.current=ue.currentTarget.selectionStart},[]);return s.jsxs("div",{className:"relative",children:[V&&s.jsx("div",{className:"absolute -top-8 left-2 @md:left-4 z-10",children:s.jsx(uG,{})}),s.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:[s.jsx(Cv,{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"}),s.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:[s.jsx(_i,{}),"Browse history"]})]}),s.jsx(dG,{}),s.jsxs("form",{onSubmit:pe,className:"p-2 @md:p-4 bg-secondary rounded-lg",children:[s.jsx("input",{ref:B,type:"file",accept:"image/*,text/*,.pdf,.json,.xml,.yaml,.yml,.js,.sh,.xhtml",onChange:$e,className:"hidden",multiple:!0}),c&&s.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:c}),n.length>0&&s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(ue=>s.jsx(yv,{attachment:ue,onRemove:_e},ue.id))}),m&&s.jsx(cG,{history:f,selectedIndex:g,onSelect:ue=>{t(ue),w()},onEscape:w,onNavigate:ue=>{ue==="up"?C():v()}}),s.jsx(gG,{messages:z,onCancel:ue=>h&&J(h,ue)}),s.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${a?"bg-accent-primary/10":"bg-primary"}`,onDragOver:Se,onDragLeave:Ge,onDrop:Je,children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx("textarea",{id:AT,ref:H,value:e,onChange:Ue,onKeyDown:ye,onSelect:de,onKeyUp:Ae,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:`${rj}px`,maxHeight:`${sj}px`},spellCheck:!1}),s.jsx(WT,{ref:K,text:e,cursorPos:F.current,workdir:U,onSelect:ae}),s.jsx(VT,{ref:G,text:e,cursorPos:F.current,workflows:lo(Wt.getState()),commands:(()=>{const ue=fn.getState();return Gn(Gn(ue.defaults,ue.userItems),ue.projectItems)})(),onSelect:Pe}),Y.length>0&&(()=>{const ue=e.match(/\/(\w+)\s+(.*)$/),Xe=(ue?ue[2].trim().split(/\s+/):[]).filter(Boolean).length,it=Y[Xe];return it?s.jsxs("span",{className:"absolute left-3 top-[26px] text-sm text-text-muted/40 pointer-events-none select-none","aria-hidden":!0,children:[it,"=?"]}):null})()]}),s.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[V&&s.jsxs("button",{type:"button",onClick:()=>h&&Z(h),"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:[s.jsx(kb,{}),"Abort"]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{type:"button",onClick:he,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"}),s.jsx(mG,{onSendCommand:O,onSelectWorkflow:L,onSelectWorkflowWithSubGroup:A,onOpenCommandsManager:E,onOpenWorkflowsManager:T,onAttach:ge,textareaContent:e,attachments:n.length>0?n:void 0})]})]})]}),s.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(SG,{}),s.jsx(wG,{})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Bt(ue=>ue.settings)[Ne.FEATURES_PER_SESSION_MCP]==="true"&&s.jsx(NG,{}),s.jsx(EG,{})]})]})]})]})}const AG=4;function LG({projectId:e}){const[,t]=Nn(),n=Ht(w=>w.tasks),r=Ht(w=>w.activeProjectId),a=Ht(w=>w.loadBoard),o=Ht(w=>w.moveTask),c=Ht(w=>w.lastError),[u,d]=j.useState(!1),[h,m]=j.useState(null);j.useEffect(()=>{r!==e&&a(e)},[r,e,a]);const f=j.useMemo(()=>n.filter(w=>w.status==="todo"&&w.sessionIds.length===0).sort((w,C)=>w.position-C.position).slice(0,AG),[n]),g=j.useMemo(()=>n.filter(w=>w.status==="in_progress"&&w.runState==="running").length,[n]);if(f.length===0)return null;const x=async w=>{var v;m(null);const C=await o(e,w.id,"in_progress");C!=null&&C.sessionId?t(`/p/${e}/s/${C.sessionId}`):C!=null&&C.task&&C.task.status==="in_progress"&&C.task.runState==="queued"&&m({label:((v=w.prompt.split(`
|
|
320
|
+
`)[0])==null?void 0:v.slice(0,60))||"This task"})};return s.jsxs("div",{className:"mx-auto max-w-xl w-full",children:[s.jsxs("div",{className:"rounded-lg border border-border bg-bg-secondary/60 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold uppercase tracking-wide text-text-muted",children:[s.jsx(Kf,{className:"w-3.5 h-3.5"}),"Up next",g>0&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-emerald-500/40 bg-emerald-500/10 px-2 py-0.5 text-xs font-medium normal-case tracking-normal text-emerald-400",title:`${g} task${g!==1?"s":""} currently running`,children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),g," running"]})]}),s.jsx(ot,{size:"sm",onClick:()=>d(!0),children:"Manage tasks"})]}),h&&s.jsx("div",{className:"mt-3 rounded-md border border-amber-400/40 bg-amber-400/10 p-2.5",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("p",{className:"text-xs text-text-primary",children:["“",h.label,"” is queued — it’ll start automatically when a slot frees."]}),s.jsx("button",{type:"button",onClick:()=>m(null),title:"Dismiss",className:"shrink-0 text-xs text-text-muted underline hover:text-text-primary transition-colors",children:"Dismiss"})]})}),s.jsx("ul",{className:"mt-3 space-y-2",children:f.map((w,C)=>s.jsxs("li",{className:"flex items-start justify-between gap-3 rounded-md border border-border bg-bg-secondary px-3 py-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-text-primary font-medium leading-snug line-clamp-2 break-words whitespace-pre-wrap",children:w.prompt}),s.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-text-muted",children:[w.attachments.length>0&&s.jsxs("span",{children:["📎 ",w.attachments.length]}),w.model&&s.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary border border-border",children:w.model})]})]}),s.jsxs(ot,{variant:C===0?"primary":"secondary",size:"sm",onClick:()=>void x(w),className:"shrink-0 flex items-center gap-1",children:["Start ",s.jsx(Uf,{className:"w-3 h-3"})]})]},w.id))}),c&&s.jsx("div",{className:"mt-3 text-sm text-accent-error",children:c})]}),s.jsx(vm,{isOpen:u,onClose:()=>d(!1),projectId:e})]})}function ij({workflowName:e,parameters:t,onConfirm:n,onCancel:r,confirmLabel:a="Run workflow"}){const[o,c]=j.useState({}),u=[...t].sort((m,f)=>(m.position??0)-(f.position??0)),d=()=>{var f;const m={};for(const g of u){const x=(f=o[g.id])==null?void 0:f.trim();x&&(m[g.id]=x)}n(m)},h=u.every(m=>{var f;return!m.required||(((f=o[m.id])==null?void 0:f.trim())??"")!==""});return s.jsxs(Et,{isOpen:!0,onClose:r,title:`Run: ${e}`,size:"sm",closeOnEscape:!0,closeOnBackdropClick:!0,children:[s.jsx("div",{className:"space-y-3 py-2",children:u.map(m=>s.jsxs("label",{className:"block",children:[s.jsxs("span",{className:"text-sm text-text-primary font-medium",children:[m.label||m.id,m.required&&s.jsx("span",{className:"text-accent-error ml-1",children:"*"})]}),m.description&&s.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:m.description}),s.jsx("input",{value:o[m.id]??"",onChange:f=>c(g=>({...g,[m.id]:f.target.value})),placeholder:m.label||m.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:(m.position===0||m===u[0])&&Gt()})]},m.id))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border",children:[s.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm text-text-muted hover:text-text-primary transition-colors",children:"Cancel"}),s.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 aj=9999,Lh=j.forwardRef(function({trigger:t,children:n},r){const[a,o]=j.useState(!1),c=j.useRef(null),u=j.useRef(null),d=j.useRef(null),h=j.useCallback(()=>{o(!1)},[]);j.useImperativeHandle(r,()=>({close:h}),[h]);const m=j.useCallback(f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a?h():(d.current=document.activeElement,o(!0))),f.key==="Escape"&&a&&h()},[a,h]);return j.useEffect(()=>{var w;if(!a){Gt()&&((w=d.current)==null||w.focus()),d.current=null;return}const f=C=>{u.current&&!u.current.contains(C.target)&&c.current&&!c.current.contains(C.target)&&h()},g=C=>{C.key==="Escape"&&h()},x=()=>h();return document.addEventListener("mousedown",f),document.addEventListener("keydown",g),window.addEventListener("blur",x),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",g),window.removeEventListener("blur",x)}},[a,h]),s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:c,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),o(f=>!f)},onKeyDown:m,children:t}),a&&wi.createPortal(s.jsx("div",{ref:u,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(!c.current)return{zIndex:aj,top:0,left:0};const f=c.current.getBoundingClientRect(),g=320,x=8;let w=f.left;return w+g>window.innerWidth-x&&(w=f.right-g),w=Math.max(x,Math.min(w,window.innerWidth-g-x)),{zIndex:aj,top:f.bottom+4,left:w}})(),children:s.jsx(pt,{className:"max-h-full",children:n})}),document.body)]})});function RG({entries:e}){const t=new Map;for(const r of e)t.set(r.status,(t.get(r.status)??0)+1);const n=lA.filter(r=>(t.get(r)??0)>0);return n.length===0?s.jsx("span",{className:"text-text-muted text-sm",children:"None"}):s.jsx("span",{className:"flex items-center gap-1.5 text-sm",children:n.map(r=>s.jsxs("span",{className:"flex items-center gap-0.5",children:[s.jsx(Ul,{status:r}),s.jsx("span",{className:"text-text-muted",children:t.get(r)})]},r))})}function DG({visible:e}){const{contextState:t,currentSession:n}=zl(),r=nr(I=>I.status),a=nr(I=>I.config),o=nr(I=>I.start),c=Oe(I=>I.queueUpdate),u=nr(I=>I.logs),{branch:d,diff:h}=Sv(),[m,f]=j.useState(!1),[g,x]=j.useState(!1),[w,C]=j.useState(!1),[v,S]=j.useState(null),[_,b]=j.useState(!1),[k,E]=j.useState(!1),T=j.useRef(null),L=j.useRef(null),A=j.useRef(null),O=j.useRef(null),M=Bt(I=>I.settings[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true";if(!e||!n)return null;const H=Au(n.workspace??"")||"original",B=n.workspace??n.workdir,F=n.metadataEntries??{},K=F.criteria??[],G=["review_findings","todos"],V=G.filter(I=>{var Q;return I in F&&(((Q=F[I])==null?void 0:Q.length)??0)>0}),Z=Object.keys(F).filter(I=>I!=="criteria"&&!G.includes(I)).filter(I=>{var Q;return(((Q=F[I])==null?void 0:Q.length)??0)>0}),J=[...V,...Z].reduce((I,Q)=>{var ne;return I+(((ne=F[Q])==null?void 0:ne.length)??0)},0),z=[...V,...Z].map(wl),P=h.files,D=P.reduce((I,Q)=>I+Q.additions,0),U=P.reduce((I,Q)=>I+Q.deletions,0),$=(r==null?void 0:r.state)??"off",te=$==="running"||$==="warning",q=a!==null,X=I=>{I.stopPropagation(),o()},Y=I=>{I.stopPropagation(),r!=null&&r.url&&window.open(r.url,"_blank")};return s.jsxs("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-secondary",children:[s.jsxs("div",{className:"grid grid-cols-2 @sm:flex @sm:items-center @sm:justify-between gap-x-2 gap-y-1 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-1 min-w-0 @sm:shrink-0",children:[s.jsx(Cr,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary max-w-[120px]",children:H}),s.jsx("span",{className:"text-text-muted",children:"/"}),s.jsx(eo,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary max-w-[120px]",children:d??"-"}),P.length>0?s.jsxs("span",{className:"text-text-muted shrink-0 font-mono",children:["+",D," -",U]}):s.jsx("span",{className:"shrink-0"}),s.jsx(Lh,{ref:O,trigger:s.jsx(gn,{className:"w-3 h-3"}),children:s.jsx(CA,{workspaceName:H,branch:d,workdir:B,showEditorLink:M,sessionId:n.id,projectId:n.projectId,onEditWorkspace:()=>{var I;(I=O.current)==null||I.close(),b(!0)},onEditBranch:()=>{var I;(I=O.current)==null||I.close(),E(!0)}})})]}),s.jsx("div",{className:"hidden @sm:block w-px bg-border self-stretch mx-1"}),s.jsxs("div",{className:"flex-1 flex items-center @sm:justify-center justify-self-end gap-1 min-w-0",children:[s.jsx(RG,{entries:K}),J>0&&s.jsxs("span",{className:"text-text-muted text-xs bg-bg-tertiary px-1 py-0.5 rounded leading-none",title:z.join(", "),children:["+",J]}),s.jsx(Lh,{ref:A,trigger:s.jsx(gn,{className:"w-3 h-3"}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("button",{onClick:()=>{var I;(I=A.current)==null||I.close(),S("criteria")},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(Sf,{entries:K,title:"Acceptance Criteria"})}),s.jsx(dA,{entries:K,sessionId:n.id})]}),[...V,...Z].map(I=>{const Q=F[I];return s.jsxs("div",{children:[s.jsx("button",{onClick:()=>{var ne;(ne=A.current)==null||ne.close(),S(I)},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(Sf,{entries:Q,title:wl(I)})}),s.jsx(cA,{entries:Q})]},I)})]})})]}),s.jsx("div",{className:"hidden @sm:block w-px bg-border self-stretch mx-1"}),s.jsx("div",{className:"col-span-2 border-t border-border @sm:hidden -mx-4"}),s.jsx("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:t&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted text-xs font-mono tabular-nums",children:t.currentTokens>=1e3?`${Math.round(t.currentTokens/1e3)}K`:t.currentTokens}),s.jsx(jv,{percent:Math.round(t.currentTokens/t.maxTokens*100),dangerZone:t.dangerZone,size:"sm"}),s.jsx(Lh,{ref:L,trigger:s.jsx(gn,{className:"w-3 h-3"}),children:s.jsx(jA,{onUpdateSystemPrompt:()=>{var I;(I=L.current)==null||I.close(),C(!0)}})})]})}),s.jsx("div",{className:"hidden @sm:block w-px bg-border self-stretch mx-1"}),s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0 justify-self-end",children:[s.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?te?s.jsx("button",{onClick:Y,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:s.jsx(Cb,{className:"w-3.5 h-3.5"})}):s.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:s.jsx(Wf,{className:"w-3.5 h-3.5"})}):s.jsx("span",{className:"text-text-muted text-xs",children:"No config"}),s.jsx(Lh,{ref:T,trigger:s.jsx(gn,{className:"w-3 h-3"}),children:s.jsx(pA,{workdir:B,compact:!0,onExpand:()=>f(!0),onConfigure:()=>{var I;(I=T.current)==null||I.close(),x(!0)}})})]})]}),m&&s.jsx(kv,{title:"Dev Server Logs",logs:u,onClose:()=>f(!1)}),g&&s.jsx(hA,{isOpen:!0,onClose:()=>x(!1)}),v&&n&&s.jsx(uA,{isOpen:!0,onClose:()=>S(null),entries:F[v]??[],sessionId:n.id,metadataKey:v,title:wl(v)}),_&&s.jsx(SA,{isOpen:!0,onClose:()=>b(!1),projectId:n.projectId,sessionId:n.id,currentWorkspace:H,currentBranch:d}),k&&s.jsx(wA,{isOpen:!0,onClose:()=>E(!1),sessionId:n.id}),w&&t&&s.jsx(Ev,{isOpen:!0,onClose:()=>C(!1),isRunning:n.isRunning,onApply:()=>{n.isRunning?c(n.id):Vt.send("context.applyDynamic",{sessionId:n.id}),C(!1)}})]})}function OG(e){return(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="f"&&document.querySelector("[data-global-settings]")===null}function qA(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 o,c=1,u=null;const d=()=>{if(!u||u.size===0)return;const h=new Map;let m=0;for(const g of e)g.role!=="tool"&&g.contextWindowId===o&&(g.subAgentId&&!h.has(g.subAgentId)&&h.set(g.subAgentId,m),m++);const f=[...u.entries()].sort((g,x)=>(h.get(g[0])??0)-(h.get(x[0])??0));for(const[g,x]of f){const w=r.get(g);(w==null?void 0:w.type)==="subagent"&&w.messages.length===x.messages.length&&w.messages.every((v,S)=>v===x.messages[S])?a.push(w):a.push({type:"subagent",subAgentId:g,subAgentType:x.subAgentType,messages:x.messages})}u=null};for(let h=0;h<e.length;h++){const m=e[h];if(m.role!=="tool")if(m.contextWindowId&&o&&m.contextWindowId!==o&&(d(),c++,a.push({type:"context-divider",windowSequence:c})),o=m.contextWindowId,m.subAgentId&&m.subAgentType){u||(u=new Map);let f=u.get(m.subAgentId);f||(f={subAgentType:m.subAgentType,messages:[]},u.set(m.subAgentId,f)),f.messages.push(m)}else{d();const f=n.get(m.id);(f==null?void 0:f.type)==="message"&&f.message===m?a.push(f):a.push({type:"message",message:m})}}return d(),a}const IG=10,MG=150;function PG(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 BG(e){return[...e].sort((r,a)=>new Date(a.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,IG).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:xU(r.timestamp),trimmedContent:xf(r.content,MG),sessionId:r.sessionId,sessionName:r.sessionName}))}function $G(e,t,n){const r=[],a=e.filter(o=>o.role==="user"&&!o.isSystemGenerated&&o.messageKind!=="auto-prompt");for(const o of a)r.push({id:o.id,content:o.content,timestamp:o.timestamp,sessionId:n??"",sessionName:"This session"});for(const o of t)n&&o.id===n||r.push(...PG(o));return BG(r)}function FG(e,t=[],n=null){const[r,a]=j.useState(0),[o,c]=j.useState(!1),u=j.useMemo(()=>$G(e,t,n),[e,t,n]),d=j.useCallback(()=>{u.length>0&&(a(u.length-1),c(!0))},[u.length]),h=j.useCallback(()=>{c(!1),a(0)},[]),m=j.useCallback(()=>{a(x=>u.length===0?x:x===0?u.length-1:x-1)},[u.length]),f=j.useCallback(()=>{a(x=>u.length===0?x:x===u.length-1?0:x+1)},[u.length]),g=j.useCallback(()=>{if(u.length===0||!o)return null;const x=u[r];return(x==null?void 0:x.content)??null},[u,r,o]);return{history:u,selectedIndex:r,showHistory:o,openHistory:d,closeHistory:h,navigateUp:m,navigateDown:f,selectCurrent:g}}j.memo(function({item:t}){const[n,r]=j.useState(!1);return t.type==="start"?s.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:[s.jsx("span",{className:"animate-pulse",children:"●"}),s.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&s.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):s.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[s.jsx("span",{className:"text-accent-success",children:"✓"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),s.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&&s.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:s.jsx(rr,{content:t.description})})]})]})});function KA({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t,rawMessages:n,hiddenCount:r,sessionId:a}={}){const o=e??!0,[c,u]=j.useState(""),[d,h]=j.useState([]),[m,f]=j.useState(!1),[g,x]=j.useState(null),[w,C]=j.useState(!1),[v,S]=j.useState(!1),[_,b]=j.useState(!1),[k,E]=j.useState(!1),[T,L]=j.useState(null),A=j.useRef(null),O=$u(A),M=Oe(De=>{var Re;return De.focusedSessionId??((Re=De.currentSession)==null?void 0:Re.id)??null}),H=a??M,B=a!=null,F=!B||M===a,K=cn(B?a:null,De=>De.session??null,De=>De.currentSession,null),G=cn(B?a:null,De=>De.messages,De=>De.messages,[]),V=cn(B?a:null,De=>De.hiddenCount??0,De=>De.hiddenCount,0),Z=Oe(De=>De.sessions),J=zf(B?a:null),z=Oe(De=>De.stopGeneration),P=n??G,{maxVisibleItems:D}=Fs(),U=dt(De=>De.defaults),$=dt(De=>De.userItems),te=[...U,...$].filter(De=>!De.subagent),{history:q,selectedIndex:X,showHistory:Y,openHistory:I,closeHistory:Q,navigateUp:ne,navigateDown:re,selectCurrent:ie}=FG(P,Z,K==null?void 0:K.id);j.useEffect(()=>{if(!F)return;const De=Re=>{L(Re.detail.stats)};return window.addEventListener("open-turn-stats",De),()=>window.removeEventListener("open-turn-stats",De)},[F]);const pe=K==null?void 0:K.workdir;j.useEffect(()=>{Wt.getState().setWorkdir(pe),pe&&Wt.getState().fetchWorkflows()},[pe]),j.useEffect(()=>{Wt.getState().fetchWorkflows()},[]),j.useEffect(()=>{if(!F)return;const De=Re=>{OG(Re)&&(Re.preventDefault(),E(!0))};return window.addEventListener("keydown",De),()=>window.removeEventListener("keydown",De)},[F]);const ye=j.useRef([]),{displayItems:Ie,hiddenCount:$e}=j.useMemo(()=>{const De=qA(P,ye.current);return ye.current=De,D>0&&De.length>D?{displayItems:De.slice(-D),hiddenCount:De.length-D}:{displayItems:De,hiddenCount:0}},[P,D]),Se=r??V??$e,{isAutoScrollActive:Ge,setAutoScroll:Je,handleScrollbarGesture:_e}=Bu(A,K,O),{sendMessage:ge,launchWorkflow:he}=UA(Je,H);j.useEffect(()=>{const De=()=>Je(!0);return window.addEventListener(jf,De),()=>window.removeEventListener(jf,De)},[Je]);const[ae,Pe]=j.useState(null),[Ue,de]=j.useState(null),Ae=j.useCallback((De,Re,ke,We="auto")=>{const Ce=lo(Wt.getState()),nt=Vy(Ce,De,We);((nt==null?void 0:nt.parameters)??[]).filter(ht=>ht.position!==void 0||ht.required).length>0?Pe({id:De,name:(nt==null?void 0:nt.name)??De,subGroup:Re,scope:We}):he(void 0,void 0,De,Re,ke,We)},[he]),ue=j.useCallback((De,Re,ke,We)=>{Ae(De,Re,ke,We)},[Ae]),Fe=j.useCallback(De=>{Je(!1);const Re=document.querySelector(`[data-item-index="${De}"]`);Re&&(Re.hasAttribute("data-placeholder")?(window.dispatchEvent(new CustomEvent(Ky,{detail:{index:De}})),requestAnimationFrame(()=>requestAnimationFrame(()=>{var ke;(ke=document.querySelector(`[data-item-index="${De}"]`))==null||ke.scrollIntoView({behavior:"smooth",block:"center"})}))):Re.scrollIntoView({behavior:"smooth",block:"center"}))},[Je]);j.useEffect(()=>{if(!F)return;const De=Re=>{const ke=_||w||v||k||T;Re.key==="Escape"&&J&&!ke&&H&&z(H),Re.key==="ScrollLock"&&Je(!Ge)};return window.addEventListener("keydown",De),()=>window.removeEventListener("keydown",De)},[F,J,z,Ge,_,w,v,k,T]);const Xe=Nu();gu(F?Xe.quickAction:null,()=>{b(!0)}),gu(F?Xe.criteriaSidebar:null,()=>{t==null||t()}),dO(F?Xe.agentSwitching:[],F?te:[],De=>{H&&Oe.getState().switchMode(H,De)});const it=(De,Re)=>{Ae(De,void 0,void 0,Re),lt()},Ze=(De,Re,ke)=>{Ae(De,Re,void 0,ke),lt()},lt=()=>{u(""),h([]),K!=null&&K.id&&localStorage.removeItem(`openfox:draft:${K.id}`)},gt=j.useCallback(async(De,Re,ke,We)=>{const Ce=zA(De);if(Ce.length>0)de({prompt:De,paramKeys:Ce,agentMode:Re,textareaContent:ke,attachments:We});else{Re&&H&&(K==null?void 0:K.mode)!==Re&&await Oe.getState().switchMode(H,Re);const nt=ke&&ke.trim()?`${ke.trim()}
|
|
321
|
+
|
|
322
|
+
${De}`:De;ge(nt,We!=null&&We.length?We:void 0,{messageKind:"command",isSystemGenerated:!0}),lt()}},[ge,lt,K]);return s.jsxs(p9,{value:H,children:[s.jsxs(mV,{criteriaSidebarOpen:o,onCriteriaSidebarToggle:t,messages:P,sessionId:H,children:[s.jsx(DG,{visible:!o}),s.jsx(pV,{}),T&&s.jsx(gV,{stats:T,onClose:()=>L(null)}),s.jsx(BW,{}),s.jsx(MW,{displayItems:Ie,scrollContainerRef:A,highlightedMessageId:null,onLaunchWorkflow:ue,onScrollToTop:()=>Je(!1),hiddenCount:Se,onScrollbarGesture:_e,emptyState:P.length===0&&(K!=null&&K.projectId)?s.jsx(LG,{projectId:K.projectId}):void 0}),s.jsx(TG,{input:c,setInput:u,attachments:d,setAttachments:h,dragOver:m,setDragOver:f,errorMessage:g,setErrorMessage:x,scrollToBottom:()=>{var De,Re;return(Re=O())==null?void 0:Re.scrollTo({top:((De=O())==null?void 0:De.scrollHeight)??0,behavior:"smooth"})},sessionId:H,showHistory:Y,history:q,selectedIndex:X,openHistory:I,closeHistory:Q,navigateUp:ne,navigateDown:re,selectCurrent:ie,isAutoScrollActive:Ge,setAutoScroll:Je,onOpenMessageSearch:()=>E(!0),onOpenCommandsModal:()=>C(!0),onOpenWorkflowsModal:()=>S(!0),onSelectWorkflow:it,onSelectWorkflowWithSubGroup:Ze,onSendCommand:gt,clearInput:lt}),s.jsx(PA,{isOpen:w,onClose:()=>C(!1),projectDir:K==null?void 0:K.workdir}),s.jsx(FA,{isOpen:v,onClose:()=>S(!1),projectDir:K==null?void 0:K.workdir}),s.jsx(JW,{isOpen:_,onClose:()=>b(!1),onSearchMessages:()=>E(!0),isAutoScrollActive:Ge,onToggleAutoScroll:Je,textareaContent:c,onCloseComplete:ku,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(De,Re)=>{const ke=await fn.getState().fetchCommand(De,K==null?void 0:K.workdir);ke&>(ke.prompt,ke.metadata.agentMode,Re)},onSelectWorkflow:(De,Re)=>{Ae(De,void 0,void 0,Re),lt()}}),ae&&s.jsx(ij,{workflowName:ae.name,parameters:(()=>{var Re;const De=lo(Wt.getState());return((Re=Vy(De,ae.id,ae.scope))==null?void 0:Re.parameters)??[]})(),onConfirm:De=>{he(void 0,void 0,ae.id,ae.subGroup,De,ae.scope),Pe(null)},onCancel:()=>Pe(null)}),Ue&&s.jsx(ij,{workflowName:"Command",confirmLabel:"Launch command",parameters:Ue.paramKeys.map((De,Re)=>({id:De,label:De,position:Re})),onConfirm:De=>{let Re=Ue.prompt;for(const[tt,ht]of Object.entries(De))Re=Re.replaceAll(`{{${tt}}}`,ht);const{agentMode:ke,textareaContent:We,attachments:Ce}=Ue;ke&&H&&(K==null?void 0:K.mode)!==ke&&Oe.getState().switchMode(H,ke);const nt=We&&We.trim()?`${We.trim()}
|
|
323
|
+
|
|
324
|
+
${Re}`:Re;ge(nt,Ce!=null&&Ce.length?Ce:void 0,{messageKind:"command",isSystemGenerated:!0}),lt(),de(null)},onCancel:()=>de(null)})]}),k&&s.jsx(oG,{isOpen:k,onClose:()=>{E(!1),ku(!0)},displayItems:Ie,onNavigate:Fe})]})}function HG(){var b;const[,e]=Dl("/p/:projectId/s/:sessionId/readonly"),t=e==null?void 0:e.sessionId,[n,r]=j.useState(null),[a,o]=j.useState([]),[c,u]=j.useState(0),[d,h]=j.useState(!0),[m,f]=j.useState(null),g=async()=>{if(t){h(!0),f(null);try{const k=await me(`/api/sessions/${t}?full=true`);if(!k.ok){f(`Failed to load session (${k.status})`),h(!1);return}const E=await k.json();r(E.session??null),o(E.messages??[]),u(E.hiddenCount??0)}catch(k){f(k instanceof Error?k.message:"Unknown error")}finally{h(!1)}}};j.useEffect(()=>{Bt.getState().getSettings([...xb])},[]),j.useEffect(()=>{g()},[t]);const{showThinking:x,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:v,showWorkflowBars:S}=Fs(),_=j.useMemo(()=>qA(a),[a]);return d?s.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:s.jsx(fa,{})}):m?s.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:s.jsxs("div",{className:"text-center space-y-4",children:[s.jsx("div",{className:"text-red-400 text-sm",children:m}),s.jsx("button",{onClick:g,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"})]})}):s.jsxs("div",{className:"h-screen print:h-auto flex flex-col bg-primary",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-secondary shrink-0 print:hidden",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.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"]}),s.jsxs("span",{className:"text-xs text-text-muted whitespace-nowrap",children:[a.length," messages",c>0?` (${c} older hidden)`:""]})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("button",{onClick:g,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"})})]}),s.jsxs(pt,{className:"flex-1 print:overflow-visible",children:[s.jsx("div",{className:"pt-4",children:s.jsx(MA,{displayItems:_,showThinking:x,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:v,showWorkflowBars:S})}),s.jsx("div",{className:"h-8"})]})]})}const zG=788;function oj({sessionId:e,focused:t,onFocus:n,onClose:r,className:a}){var T,L,A,O;const o=j.useRef(null),[c,u]=j.useState(!1),d=j.useRef(!1),h=j.useRef(null);j.useEffect(()=>{const M=o.current;if(!M||typeof ResizeObserver>"u")return;const H=new ResizeObserver(()=>{const B=M.clientWidth>=zG;h.current!==null&&h.current!==B&&(d.current=!1),h.current=B,d.current||u(B)});return H.observe(M),()=>H.disconnect()},[]);const m=Oe(M=>M.panes[e]),f=(T=m==null?void 0:m.session)==null?void 0:T.projectId,g=Pt(M=>f?M.projects.find(H=>H.id===f):void 0),x=((A=(L=m==null?void 0:m.session)==null?void 0:L.metadata)==null?void 0:A.title)??e.slice(0,8),w=((O=m==null?void 0:m.session)==null?void 0:O.isRunning)??!1,C=(m==null?void 0:m.pendingPathConfirmations.length)??0,v=(m==null?void 0:m.pendingQuestions.length)??0,[S,_]=j.useState(!1),[b,k]=j.useState(!1),E=j.useMemo(()=>{const M=[];return v>0&&M.push(`${v} question${v>1?"s":""}`),C>0&&M.push(`${C} confirmation${C>1?"s":""}`),M},[v,C]);return s.jsxs("div",{ref:o,"data-split-pane":e,"data-focused":t?"true":"false",className:`${a??""} @container relative flex flex-col min-w-0 min-h-0 overflow-hidden ${t?"ring-1 ring-inset ring-accent-primary/50":""}`,onClick:n,children:[s.jsxs("div",{className:"flex items-center gap-2 px-2 h-8 border-b border-border bg-secondary shrink-0",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${w?"bg-emerald-400 animate-pulse":"bg-text-muted/40"}`,title:w?"Running":"Not running"}),g?s.jsx(ho,{items:[{label:"Manage tasks",icon:s.jsx(Kf,{className:"w-4 h-4"}),onClick:()=>_(!0)},{label:"Open project folder",icon:s.jsx(Cr,{className:"w-4 h-4"}),onClick:()=>{me(`/api/projects/${g.id}/open-folder`).catch(()=>{})}},{label:"Edit project settings",icon:s.jsx(CE,{className:"w-4 h-4"}),onClick:()=>k(!0)}],minWidth:"170px",trigger:s.jsxs("button",{type:"button",title:g.name,className:"text-[10px] font-semibold uppercase tracking-wide text-accent-primary shrink-0 max-w-[110px] flex items-center gap-0.5 hover:underline",children:[s.jsx("span",{className:"truncate",children:g.name}),s.jsx(gn,{className:"w-3 h-3 shrink-0"})]})}):s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-accent-primary shrink-0 max-w-[80px] truncate",children:f?f.slice(0,10):"…"}),s.jsx("span",{className:"text-xs text-text-primary truncate flex-1 min-w-0",title:x,children:x}),E.length>0&&s.jsx("span",{className:"flex items-center gap-1 text-[10px] text-amber-400 shrink-0",title:E.join(" · "),children:E.join(" · ")}),s.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),d.current=!0,u(H=>!H)},className:`p-1 rounded hover:bg-bg-tertiary transition-colors shrink-0 ${c?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:c?"Hide criteria sidebar":"Show criteria sidebar","aria-label":c?"Hide criteria sidebar":"Show criteria sidebar",children:s.jsx(cy,{className:"w-3.5 h-3.5"})}),s.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),r()},className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors shrink-0",title:"Close pane","aria-label":"Close pane",children:s.jsx(Ss,{className:"w-3.5 h-3.5"})})]}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 bg-primary relative",children:s.jsx(KA,{sessionId:e,criteriaSidebarOpen:c,onCriteriaSidebarToggle:()=>{d.current=!0,u(M=>!M)}})}),g&&s.jsxs(s.Fragment,{children:[s.jsx(vm,{isOpen:S,onClose:()=>_(!1),projectId:g.id}),s.jsx(ZT,{isOpen:b,onClose:()=>k(!1),project:g})]})]})}function UG(e,t,n={}){const r=n.windowMinutes??30,a=n.bucketMinutes??3,o=r*6e4,c=a*6e4,u=Math.max(1,Math.floor(o/c)),d=t-o,h=new Array(u).fill(0);for(const m of e){const f=aA(m);if(!f)continue;const g=new Map;for(const x of f.dataPoints){const w=new Date(x.timestamp).getTime();if(Number.isNaN(w)||w<d||w>t)continue;const C=Math.min(u-1,Math.max(0,Math.floor((w-d)/c))),v=g.get(C)??[];g.set(C,[...v,x.generationSpeed])}for(const[x,w]of g){const C=w.reduce((v,S)=>v+S,0)/w.length;h[x]=(h[x]??0)+C}}return h.map((m,f)=>({x:d+f*c,y:m}))}const Xy=280,Zi=44,Ef=4;function VG(e,t){const n=e.map((a,o)=>{const c=o/Math.max(1,e.length-1)*Xy,u=Zi-Ef-a.y/t*(Zi-Ef*2);return{x:c,y:u}});if(n.length===0)return"";if(n.length===1)return`M ${n[0].x.toFixed(1)} ${n[0].y.toFixed(1)}`;let r=`M ${n[0].x.toFixed(1)} ${n[0].y.toFixed(1)}`;for(let a=0;a<n.length-1;a++){const o=n[Math.max(0,a-1)],c=n[a],u=n[a+1],d=n[Math.min(n.length-1,a+2)],h=c.x+(u.x-o.x)/6,m=c.y+(u.y-o.y)/6,f=u.x-(d.x-c.x)/6,g=u.y-(d.y-c.y)/6;r+=` C ${h.toFixed(1)} ${m.toFixed(1)}, ${f.toFixed(1)} ${g.toFixed(1)}, ${u.x.toFixed(1)} ${u.y.toFixed(1)}`}return r}function WG(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function GG(e,t,n){if(n<=0||t<=0)return Math.min(100,Math.max(0,e));const r=Math.min(t/2/n*100,50);return Math.min(Math.max(e,r),100-r)}function qG(){const e=Oe(b=>b.openSessionIds),t=Oe(GT(b=>Object.fromEntries(e.map(k=>{var E;return[k,(E=b.panes[k])==null?void 0:E.messages]})))),[n,r]=j.useState(()=>Date.now()),[a,o]=j.useState(null),[c,u]=j.useState(null),d=j.useRef(null),h=j.useRef(null);j.useEffect(()=>{const b=setInterval(()=>r(Date.now()),6e4);return()=>clearInterval(b)},[]),j.useEffect(()=>{const b=d.current,k=h.current;!b||!k||u({width:k.offsetWidth,container:b.clientWidth})},[a]);const m=j.useMemo(()=>Object.values(t).filter(b=>!!b),[t]),f=j.useMemo(()=>UG(m,n),[m,n]),g=j.useMemo(()=>f.reduce((b,k)=>Math.max(b,k.y),0),[f]),x=j.useMemo(()=>g>0?VG(f,g):"",[f,g]),w=f.length-1,C=b=>b/Math.max(1,w)*100,v=b=>(Zi-Ef-b/g*(Zi-Ef*2))/Zi*100,S=a!==null?GG(C(a),(c==null?void 0:c.width)??0,(c==null?void 0:c.container)??0):0,_=b=>{const k=b.currentTarget.getBoundingClientRect();if(k.width<=0)return;const E=(b.clientX-k.left)/k.width;o(Math.min(w,Math.max(0,Math.round(E*w))))};return s.jsxs("div",{"data-testid":"aggregate-stats",title:"Combined generation speed across open panes, last 30 min (3-min buckets)",children:[s.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[s.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:"Generation"}),g>0&&s.jsxs("span",{className:"text-[10px] text-text-muted",title:"Peak combined generation speed in the window",children:[Math.round(g)," tok/s"]})]}),g>0?s.jsxs("div",{"data-testid":"aggregate-chart",ref:d,className:"relative",onMouseMove:_,onMouseLeave:()=>o(null),children:[s.jsxs("svg",{viewBox:`0 0 ${Xy} ${Zi}`,className:"w-full h-9",preserveAspectRatio:"none","aria-label":"Generation speed over the last 30 minutes",role:"img",children:[s.jsx("path",{d:`${x} L ${Xy} ${Zi} L 0 ${Zi} Z`,fill:"currentColor",className:"text-accent-primary/15"}),s.jsx("path",{d:x,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke",className:"text-accent-primary"})]}),a!==null&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"pointer-events-none absolute w-1.5 h-1.5 rounded-full bg-accent-primary -translate-x-1/2 -translate-y-1/2",style:{left:`${C(a)}%`,top:`${v(f[a].y)}%`}}),s.jsxs("div",{ref:h,"data-testid":"aggregate-tooltip",className:"pointer-events-none absolute z-10 -translate-x-1/2 -translate-y-full whitespace-nowrap rounded bg-bg-tertiary px-1.5 py-0.5 text-[10px] text-text-secondary shadow",style:{left:`${S}%`,top:`${v(f[a].y)}%`},children:[WG(f[a].x)," · ",Math.round(f[a].y)," tok/s"]})]})]}):s.jsx("p",{className:"text-xs text-text-muted",children:"No generation in the last 30 min"})]})}function KG({isOpen:e,onClose:t}){const n=Pt(g=>g.projects),r=Pt(g=>g.listProjects),a=Oe(g=>g.createSession),o=Oe(g=>g.openPane),c=Oe(g=>g.resetPendingSessionCreate),[u,d]=j.useState(!1),[h,m]=j.useState(null);j.useEffect(()=>{e&&(d(!1),m(null),r())},[e,r]);const f=async g=>{if(!u){d(!0),m(null);try{const x=await a(g);if(!x){m("Could not create the session — please try again.");return}await o(x.id,{focus:!0}),c(),t()}catch{m("Could not create the session — please try again.")}finally{d(!1)}}};return s.jsxs(Et,{isOpen:e,onClose:t,title:"New session",size:"sm",footer:s.jsx("div",{className:"flex justify-end",children:s.jsx(ot,{variant:"secondary",onClick:t,children:"Close"})}),children:[s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Choose the project for the new session."}),h&&s.jsx("div",{className:"mb-3 px-3 py-2 rounded bg-accent-error/10 border border-accent-error/30 text-sm text-accent-error",children:h}),n.length===0?s.jsx("p",{className:"text-sm text-text-muted",children:"No projects yet — create one from the home page first."}):s.jsx("div",{className:"flex flex-col gap-1",children:n.map(g=>s.jsxs("button",{type:"button",onClick:()=>void f(g.id),disabled:u,className:"flex items-center gap-3 rounded px-3 py-2 text-left hover:bg-bg-tertiary transition-colors disabled:opacity-50",children:[s.jsx(Cr,{className:"w-4 h-4 text-accent-primary shrink-0"}),s.jsx("span",{className:"font-medium truncate text-sm",children:g.name}),s.jsx("span",{className:"text-xs text-text-muted truncate ml-auto",children:Ab(g.workdir,24)})]},g.id))})]})}function lj(e,t){return t??e.slice(0,8)}function YG({collapsed:e=!1,layout:t,onLayoutChange:n}){const[r,a]=j.useState(!1),o=Oe(_=>_.openSessionIds),c=Oe(_=>{var b;return _.focusedSessionId??((b=_.currentSession)==null?void 0:b.id)}),u=Oe(_=>_.panes),d=Oe(_=>_.sessions),h=Oe(_=>_.focusPane),m=Oe(_=>_.closePane),f=Oe(_=>_.reorderPane),g=Oe(_=>_.openPane),x=Oe(_=>_.isPaneOpen),w=Pt(_=>_.projects),C=j.useMemo(()=>new Map(w.map(_=>[_.id,_])),[w]),v=j.useMemo(()=>[...d].sort((_,b)=>_.isRunning!==b.isRunning?_.isRunning?-1:1:new Date(b.updatedAt).getTime()-new Date(_.updatedAt).getTime()),[d]),S=_=>{x(_.id)?h(_.id):g(_.id,{focus:!0})};return s.jsxs("aside",{"data-testid":"split-control-panel",className:`shrink-0 border-r border-border bg-secondary flex flex-col min-h-0 transition-[width] duration-200 ${e?"w-0 overflow-hidden border-r-0":"w-56"}`,"aria-hidden":e,children:[s.jsxs("div",{className:"flex items-center gap-1 px-2 h-9 border-b border-border shrink-0",children:[s.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted whitespace-nowrap",children:"Split view"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:o.length}),s.jsxs("div",{className:"flex items-center rounded bg-bg-tertiary p-0.5 ml-1",role:"group","aria-label":"Pane layout",children:[s.jsx("button",{type:"button",onClick:()=>n("columns"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${t==="columns"?"bg-accent-primary/25 text-text-primary":"text-text-muted hover:text-text-primary"}`,title:"Stack panes as columns","aria-label":"Columns layout","aria-pressed":t==="columns",children:"Columns"}),s.jsx("button",{type:"button",onClick:()=>n("grid"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${t==="grid"?"bg-accent-primary/25 text-text-primary":"text-text-muted hover:text-text-primary"}`,title:"Arrange panes in a grid","aria-label":"Grid layout","aria-pressed":t==="grid",children:"Grid"})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[s.jsxs("div",{className:"px-3 pt-3 pb-2",children:[s.jsx("h2",{className:"text-[10px] font-semibold uppercase tracking-wide text-text-muted mb-1",children:"Open panes"}),o.length===0?s.jsx("p",{className:"text-xs text-text-muted",children:"No panes open — pick a session below."}):s.jsx("ul",{className:"space-y-0.5",children:o.map((_,b)=>{var T,L,A;const k=_===c,E=lj(_,(A=(L=(T=u[_])==null?void 0:T.session)==null?void 0:L.metadata)==null?void 0:A.title);return s.jsxs("li",{className:`group flex items-center gap-1 rounded px-1.5 py-1 cursor-pointer ${k?"bg-bg-tertiary":"hover:bg-bg-tertiary/50"}`,onClick:()=>h(_),"data-open-pane":_,children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${k?"bg-accent-primary":"bg-text-muted/40"}`}),s.jsx("span",{className:"text-xs text-text-primary truncate flex-1 min-w-0",title:E,children:E}),s.jsxs("div",{className:"flex items-center gap-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx("button",{type:"button",onClick:O=>{O.stopPropagation(),f(_,-1)},disabled:b===0,className:"p-0.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary disabled:opacity-30 disabled:cursor-default",title:"Move pane left","aria-label":"Move pane left",children:s.jsx(vb,{className:"w-3 h-3"})}),s.jsx("button",{type:"button",onClick:O=>{O.stopPropagation(),f(_,1)},disabled:b===o.length-1,className:"p-0.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary disabled:opacity-30 disabled:cursor-default",title:"Move pane right","aria-label":"Move pane right",children:s.jsx(gn,{className:"w-3 h-3"})}),s.jsx("button",{type:"button",onClick:O=>{O.stopPropagation(),m(_)},className:"p-0.5 rounded hover:bg-bg-secondary text-text-muted hover:text-text-primary",title:"Close pane","aria-label":"Close pane",children:s.jsx(Ss,{className:"w-3 h-3"})})]})]},_)})})]}),s.jsx("div",{className:"px-3 pt-3 pb-4 border-t border-border",children:s.jsx(qG,{})}),s.jsxs("div",{className:"px-3 pt-3 pb-4 border-t border-border",children:[s.jsxs("div",{className:"flex items-center mb-1",children:[s.jsx("h2",{className:"text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:"Sessions"}),s.jsx("button",{type:"button",onClick:()=>a(!0),className:"ml-auto p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New session","aria-label":"New session",children:s.jsx(Hr,{className:"w-3.5 h-3.5"})})]}),v.length===0?s.jsx("p",{className:"text-xs text-text-muted",children:"No sessions yet."}):s.jsx("ul",{className:"space-y-0.5",children:v.map(_=>{var k;const b=x(_.id);return s.jsxs("li",{className:"flex items-center gap-1.5 rounded px-1.5 py-1 cursor-pointer hover:bg-bg-tertiary/50",onClick:()=>S(_),"data-session-item":_.id,title:b?"Focus pane":"Open in split view",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${_.isRunning?"bg-emerald-400 animate-pulse":"bg-text-muted/40"}`}),s.jsx("span",{className:"text-xs text-text-primary truncate flex-1 min-w-0",children:lj(_.id,_.title)}),s.jsx("span",{className:"text-[9px] text-accent-primary truncate max-w-[60px] shrink-0",children:((k=C.get(_.projectId))==null?void 0:k.name)??_.projectId.slice(0,8)})]},_.id)})})]})]}),s.jsx(KG,{isOpen:r,onClose:()=>a(!1)})]})}function XG({controlOpen:e=!0}){const t=Oe(h=>h.openSessionIds),n=Oe(h=>{var m;return h.focusedSessionId??((m=h.currentSession)==null?void 0:m.id)}),r=Oe(h=>h.focusPane),a=Oe(h=>h.closePane),o=Oe(h=>h.listHomeSessions),[c,u]=j.useState(h3);j.useEffect(()=>{f3(c)},[c]),j.useEffect(()=>{o();const h=setInterval(()=>void o(),2e4),m=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",m),()=>{clearInterval(h),document.removeEventListener("visibilitychange",m)}},[o]);const d=t.length===0?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("p",{className:"text-sm text-text-muted px-4 text-center",children:"No panes open — pick a session on the left to open it in split view."})}):c==="columns"?s.jsx("div",{className:"flex gap-px bg-border flex-1 min-w-0 min-h-0",children:t.map(h=>{const m=h===n;return s.jsx(oj,{className:"flex-1",sessionId:h,focused:m,onFocus:()=>r(h),onClose:()=>a(h)},h)})}):s.jsx("div",{className:`grid gap-px bg-border flex-1 min-w-0 min-h-0 ${t.length<=1?"grid-cols-1":"grid-cols-2"}`,children:t.map(h=>{const m=h===n;return s.jsx(oj,{sessionId:h,focused:m,onFocus:()=>r(h),onClose:()=>a(h)},h)})});return s.jsxs("div",{className:"flex-1 min-w-0 flex h-full min-h-0 bg-primary",children:[s.jsx(YG,{collapsed:!e,layout:c,onLayoutChange:u}),d]})}function cj({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[a,o]=j.useState(""),c=j.useRef(null);j.useEffect(()=>{e&&(o(""),setTimeout(()=>{var d;Gt()&&((d=c.current)==null||d.focus())},100))},[e]);const u=d=>{d.preventDefault(),a.trim()&&n(a)};return s.jsx(Et,{isOpen:e,onClose:r,title:t?"Invalid Password":"Password Required",size:"sm",children:s.jsxs("form",{onSubmit:u,className:"space-y-4",children:[s.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."}),s.jsx(Ms,{ref:c,type:"password",value:a,onChange:d=>o(d.target.value),placeholder:"Enter password",autoFocus:Gt()}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(ot,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(ot,{type:"submit",disabled:!a.trim(),children:t?"Try Again":"Connect"})]})]})})}function QG({currentStep:e,totalSteps:t,labels:n,onStepClick:r}){return s.jsx("div",{className:"flex justify-center py-6",children:s.jsx("div",{className:"flex items-center",children:Array.from({length:t},(a,o)=>{const c=o+1,u=c<e,d=c===e;return s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{onClick:()=>r==null?void 0:r(c),className:`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors shrink-0 ${u?"bg-accent-primary text-text-primary hover:opacity-80":d?"bg-accent-primary text-text-primary":"bg-bg-tertiary text-text-muted"}`,children:u?"✓":c}),s.jsx("button",{onClick:()=>r==null?void 0:r(c),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[o]}),o<t-1&&s.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${u?"bg-accent-primary":"bg-border"}`})]},o)})})})}function JG({onNext:e}){const[t,n]=j.useState([]),[r,a]=j.useState([]),[o,c]=j.useState(!1),[u,d]=j.useState(null),[h,m]=j.useState(null),[f,g]=j.useState(null);j.useEffect(()=>{x()},[]);async function x(){try{const E=await me("/api/providers");if(E.ok){const L=(await E.json()).providers.map(A=>({id:A.id,name:A.name,url:A.url,backend:A.backend,model:null,apiKey:A.apiKey,isLocal:A.isLocal,thinkingField:A.thinkingField,sendReasoningInMessages:A.sendReasoningInMessages,models:A.models}));n(L),a(L)}}catch{}}async function w(E){const T=E.id.startsWith("temp-"),L=r.some(M=>M.id===E.id),A=r.length===0&&u===null,O=WA(E);try{let M;if(T){const B=await me("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)});if(!B.ok)throw new Error("Failed to create provider");const F=await B.json();M={...E,id:F.provider.id,model:null}}else{if(!(await me(`/api/providers/${E.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)})).ok)throw new Error("Failed to update provider");M={...E,model:null}}const H=B=>B.some(F=>F.id===M.id)?B.map(F=>F.id===M.id?M:F):[...B,M];a(H),n(H),A&&!L&&e({providers:[M]})}catch{if(T){const M={...E,model:null};a(H=>[...H,M])}}}function C(){d(null),c(!0)}function v(E){d(E),c(!0)}function S(){c(!1),d(null)}function _(E){m(E),t.some(L=>L.id===E)?me(`/api/providers/${E}`,{method:"DELETE"}).then(()=>{a(r.filter(L=>L.id!==E)),n(t.filter(L=>L.id!==E)),m(null)}).catch(()=>m(null)):(a(r.filter(L=>L.id!==E)),m(null))}function b(){const E=r.filter(T=>!T.id.startsWith("temp-"));e({providers:E})}const k=r.length>0;return s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),s.jsxs("div",{className:"space-y-4",children:[r.length>0?s.jsx("div",{className:"space-y-2",children:r.map(E=>s.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:hE(E.backend)}),s.jsx("span",{className:"text-text-primary font-medium",children:E.name}),s.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"})]}),s.jsx("p",{className:"text-text-muted text-sm mt-1 truncate",children:E.url}),E.model&&s.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",E.model]})]}),s.jsx("div",{className:"flex items-center gap-1",children:f===E.id?s.jsxs("div",{className:"flex items-center gap-1",children:[s.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"}),s.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"})]}):s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("button",{onClick:()=>g(E.id),className:"p-2 text-text-muted hover:text-red-500 transition-colors",title:"Remove provider",children:s.jsx(Si,{})})]})})]},E.id))}):s.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:s.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),s.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:[s.jsx(Hr,{className:"w-4 h-4"}),"Add Provider"]}),s.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"})]}),s.jsx(GA,{isOpen:o,onClose:S,onSave:w,initialStep:1,editProvider:u??void 0})]})}function ZG({onNext:e}){const[t,n]=j.useState(""),[r,a]=j.useState(!1);return j.useEffect(()=>{me("/api/config").then(o=>o.json()).then(o=>{o.workdir?n(o.workdir):fetch(vs("/api/directories?path=")+encodeURIComponent("/home")).then(c=>c.json()).then(c=>{c.current&&n(c.current)}).catch(()=>{})}).catch(()=>{fetch(vs("/api/directories?path=")+encodeURIComponent("/home")).then(o=>o.json()).then(o=>{o.current&&n(o.current)}).catch(()=>{})})},[]),s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:t,onChange:o=>n(o.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"}),s.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&&s.jsx(Qf,{initialPath:t||void 0,onSelect:o=>{n(o),a(!1)},onClose:()=>a(!1)}),s.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 eq(e){var t;return((t=e.split("/").pop())==null?void 0:t.replace(/-/g," "))??e}function tq(e){return j.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??eq(r.id)});return t},[e])}function nq({value:e,options:t,onChange:n,className:r}){return s.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:[s.jsx("option",{value:"",children:"Manual configuration..."}),t.map(a=>s.jsxs("option",{value:`${a.providerId}/${a.modelId}`,children:[a.providerName," • ",a.modelName]},`${a.providerId}/${a.modelId}`))]})}function rq({backend:e,url:t,model:n,apiKey:r,onBackendChange:a,onUrlChange:o,onModelChange:c,onApiKeyChange:u}){return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Backend type"}),s.jsxs("select",{value:e,onChange:d=>a(d.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:[s.jsx("option",{value:"ollama",children:"Ollama"}),s.jsx("option",{value:"openai",children:"OpenAI-compatible (vLLM, sglang, llama.cpp)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),s.jsx("input",{type:"text",value:t,onChange:d=>o(d.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),s.jsx("input",{type:"text",value:n,onChange:d=>c(d.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"})]}),e==="openai"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"API key (optional)"}),s.jsx("input",{type:"password",value:r,onChange:d=>u(d.target.value),placeholder:"Leave empty for a local server that needs no auth",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 sq(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 iq(e,t,n){return r=>{e(r),r&&(t(""),n(""))}}function aq({enabled:e,hasOptions:t,selectedRef:n,visionModelOptions:r,onProviderModelSelect:a,noOptionsMessage:o,children:c,...u}){return e?s.jsxs("div",{className:"space-y-4 pl-8",children:[t?s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model from your providers"}),s.jsx(nq,{value:n,options:r,onChange:a})]}):s.jsx("p",{className:"text-sm text-text-muted italic",children:o}),s.jsx(rq,{...u}),c]}):null}function oq({onNext:e}){const[t,n]=j.useState(!1),[r,a]=j.useState("http://localhost:11434"),[o,c]=j.useState("qwen3.5:0.8b"),[u,d]=j.useState(""),[h,m]=j.useState("ollama"),[f,g]=j.useState([]),[x,w]=j.useState(""),{copied:C,copy:v}=wT();j.useEffect(()=>{me("/api/config").then(L=>L.json()).then(L=>{L.visionFallback&&(n(L.visionFallback.enabled),L.visionFallback.providerModelRef?w(L.visionFallback.providerModelRef):(a(L.visionFallback.url??"http://localhost:11434"),c(L.visionFallback.model??"qwen3.5:0.8b"),d(L.visionFallback.apiKey??""),L.visionFallback.backend&&m(L.visionFallback.backend))),L.providers&&g(L.providers)}).catch(()=>{})},[]);const S=tq(f),_=iq(w,a,c),b=sq(m,w,a,c);function k(L){if(L){e({});return}e(t&&x?{visionFallback:{enabled:t,providerModelRef:x,timeout:120}}:{visionFallback:{enabled:t,url:r,model:o,timeout:120,backend:h,providerModelRef:"",apiKey:h==="openai"?u:""}})}const E=S.length>0;return s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"You need a server with a vision model. Choose your backend type below."}),s.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"For Ollama:"}),s.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),s.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[s.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3.5:0.8b"}),s.jsx("button",{onClick:()=>v("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:C?s.jsx(Hs,{className:"w-4 h-4 text-accent-primary"}):s.jsx(X3,{className:"w-4 h-4"})})]}),s.jsxs("p",{className:"text-text-secondary text-sm mt-3",children:["For OpenAI-compatible servers (vLLM, sglang, llama.cpp): use the ",s.jsx("strong",{children:"OpenAI"})," backend type."]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t,onChange:L=>n(L.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),s.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),s.jsx(aq,{enabled:t,hasOptions:E,selectedRef:x,visionModelOptions:S,onProviderModelSelect:_,backend:h,url:r,model:o,apiKey:u,onBackendChange:b,onUrlChange:a,onModelChange:c,onApiKeyChange:d,noOptionsMessage:"No vision-capable models found in your providers. You can manually enter a model below."}),s.jsxs("div",{className:"flex items-center justify-between pt-4",children:[s.jsx("button",{onClick:()=>k(!0),"data-testid":"onboarding-skip-button",className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),s.jsx("button",{onClick:()=>k(!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 lq({onComplete:e}){const[t,n]=j.useState(1),[r,a]=j.useState(!1),[o,c]=j.useState({});async function u(f){c(g=>({...g,providers:f.providers})),n(2)}async function d(f){c(g=>({...g,...f})),n(3)}async function h(f){a(!0);try{if(!(await me("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:o.workdir,visionFallback:f.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(g){console.error("Failed to save onboarding data:",g),a(!1)}}const m=f=>{n(f)};return s.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[s.jsx(Pu,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),s.jsx(QG,{currentStep:t,totalSteps:3,labels:["LLM Providers","Projects Folder","Vision"],onStepClick:m}),s.jsx("div",{className:"max-w-xl mx-auto",children:r?s.jsxs("div",{className:"text-center",children:[s.jsx(Hr,{className:"w-6 h-6"}),s.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):s.jsxs(s.Fragment,{children:[t===1&&s.jsx(JG,{onNext:u}),t===2&&s.jsx(ZG,{onNext:d}),t===3&&s.jsx(oq,{onNext:h})]})})]})}function cq({projectId:e}){var m;const[,t]=Nn(),n=Oe(f=>f.sessionsWithPendingConfirmations),r=Oe(f=>{var g;return(g=f.currentSession)==null?void 0:g.id}),a=Oe(f=>f.crossSessionConfirmations),o=Oe(f=>f.sessions),c=n.find(f=>f!==r);if(!c)return null;const u=o.find(f=>f.id===c),d=(u==null?void 0:u.title)??c.slice(0,6),h=((m=a[c])==null?void 0:m.length)??0;return s.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/${c}`:`/s/${c}`),role:"button",tabIndex:0,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&t(e?`/p/${e}/s/${c}`:`/s/${c}`)},children:[s.jsx(Vf,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),s.jsxs("span",{className:"text-sm text-amber-300 flex-1 truncate",children:[h," confirmation",h>1?"s":"",' pending in session "',d,'"']}),s.jsx("span",{className:"text-xs text-amber-400 font-medium flex-shrink-0",children:"View session →"})]})}const Wx="openfox_updated_to",Gx="update_pending";function uq(){const[e,t]=j.useState(!1),n=localStorage.getItem(Wx),r=localStorage.getItem(Gx);j.useEffect(()=>{if(!n||!r)return;const o=setTimeout(()=>{localStorage.removeItem(Wx),localStorage.removeItem(Gx),t(!0)},8e3);return()=>clearTimeout(o)},[n,r]);const a=()=>{localStorage.removeItem(Wx),localStorage.removeItem(Gx),t(!0)};return e||r!=="true"||!n?null:s.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:[s.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:s.jsx(Hs,{className:"w-3 h-3 text-accent-primary"})}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),s.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),s.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:s.jsx(jb,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Zt.getState().loadUserPresets(),Zt.getState().applySavedTheme());function Lv(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function Rv(){return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(fa,{})})}function dq({sidebarOpen:e,onSidebarToggle:t}){const[,n]=Dl("/p/:projectId"),r=n==null?void 0:n.projectId,a=Oe(d=>d.connectionStatus),o=Pt(d=>d.currentProject),c=Lv();return W3({canLoad:a==="connected"||c,projectId:r,currentProjectId:o==null?void 0:o.id}),!o||o.id!==r?s.jsx(Rv,{}):s.jsxs(s.Fragment,{children:[s.jsx(nA,{projectId:r,isOpen:e,onClose:t}),s.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:s.jsx(m9,{})})]})}function hq({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,a]=Dl("/p/:projectId/s/:sessionId"),o=a==null?void 0:a.projectId,c=a==null?void 0:a.sessionId,[,u]=Nn(),d=Oe(C=>C.connectionStatus),h=Oe(C=>C.currentSession),m=Oe(C=>C.error),f=Oe(C=>C.clearError),g=Pt(C=>C.currentProject),x=Lv();return G3({canLoad:d==="connected"||x,projectId:o,sessionId:c,currentProjectId:g==null?void 0:g.id,currentSessionId:h==null?void 0:h.id}),j.useEffect(()=>{(m==null?void 0:m.code)==="NOT_FOUND"&&o&&(f(),u(`/p/${o}`))},[m,o,f,u]),!g||g.id!==o?s.jsx(Rv,{}):s.jsxs(s.Fragment,{children:[s.jsx(nA,{projectId:o,isOpen:e,onClose:t}),s.jsxs("div",{className:"flex-1 min-w-0 bg-primary flex flex-col",children:[s.jsx(cq,{projectId:o}),s.jsx(KA,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})]})]})}function fq(){const e=an(r=>r.fetchConfig),[,t]=Nn();async function n(){await e(),t("/")}return s.jsx(pt,{className:"flex-1",children:s.jsx(lq,{onComplete:n})})}function mq(){const{connectionStatus:e}=$3(),t=an(X=>X.fetchConfig),n=an(X=>X.refreshProviderModels),r=an(X=>X.providers),a=an(X=>X.activeProviderId),[,o]=Nn(),c=Lv(),[u,d]=j.useState(!1);j.useEffect(()=>{(e==="connected"||c)&&t().then(()=>{d(!0),Bt.getState().getSettings([...xb,Ne.DISPLAY_THEME,Ne.DISPLAY_USER_PRESETS,Ne.DISPLAY_CUSTOM_CSS,Ne.KEYBINDINGS,Ne.FEATURES_PER_SESSION_MCP]),hu.getState().fetchServers()})},[e,c,t]),j.useEffect(()=>{u&&a&&n(a).then(()=>{const X=an.getState().defaultModelSelection;(X?X.split("/")[0]:null)!==a&&t()})},[u,a,n,t]);const h=Bt(X=>X.settings);j.useEffect(()=>{u&&r.length===0&&o("/onboarding")},[u,r.length]),j.useEffect(()=>{const{applyPreset:X,applyTokens:Y,setFollowSystemTheme:I,initSystemThemeListener:Q}=Zt.getState(),ne=h[Ne.DISPLAY_THEME],re=h[Ne.DISPLAY_USER_PRESETS],ie=h[Ne.DISPLAY_FOLLOW_SYSTEM_THEME];if(re&&localStorage.setItem("openfox:userPresets",re),ne){localStorage.setItem("openfox:theme",ne);try{const ye=JSON.parse(ne);ye.preset&&ye.tokens?(X(ye.preset),Zt.setState({basePreset:ye.preset}),Y(ye.tokens)):ye.preset?X(ye.preset):ye.tokens&&Y(ye.tokens)}catch{X("dark")}}else X("system");ie!==void 0&&Zt.getState().followSystemTheme!==(ie==="true")&&I(ie==="true");const pe=Q();return()=>pe()},[h[Ne.DISPLAY_THEME],h[Ne.DISPLAY_USER_PRESETS]]),j.useEffect(()=>{const X=h[Ne.DISPLAY_CUSTOM_CSS]??"";let Y=document.getElementById("custom-css");Y||(Y=document.createElement("style"),Y.id="custom-css",document.head.appendChild(Y)),Y.textContent=X},[h[Ne.DISPLAY_CUSTOM_CSS]]);const[m,f]=j.useState(!1);j.useEffect(()=>{const X=Bt.getState().settings[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE];if(X===void 0||X==="false")return;let Y=!1;if(localStorage.getItem("update_pending")==="true"&&(Y=!0,localStorage.removeItem("update_pending")),u){const Q=an.getState().version,ne=Rb();YO(Q,ne)&&(Y=!0),KO(Q)}Y&&f(!0)},[h[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE],u]);const g=()=>{const X=localStorage.getItem("openfox:leftSidebar");return X!==null?X==="true":!0},x=()=>{const X=localStorage.getItem("openfox:rightSidebar");return X!==null?X==="true":!0},[w,C]=j.useState(g),[v,S]=j.useState(x),[_,b]=j.useState(!1),[k,E]=j.useState(!1),[T,L]=j.useState(!1),A=n3();j.useEffect(()=>{const X=()=>{L(window.innerWidth<768)};return X(),window.addEventListener("resize",X),()=>window.removeEventListener("resize",X)},[]);const[O]=Nn(),M=/^\/p\/[^/]+$/.test(O),H=gE(),[B,F]=j.useState(!1),K=j.useRef(!1);j.useEffect(()=>{K.current&&!H&&Oe.getState().exitSplitView(),K.current=H},[H]),j.useEffect(()=>{if(!H){F(!1);return}let X=!1;const Y=m3();return(Y&&Y.openSessionIds.length>0?Oe.getState().enterSplitView(Y.openSessionIds,Y.focusedSessionId??void 0):Promise.resolve()).then(()=>{X||F(!0)}),()=>{X=!0}},[H]);const G=T?_:M?!0:w,V=T?k:v,Z=Oe(X=>X.openSessionIds.length),J=H&&Z===0?!0:G,z=()=>{T?b(!_):C(!w)},P=()=>{T?E(!k):S(!v)};j.useEffect(()=>{T||localStorage.setItem("openfox:leftSidebar",String(w))},[w,T]),j.useEffect(()=>{T||localStorage.setItem("openfox:rightSidebar",String(v))},[v,T]),j.useEffect(()=>{(e==="connected"||c)&&t()},[e,t,c]);const D=Oe(X=>X.showPasswordModal),U=Oe(X=>X.passwordModalRetry),$=Oe(X=>X.submitPassword),te=Oe(X=>X.cancelPassword),[q]=Dl("/p/:projectId/s/:sessionId/readonly");return!q&&e!=="connected"&&!D&&!c?s.jsxs(s.Fragment,{children:[s.jsx(cj,{isOpen:!0,isRetry:U,onSubmit:$,onCancel:te}),s.jsx("div",{className:"h-screen flex items-center justify-center",children:s.jsx(yO,{text:"Connecting to server..."})})]}):q?s.jsx(HG,{}):s.jsxs(s.Fragment,{children:[s.jsx(cj,{isOpen:D,isRetry:U,onSubmit:$,onCancel:te}),s.jsxs("div",{className:"flex flex-col",style:{height:T?`calc(${A.offsetTop}px + ${A.height}px)`:"100vh"},children:[s.jsx(a9,{}),s.jsx(e9,{onMenuClick:z,onCriteriaToggle:P}),s.jsx("div",{className:"@container flex-1 flex overflow-hidden",children:s.jsxs(FD,{children:[s.jsx(Qo,{path:"/onboarding",children:s.jsx(fq,{})}),s.jsx(Qo,{path:"/split-view",children:B?s.jsx(XG,{controlOpen:J}):s.jsx(Rv,{})}),s.jsx(Qo,{path:"/p/:projectId/s/:sessionId",children:s.jsx(hq,{sidebarOpen:G,onSidebarToggle:z,rightSidebarOpen:V,onRightSidebarToggle:P})}),s.jsx(Qo,{path:"/p/:projectId/new",children:s.jsx(f9,{})}),s.jsx(Qo,{path:"/p/:projectId",children:s.jsx(dq,{sidebarOpen:G,onSidebarToggle:z})}),s.jsx(Qo,{path:"/",children:s.jsx(h9,{})})]})})]}),s.jsx(uq,{}),s.jsx(jT,{isOpen:m,onClose:()=>f(!1),since:qO()??void 0})]})}const Rh=window.location.pathname.match(/\/p\/[^/]+\/s\/([0-9a-fA-F-]+)/);Rh!=null&&Rh[1]&&s3(Rh[1]);bD.createRoot(document.getElementById("root")).render(s.jsx(ps.StrictMode,{children:s.jsx(yj,{base:uE,children:s.jsx(mq,{})})}));
|