openfox 2.0.113 → 2.0.115
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 +43 -0
- package/dist/CHANGELOG.md +43 -0
- package/dist/agent-defaults/builder.agent.md +1 -0
- package/dist/agent-defaults/planner.agent.md +1 -0
- package/dist/{backend-P3GHHLHJ.js → backend-LVYHLGQJ.js} +2 -2
- package/dist/{chat-handler-PEK5JDHO.js → chat-handler-5SP265CR.js} +32 -26
- package/dist/{chunk-HKD4IMOE.js → chunk-27NABDXB.js} +2 -2
- package/dist/{chunk-FF2EKUQO.js → chunk-2FCLCUVR.js} +6 -6
- package/dist/{chunk-ONONXV3N.js → chunk-37QLXLML.js} +4 -4
- package/dist/{chunk-YB6WYVNY.js → chunk-3KBRMBTP.js} +2 -2
- package/dist/{chunk-YGPPFVLJ.js → chunk-3NPLERPQ.js} +17 -17
- package/dist/{chunk-XQR76MQ5.js → chunk-3PG65AXG.js} +18 -3
- package/dist/chunk-3QQAIUZI.js +957 -0
- package/dist/{chunk-PWXBIUEY.js → chunk-5PT4UMRR.js} +89 -1
- package/dist/chunk-5V3BF67X.js +7 -0
- package/dist/{chunk-6UPBZ2ZR.js → chunk-6KPJLELC.js} +4 -4
- package/dist/chunk-6RGACY4E.js +1081 -0
- package/dist/{chunk-BNFGDTEU.js → chunk-AESOGRFK.js} +2 -2
- package/dist/{chunk-YHEQTVFV.js → chunk-AZHWLLPP.js} +1 -1
- package/dist/{chunk-TCGWZBTS.js → chunk-BVVCRIVM.js} +4 -4
- package/dist/{chunk-EMI3YYLP.js → chunk-BWVO5WFK.js} +4 -4
- package/dist/{chunk-CP44U7BT.js → chunk-ERNWAKUB.js} +7 -7
- package/dist/{chunk-WWTYWLDM.js → chunk-HD6Y77RO.js} +2 -2
- package/dist/{chunk-4NMGX5F2.js → chunk-I7FY2LTR.js} +2 -2
- package/dist/{chunk-5VYSKVZT.js → chunk-JFK4GKQD.js} +321 -54
- package/dist/{chunk-43M7QZMX.js → chunk-JGWHRYWG.js} +4 -4
- package/dist/{chunk-Y64PEWKP.js → chunk-JLAR2CMV.js} +2 -2
- package/dist/{chunk-BYSUSSSC.js → chunk-LNNBLB6G.js} +48 -151
- package/dist/{chunk-V4664YKR.js → chunk-LTYL6ZGH.js} +2 -2
- package/dist/{chunk-R2MTWC7C.js → chunk-M6X6AIEG.js} +6 -4
- package/dist/{chunk-VGRVPYZ5.js → chunk-O6DU226D.js} +2 -2
- package/dist/{chunk-TEQEDOWI.js → chunk-OCBBAEMT.js} +288 -316
- package/dist/{chunk-SNLLOXCM.js → chunk-OCSTEGK7.js} +3 -3
- package/dist/{chunk-HGOTZWON.js → chunk-OKVHMKE2.js} +60 -1064
- package/dist/chunk-OSXPQSLW.js +128 -0
- package/dist/{chunk-O2YSYW2F.js → chunk-TFF5T3K3.js} +10 -10
- package/dist/{chunk-3R43CMLS.js → chunk-TGLVWAFC.js} +11 -11
- package/dist/{chunk-L737Y63F.js → chunk-TOKQ2UVG.js} +2 -2
- package/dist/{chunk-AZFZE36I.js → chunk-VWEATA7R.js} +18 -8
- package/dist/{chunk-BKCW3JLL.js → chunk-X25Q6RAV.js} +1 -1
- package/dist/{chunk-JR54MDZI.js → chunk-YX3OQBNX.js} +3 -3
- package/dist/{chunk-EC5T5A6O.js → chunk-ZTOG6LJD.js} +3 -3
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/client-KE7EDI2D.js +16 -0
- package/dist/{client-pure-VFZIIK4S.js → client-pure-66Z6FWS6.js} +2 -2
- package/dist/command-defaults/mark-done.command.md +14 -0
- package/dist/compactor-SKVC2VNL.js +32 -0
- package/dist/{dynamic-context-F2XTQJR5.js → dynamic-context-QNB4ELLP.js} +10 -9
- package/dist/{events-224IO5NJ.js → events-5PLO4QJU.js} +9 -7
- package/dist/{folding-YTTTVS56.js → folding-CJWYFUKD.js} +7 -5
- package/dist/http-client-KLODRQC2.js +11 -0
- package/dist/{inspect-proxy-B7LGGTM7.js → inspect-proxy-K6QKEYDT.js} +4 -4
- package/dist/launch-EOXVWLOP.js +52 -0
- package/dist/{manager-4QGXI6WZ.js → manager-LZ3JQ443.js} +5 -5
- package/dist/{model-overrides-OY2YKUNV.js → model-overrides-5UVW3KTE.js} +4 -4
- package/dist/orchestrator-ED3KFPXO.js +63 -0
- package/dist/package.json +3 -3
- package/dist/{path-security-PFMZY7IA.js → path-security-B6EZC63L.js} +13 -11
- package/dist/{platform-QNGCKX4L.js → platform-6RPPBHKH.js} +4 -4
- package/dist/{processor-NYPJ5PFA.js → processor-226ZOTRI.js} +31 -25
- package/dist/{project-creator-AWP2JUFS.js → project-creator-VBFE35NI.js} +3 -3
- package/dist/{projects-C4353IQK.js → projects-AXHZOBR2.js} +5 -3
- package/dist/{protocol-CBT1d98i.d.ts → protocol-JdxRpPxM.d.ts} +21 -3
- package/dist/{protocol-LZZ7C4VQ.js → protocol-RKSWKNXI.js} +3 -3
- package/dist/provider/index.d.ts +4 -4
- package/dist/{provider-PIRPN2CC.js → provider-DL4ZWQY7.js} +8 -8
- package/dist/{provider-manager-GNEPR6UN.js → provider-manager-6CLRMGDE.js} +8 -8
- package/dist/{registry-VCKDSVKA.js → registry-5XI5NDBF.js} +6 -4
- package/dist/{serve-6DRHQLCG.js → serve-DARV4NJG.js} +36 -33
- package/dist/server/index.d.ts +13 -6
- package/dist/server/index.js +35 -32
- package/dist/server-LQJ7MBDS.js +55 -0
- package/dist/service-4JKTGPRG.js +25 -0
- package/dist/{session-overrides-RNKV35MU.js → session-overrides-AZKV6BRD.js} +8 -6
- package/dist/{sessions-D5CEPQGU.js → sessions-752IZIIK.js} +7 -5
- package/dist/{settings-BNRNX6IW.js → settings-2AHDKCD7.js} +3 -3
- package/dist/shared/index.d.ts +3 -3
- package/dist/shared/index.js +1 -1
- package/dist/skill-defaults/workflows/SKILL.md +24 -6
- package/dist/tasks-XJXHU623.js +217 -0
- package/dist/{tools-2B363F7L.js → tools-QYYNFMGU.js} +31 -23
- package/dist/{types-cVfqOj6M.d.ts → types-CIVhQMvD.d.ts} +1 -1
- package/dist/{types-BAxh20ZL.d.ts → types-Df7NM9b5.d.ts} +76 -1
- package/dist/{update-IQMRYN7J.js → update-2REP2WB6.js} +2 -2
- package/dist/web/assets/{index-CjWC6EQ4.css → index-BmILAZrT.css} +1 -1
- package/dist/web/assets/index-M7ToECa4.js +324 -0
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/dist/workflow-defaults/default.workflow.json +5 -3
- package/dist/{workspace-YUNHV4WS.js → workspace-RMZVTFJD.js} +4 -4
- package/package.json +3 -3
- package/dist/chunk-B2PHPBFU.js +0 -7
- package/dist/client-3LJGD6KY.js +0 -16
- package/dist/compactor-ZBNKANHV.js +0 -30
- package/dist/http-client-YC3UA5OZ.js +0 -11
- package/dist/orchestrator-JKBY7B3P.js +0 -57
- package/dist/server-HUHFJW7U.js +0 -48
- package/dist/web/assets/index-DBUtUSHK.js +0 -323
|
@@ -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 mD=Object.defineProperty;var pD=Object.getPrototypeOf;var gD=Reflect.get;var qS=e=>{throw TypeError(e)};var xD=(e,t,n)=>t in e?mD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Le=(e,t,n)=>xD(e,typeof t!="symbol"?t+"":t,n),lg=(e,t,n)=>t.has(e)||qS("Cannot "+n);var ir=(e,t,n)=>(lg(e,t,"read from private field"),n?n.call(e):t.get(e)),Sa=(e,t,n)=>t.has(e)?qS("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ss=(e,t,n,r)=>(lg(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),cg=(e,t,n)=>(lg(e,t,"access private method"),n);var KS=(e,t,n)=>gD(pD(e),n,t);function yD(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 uf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ug={exports:{}},bc={};/**
|
|
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 YS;function bD(){if(YS)return bc;YS=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 bc.Fragment=t,bc.jsx=n,bc.jsxs=n,bc}var XS;function vD(){return XS||(XS=1,ug.exports=bD()),ug.exports}var s=vD(),dg={exports:{}},xt={};/**
|
|
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 JS;function _D(){if(JS)return xt;JS=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"),p=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),g=Symbol.iterator;function x(O){return O===null||typeof O!="object"?null:(O=g&&O[g]||O["@@iterator"],typeof O=="function"?O:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,v={};function S(O,V,z){this.props=O,this.context=V,this.refs=v,this.updater=z||w}S.prototype.isReactComponent={},S.prototype.setState=function(O,V){if(typeof O!="object"&&typeof O!="function"&&O!=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,O,V,"setState")},S.prototype.forceUpdate=function(O){this.updater.enqueueForceUpdate(this,O,"forceUpdate")};function _(){}_.prototype=S.prototype;function b(O,V,z){this.props=O,this.context=V,this.refs=v,this.updater=z||w}var k=b.prototype=new _;k.constructor=b,C(k,S.prototype),k.isPureReactComponent=!0;var E=Array.isArray;function T(){}var D={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function R(O,V,z){var Y=z.ref;return{$$typeof:e,type:O,key:V,ref:Y!==void 0?Y:null,props:z}}function M(O,V){return R(O.type,V,O.props)}function W(O){return typeof O=="object"&&O!==null&&O.$$typeof===e}function $(O){var V={"=":"=0",":":"=2"};return"$"+O.replace(/[=:]/g,function(z){return V[z]})}var G=/\/+/g;function B(O,V){return typeof O=="object"&&O!==null&&O.key!=null?$(""+O.key):V.toString(36)}function H(O){switch(O.status){case"fulfilled":return O.value;case"rejected":throw O.reason;default:switch(typeof O.status=="string"?O.then(T,T):(O.status="pending",O.then(function(V){O.status==="pending"&&(O.status="fulfilled",O.value=V)},function(V){O.status==="pending"&&(O.status="rejected",O.reason=V)})),O.status){case"fulfilled":return O.value;case"rejected":throw O.reason}}throw O}function q(O,V,z,Y,X){var Z=typeof O;(Z==="undefined"||Z==="boolean")&&(O=null);var F=!1;if(O===null)F=!0;else switch(Z){case"bigint":case"string":case"number":F=!0;break;case"object":switch(O.$$typeof){case e:case t:F=!0;break;case p:return F=O._init,q(F(O._payload),V,z,Y,X)}}if(F)return X=X(O),F=Y===""?"."+B(O,0):Y,E(X)?(z="",F!=null&&(z=F.replace(G,"$&/")+"/"),q(X,V,z,"",function(se){return se})):X!=null&&(W(X)&&(X=M(X,z+(X.key==null||O&&O.key===X.key?"":(""+X.key).replace(G,"$&/")+"/")+F)),V.push(X)),1;F=0;var P=Y===""?".":Y+":";if(E(O))for(var te=0;te<O.length;te++)Y=O[te],Z=P+B(Y,te),F+=q(Y,V,z,Z,X);else if(te=x(O),typeof te=="function")for(O=te.call(O),te=0;!(Y=O.next()).done;)Y=Y.value,Z=P+B(Y,te++),F+=q(Y,V,z,Z,X);else if(Z==="object"){if(typeof O.then=="function")return q(H(O),V,z,Y,X);throw V=String(O),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(O).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return F}function Q(O,V,z){if(O==null)return O;var Y=[],X=0;return q(O,Y,"","",function(Z){return V.call(z,Z,X++)}),Y}function J(O){if(O._status===-1){var V=O._result;V=V(),V.then(function(z){(O._status===0||O._status===-1)&&(O._status=1,O._result=z)},function(z){(O._status===0||O._status===-1)&&(O._status=2,O._result=z)}),O._status===-1&&(O._status=0,O._result=V)}if(O._status===1)return O._result.default;throw O._result}var U=typeof reportError=="function"?reportError:function(O){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof O=="object"&&O!==null&&typeof O.message=="string"?String(O.message):String(O),error:O});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",O);return}console.error(O)},I={map:Q,forEach:function(O,V,z){Q(O,function(){V.apply(this,arguments)},z)},count:function(O){var V=0;return Q(O,function(){V++}),V},toArray:function(O){return Q(O,function(V){return V})||[]},only:function(O){if(!W(O))throw Error("React.Children.only expected to receive a single React element child.");return O}};return xt.Activity=m,xt.Children=I,xt.Component=S,xt.Fragment=n,xt.Profiler=a,xt.PureComponent=b,xt.StrictMode=r,xt.Suspense=d,xt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=D,xt.__COMPILER_RUNTIME={__proto__:null,c:function(O){return D.H.useMemoCache(O)}},xt.cache=function(O){return function(){return O.apply(null,arguments)}},xt.cacheSignal=function(){return null},xt.cloneElement=function(O,V,z){if(O==null)throw Error("The argument must be a React element, but you passed "+O+".");var Y=C({},O.props),X=O.key;if(V!=null)for(Z in V.key!==void 0&&(X=""+V.key),V)!A.call(V,Z)||Z==="key"||Z==="__self"||Z==="__source"||Z==="ref"&&V.ref===void 0||(Y[Z]=V[Z]);var Z=arguments.length-2;if(Z===1)Y.children=z;else if(1<Z){for(var F=Array(Z),P=0;P<Z;P++)F[P]=arguments[P+2];Y.children=F}return R(O.type,X,Y)},xt.createContext=function(O){return O={$$typeof:c,_currentValue:O,_currentValue2:O,_threadCount:0,Provider:null,Consumer:null},O.Provider=O,O.Consumer={$$typeof:o,_context:O},O},xt.createElement=function(O,V,z){var Y,X={},Z=null;if(V!=null)for(Y in V.key!==void 0&&(Z=""+V.key),V)A.call(V,Y)&&Y!=="key"&&Y!=="__self"&&Y!=="__source"&&(X[Y]=V[Y]);var F=arguments.length-2;if(F===1)X.children=z;else if(1<F){for(var P=Array(F),te=0;te<F;te++)P[te]=arguments[te+2];X.children=P}if(O&&O.defaultProps)for(Y in F=O.defaultProps,F)X[Y]===void 0&&(X[Y]=F[Y]);return R(O,Z,X)},xt.createRef=function(){return{current:null}},xt.forwardRef=function(O){return{$$typeof:u,render:O}},xt.isValidElement=W,xt.lazy=function(O){return{$$typeof:p,_payload:{_status:-1,_result:O},_init:J}},xt.memo=function(O,V){return{$$typeof:h,type:O,compare:V===void 0?null:V}},xt.startTransition=function(O){var V=D.T,z={};D.T=z;try{var Y=O(),X=D.S;X!==null&&X(z,Y),typeof Y=="object"&&Y!==null&&typeof Y.then=="function"&&Y.then(T,U)}catch(Z){U(Z)}finally{V!==null&&z.types!==null&&(V.types=z.types),D.T=V}},xt.unstable_useCacheRefresh=function(){return D.H.useCacheRefresh()},xt.use=function(O){return D.H.use(O)},xt.useActionState=function(O,V,z){return D.H.useActionState(O,V,z)},xt.useCallback=function(O,V){return D.H.useCallback(O,V)},xt.useContext=function(O){return D.H.useContext(O)},xt.useDebugValue=function(){},xt.useDeferredValue=function(O,V){return D.H.useDeferredValue(O,V)},xt.useEffect=function(O,V){return D.H.useEffect(O,V)},xt.useEffectEvent=function(O){return D.H.useEffectEvent(O)},xt.useId=function(){return D.H.useId()},xt.useImperativeHandle=function(O,V,z){return D.H.useImperativeHandle(O,V,z)},xt.useInsertionEffect=function(O,V){return D.H.useInsertionEffect(O,V)},xt.useLayoutEffect=function(O,V){return D.H.useLayoutEffect(O,V)},xt.useMemo=function(O,V){return D.H.useMemo(O,V)},xt.useOptimistic=function(O,V){return D.H.useOptimistic(O,V)},xt.useReducer=function(O,V,z){return D.H.useReducer(O,V,z)},xt.useRef=function(O){return D.H.useRef(O)},xt.useState=function(O){return D.H.useState(O)},xt.useSyncExternalStore=function(O,V,z){return D.H.useSyncExternalStore(O,V,z)},xt.useTransition=function(){return D.H.useTransition()},xt.version="19.2.8",xt}var QS;function df(){return QS||(QS=1,dg.exports=_D()),dg.exports}var j=df();const cs=uf(j),SD=yD({__proto__:null,default:cs},[j]);var hg={exports:{}},vc={},fg={exports:{}},mg={};/**
|
|
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 ZS;function wD(){return ZS||(ZS=1,(function(e){function t(q,Q){var J=q.length;q.push(Q);e:for(;0<J;){var U=J-1>>>1,I=q[U];if(0<a(I,Q))q[U]=Q,q[J]=I,J=U;else break e}}function n(q){return q.length===0?null:q[0]}function r(q){if(q.length===0)return null;var Q=q[0],J=q.pop();if(J!==Q){q[0]=J;e:for(var U=0,I=q.length,O=I>>>1;U<O;){var V=2*(U+1)-1,z=q[V],Y=V+1,X=q[Y];if(0>a(z,J))Y<I&&0>a(X,z)?(q[U]=X,q[Y]=J,U=Y):(q[U]=z,q[V]=J,U=V);else if(Y<I&&0>a(X,J))q[U]=X,q[Y]=J,U=Y;else break e}}return Q}function a(q,Q){var J=q.sortIndex-Q.sortIndex;return J!==0?J:q.id-Q.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=[],p=1,m=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(q){for(var Q=n(h);Q!==null;){if(Q.callback===null)r(h);else if(Q.startTime<=q)r(h),Q.sortIndex=Q.expirationTime,t(d,Q);else break;Q=n(h)}}function E(q){if(C=!1,k(q),!w)if(n(d)!==null)w=!0,T||(T=!0,$());else{var Q=n(h);Q!==null&&H(E,Q.startTime-q)}}var T=!1,D=-1,A=5,R=-1;function M(){return v?!0:!(e.unstable_now()-R<A)}function W(){if(v=!1,T){var q=e.unstable_now();R=q;var Q=!0;try{e:{w=!1,C&&(C=!1,_(D),D=-1),x=!0;var J=g;try{t:{for(k(q),m=n(d);m!==null&&!(m.expirationTime>q&&M());){var U=m.callback;if(typeof U=="function"){m.callback=null,g=m.priorityLevel;var I=U(m.expirationTime<=q);if(q=e.unstable_now(),typeof I=="function"){m.callback=I,k(q),Q=!0;break t}m===n(d)&&r(d),k(q)}else r(d);m=n(d)}if(m!==null)Q=!0;else{var O=n(h);O!==null&&H(E,O.startTime-q),Q=!1}}break e}finally{m=null,g=J,x=!1}Q=void 0}}finally{Q?$():T=!1}}}var $;if(typeof b=="function")$=function(){b(W)};else if(typeof MessageChannel<"u"){var G=new MessageChannel,B=G.port2;G.port1.onmessage=W,$=function(){B.postMessage(null)}}else $=function(){S(W,0)};function H(q,Q){D=S(function(){q(e.unstable_now())},Q)}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(q){q.callback=null},e.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<q?Math.floor(1e3/q):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_next=function(q){switch(g){case 1:case 2:case 3:var Q=3;break;default:Q=g}var J=g;g=Q;try{return q()}finally{g=J}},e.unstable_requestPaint=function(){v=!0},e.unstable_runWithPriority=function(q,Q){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var J=g;g=q;try{return Q()}finally{g=J}},e.unstable_scheduleCallback=function(q,Q,J){var U=e.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?U+J:U):J=U,q){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=J+I,q={id:p++,callback:Q,priorityLevel:q,startTime:J,expirationTime:I,sortIndex:-1},J>U?(q.sortIndex=J,t(h,q),n(d)===null&&q===n(h)&&(C?(_(D),D=-1):C=!0,H(E,J-U))):(q.sortIndex=I,t(d,q),w||x||(w=!0,T||(T=!0,$()))),q},e.unstable_shouldYield=M,e.unstable_wrapCallback=function(q){var Q=g;return function(){var J=g;g=Q;try{return q.apply(this,arguments)}finally{g=J}}}})(mg)),mg}var ew;function CD(){return ew||(ew=1,fg.exports=wD()),fg.exports}var pg={exports:{}},Yn={};/**
|
|
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 tw;function kD(){if(tw)return Yn;tw=1;var e=df();function t(d){var h="https://react.dev/errors/"+d;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)h+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+d+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");function o(d,h,p){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:m==null?null:""+m,children:d,containerInfo:h,implementation:p}}var 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 Yn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Yn.createPortal=function(d,h){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return o(d,h,null,p)},Yn.flushSync=function(d){var h=c.T,p=r.p;try{if(c.T=null,r.p=2,d)return d()}finally{c.T=h,r.p=p,r.d.f()}},Yn.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))},Yn.prefetchDNS=function(d){typeof d=="string"&&r.d.D(d)},Yn.preinit=function(d,h){if(typeof d=="string"&&h&&typeof h.as=="string"){var p=h.as,m=u(p,h.crossOrigin),g=typeof h.integrity=="string"?h.integrity:void 0,x=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;p==="style"?r.d.S(d,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:m,integrity:g,fetchPriority:x}):p==="script"&&r.d.X(d,{crossOrigin:m,integrity:g,fetchPriority:x,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Yn.preinitModule=function(d,h){if(typeof d=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var p=u(h.as,h.crossOrigin);r.d.M(d,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&r.d.M(d)},Yn.preload=function(d,h){if(typeof d=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var p=h.as,m=u(p,h.crossOrigin);r.d.L(d,p,{crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Yn.preloadModule=function(d,h){if(typeof d=="string")if(h){var p=u(h.as,h.crossOrigin);r.d.m(d,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(d)},Yn.requestFormReset=function(d){r.d.r(d)},Yn.unstable_batchedUpdates=function(d,h){return d(h)},Yn.useFormState=function(d,h,p){return c.H.useFormState(d,h,p)},Yn.useFormStatus=function(){return c.H.useHostTransitionStatus()},Yn.version="19.2.8",Yn}var nw;function Lk(){if(nw)return pg.exports;nw=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(),pg.exports=kD(),pg.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 jD(){if(rw)return vc;rw=1;var e=CD(),t=df(),n=Lk();function r(i){var l="https://react.dev/errors/"+i;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var f=2;f<arguments.length;f++)l+="&args[]="+encodeURIComponent(arguments[f])}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,f=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,(l.flags&4098)!==0&&(f=l.return),i=l.return;while(i)}return l.tag===3?f: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 f=i,y=l;;){var N=f.return;if(N===null)break;var L=N.alternate;if(L===null){if(y=N.return,y!==null){f=y;continue}break}if(N.child===L.child){for(L=N.child;L;){if(L===f)return d(N),i;if(L===y)return d(N),l;L=L.sibling}throw Error(r(188))}if(f.return!==y.return)f=N,y=L;else{for(var K=!1,ee=N.child;ee;){if(ee===f){K=!0,f=N,y=L;break}if(ee===y){K=!0,y=N,f=L;break}ee=ee.sibling}if(!K){for(ee=L.child;ee;){if(ee===f){K=!0,f=L,y=N;break}if(ee===y){K=!0,y=L,f=N;break}ee=ee.sibling}if(!K)throw Error(r(189))}}if(f.alternate!==y)throw Error(r(190))}if(f.tag!==3)throw Error(r(188));return f.stateNode.current===f?i:l}function p(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(l=p(i),l!==null)return l;i=i.sibling}return null}var m=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"),D=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),R=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),W=Symbol.iterator;function $(i){return i===null||typeof i!="object"?null:(i=W&&i[W]||i["@@iterator"],typeof i=="function"?i:null)}var G=Symbol.for("react.client.reference");function B(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===G?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 R: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 D:return l=i.displayName||null,l!==null?l:B(i.type)||"Memo";case A:l=i._payload,i=i._init;try{return B(i(l))}catch{}}return null}var H=Array.isArray,q=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},U=[],I=-1;function O(i){return{current:i}}function V(i){0>I||(i.current=U[I],U[I]=null,I--)}function z(i,l){I++,U[I]=i.current,i.current=l}var Y=O(null),X=O(null),Z=O(null),F=O(null);function P(i,l){switch(z(Z,l),z(X,i),z(Y,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?gS(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=gS(l),i=xS(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}V(Y),z(Y,i)}function te(){V(Y),V(X),V(Z)}function se(i){i.memoizedState!==null&&z(F,i);var l=Y.current,f=xS(l,i.type);l!==f&&(z(X,i),z(Y,f))}function re(i){X.current===i&&(V(Y),V(X)),F.current===i&&(V(F),pc._currentValue=J)}var ae,ye;function _e(i){if(ae===void 0)try{throw Error()}catch(f){var l=f.stack.trim().match(/\n( *(at )?)/);ae=l&&l[1]||"",ye=-1<f.stack.indexOf(`
|
|
43
|
+
at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
+
`+ae+i+ye}var Ie=!1;function He(i,l){if(!i||Ie)return"";Ie=!0;var f=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(Ee){var ke=Ee}Reflect.construct(i,[],ze)}else{try{ze.call()}catch(Ee){ke=Ee}i.call(ze.prototype)}}else{try{throw Error()}catch(Ee){ke=Ee}(ze=i())&&typeof ze.catch=="function"&&ze.catch(function(){})}}catch(Ee){if(Ee&&ke&&typeof Ee.stack=="string")return[Ee.stack,ke.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 L=y.DetermineComponentFrameRoot(),K=L[0],ee=L[1];if(K&&ee){var le=K.split(`
|
|
45
|
+
`),we=ee.split(`
|
|
46
|
+
`);for(N=y=0;y<le.length&&!le[y].includes("DetermineComponentFrameRoot");)y++;for(;N<we.length&&!we[N].includes("DetermineComponentFrameRoot");)N++;if(y===le.length||N===we.length)for(y=le.length-1,N=we.length-1;1<=y&&0<=N&&le[y]!==we[N];)N--;for(;1<=y&&0<=N;y--,N--)if(le[y]!==we[N]){if(y!==1||N!==1)do if(y--,N--,0>N||le[y]!==we[N]){var Oe=`
|
|
47
|
+
`+le[y].replace(" at new "," at ");return i.displayName&&Oe.includes("<anonymous>")&&(Oe=Oe.replace("<anonymous>",i.displayName)),Oe}while(1<=y&&0<=N);break}}}finally{Ie=!1,Error.prepareStackTrace=f}return(f=i?i.displayName||i.name:"")?_e(f):""}function je(i,l){switch(i.tag){case 26:case 27:case 5:return _e(i.type);case 16:return _e("Lazy");case 13:return i.child!==l&&l!==null?_e("Suspense Fallback"):_e("Suspense");case 19:return _e("SuspenseList");case 0:case 15:return He(i.type,!1);case 11:return He(i.type.render,!1);case 1:return He(i.type,!0);case 31:return _e("Activity");default:return""}}function Ge(i){try{var l="",f=null;do l+=je(i,f),f=i,i=i.return;while(i);return l}catch(y){return`
|
|
48
|
+
Error generating stack: `+y.message+`
|
|
49
|
+
`+y.stack}}var Ze=Object.prototype.hasOwnProperty,Se=e.unstable_scheduleCallback,be=e.unstable_cancelCallback,de=e.unstable_shouldYield,ie=e.unstable_requestPaint,Pe=e.unstable_now,Ue=e.unstable_getCurrentPriorityLevel,ue=e.unstable_ImmediatePriority,De=e.unstable_UserBlockingPriority,qe=e.unstable_NormalPriority,pe=e.unstable_LowPriority,he=e.unstable_IdlePriority,We=e.log,Ve=e.unstable_setDisableYieldValue,et=null,it=null;function ge(i){if(typeof We=="function"&&Ve(i),it&&typeof it.setStrictMode=="function")try{it.setStrictMode(et,i)}catch{}}var fe=Math.clz32?Math.clz32:_t,Fe=Math.log,Xe=Math.LN2;function _t(i){return i>>>=0,i===0?32:31-(Fe(i)/Xe|0)|0}var Dt=256,Ct=262144,Sn=4194304;function wn(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 fn(i,l,f){var y=i.pendingLanes;if(y===0)return 0;var N=0,L=i.suspendedLanes,K=i.pingedLanes;i=i.warmLanes;var ee=y&134217727;return ee!==0?(y=ee&~L,y!==0?N=wn(y):(K&=ee,K!==0?N=wn(K):f||(f=ee&~i,f!==0&&(N=wn(f))))):(ee=y&~L,ee!==0?N=wn(ee):K!==0?N=wn(K):f||(f=y&~i,f!==0&&(N=wn(f)))),N===0?0:l!==0&&l!==N&&(l&L)===0&&(L=N&-N,f=l&-l,L>=f||L===32&&(f&4194048)!==0)?l:N}function Dn(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Cn(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 dn(){var i=Sn;return Sn<<=1,(Sn&62914560)===0&&(Sn=4194304),i}function rr(i){for(var l=[],f=0;31>f;f++)l.push(i);return l}function Ce(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function nt(i,l,f,y,N,L){var K=i.pendingLanes;i.pendingLanes=f,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=f,i.entangledLanes&=f,i.errorRecoveryDisabledLanes&=f,i.shellSuspendCounter=0;var ee=i.entanglements,le=i.expirationTimes,we=i.hiddenUpdates;for(f=K&~f;0<f;){var Oe=31-fe(f),ze=1<<Oe;ee[Oe]=0,le[Oe]=-1;var ke=we[Oe];if(ke!==null)for(we[Oe]=null,Oe=0;Oe<ke.length;Oe++){var Ee=ke[Oe];Ee!==null&&(Ee.lane&=-536870913)}f&=~ze}y!==0&&Je(i,y,0),L!==0&&N===0&&i.tag!==0&&(i.suspendedLanes|=L&~(K&~l))}function Je(i,l,f){i.pendingLanes|=l,i.suspendedLanes&=~l;var y=31-fe(l);i.entangledLanes|=l,i.entanglements[y]=i.entanglements[y]|1073741824|f&261930}function oe(i,l){var f=i.entangledLanes|=l;for(i=i.entanglements;f;){var y=31-fe(f),N=1<<y;N&l|i[y]&l&&(i[y]|=l),f&=~N}}function Be(i,l){var f=l&-l;return f=(f&42)!==0?1:tt(f),(f&(i.suspendedLanes|l))!==0?0:f}function tt(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 Ot(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function rn(){var i=Q.p;return i!==0?i:(i=window.event,i===void 0?32:zS(i.type))}function Te(i,l){var f=Q.p;try{return Q.p=i,l()}finally{Q.p=f}}var Ae=Math.random().toString(36).slice(2),$e="__reactFiber$"+Ae,Qe="__reactProps$"+Ae,rt="__reactContainer$"+Ae,mt="__reactEvents$"+Ae,St="__reactListeners$"+Ae,Rn="__reactHandles$"+Ae,xn="__reactResources$"+Ae,kn="__reactMarker$"+Ae;function no(i){delete i[$e],delete i[Qe],delete i[mt],delete i[St],delete i[Rn]}function ro(i){var l=i[$e];if(l)return l;for(var f=i.parentNode;f;){if(l=f[rt]||f[$e]){if(f=l.alternate,l.child!==null||f!==null&&f.child!==null)for(i=CS(i);i!==null;){if(f=i[$e])return f;i=CS(i)}return l}i=f,f=i.parentNode}return null}function so(i){if(i=i[$e]||i[rt]){var l=i.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return i}return null}function Ll(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i.stateNode;throw Error(r(33))}function io(i){var l=i[xn];return l||(l=i[xn]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function $n(i){i[kn]=!0}var sv=new Set,iv={};function ia(i,l){ao(i,l),ao(i+"Capture",l)}function ao(i,l){for(iv[i]=l,i=0;i<l.length;i++)sv.add(l[i])}var iA=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]*$"),av={},ov={};function aA(i){return Ze.call(ov,i)?!0:Ze.call(av,i)?!1:iA.test(i)?ov[i]=!0:(av[i]=!0,!1)}function Eu(i,l,f){if(aA(l))if(f===null)i.removeAttribute(l);else{switch(typeof f){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,""+f)}}function Nu(i,l,f){if(f===null)i.removeAttribute(l);else{switch(typeof f){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(l);return}i.setAttribute(l,""+f)}}function Is(i,l,f,y){if(y===null)i.removeAttribute(f);else{switch(typeof y){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(f);return}i.setAttributeNS(l,f,""+y)}}function Ir(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function lv(i){var l=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function oA(i,l,f){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,L=y.set;return Object.defineProperty(i,l,{configurable:!0,get:function(){return N.call(this)},set:function(K){f=""+K,L.call(this,K)}}),Object.defineProperty(i,l,{enumerable:y.enumerable}),{getValue:function(){return f},setValue:function(K){f=""+K},stopTracking:function(){i._valueTracker=null,delete i[l]}}}}function tm(i){if(!i._valueTracker){var l=lv(i)?"checked":"value";i._valueTracker=oA(i,l,""+i[l])}}function cv(i){if(!i)return!1;var l=i._valueTracker;if(!l)return!0;var f=l.getValue(),y="";return i&&(y=lv(i)?i.checked?"true":"false":i.value),i=y,i!==f?(l.setValue(i),!0):!1}function Tu(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 lA=/[\n"\\]/g;function Mr(i){return i.replace(lA,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function nm(i,l,f,y,N,L,K,ee){i.name="",K!=null&&typeof K!="function"&&typeof K!="symbol"&&typeof K!="boolean"?i.type=K:i.removeAttribute("type"),l!=null?K==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+Ir(l)):i.value!==""+Ir(l)&&(i.value=""+Ir(l)):K!=="submit"&&K!=="reset"||i.removeAttribute("value"),l!=null?rm(i,K,Ir(l)):f!=null?rm(i,K,Ir(f)):y!=null&&i.removeAttribute("value"),N==null&&L!=null&&(i.defaultChecked=!!L),N!=null&&(i.checked=N&&typeof N!="function"&&typeof N!="symbol"),ee!=null&&typeof ee!="function"&&typeof ee!="symbol"&&typeof ee!="boolean"?i.name=""+Ir(ee):i.removeAttribute("name")}function uv(i,l,f,y,N,L,K,ee){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(i.type=L),l!=null||f!=null){if(!(L!=="submit"&&L!=="reset"||l!=null)){tm(i);return}f=f!=null?""+Ir(f):"",l=l!=null?""+Ir(l):f,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,K!=null&&typeof K!="function"&&typeof K!="symbol"&&typeof K!="boolean"&&(i.name=K),tm(i)}function rm(i,l,f){l==="number"&&Tu(i.ownerDocument)===i||i.defaultValue===""+f||(i.defaultValue=""+f)}function oo(i,l,f,y){if(i=i.options,l){l={};for(var N=0;N<f.length;N++)l["$"+f[N]]=!0;for(f=0;f<i.length;f++)N=l.hasOwnProperty("$"+i[f].value),i[f].selected!==N&&(i[f].selected=N),N&&y&&(i[f].defaultSelected=!0)}else{for(f=""+Ir(f),l=null,N=0;N<i.length;N++){if(i[N].value===f){i[N].selected=!0,y&&(i[N].defaultSelected=!0);return}l!==null||i[N].disabled||(l=i[N])}l!==null&&(l.selected=!0)}}function dv(i,l,f){if(l!=null&&(l=""+Ir(l),l!==i.value&&(i.value=l),f==null)){i.defaultValue!==l&&(i.defaultValue=l);return}i.defaultValue=f!=null?""+Ir(f):""}function hv(i,l,f,y){if(l==null){if(y!=null){if(f!=null)throw Error(r(92));if(H(y)){if(1<y.length)throw Error(r(93));y=y[0]}f=y}f==null&&(f=""),l=f}f=Ir(l),i.defaultValue=f,y=i.textContent,y===f&&y!==""&&y!==null&&(i.value=y),tm(i)}function lo(i,l){if(l){var f=i.firstChild;if(f&&f===i.lastChild&&f.nodeType===3){f.nodeValue=l;return}}i.textContent=l}var cA=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 fv(i,l,f){var y=l.indexOf("--")===0;f==null||typeof f=="boolean"||f===""?y?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="":y?i.setProperty(l,f):typeof f!="number"||f===0||cA.has(l)?l==="float"?i.cssFloat=f:i[l]=(""+f).trim():i[l]=f+"px"}function mv(i,l,f){if(l!=null&&typeof l!="object")throw Error(r(62));if(i=i.style,f!=null){for(var y in f)!f.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)&&f[N]!==y&&fv(i,N,y)}else for(var L in l)l.hasOwnProperty(L)&&fv(i,L,l[L])}function sm(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 uA=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"]]),dA=/^[\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 Au(i){return dA.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Ms(){}var im=null;function am(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var co=null,uo=null;function pv(i){var l=so(i);if(l&&(i=l.stateNode)){var f=i[Qe]||null;e:switch(i=l.stateNode,l.type){case"input":if(nm(i,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name),l=f.name,f.type==="radio"&&l!=null){for(f=i;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll('input[name="'+Mr(""+l)+'"][type="radio"]'),l=0;l<f.length;l++){var y=f[l];if(y!==i&&y.form===i.form){var N=y[Qe]||null;if(!N)throw Error(r(90));nm(y,N.value,N.defaultValue,N.defaultValue,N.checked,N.defaultChecked,N.type,N.name)}}for(l=0;l<f.length;l++)y=f[l],y.form===i.form&&cv(y)}break e;case"textarea":dv(i,f.value,f.defaultValue);break e;case"select":l=f.value,l!=null&&oo(i,!!f.multiple,l,!1)}}}var om=!1;function gv(i,l,f){if(om)return i(l,f);om=!0;try{var y=i(l);return y}finally{if(om=!1,(co!==null||uo!==null)&&(xd(),co&&(l=co,i=uo,uo=co=null,pv(l),i)))for(l=0;l<i.length;l++)pv(i[l])}}function Dl(i,l){var f=i.stateNode;if(f===null)return null;var y=f[Qe]||null;if(y===null)return null;f=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(f&&typeof f!="function")throw Error(r(231,l,typeof f));return f}var Ps=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),lm=!1;if(Ps)try{var Rl={};Object.defineProperty(Rl,"passive",{get:function(){lm=!0}}),window.addEventListener("test",Rl,Rl),window.removeEventListener("test",Rl,Rl)}catch{lm=!1}var gi=null,cm=null,Lu=null;function xv(){if(Lu)return Lu;var i,l=cm,f=l.length,y,N="value"in gi?gi.value:gi.textContent,L=N.length;for(i=0;i<f&&l[i]===N[i];i++);var K=f-i;for(y=1;y<=K&&l[f-y]===N[L-y];y++);return Lu=N.slice(i,1<y?1-y:void 0)}function Du(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 Ru(){return!0}function yv(){return!1}function cr(i){function l(f,y,N,L,K){this._reactName=f,this._targetInst=N,this.type=y,this.nativeEvent=L,this.target=K,this.currentTarget=null;for(var ee in i)i.hasOwnProperty(ee)&&(f=i[ee],this[ee]=f?f(L):L[ee]);return this.isDefaultPrevented=(L.defaultPrevented!=null?L.defaultPrevented:L.returnValue===!1)?Ru:yv,this.isPropagationStopped=yv,this}return m(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=Ru)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=Ru)},persist:function(){},isPersistent:Ru}),l}var aa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ou=cr(aa),Ol=m({},aa,{view:0,detail:0}),hA=cr(Ol),um,dm,Il,Iu=m({},Ol,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:fm,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!==Il&&(Il&&i.type==="mousemove"?(um=i.screenX-Il.screenX,dm=i.screenY-Il.screenY):dm=um=0,Il=i),um)},movementY:function(i){return"movementY"in i?i.movementY:dm}}),bv=cr(Iu),fA=m({},Iu,{dataTransfer:0}),mA=cr(fA),pA=m({},Ol,{relatedTarget:0}),hm=cr(pA),gA=m({},aa,{animationName:0,elapsedTime:0,pseudoElement:0}),xA=cr(gA),yA=m({},aa,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),bA=cr(yA),vA=m({},aa,{data:0}),vv=cr(vA),_A={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},SA={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"},wA={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function CA(i){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(i):(i=wA[i])?!!l[i]:!1}function fm(){return CA}var kA=m({},Ol,{key:function(i){if(i.key){var l=_A[i.key]||i.key;if(l!=="Unidentified")return l}return i.type==="keypress"?(i=Du(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?SA[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:fm,charCode:function(i){return i.type==="keypress"?Du(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Du(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),jA=cr(kA),EA=m({},Iu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),_v=cr(EA),NA=m({},Ol,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:fm}),TA=cr(NA),AA=m({},aa,{propertyName:0,elapsedTime:0,pseudoElement:0}),LA=cr(AA),DA=m({},Iu,{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}),RA=cr(DA),OA=m({},aa,{newState:0,oldState:0}),IA=cr(OA),MA=[9,13,27,32],mm=Ps&&"CompositionEvent"in window,Ml=null;Ps&&"documentMode"in document&&(Ml=document.documentMode);var PA=Ps&&"TextEvent"in window&&!Ml,Sv=Ps&&(!mm||Ml&&8<Ml&&11>=Ml),wv=" ",Cv=!1;function kv(i,l){switch(i){case"keyup":return MA.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function jv(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ho=!1;function BA(i,l){switch(i){case"compositionend":return jv(l);case"keypress":return l.which!==32?null:(Cv=!0,wv);case"textInput":return i=l.data,i===wv&&Cv?null:i;default:return null}}function $A(i,l){if(ho)return i==="compositionend"||!mm&&kv(i,l)?(i=xv(),Lu=cm=gi=null,ho=!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 Sv&&l.locale!=="ko"?null:l.data;default:return null}}var zA={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 Ev(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l==="input"?!!zA[i.type]:l==="textarea"}function Nv(i,l,f,y){co?uo?uo.push(y):uo=[y]:co=y,l=Cd(l,"onChange"),0<l.length&&(f=new Ou("onChange","change",null,f,y),i.push({event:f,listeners:l}))}var Pl=null,Bl=null;function HA(i){uS(i,0)}function Mu(i){var l=Ll(i);if(cv(l))return i}function Tv(i,l){if(i==="change")return l}var Av=!1;if(Ps){var pm;if(Ps){var gm="oninput"in document;if(!gm){var Lv=document.createElement("div");Lv.setAttribute("oninput","return;"),gm=typeof Lv.oninput=="function"}pm=gm}else pm=!1;Av=pm&&(!document.documentMode||9<document.documentMode)}function Dv(){Pl&&(Pl.detachEvent("onpropertychange",Rv),Bl=Pl=null)}function Rv(i){if(i.propertyName==="value"&&Mu(Bl)){var l=[];Nv(l,Bl,i,am(i)),gv(HA,l)}}function FA(i,l,f){i==="focusin"?(Dv(),Pl=l,Bl=f,Pl.attachEvent("onpropertychange",Rv)):i==="focusout"&&Dv()}function UA(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Mu(Bl)}function VA(i,l){if(i==="click")return Mu(l)}function GA(i,l){if(i==="input"||i==="change")return Mu(l)}function WA(i,l){return i===l&&(i!==0||1/i===1/l)||i!==i&&l!==l}var _r=typeof Object.is=="function"?Object.is:WA;function $l(i,l){if(_r(i,l))return!0;if(typeof i!="object"||i===null||typeof l!="object"||l===null)return!1;var f=Object.keys(i),y=Object.keys(l);if(f.length!==y.length)return!1;for(y=0;y<f.length;y++){var N=f[y];if(!Ze.call(l,N)||!_r(i[N],l[N]))return!1}return!0}function Ov(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Iv(i,l){var f=Ov(i);i=0;for(var y;f;){if(f.nodeType===3){if(y=i+f.textContent.length,i<=l&&y>=l)return{node:f,offset:l-i};i=y}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=Ov(f)}}function Mv(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?Mv(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function Pv(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=Tu(i.document);l instanceof i.HTMLIFrameElement;){try{var f=typeof l.contentWindow.location.href=="string"}catch{f=!1}if(f)i=l.contentWindow;else break;l=Tu(i.document)}return l}function xm(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 qA=Ps&&"documentMode"in document&&11>=document.documentMode,fo=null,ym=null,zl=null,bm=!1;function Bv(i,l,f){var y=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;bm||fo==null||fo!==Tu(y)||(y=fo,"selectionStart"in y&&xm(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&&$l(zl,y)||(zl=y,y=Cd(ym,"onSelect"),0<y.length&&(l=new Ou("onSelect","select",null,l,f),i.push({event:l,listeners:y}),l.target=fo)))}function oa(i,l){var f={};return f[i.toLowerCase()]=l.toLowerCase(),f["Webkit"+i]="webkit"+l,f["Moz"+i]="moz"+l,f}var mo={animationend:oa("Animation","AnimationEnd"),animationiteration:oa("Animation","AnimationIteration"),animationstart:oa("Animation","AnimationStart"),transitionrun:oa("Transition","TransitionRun"),transitionstart:oa("Transition","TransitionStart"),transitioncancel:oa("Transition","TransitionCancel"),transitionend:oa("Transition","TransitionEnd")},vm={},$v={};Ps&&($v=document.createElement("div").style,"AnimationEvent"in window||(delete mo.animationend.animation,delete mo.animationiteration.animation,delete mo.animationstart.animation),"TransitionEvent"in window||delete mo.transitionend.transition);function la(i){if(vm[i])return vm[i];if(!mo[i])return i;var l=mo[i],f;for(f in l)if(l.hasOwnProperty(f)&&f in $v)return vm[i]=l[f];return i}var zv=la("animationend"),Hv=la("animationiteration"),Fv=la("animationstart"),KA=la("transitionrun"),YA=la("transitionstart"),XA=la("transitioncancel"),Uv=la("transitionend"),Vv=new Map,_m="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(" ");_m.push("scrollEnd");function ts(i,l){Vv.set(i,l),ia(l,[i])}var Pu=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)},Pr=[],po=0,Sm=0;function Bu(){for(var i=po,l=Sm=po=0;l<i;){var f=Pr[l];Pr[l++]=null;var y=Pr[l];Pr[l++]=null;var N=Pr[l];Pr[l++]=null;var L=Pr[l];if(Pr[l++]=null,y!==null&&N!==null){var K=y.pending;K===null?N.next=N:(N.next=K.next,K.next=N),y.pending=N}L!==0&&Gv(f,N,L)}}function $u(i,l,f,y){Pr[po++]=i,Pr[po++]=l,Pr[po++]=f,Pr[po++]=y,Sm|=y,i.lanes|=y,i=i.alternate,i!==null&&(i.lanes|=y)}function wm(i,l,f,y){return $u(i,l,f,y),zu(i)}function ca(i,l){return $u(i,null,null,l),zu(i)}function Gv(i,l,f){i.lanes|=f;var y=i.alternate;y!==null&&(y.lanes|=f);for(var N=!1,L=i.return;L!==null;)L.childLanes|=f,y=L.alternate,y!==null&&(y.childLanes|=f),L.tag===22&&(i=L.stateNode,i===null||i._visibility&1||(N=!0)),i=L,L=L.return;return i.tag===3?(L=i.stateNode,N&&l!==null&&(N=31-fe(f),i=L.hiddenUpdates,y=i[N],y===null?i[N]=[l]:y.push(l),l.lane=f|536870912),L):null}function zu(i){if(50<lc)throw lc=0,Dp=null,Error(r(185));for(var l=i.return;l!==null;)i=l,l=i.return;return i.tag===3?i.stateNode:null}var go={};function JA(i,l,f,y){this.tag=i,this.key=f,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=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 Sr(i,l,f,y){return new JA(i,l,f,y)}function Cm(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Bs(i,l){var f=i.alternate;return f===null?(f=Sr(i.tag,l,i.key,i.mode),f.elementType=i.elementType,f.type=i.type,f.stateNode=i.stateNode,f.alternate=i,i.alternate=f):(f.pendingProps=l,f.type=i.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=i.flags&65011712,f.childLanes=i.childLanes,f.lanes=i.lanes,f.child=i.child,f.memoizedProps=i.memoizedProps,f.memoizedState=i.memoizedState,f.updateQueue=i.updateQueue,l=i.dependencies,f.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},f.sibling=i.sibling,f.index=i.index,f.ref=i.ref,f.refCleanup=i.refCleanup,f}function Wv(i,l){i.flags&=65011714;var f=i.alternate;return f===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=f.childLanes,i.lanes=f.lanes,i.child=f.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=f.memoizedProps,i.memoizedState=f.memoizedState,i.updateQueue=f.updateQueue,i.type=f.type,l=f.dependencies,i.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),i}function Hu(i,l,f,y,N,L){var K=0;if(y=i,typeof i=="function")Cm(i)&&(K=1);else if(typeof i=="string")K=nD(i,f,Y.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case R:return i=Sr(31,f,l,N),i.elementType=R,i.lanes=L,i;case C:return ua(f.children,N,L,l);case v:K=8,N|=24;break;case S:return i=Sr(12,f,l,N|2),i.elementType=S,i.lanes=L,i;case E:return i=Sr(13,f,l,N),i.elementType=E,i.lanes=L,i;case T:return i=Sr(19,f,l,N),i.elementType=T,i.lanes=L,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case b:K=10;break e;case _:K=9;break e;case k:K=11;break e;case D:K=14;break e;case A:K=16,y=null;break e}K=29,f=Error(r(130,i===null?"null":typeof i,"")),y=null}return l=Sr(K,f,l,N),l.elementType=i,l.type=y,l.lanes=L,l}function ua(i,l,f,y){return i=Sr(7,i,y,l),i.lanes=f,i}function km(i,l,f){return i=Sr(6,i,null,l),i.lanes=f,i}function qv(i){var l=Sr(18,null,null,0);return l.stateNode=i,l}function jm(i,l,f){return l=Sr(4,i.children!==null?i.children:[],i.key,l),l.lanes=f,l.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},l}var Kv=new WeakMap;function Br(i,l){if(typeof i=="object"&&i!==null){var f=Kv.get(i);return f!==void 0?f:(l={value:i,source:l,stack:Ge(l)},Kv.set(i,l),l)}return{value:i,source:l,stack:Ge(l)}}var xo=[],yo=0,Fu=null,Hl=0,$r=[],zr=0,xi=null,gs=1,xs="";function $s(i,l){xo[yo++]=Hl,xo[yo++]=Fu,Fu=i,Hl=l}function Yv(i,l,f){$r[zr++]=gs,$r[zr++]=xs,$r[zr++]=xi,xi=i;var y=gs;i=xs;var N=32-fe(y)-1;y&=~(1<<N),f+=1;var L=32-fe(l)+N;if(30<L){var K=N-N%5;L=(y&(1<<K)-1).toString(32),y>>=K,N-=K,gs=1<<32-fe(l)+N|f<<N|y,xs=L+i}else gs=1<<L|f<<N|y,xs=i}function Em(i){i.return!==null&&($s(i,1),Yv(i,1,0))}function Nm(i){for(;i===Fu;)Fu=xo[--yo],xo[yo]=null,Hl=xo[--yo],xo[yo]=null;for(;i===xi;)xi=$r[--zr],$r[zr]=null,xs=$r[--zr],$r[zr]=null,gs=$r[--zr],$r[zr]=null}function Xv(i,l){$r[zr++]=gs,$r[zr++]=xs,$r[zr++]=xi,gs=l.id,xs=l.overflow,xi=i}var Vn=null,sn=null,At=!1,yi=null,Hr=!1,Tm=Error(r(519));function bi(i){var l=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Fl(Br(l,i)),Tm}function Jv(i){var l=i.stateNode,f=i.type,y=i.memoizedProps;switch(l[$e]=i,l[Qe]=y,f){case"dialog":jt("cancel",l),jt("close",l);break;case"iframe":case"object":case"embed":jt("load",l);break;case"video":case"audio":for(f=0;f<uc.length;f++)jt(uc[f],l);break;case"source":jt("error",l);break;case"img":case"image":case"link":jt("error",l),jt("load",l);break;case"details":jt("toggle",l);break;case"input":jt("invalid",l),uv(l,y.value,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name,!0);break;case"select":jt("invalid",l);break;case"textarea":jt("invalid",l),hv(l,y.value,y.defaultValue,y.children)}f=y.children,typeof f!="string"&&typeof f!="number"&&typeof f!="bigint"||l.textContent===""+f||y.suppressHydrationWarning===!0||mS(l.textContent,f)?(y.popover!=null&&(jt("beforetoggle",l),jt("toggle",l)),y.onScroll!=null&&jt("scroll",l),y.onScrollEnd!=null&&jt("scrollend",l),y.onClick!=null&&(l.onclick=Ms),l=!0):l=!1,l||bi(i,!0)}function Qv(i){for(Vn=i.return;Vn;)switch(Vn.tag){case 5:case 31:case 13:Hr=!1;return;case 27:case 3:Hr=!0;return;default:Vn=Vn.return}}function bo(i){if(i!==Vn)return!1;if(!At)return Qv(i),At=!0,!1;var l=i.tag,f;if((f=l!==3&&l!==27)&&((f=l===5)&&(f=i.type,f=!(f!=="form"&&f!=="button")||qp(i.type,i.memoizedProps)),f=!f),f&&sn&&bi(i),Qv(i),l===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));sn=wS(i)}else if(l===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));sn=wS(i)}else l===27?(l=sn,Ri(i.type)?(i=Qp,Qp=null,sn=i):sn=l):sn=Vn?Ur(i.stateNode.nextSibling):null;return!0}function da(){sn=Vn=null,At=!1}function Am(){var i=yi;return i!==null&&(fr===null?fr=i:fr.push.apply(fr,i),yi=null),i}function Fl(i){yi===null?yi=[i]:yi.push(i)}var Lm=O(null),ha=null,zs=null;function vi(i,l,f){z(Lm,l._currentValue),l._currentValue=f}function Hs(i){i._currentValue=Lm.current,V(Lm)}function Dm(i,l,f){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===f)break;i=i.return}}function Rm(i,l,f,y){var N=i.child;for(N!==null&&(N.return=i);N!==null;){var L=N.dependencies;if(L!==null){var K=N.child;L=L.firstContext;e:for(;L!==null;){var ee=L;L=N;for(var le=0;le<l.length;le++)if(ee.context===l[le]){L.lanes|=f,ee=L.alternate,ee!==null&&(ee.lanes|=f),Dm(L.return,f,i),y||(K=null);break e}L=ee.next}}else if(N.tag===18){if(K=N.return,K===null)throw Error(r(341));K.lanes|=f,L=K.alternate,L!==null&&(L.lanes|=f),Dm(K,f,i),K=null}else K=N.child;if(K!==null)K.return=N;else for(K=N;K!==null;){if(K===i){K=null;break}if(N=K.sibling,N!==null){N.return=K.return,K=N;break}K=K.return}N=K}}function vo(i,l,f,y){i=null;for(var N=l,L=!1;N!==null;){if(!L){if((N.flags&524288)!==0)L=!0;else if((N.flags&262144)!==0)break}if(N.tag===10){var K=N.alternate;if(K===null)throw Error(r(387));if(K=K.memoizedProps,K!==null){var ee=N.type;_r(N.pendingProps.value,K.value)||(i!==null?i.push(ee):i=[ee])}}else if(N===F.current){if(K=N.alternate,K===null)throw Error(r(387));K.memoizedState.memoizedState!==N.memoizedState.memoizedState&&(i!==null?i.push(pc):i=[pc])}N=N.return}i!==null&&Rm(l,i,f,y),l.flags|=262144}function Uu(i){for(i=i.firstContext;i!==null;){if(!_r(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function fa(i){ha=i,zs=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Gn(i){return Zv(ha,i)}function Vu(i,l){return ha===null&&fa(i),Zv(i,l)}function Zv(i,l){var f=l._currentValue;if(l={context:l,memoizedValue:f,next:null},zs===null){if(i===null)throw Error(r(308));zs=l,i.dependencies={lanes:0,firstContext:l},i.flags|=524288}else zs=zs.next=l;return f}var QA=typeof AbortController<"u"?AbortController:function(){var i=[],l=this.signal={aborted:!1,addEventListener:function(f,y){i.push(y)}};this.abort=function(){l.aborted=!0,i.forEach(function(f){return f()})}},ZA=e.unstable_scheduleCallback,eL=e.unstable_NormalPriority,jn={$$typeof:b,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Om(){return{controller:new QA,data:new Map,refCount:0}}function Ul(i){i.refCount--,i.refCount===0&&ZA(eL,function(){i.controller.abort()})}var Vl=null,Im=0,_o=0,So=null;function tL(i,l){if(Vl===null){var f=Vl=[];Im=0,_o=Bp(),So={status:"pending",value:void 0,then:function(y){f.push(y)}}}return Im++,l.then(e_,e_),l}function e_(){if(--Im===0&&Vl!==null){So!==null&&(So.status="fulfilled");var i=Vl;Vl=null,_o=0,So=null;for(var l=0;l<i.length;l++)(0,i[l])()}}function nL(i,l){var f=[],y={status:"pending",value:null,reason:null,then:function(N){f.push(N)}};return i.then(function(){y.status="fulfilled",y.value=l;for(var N=0;N<f.length;N++)(0,f[N])(l)},function(N){for(y.status="rejected",y.reason=N,N=0;N<f.length;N++)(0,f[N])(void 0)}),y}var t_=q.S;q.S=function(i,l){B0=Pe(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&tL(i,l),t_!==null&&t_(i,l)};var ma=O(null);function Mm(){var i=ma.current;return i!==null?i:Jt.pooledCache}function Gu(i,l){l===null?z(ma,ma.current):z(ma,l.pool)}function n_(){var i=Mm();return i===null?null:{parent:jn._currentValue,pool:i}}var wo=Error(r(460)),Pm=Error(r(474)),Wu=Error(r(542)),qu={then:function(){}};function r_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function s_(i,l,f){switch(f=i[f],f===void 0?i.push(l):f!==l&&(l.then(Ms,Ms),l=f),l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,a_(i),i;default:if(typeof l.status=="string")l.then(Ms,Ms);else{if(i=Jt,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,a_(i),i}throw ga=l,wo}}function pa(i){try{var l=i._init;return l(i._payload)}catch(f){throw f!==null&&typeof f=="object"&&typeof f.then=="function"?(ga=f,wo):f}}var ga=null;function i_(){if(ga===null)throw Error(r(459));var i=ga;return ga=null,i}function a_(i){if(i===wo||i===Wu)throw Error(r(483))}var Co=null,Gl=0;function Ku(i){var l=Gl;return Gl+=1,Co===null&&(Co=[]),s_(Co,i,l)}function Wl(i,l){l=l.props.ref,i.ref=l!==void 0?l:null}function Yu(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 o_(i){function l(me,ce){if(i){var ve=me.deletions;ve===null?(me.deletions=[ce],me.flags|=16):ve.push(ce)}}function f(me,ce){if(!i)return null;for(;ce!==null;)l(me,ce),ce=ce.sibling;return null}function y(me){for(var ce=new Map;me!==null;)me.key!==null?ce.set(me.key,me):ce.set(me.index,me),me=me.sibling;return ce}function N(me,ce){return me=Bs(me,ce),me.index=0,me.sibling=null,me}function L(me,ce,ve){return me.index=ve,i?(ve=me.alternate,ve!==null?(ve=ve.index,ve<ce?(me.flags|=67108866,ce):ve):(me.flags|=67108866,ce)):(me.flags|=1048576,ce)}function K(me){return i&&me.alternate===null&&(me.flags|=67108866),me}function ee(me,ce,ve,Me){return ce===null||ce.tag!==6?(ce=km(ve,me.mode,Me),ce.return=me,ce):(ce=N(ce,ve),ce.return=me,ce)}function le(me,ce,ve,Me){var lt=ve.type;return lt===C?Oe(me,ce,ve.props.children,Me,ve.key):ce!==null&&(ce.elementType===lt||typeof lt=="object"&<!==null&<.$$typeof===A&&pa(lt)===ce.type)?(ce=N(ce,ve.props),Wl(ce,ve),ce.return=me,ce):(ce=Hu(ve.type,ve.key,ve.props,null,me.mode,Me),Wl(ce,ve),ce.return=me,ce)}function we(me,ce,ve,Me){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==ve.containerInfo||ce.stateNode.implementation!==ve.implementation?(ce=jm(ve,me.mode,Me),ce.return=me,ce):(ce=N(ce,ve.children||[]),ce.return=me,ce)}function Oe(me,ce,ve,Me,lt){return ce===null||ce.tag!==7?(ce=ua(ve,me.mode,Me,lt),ce.return=me,ce):(ce=N(ce,ve),ce.return=me,ce)}function ze(me,ce,ve){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return ce=km(""+ce,me.mode,ve),ce.return=me,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case x:return ve=Hu(ce.type,ce.key,ce.props,null,me.mode,ve),Wl(ve,ce),ve.return=me,ve;case w:return ce=jm(ce,me.mode,ve),ce.return=me,ce;case A:return ce=pa(ce),ze(me,ce,ve)}if(H(ce)||$(ce))return ce=ua(ce,me.mode,ve,null),ce.return=me,ce;if(typeof ce.then=="function")return ze(me,Ku(ce),ve);if(ce.$$typeof===b)return ze(me,Vu(me,ce),ve);Yu(me,ce)}return null}function ke(me,ce,ve,Me){var lt=ce!==null?ce.key:null;if(typeof ve=="string"&&ve!==""||typeof ve=="number"||typeof ve=="bigint")return lt!==null?null:ee(me,ce,""+ve,Me);if(typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case x:return ve.key===lt?le(me,ce,ve,Me):null;case w:return ve.key===lt?we(me,ce,ve,Me):null;case A:return ve=pa(ve),ke(me,ce,ve,Me)}if(H(ve)||$(ve))return lt!==null?null:Oe(me,ce,ve,Me,null);if(typeof ve.then=="function")return ke(me,ce,Ku(ve),Me);if(ve.$$typeof===b)return ke(me,ce,Vu(me,ve),Me);Yu(me,ve)}return null}function Ee(me,ce,ve,Me,lt){if(typeof Me=="string"&&Me!==""||typeof Me=="number"||typeof Me=="bigint")return me=me.get(ve)||null,ee(ce,me,""+Me,lt);if(typeof Me=="object"&&Me!==null){switch(Me.$$typeof){case x:return me=me.get(Me.key===null?ve:Me.key)||null,le(ce,me,Me,lt);case w:return me=me.get(Me.key===null?ve:Me.key)||null,we(ce,me,Me,lt);case A:return Me=pa(Me),Ee(me,ce,ve,Me,lt)}if(H(Me)||$(Me))return me=me.get(ve)||null,Oe(ce,me,Me,lt,null);if(typeof Me.then=="function")return Ee(me,ce,ve,Ku(Me),lt);if(Me.$$typeof===b)return Ee(me,ce,ve,Vu(ce,Me),lt);Yu(ce,Me)}return null}function st(me,ce,ve,Me){for(var lt=null,It=null,at=ce,vt=ce=0,Tt=null;at!==null&&vt<ve.length;vt++){at.index>vt?(Tt=at,at=null):Tt=at.sibling;var Mt=ke(me,at,ve[vt],Me);if(Mt===null){at===null&&(at=Tt);break}i&&at&&Mt.alternate===null&&l(me,at),ce=L(Mt,ce,vt),It===null?lt=Mt:It.sibling=Mt,It=Mt,at=Tt}if(vt===ve.length)return f(me,at),At&&$s(me,vt),lt;if(at===null){for(;vt<ve.length;vt++)at=ze(me,ve[vt],Me),at!==null&&(ce=L(at,ce,vt),It===null?lt=at:It.sibling=at,It=at);return At&&$s(me,vt),lt}for(at=y(at);vt<ve.length;vt++)Tt=Ee(at,me,vt,ve[vt],Me),Tt!==null&&(i&&Tt.alternate!==null&&at.delete(Tt.key===null?vt:Tt.key),ce=L(Tt,ce,vt),It===null?lt=Tt:It.sibling=Tt,It=Tt);return i&&at.forEach(function(Bi){return l(me,Bi)}),At&&$s(me,vt),lt}function dt(me,ce,ve,Me){if(ve==null)throw Error(r(151));for(var lt=null,It=null,at=ce,vt=ce=0,Tt=null,Mt=ve.next();at!==null&&!Mt.done;vt++,Mt=ve.next()){at.index>vt?(Tt=at,at=null):Tt=at.sibling;var Bi=ke(me,at,Mt.value,Me);if(Bi===null){at===null&&(at=Tt);break}i&&at&&Bi.alternate===null&&l(me,at),ce=L(Bi,ce,vt),It===null?lt=Bi:It.sibling=Bi,It=Bi,at=Tt}if(Mt.done)return f(me,at),At&&$s(me,vt),lt;if(at===null){for(;!Mt.done;vt++,Mt=ve.next())Mt=ze(me,Mt.value,Me),Mt!==null&&(ce=L(Mt,ce,vt),It===null?lt=Mt:It.sibling=Mt,It=Mt);return At&&$s(me,vt),lt}for(at=y(at);!Mt.done;vt++,Mt=ve.next())Mt=Ee(at,me,vt,Mt.value,Me),Mt!==null&&(i&&Mt.alternate!==null&&at.delete(Mt.key===null?vt:Mt.key),ce=L(Mt,ce,vt),It===null?lt=Mt:It.sibling=Mt,It=Mt);return i&&at.forEach(function(fD){return l(me,fD)}),At&&$s(me,vt),lt}function qt(me,ce,ve,Me){if(typeof ve=="object"&&ve!==null&&ve.type===C&&ve.key===null&&(ve=ve.props.children),typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case x:e:{for(var lt=ve.key;ce!==null;){if(ce.key===lt){if(lt=ve.type,lt===C){if(ce.tag===7){f(me,ce.sibling),Me=N(ce,ve.props.children),Me.return=me,me=Me;break e}}else if(ce.elementType===lt||typeof lt=="object"&<!==null&<.$$typeof===A&&pa(lt)===ce.type){f(me,ce.sibling),Me=N(ce,ve.props),Wl(Me,ve),Me.return=me,me=Me;break e}f(me,ce);break}else l(me,ce);ce=ce.sibling}ve.type===C?(Me=ua(ve.props.children,me.mode,Me,ve.key),Me.return=me,me=Me):(Me=Hu(ve.type,ve.key,ve.props,null,me.mode,Me),Wl(Me,ve),Me.return=me,me=Me)}return K(me);case w:e:{for(lt=ve.key;ce!==null;){if(ce.key===lt)if(ce.tag===4&&ce.stateNode.containerInfo===ve.containerInfo&&ce.stateNode.implementation===ve.implementation){f(me,ce.sibling),Me=N(ce,ve.children||[]),Me.return=me,me=Me;break e}else{f(me,ce);break}else l(me,ce);ce=ce.sibling}Me=jm(ve,me.mode,Me),Me.return=me,me=Me}return K(me);case A:return ve=pa(ve),qt(me,ce,ve,Me)}if(H(ve))return st(me,ce,ve,Me);if($(ve)){if(lt=$(ve),typeof lt!="function")throw Error(r(150));return ve=lt.call(ve),dt(me,ce,ve,Me)}if(typeof ve.then=="function")return qt(me,ce,Ku(ve),Me);if(ve.$$typeof===b)return qt(me,ce,Vu(me,ve),Me);Yu(me,ve)}return typeof ve=="string"&&ve!==""||typeof ve=="number"||typeof ve=="bigint"?(ve=""+ve,ce!==null&&ce.tag===6?(f(me,ce.sibling),Me=N(ce,ve),Me.return=me,me=Me):(f(me,ce),Me=km(ve,me.mode,Me),Me.return=me,me=Me),K(me)):f(me,ce)}return function(me,ce,ve,Me){try{Gl=0;var lt=qt(me,ce,ve,Me);return Co=null,lt}catch(at){if(at===wo||at===Wu)throw at;var It=Sr(29,at,null,me.mode);return It.lanes=Me,It.return=me,It}finally{}}}var xa=o_(!0),l_=o_(!1),_i=!1;function Bm(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function $m(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 Si(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function wi(i,l,f){var y=i.updateQueue;if(y===null)return null;if(y=y.shared,($t&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),Gv(i,null,f),l}return $u(i,y,l,f),zu(i)}function ql(i,l,f){if(l=l.updateQueue,l!==null&&(l=l.shared,(f&4194048)!==0)){var y=l.lanes;y&=i.pendingLanes,f|=y,l.lanes=f,oe(i,f)}}function zm(i,l){var f=i.updateQueue,y=i.alternate;if(y!==null&&(y=y.updateQueue,f===y)){var N=null,L=null;if(f=f.firstBaseUpdate,f!==null){do{var K={lane:f.lane,tag:f.tag,payload:f.payload,callback:null,next:null};L===null?N=L=K:L=L.next=K,f=f.next}while(f!==null);L===null?N=L=l:L=L.next=l}else N=L=l;f={baseState:y.baseState,firstBaseUpdate:N,lastBaseUpdate:L,shared:y.shared,callbacks:y.callbacks},i.updateQueue=f;return}i=f.lastBaseUpdate,i===null?f.firstBaseUpdate=l:i.next=l,f.lastBaseUpdate=l}var Hm=!1;function Kl(){if(Hm){var i=So;if(i!==null)throw i}}function Yl(i,l,f,y){Hm=!1;var N=i.updateQueue;_i=!1;var L=N.firstBaseUpdate,K=N.lastBaseUpdate,ee=N.shared.pending;if(ee!==null){N.shared.pending=null;var le=ee,we=le.next;le.next=null,K===null?L=we:K.next=we,K=le;var Oe=i.alternate;Oe!==null&&(Oe=Oe.updateQueue,ee=Oe.lastBaseUpdate,ee!==K&&(ee===null?Oe.firstBaseUpdate=we:ee.next=we,Oe.lastBaseUpdate=le))}if(L!==null){var ze=N.baseState;K=0,Oe=we=le=null,ee=L;do{var ke=ee.lane&-536870913,Ee=ke!==ee.lane;if(Ee?(Nt&ke)===ke:(y&ke)===ke){ke!==0&&ke===_o&&(Hm=!0),Oe!==null&&(Oe=Oe.next={lane:0,tag:ee.tag,payload:ee.payload,callback:null,next:null});e:{var st=i,dt=ee;ke=l;var qt=f;switch(dt.tag){case 1:if(st=dt.payload,typeof st=="function"){ze=st.call(qt,ze,ke);break e}ze=st;break e;case 3:st.flags=st.flags&-65537|128;case 0:if(st=dt.payload,ke=typeof st=="function"?st.call(qt,ze,ke):st,ke==null)break e;ze=m({},ze,ke);break e;case 2:_i=!0}}ke=ee.callback,ke!==null&&(i.flags|=64,Ee&&(i.flags|=8192),Ee=N.callbacks,Ee===null?N.callbacks=[ke]:Ee.push(ke))}else Ee={lane:ke,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null},Oe===null?(we=Oe=Ee,le=ze):Oe=Oe.next=Ee,K|=ke;if(ee=ee.next,ee===null){if(ee=N.shared.pending,ee===null)break;Ee=ee,ee=Ee.next,Ee.next=null,N.lastBaseUpdate=Ee,N.shared.pending=null}}while(!0);Oe===null&&(le=ze),N.baseState=le,N.firstBaseUpdate=we,N.lastBaseUpdate=Oe,L===null&&(N.shared.lanes=0),Ni|=K,i.lanes=K,i.memoizedState=ze}}function c_(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function u_(i,l){var f=i.callbacks;if(f!==null)for(i.callbacks=null,i=0;i<f.length;i++)c_(f[i],l)}var ko=O(null),Xu=O(0);function d_(i,l){i=Xs,z(Xu,i),z(ko,l),Xs=i|l.baseLanes}function Fm(){z(Xu,Xs),z(ko,ko.current)}function Um(){Xs=Xu.current,V(ko),V(Xu)}var wr=O(null),Fr=null;function Ci(i){var l=i.alternate;z(yn,yn.current&1),z(wr,i),Fr===null&&(l===null||ko.current!==null||l.memoizedState!==null)&&(Fr=i)}function Vm(i){z(yn,yn.current),z(wr,i),Fr===null&&(Fr=i)}function h_(i){i.tag===22?(z(yn,yn.current),z(wr,i),Fr===null&&(Fr=i)):ki()}function ki(){z(yn,yn.current),z(wr,wr.current)}function Cr(i){V(wr),Fr===i&&(Fr=null),V(yn)}var yn=O(0);function Ju(i){for(var l=i;l!==null;){if(l.tag===13){var f=l.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||Xp(f)||Jp(f)))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 Fs=0,bt=null,Gt=null,En=null,Qu=!1,jo=!1,ya=!1,Zu=0,Xl=0,Eo=null,rL=0;function mn(){throw Error(r(321))}function Gm(i,l){if(l===null)return!1;for(var f=0;f<l.length&&f<i.length;f++)if(!_r(i[f],l[f]))return!1;return!0}function Wm(i,l,f,y,N,L){return Fs=L,bt=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,q.H=i===null||i.memoizedState===null?Y_:op,ya=!1,L=f(y,N),ya=!1,jo&&(L=m_(l,f,y,N)),f_(i),L}function f_(i){q.H=Zl;var l=Gt!==null&&Gt.next!==null;if(Fs=0,En=Gt=bt=null,Qu=!1,Xl=0,Eo=null,l)throw Error(r(300));i===null||Nn||(i=i.dependencies,i!==null&&Uu(i)&&(Nn=!0))}function m_(i,l,f,y){bt=i;var N=0;do{if(jo&&(Eo=null),Xl=0,jo=!1,25<=N)throw Error(r(301));if(N+=1,En=Gt=null,i.updateQueue!=null){var L=i.updateQueue;L.lastEffect=null,L.events=null,L.stores=null,L.memoCache!=null&&(L.memoCache.index=0)}q.H=X_,L=l(f,y)}while(jo);return L}function sL(){var i=q.H,l=i.useState()[0];return l=typeof l.then=="function"?Jl(l):l,i=i.useState()[0],(Gt!==null?Gt.memoizedState:null)!==i&&(bt.flags|=1024),l}function qm(){var i=Zu!==0;return Zu=0,i}function Km(i,l,f){l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~f}function Ym(i){if(Qu){for(i=i.memoizedState;i!==null;){var l=i.queue;l!==null&&(l.pending=null),i=i.next}Qu=!1}Fs=0,En=Gt=bt=null,jo=!1,Xl=Zu=0,Eo=null}function sr(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return En===null?bt.memoizedState=En=i:En=En.next=i,En}function bn(){if(Gt===null){var i=bt.alternate;i=i!==null?i.memoizedState:null}else i=Gt.next;var l=En===null?bt.memoizedState:En.next;if(l!==null)En=l,Gt=i;else{if(i===null)throw bt.alternate===null?Error(r(467)):Error(r(310));Gt=i,i={memoizedState:Gt.memoizedState,baseState:Gt.baseState,baseQueue:Gt.baseQueue,queue:Gt.queue,next:null},En===null?bt.memoizedState=En=i:En=En.next=i}return En}function ed(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Jl(i){var l=Xl;return Xl+=1,Eo===null&&(Eo=[]),i=s_(Eo,i,l),l=bt,(En===null?l.memoizedState:En.next)===null&&(l=l.alternate,q.H=l===null||l.memoizedState===null?Y_:op),i}function td(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Jl(i);if(i.$$typeof===b)return Gn(i)}throw Error(r(438,String(i)))}function Xm(i){var l=null,f=bt.updateQueue;if(f!==null&&(l=f.memoCache),l==null){var y=bt.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}),f===null&&(f=ed(),bt.updateQueue=f),f.memoCache=l,f=l.data[l.index],f===void 0)for(f=l.data[l.index]=Array(i),y=0;y<i;y++)f[y]=M;return l.index++,f}function Us(i,l){return typeof l=="function"?l(i):l}function nd(i){var l=bn();return Jm(l,Gt,i)}function Jm(i,l,f){var y=i.queue;if(y===null)throw Error(r(311));y.lastRenderedReducer=f;var N=i.baseQueue,L=y.pending;if(L!==null){if(N!==null){var K=N.next;N.next=L.next,L.next=K}l.baseQueue=N=L,y.pending=null}if(L=i.baseState,N===null)i.memoizedState=L;else{l=N.next;var ee=K=null,le=null,we=l,Oe=!1;do{var ze=we.lane&-536870913;if(ze!==we.lane?(Nt&ze)===ze:(Fs&ze)===ze){var ke=we.revertLane;if(ke===0)le!==null&&(le=le.next={lane:0,revertLane:0,gesture:null,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null}),ze===_o&&(Oe=!0);else if((Fs&ke)===ke){we=we.next,ke===_o&&(Oe=!0);continue}else ze={lane:0,revertLane:we.revertLane,gesture:null,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null},le===null?(ee=le=ze,K=L):le=le.next=ze,bt.lanes|=ke,Ni|=ke;ze=we.action,ya&&f(L,ze),L=we.hasEagerState?we.eagerState:f(L,ze)}else ke={lane:ze,revertLane:we.revertLane,gesture:we.gesture,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null},le===null?(ee=le=ke,K=L):le=le.next=ke,bt.lanes|=ze,Ni|=ze;we=we.next}while(we!==null&&we!==l);if(le===null?K=L:le.next=ee,!_r(L,i.memoizedState)&&(Nn=!0,Oe&&(f=So,f!==null)))throw f;i.memoizedState=L,i.baseState=K,i.baseQueue=le,y.lastRenderedState=L}return N===null&&(y.lanes=0),[i.memoizedState,y.dispatch]}function Qm(i){var l=bn(),f=l.queue;if(f===null)throw Error(r(311));f.lastRenderedReducer=i;var y=f.dispatch,N=f.pending,L=l.memoizedState;if(N!==null){f.pending=null;var K=N=N.next;do L=i(L,K.action),K=K.next;while(K!==N);_r(L,l.memoizedState)||(Nn=!0),l.memoizedState=L,l.baseQueue===null&&(l.baseState=L),f.lastRenderedState=L}return[L,y]}function p_(i,l,f){var y=bt,N=bn(),L=At;if(L){if(f===void 0)throw Error(r(407));f=f()}else f=l();var K=!_r((Gt||N).memoizedState,f);if(K&&(N.memoizedState=f,Nn=!0),N=N.queue,tp(y_.bind(null,y,N,i),[i]),N.getSnapshot!==l||K||En!==null&&En.memoizedState.tag&1){if(y.flags|=2048,No(9,{destroy:void 0},x_.bind(null,y,N,f,l),null),Jt===null)throw Error(r(349));L||(Fs&127)!==0||g_(y,l,f)}return f}function g_(i,l,f){i.flags|=16384,i={getSnapshot:l,value:f},l=bt.updateQueue,l===null?(l=ed(),bt.updateQueue=l,l.stores=[i]):(f=l.stores,f===null?l.stores=[i]:f.push(i))}function x_(i,l,f,y){l.value=f,l.getSnapshot=y,b_(l)&&v_(i)}function y_(i,l,f){return f(function(){b_(l)&&v_(i)})}function b_(i){var l=i.getSnapshot;i=i.value;try{var f=l();return!_r(i,f)}catch{return!0}}function v_(i){var l=ca(i,2);l!==null&&mr(l,i,2)}function Zm(i){var l=sr();if(typeof i=="function"){var f=i;if(i=f(),ya){ge(!0);try{f()}finally{ge(!1)}}}return l.memoizedState=l.baseState=i,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Us,lastRenderedState:i},l}function __(i,l,f,y){return i.baseState=f,Jm(i,Gt,typeof y=="function"?y:Us)}function iL(i,l,f,y,N){if(id(i))throw Error(r(485));if(i=l.action,i!==null){var L={payload:N,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(K){L.listeners.push(K)}};q.T!==null?f(!0):L.isTransition=!1,y(L),f=l.pending,f===null?(L.next=l.pending=L,S_(l,L)):(L.next=f.next,l.pending=f.next=L)}}function S_(i,l){var f=l.action,y=l.payload,N=i.state;if(l.isTransition){var L=q.T,K={};q.T=K;try{var ee=f(N,y),le=q.S;le!==null&&le(K,ee),w_(i,l,ee)}catch(we){ep(i,l,we)}finally{L!==null&&K.types!==null&&(L.types=K.types),q.T=L}}else try{L=f(N,y),w_(i,l,L)}catch(we){ep(i,l,we)}}function w_(i,l,f){f!==null&&typeof f=="object"&&typeof f.then=="function"?f.then(function(y){C_(i,l,y)},function(y){return ep(i,l,y)}):C_(i,l,f)}function C_(i,l,f){l.status="fulfilled",l.value=f,k_(l),i.state=f,l=i.pending,l!==null&&(f=l.next,f===l?i.pending=null:(f=f.next,l.next=f,S_(i,f)))}function ep(i,l,f){var y=i.pending;if(i.pending=null,y!==null){y=y.next;do l.status="rejected",l.reason=f,k_(l),l=l.next;while(l!==y)}i.action=null}function k_(i){i=i.listeners;for(var l=0;l<i.length;l++)(0,i[l])()}function j_(i,l){return l}function E_(i,l){if(At){var f=Jt.formState;if(f!==null){e:{var y=bt;if(At){if(sn){t:{for(var N=sn,L=Hr;N.nodeType!==8;){if(!L){N=null;break t}if(N=Ur(N.nextSibling),N===null){N=null;break t}}L=N.data,N=L==="F!"||L==="F"?N:null}if(N){sn=Ur(N.nextSibling),y=N.data==="F!";break e}}bi(y)}y=!1}y&&(l=f[0])}}return f=sr(),f.memoizedState=f.baseState=l,y={pending:null,lanes:0,dispatch:null,lastRenderedReducer:j_,lastRenderedState:l},f.queue=y,f=W_.bind(null,bt,y),y.dispatch=f,y=Zm(!1),L=ap.bind(null,bt,!1,y.queue),y=sr(),N={state:l,dispatch:null,action:i,pending:null},y.queue=N,f=iL.bind(null,bt,N,L,f),N.dispatch=f,y.memoizedState=i,[l,f,!1]}function N_(i){var l=bn();return T_(l,Gt,i)}function T_(i,l,f){if(l=Jm(i,l,j_)[0],i=nd(Us)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var y=Jl(l)}catch(K){throw K===wo?Wu:K}else y=l;l=bn();var N=l.queue,L=N.dispatch;return f!==l.memoizedState&&(bt.flags|=2048,No(9,{destroy:void 0},aL.bind(null,N,f),null)),[y,L,i]}function aL(i,l){i.action=l}function A_(i){var l=bn(),f=Gt;if(f!==null)return T_(l,f,i);bn(),l=l.memoizedState,f=bn();var y=f.queue.dispatch;return f.memoizedState=i,[l,y,!1]}function No(i,l,f,y){return i={tag:i,create:f,deps:y,inst:l,next:null},l=bt.updateQueue,l===null&&(l=ed(),bt.updateQueue=l),f=l.lastEffect,f===null?l.lastEffect=i.next=i:(y=f.next,f.next=i,i.next=y,l.lastEffect=i),i}function L_(){return bn().memoizedState}function rd(i,l,f,y){var N=sr();bt.flags|=i,N.memoizedState=No(1|l,{destroy:void 0},f,y===void 0?null:y)}function sd(i,l,f,y){var N=bn();y=y===void 0?null:y;var L=N.memoizedState.inst;Gt!==null&&y!==null&&Gm(y,Gt.memoizedState.deps)?N.memoizedState=No(l,L,f,y):(bt.flags|=i,N.memoizedState=No(1|l,L,f,y))}function D_(i,l){rd(8390656,8,i,l)}function tp(i,l){sd(2048,8,i,l)}function oL(i){bt.flags|=4;var l=bt.updateQueue;if(l===null)l=ed(),bt.updateQueue=l,l.events=[i];else{var f=l.events;f===null?l.events=[i]:f.push(i)}}function R_(i){var l=bn().memoizedState;return oL({ref:l,nextImpl:i}),function(){if(($t&2)!==0)throw Error(r(440));return l.impl.apply(void 0,arguments)}}function O_(i,l){return sd(4,2,i,l)}function I_(i,l){return sd(4,4,i,l)}function M_(i,l){if(typeof l=="function"){i=i();var f=l(i);return function(){typeof f=="function"?f():l(null)}}if(l!=null)return i=i(),l.current=i,function(){l.current=null}}function P_(i,l,f){f=f!=null?f.concat([i]):null,sd(4,4,M_.bind(null,l,i),f)}function np(){}function B_(i,l){var f=bn();l=l===void 0?null:l;var y=f.memoizedState;return l!==null&&Gm(l,y[1])?y[0]:(f.memoizedState=[i,l],i)}function $_(i,l){var f=bn();l=l===void 0?null:l;var y=f.memoizedState;if(l!==null&&Gm(l,y[1]))return y[0];if(y=i(),ya){ge(!0);try{i()}finally{ge(!1)}}return f.memoizedState=[y,l],y}function rp(i,l,f){return f===void 0||(Fs&1073741824)!==0&&(Nt&261930)===0?i.memoizedState=l:(i.memoizedState=f,i=z0(),bt.lanes|=i,Ni|=i,f)}function z_(i,l,f,y){return _r(f,l)?f:ko.current!==null?(i=rp(i,f,y),_r(i,l)||(Nn=!0),i):(Fs&42)===0||(Fs&1073741824)!==0&&(Nt&261930)===0?(Nn=!0,i.memoizedState=f):(i=z0(),bt.lanes|=i,Ni|=i,l)}function H_(i,l,f,y,N){var L=Q.p;Q.p=L!==0&&8>L?L:8;var K=q.T,ee={};q.T=ee,ap(i,!1,l,f);try{var le=N(),we=q.S;if(we!==null&&we(ee,le),le!==null&&typeof le=="object"&&typeof le.then=="function"){var Oe=nL(le,y);Ql(i,l,Oe,Er(i))}else Ql(i,l,y,Er(i))}catch(ze){Ql(i,l,{then:function(){},status:"rejected",reason:ze},Er())}finally{Q.p=L,K!==null&&ee.types!==null&&(K.types=ee.types),q.T=K}}function lL(){}function sp(i,l,f,y){if(i.tag!==5)throw Error(r(476));var N=F_(i).queue;H_(i,N,l,J,f===null?lL:function(){return U_(i),f(y)})}function F_(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:Us,lastRenderedState:J},next:null};var f={};return l.next={memoizedState:f,baseState:f,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Us,lastRenderedState:f},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function U_(i){var l=F_(i);l.next===null&&(l=i.alternate.memoizedState),Ql(i,l.next.queue,{},Er())}function ip(){return Gn(pc)}function V_(){return bn().memoizedState}function G_(){return bn().memoizedState}function cL(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var f=Er();i=Si(f);var y=wi(l,i,f);y!==null&&(mr(y,l,f),ql(y,l,f)),l={cache:Om()},i.payload=l;return}l=l.return}}function uL(i,l,f){var y=Er();f={lane:y,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},id(i)?q_(l,f):(f=wm(i,l,f,y),f!==null&&(mr(f,i,y),K_(f,l,y)))}function W_(i,l,f){var y=Er();Ql(i,l,f,y)}function Ql(i,l,f,y){var N={lane:y,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null};if(id(i))q_(l,N);else{var L=i.alternate;if(i.lanes===0&&(L===null||L.lanes===0)&&(L=l.lastRenderedReducer,L!==null))try{var K=l.lastRenderedState,ee=L(K,f);if(N.hasEagerState=!0,N.eagerState=ee,_r(ee,K))return $u(i,l,N,0),Jt===null&&Bu(),!1}catch{}finally{}if(f=wm(i,l,N,y),f!==null)return mr(f,i,y),K_(f,l,y),!0}return!1}function ap(i,l,f,y){if(y={lane:2,revertLane:Bp(),gesture:null,action:y,hasEagerState:!1,eagerState:null,next:null},id(i)){if(l)throw Error(r(479))}else l=wm(i,f,y,2),l!==null&&mr(l,i,2)}function id(i){var l=i.alternate;return i===bt||l!==null&&l===bt}function q_(i,l){jo=Qu=!0;var f=i.pending;f===null?l.next=l:(l.next=f.next,f.next=l),i.pending=l}function K_(i,l,f){if((f&4194048)!==0){var y=l.lanes;y&=i.pendingLanes,f|=y,l.lanes=f,oe(i,f)}}var Zl={readContext:Gn,use:td,useCallback:mn,useContext:mn,useEffect:mn,useImperativeHandle:mn,useLayoutEffect:mn,useInsertionEffect:mn,useMemo:mn,useReducer:mn,useRef:mn,useState:mn,useDebugValue:mn,useDeferredValue:mn,useTransition:mn,useSyncExternalStore:mn,useId:mn,useHostTransitionStatus:mn,useFormState:mn,useActionState:mn,useOptimistic:mn,useMemoCache:mn,useCacheRefresh:mn};Zl.useEffectEvent=mn;var Y_={readContext:Gn,use:td,useCallback:function(i,l){return sr().memoizedState=[i,l===void 0?null:l],i},useContext:Gn,useEffect:D_,useImperativeHandle:function(i,l,f){f=f!=null?f.concat([i]):null,rd(4194308,4,M_.bind(null,l,i),f)},useLayoutEffect:function(i,l){return rd(4194308,4,i,l)},useInsertionEffect:function(i,l){rd(4,2,i,l)},useMemo:function(i,l){var f=sr();l=l===void 0?null:l;var y=i();if(ya){ge(!0);try{i()}finally{ge(!1)}}return f.memoizedState=[y,l],y},useReducer:function(i,l,f){var y=sr();if(f!==void 0){var N=f(l);if(ya){ge(!0);try{f(l)}finally{ge(!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=uL.bind(null,bt,i),[y.memoizedState,i]},useRef:function(i){var l=sr();return i={current:i},l.memoizedState=i},useState:function(i){i=Zm(i);var l=i.queue,f=W_.bind(null,bt,l);return l.dispatch=f,[i.memoizedState,f]},useDebugValue:np,useDeferredValue:function(i,l){var f=sr();return rp(f,i,l)},useTransition:function(){var i=Zm(!1);return i=H_.bind(null,bt,i.queue,!0,!1),sr().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,f){var y=bt,N=sr();if(At){if(f===void 0)throw Error(r(407));f=f()}else{if(f=l(),Jt===null)throw Error(r(349));(Nt&127)!==0||g_(y,l,f)}N.memoizedState=f;var L={value:f,getSnapshot:l};return N.queue=L,D_(y_.bind(null,y,L,i),[i]),y.flags|=2048,No(9,{destroy:void 0},x_.bind(null,y,L,f,l),null),f},useId:function(){var i=sr(),l=Jt.identifierPrefix;if(At){var f=xs,y=gs;f=(y&~(1<<32-fe(y)-1)).toString(32)+f,l="_"+l+"R_"+f,f=Zu++,0<f&&(l+="H"+f.toString(32)),l+="_"}else f=rL++,l="_"+l+"r_"+f.toString(32)+"_";return i.memoizedState=l},useHostTransitionStatus:ip,useFormState:E_,useActionState:E_,useOptimistic:function(i){var l=sr();l.memoizedState=l.baseState=i;var f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=f,l=ap.bind(null,bt,!0,f),f.dispatch=l,[i,l]},useMemoCache:Xm,useCacheRefresh:function(){return sr().memoizedState=cL.bind(null,bt)},useEffectEvent:function(i){var l=sr(),f={impl:i};return l.memoizedState=f,function(){if(($t&2)!==0)throw Error(r(440));return f.impl.apply(void 0,arguments)}}},op={readContext:Gn,use:td,useCallback:B_,useContext:Gn,useEffect:tp,useImperativeHandle:P_,useInsertionEffect:O_,useLayoutEffect:I_,useMemo:$_,useReducer:nd,useRef:L_,useState:function(){return nd(Us)},useDebugValue:np,useDeferredValue:function(i,l){var f=bn();return z_(f,Gt.memoizedState,i,l)},useTransition:function(){var i=nd(Us)[0],l=bn().memoizedState;return[typeof i=="boolean"?i:Jl(i),l]},useSyncExternalStore:p_,useId:V_,useHostTransitionStatus:ip,useFormState:N_,useActionState:N_,useOptimistic:function(i,l){var f=bn();return __(f,Gt,i,l)},useMemoCache:Xm,useCacheRefresh:G_};op.useEffectEvent=R_;var X_={readContext:Gn,use:td,useCallback:B_,useContext:Gn,useEffect:tp,useImperativeHandle:P_,useInsertionEffect:O_,useLayoutEffect:I_,useMemo:$_,useReducer:Qm,useRef:L_,useState:function(){return Qm(Us)},useDebugValue:np,useDeferredValue:function(i,l){var f=bn();return Gt===null?rp(f,i,l):z_(f,Gt.memoizedState,i,l)},useTransition:function(){var i=Qm(Us)[0],l=bn().memoizedState;return[typeof i=="boolean"?i:Jl(i),l]},useSyncExternalStore:p_,useId:V_,useHostTransitionStatus:ip,useFormState:A_,useActionState:A_,useOptimistic:function(i,l){var f=bn();return Gt!==null?__(f,Gt,i,l):(f.baseState=i,[i,f.queue.dispatch])},useMemoCache:Xm,useCacheRefresh:G_};X_.useEffectEvent=R_;function lp(i,l,f,y){l=i.memoizedState,f=f(y,l),f=f==null?l:m({},l,f),i.memoizedState=f,i.lanes===0&&(i.updateQueue.baseState=f)}var cp={enqueueSetState:function(i,l,f){i=i._reactInternals;var y=Er(),N=Si(y);N.payload=l,f!=null&&(N.callback=f),l=wi(i,N,y),l!==null&&(mr(l,i,y),ql(l,i,y))},enqueueReplaceState:function(i,l,f){i=i._reactInternals;var y=Er(),N=Si(y);N.tag=1,N.payload=l,f!=null&&(N.callback=f),l=wi(i,N,y),l!==null&&(mr(l,i,y),ql(l,i,y))},enqueueForceUpdate:function(i,l){i=i._reactInternals;var f=Er(),y=Si(f);y.tag=2,l!=null&&(y.callback=l),l=wi(i,y,f),l!==null&&(mr(l,i,f),ql(l,i,f))}};function J_(i,l,f,y,N,L,K){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(y,L,K):l.prototype&&l.prototype.isPureReactComponent?!$l(f,y)||!$l(N,L):!0}function Q_(i,l,f,y){i=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(f,y),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(f,y),l.state!==i&&cp.enqueueReplaceState(l,l.state,null)}function ba(i,l){var f=l;if("ref"in l){f={};for(var y in l)y!=="ref"&&(f[y]=l[y])}if(i=i.defaultProps){f===l&&(f=m({},f));for(var N in i)f[N]===void 0&&(f[N]=i[N])}return f}function Z_(i){Pu(i)}function e0(i){console.error(i)}function t0(i){Pu(i)}function ad(i,l){try{var f=i.onUncaughtError;f(l.value,{componentStack:l.stack})}catch(y){setTimeout(function(){throw y})}}function n0(i,l,f){try{var y=i.onCaughtError;y(f.value,{componentStack:f.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(N){setTimeout(function(){throw N})}}function up(i,l,f){return f=Si(f),f.tag=3,f.payload={element:null},f.callback=function(){ad(i,l)},f}function r0(i){return i=Si(i),i.tag=3,i}function s0(i,l,f,y){var N=f.type.getDerivedStateFromError;if(typeof N=="function"){var L=y.value;i.payload=function(){return N(L)},i.callback=function(){n0(l,f,y)}}var K=f.stateNode;K!==null&&typeof K.componentDidCatch=="function"&&(i.callback=function(){n0(l,f,y),typeof N!="function"&&(Ti===null?Ti=new Set([this]):Ti.add(this));var ee=y.stack;this.componentDidCatch(y.value,{componentStack:ee!==null?ee:""})})}function dL(i,l,f,y,N){if(f.flags|=32768,y!==null&&typeof y=="object"&&typeof y.then=="function"){if(l=f.alternate,l!==null&&vo(l,f,N,!0),f=wr.current,f!==null){switch(f.tag){case 31:case 13:return Fr===null?yd():f.alternate===null&&pn===0&&(pn=3),f.flags&=-257,f.flags|=65536,f.lanes=N,y===qu?f.flags|=16384:(l=f.updateQueue,l===null?f.updateQueue=new Set([y]):l.add(y),Ip(i,y,N)),!1;case 22:return f.flags|=65536,y===qu?f.flags|=16384:(l=f.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([y])},f.updateQueue=l):(f=l.retryQueue,f===null?l.retryQueue=new Set([y]):f.add(y)),Ip(i,y,N)),!1}throw Error(r(435,f.tag))}return Ip(i,y,N),yd(),!1}if(At)return l=wr.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=N,y!==Tm&&(i=Error(r(422),{cause:y}),Fl(Br(i,f)))):(y!==Tm&&(l=Error(r(423),{cause:y}),Fl(Br(l,f))),i=i.current.alternate,i.flags|=65536,N&=-N,i.lanes|=N,y=Br(y,f),N=up(i.stateNode,y,N),zm(i,N),pn!==4&&(pn=2)),!1;var L=Error(r(520),{cause:y});if(L=Br(L,f),oc===null?oc=[L]:oc.push(L),pn!==4&&(pn=2),l===null)return!0;y=Br(y,f),f=l;do{switch(f.tag){case 3:return f.flags|=65536,i=N&-N,f.lanes|=i,i=up(f.stateNode,y,i),zm(f,i),!1;case 1:if(l=f.type,L=f.stateNode,(f.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||L!==null&&typeof L.componentDidCatch=="function"&&(Ti===null||!Ti.has(L))))return f.flags|=65536,N&=-N,f.lanes|=N,N=r0(N),s0(N,i,f,y),zm(f,N),!1}f=f.return}while(f!==null);return!1}var dp=Error(r(461)),Nn=!1;function Wn(i,l,f,y){l.child=i===null?l_(l,null,f,y):xa(l,i.child,f,y)}function i0(i,l,f,y,N){f=f.render;var L=l.ref;if("ref"in y){var K={};for(var ee in y)ee!=="ref"&&(K[ee]=y[ee])}else K=y;return fa(l),y=Wm(i,l,f,K,L,N),ee=qm(),i!==null&&!Nn?(Km(i,l,N),Vs(i,l,N)):(At&&ee&&Em(l),l.flags|=1,Wn(i,l,y,N),l.child)}function a0(i,l,f,y,N){if(i===null){var L=f.type;return typeof L=="function"&&!Cm(L)&&L.defaultProps===void 0&&f.compare===null?(l.tag=15,l.type=L,o0(i,l,L,y,N)):(i=Hu(f.type,null,y,l,l.mode,N),i.ref=l.ref,i.return=l,l.child=i)}if(L=i.child,!bp(i,N)){var K=L.memoizedProps;if(f=f.compare,f=f!==null?f:$l,f(K,y)&&i.ref===l.ref)return Vs(i,l,N)}return l.flags|=1,i=Bs(L,y),i.ref=l.ref,i.return=l,l.child=i}function o0(i,l,f,y,N){if(i!==null){var L=i.memoizedProps;if($l(L,y)&&i.ref===l.ref)if(Nn=!1,l.pendingProps=y=L,bp(i,N))(i.flags&131072)!==0&&(Nn=!0);else return l.lanes=i.lanes,Vs(i,l,N)}return hp(i,l,f,y,N)}function l0(i,l,f,y){var N=y.children,L=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(L=L!==null?L.baseLanes|f:f,i!==null){for(y=l.child=i.child,N=0;y!==null;)N=N|y.lanes|y.childLanes,y=y.sibling;y=N&~L}else y=0,l.child=null;return c0(i,l,L,f,y)}if((f&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},i!==null&&Gu(l,L!==null?L.cachePool:null),L!==null?d_(l,L):Fm(),h_(l);else return y=l.lanes=536870912,c0(i,l,L!==null?L.baseLanes|f:f,f,y)}else L!==null?(Gu(l,L.cachePool),d_(l,L),ki(),l.memoizedState=null):(i!==null&&Gu(l,null),Fm(),ki());return Wn(i,l,N,f),l.child}function ec(i,l){return i!==null&&i.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function c0(i,l,f,y,N){var L=Mm();return L=L===null?null:{parent:jn._currentValue,pool:L},l.memoizedState={baseLanes:f,cachePool:L},i!==null&&Gu(l,null),Fm(),h_(l),i!==null&&vo(i,l,y,!0),l.childLanes=N,null}function od(i,l){return l=cd({mode:l.mode,children:l.children},i.mode),l.ref=i.ref,i.child=l,l.return=i,l}function u0(i,l,f){return xa(l,i.child,null,f),i=od(l,l.pendingProps),i.flags|=2,Cr(l),l.memoizedState=null,i}function hL(i,l,f){var y=l.pendingProps,N=(l.flags&128)!==0;if(l.flags&=-129,i===null){if(At){if(y.mode==="hidden")return i=od(l,y),l.lanes=536870912,ec(null,i);if(Vm(l),(i=sn)?(i=SS(i,Hr),i=i!==null&&i.data==="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:xi!==null?{id:gs,overflow:xs}:null,retryLane:536870912,hydrationErrors:null},f=qv(i),f.return=l,l.child=f,Vn=l,sn=null)):i=null,i===null)throw bi(l);return l.lanes=536870912,null}return od(l,y)}var L=i.memoizedState;if(L!==null){var K=L.dehydrated;if(Vm(l),N)if(l.flags&256)l.flags&=-257,l=u0(i,l,f);else if(l.memoizedState!==null)l.child=i.child,l.flags|=128,l=null;else throw Error(r(558));else if(Nn||vo(i,l,f,!1),N=(f&i.childLanes)!==0,Nn||N){if(y=Jt,y!==null&&(K=Be(y,f),K!==0&&K!==L.retryLane))throw L.retryLane=K,ca(i,K),mr(y,i,K),dp;yd(),l=u0(i,l,f)}else i=L.treeContext,sn=Ur(K.nextSibling),Vn=l,At=!0,yi=null,Hr=!1,i!==null&&Xv(l,i),l=od(l,y),l.flags|=4096;return l}return i=Bs(i.child,{mode:y.mode,children:y.children}),i.ref=l.ref,l.child=i,i.return=l,i}function ld(i,l){var f=l.ref;if(f===null)i!==null&&i.ref!==null&&(l.flags|=4194816);else{if(typeof f!="function"&&typeof f!="object")throw Error(r(284));(i===null||i.ref!==f)&&(l.flags|=4194816)}}function hp(i,l,f,y,N){return fa(l),f=Wm(i,l,f,y,void 0,N),y=qm(),i!==null&&!Nn?(Km(i,l,N),Vs(i,l,N)):(At&&y&&Em(l),l.flags|=1,Wn(i,l,f,N),l.child)}function d0(i,l,f,y,N,L){return fa(l),l.updateQueue=null,f=m_(l,y,f,N),f_(i),y=qm(),i!==null&&!Nn?(Km(i,l,L),Vs(i,l,L)):(At&&y&&Em(l),l.flags|=1,Wn(i,l,f,L),l.child)}function h0(i,l,f,y,N){if(fa(l),l.stateNode===null){var L=go,K=f.contextType;typeof K=="object"&&K!==null&&(L=Gn(K)),L=new f(y,L),l.memoizedState=L.state!==null&&L.state!==void 0?L.state:null,L.updater=cp,l.stateNode=L,L._reactInternals=l,L=l.stateNode,L.props=y,L.state=l.memoizedState,L.refs={},Bm(l),K=f.contextType,L.context=typeof K=="object"&&K!==null?Gn(K):go,L.state=l.memoizedState,K=f.getDerivedStateFromProps,typeof K=="function"&&(lp(l,f,K,y),L.state=l.memoizedState),typeof f.getDerivedStateFromProps=="function"||typeof L.getSnapshotBeforeUpdate=="function"||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(K=L.state,typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount(),K!==L.state&&cp.enqueueReplaceState(L,L.state,null),Yl(l,y,L,N),Kl(),L.state=l.memoizedState),typeof L.componentDidMount=="function"&&(l.flags|=4194308),y=!0}else if(i===null){L=l.stateNode;var ee=l.memoizedProps,le=ba(f,ee);L.props=le;var we=L.context,Oe=f.contextType;K=go,typeof Oe=="object"&&Oe!==null&&(K=Gn(Oe));var ze=f.getDerivedStateFromProps;Oe=typeof ze=="function"||typeof L.getSnapshotBeforeUpdate=="function",ee=l.pendingProps!==ee,Oe||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(ee||we!==K)&&Q_(l,L,y,K),_i=!1;var ke=l.memoizedState;L.state=ke,Yl(l,y,L,N),Kl(),we=l.memoizedState,ee||ke!==we||_i?(typeof ze=="function"&&(lp(l,f,ze,y),we=l.memoizedState),(le=_i||J_(l,f,le,y,ke,we,K))?(Oe||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount()),typeof L.componentDidMount=="function"&&(l.flags|=4194308)):(typeof L.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=y,l.memoizedState=we),L.props=y,L.state=we,L.context=K,y=le):(typeof L.componentDidMount=="function"&&(l.flags|=4194308),y=!1)}else{L=l.stateNode,$m(i,l),K=l.memoizedProps,Oe=ba(f,K),L.props=Oe,ze=l.pendingProps,ke=L.context,we=f.contextType,le=go,typeof we=="object"&&we!==null&&(le=Gn(we)),ee=f.getDerivedStateFromProps,(we=typeof ee=="function"||typeof L.getSnapshotBeforeUpdate=="function")||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(K!==ze||ke!==le)&&Q_(l,L,y,le),_i=!1,ke=l.memoizedState,L.state=ke,Yl(l,y,L,N),Kl();var Ee=l.memoizedState;K!==ze||ke!==Ee||_i||i!==null&&i.dependencies!==null&&Uu(i.dependencies)?(typeof ee=="function"&&(lp(l,f,ee,y),Ee=l.memoizedState),(Oe=_i||J_(l,f,Oe,y,ke,Ee,le)||i!==null&&i.dependencies!==null&&Uu(i.dependencies))?(we||typeof L.UNSAFE_componentWillUpdate!="function"&&typeof L.componentWillUpdate!="function"||(typeof L.componentWillUpdate=="function"&&L.componentWillUpdate(y,Ee,le),typeof L.UNSAFE_componentWillUpdate=="function"&&L.UNSAFE_componentWillUpdate(y,Ee,le)),typeof L.componentDidUpdate=="function"&&(l.flags|=4),typeof L.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof L.componentDidUpdate!="function"||K===i.memoizedProps&&ke===i.memoizedState||(l.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||K===i.memoizedProps&&ke===i.memoizedState||(l.flags|=1024),l.memoizedProps=y,l.memoizedState=Ee),L.props=y,L.state=Ee,L.context=le,y=Oe):(typeof L.componentDidUpdate!="function"||K===i.memoizedProps&&ke===i.memoizedState||(l.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||K===i.memoizedProps&&ke===i.memoizedState||(l.flags|=1024),y=!1)}return L=y,ld(i,l),y=(l.flags&128)!==0,L||y?(L=l.stateNode,f=y&&typeof f.getDerivedStateFromError!="function"?null:L.render(),l.flags|=1,i!==null&&y?(l.child=xa(l,i.child,null,N),l.child=xa(l,null,f,N)):Wn(i,l,f,N),l.memoizedState=L.state,i=l.child):i=Vs(i,l,N),i}function f0(i,l,f,y){return da(),l.flags|=256,Wn(i,l,f,y),l.child}var fp={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function mp(i){return{baseLanes:i,cachePool:n_()}}function pp(i,l,f){return i=i!==null?i.childLanes&~f:0,l&&(i|=jr),i}function m0(i,l,f){var y=l.pendingProps,N=!1,L=(l.flags&128)!==0,K;if((K=L)||(K=i!==null&&i.memoizedState===null?!1:(yn.current&2)!==0),K&&(N=!0,l.flags&=-129),K=(l.flags&32)!==0,l.flags&=-33,i===null){if(At){if(N?Ci(l):ki(),(i=sn)?(i=SS(i,Hr),i=i!==null&&i.data!=="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:xi!==null?{id:gs,overflow:xs}:null,retryLane:536870912,hydrationErrors:null},f=qv(i),f.return=l,l.child=f,Vn=l,sn=null)):i=null,i===null)throw bi(l);return Jp(i)?l.lanes=32:l.lanes=536870912,null}var ee=y.children;return y=y.fallback,N?(ki(),N=l.mode,ee=cd({mode:"hidden",children:ee},N),y=ua(y,N,f,null),ee.return=l,y.return=l,ee.sibling=y,l.child=ee,y=l.child,y.memoizedState=mp(f),y.childLanes=pp(i,K,f),l.memoizedState=fp,ec(null,y)):(Ci(l),gp(l,ee))}var le=i.memoizedState;if(le!==null&&(ee=le.dehydrated,ee!==null)){if(L)l.flags&256?(Ci(l),l.flags&=-257,l=xp(i,l,f)):l.memoizedState!==null?(ki(),l.child=i.child,l.flags|=128,l=null):(ki(),ee=y.fallback,N=l.mode,y=cd({mode:"visible",children:y.children},N),ee=ua(ee,N,f,null),ee.flags|=2,y.return=l,ee.return=l,y.sibling=ee,l.child=y,xa(l,i.child,null,f),y=l.child,y.memoizedState=mp(f),y.childLanes=pp(i,K,f),l.memoizedState=fp,l=ec(null,y));else if(Ci(l),Jp(ee)){if(K=ee.nextSibling&&ee.nextSibling.dataset,K)var we=K.dgst;K=we,y=Error(r(419)),y.stack="",y.digest=K,Fl({value:y,source:null,stack:null}),l=xp(i,l,f)}else if(Nn||vo(i,l,f,!1),K=(f&i.childLanes)!==0,Nn||K){if(K=Jt,K!==null&&(y=Be(K,f),y!==0&&y!==le.retryLane))throw le.retryLane=y,ca(i,y),mr(K,i,y),dp;Xp(ee)||yd(),l=xp(i,l,f)}else Xp(ee)?(l.flags|=192,l.child=i.child,l=null):(i=le.treeContext,sn=Ur(ee.nextSibling),Vn=l,At=!0,yi=null,Hr=!1,i!==null&&Xv(l,i),l=gp(l,y.children),l.flags|=4096);return l}return N?(ki(),ee=y.fallback,N=l.mode,le=i.child,we=le.sibling,y=Bs(le,{mode:"hidden",children:y.children}),y.subtreeFlags=le.subtreeFlags&65011712,we!==null?ee=Bs(we,ee):(ee=ua(ee,N,f,null),ee.flags|=2),ee.return=l,y.return=l,y.sibling=ee,l.child=y,ec(null,y),y=l.child,ee=i.child.memoizedState,ee===null?ee=mp(f):(N=ee.cachePool,N!==null?(le=jn._currentValue,N=N.parent!==le?{parent:le,pool:le}:N):N=n_(),ee={baseLanes:ee.baseLanes|f,cachePool:N}),y.memoizedState=ee,y.childLanes=pp(i,K,f),l.memoizedState=fp,ec(i.child,y)):(Ci(l),f=i.child,i=f.sibling,f=Bs(f,{mode:"visible",children:y.children}),f.return=l,f.sibling=null,i!==null&&(K=l.deletions,K===null?(l.deletions=[i],l.flags|=16):K.push(i)),l.child=f,l.memoizedState=null,f)}function gp(i,l){return l=cd({mode:"visible",children:l},i.mode),l.return=i,i.child=l}function cd(i,l){return i=Sr(22,i,null,l),i.lanes=0,i}function xp(i,l,f){return xa(l,i.child,null,f),i=gp(l,l.pendingProps.children),i.flags|=2,l.memoizedState=null,i}function p0(i,l,f){i.lanes|=l;var y=i.alternate;y!==null&&(y.lanes|=l),Dm(i.return,l,f)}function yp(i,l,f,y,N,L){var K=i.memoizedState;K===null?i.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:y,tail:f,tailMode:N,treeForkCount:L}:(K.isBackwards=l,K.rendering=null,K.renderingStartTime=0,K.last=y,K.tail=f,K.tailMode=N,K.treeForkCount=L)}function g0(i,l,f){var y=l.pendingProps,N=y.revealOrder,L=y.tail;y=y.children;var K=yn.current,ee=(K&2)!==0;if(ee?(K=K&1|2,l.flags|=128):K&=1,z(yn,K),Wn(i,l,y,f),y=At?Hl:0,!ee&&i!==null&&(i.flags&128)!==0)e:for(i=l.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&p0(i,f,l);else if(i.tag===19)p0(i,f,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(f=l.child,N=null;f!==null;)i=f.alternate,i!==null&&Ju(i)===null&&(N=f),f=f.sibling;f=N,f===null?(N=l.child,l.child=null):(N=f.sibling,f.sibling=null),yp(l,!1,N,f,L,y);break;case"backwards":case"unstable_legacy-backwards":for(f=null,N=l.child,l.child=null;N!==null;){if(i=N.alternate,i!==null&&Ju(i)===null){l.child=N;break}i=N.sibling,N.sibling=f,f=N,N=i}yp(l,!0,f,null,L,y);break;case"together":yp(l,!1,null,null,void 0,y);break;default:l.memoizedState=null}return l.child}function Vs(i,l,f){if(i!==null&&(l.dependencies=i.dependencies),Ni|=l.lanes,(f&l.childLanes)===0)if(i!==null){if(vo(i,l,f,!1),(f&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,f=Bs(i,i.pendingProps),l.child=f,f.return=l;i.sibling!==null;)i=i.sibling,f=f.sibling=Bs(i,i.pendingProps),f.return=l;f.sibling=null}return l.child}function bp(i,l){return(i.lanes&l)!==0?!0:(i=i.dependencies,!!(i!==null&&Uu(i)))}function fL(i,l,f){switch(l.tag){case 3:P(l,l.stateNode.containerInfo),vi(l,jn,i.memoizedState.cache),da();break;case 27:case 5:se(l);break;case 4:P(l,l.stateNode.containerInfo);break;case 10:vi(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,Vm(l),null;break;case 13:var y=l.memoizedState;if(y!==null)return y.dehydrated!==null?(Ci(l),l.flags|=128,null):(f&l.child.childLanes)!==0?m0(i,l,f):(Ci(l),i=Vs(i,l,f),i!==null?i.sibling:null);Ci(l);break;case 19:var N=(i.flags&128)!==0;if(y=(f&l.childLanes)!==0,y||(vo(i,l,f,!1),y=(f&l.childLanes)!==0),N){if(y)return g0(i,l,f);l.flags|=128}if(N=l.memoizedState,N!==null&&(N.rendering=null,N.tail=null,N.lastEffect=null),z(yn,yn.current),y)break;return null;case 22:return l.lanes=0,l0(i,l,f,l.pendingProps);case 24:vi(l,jn,i.memoizedState.cache)}return Vs(i,l,f)}function x0(i,l,f){if(i!==null)if(i.memoizedProps!==l.pendingProps)Nn=!0;else{if(!bp(i,f)&&(l.flags&128)===0)return Nn=!1,fL(i,l,f);Nn=(i.flags&131072)!==0}else Nn=!1,At&&(l.flags&1048576)!==0&&Yv(l,Hl,l.index);switch(l.lanes=0,l.tag){case 16:e:{var y=l.pendingProps;if(i=pa(l.elementType),l.type=i,typeof i=="function")Cm(i)?(y=ba(i,y),l.tag=1,l=h0(null,l,i,y,f)):(l.tag=0,l=hp(null,l,i,y,f));else{if(i!=null){var N=i.$$typeof;if(N===k){l.tag=11,l=i0(null,l,i,y,f);break e}else if(N===D){l.tag=14,l=a0(null,l,i,y,f);break e}}throw l=B(i)||i,Error(r(306,l,""))}}return l;case 0:return hp(i,l,l.type,l.pendingProps,f);case 1:return y=l.type,N=ba(y,l.pendingProps),h0(i,l,y,N,f);case 3:e:{if(P(l,l.stateNode.containerInfo),i===null)throw Error(r(387));y=l.pendingProps;var L=l.memoizedState;N=L.element,$m(i,l),Yl(l,y,null,f);var K=l.memoizedState;if(y=K.cache,vi(l,jn,y),y!==L.cache&&Rm(l,[jn],f,!0),Kl(),y=K.element,L.isDehydrated)if(L={element:y,isDehydrated:!1,cache:K.cache},l.updateQueue.baseState=L,l.memoizedState=L,l.flags&256){l=f0(i,l,y,f);break e}else if(y!==N){N=Br(Error(r(424)),l),Fl(N),l=f0(i,l,y,f);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(sn=Ur(i.firstChild),Vn=l,At=!0,yi=null,Hr=!0,f=l_(l,null,y,f),l.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling}else{if(da(),y===N){l=Vs(i,l,f);break e}Wn(i,l,y,f)}l=l.child}return l;case 26:return ld(i,l),i===null?(f=NS(l.type,null,l.pendingProps,null))?l.memoizedState=f:At||(f=l.type,i=l.pendingProps,y=kd(Z.current).createElement(f),y[$e]=l,y[Qe]=i,qn(y,f,i),$n(y),l.stateNode=y):l.memoizedState=NS(l.type,i.memoizedProps,l.pendingProps,i.memoizedState),null;case 27:return se(l),i===null&&At&&(y=l.stateNode=kS(l.type,l.pendingProps,Z.current),Vn=l,Hr=!0,N=sn,Ri(l.type)?(Qp=N,sn=Ur(y.firstChild)):sn=N),Wn(i,l,l.pendingProps.children,f),ld(i,l),i===null&&(l.flags|=4194304),l.child;case 5:return i===null&&At&&((N=y=sn)&&(y=UL(y,l.type,l.pendingProps,Hr),y!==null?(l.stateNode=y,Vn=l,sn=Ur(y.firstChild),Hr=!1,N=!0):N=!1),N||bi(l)),se(l),N=l.type,L=l.pendingProps,K=i!==null?i.memoizedProps:null,y=L.children,qp(N,L)?y=null:K!==null&&qp(N,K)&&(l.flags|=32),l.memoizedState!==null&&(N=Wm(i,l,sL,null,null,f),pc._currentValue=N),ld(i,l),Wn(i,l,y,f),l.child;case 6:return i===null&&At&&((i=f=sn)&&(f=VL(f,l.pendingProps,Hr),f!==null?(l.stateNode=f,Vn=l,sn=null,i=!0):i=!1),i||bi(l)),null;case 13:return m0(i,l,f);case 4:return P(l,l.stateNode.containerInfo),y=l.pendingProps,i===null?l.child=xa(l,null,y,f):Wn(i,l,y,f),l.child;case 11:return i0(i,l,l.type,l.pendingProps,f);case 7:return Wn(i,l,l.pendingProps,f),l.child;case 8:return Wn(i,l,l.pendingProps.children,f),l.child;case 12:return Wn(i,l,l.pendingProps.children,f),l.child;case 10:return y=l.pendingProps,vi(l,l.type,y.value),Wn(i,l,y.children,f),l.child;case 9:return N=l.type._context,y=l.pendingProps.children,fa(l),N=Gn(N),y=y(N),l.flags|=1,Wn(i,l,y,f),l.child;case 14:return a0(i,l,l.type,l.pendingProps,f);case 15:return o0(i,l,l.type,l.pendingProps,f);case 19:return g0(i,l,f);case 31:return hL(i,l,f);case 22:return l0(i,l,f,l.pendingProps);case 24:return fa(l),y=Gn(jn),i===null?(N=Mm(),N===null&&(N=Jt,L=Om(),N.pooledCache=L,L.refCount++,L!==null&&(N.pooledCacheLanes|=f),N=L),l.memoizedState={parent:y,cache:N},Bm(l),vi(l,jn,N)):((i.lanes&f)!==0&&($m(i,l),Yl(l,null,null,f),Kl()),N=i.memoizedState,L=l.memoizedState,N.parent!==y?(N={parent:y,cache:y},l.memoizedState=N,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=N),vi(l,jn,y)):(y=L.cache,vi(l,jn,y),y!==N.cache&&Rm(l,[jn],f,!0))),Wn(i,l,l.pendingProps.children,f),l.child;case 29:throw l.pendingProps}throw Error(r(156,l.tag))}function Gs(i){i.flags|=4}function vp(i,l,f,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(V0())i.flags|=8192;else throw ga=qu,Pm}else i.flags&=-16777217}function y0(i,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!RS(l))if(V0())i.flags|=8192;else throw ga=qu,Pm}function ud(i,l){l!==null&&(i.flags|=4),i.flags&16384&&(l=i.tag!==22?dn():536870912,i.lanes|=l,Do|=l)}function tc(i,l){if(!At)switch(i.tailMode){case"hidden":l=i.tail;for(var f=null;l!==null;)l.alternate!==null&&(f=l),l=l.sibling;f===null?i.tail=null:f.sibling=null;break;case"collapsed":f=i.tail;for(var y=null;f!==null;)f.alternate!==null&&(y=f),f=f.sibling;y===null?l||i.tail===null?i.tail=null:i.tail.sibling=null:y.sibling=null}}function an(i){var l=i.alternate!==null&&i.alternate.child===i.child,f=0,y=0;if(l)for(var N=i.child;N!==null;)f|=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;)f|=N.lanes|N.childLanes,y|=N.subtreeFlags,y|=N.flags,N.return=i,N=N.sibling;return i.subtreeFlags|=y,i.childLanes=f,l}function mL(i,l,f){var y=l.pendingProps;switch(Nm(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return an(l),null;case 1:return an(l),null;case 3:return f=l.stateNode,y=null,i!==null&&(y=i.memoizedState.cache),l.memoizedState.cache!==y&&(l.flags|=2048),Hs(jn),te(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(i===null||i.child===null)&&(bo(l)?Gs(l):i===null||i.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Am())),an(l),null;case 26:var N=l.type,L=l.memoizedState;return i===null?(Gs(l),L!==null?(an(l),y0(l,L)):(an(l),vp(l,N,null,y,f))):L?L!==i.memoizedState?(Gs(l),an(l),y0(l,L)):(an(l),l.flags&=-16777217):(i=i.memoizedProps,i!==y&&Gs(l),an(l),vp(l,N,i,y,f)),null;case 27:if(re(l),f=Z.current,N=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==y&&Gs(l);else{if(!y){if(l.stateNode===null)throw Error(r(166));return an(l),null}i=Y.current,bo(l)?Jv(l):(i=kS(N,y,f),l.stateNode=i,Gs(l))}return an(l),null;case 5:if(re(l),N=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==y&&Gs(l);else{if(!y){if(l.stateNode===null)throw Error(r(166));return an(l),null}if(L=Y.current,bo(l))Jv(l);else{var K=kd(Z.current);switch(L){case 1:L=K.createElementNS("http://www.w3.org/2000/svg",N);break;case 2:L=K.createElementNS("http://www.w3.org/1998/Math/MathML",N);break;default:switch(N){case"svg":L=K.createElementNS("http://www.w3.org/2000/svg",N);break;case"math":L=K.createElementNS("http://www.w3.org/1998/Math/MathML",N);break;case"script":L=K.createElement("div"),L.innerHTML="<script><\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof y.is=="string"?K.createElement("select",{is:y.is}):K.createElement("select"),y.multiple?L.multiple=!0:y.size&&(L.size=y.size);break;default:L=typeof y.is=="string"?K.createElement(N,{is:y.is}):K.createElement(N)}}L[$e]=l,L[Qe]=y;e:for(K=l.child;K!==null;){if(K.tag===5||K.tag===6)L.appendChild(K.stateNode);else if(K.tag!==4&&K.tag!==27&&K.child!==null){K.child.return=K,K=K.child;continue}if(K===l)break e;for(;K.sibling===null;){if(K.return===null||K.return===l)break e;K=K.return}K.sibling.return=K.return,K=K.sibling}l.stateNode=L;e:switch(qn(L,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&&Gs(l)}}return an(l),vp(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,f),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==y&&Gs(l);else{if(typeof y!="string"&&l.stateNode===null)throw Error(r(166));if(i=Z.current,bo(l)){if(i=l.stateNode,f=l.memoizedProps,y=null,N=Vn,N!==null)switch(N.tag){case 27:case 5:y=N.memoizedProps}i[$e]=l,i=!!(i.nodeValue===f||y!==null&&y.suppressHydrationWarning===!0||mS(i.nodeValue,f)),i||bi(l,!0)}else i=kd(i).createTextNode(y),i[$e]=l,l.stateNode=i}return an(l),null;case 31:if(f=l.memoizedState,i===null||i.memoizedState!==null){if(y=bo(l),f!==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[$e]=l}else da(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;an(l),i=!1}else f=Am(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=f),i=!0;if(!i)return l.flags&256?(Cr(l),l):(Cr(l),null);if((l.flags&128)!==0)throw Error(r(558))}return an(l),null;case 13:if(y=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(N=bo(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[$e]=l}else da(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;an(l),N=!1}else N=Am(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=N),N=!0;if(!N)return l.flags&256?(Cr(l),l):(Cr(l),null)}return Cr(l),(l.flags&128)!==0?(l.lanes=f,l):(f=y!==null,i=i!==null&&i.memoizedState!==null,f&&(y=l.child,N=null,y.alternate!==null&&y.alternate.memoizedState!==null&&y.alternate.memoizedState.cachePool!==null&&(N=y.alternate.memoizedState.cachePool.pool),L=null,y.memoizedState!==null&&y.memoizedState.cachePool!==null&&(L=y.memoizedState.cachePool.pool),L!==N&&(y.flags|=2048)),f!==i&&f&&(l.child.flags|=8192),ud(l,l.updateQueue),an(l),null);case 4:return te(),i===null&&Fp(l.stateNode.containerInfo),an(l),null;case 10:return Hs(l.type),an(l),null;case 19:if(V(yn),y=l.memoizedState,y===null)return an(l),null;if(N=(l.flags&128)!==0,L=y.rendering,L===null)if(N)tc(y,!1);else{if(pn!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(L=Ju(i),L!==null){for(l.flags|=128,tc(y,!1),i=L.updateQueue,l.updateQueue=i,ud(l,i),l.subtreeFlags=0,i=f,f=l.child;f!==null;)Wv(f,i),f=f.sibling;return z(yn,yn.current&1|2),At&&$s(l,y.treeForkCount),l.child}i=i.sibling}y.tail!==null&&Pe()>pd&&(l.flags|=128,N=!0,tc(y,!1),l.lanes=4194304)}else{if(!N)if(i=Ju(L),i!==null){if(l.flags|=128,N=!0,i=i.updateQueue,l.updateQueue=i,ud(l,i),tc(y,!0),y.tail===null&&y.tailMode==="hidden"&&!L.alternate&&!At)return an(l),null}else 2*Pe()-y.renderingStartTime>pd&&f!==536870912&&(l.flags|=128,N=!0,tc(y,!1),l.lanes=4194304);y.isBackwards?(L.sibling=l.child,l.child=L):(i=y.last,i!==null?i.sibling=L:l.child=L,y.last=L)}return y.tail!==null?(i=y.tail,y.rendering=i,y.tail=i.sibling,y.renderingStartTime=Pe(),i.sibling=null,f=yn.current,z(yn,N?f&1|2:f&1),At&&$s(l,y.treeForkCount),i):(an(l),null);case 22:case 23:return Cr(l),Um(),y=l.memoizedState!==null,i!==null?i.memoizedState!==null!==y&&(l.flags|=8192):y&&(l.flags|=8192),y?(f&536870912)!==0&&(l.flags&128)===0&&(an(l),l.subtreeFlags&6&&(l.flags|=8192)):an(l),f=l.updateQueue,f!==null&&ud(l,f.retryQueue),f=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),y=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(y=l.memoizedState.cachePool.pool),y!==f&&(l.flags|=2048),i!==null&&V(ma),null;case 24:return f=null,i!==null&&(f=i.memoizedState.cache),l.memoizedState.cache!==f&&(l.flags|=2048),Hs(jn),an(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function pL(i,l){switch(Nm(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return Hs(jn),te(),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(Cr(l),l.alternate===null)throw Error(r(340));da()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(Cr(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));da()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return V(yn),null;case 4:return te(),null;case 10:return Hs(l.type),null;case 22:case 23:return Cr(l),Um(),i!==null&&V(ma),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return Hs(jn),null;case 25:return null;default:return null}}function b0(i,l){switch(Nm(l),l.tag){case 3:Hs(jn),te();break;case 26:case 27:case 5:re(l);break;case 4:te();break;case 31:l.memoizedState!==null&&Cr(l);break;case 13:Cr(l);break;case 19:V(yn);break;case 10:Hs(l.type);break;case 22:case 23:Cr(l),Um(),i!==null&&V(ma);break;case 24:Hs(jn)}}function nc(i,l){try{var f=l.updateQueue,y=f!==null?f.lastEffect:null;if(y!==null){var N=y.next;f=N;do{if((f.tag&i)===i){y=void 0;var L=f.create,K=f.inst;y=L(),K.destroy=y}f=f.next}while(f!==N)}}catch(ee){Vt(l,l.return,ee)}}function ji(i,l,f){try{var y=l.updateQueue,N=y!==null?y.lastEffect:null;if(N!==null){var L=N.next;y=L;do{if((y.tag&i)===i){var K=y.inst,ee=K.destroy;if(ee!==void 0){K.destroy=void 0,N=l;var le=f,we=ee;try{we()}catch(Oe){Vt(N,le,Oe)}}}y=y.next}while(y!==L)}}catch(Oe){Vt(l,l.return,Oe)}}function v0(i){var l=i.updateQueue;if(l!==null){var f=i.stateNode;try{u_(l,f)}catch(y){Vt(i,i.return,y)}}}function _0(i,l,f){f.props=ba(i.type,i.memoizedProps),f.state=i.memoizedState;try{f.componentWillUnmount()}catch(y){Vt(i,l,y)}}function rc(i,l){try{var f=i.ref;if(f!==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 f=="function"?i.refCleanup=f(y):f.current=y}}catch(N){Vt(i,l,N)}}function ys(i,l){var f=i.ref,y=i.refCleanup;if(f!==null)if(typeof y=="function")try{y()}catch(N){Vt(i,l,N)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof f=="function")try{f(null)}catch(N){Vt(i,l,N)}else f.current=null}function S0(i){var l=i.type,f=i.memoizedProps,y=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":f.autoFocus&&y.focus();break e;case"img":f.src?y.src=f.src:f.srcSet&&(y.srcset=f.srcSet)}}catch(N){Vt(i,i.return,N)}}function _p(i,l,f){try{var y=i.stateNode;PL(y,i.type,f,l),y[Qe]=l}catch(N){Vt(i,i.return,N)}}function w0(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Ri(i.type)||i.tag===4}function Sp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||w0(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&&Ri(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 wp(i,l,f){var y=i.tag;if(y===5||y===6)i=i.stateNode,l?(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f).insertBefore(i,l):(l=f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,l.appendChild(i),f=f._reactRootContainer,f!=null||l.onclick!==null||(l.onclick=Ms));else if(y!==4&&(y===27&&Ri(i.type)&&(f=i.stateNode,l=null),i=i.child,i!==null))for(wp(i,l,f),i=i.sibling;i!==null;)wp(i,l,f),i=i.sibling}function dd(i,l,f){var y=i.tag;if(y===5||y===6)i=i.stateNode,l?f.insertBefore(i,l):f.appendChild(i);else if(y!==4&&(y===27&&Ri(i.type)&&(f=i.stateNode),i=i.child,i!==null))for(dd(i,l,f),i=i.sibling;i!==null;)dd(i,l,f),i=i.sibling}function C0(i){var l=i.stateNode,f=i.memoizedProps;try{for(var y=i.type,N=l.attributes;N.length;)l.removeAttributeNode(N[0]);qn(l,y,f),l[$e]=i,l[Qe]=f}catch(L){Vt(i,i.return,L)}}var Ws=!1,Tn=!1,Cp=!1,k0=typeof WeakSet=="function"?WeakSet:Set,zn=null;function gL(i,l){if(i=i.containerInfo,Gp=Dd,i=Pv(i),xm(i)){if("selectionStart"in i)var f={start:i.selectionStart,end:i.selectionEnd};else e:{f=(f=i.ownerDocument)&&f.defaultView||window;var y=f.getSelection&&f.getSelection();if(y&&y.rangeCount!==0){f=y.anchorNode;var N=y.anchorOffset,L=y.focusNode;y=y.focusOffset;try{f.nodeType,L.nodeType}catch{f=null;break e}var K=0,ee=-1,le=-1,we=0,Oe=0,ze=i,ke=null;t:for(;;){for(var Ee;ze!==f||N!==0&&ze.nodeType!==3||(ee=K+N),ze!==L||y!==0&&ze.nodeType!==3||(le=K+y),ze.nodeType===3&&(K+=ze.nodeValue.length),(Ee=ze.firstChild)!==null;)ke=ze,ze=Ee;for(;;){if(ze===i)break t;if(ke===f&&++we===N&&(ee=K),ke===L&&++Oe===y&&(le=K),(Ee=ze.nextSibling)!==null)break;ze=ke,ke=ze.parentNode}ze=Ee}f=ee===-1||le===-1?null:{start:ee,end:le}}else f=null}f=f||{start:0,end:0}}else f=null;for(Wp={focusedElem:i,selectionRange:f},Dd=!1,zn=l;zn!==null;)if(l=zn,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,zn=i;else for(;zn!==null;){switch(l=zn,L=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(f=0;f<i.length;f++)N=i[f],N.ref.impl=N.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&L!==null){i=void 0,f=l,N=L.memoizedProps,L=L.memoizedState,y=f.stateNode;try{var st=ba(f.type,N);i=y.getSnapshotBeforeUpdate(st,L),y.__reactInternalSnapshotBeforeUpdate=i}catch(dt){Vt(f,f.return,dt)}}break;case 3:if((i&1024)!==0){if(i=l.stateNode.containerInfo,f=i.nodeType,f===9)Yp(i);else if(f===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Yp(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,zn=i;break}zn=l.return}}function j0(i,l,f){var y=f.flags;switch(f.tag){case 0:case 11:case 15:Ks(i,f),y&4&&nc(5,f);break;case 1:if(Ks(i,f),y&4)if(i=f.stateNode,l===null)try{i.componentDidMount()}catch(K){Vt(f,f.return,K)}else{var N=ba(f.type,l.memoizedProps);l=l.memoizedState;try{i.componentDidUpdate(N,l,i.__reactInternalSnapshotBeforeUpdate)}catch(K){Vt(f,f.return,K)}}y&64&&v0(f),y&512&&rc(f,f.return);break;case 3:if(Ks(i,f),y&64&&(i=f.updateQueue,i!==null)){if(l=null,f.child!==null)switch(f.child.tag){case 27:case 5:l=f.child.stateNode;break;case 1:l=f.child.stateNode}try{u_(i,l)}catch(K){Vt(f,f.return,K)}}break;case 27:l===null&&y&4&&C0(f);case 26:case 5:Ks(i,f),l===null&&y&4&&S0(f),y&512&&rc(f,f.return);break;case 12:Ks(i,f);break;case 31:Ks(i,f),y&4&&T0(i,f);break;case 13:Ks(i,f),y&4&&A0(i,f),y&64&&(i=f.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(f=kL.bind(null,f),GL(i,f))));break;case 22:if(y=f.memoizedState!==null||Ws,!y){l=l!==null&&l.memoizedState!==null||Tn,N=Ws;var L=Tn;Ws=y,(Tn=l)&&!L?Ys(i,f,(f.subtreeFlags&8772)!==0):Ks(i,f),Ws=N,Tn=L}break;case 30:break;default:Ks(i,f)}}function E0(i){var l=i.alternate;l!==null&&(i.alternate=null,E0(l)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(l=i.stateNode,l!==null&&no(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 un=null,ur=!1;function qs(i,l,f){for(f=f.child;f!==null;)N0(i,l,f),f=f.sibling}function N0(i,l,f){if(it&&typeof it.onCommitFiberUnmount=="function")try{it.onCommitFiberUnmount(et,f)}catch{}switch(f.tag){case 26:Tn||ys(f,l),qs(i,l,f),f.memoizedState?f.memoizedState.count--:f.stateNode&&(f=f.stateNode,f.parentNode.removeChild(f));break;case 27:Tn||ys(f,l);var y=un,N=ur;Ri(f.type)&&(un=f.stateNode,ur=!1),qs(i,l,f),hc(f.stateNode),un=y,ur=N;break;case 5:Tn||ys(f,l);case 6:if(y=un,N=ur,un=null,qs(i,l,f),un=y,ur=N,un!==null)if(ur)try{(un.nodeType===9?un.body:un.nodeName==="HTML"?un.ownerDocument.body:un).removeChild(f.stateNode)}catch(L){Vt(f,l,L)}else try{un.removeChild(f.stateNode)}catch(L){Vt(f,l,L)}break;case 18:un!==null&&(ur?(i=un,vS(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,f.stateNode),zo(i)):vS(un,f.stateNode));break;case 4:y=un,N=ur,un=f.stateNode.containerInfo,ur=!0,qs(i,l,f),un=y,ur=N;break;case 0:case 11:case 14:case 15:ji(2,f,l),Tn||ji(4,f,l),qs(i,l,f);break;case 1:Tn||(ys(f,l),y=f.stateNode,typeof y.componentWillUnmount=="function"&&_0(f,l,y)),qs(i,l,f);break;case 21:qs(i,l,f);break;case 22:Tn=(y=Tn)||f.memoizedState!==null,qs(i,l,f),Tn=y;break;default:qs(i,l,f)}}function T0(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{zo(i)}catch(f){Vt(l,l.return,f)}}}function A0(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{zo(i)}catch(f){Vt(l,l.return,f)}}function xL(i){switch(i.tag){case 31:case 13:case 19:var l=i.stateNode;return l===null&&(l=i.stateNode=new k0),l;case 22:return i=i.stateNode,l=i._retryCache,l===null&&(l=i._retryCache=new k0),l;default:throw Error(r(435,i.tag))}}function hd(i,l){var f=xL(i);l.forEach(function(y){if(!f.has(y)){f.add(y);var N=jL.bind(null,i,y);y.then(N,N)}})}function dr(i,l){var f=l.deletions;if(f!==null)for(var y=0;y<f.length;y++){var N=f[y],L=i,K=l,ee=K;e:for(;ee!==null;){switch(ee.tag){case 27:if(Ri(ee.type)){un=ee.stateNode,ur=!1;break e}break;case 5:un=ee.stateNode,ur=!1;break e;case 3:case 4:un=ee.stateNode.containerInfo,ur=!0;break e}ee=ee.return}if(un===null)throw Error(r(160));N0(L,K,N),un=null,ur=!1,L=N.alternate,L!==null&&(L.return=null),N.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)L0(l,i),l=l.sibling}var ns=null;function L0(i,l){var f=i.alternate,y=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:dr(l,i),hr(i),y&4&&(ji(3,i,i.return),nc(3,i),ji(5,i,i.return));break;case 1:dr(l,i),hr(i),y&512&&(Tn||f===null||ys(f,f.return)),y&64&&Ws&&(i=i.updateQueue,i!==null&&(y=i.callbacks,y!==null&&(f=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=f===null?y:f.concat(y))));break;case 26:var N=ns;if(dr(l,i),hr(i),y&512&&(Tn||f===null||ys(f,f.return)),y&4){var L=f!==null?f.memoizedState:null;if(y=i.memoizedState,f===null)if(y===null)if(i.stateNode===null){e:{y=i.type,f=i.memoizedProps,N=N.ownerDocument||N;t:switch(y){case"title":L=N.getElementsByTagName("title")[0],(!L||L[kn]||L[$e]||L.namespaceURI==="http://www.w3.org/2000/svg"||L.hasAttribute("itemprop"))&&(L=N.createElement(y),N.head.insertBefore(L,N.querySelector("head > title"))),qn(L,y,f),L[$e]=i,$n(L),y=L;break e;case"link":var K=LS("link","href",N).get(y+(f.href||""));if(K){for(var ee=0;ee<K.length;ee++)if(L=K[ee],L.getAttribute("href")===(f.href==null||f.href===""?null:f.href)&&L.getAttribute("rel")===(f.rel==null?null:f.rel)&&L.getAttribute("title")===(f.title==null?null:f.title)&&L.getAttribute("crossorigin")===(f.crossOrigin==null?null:f.crossOrigin)){K.splice(ee,1);break t}}L=N.createElement(y),qn(L,y,f),N.head.appendChild(L);break;case"meta":if(K=LS("meta","content",N).get(y+(f.content||""))){for(ee=0;ee<K.length;ee++)if(L=K[ee],L.getAttribute("content")===(f.content==null?null:""+f.content)&&L.getAttribute("name")===(f.name==null?null:f.name)&&L.getAttribute("property")===(f.property==null?null:f.property)&&L.getAttribute("http-equiv")===(f.httpEquiv==null?null:f.httpEquiv)&&L.getAttribute("charset")===(f.charSet==null?null:f.charSet)){K.splice(ee,1);break t}}L=N.createElement(y),qn(L,y,f),N.head.appendChild(L);break;default:throw Error(r(468,y))}L[$e]=i,$n(L),y=L}i.stateNode=y}else DS(N,i.type,i.stateNode);else i.stateNode=AS(N,y,i.memoizedProps);else L!==y?(L===null?f.stateNode!==null&&(f=f.stateNode,f.parentNode.removeChild(f)):L.count--,y===null?DS(N,i.type,i.stateNode):AS(N,y,i.memoizedProps)):y===null&&i.stateNode!==null&&_p(i,i.memoizedProps,f.memoizedProps)}break;case 27:dr(l,i),hr(i),y&512&&(Tn||f===null||ys(f,f.return)),f!==null&&y&4&&_p(i,i.memoizedProps,f.memoizedProps);break;case 5:if(dr(l,i),hr(i),y&512&&(Tn||f===null||ys(f,f.return)),i.flags&32){N=i.stateNode;try{lo(N,"")}catch(st){Vt(i,i.return,st)}}y&4&&i.stateNode!=null&&(N=i.memoizedProps,_p(i,N,f!==null?f.memoizedProps:N)),y&1024&&(Cp=!0);break;case 6:if(dr(l,i),hr(i),y&4){if(i.stateNode===null)throw Error(r(162));y=i.memoizedProps,f=i.stateNode;try{f.nodeValue=y}catch(st){Vt(i,i.return,st)}}break;case 3:if(Nd=null,N=ns,ns=jd(l.containerInfo),dr(l,i),ns=N,hr(i),y&4&&f!==null&&f.memoizedState.isDehydrated)try{zo(l.containerInfo)}catch(st){Vt(i,i.return,st)}Cp&&(Cp=!1,D0(i));break;case 4:y=ns,ns=jd(i.stateNode.containerInfo),dr(l,i),hr(i),ns=y;break;case 12:dr(l,i),hr(i);break;case 31:dr(l,i),hr(i),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,hd(i,y)));break;case 13:dr(l,i),hr(i),i.child.flags&8192&&i.memoizedState!==null!=(f!==null&&f.memoizedState!==null)&&(md=Pe()),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,hd(i,y)));break;case 22:N=i.memoizedState!==null;var le=f!==null&&f.memoizedState!==null,we=Ws,Oe=Tn;if(Ws=we||N,Tn=Oe||le,dr(l,i),Tn=Oe,Ws=we,hr(i),y&8192)e:for(l=i.stateNode,l._visibility=N?l._visibility&-2:l._visibility|1,N&&(f===null||le||Ws||Tn||va(i)),f=null,l=i;;){if(l.tag===5||l.tag===26){if(f===null){le=f=l;try{if(L=le.stateNode,N)K=L.style,typeof K.setProperty=="function"?K.setProperty("display","none","important"):K.display="none";else{ee=le.stateNode;var ze=le.memoizedProps.style,ke=ze!=null&&ze.hasOwnProperty("display")?ze.display:null;ee.style.display=ke==null||typeof ke=="boolean"?"":(""+ke).trim()}}catch(st){Vt(le,le.return,st)}}}else if(l.tag===6){if(f===null){le=l;try{le.stateNode.nodeValue=N?"":le.memoizedProps}catch(st){Vt(le,le.return,st)}}}else if(l.tag===18){if(f===null){le=l;try{var Ee=le.stateNode;N?_S(Ee,!0):_S(le.stateNode,!1)}catch(st){Vt(le,le.return,st)}}}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;f===l&&(f=null),l=l.return}f===l&&(f=null),l.sibling.return=l.return,l=l.sibling}y&4&&(y=i.updateQueue,y!==null&&(f=y.retryQueue,f!==null&&(y.retryQueue=null,hd(i,f))));break;case 19:dr(l,i),hr(i),y&4&&(y=i.updateQueue,y!==null&&(i.updateQueue=null,hd(i,y)));break;case 30:break;case 21:break;default:dr(l,i),hr(i)}}function hr(i){var l=i.flags;if(l&2){try{for(var f,y=i.return;y!==null;){if(w0(y)){f=y;break}y=y.return}if(f==null)throw Error(r(160));switch(f.tag){case 27:var N=f.stateNode,L=Sp(i);dd(i,L,N);break;case 5:var K=f.stateNode;f.flags&32&&(lo(K,""),f.flags&=-33);var ee=Sp(i);dd(i,ee,K);break;case 3:case 4:var le=f.stateNode.containerInfo,we=Sp(i);wp(i,we,le);break;default:throw Error(r(161))}}catch(Oe){Vt(i,i.return,Oe)}i.flags&=-3}l&4096&&(i.flags&=-4097)}function D0(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var l=i;D0(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),i=i.sibling}}function Ks(i,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)j0(i,l.alternate,l),l=l.sibling}function va(i){for(i=i.child;i!==null;){var l=i;switch(l.tag){case 0:case 11:case 14:case 15:ji(4,l,l.return),va(l);break;case 1:ys(l,l.return);var f=l.stateNode;typeof f.componentWillUnmount=="function"&&_0(l,l.return,f),va(l);break;case 27:hc(l.stateNode);case 26:case 5:ys(l,l.return),va(l);break;case 22:l.memoizedState===null&&va(l);break;case 30:va(l);break;default:va(l)}i=i.sibling}}function Ys(i,l,f){for(f=f&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var y=l.alternate,N=i,L=l,K=L.flags;switch(L.tag){case 0:case 11:case 15:Ys(N,L,f),nc(4,L);break;case 1:if(Ys(N,L,f),y=L,N=y.stateNode,typeof N.componentDidMount=="function")try{N.componentDidMount()}catch(we){Vt(y,y.return,we)}if(y=L,N=y.updateQueue,N!==null){var ee=y.stateNode;try{var le=N.shared.hiddenCallbacks;if(le!==null)for(N.shared.hiddenCallbacks=null,N=0;N<le.length;N++)c_(le[N],ee)}catch(we){Vt(y,y.return,we)}}f&&K&64&&v0(L),rc(L,L.return);break;case 27:C0(L);case 26:case 5:Ys(N,L,f),f&&y===null&&K&4&&S0(L),rc(L,L.return);break;case 12:Ys(N,L,f);break;case 31:Ys(N,L,f),f&&K&4&&T0(N,L);break;case 13:Ys(N,L,f),f&&K&4&&A0(N,L);break;case 22:L.memoizedState===null&&Ys(N,L,f),rc(L,L.return);break;case 30:break;default:Ys(N,L,f)}l=l.sibling}}function kp(i,l){var f=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),i=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(i=l.memoizedState.cachePool.pool),i!==f&&(i!=null&&i.refCount++,f!=null&&Ul(f))}function jp(i,l){i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&Ul(i))}function rs(i,l,f,y){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)R0(i,l,f,y),l=l.sibling}function R0(i,l,f,y){var N=l.flags;switch(l.tag){case 0:case 11:case 15:rs(i,l,f,y),N&2048&&nc(9,l);break;case 1:rs(i,l,f,y);break;case 3:rs(i,l,f,y),N&2048&&(i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&Ul(i)));break;case 12:if(N&2048){rs(i,l,f,y),i=l.stateNode;try{var L=l.memoizedProps,K=L.id,ee=L.onPostCommit;typeof ee=="function"&&ee(K,l.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(le){Vt(l,l.return,le)}}else rs(i,l,f,y);break;case 31:rs(i,l,f,y);break;case 13:rs(i,l,f,y);break;case 23:break;case 22:L=l.stateNode,K=l.alternate,l.memoizedState!==null?L._visibility&2?rs(i,l,f,y):sc(i,l):L._visibility&2?rs(i,l,f,y):(L._visibility|=2,To(i,l,f,y,(l.subtreeFlags&10256)!==0||!1)),N&2048&&kp(K,l);break;case 24:rs(i,l,f,y),N&2048&&jp(l.alternate,l);break;default:rs(i,l,f,y)}}function To(i,l,f,y,N){for(N=N&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var L=i,K=l,ee=f,le=y,we=K.flags;switch(K.tag){case 0:case 11:case 15:To(L,K,ee,le,N),nc(8,K);break;case 23:break;case 22:var Oe=K.stateNode;K.memoizedState!==null?Oe._visibility&2?To(L,K,ee,le,N):sc(L,K):(Oe._visibility|=2,To(L,K,ee,le,N)),N&&we&2048&&kp(K.alternate,K);break;case 24:To(L,K,ee,le,N),N&&we&2048&&jp(K.alternate,K);break;default:To(L,K,ee,le,N)}l=l.sibling}}function sc(i,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var f=i,y=l,N=y.flags;switch(y.tag){case 22:sc(f,y),N&2048&&kp(y.alternate,y);break;case 24:sc(f,y),N&2048&&jp(y.alternate,y);break;default:sc(f,y)}l=l.sibling}}var ic=8192;function Ao(i,l,f){if(i.subtreeFlags&ic)for(i=i.child;i!==null;)O0(i,l,f),i=i.sibling}function O0(i,l,f){switch(i.tag){case 26:Ao(i,l,f),i.flags&ic&&i.memoizedState!==null&&rD(f,ns,i.memoizedState,i.memoizedProps);break;case 5:Ao(i,l,f);break;case 3:case 4:var y=ns;ns=jd(i.stateNode.containerInfo),Ao(i,l,f),ns=y;break;case 22:i.memoizedState===null&&(y=i.alternate,y!==null&&y.memoizedState!==null?(y=ic,ic=16777216,Ao(i,l,f),ic=y):Ao(i,l,f));break;default:Ao(i,l,f)}}function I0(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 ac(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var f=0;f<l.length;f++){var y=l[f];zn=y,P0(y,i)}I0(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)M0(i),i=i.sibling}function M0(i){switch(i.tag){case 0:case 11:case 15:ac(i),i.flags&2048&&ji(9,i,i.return);break;case 3:ac(i);break;case 12:ac(i);break;case 22:var l=i.stateNode;i.memoizedState!==null&&l._visibility&2&&(i.return===null||i.return.tag!==13)?(l._visibility&=-3,fd(i)):ac(i);break;default:ac(i)}}function fd(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var f=0;f<l.length;f++){var y=l[f];zn=y,P0(y,i)}I0(i)}for(i=i.child;i!==null;){switch(l=i,l.tag){case 0:case 11:case 15:ji(8,l,l.return),fd(l);break;case 22:f=l.stateNode,f._visibility&2&&(f._visibility&=-3,fd(l));break;default:fd(l)}i=i.sibling}}function P0(i,l){for(;zn!==null;){var f=zn;switch(f.tag){case 0:case 11:case 15:ji(8,f,l);break;case 23:case 22:if(f.memoizedState!==null&&f.memoizedState.cachePool!==null){var y=f.memoizedState.cachePool.pool;y!=null&&y.refCount++}break;case 24:Ul(f.memoizedState.cache)}if(y=f.child,y!==null)y.return=f,zn=y;else e:for(f=i;zn!==null;){y=zn;var N=y.sibling,L=y.return;if(E0(y),y===f){zn=null;break e}if(N!==null){N.return=L,zn=N;break e}zn=L}}}var yL={getCacheForType:function(i){var l=Gn(jn),f=l.data.get(i);return f===void 0&&(f=i(),l.data.set(i,f)),f},cacheSignal:function(){return Gn(jn).controller.signal}},bL=typeof WeakMap=="function"?WeakMap:Map,$t=0,Jt=null,kt=null,Nt=0,Ut=0,kr=null,Ei=!1,Lo=!1,Ep=!1,Xs=0,pn=0,Ni=0,_a=0,Np=0,jr=0,Do=0,oc=null,fr=null,Tp=!1,md=0,B0=0,pd=1/0,gd=null,Ti=null,On=0,Ai=null,Ro=null,Js=0,Ap=0,Lp=null,$0=null,lc=0,Dp=null;function Er(){return($t&2)!==0&&Nt!==0?Nt&-Nt:q.T!==null?Bp():rn()}function z0(){if(jr===0)if((Nt&536870912)===0||At){var i=Ct;Ct<<=1,(Ct&3932160)===0&&(Ct=262144),jr=i}else jr=536870912;return i=wr.current,i!==null&&(i.flags|=32),jr}function mr(i,l,f){(i===Jt&&(Ut===2||Ut===9)||i.cancelPendingCommit!==null)&&(Oo(i,0),Li(i,Nt,jr,!1)),Ce(i,f),(($t&2)===0||i!==Jt)&&(i===Jt&&(($t&2)===0&&(_a|=f),pn===4&&Li(i,Nt,jr,!1)),bs(i))}function H0(i,l,f){if(($t&6)!==0)throw Error(r(327));var y=!f&&(l&127)===0&&(l&i.expiredLanes)===0||Dn(i,l),N=y?SL(i,l):Op(i,l,!0),L=y;do{if(N===0){Lo&&!y&&Li(i,l,0,!1);break}else{if(f=i.current.alternate,L&&!vL(f)){N=Op(i,l,!1),L=!1;continue}if(N===2){if(L=l,i.errorRecoveryDisabledLanes&L)var K=0;else K=i.pendingLanes&-536870913,K=K!==0?K:K&536870912?536870912:0;if(K!==0){l=K;e:{var ee=i;N=oc;var le=ee.current.memoizedState.isDehydrated;if(le&&(Oo(ee,K).flags|=256),K=Op(ee,K,!1),K!==2){if(Ep&&!le){ee.errorRecoveryDisabledLanes|=L,_a|=L,N=4;break e}L=fr,fr=N,L!==null&&(fr===null?fr=L:fr.push.apply(fr,L))}N=K}if(L=!1,N!==2)continue}}if(N===1){Oo(i,0),Li(i,l,0,!0);break}e:{switch(y=i,L=N,L){case 0:case 1:throw Error(r(345));case 4:if((l&4194048)!==l)break;case 6:Li(y,l,jr,!Ei);break e;case 2:fr=null;break;case 3:case 5:break;default:throw Error(r(329))}if((l&62914560)===l&&(N=md+300-Pe(),10<N)){if(Li(y,l,jr,!Ei),fn(y,0,!0)!==0)break e;Js=l,y.timeoutHandle=yS(F0.bind(null,y,f,fr,gd,Tp,l,jr,_a,Do,Ei,L,"Throttled",-0,0),N);break e}F0(y,f,fr,gd,Tp,l,jr,_a,Do,Ei,L,null,-0,0)}}break}while(!0);bs(i)}function F0(i,l,f,y,N,L,K,ee,le,we,Oe,ze,ke,Ee){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:Ms},O0(l,L,ze);var st=(L&62914560)===L?md-Pe():(L&4194048)===L?B0-Pe():0;if(st=sD(ze,st),st!==null){Js=L,i.cancelPendingCommit=st(X0.bind(null,i,l,L,f,y,N,K,ee,le,Oe,ze,null,ke,Ee)),Li(i,L,K,!we);return}}X0(i,l,L,f,y,N,K,ee,le)}function vL(i){for(var l=i;;){var f=l.tag;if((f===0||f===11||f===15)&&l.flags&16384&&(f=l.updateQueue,f!==null&&(f=f.stores,f!==null)))for(var y=0;y<f.length;y++){var N=f[y],L=N.getSnapshot;N=N.value;try{if(!_r(L(),N))return!1}catch{return!1}}if(f=l.child,l.subtreeFlags&16384&&f!==null)f.return=l,l=f;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 Li(i,l,f,y){l&=~Np,l&=~_a,i.suspendedLanes|=l,i.pingedLanes&=~l,y&&(i.warmLanes|=l),y=i.expirationTimes;for(var N=l;0<N;){var L=31-fe(N),K=1<<L;y[L]=-1,N&=~K}f!==0&&Je(i,f,l)}function xd(){return($t&6)===0?(cc(0),!1):!0}function Rp(){if(kt!==null){if(Ut===0)var i=kt.return;else i=kt,zs=ha=null,Ym(i),Co=null,Gl=0,i=kt;for(;i!==null;)b0(i.alternate,i),i=i.return;kt=null}}function Oo(i,l){var f=i.timeoutHandle;f!==-1&&(i.timeoutHandle=-1,zL(f)),f=i.cancelPendingCommit,f!==null&&(i.cancelPendingCommit=null,f()),Js=0,Rp(),Jt=i,kt=f=Bs(i.current,null),Nt=l,Ut=0,kr=null,Ei=!1,Lo=Dn(i,l),Ep=!1,Do=jr=Np=_a=Ni=pn=0,fr=oc=null,Tp=!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-fe(y),L=1<<N;l|=i[N],y&=~L}return Xs=l,Bu(),f}function U0(i,l){bt=null,q.H=Zl,l===wo||l===Wu?(l=i_(),Ut=3):l===Pm?(l=i_(),Ut=4):Ut=l===dp?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,kr=l,kt===null&&(pn=1,ad(i,Br(l,i.current)))}function V0(){var i=wr.current;return i===null?!0:(Nt&4194048)===Nt?Fr===null:(Nt&62914560)===Nt||(Nt&536870912)!==0?i===Fr:!1}function G0(){var i=q.H;return q.H=Zl,i===null?Zl:i}function W0(){var i=q.A;return q.A=yL,i}function yd(){pn=4,Ei||(Nt&4194048)!==Nt&&wr.current!==null||(Lo=!0),(Ni&134217727)===0&&(_a&134217727)===0||Jt===null||Li(Jt,Nt,jr,!1)}function Op(i,l,f){var y=$t;$t|=2;var N=G0(),L=W0();(Jt!==i||Nt!==l)&&(gd=null,Oo(i,l)),l=!1;var K=pn;e:do try{if(Ut!==0&&kt!==null){var ee=kt,le=kr;switch(Ut){case 8:Rp(),K=6;break e;case 3:case 2:case 9:case 6:wr.current===null&&(l=!0);var we=Ut;if(Ut=0,kr=null,Io(i,ee,le,we),f&&Lo){K=0;break e}break;default:we=Ut,Ut=0,kr=null,Io(i,ee,le,we)}}_L(),K=pn;break}catch(Oe){U0(i,Oe)}while(!0);return l&&i.shellSuspendCounter++,zs=ha=null,$t=y,q.H=N,q.A=L,kt===null&&(Jt=null,Nt=0,Bu()),K}function _L(){for(;kt!==null;)q0(kt)}function SL(i,l){var f=$t;$t|=2;var y=G0(),N=W0();Jt!==i||Nt!==l?(gd=null,pd=Pe()+500,Oo(i,l)):Lo=Dn(i,l);e:do try{if(Ut!==0&&kt!==null){l=kt;var L=kr;t:switch(Ut){case 1:Ut=0,kr=null,Io(i,l,L,1);break;case 2:case 9:if(r_(L)){Ut=0,kr=null,K0(l);break}l=function(){Ut!==2&&Ut!==9||Jt!==i||(Ut=7),bs(i)},L.then(l,l);break e;case 3:Ut=7;break e;case 4:Ut=5;break e;case 7:r_(L)?(Ut=0,kr=null,K0(l)):(Ut=0,kr=null,Io(i,l,L,7));break;case 5:var K=null;switch(kt.tag){case 26:K=kt.memoizedState;case 5:case 27:var ee=kt;if(K?RS(K):ee.stateNode.complete){Ut=0,kr=null;var le=ee.sibling;if(le!==null)kt=le;else{var we=ee.return;we!==null?(kt=we,bd(we)):kt=null}break t}}Ut=0,kr=null,Io(i,l,L,5);break;case 6:Ut=0,kr=null,Io(i,l,L,6);break;case 8:Rp(),pn=6;break e;default:throw Error(r(462))}}wL();break}catch(Oe){U0(i,Oe)}while(!0);return zs=ha=null,q.H=y,q.A=N,$t=f,kt!==null?0:(Jt=null,Nt=0,Bu(),pn)}function wL(){for(;kt!==null&&!de();)q0(kt)}function q0(i){var l=x0(i.alternate,i,Xs);i.memoizedProps=i.pendingProps,l===null?bd(i):kt=l}function K0(i){var l=i,f=l.alternate;switch(l.tag){case 15:case 0:l=d0(f,l,l.pendingProps,l.type,void 0,Nt);break;case 11:l=d0(f,l,l.pendingProps,l.type.render,l.ref,Nt);break;case 5:Ym(l);default:b0(f,l),l=kt=Wv(l,Xs),l=x0(f,l,Xs)}i.memoizedProps=i.pendingProps,l===null?bd(i):kt=l}function Io(i,l,f,y){zs=ha=null,Ym(l),Co=null,Gl=0;var N=l.return;try{if(dL(i,N,l,f,Nt)){pn=1,ad(i,Br(f,i.current)),kt=null;return}}catch(L){if(N!==null)throw kt=N,L;pn=1,ad(i,Br(f,i.current)),kt=null;return}l.flags&32768?(At||y===1?i=!0:Lo||(Nt&536870912)!==0?i=!1:(Ei=i=!0,(y===2||y===9||y===3||y===6)&&(y=wr.current,y!==null&&y.tag===13&&(y.flags|=16384))),Y0(l,i)):bd(l)}function bd(i){var l=i;do{if((l.flags&32768)!==0){Y0(l,Ei);return}i=l.return;var f=mL(l.alternate,l,Xs);if(f!==null){kt=f;return}if(l=l.sibling,l!==null){kt=l;return}kt=l=i}while(l!==null);pn===0&&(pn=5)}function Y0(i,l){do{var f=pL(i.alternate,i);if(f!==null){f.flags&=32767,kt=f;return}if(f=i.return,f!==null&&(f.flags|=32768,f.subtreeFlags=0,f.deletions=null),!l&&(i=i.sibling,i!==null)){kt=i;return}kt=i=f}while(i!==null);pn=6,kt=null}function X0(i,l,f,y,N,L,K,ee,le){i.cancelPendingCommit=null;do vd();while(On!==0);if(($t&6)!==0)throw Error(r(327));if(l!==null){if(l===i.current)throw Error(r(177));if(L=l.lanes|l.childLanes,L|=Sm,nt(i,f,L,K,ee,le),i===Jt&&(kt=Jt=null,Nt=0),Ro=l,Ai=i,Js=f,Ap=L,Lp=N,$0=y,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,EL(qe,function(){return tS(),null})):(i.callbackNode=null,i.callbackPriority=0),y=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||y){y=q.T,q.T=null,N=Q.p,Q.p=2,K=$t,$t|=4;try{gL(i,l,f)}finally{$t=K,Q.p=N,q.T=y}}On=1,J0(),Q0(),Z0()}}function J0(){if(On===1){On=0;var i=Ai,l=Ro,f=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||f){f=q.T,q.T=null;var y=Q.p;Q.p=2;var N=$t;$t|=4;try{L0(l,i);var L=Wp,K=Pv(i.containerInfo),ee=L.focusedElem,le=L.selectionRange;if(K!==ee&&ee&&ee.ownerDocument&&Mv(ee.ownerDocument.documentElement,ee)){if(le!==null&&xm(ee)){var we=le.start,Oe=le.end;if(Oe===void 0&&(Oe=we),"selectionStart"in ee)ee.selectionStart=we,ee.selectionEnd=Math.min(Oe,ee.value.length);else{var ze=ee.ownerDocument||document,ke=ze&&ze.defaultView||window;if(ke.getSelection){var Ee=ke.getSelection(),st=ee.textContent.length,dt=Math.min(le.start,st),qt=le.end===void 0?dt:Math.min(le.end,st);!Ee.extend&&dt>qt&&(K=qt,qt=dt,dt=K);var me=Iv(ee,dt),ce=Iv(ee,qt);if(me&&ce&&(Ee.rangeCount!==1||Ee.anchorNode!==me.node||Ee.anchorOffset!==me.offset||Ee.focusNode!==ce.node||Ee.focusOffset!==ce.offset)){var ve=ze.createRange();ve.setStart(me.node,me.offset),Ee.removeAllRanges(),dt>qt?(Ee.addRange(ve),Ee.extend(ce.node,ce.offset)):(ve.setEnd(ce.node,ce.offset),Ee.addRange(ve))}}}}for(ze=[],Ee=ee;Ee=Ee.parentNode;)Ee.nodeType===1&&ze.push({element:Ee,left:Ee.scrollLeft,top:Ee.scrollTop});for(typeof ee.focus=="function"&&ee.focus(),ee=0;ee<ze.length;ee++){var Me=ze[ee];Me.element.scrollLeft=Me.left,Me.element.scrollTop=Me.top}}Dd=!!Gp,Wp=Gp=null}finally{$t=N,Q.p=y,q.T=f}}i.current=l,On=2}}function Q0(){if(On===2){On=0;var i=Ai,l=Ro,f=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||f){f=q.T,q.T=null;var y=Q.p;Q.p=2;var N=$t;$t|=4;try{j0(i,l.alternate,l)}finally{$t=N,Q.p=y,q.T=f}}On=3}}function Z0(){if(On===4||On===3){On=0,ie();var i=Ai,l=Ro,f=Js,y=$0;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?On=5:(On=0,Ro=Ai=null,eS(i,i.pendingLanes));var N=i.pendingLanes;if(N===0&&(Ti=null),Ot(f),l=l.stateNode,it&&typeof it.onCommitFiberRoot=="function")try{it.onCommitFiberRoot(et,l,void 0,(l.current.flags&128)===128)}catch{}if(y!==null){l=q.T,N=Q.p,Q.p=2,q.T=null;try{for(var L=i.onRecoverableError,K=0;K<y.length;K++){var ee=y[K];L(ee.value,{componentStack:ee.stack})}}finally{q.T=l,Q.p=N}}(Js&3)!==0&&vd(),bs(i),N=i.pendingLanes,(f&261930)!==0&&(N&42)!==0?i===Dp?lc++:(lc=0,Dp=i):lc=0,cc(0)}}function eS(i,l){(i.pooledCacheLanes&=l)===0&&(l=i.pooledCache,l!=null&&(i.pooledCache=null,Ul(l)))}function vd(){return J0(),Q0(),Z0(),tS()}function tS(){if(On!==5)return!1;var i=Ai,l=Ap;Ap=0;var f=Ot(Js),y=q.T,N=Q.p;try{Q.p=32>f?32:f,q.T=null,f=Lp,Lp=null;var L=Ai,K=Js;if(On=0,Ro=Ai=null,Js=0,($t&6)!==0)throw Error(r(331));var ee=$t;if($t|=4,M0(L.current),R0(L,L.current,K,f),$t=ee,cc(0,!1),it&&typeof it.onPostCommitFiberRoot=="function")try{it.onPostCommitFiberRoot(et,L)}catch{}return!0}finally{Q.p=N,q.T=y,eS(i,l)}}function nS(i,l,f){l=Br(f,l),l=up(i.stateNode,l,2),i=wi(i,l,2),i!==null&&(Ce(i,2),bs(i))}function Vt(i,l,f){if(i.tag===3)nS(i,i,f);else for(;l!==null;){if(l.tag===3){nS(l,i,f);break}else if(l.tag===1){var y=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&(Ti===null||!Ti.has(y))){i=Br(f,i),f=r0(2),y=wi(l,f,2),y!==null&&(s0(f,y,l,i),Ce(y,2),bs(y));break}}l=l.return}}function Ip(i,l,f){var y=i.pingCache;if(y===null){y=i.pingCache=new bL;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(f)||(Ep=!0,N.add(f),i=CL.bind(null,i,l,f),l.then(i,i))}function CL(i,l,f){var y=i.pingCache;y!==null&&y.delete(l),i.pingedLanes|=i.suspendedLanes&f,i.warmLanes&=~f,Jt===i&&(Nt&f)===f&&(pn===4||pn===3&&(Nt&62914560)===Nt&&300>Pe()-md?($t&2)===0&&Oo(i,0):Np|=f,Do===Nt&&(Do=0)),bs(i)}function rS(i,l){l===0&&(l=dn()),i=ca(i,l),i!==null&&(Ce(i,l),bs(i))}function kL(i){var l=i.memoizedState,f=0;l!==null&&(f=l.retryLane),rS(i,f)}function jL(i,l){var f=0;switch(i.tag){case 31:case 13:var y=i.stateNode,N=i.memoizedState;N!==null&&(f=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,f)}function EL(i,l){return Se(i,l)}var _d=null,Mo=null,Mp=!1,Sd=!1,Pp=!1,Di=0;function bs(i){i!==Mo&&i.next===null&&(Mo===null?_d=Mo=i:Mo=Mo.next=i),Sd=!0,Mp||(Mp=!0,TL())}function cc(i,l){if(!Pp&&Sd){Pp=!0;do for(var f=!1,y=_d;y!==null;){if(i!==0){var N=y.pendingLanes;if(N===0)var L=0;else{var K=y.suspendedLanes,ee=y.pingedLanes;L=(1<<31-fe(42|i)+1)-1,L&=N&~(K&~ee),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(f=!0,oS(y,L))}else L=Nt,L=fn(y,y===Jt?L:0,y.cancelPendingCommit!==null||y.timeoutHandle!==-1),(L&3)===0||Dn(y,L)||(f=!0,oS(y,L));y=y.next}while(f);Pp=!1}}function NL(){sS()}function sS(){Sd=Mp=!1;var i=0;Di!==0&&$L()&&(i=Di);for(var l=Pe(),f=null,y=_d;y!==null;){var N=y.next,L=iS(y,l);L===0?(y.next=null,f===null?_d=N:f.next=N,N===null&&(Mo=f)):(f=y,(i!==0||(L&3)!==0)&&(Sd=!0)),y=N}On!==0&&On!==5||cc(i),Di!==0&&(Di=0)}function iS(i,l){for(var f=i.suspendedLanes,y=i.pingedLanes,N=i.expirationTimes,L=i.pendingLanes&-62914561;0<L;){var K=31-fe(L),ee=1<<K,le=N[K];le===-1?((ee&f)===0||(ee&y)!==0)&&(N[K]=Cn(ee,l)):le<=l&&(i.expiredLanes|=ee),L&=~ee}if(l=Jt,f=Nt,f=fn(i,i===l?f:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),y=i.callbackNode,f===0||i===l&&(Ut===2||Ut===9)||i.cancelPendingCommit!==null)return y!==null&&y!==null&&be(y),i.callbackNode=null,i.callbackPriority=0;if((f&3)===0||Dn(i,f)){if(l=f&-f,l===i.callbackPriority)return l;switch(y!==null&&be(y),Ot(f)){case 2:case 8:f=De;break;case 32:f=qe;break;case 268435456:f=he;break;default:f=qe}return y=aS.bind(null,i),f=Se(f,y),i.callbackPriority=l,i.callbackNode=f,l}return y!==null&&y!==null&&be(y),i.callbackPriority=2,i.callbackNode=null,2}function aS(i,l){if(On!==0&&On!==5)return i.callbackNode=null,i.callbackPriority=0,null;var f=i.callbackNode;if(vd()&&i.callbackNode!==f)return null;var y=Nt;return y=fn(i,i===Jt?y:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),y===0?null:(H0(i,y,l),iS(i,Pe()),i.callbackNode!=null&&i.callbackNode===f?aS.bind(null,i):null)}function oS(i,l){if(vd())return null;H0(i,l,!0)}function TL(){HL(function(){($t&6)!==0?Se(ue,NL):sS()})}function Bp(){if(Di===0){var i=_o;i===0&&(i=Dt,Dt<<=1,(Dt&261888)===0&&(Dt=256)),Di=i}return Di}function lS(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Au(""+i)}function cS(i,l){var f=l.ownerDocument.createElement("input");return f.name=l.name,f.value=l.value,i.id&&f.setAttribute("form",i.id),l.parentNode.insertBefore(f,l),i=new FormData(i),f.parentNode.removeChild(f),i}function AL(i,l,f,y,N){if(l==="submit"&&f&&f.stateNode===N){var L=lS((N[Qe]||null).action),K=y.submitter;K&&(l=(l=K[Qe]||null)?lS(l.formAction):K.getAttribute("formAction"),l!==null&&(L=l,K=null));var ee=new Ou("action","action",null,y,N);i.push({event:ee,listeners:[{instance:null,listener:function(){if(y.defaultPrevented){if(Di!==0){var le=K?cS(N,K):new FormData(N);sp(f,{pending:!0,data:le,method:N.method,action:L},null,le)}}else typeof L=="function"&&(ee.preventDefault(),le=K?cS(N,K):new FormData(N),sp(f,{pending:!0,data:le,method:N.method,action:L},L,le))},currentTarget:N}]})}}for(var $p=0;$p<_m.length;$p++){var zp=_m[$p],LL=zp.toLowerCase(),DL=zp[0].toUpperCase()+zp.slice(1);ts(LL,"on"+DL)}ts(zv,"onAnimationEnd"),ts(Hv,"onAnimationIteration"),ts(Fv,"onAnimationStart"),ts("dblclick","onDoubleClick"),ts("focusin","onFocus"),ts("focusout","onBlur"),ts(KA,"onTransitionRun"),ts(YA,"onTransitionStart"),ts(XA,"onTransitionCancel"),ts(Uv,"onTransitionEnd"),ao("onMouseEnter",["mouseout","mouseover"]),ao("onMouseLeave",["mouseout","mouseover"]),ao("onPointerEnter",["pointerout","pointerover"]),ao("onPointerLeave",["pointerout","pointerover"]),ia("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ia("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ia("onBeforeInput",["compositionend","keypress","textInput","paste"]),ia("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ia("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ia("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var uc="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(" "),RL=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(uc));function uS(i,l){l=(l&4)!==0;for(var f=0;f<i.length;f++){var y=i[f],N=y.event;y=y.listeners;e:{var L=void 0;if(l)for(var K=y.length-1;0<=K;K--){var ee=y[K],le=ee.instance,we=ee.currentTarget;if(ee=ee.listener,le!==L&&N.isPropagationStopped())break e;L=ee,N.currentTarget=we;try{L(N)}catch(Oe){Pu(Oe)}N.currentTarget=null,L=le}else for(K=0;K<y.length;K++){if(ee=y[K],le=ee.instance,we=ee.currentTarget,ee=ee.listener,le!==L&&N.isPropagationStopped())break e;L=ee,N.currentTarget=we;try{L(N)}catch(Oe){Pu(Oe)}N.currentTarget=null,L=le}}}}function jt(i,l){var f=l[mt];f===void 0&&(f=l[mt]=new Set);var y=i+"__bubble";f.has(y)||(dS(l,i,2,!1),f.add(y))}function Hp(i,l,f){var y=0;l&&(y|=4),dS(f,i,y,l)}var wd="_reactListening"+Math.random().toString(36).slice(2);function Fp(i){if(!i[wd]){i[wd]=!0,sv.forEach(function(f){f!=="selectionchange"&&(RL.has(f)||Hp(f,!1,i),Hp(f,!0,i))});var l=i.nodeType===9?i:i.ownerDocument;l===null||l[wd]||(l[wd]=!0,Hp("selectionchange",!1,l))}}function dS(i,l,f,y){switch(zS(l)){case 2:var N=oD;break;case 8:N=lD;break;default:N=rg}f=N.bind(null,l,f,i),N=void 0,!lm||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(N=!0),y?N!==void 0?i.addEventListener(l,f,{capture:!0,passive:N}):i.addEventListener(l,f,!0):N!==void 0?i.addEventListener(l,f,{passive:N}):i.addEventListener(l,f,!1)}function Up(i,l,f,y,N){var L=y;if((l&1)===0&&(l&2)===0&&y!==null)e:for(;;){if(y===null)return;var K=y.tag;if(K===3||K===4){var ee=y.stateNode.containerInfo;if(ee===N)break;if(K===4)for(K=y.return;K!==null;){var le=K.tag;if((le===3||le===4)&&K.stateNode.containerInfo===N)return;K=K.return}for(;ee!==null;){if(K=ro(ee),K===null)return;if(le=K.tag,le===5||le===6||le===26||le===27){y=L=K;continue e}ee=ee.parentNode}}y=y.return}gv(function(){var we=L,Oe=am(f),ze=[];e:{var ke=Vv.get(i);if(ke!==void 0){var Ee=Ou,st=i;switch(i){case"keypress":if(Du(f)===0)break e;case"keydown":case"keyup":Ee=jA;break;case"focusin":st="focus",Ee=hm;break;case"focusout":st="blur",Ee=hm;break;case"beforeblur":case"afterblur":Ee=hm;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ee=bv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ee=mA;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ee=TA;break;case zv:case Hv:case Fv:Ee=xA;break;case Uv:Ee=LA;break;case"scroll":case"scrollend":Ee=hA;break;case"wheel":Ee=RA;break;case"copy":case"cut":case"paste":Ee=bA;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ee=_v;break;case"toggle":case"beforetoggle":Ee=IA}var dt=(l&4)!==0,qt=!dt&&(i==="scroll"||i==="scrollend"),me=dt?ke!==null?ke+"Capture":null:ke;dt=[];for(var ce=we,ve;ce!==null;){var Me=ce;if(ve=Me.stateNode,Me=Me.tag,Me!==5&&Me!==26&&Me!==27||ve===null||me===null||(Me=Dl(ce,me),Me!=null&&dt.push(dc(ce,Me,ve))),qt)break;ce=ce.return}0<dt.length&&(ke=new Ee(ke,st,null,f,Oe),ze.push({event:ke,listeners:dt}))}}if((l&7)===0){e:{if(ke=i==="mouseover"||i==="pointerover",Ee=i==="mouseout"||i==="pointerout",ke&&f!==im&&(st=f.relatedTarget||f.fromElement)&&(ro(st)||st[rt]))break e;if((Ee||ke)&&(ke=Oe.window===Oe?Oe:(ke=Oe.ownerDocument)?ke.defaultView||ke.parentWindow:window,Ee?(st=f.relatedTarget||f.toElement,Ee=we,st=st?ro(st):null,st!==null&&(qt=o(st),dt=st.tag,st!==qt||dt!==5&&dt!==27&&dt!==6)&&(st=null)):(Ee=null,st=we),Ee!==st)){if(dt=bv,Me="onMouseLeave",me="onMouseEnter",ce="mouse",(i==="pointerout"||i==="pointerover")&&(dt=_v,Me="onPointerLeave",me="onPointerEnter",ce="pointer"),qt=Ee==null?ke:Ll(Ee),ve=st==null?ke:Ll(st),ke=new dt(Me,ce+"leave",Ee,f,Oe),ke.target=qt,ke.relatedTarget=ve,Me=null,ro(Oe)===we&&(dt=new dt(me,ce+"enter",st,f,Oe),dt.target=ve,dt.relatedTarget=qt,Me=dt),qt=Me,Ee&&st)t:{for(dt=OL,me=Ee,ce=st,ve=0,Me=me;Me;Me=dt(Me))ve++;Me=0;for(var lt=ce;lt;lt=dt(lt))Me++;for(;0<ve-Me;)me=dt(me),ve--;for(;0<Me-ve;)ce=dt(ce),Me--;for(;ve--;){if(me===ce||ce!==null&&me===ce.alternate){dt=me;break t}me=dt(me),ce=dt(ce)}dt=null}else dt=null;Ee!==null&&hS(ze,ke,Ee,dt,!1),st!==null&&qt!==null&&hS(ze,qt,st,dt,!0)}}e:{if(ke=we?Ll(we):window,Ee=ke.nodeName&&ke.nodeName.toLowerCase(),Ee==="select"||Ee==="input"&&ke.type==="file")var It=Tv;else if(Ev(ke))if(Av)It=GA;else{It=UA;var at=FA}else Ee=ke.nodeName,!Ee||Ee.toLowerCase()!=="input"||ke.type!=="checkbox"&&ke.type!=="radio"?we&&sm(we.elementType)&&(It=Tv):It=VA;if(It&&(It=It(i,we))){Nv(ze,It,f,Oe);break e}at&&at(i,ke,we),i==="focusout"&&we&&ke.type==="number"&&we.memoizedProps.value!=null&&rm(ke,"number",ke.value)}switch(at=we?Ll(we):window,i){case"focusin":(Ev(at)||at.contentEditable==="true")&&(fo=at,ym=we,zl=null);break;case"focusout":zl=ym=fo=null;break;case"mousedown":bm=!0;break;case"contextmenu":case"mouseup":case"dragend":bm=!1,Bv(ze,f,Oe);break;case"selectionchange":if(qA)break;case"keydown":case"keyup":Bv(ze,f,Oe)}var vt;if(mm)e:{switch(i){case"compositionstart":var Tt="onCompositionStart";break e;case"compositionend":Tt="onCompositionEnd";break e;case"compositionupdate":Tt="onCompositionUpdate";break e}Tt=void 0}else ho?kv(i,f)&&(Tt="onCompositionEnd"):i==="keydown"&&f.keyCode===229&&(Tt="onCompositionStart");Tt&&(Sv&&f.locale!=="ko"&&(ho||Tt!=="onCompositionStart"?Tt==="onCompositionEnd"&&ho&&(vt=xv()):(gi=Oe,cm="value"in gi?gi.value:gi.textContent,ho=!0)),at=Cd(we,Tt),0<at.length&&(Tt=new vv(Tt,i,null,f,Oe),ze.push({event:Tt,listeners:at}),vt?Tt.data=vt:(vt=jv(f),vt!==null&&(Tt.data=vt)))),(vt=PA?BA(i,f):$A(i,f))&&(Tt=Cd(we,"onBeforeInput"),0<Tt.length&&(at=new vv("onBeforeInput","beforeinput",null,f,Oe),ze.push({event:at,listeners:Tt}),at.data=vt)),AL(ze,i,we,f,Oe)}uS(ze,l)})}function dc(i,l,f){return{instance:i,listener:l,currentTarget:f}}function Cd(i,l){for(var f=l+"Capture",y=[];i!==null;){var N=i,L=N.stateNode;if(N=N.tag,N!==5&&N!==26&&N!==27||L===null||(N=Dl(i,f),N!=null&&y.unshift(dc(i,N,L)),N=Dl(i,l),N!=null&&y.push(dc(i,N,L))),i.tag===3)return y;i=i.return}return[]}function OL(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,f,y,N){for(var L=l._reactName,K=[];f!==null&&f!==y;){var ee=f,le=ee.alternate,we=ee.stateNode;if(ee=ee.tag,le!==null&&le===y)break;ee!==5&&ee!==26&&ee!==27||we===null||(le=we,N?(we=Dl(f,L),we!=null&&K.unshift(dc(f,we,le))):N||(we=Dl(f,L),we!=null&&K.push(dc(f,we,le)))),f=f.return}K.length!==0&&i.push({event:l,listeners:K})}var IL=/\r\n?/g,ML=/\u0000|\uFFFD/g;function fS(i){return(typeof i=="string"?i:""+i).replace(IL,`
|
|
50
|
+
`).replace(ML,"")}function mS(i,l){return l=fS(l),fS(i)===l}function Wt(i,l,f,y,N,L){switch(f){case"children":typeof y=="string"?l==="body"||l==="textarea"&&y===""||lo(i,y):(typeof y=="number"||typeof y=="bigint")&&l!=="body"&&lo(i,""+y);break;case"className":Nu(i,"class",y);break;case"tabIndex":Nu(i,"tabindex",y);break;case"dir":case"role":case"viewBox":case"width":case"height":Nu(i,f,y);break;case"style":mv(i,y,L);break;case"data":if(l!=="object"){Nu(i,"data",y);break}case"src":case"href":if(y===""&&(l!=="a"||f!=="href")){i.removeAttribute(f);break}if(y==null||typeof y=="function"||typeof y=="symbol"||typeof y=="boolean"){i.removeAttribute(f);break}y=Au(""+y),i.setAttribute(f,y);break;case"action":case"formAction":if(typeof y=="function"){i.setAttribute(f,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof L=="function"&&(f==="formAction"?(l!=="input"&&Wt(i,l,"name",N.name,N,null),Wt(i,l,"formEncType",N.formEncType,N,null),Wt(i,l,"formMethod",N.formMethod,N,null),Wt(i,l,"formTarget",N.formTarget,N,null)):(Wt(i,l,"encType",N.encType,N,null),Wt(i,l,"method",N.method,N,null),Wt(i,l,"target",N.target,N,null)));if(y==null||typeof y=="symbol"||typeof y=="boolean"){i.removeAttribute(f);break}y=Au(""+y),i.setAttribute(f,y);break;case"onClick":y!=null&&(i.onclick=Ms);break;case"onScroll":y!=null&&jt("scroll",i);break;case"onScrollEnd":y!=null&&jt("scrollend",i);break;case"dangerouslySetInnerHTML":if(y!=null){if(typeof y!="object"||!("__html"in y))throw Error(r(61));if(f=y.__html,f!=null){if(N.children!=null)throw Error(r(60));i.innerHTML=f}}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}f=Au(""+y),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":y!=null&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(f,""+y):i.removeAttribute(f);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":y&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(f,""):i.removeAttribute(f);break;case"capture":case"download":y===!0?i.setAttribute(f,""):y!==!1&&y!=null&&typeof y!="function"&&typeof y!="symbol"?i.setAttribute(f,y):i.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":y!=null&&typeof y!="function"&&typeof y!="symbol"&&!isNaN(y)&&1<=y?i.setAttribute(f,y):i.removeAttribute(f);break;case"rowSpan":case"start":y==null||typeof y=="function"||typeof y=="symbol"||isNaN(y)?i.removeAttribute(f):i.setAttribute(f,y);break;case"popover":jt("beforetoggle",i),jt("toggle",i),Eu(i,"popover",y);break;case"xlinkActuate":Is(i,"http://www.w3.org/1999/xlink","xlink:actuate",y);break;case"xlinkArcrole":Is(i,"http://www.w3.org/1999/xlink","xlink:arcrole",y);break;case"xlinkRole":Is(i,"http://www.w3.org/1999/xlink","xlink:role",y);break;case"xlinkShow":Is(i,"http://www.w3.org/1999/xlink","xlink:show",y);break;case"xlinkTitle":Is(i,"http://www.w3.org/1999/xlink","xlink:title",y);break;case"xlinkType":Is(i,"http://www.w3.org/1999/xlink","xlink:type",y);break;case"xmlBase":Is(i,"http://www.w3.org/XML/1998/namespace","xml:base",y);break;case"xmlLang":Is(i,"http://www.w3.org/XML/1998/namespace","xml:lang",y);break;case"xmlSpace":Is(i,"http://www.w3.org/XML/1998/namespace","xml:space",y);break;case"is":Eu(i,"is",y);break;case"innerText":case"textContent":break;default:(!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(f=uA.get(f)||f,Eu(i,f,y))}}function Vp(i,l,f,y,N,L){switch(f){case"style":mv(i,y,L);break;case"dangerouslySetInnerHTML":if(y!=null){if(typeof y!="object"||!("__html"in y))throw Error(r(61));if(f=y.__html,f!=null){if(N.children!=null)throw Error(r(60));i.innerHTML=f}}break;case"children":typeof y=="string"?lo(i,y):(typeof y=="number"||typeof y=="bigint")&&lo(i,""+y);break;case"onScroll":y!=null&&jt("scroll",i);break;case"onScrollEnd":y!=null&&jt("scrollend",i);break;case"onClick":y!=null&&(i.onclick=Ms);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!iv.hasOwnProperty(f))e:{if(f[0]==="o"&&f[1]==="n"&&(N=f.endsWith("Capture"),l=f.slice(2,N?f.length-7:void 0),L=i[Qe]||null,L=L!=null?L[f]:null,typeof L=="function"&&i.removeEventListener(l,L,N),typeof y=="function")){typeof L!="function"&&L!==null&&(f in i?i[f]=null:i.hasAttribute(f)&&i.removeAttribute(f)),i.addEventListener(l,y,N);break e}f in i?i[f]=y:y===!0?i.setAttribute(f,""):Eu(i,f,y)}}}function qn(i,l,f){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":jt("error",i),jt("load",i);var y=!1,N=!1,L;for(L in f)if(f.hasOwnProperty(L)){var K=f[L];if(K!=null)switch(L){case"src":y=!0;break;case"srcSet":N=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,l));default:Wt(i,l,L,K,f,null)}}N&&Wt(i,l,"srcSet",f.srcSet,f,null),y&&Wt(i,l,"src",f.src,f,null);return;case"input":jt("invalid",i);var ee=L=K=N=null,le=null,we=null;for(y in f)if(f.hasOwnProperty(y)){var Oe=f[y];if(Oe!=null)switch(y){case"name":N=Oe;break;case"type":K=Oe;break;case"checked":le=Oe;break;case"defaultChecked":we=Oe;break;case"value":L=Oe;break;case"defaultValue":ee=Oe;break;case"children":case"dangerouslySetInnerHTML":if(Oe!=null)throw Error(r(137,l));break;default:Wt(i,l,y,Oe,f,null)}}uv(i,L,ee,le,we,K,N,!1);return;case"select":jt("invalid",i),y=K=L=null;for(N in f)if(f.hasOwnProperty(N)&&(ee=f[N],ee!=null))switch(N){case"value":L=ee;break;case"defaultValue":K=ee;break;case"multiple":y=ee;default:Wt(i,l,N,ee,f,null)}l=L,f=K,i.multiple=!!y,l!=null?oo(i,!!y,l,!1):f!=null&&oo(i,!!y,f,!0);return;case"textarea":jt("invalid",i),L=N=y=null;for(K in f)if(f.hasOwnProperty(K)&&(ee=f[K],ee!=null))switch(K){case"value":y=ee;break;case"defaultValue":N=ee;break;case"children":L=ee;break;case"dangerouslySetInnerHTML":if(ee!=null)throw Error(r(91));break;default:Wt(i,l,K,ee,f,null)}hv(i,y,N,L);return;case"option":for(le in f)if(f.hasOwnProperty(le)&&(y=f[le],y!=null))switch(le){case"selected":i.selected=y&&typeof y!="function"&&typeof y!="symbol";break;default:Wt(i,l,le,y,f,null)}return;case"dialog":jt("beforetoggle",i),jt("toggle",i),jt("cancel",i),jt("close",i);break;case"iframe":case"object":jt("load",i);break;case"video":case"audio":for(y=0;y<uc.length;y++)jt(uc[y],i);break;case"image":jt("error",i),jt("load",i);break;case"details":jt("toggle",i);break;case"embed":case"source":case"link":jt("error",i),jt("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(we in f)if(f.hasOwnProperty(we)&&(y=f[we],y!=null))switch(we){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,l));default:Wt(i,l,we,y,f,null)}return;default:if(sm(l)){for(Oe in f)f.hasOwnProperty(Oe)&&(y=f[Oe],y!==void 0&&Vp(i,l,Oe,y,f,void 0));return}}for(ee in f)f.hasOwnProperty(ee)&&(y=f[ee],y!=null&&Wt(i,l,ee,y,f,null))}function PL(i,l,f,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,L=null,K=null,ee=null,le=null,we=null,Oe=null;for(Ee in f){var ze=f[Ee];if(f.hasOwnProperty(Ee)&&ze!=null)switch(Ee){case"checked":break;case"value":break;case"defaultValue":le=ze;default:y.hasOwnProperty(Ee)||Wt(i,l,Ee,null,y,ze)}}for(var ke in y){var Ee=y[ke];if(ze=f[ke],y.hasOwnProperty(ke)&&(Ee!=null||ze!=null))switch(ke){case"type":L=Ee;break;case"name":N=Ee;break;case"checked":we=Ee;break;case"defaultChecked":Oe=Ee;break;case"value":K=Ee;break;case"defaultValue":ee=Ee;break;case"children":case"dangerouslySetInnerHTML":if(Ee!=null)throw Error(r(137,l));break;default:Ee!==ze&&Wt(i,l,ke,Ee,y,ze)}}nm(i,K,ee,le,we,Oe,L,N);return;case"select":Ee=K=ee=ke=null;for(L in f)if(le=f[L],f.hasOwnProperty(L)&&le!=null)switch(L){case"value":break;case"multiple":Ee=le;default:y.hasOwnProperty(L)||Wt(i,l,L,null,y,le)}for(N in y)if(L=y[N],le=f[N],y.hasOwnProperty(N)&&(L!=null||le!=null))switch(N){case"value":ke=L;break;case"defaultValue":ee=L;break;case"multiple":K=L;default:L!==le&&Wt(i,l,N,L,y,le)}l=ee,f=K,y=Ee,ke!=null?oo(i,!!f,ke,!1):!!y!=!!f&&(l!=null?oo(i,!!f,l,!0):oo(i,!!f,f?[]:"",!1));return;case"textarea":Ee=ke=null;for(ee in f)if(N=f[ee],f.hasOwnProperty(ee)&&N!=null&&!y.hasOwnProperty(ee))switch(ee){case"value":break;case"children":break;default:Wt(i,l,ee,null,y,N)}for(K in y)if(N=y[K],L=f[K],y.hasOwnProperty(K)&&(N!=null||L!=null))switch(K){case"value":ke=N;break;case"defaultValue":Ee=N;break;case"children":break;case"dangerouslySetInnerHTML":if(N!=null)throw Error(r(91));break;default:N!==L&&Wt(i,l,K,N,y,L)}dv(i,ke,Ee);return;case"option":for(var st in f)if(ke=f[st],f.hasOwnProperty(st)&&ke!=null&&!y.hasOwnProperty(st))switch(st){case"selected":i.selected=!1;break;default:Wt(i,l,st,null,y,ke)}for(le in y)if(ke=y[le],Ee=f[le],y.hasOwnProperty(le)&&ke!==Ee&&(ke!=null||Ee!=null))switch(le){case"selected":i.selected=ke&&typeof ke!="function"&&typeof ke!="symbol";break;default:Wt(i,l,le,ke,y,Ee)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var dt in f)ke=f[dt],f.hasOwnProperty(dt)&&ke!=null&&!y.hasOwnProperty(dt)&&Wt(i,l,dt,null,y,ke);for(we in y)if(ke=y[we],Ee=f[we],y.hasOwnProperty(we)&&ke!==Ee&&(ke!=null||Ee!=null))switch(we){case"children":case"dangerouslySetInnerHTML":if(ke!=null)throw Error(r(137,l));break;default:Wt(i,l,we,ke,y,Ee)}return;default:if(sm(l)){for(var qt in f)ke=f[qt],f.hasOwnProperty(qt)&&ke!==void 0&&!y.hasOwnProperty(qt)&&Vp(i,l,qt,void 0,y,ke);for(Oe in y)ke=y[Oe],Ee=f[Oe],!y.hasOwnProperty(Oe)||ke===Ee||ke===void 0&&Ee===void 0||Vp(i,l,Oe,ke,y,Ee);return}}for(var me in f)ke=f[me],f.hasOwnProperty(me)&&ke!=null&&!y.hasOwnProperty(me)&&Wt(i,l,me,null,y,ke);for(ze in y)ke=y[ze],Ee=f[ze],!y.hasOwnProperty(ze)||ke===Ee||ke==null&&Ee==null||Wt(i,l,ze,ke,y,Ee)}function pS(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function BL(){if(typeof performance.getEntriesByType=="function"){for(var i=0,l=0,f=performance.getEntriesByType("resource"),y=0;y<f.length;y++){var N=f[y],L=N.transferSize,K=N.initiatorType,ee=N.duration;if(L&&ee&&pS(K)){for(K=0,ee=N.responseEnd,y+=1;y<f.length;y++){var le=f[y],we=le.startTime;if(we>ee)break;var Oe=le.transferSize,ze=le.initiatorType;Oe&&pS(ze)&&(le=le.responseEnd,K+=Oe*(le<ee?1:(ee-we)/(le-we)))}if(--y,l+=8*(L+K)/(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 Gp=null,Wp=null;function kd(i){return i.nodeType===9?i:i.ownerDocument}function gS(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 xS(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 qp(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 Kp=null;function $L(){var i=window.event;return i&&i.type==="popstate"?i===Kp?!1:(Kp=i,!0):(Kp=null,!1)}var yS=typeof setTimeout=="function"?setTimeout:void 0,zL=typeof clearTimeout=="function"?clearTimeout:void 0,bS=typeof Promise=="function"?Promise:void 0,HL=typeof queueMicrotask=="function"?queueMicrotask:typeof bS<"u"?function(i){return bS.resolve(null).then(i).catch(FL)}:yS;function FL(i){setTimeout(function(){throw i})}function Ri(i){return i==="head"}function vS(i,l){var f=l,y=0;do{var N=f.nextSibling;if(i.removeChild(f),N&&N.nodeType===8)if(f=N.data,f==="/$"||f==="/&"){if(y===0){i.removeChild(N),zo(l);return}y--}else if(f==="$"||f==="$?"||f==="$~"||f==="$!"||f==="&")y++;else if(f==="html")hc(i.ownerDocument.documentElement);else if(f==="head"){f=i.ownerDocument.head,hc(f);for(var L=f.firstChild;L;){var K=L.nextSibling,ee=L.nodeName;L[kn]||ee==="SCRIPT"||ee==="STYLE"||ee==="LINK"&&L.rel.toLowerCase()==="stylesheet"||f.removeChild(L),L=K}}else f==="body"&&hc(i.ownerDocument.body);f=N}while(f);zo(l)}function _S(i,l){var f=i;i=0;do{var y=f.nextSibling;if(f.nodeType===1?l?(f._stashedDisplay=f.style.display,f.style.display="none"):(f.style.display=f._stashedDisplay||"",f.getAttribute("style")===""&&f.removeAttribute("style")):f.nodeType===3&&(l?(f._stashedText=f.nodeValue,f.nodeValue=""):f.nodeValue=f._stashedText||""),y&&y.nodeType===8)if(f=y.data,f==="/$"){if(i===0)break;i--}else f!=="$"&&f!=="$?"&&f!=="$~"&&f!=="$!"||i++;f=y}while(f)}function Yp(i){var l=i.firstChild;for(l&&l.nodeType===10&&(l=l.nextSibling);l;){var f=l;switch(l=l.nextSibling,f.nodeName){case"HTML":case"HEAD":case"BODY":Yp(f),no(f);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(f.rel.toLowerCase()==="stylesheet")continue}i.removeChild(f)}}function UL(i,l,f,y){for(;i.nodeType===1;){var N=f;if(i.nodeName.toLowerCase()!==l.toLowerCase()){if(!y&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(y){if(!i[kn])switch(l){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(L=i.getAttribute("rel"),L==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(L!==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(L=i.getAttribute("src"),(L!==(N.src==null?null:N.src)||i.getAttribute("type")!==(N.type==null?null:N.type)||i.getAttribute("crossorigin")!==(N.crossOrigin==null?null:N.crossOrigin))&&L&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(l==="input"&&i.type==="hidden"){var L=N.name==null?null:""+N.name;if(N.type==="hidden"&&i.getAttribute("name")===L)return i}else return i;if(i=Ur(i.nextSibling),i===null)break}return null}function VL(i,l,f){if(l==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!f||(i=Ur(i.nextSibling),i===null))return null;return i}function SS(i,l){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!l||(i=Ur(i.nextSibling),i===null))return null;return i}function Xp(i){return i.data==="$?"||i.data==="$~"}function Jp(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function GL(i,l){var f=i.ownerDocument;if(i.data==="$~")i._reactRetry=l;else if(i.data!=="$?"||f.readyState!=="loading")l();else{var y=function(){l(),f.removeEventListener("DOMContentLoaded",y)};f.addEventListener("DOMContentLoaded",y),i._reactRetry=y}}function Ur(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 Qp=null;function wS(i){i=i.nextSibling;for(var l=0;i;){if(i.nodeType===8){var f=i.data;if(f==="/$"||f==="/&"){if(l===0)return Ur(i.nextSibling);l--}else f!=="$"&&f!=="$!"&&f!=="$?"&&f!=="$~"&&f!=="&"||l++}i=i.nextSibling}return null}function CS(i){i=i.previousSibling;for(var l=0;i;){if(i.nodeType===8){var f=i.data;if(f==="$"||f==="$!"||f==="$?"||f==="$~"||f==="&"){if(l===0)return i;l--}else f!=="/$"&&f!=="/&"||l++}i=i.previousSibling}return null}function kS(i,l,f){switch(l=kd(f),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 hc(i){for(var l=i.attributes;l.length;)i.removeAttributeNode(l[0]);no(i)}var Vr=new Map,jS=new Set;function jd(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Qs=Q.d;Q.d={f:WL,r:qL,D:KL,C:YL,L:XL,m:JL,X:ZL,S:QL,M:eD};function WL(){var i=Qs.f(),l=xd();return i||l}function qL(i){var l=so(i);l!==null&&l.tag===5&&l.type==="form"?U_(l):Qs.r(i)}var Po=typeof document>"u"?null:document;function ES(i,l,f){var y=Po;if(y&&typeof l=="string"&&l){var N=Mr(l);N='link[rel="'+i+'"][href="'+N+'"]',typeof f=="string"&&(N+='[crossorigin="'+f+'"]'),jS.has(N)||(jS.add(N),i={rel:i,crossOrigin:f,href:l},y.querySelector(N)===null&&(l=y.createElement("link"),qn(l,"link",i),$n(l),y.head.appendChild(l)))}}function KL(i){Qs.D(i),ES("dns-prefetch",i,null)}function YL(i,l){Qs.C(i,l),ES("preconnect",i,l)}function XL(i,l,f){Qs.L(i,l,f);var y=Po;if(y&&i&&l){var N='link[rel="preload"][as="'+Mr(l)+'"]';l==="image"&&f&&f.imageSrcSet?(N+='[imagesrcset="'+Mr(f.imageSrcSet)+'"]',typeof f.imageSizes=="string"&&(N+='[imagesizes="'+Mr(f.imageSizes)+'"]')):N+='[href="'+Mr(i)+'"]';var L=N;switch(l){case"style":L=Bo(i);break;case"script":L=$o(i)}Vr.has(L)||(i=m({rel:"preload",href:l==="image"&&f&&f.imageSrcSet?void 0:i,as:l},f),Vr.set(L,i),y.querySelector(N)!==null||l==="style"&&y.querySelector(fc(L))||l==="script"&&y.querySelector(mc(L))||(l=y.createElement("link"),qn(l,"link",i),$n(l),y.head.appendChild(l)))}}function JL(i,l){Qs.m(i,l);var f=Po;if(f&&i){var y=l&&typeof l.as=="string"?l.as:"script",N='link[rel="modulepreload"][as="'+Mr(y)+'"][href="'+Mr(i)+'"]',L=N;switch(y){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=$o(i)}if(!Vr.has(L)&&(i=m({rel:"modulepreload",href:i},l),Vr.set(L,i),f.querySelector(N)===null)){switch(y){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(f.querySelector(mc(L)))return}y=f.createElement("link"),qn(y,"link",i),$n(y),f.head.appendChild(y)}}}function QL(i,l,f){Qs.S(i,l,f);var y=Po;if(y&&i){var N=io(y).hoistableStyles,L=Bo(i);l=l||"default";var K=N.get(L);if(!K){var ee={loading:0,preload:null};if(K=y.querySelector(fc(L)))ee.loading=5;else{i=m({rel:"stylesheet",href:i,"data-precedence":l},f),(f=Vr.get(L))&&Zp(i,f);var le=K=y.createElement("link");$n(le),qn(le,"link",i),le._p=new Promise(function(we,Oe){le.onload=we,le.onerror=Oe}),le.addEventListener("load",function(){ee.loading|=1}),le.addEventListener("error",function(){ee.loading|=2}),ee.loading|=4,Ed(K,l,y)}K={type:"stylesheet",instance:K,count:1,state:ee},N.set(L,K)}}}function ZL(i,l){Qs.X(i,l);var f=Po;if(f&&i){var y=io(f).hoistableScripts,N=$o(i),L=y.get(N);L||(L=f.querySelector(mc(N)),L||(i=m({src:i,async:!0},l),(l=Vr.get(N))&&eg(i,l),L=f.createElement("script"),$n(L),qn(L,"link",i),f.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},y.set(N,L))}}function eD(i,l){Qs.M(i,l);var f=Po;if(f&&i){var y=io(f).hoistableScripts,N=$o(i),L=y.get(N);L||(L=f.querySelector(mc(N)),L||(i=m({src:i,async:!0,type:"module"},l),(l=Vr.get(N))&&eg(i,l),L=f.createElement("script"),$n(L),qn(L,"link",i),f.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},y.set(N,L))}}function NS(i,l,f,y){var N=(N=Z.current)?jd(N):null;if(!N)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof f.precedence=="string"&&typeof f.href=="string"?(l=Bo(f.href),f=io(N).hoistableStyles,y=f.get(l),y||(y={type:"style",instance:null,count:0,state:null},f.set(l,y)),y):{type:"void",instance:null,count:0,state:null};case"link":if(f.rel==="stylesheet"&&typeof f.href=="string"&&typeof f.precedence=="string"){i=Bo(f.href);var L=io(N).hoistableStyles,K=L.get(i);if(K||(N=N.ownerDocument||N,K={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(i,K),(L=N.querySelector(fc(i)))&&!L._p&&(K.instance=L,K.state.loading=5),Vr.has(i)||(f={rel:"preload",as:"style",href:f.href,crossOrigin:f.crossOrigin,integrity:f.integrity,media:f.media,hrefLang:f.hrefLang,referrerPolicy:f.referrerPolicy},Vr.set(i,f),L||tD(N,i,f,K.state))),l&&y===null)throw Error(r(528,""));return K}if(l&&y!==null)throw Error(r(529,""));return null;case"script":return l=f.async,f=f.src,typeof f=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=$o(f),f=io(N).hoistableScripts,y=f.get(l),y||(y={type:"script",instance:null,count:0,state:null},f.set(l,y)),y):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function Bo(i){return'href="'+Mr(i)+'"'}function fc(i){return'link[rel="stylesheet"]['+i+"]"}function TS(i){return m({},i,{"data-precedence":i.precedence,precedence:null})}function tD(i,l,f,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",f),$n(l),i.head.appendChild(l))}function $o(i){return'[src="'+Mr(i)+'"]'}function mc(i){return"script[async]"+i}function AS(i,l,f){if(l.count++,l.instance===null)switch(l.type){case"style":var y=i.querySelector('style[data-href~="'+Mr(f.href)+'"]');if(y)return l.instance=y,$n(y),y;var N=m({},f,{"data-href":f.href,"data-precedence":f.precedence,href:null,precedence:null});return y=(i.ownerDocument||i).createElement("style"),$n(y),qn(y,"style",N),Ed(y,f.precedence,i),l.instance=y;case"stylesheet":N=Bo(f.href);var L=i.querySelector(fc(N));if(L)return l.state.loading|=4,l.instance=L,$n(L),L;y=TS(f),(N=Vr.get(N))&&Zp(y,N),L=(i.ownerDocument||i).createElement("link"),$n(L);var K=L;return K._p=new Promise(function(ee,le){K.onload=ee,K.onerror=le}),qn(L,"link",y),l.state.loading|=4,Ed(L,f.precedence,i),l.instance=L;case"script":return L=$o(f.src),(N=i.querySelector(mc(L)))?(l.instance=N,$n(N),N):(y=f,(N=Vr.get(L))&&(y=m({},f),eg(y,N)),i=i.ownerDocument||i,N=i.createElement("script"),$n(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,Ed(y,f.precedence,i));return l.instance}function Ed(i,l,f){for(var y=f.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),N=y.length?y[y.length-1]:null,L=N,K=0;K<y.length;K++){var ee=y[K];if(ee.dataset.precedence===l)L=ee;else if(L!==N)break}L?L.parentNode.insertBefore(i,L.nextSibling):(l=f.nodeType===9?f.head:f,l.insertBefore(i,l.firstChild))}function Zp(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.title==null&&(i.title=l.title)}function eg(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.integrity==null&&(i.integrity=l.integrity)}var Nd=null;function LS(i,l,f){if(Nd===null){var y=new Map,N=Nd=new Map;N.set(f,y)}else N=Nd,y=N.get(f),y||(y=new Map,N.set(f,y));if(y.has(i))return y;for(y.set(i,null),f=f.getElementsByTagName(i),N=0;N<f.length;N++){var L=f[N];if(!(L[kn]||L[$e]||i==="link"&&L.getAttribute("rel")==="stylesheet")&&L.namespaceURI!=="http://www.w3.org/2000/svg"){var K=L.getAttribute(l)||"";K=i+K;var ee=y.get(K);ee?ee.push(L):y.set(K,[L])}}return y}function DS(i,l,f){i=i.ownerDocument||i,i.head.insertBefore(f,l==="title"?i.querySelector("head > title"):null)}function nD(i,l,f){if(f===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 RS(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function rD(i,l,f,y){if(f.type==="stylesheet"&&(typeof y.media!="string"||matchMedia(y.media).matches!==!1)&&(f.state.loading&4)===0){if(f.instance===null){var N=Bo(y.href),L=l.querySelector(fc(N));if(L){l=L._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=Td.bind(i),l.then(i,i)),f.state.loading|=4,f.instance=L,$n(L);return}L=l.ownerDocument||l,y=TS(y),(N=Vr.get(N))&&Zp(y,N),L=L.createElement("link"),$n(L);var K=L;K._p=new Promise(function(ee,le){K.onload=ee,K.onerror=le}),qn(L,"link",y),f.instance=L}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(f,l),(l=f.state.preload)&&(f.state.loading&3)===0&&(i.count++,f=Td.bind(i),l.addEventListener("load",f),l.addEventListener("error",f))}}var tg=0;function sD(i,l){return i.stylesheets&&i.count===0&&Ld(i,i.stylesheets),0<i.count||0<i.imgCount?function(f){var y=setTimeout(function(){if(i.stylesheets&&Ld(i,i.stylesheets),i.unsuspend){var L=i.unsuspend;i.unsuspend=null,L()}},6e4+l);0<i.imgBytes&&tg===0&&(tg=62500*BL());var N=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Ld(i,i.stylesheets),i.unsuspend)){var L=i.unsuspend;i.unsuspend=null,L()}},(i.imgBytes>tg?50:800)+l);return i.unsuspend=f,function(){i.unsuspend=null,clearTimeout(y),clearTimeout(N)}}:null}function Td(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ld(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Ad=null;function Ld(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Ad=new Map,l.forEach(iD,i),Ad=null,Td.call(i))}function iD(i,l){if(!(l.state.loading&4)){var f=Ad.get(i);if(f)var y=f.get(null);else{f=new Map,Ad.set(i,f);for(var N=i.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L<N.length;L++){var K=N[L];(K.nodeName==="LINK"||K.getAttribute("media")!=="not all")&&(f.set(K.dataset.precedence,K),y=K)}y&&f.set(null,y)}N=l.instance,K=N.getAttribute("data-precedence"),L=f.get(K)||y,L===y&&f.set(null,N),f.set(K,N),this.count++,y=Td.bind(this),N.addEventListener("load",y),N.addEventListener("error",y),L?L.parentNode.insertBefore(N,L.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(N,i.firstChild)),l.state.loading|=4}}var pc={$$typeof:b,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function aD(i,l,f,y,N,L,K,ee,le){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=rr(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rr(0),this.hiddenUpdates=rr(null),this.identifierPrefix=y,this.onUncaughtError=N,this.onCaughtError=L,this.onRecoverableError=K,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=le,this.incompleteTransitions=new Map}function OS(i,l,f,y,N,L,K,ee,le,we,Oe,ze){return i=new aD(i,l,f,K,le,we,Oe,ze,ee),l=1,L===!0&&(l|=24),L=Sr(3,null,null,l),i.current=L,L.stateNode=i,l=Om(),l.refCount++,i.pooledCache=l,l.refCount++,L.memoizedState={element:y,isDehydrated:f,cache:l},Bm(L),i}function IS(i){return i?(i=go,i):go}function MS(i,l,f,y,N,L){N=IS(N),y.context===null?y.context=N:y.pendingContext=N,y=Si(l),y.payload={element:f},L=L===void 0?null:L,L!==null&&(y.callback=L),f=wi(i,y,l),f!==null&&(mr(f,i,l),ql(f,i,l))}function PS(i,l){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var f=i.retryLane;i.retryLane=f!==0&&f<l?f:l}}function ng(i,l){PS(i,l),(i=i.alternate)&&PS(i,l)}function BS(i){if(i.tag===13||i.tag===31){var l=ca(i,67108864);l!==null&&mr(l,i,67108864),ng(i,67108864)}}function $S(i){if(i.tag===13||i.tag===31){var l=Er();l=tt(l);var f=ca(i,l);f!==null&&mr(f,i,l),ng(i,l)}}var Dd=!0;function oD(i,l,f,y){var N=q.T;q.T=null;var L=Q.p;try{Q.p=2,rg(i,l,f,y)}finally{Q.p=L,q.T=N}}function lD(i,l,f,y){var N=q.T;q.T=null;var L=Q.p;try{Q.p=8,rg(i,l,f,y)}finally{Q.p=L,q.T=N}}function rg(i,l,f,y){if(Dd){var N=sg(y);if(N===null)Up(i,l,y,Rd,f),HS(i,y);else if(uD(N,i,l,f,y))y.stopPropagation();else if(HS(i,y),l&4&&-1<cD.indexOf(i)){for(;N!==null;){var L=so(N);if(L!==null)switch(L.tag){case 3:if(L=L.stateNode,L.current.memoizedState.isDehydrated){var K=wn(L.pendingLanes);if(K!==0){var ee=L;for(ee.pendingLanes|=2,ee.entangledLanes|=2;K;){var le=1<<31-fe(K);ee.entanglements[1]|=le,K&=~le}bs(L),($t&6)===0&&(pd=Pe()+500,cc(0))}}break;case 31:case 13:ee=ca(L,2),ee!==null&&mr(ee,L,2),xd(),ng(L,2)}if(L=sg(y),L===null&&Up(i,l,y,Rd,f),L===N)break;N=L}N!==null&&y.stopPropagation()}else Up(i,l,y,null,f)}}function sg(i){return i=am(i),ig(i)}var Rd=null;function ig(i){if(Rd=null,i=ro(i),i!==null){var l=o(i);if(l===null)i=null;else{var f=l.tag;if(f===13){if(i=c(l),i!==null)return i;i=null}else if(f===31){if(i=u(l),i!==null)return i;i=null}else if(f===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;i=null}else l!==i&&(i=null)}}return Rd=i,null}function zS(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 ue:return 2;case De:return 8;case qe:case pe:return 32;case he:return 268435456;default:return 32}default:return 32}}var ag=!1,Oi=null,Ii=null,Mi=null,gc=new Map,xc=new Map,Pi=[],cD="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 HS(i,l){switch(i){case"focusin":case"focusout":Oi=null;break;case"dragenter":case"dragleave":Ii=null;break;case"mouseover":case"mouseout":Mi=null;break;case"pointerover":case"pointerout":gc.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":xc.delete(l.pointerId)}}function yc(i,l,f,y,N,L){return i===null||i.nativeEvent!==L?(i={blockedOn:l,domEventName:f,eventSystemFlags:y,nativeEvent:L,targetContainers:[N]},l!==null&&(l=so(l),l!==null&&BS(l)),i):(i.eventSystemFlags|=y,l=i.targetContainers,N!==null&&l.indexOf(N)===-1&&l.push(N),i)}function uD(i,l,f,y,N){switch(l){case"focusin":return Oi=yc(Oi,i,l,f,y,N),!0;case"dragenter":return Ii=yc(Ii,i,l,f,y,N),!0;case"mouseover":return Mi=yc(Mi,i,l,f,y,N),!0;case"pointerover":var L=N.pointerId;return gc.set(L,yc(gc.get(L)||null,i,l,f,y,N)),!0;case"gotpointercapture":return L=N.pointerId,xc.set(L,yc(xc.get(L)||null,i,l,f,y,N)),!0}return!1}function FS(i){var l=ro(i.target);if(l!==null){var f=o(l);if(f!==null){if(l=f.tag,l===13){if(l=c(f),l!==null){i.blockedOn=l,Te(i.priority,function(){$S(f)});return}}else if(l===31){if(l=u(f),l!==null){i.blockedOn=l,Te(i.priority,function(){$S(f)});return}}else if(l===3&&f.stateNode.current.memoizedState.isDehydrated){i.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Od(i){if(i.blockedOn!==null)return!1;for(var l=i.targetContainers;0<l.length;){var f=sg(i.nativeEvent);if(f===null){f=i.nativeEvent;var y=new f.constructor(f.type,f);im=y,f.target.dispatchEvent(y),im=null}else return l=so(f),l!==null&&BS(l),i.blockedOn=f,!1;l.shift()}return!0}function US(i,l,f){Od(i)&&f.delete(l)}function dD(){ag=!1,Oi!==null&&Od(Oi)&&(Oi=null),Ii!==null&&Od(Ii)&&(Ii=null),Mi!==null&&Od(Mi)&&(Mi=null),gc.forEach(US),xc.forEach(US)}function Id(i,l){i.blockedOn===l&&(i.blockedOn=null,ag||(ag=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,dD)))}var Md=null;function VS(i){Md!==i&&(Md=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Md===i&&(Md=null);for(var l=0;l<i.length;l+=3){var f=i[l],y=i[l+1],N=i[l+2];if(typeof y!="function"){if(ig(y||f)===null)continue;break}var L=so(f);L!==null&&(i.splice(l,3),l-=3,sp(L,{pending:!0,data:N,method:f.method,action:y},y,N))}}))}function zo(i){function l(le){return Id(le,i)}Oi!==null&&Id(Oi,i),Ii!==null&&Id(Ii,i),Mi!==null&&Id(Mi,i),gc.forEach(l),xc.forEach(l);for(var f=0;f<Pi.length;f++){var y=Pi[f];y.blockedOn===i&&(y.blockedOn=null)}for(;0<Pi.length&&(f=Pi[0],f.blockedOn===null);)FS(f),f.blockedOn===null&&Pi.shift();if(f=(i.ownerDocument||i).$$reactFormReplay,f!=null)for(y=0;y<f.length;y+=3){var N=f[y],L=f[y+1],K=N[Qe]||null;if(typeof L=="function")K||VS(f);else if(K){var ee=null;if(L&&L.hasAttribute("formAction")){if(N=L,K=L[Qe]||null)ee=K.formAction;else if(ig(N)!==null)continue}else ee=K.action;typeof ee=="function"?f[y+1]=ee:(f.splice(y,3),y-=3),VS(f)}}}function GS(){function i(L){L.canIntercept&&L.info==="react-transition"&&L.intercept({handler:function(){return new Promise(function(K){return N=K})},focusReset:"manual",scroll:"manual"})}function l(){N!==null&&(N(),N=null),y||setTimeout(f,20)}function f(){if(!y&&!navigation.transition){var L=navigation.currentEntry;L&&L.url!=null&&navigation.navigate(L.url,{state:L.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(f,100),function(){y=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),N!==null&&(N(),N=null)}}}function og(i){this._internalRoot=i}Pd.prototype.render=og.prototype.render=function(i){var l=this._internalRoot;if(l===null)throw Error(r(409));var f=l.current,y=Er();MS(f,y,i,l,null,null)},Pd.prototype.unmount=og.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var l=i.containerInfo;MS(i.current,2,null,i,null,null),xd(),l[rt]=null}};function Pd(i){this._internalRoot=i}Pd.prototype.unstable_scheduleHydration=function(i){if(i){var l=rn();i={blockedOn:null,target:i,priority:l};for(var f=0;f<Pi.length&&l!==0&&l<Pi[f].priority;f++);Pi.splice(f,0,i),f===0&&FS(i)}};var WS=t.version;if(WS!=="19.2.8")throw Error(r(527,WS,"19.2.8"));Q.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?p(i):null,i=i===null?null:i.stateNode,i};var hD={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Bd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bd.isDisabled&&Bd.supportsFiber)try{et=Bd.inject(hD),it=Bd}catch{}}return vc.createRoot=function(i,l){if(!a(i))throw Error(r(299));var f=!1,y="",N=Z_,L=e0,K=t0;return l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(y=l.identifierPrefix),l.onUncaughtError!==void 0&&(N=l.onUncaughtError),l.onCaughtError!==void 0&&(L=l.onCaughtError),l.onRecoverableError!==void 0&&(K=l.onRecoverableError)),l=OS(i,1,!1,null,null,f,y,null,N,L,K,GS),i[rt]=l.current,Fp(i),new og(l)},vc.hydrateRoot=function(i,l,f){if(!a(i))throw Error(r(299));var y=!1,N="",L=Z_,K=e0,ee=t0,le=null;return f!=null&&(f.unstable_strictMode===!0&&(y=!0),f.identifierPrefix!==void 0&&(N=f.identifierPrefix),f.onUncaughtError!==void 0&&(L=f.onUncaughtError),f.onCaughtError!==void 0&&(K=f.onCaughtError),f.onRecoverableError!==void 0&&(ee=f.onRecoverableError),f.formState!==void 0&&(le=f.formState)),l=OS(i,1,!0,l,f??null,y,N,le,L,K,ee,GS),l.context=IS(null),f=l.current,y=Er(),y=tt(y),N=Si(y),N.callback=null,wi(f,N,y),f=y,l.current.lanes=f,Ce(l,f),bs(l),i[rt]=l.current,Fp(i),new Pd(l)},vc.version="19.2.8",vc}var sw;function ED(){if(sw)return hg.exports;sw=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(),hg.exports=jD(),hg.exports}var ND=ED();const TD=uf(ND);function AD(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 gg={exports:{}},xg={};/**
|
|
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 iw;function LD(){if(iw)return xg;iw=1;var e=df();function t(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&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(m,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})},[m,x,g]),a(function(){return d(C)&&v({inst:C}),m(function(){d(C)&&v({inst:C})})},[m]),c(x),x}function d(m){var g=m.getSnapshot;m=m.value;try{var x=g();return!n(m,x)}catch{return!0}}function h(m,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;return xg.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,xg}var aw;function DD(){return aw||(aw=1,gg.exports=LD()),gg.exports}var RD=DD();const OD=SD.useInsertionEffect,ID=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",MD=ID?j.useLayoutEffect:j.useEffect,PD=OD||MD,Dk=e=>{const t=j.useRef([e,(...n)=>t[0](...n)]).current;return PD(()=>{t[0]=e}),t[1]},BD="popstate",jy="pushState",Ey="replaceState",$D="hashchange",ow=[BD,jy,Ey,$D],zD=e=>{for(const t of ow)addEventListener(t,e);return()=>{for(const t of ow)removeEventListener(t,e)}},Rk=(e,t)=>RD.useSyncExternalStore(zD,e,t),lw=()=>location.search,HD=({ssrSearch:e}={})=>Rk(lw,e!=null?()=>e:lw),cw=()=>location.pathname,FD=({ssrPath:e}={})=>Rk(cw,e!=null?()=>e:cw),UD=(e,{replace:t=!1,state:n=null}={})=>history[t?Ey:jy](n,"",e),VD=(e={})=>[FD(e),UD],uw=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[uw]>"u"){for(const e of[jy,Ey]){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,uw,{value:!0})}const GD=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",Ok=(e="")=>e==="/"?"":e,WD=(e,t)=>e[0]==="~"?e.slice(1):Ok(t)+e,qD=(e="",t)=>GD(dw(Ok(e)),dw(t)),dw=e=>{try{return decodeURI(e)}catch{return e}},Ik={hook:VD,searchHook:HD,parser:AD,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},Mk=j.createContext(Ik),bl=()=>j.useContext(Mk),Pk={},Bk=j.createContext(Pk),KD=()=>j.useContext(Bk),hf=e=>{const[t,n]=e.hook(e);return[qD(e.base,t),Dk((r,a)=>e.aroundNav(n,WD(r,e.base),a))]},Pn=()=>hf(bl()),Ny=(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((m,g)=>[m,d[g]])):c.groups;let p={...d};return h&&Object.assign(p,h),p})(),...r?[u]:[]]:[!1,null]},vl=e=>Ny(bl().parser,e,Pn()[0]),$k=({children:e,...t})=>{var p,m,g;const n=bl(),r=t.hook?Ik:n;let a=r;const[o,c=t.ssrSearch??""]=((p=t.ssrPath)==null?void 0:p.split("?"))??[];o&&(t.ssrSearch=c,t.ssrPath=o),t.hrefs=t.hrefs??((m=t.hook)==null?void 0:m.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(Mk.Provider,{value:a,children:e})},hw=({children:e,component:t},n)=>t?j.createElement(t,{params:n}):typeof e=="function"?e(n):e,YD=e=>{let t=j.useRef(Pk);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},_c=({path:e,nest:t,match:n,...r})=>{const a=bl(),[o]=hf(a),[c,u,d]=n??Ny(a.parser,e,o,t),h=YD({...KD(),...u});if(!c)return null;const p=d?j.createElement($k,{base:d},hw(r,h)):hw(r,h);return j.createElement(Bk.Provider,{value:h,children:p})},lr=j.forwardRef((e,t)=>{const n=bl(),[r,a]=hf(n),{to:o="",href:c=o,onClick:u,asChild:d,children:h,className:p,replace:m,state:g,transition:x,...w}=e,C=Dk(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:p!=null&&p.call?p(r===c):p,children:h,ref:t})}),zk=e=>Array.isArray(e)?e.flatMap(t=>zk(t&&t.type===j.Fragment?t.props.children:t)):[e],XD=({children:e,location:t})=>{const n=bl(),[r]=hf(n);for(const a of zk(e)){let o=0;if(j.isValidElement(a)&&(o=Ny(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 Ar=(e,t)=>{const{o:n,i:r,u:a}=e;let o=n,c;const u=(p,m)=>{const g=o,x=p,w=m||(r?!r(g,x):g!==x);return(w||a)&&(o=x,c=g),[o,w,c]};return[t?p=>u(t(o,c),p):u,p=>[o,!!p,c]]},JD=typeof window<"u"&&typeof HTMLElement<"u"&&!!window.document,yr=JD?window:{},Hk=Math.max,QD=Math.min,jx=Math.round,Wi=Math.abs,fw=Math.sign,Fk=yr.cancelAnimationFrame,Ty=yr.requestAnimationFrame,Ay=yr.setTimeout,Uk=yr.clearTimeout,ff=e=>typeof yr[e]<"u"?yr[e]:void 0,ZD=ff("MutationObserver"),mw=ff("IntersectionObserver"),el=ff("ResizeObserver"),Bc=ff("ScrollTimeline"),Ly=e=>e===void 0,mf=e=>e===null,Yi=e=>typeof e=="number",_l=e=>typeof e=="string",pf=e=>typeof e=="boolean",ps=e=>typeof e=="function",Zr=e=>Array.isArray(e),Nh=e=>typeof e=="object"&&!Zr(e)&&!mf(e),Dy=e=>{const t=!!e&&e.length,n=Yi(t)&&t>-1&&t%1==0;return Zr(e)||!ps(e)&&n?t>0&&Nh(e)?t-1 in e:!0:!1},Jc=e=>!!e&&e.constructor===Object,Th=e=>e instanceof HTMLElement,gf=e=>e instanceof Element;function Xt(e,t){if(Dy(e))for(let n=0;n<e.length&&t(e[n],n,e)!==!1;n++);else e&&Xt(Object.keys(e),(n=>t(e[n],n,e)));return e}const Vk=(e,t)=>e.indexOf(t)>=0,dl=(e,t)=>e.concat(t),hn=(e,t,n)=>(!_l(t)&&Dy(t)?Array.prototype.push.apply(e,t):e.push(t),e),ea=e=>Array.from(e||[]),Ry=e=>Zr(e)?e:!_l(e)&&Dy(e)?ea(e):[e],Ah=e=>!!e&&!e.length,Lh=e=>ea(new Set(e)),Dr=(e,t,n)=>{Xt(e,a=>a?a.apply(void 0,t||[]):!0),n||(e.length=0)},Gk="paddingTop",Wk="paddingRight",qk="paddingLeft",Kk="paddingBottom",Yk="marginLeft",Xk="marginRight",Jk="marginBottom",Oy="overflowX",Iy="overflowY",xf="width",yf="height",ai="visible",as="hidden",Fa="scroll",eR=e=>{const t=String(e||"");return t?t[0].toUpperCase()+t.slice(1):""},bf=(e,t,n,r)=>{if(e&&t){let a=!0;return Xt(n,(o=>{const c=e[o],u=t[o];c!==u&&(a=!1)})),a}return!1},Qk=(e,t)=>bf(e,t,["w","h"]),xh=(e,t)=>bf(e,t,["x","y"]),tR=(e,t)=>bf(e,t,["t","r","b","l"]),ft=(e,...t)=>e.bind(0,...t),tl=e=>{let t;const n=e?Ay:Ty,r=e?Uk:Fk;return[a=>{r(t),t=n((()=>a()),ps(e)?e():e)},()=>r(t)]},pw=e=>{const t=ps(e)?e():e;if(Yi(t)){const n=t?Ay:Ty,r=t?Uk:Fk;return a=>{const o=n((()=>a()),t);return()=>{r(o)}}}return t&&t._},Zk=(e,t)=>{const{p:n,v:r,S:a,m:o}=t||{};let c,u,d,h;const p=function(C){u&&u(),c&&c(),h=u=c=d=void 0,e.apply(this,C)},m=w=>o&&d?o(d,w):w,g=()=>{u&&d&&p(m(d)||d)},x=function(){const C=ea(arguments),v=pw(n);if(v){const S=typeof a=="function"?a():a,_=pw(r),k=m(C)||C,E=p.bind(0,k);u&&u(),S&&!h?(E(),h=!0,u=v((()=>h=void 0))):(u=v(E),_&&!c&&(c=_(g))),d=k}else p(C)};return x.O=g,x},ej=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),gr=e=>e?Object.keys(e):[],Bt=(e,t,n,r,a,o,c)=>{const u=[t,n,r,a,o,c];return(typeof e!="object"||mf(e))&&!ps(e)&&(e={}),Xt(u,(d=>{Xt(d,((h,p)=>{const m=d[p];if(e===m)return!0;const g=Zr(m);if(m&&Jc(m)){const x=e[p];let w=x;g&&!Zr(x)?w=[]:!g&&!Jc(x)&&(w={}),e[p]=Bt(w,m)}else e[p]=g?m.slice():m}))})),e},tj=(e,t)=>Xt(Bt({},e),((n,r,a)=>{n===void 0?delete a[r]:n&&Jc(n)&&(a[r]=tj(n))})),My=e=>!gr(e).length,Qc=()=>{},nj=(e,t,n)=>Hk(e,QD(t,n)),Ua=e=>Lh((Zr(e)?e:(e||"").split(" ")).filter((t=>t))),Py=(e,t)=>e&&e.getAttribute(t),gw=(e,t)=>e&&e.hasAttribute(t),ri=(e,t,n)=>{Xt(Ua(t),(r=>{e&&e.setAttribute(r,String(n||""))}))},Ss=(e,t)=>{Xt(Ua(t),(n=>e&&e.removeAttribute(n)))},vf=(e,t)=>{const n=Ua(Py(e,t)),r=ft(ri,e,t),a=(o,c)=>{const u=new Set(n);return Xt(Ua(o),(d=>{u[c](d)})),ea(u).join(" ")};return{C:o=>r(a(o,"delete")),$:o=>r(a(o,"add")),H:o=>{const c=Ua(o);return c.reduce(((u,d)=>u&&n.includes(d)),c.length>0)}}},rj=(e,t,n)=>(vf(e,t).C(n),ft(By,e,t,n)),By=(e,t,n)=>(vf(e,t).$(n),ft(rj,e,t,n)),Dh=(e,t,n,r)=>(r?By:rj)(e,t,n),$y=(e,t,n)=>vf(e,t).H(n),sj=e=>vf(e,"class"),ij=(e,t)=>{sj(e).C(t)},zy=(e,t)=>(sj(e).$(t),ft(ij,e,t)),aj=(e,t)=>{const n=t?gf(t)&&t:document;return n?ea(n.querySelectorAll(e)):[]},nR=(e,t)=>{const n=t?gf(t)&&t:document;return n&&n.querySelector(e)},Ex=(e,t)=>gf(e)&&e.matches(t),oj=e=>Ex(e,"body"),Nx=e=>e?ea(e.childNodes):[],Zc=e=>e&&e.parentElement,nl=(e,t)=>gf(e)&&e.closest(t),Tx=e=>document.activeElement,rR=(e,t,n)=>{const r=nl(e,t),a=e&&nR(n,r),o=nl(a,t)===r;return r&&a?r===e||a===e||o&&nl(nl(e,n),t)!==r:!1},hl=e=>{Xt(Ry(e),(t=>{const n=Zc(t);t&&n&&n.removeChild(t)}))},xr=(e,t)=>ft(hl,e&&t&&Xt(Ry(t),(n=>{n&&e.appendChild(n)})));let lj;const sR=()=>lj,iR=e=>{lj=e},il=e=>{const t=document.createElement("div");return ri(t,"class",e),t},cj=e=>{const t=il(),n=sR(),r=e.trim();return t.innerHTML=n?n.createHTML(r):r,Xt(Nx(t),(a=>hl(a)))},xw=(e,t)=>e.getPropertyValue(t)||e[t]||"",uj=e=>{const t=e||0;return isFinite(t)?t:0},$d=e=>uj(parseFloat(e||"")),Ax=e=>Math.round(e*1e4)/1e4,dj=e=>`${Ax(uj(e))}px`;function eu(e,t){e&&t&&Xt(t,((n,r)=>{try{const a=e.style,o=mf(n)||pf(n)?"":Yi(n)?dj(n):n;r.indexOf("--")===0?a.setProperty(r,o):a[r]=o}catch{}}))}function As(e,t,n){const r=_l(t);let a=r?"":{};if(e){const o=yr.getComputedStyle(e,n)||e.style;a=r?xw(o,t):ea(t).reduce(((c,u)=>(c[u]=xw(o,u),c)),a)}return a}const yw=(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=As(e,[o,c,u,d]);return{t:$d(h[o]),r:$d(h[c]),b:$d(h[u]),l:$d(h[d])}},yg=(e,t)=>`translate${Nh(e)?`(${e.x},${e.y})`:`${t?"X":"Y"}(${e})`}`,aR=e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length),oR={w:0,h:0},_f=(e,t)=>t?{w:t[`${e}Width`],h:t[`${e}Height`]}:oR,lR=e=>_f("inner",e||yr),al=ft(_f,"offset"),hj=ft(_f,"client"),Rh=ft(_f,"scroll"),Hy=e=>{const t=parseFloat(As(e,xf))||0,n=parseFloat(As(e,yf))||0;return{w:t-jx(t),h:n-jx(n)}},bg=e=>e.getBoundingClientRect(),cR=e=>!!e&&aR(e),Lx=e=>!!(e&&(e[yf]||e[xf])),fj=(e,t)=>{const n=Lx(e);return!Lx(t)&&n},bw=(e,t,n,r)=>{Xt(Ua(t),(a=>{e&&e.removeEventListener(a,n,r)}))},on=(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 ft(Dr,Ua(t).map((h=>{const p=u?m=>{bw(e,h,p,c),n&&n(m)}:n;return e&&e.addEventListener(h,p,d),ft(bw,e,h,p,c)})))},mj=e=>e.stopPropagation(),Dx=e=>e.preventDefault(),pj=e=>mj(e)||Dx(e),Es=(e,t)=>{const{x:n,y:r}=Yi(t)?{x:t,y:t}:t||{};Yi(n)&&(e.scrollLeft=n),Yi(r)&&(e.scrollTop=r)},Lr=e=>({x:e.scrollLeft,y:e.scrollTop}),gj=()=>({T:{x:0,y:0},k:{x:0,y:0}}),uR=(e,t)=>{const{T:n,k:r}=e,{w:a,h:o}=t,c=(m,g,x)=>{let w=fw(m)*x,C=fw(g)*x;if(w===C){const v=Wi(m),S=Wi(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,p]=c(n.y,r.y,o);return{T:{x:u,y:h},k:{x:d,y:p}}},vg=({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)}},vw=({T:e,k:t},n)=>{const r=(a,o,c)=>nj(0,1,(a-c)/(a-o)||0);return{x:r(e.x,t.x,n.x),y:r(e.y,t.y,n.y)}},Rx=e=>{e&&e.focus&&e.focus({preventScroll:!0,focusVisible:!1})},_w=(e,t)=>{Xt(Ry(t),e)},Ox=e=>{const t=new Map,n=(o,c)=>{if(o){const u=t.get(o);_w((d=>{u&&u[d?"delete":"clear"](d)}),c)}else t.forEach((u=>{u.clear()})),t.clear()},r=(o,c)=>{if(_l(o)){const h=t.get(o)||new Set;return t.set(o,h),_w((p=>{ps(p)&&h.add(p)}),c),ft(n,o,c)}pf(c)&&c&&n();const u=gr(o),d=[];return Xt(u,(h=>{const p=o[h];p&&hn(d,r(h,p))})),ft(Dr,d)},a=(o,c)=>{Xt(ea(t.get(o)),(u=>{c&&!Ah(c)?u.apply(0,c):u()}))};return r(e||{}),[r,n,a]},xj={},yj={},dR=e=>{Xt(e,(t=>Xt(t,((n,r)=>{xj[r]=t[r]}))))},bj=(e,t,n)=>gr(e).map((r=>{const{static:a,instance:o}=e[r],[c,u,d]=n||[],h=n?o:a;if(h){const p=n?h(c,u,t):h(t);return(d||yj)[r]=p}})),hR=(e,t)=>e[t],Sl=e=>hR(yj,e),fR="__osOptionsValidationPlugin",wl="data-overlayscrollbars",yh="os-environment",zd=`${yh}-scrollbar-hidden`,_g=`${wl}-initialize`,bh="noClipping",Sw=`${wl}-body`,Xi=wl,mR="host",si=`${wl}-viewport`,pR=Oy,gR=Iy,xR="arrange",vj="measuring",yR="scrolling",_j="scrollbarHidden",bR="noContent",Ix=`${wl}-padding`,ww=`${wl}-content`,Fy="os-size-observer",vR=`${Fy}-appear`,_R=`${Fy}-listener`,SR="os-trinsic-observer",wR="os-theme-none",Or="os-scrollbar",CR=`${Or}-rtl`,kR=`${Or}-horizontal`,jR=`${Or}-vertical`,Sj=`${Or}-track`,Uy=`${Or}-handle`,ER=`${Or}-visible`,NR=`${Or}-cornerless`,Cw=`${Or}-interaction`,kw=`${Or}-unusable`,Mx=`${Or}-auto-hide`,TR=`${Mx}-hidden`,jw=`${Or}-wheel`,AR=`${Sj}-interactive`,LR=`${Uy}-interactive`,DR="__osSizeObserverPlugin",RR=(e,t)=>{const{M:n}=t,[r,a]=e("showNativeOverlaidScrollbars");return[r&&n.x&&n.y,a]},rl=e=>e.indexOf(ai)===0,OR=e=>e.replace(`${ai}-`,""),Px=(e,t)=>{if(e==="auto")return t?Fa:as;const n=e||as;return[as,Fa,ai].includes(n)?n:as},IR=(e,t)=>{const{overflowX:n,overflowY:r}=As(e,[Oy,Iy]);return{x:Px(n,t.x),y:Px(r,t.y)}},Vy="__osScrollbarsHidingPlugin",MR="__osClickScrollPlugin",Ew=e=>JSON.stringify(e,((t,n)=>{if(ps(n))throw 0;return n})),Nw=(e,t)=>e?`${t}`.split(".").reduce(((n,r)=>n&&ej(n,r)?n[r]:void 0),e):void 0,PR=[0,33],wj=[33,99],Cj=[222,666,!0],BR={paddingAbsolute:!1,showNativeOverlaidScrollbars:!1,update:{elementEvents:[["img","load"]],debounce:{mutation:PR,resize:null,event:wj,env:Cj},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"]}},kj=(e,t)=>{const n={},r=dl(gr(t),gr(e));return Xt(r,(a=>{const o=e[a],c=t[a];if(Nh(o)&&Nh(c))Bt(n[a]={},kj(o,c)),My(n[a])&&delete n[a];else if(ej(t,a)&&c!==o){let u=!0;if(Zr(o)||Zr(c))try{Ew(o)===Ew(c)&&(u=!1)}catch{}u&&(n[a]=c)}})),n},Sg=(e,t,n)=>r=>[Nw(e,r),n||Nw(t,r)!==void 0];let jj;const $R=()=>jj,zR=e=>{jj=e};let wg;const HR=()=>{const e=(k,E,T)=>{xr(document.body,k),xr(document.body,k);const D=hj(k),A=al(k),R=Hy(E);return T&&hl(k),{x:A.h-D.h+R.h,y:A.w-D.w+R.w}},t=k=>{let E=!1;const T=zy(k,zd);try{E=As(k,"scrollbar-width")==="none"||As(k,"display","::-webkit-scrollbar")==="none"}catch{}return T(),E},n=`.${yh}{scroll-behavior:auto!important;position:fixed;opacity:0;visibility:hidden;overflow:scroll;height:200px;width:200px;z-index:-1}.${yh} 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=cj(`<div class="${yh}"><div></div><style>${n}</style></div>`)[0],o=a.firstChild,c=a.lastChild,u=$R();u&&(c.nonce=u);const[d,,h]=Ox(),[p,m]=Ar({o:e(a,o),i:xh},ft(e,a,o,!0)),[g]=m(),x=t(a),w={x:g.x===0,y:g.y===0},C={elements:{host:null,padding:!x,viewport:k=>x&&oj(k)&&k,content:!1},scrollbars:{slot:!0},cancel:{nativeScrollbarsOverlaid:!1,body:null}},v=Bt({},BR),S=ft(Bt,{},v),_=ft(Bt,{},C),b={U:g,M:w,P:x,J:!!Bc,G:ft(d,"r"),K:_,Z:k=>Bt(C,k)&&_(),tt:S,nt:k=>Bt(v,k)&&S(),ot:Bt({},C),st:Bt({},v)};if(Ss(a,"style"),hl(a),on(yr,"resize",(()=>{h("r",[])})),ps(yr.matchMedia)&&!x&&(!w.x||!w.y)){const k=E=>{const T=yr.matchMedia(`(resolution: ${yr.devicePixelRatio}dppx)`);on(T,"change",(()=>{E(),k(E)}),{A:!0})};k((()=>{const[E,T]=p();Bt(b.U,E),h("r",[T])}))}return b},Ls=()=>(wg||(wg=HR()),wg),FR=(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[p,m]=h||[];return[m&&p?(u||aj)(p,e):[],m]}));Xt(d,(h=>Xt(h[0],(p=>{const m=h[1],g=a.get(p)||[];if(e.contains(p)&&m){const w=on(p,m,(C=>{r?(w(),a.delete(p)):t(C)}));a.set(p,hn(g,w))}else Dr(g),a.delete(p)}))))}};return c(),[o,c]},Tw=(e,t,n,r)=>{let a=!1;const{et:o,ct:c,rt:u,it:d,lt:h,ut:p}=r||{},[m,g]=FR(e,(()=>a&&n(!0)),u),x=o||[],w=c||[],C=dl(x,w),v=(_,b)=>{if(!Ah(b)){const k=h||Qc,E=p||Qc,T=[],D=[];let A=!1,R=!1;if(Xt(b,(M=>{const{attributeName:W,target:$,type:G,oldValue:B,addedNodes:H,removedNodes:q}=M,Q=G==="attributes",J=G==="childList",U=e===$,I=Q&&W,O=I&&Py($,W||""),V=_l(O)?O:null,z=I&&B!==V,Y=Vk(w,W)&&z;if(t&&(J||!U)){const X=Q&&z,Z=X&&d&&Ex($,d),P=(Z?!k($,W,B,V):!Q||X)&&!E(M,!!Z,e,r);Xt(H,(te=>hn(T,te))),Xt(q,(te=>hn(T,te))),R=R||P}!t&&U&&z&&!k($,W,B,V)&&(hn(D,W),A=A||Y)})),g((M=>Lh(T).reduce(((W,$)=>(hn(W,aj(M,$)),Ex($,M)?hn(W,$):W)),[]))),t)return!_&&R&&n(!1),[!1];if(!Ah(D)||A){const M=[Lh(D),A];return _||n.apply(0,M),M}}},S=new ZD(ft(v,!1));return[()=>(S.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:C,subtree:t,childList:t,characterData:t}),a=!0,()=>{a&&(m(),S.disconnect(),a=!1)}),()=>{if(a)return v(!0,S.takeRecords())}]};let wa=null;const Ej=(e,t,n)=>{const{ft:r}=n||{},a=Sl(DR),[o]=Ar({o:!1,u:!0});return()=>{const c=[],d=cj(`<div class="${Fy}"><div class="${_R}"></div></div>`)[0],h=d.firstChild,p=m=>{const g=Zr(m)&&!Ah(m);let x=!1,w=!1;if(g){const C=m[0],[v,,S]=o(C.contentRect),_=Lx(v);w=fj(v,S),x=!w&&!_}else w=m===!0;x||t({_t:!0,ft:w})};if(el){if(!pf(wa)){const w=new el(Qc);w.observe(e,{get box(){wa=!0}}),wa=wa||!1,w.disconnect()}const m=Zk(p,{p:0,v:0}),g=w=>m(w),x=new el(g);if(x.observe(wa?e:h),hn(c,[()=>{x.disconnect()},!wa&&xr(e,d)]),wa){const w=new el(g);w.observe(e,{box:"border-box"}),hn(c,(()=>w.disconnect()))}}else if(a){const[m,g]=a(h,p,r);hn(c,dl([zy(d,vR),on(d,"animationstart",m),xr(e,d)],g))}else return Qc;return ft(Dr,c)}},UR=(e,t)=>{let n;const r=d=>d.h===0||d.isIntersecting||d.intersectionRatio>0,a=il(SR),[o]=Ar({o:!1}),c=(d,h)=>{if(d){const p=o(r(d)),[,m]=p;return m&&!h&&t(p)&&[p]}},u=(d,h)=>c(h.pop(),d);return[()=>{const d=[];if(mw)n=new mw(ft(u,!1),{root:e}),n.observe(a),hn(d,(()=>{n.disconnect()}));else{const h=()=>{const p=al(a);c(p)};hn(d,Ej(a,h)()),h()}return ft(Dr,hn(d,xr(e,a)))},()=>n&&u(!0,n.takeRecords())]},VR=(e,t,n,r)=>{let a,o,c,u,d,h,p,m;const g=`[${Xi}]`,x=`[${si}]`,w=["id","class","style","open","wrap","cols","rows"],{dt:C,vt:v,L:S,gt:_,ht:b,V:k,bt:E,yt:T,wt:D,St:A}=e,R=F=>As(F,"direction")==="rtl",M=()=>{let F,P,te;const se=Zk(r,{p:()=>F,v:()=>P,S:()=>te,m(ae,ye){const[_e]=ae,[Ie]=ye;return[dl(gr(_e),gr(Ie)).reduce(((He,je)=>(He[je]=_e[je]||Ie[je],He)),{})]}}),re=(ae,ye)=>{if(Zr(ye)){const[_e,Ie,He]=ye;F=_e,P=Ie,te=He}else Yi(ye)?(F=ye,P=!1,te=!1):(F=!1,P=!1,te=!1);se(ae)};return re.O=se.O,re},W={Ot:!1,B:R(C)},$=Ls(),G=Sl(Vy),[B]=Ar({i:Qk,o:{w:0,h:0}},(()=>{const F=G&&G.R(e,t,W,$,n).Y,te=!(E&&k)&&$y(v,Xi,bh),se=!k&&T(xR),re=se&&Lr(_),ae=re&&A(),ye=D(vj,te),_e=se&&F&&F(),Ie=Rh(S),He=Hy(S);return _e&&_e(),Es(_,re),ae&&ae(),te&&ye(),{w:Ie.w+He.w,h:Ie.h+He.h}})),H=M(),q=F=>{const P=R(C);Bt(F,{Ct:m!==P}),Bt(W,{B:P}),m=P},Q=(F,P)=>{const[te,se]=F,re={$t:se};return Bt(W,{Ot:te}),P||r(re),re},J=({_t:F,ft:P})=>{const te=P?r:H,se={_t:F||P,ft:P};q(se),te(se,o)},U=(F,P)=>{const[,te]=B(),se={xt:te};return q(se),te&&!P&&H(se,F?c:a),se},I=(F,P,te)=>{const se={Ht:P};return q(se),P&&!te&&H(se,a),se},[O,V]=b?UR(v,Q):[],z=!k&&Ej(v,J,{ft:!0}),[Y,X]=Tw(v,!1,I,{ct:w,et:w}),Z=k&&el&&new el((F=>{const P=F[F.length-1].contentRect;J({_t:!0,ft:fj(P,p)}),p=P}));return[()=>{Z&&Z.observe(v);const F=z&&z(),P=O&&O(),te=Y(),se=$.G((re=>{const[,ae]=B();H({Et:re,xt:ae,_t:E},u)}));return()=>{Z&&Z.disconnect(),F&&F(),P&&P(),h&&h(),te(),se()}},({Dt:F,zt:P,It:te})=>{const se={},[re]=F("update.ignoreMutation"),[ae,ye]=F("update.attributes"),[_e,Ie]=F("update.elementEvents"),[He,je]=F("update.debounce"),Ge=Ie||ye,Ze=P||te,Se=be=>ps(re)&&!!re(be);if(Ge){d&&d(),h&&h();const[be,de]=Tw(b||S,!0,U,{et:dl(w,ae||[]),rt:_e,it:g,ut:(ie,Pe)=>{const{target:Ue,attributeName:ue}=ie;return(!Pe&&ue&&!k?rR(Ue,g,x):!1)||!!nl(Ue,`.${Or}`)||Se(ie)}});h=be(),d=de}if(je&&(H.O(),Zr(He)||Yi(He)?(a=He,o=!1,c=wj,u=Cj):Jc(He)?(a=He.mutation,o=He.resize,c=He.event,u=He.env):(a=!1,o=!1,c=!1,u=!1)),Ze){const be=X(),de=V&&V(),ie=d&&d();be&&Bt(se,I(be[0],be[1],Ze)),de&&Bt(se,Q(de[0],Ze)),ie&&Bt(se,U(ie[0],Ze))}return q(se),se},W]},Nj=(e,t)=>ps(t)?t.apply(0,e):t,GR=(e,t,n,r)=>{const a=Ly(r)?n:r;return Nj(e,a)||t.apply(0,e)},Tj=(e,t,n,r)=>{const a=Ly(r)?n:r,o=Nj(e,a);return!!o&&(Th(o)?o:t.apply(0,e))},WR=(e,t)=>{const{nativeScrollbarsOverlaid:n,body:r}=t||{},{M:a,P:o,K:c}=Ls(),{nativeScrollbarsOverlaid:u,body:d}=c().cancel,h=n??u,p=Ly(r)?d:r,m=(a.x||a.y)&&h,g=e&&(mf(p)?!o:p);return!!m||!!g},qR=(e,t,n,r)=>{const a="--os-viewport-percent",o="--os-scroll-percent",c="--os-scroll-direction",{K:u}=Ls(),{scrollbars:d}=u(),{slot:h}=d,{dt:p,vt:m,L:g,At:x,gt:w,bt:C,V:v}=t,{scrollbars:S}=x?{}:e,{slot:_}=S||{},b=[],k=[],E=[],T=Tj([p,m,g],(()=>v&&C?p:m),h,_),D=O=>{if(Bc){let V=null,z=[];const Y=new Bc({source:w,axis:O}),X=()=>{V&&V.cancel(),V=null};return{Mt:F=>{const{Tt:P}=n,te=vg(P)[O],se=O==="x",re=[yg(0,se),yg(`calc(-100% + 100cq${se?"w":"h"})`,se)],ae=te?re:re.reverse();return z[0]===ae[0]&&z[1]===ae[1]||(z=ae,X(),V=F.kt.animate({clear:["left"],transform:ae},{timeline:Y})),X}}}},A={x:D("x"),y:D("y")},R=()=>{const{Rt:O,Vt:V}=n,z=(Y,X)=>nj(0,1,Y/(Y+X)||0);return{x:z(V.x,O.x),y:z(V.y,O.y)}},M=(O,V,z)=>{const Y=z?zy:ij;Xt(O,(X=>{Y(X.Lt,V)}))},W=(O,V)=>{Xt(O,(z=>{const[Y,X]=V(z);eu(Y,X)}))},$=(O,V,z)=>{const Y=pf(z),X=Y?z:!0,Z=Y?!z:!0;X&&M(k,O,V),Z&&M(E,O,V)},G=()=>{const O=R(),V=z=>Y=>[Y.Lt,{[a]:Ax(z)+""}];W(k,V(O.x)),W(E,V(O.y))},B=()=>{if(!Bc){const{Tt:O}=n,V=vw(O,Lr(w)),z=Y=>X=>[X.Lt,{[o]:Ax(Y)+""}];W(k,z(V.x)),W(E,z(V.y))}},H=()=>{const{Tt:O}=n,V=vg(O),z=Y=>X=>[X.Lt,{[c]:Y?"0":"1"}];W(k,z(V.x)),W(E,z(V.y)),Bc&&(k.forEach(A.x.Mt),E.forEach(A.y.Mt))},q=()=>{if(v&&!C){const{Rt:O,Tt:V}=n,z=vg(V),Y=vw(V,Lr(w)),X=Z=>{const{Lt:F}=Z,P=Zc(F)===g&&F,te=(se,re,ae)=>{const ye=re*se;return dj(ae?ye:-ye)};return[P,P&&{transform:yg({x:te(Y.x,O.x,z.x),y:te(Y.y,O.y,z.y)})}]};W(k,X),W(E,X)}},Q=O=>{const V=O?"x":"y",Y=il(`${Or} ${O?kR:jR}`),X=il(Sj),Z=il(Uy),F={Lt:Y,Pt:X,kt:Z},P=A[V];return hn(O?k:E,F),hn(b,[xr(Y,X),xr(X,Z),ft(hl,Y),P&&P.Mt(F),r(F,$,O)]),F},J=ft(Q,!0),U=ft(Q,!1),I=()=>(xr(T,k[0].Lt),xr(T,E[0].Lt),ft(Dr,b));return J(),U(),[{Ut:G,Nt:B,qt:H,Bt:q,Ft:$,jt:{Xt:k,Yt:J,Wt:ft(W,k)},Jt:{Xt:E,Yt:U,Wt:ft(W,E)}},I]},KR=(e,t,n,r,a)=>(o,c,u)=>{const{vt:d,L:h,V:p,gt:m,Gt:g,St:x}=t,{Lt:w,Pt:C,kt:v}=o,[S,_]=tl(333),[b,k]=tl(444),E=A=>{ps(m.scrollBy)&&m.scrollBy({behavior:"smooth",left:A.x,top:A.y})},T=()=>{const A="pointerup pointercancel lostpointercapture",R=`client${u?"X":"Y"}`,M=u?xf:yf,W=u?"left":"top",$=u?"w":"h",G=u?"x":"y",B=[];return on(C,"pointerdown",r((H=>{const q=nl(H.target,`.${Uy}`)===v,Q=q?v:C,J=e.scrollbars,U=J[q?"dragScroll":"clickScroll"],{button:I,isPrimary:O,pointerType:V}=H,{pointers:z}=J;if(I===0&&O&&U&&(z||[]).includes(V)){Dr(B),k();const X=!q&&(H.shiftKey||U==="instant"),Z=ft(bg,v),F=ft(bg,C),P=(Ue,ue)=>(Ue||Z())[W]-(ue||F())[W],te=jx(bg(m)[M])/al(m)[$]||1,se=Lr(m)[G],re=Ue=>{Es(m,{[G]:se+Ue})},ae=Ue=>{const{Rt:ue}=n,De=al(C)[$]-al(v)[$],qe=1/te*Ue/De;re(qe*ue[G])},ye=H[R],_e=Z(),Ie=F(),He=_e[M],je=P(_e,Ie)+He/2,Ze=ye-Ie[W]-je,Se=q?0:Ze,be=Ue=>{Dr(Pe),Q.releasePointerCapture(Ue.pointerId)},de=q||X,ie=x(),Pe=[on(g,A,be),on(g,"selectstart",(Ue=>Dx(Ue)),{D:!1}),on(C,A,be),de&&on(C,"pointermove",(Ue=>ae(Se+Ue[R]-ye))),de&&(()=>{const Ue=Lr(m);ie();const ue=Lr(m),De={x:ue.x-Ue.x,y:ue.y-Ue.y};(Wi(De.x)>3||Wi(De.y)>3)&&(x(),Es(m,Ue),E(De),b(ie))})];if(Q.setPointerCapture(H.pointerId),X)ae(Ze);else if(!q){const Ue=Sl(MR);if(Ue){const{Vt:ue}=n,De=Ue(re,ae,ft(P),Ze,ue[G],U,!!u,(qe=>{qe?ie():hn(Pe,ie)}));hn(Pe,De),hn(B,ft(De,!0))}}}})))};let D=!0;return ft(Dr,[on(v,"pointermove pointerleave",r(a)),on(w,"pointerenter",r((()=>{c(Cw,!0)}))),on(w,"pointerleave pointercancel",r((()=>{c(Cw,!1)}))),on(w,"wheel",r((A=>{const{deltaX:R,deltaY:M,deltaMode:W}=A;D&&W===0&&Zc(w)===d&&E({x:R,y:M}),D=!1,c(jw,!0),S((()=>{D=!0,c(jw)})),Dx(A)})),{D:!1,I:!0}),!p&&on(w,"mousedown",r((()=>{const A=Tx();(gw(A,si)||gw(A,Xi)||A===document.body)&&Ay(ft(Rx,h),25)}))),on(w,"pointerdown",(()=>{const A=on(g,"click",(M=>{R(),pj(M)}),{A:!0,I:!0,D:!1}),R=on(g,"pointerup pointercancel",(()=>{R(),setTimeout(A,150)}),{I:!0,D:!0})}),{I:!0,D:!0}),T(),_,k])},YR=(e,t,n,r,a,o,c)=>{let u,d,h,p,m,g=Qc,x=0;const w=["mouse","pen"],C=Z=>F=>{n.Kt||Z(F)},v=Z=>w.includes(Z.pointerType),[S,_]=tl(),[b,k]=tl(100),[E,T]=tl(50),[D,A]=tl((()=>x)),[R,M]=qR(e,o,a,KR(t,o,a,C,(Z=>v(Z)&&I()))),{vt:W,Qt:$,bt:G}=o,{Ft:B,Ut:H,Nt:q,qt:Q,Bt:J}=R,U=(Z,F)=>{A();const P=te=>{n.Kt||B(TR,te)};if(Z)P();else{const te=h?!u:!0;x>0&&!F?D(ft(P,te)):P(te)}},I=()=>{(h?!u:!p)&&(U(!0),b((()=>{U(!1)})))},O=Z=>{v(Z)&&(u=!0,!n.Kt&&h&&U(!0))},V=Z=>{v(Z)&&(u=!1,!n.Kt&&h&&U(!1))},z=Z=>{B(Mx,Z,!0),B(Mx,Z,!1)},Y=[A,k,T,_,()=>g(),on(W,"pointerover",O,{A:!0}),on(W,"pointerenter",O),on(W,"pointerleave",V),on(W,"pointermove",C((Z=>{v(Z)&&d&&I()}))),on($,"scroll",C((Z=>{S((()=>{q(),I()})),c(Z),J()})))],X=Sl(Vy);return[()=>ft(Dr,hn(Y,M())),({Dt:Z,It:F,Zt:P,tn:te})=>{const{nn:se,sn:re,en:ae,cn:ye}=te||{},{Ct:_e,ft:Ie}=P||{},{B:He}=r,{M:je,P:Ge}=Ls(),{rn:Ze,j:Se}=a,[be,de]=Z("showNativeOverlaidScrollbars"),[ie,Pe]=Z("scrollbars.theme"),[Ue,ue]=Z("scrollbars.visibility"),[De,qe]=Z("scrollbars.autoHide"),[pe,he]=Z("scrollbars.autoHideSuspend"),[We]=Z("scrollbars.autoHideDelay"),[Ve,et]=Z("scrollbars.dragScroll"),[it,ge]=Z("scrollbars.clickScroll"),[fe,Fe]=Z("overflow"),Xe=Ie&&!F,_t=se||re||ye||_e||F,Dt=ae||ue||Fe,Ct=be&&je.x&&je.y,Sn=!Ge&&!X,wn=Ct||Sn,fn=(Dn,Cn,dn)=>{const rr=Dn.includes(Fa)&&(Ue===ai||Ue==="auto"&&Cn===Fa);return B(ER,rr,dn),rr};if(x=We,(de||Sn)&&B(wR,wn),Pe&&(B(m),B(ie,!0),m=ie),(he||Xe)&&(z(!pe),Xe&&pe&&(Se.x||Se.y?(g(),E((()=>{g=on($,Fa,C(ft(z,!0)),{A:!0})}))):z(!0))),qe&&(d=De==="move",h=De==="leave",p=De==="never",U(p,!0)),et&&B(LR,Ve),ge&&B(AR,!!it),Dt){const Dn=fn(fe.x,Ze.x,!0),Cn=fn(fe.y,Ze.y,!1);B(NR,!(Dn&&Cn))}_t&&(q(),H(),J(),ye&&Q(),B(kw,!Se.x,!0),B(kw,!Se.y,!1),B(CR,He&&!G))},{},R]},XR=e=>{const t=Ls(),{K:n,P:r}=t,{elements:a}=n(),{padding:o,viewport:c,content:u}=a,d=Th(e),h=d?{}:e,{elements:p}=h,{padding:m,viewport:g,content:x}=p||{},w=d?e:h.target,C=oj(w),v=w.ownerDocument,S=v.documentElement,_=()=>v.defaultView||yr,b=ft(GR,[w]),k=ft(Tj,[w]),E=ft(il,""),T=ft(b,E,c),D=ft(k,E,u),A=_e=>{const Ie=al(_e),He=Rh(_e),je=As(_e,Oy),Ge=As(_e,Iy);return He.w-Ie.w>0&&!rl(je)||He.h-Ie.h>0&&!rl(Ge)},R=T(g),M=R===w,W=M&&C,$=!M&&D(x),G=!M&&R===$,B=W?S:R,H=W?B:w,q=!M&&k(E,o,m),Q=!G&&$,J=[Q,B,q,H].map((_e=>Th(_e)&&!Zc(_e)&&_e)),U=_e=>_e&&Vk(J,_e),I=!U(B)&&A(B)?B:w,O=W?S:B,z={dt:w,vt:H,L:B,ln:q,ht:Q,gt:O,Qt:W?v:B,an:C?S:I,Gt:v,bt:C,At:d,V:M,un:_,yt:_e=>$y(B,si,_e),wt:(_e,Ie)=>Dh(B,si,_e,Ie),St:()=>Dh(O,si,yR,!0)},{dt:Y,vt:X,ln:Z,L:F,ht:P}=z,te=[()=>{Ss(X,[Xi,_g]),Ss(Y,_g),C&&Ss(S,[_g,Xi])}];let se=Nx([P,F,Z,X,Y].find((_e=>_e&&!U(_e))));const re=W?Y:P||F,ae=ft(Dr,te);return[z,()=>{const _e=_(),Ie=Tx(),He=be=>{xr(Zc(be),Nx(be)),hl(be)},je=be=>on(be,"focusin focusout focus blur",pj,{I:!0,D:!1}),Ge="tabindex",Ze=Py(F,Ge),Se=je(Ie);return ri(X,Xi,M?"":mR),ri(Z,Ix,""),ri(F,si,""),ri(P,ww,""),M||(ri(F,Ge,Ze||"-1"),C&&ri(S,Sw,"")),xr(re,se),xr(X,Z),xr(Z||X,!M&&F),xr(F,P),hn(te,[Se,()=>{const be=Tx(),de=U(F),ie=de&&be===F?Y:be,Pe=je(ie);Ss(Z,Ix),Ss(P,ww),Ss(F,si),C&&Ss(S,Sw),Ze?ri(F,Ge,Ze):Ss(F,Ge),U(P)&&He(P),de&&He(F),U(Z)&&He(Z),Rx(ie),Pe()}]),r&&!M&&(By(F,si,_j),hn(te,ft(Ss,F,si))),Rx(!M&&C&&Ie===Y&&_e.top===_e?F:Ie),Se(),se=0,ae},ae]},JR=({ht:e})=>({Zt:t,fn:n,It:r})=>{const{$t:a}=t||{},{Ot:o}=n;e&&(a||r)&&eu(e,{[yf]:o&&"100%"})},QR=({vt:e,ln:t,L:n,V:r},a)=>{const[o,c]=Ar({i:tR,o:yw()},ft(yw,e,"padding",""));return({Dt:u,Zt:d,fn:h,It:p})=>{let[m,g]=c(p);const{P:x}=Ls(),{_t:w,xt:C,Ct:v}=d||{},{B:S}=h,[_,b]=u("paddingAbsolute");(w||g||(p||C))&&([m,g]=o(p));const E=!r&&(b||v||g);if(E){const T=!_||!t&&!x,D=m.r+m.l,A=m.t+m.b,R={[Xk]:T&&!S?-D:0,[Jk]:T?-A:0,[Yk]:T&&S?-D:0,top:T?-m.t:0,right:T?S?-m.r:"auto":0,left:T?S?"auto":-m.l:0,[xf]:T&&`calc(100% + ${D}px)`},M={[Gk]:T?m.t:0,[Wk]:T?m.r:0,[Kk]:T?m.b:0,[qk]:T?m.l:0};eu(t||n,R),eu(n,M),Bt(a,{ln:m,_n:!T,F:t?M:Bt({},R,M)})}return{dn:E}}},ZR=(e,t)=>{const n=Ls(),{vt:r,ln:a,L:o,V:c,Qt:u,gt:d,bt:h,wt:p,un:m}=e,{P:g}=n,x=h&&c,w=ft(Hk,0),C={display:()=>!1,direction:Y=>Y!=="ltr",flexDirection:Y=>Y.endsWith("-reverse"),writingMode:Y=>Y!=="horizontal-tb"},v=gr(C),S={i:Qk,o:{w:0,h:0}},_={i:xh,o:{}},b=Y=>{p(vj,!x&&Y)},k=()=>As(o,v),E=(Y,X)=>{const Z=!gr(Y).length,F=X?!0:v.some((Ge=>{const Ze=Y[Ge];return _l(Ze)&&C[Ge](Ze)}));if(Z||!F||!cR(o))return{T:{x:0,y:0},k:{x:1,y:1}};b(!0);const P=Lr(d),te=on(u,Fa,(Ge=>{const Ze=Lr(d);Ge.isTrusted&&Ze.x===P.x&&Ze.y===P.y&&mj(Ge)}),{I:!0,A:!0}),se=p(bR,!0);Es(d,{x:0,y:0}),se();const re=Lr(d),ae=Rh(d);Es(d,{x:ae.w,y:ae.h});const ye=Lr(d),_e={x:ye.x-re.x,y:ye.y-re.y};Es(d,{x:-ae.w,y:-ae.h});const Ie=Lr(d),He={x:Ie.x-re.x,y:Ie.y-re.y},je={x:Wi(_e.x)>=Wi(He.x)?ye.x:Ie.x,y:Wi(_e.y)>=Wi(He.y)?ye.y:Ie.y};return Es(d,P),Ty((()=>te())),{T:re,k:je}},T=(Y,X)=>{const Z=yr.devicePixelRatio%1!==0?1:0,F={w:w(Y.w-X.w),h:w(Y.h-X.h)};return{w:F.w>Z?F.w:0,h:F.h>Z?F.h:0}},D=(Y,X)=>{const Z=(F,P,te,se)=>{const re=F===ai?as:OR(F),ae=rl(F),ye=rl(te);return!P&&!se?as:ae&&ye?ai:ae?P&&se?re:P?ai:as:P?re:ye&&se?ai:as};return{x:Z(X.x,Y.x,X.y,Y.y),y:Z(X.y,Y.y,X.x,Y.x)}},A=Y=>{const X=F=>[ai,as,Fa].map((P=>z(Px(P),F))),Z=X(!0).concat(X()).join(" ");p(Z),p(gr(Y).map((F=>z(Y[F],F==="x"))).join(" "),!0)},[R,M]=Ar(S,ft(Hy,o)),[W,$]=Ar(S,ft(Rh,o)),[G,B]=Ar(S),[H]=Ar(_),[q,Q]=Ar(S),[J]=Ar(_),[U]=Ar({i:(Y,X)=>bf(Y,X,Lh(dl(gr(Y),gr(X)))),o:{}}),[I,O]=Ar({i:(Y,X)=>xh(Y.T,X.T)&&xh(Y.k,X.k),o:gj()}),V=Sl(Vy),z=(Y,X)=>`${X?pR:gR}${eR(Y)}`;return({Dt:Y,Zt:X,fn:Z,It:F},{dn:P})=>{const{_t:te,Ht:se,xt:re,Ct:ae,ft:ye,Et:_e}=X||{},Ie=V&&V.R(e,t,Z,n,Y),{X:He,Y:je,W:Ge}=Ie||{},[Ze,Se]=RR(Y,n),[be,de]=Y("overflow"),ie=rl(be.x),Pe=rl(be.y),Ue=te||P||re||ae||_e||Se;let ue=M(F),De=$(F),qe=B(F),pe=Q(F);if(Se&&g&&p(_j,!Ze),Ue){$y(r,Xi,bh)&&b(!0);const nt=je&&je(),[Je]=ue=R(F),[oe]=De=W(F),Be=hj(o),tt=x&&lR(m()),Ot={w:w(oe.w+Je.w),h:w(oe.h+Je.h)},rn={w:w((tt?tt.w:Be.w+w(Be.w-oe.w))+Je.w),h:w((tt?tt.h:Be.h+w(Be.h-oe.h))+Je.h)};nt&&nt(),pe=q(rn),qe=G(T(Ot,rn),F)}const[he,We]=pe,[Ve,et]=qe,[it,ge]=De,[fe,Fe]=ue,[Xe]=H({x:Ve.w>0,y:Ve.h>0}),_t=ie&&Pe&&(Xe.x||Xe.y)||ie&&Xe.x&&!Xe.y||Pe&&Xe.y&&!Xe.x,Dt=P||ae||_e||Fe||ge||We||et||de||Se||Ue||se&&x,[Ct]=Y("update.flowDirectionStyles"),[Sn,wn]=U(Ct?Ct(o)||{}:k(),F),fn=ae||ye||wn||F,[Dn,Cn]=fn?I(E(Sn,!!Ct),F):O();let dn=D(Xe,be);b(!1),Dt&&(A(dn),dn=IR(o,Xe),Ge&&He&&(He(dn,it,fe),eu(o,Ge(dn))));const[rr,Ce]=J(dn);return Dh(r,Xi,bh,_t),Dh(a,Ix,bh,_t),Bt(t,{rn:rr,Vt:{x:he.w,y:he.h},Rt:{x:Ve.w,y:Ve.h},j:Xe,Tt:uR(Dn,Ve)}),{en:Ce,nn:We,sn:et,cn:Cn||et}}},e5=e=>{const[t,n,r]=XR(e),a={ln:{t:0,r:0,b:0,l:0},_n:!1,F:{[Xk]:0,[Jk]:0,[Yk]:0,[Gk]:0,[Wk]:0,[Kk]:0,[qk]:0},Vt:{x:0,y:0},Rt:{x:0,y:0},rn:{x:as,y:as},j:{x:!1,y:!1},Tt:gj()},{dt:o,gt:c,V:u,St:d}=t,{P:h,M:p}=Ls(),m=!h&&(p.x||p.y),g=[JR(t),QR(t,a),ZR(t,a)];return[n,x=>{const w={},v=m&&Lr(c),S=v&&d();return Xt(g,(_=>{Bt(w,_(x,w)||{})})),Es(c,v),S&&S(),u||Es(o,0),w},a,t,r]},t5=(e,t,n,r)=>{let a=!1;const o={Kt:!1,pn:!1},c=Sg(t,{}),[u,d,h,p,m]=e5(e),[g,x,w]=VR(p,h,c,(k=>{b({},k)})),[C,v,,S]=YR(e,t,o,w,h,p,r),_=k=>gr(k).some((E=>!!k[E])),b=(k,E)=>{const{Kt:T,pn:D}=o;if(D||T&&a)return!1;const{vn:A,It:R,zt:M}=k,W=A||{},$=!!R||!a,G={Dt:Sg(t,W,$),vn:W,It:$},B=E||x(Bt({},G,{zt:M})),H=d(Bt({},G,{fn:w,Zt:B}));v(Bt({},G,{Zt:B,tn:H}));const q=_(B),Q=_(H),J=q||Q||!My(W)||$;return a=!0,J&&n(k,{Zt:B,tn:H}),J};return[()=>{const{an:k,gt:E,St:T}=p,D=Lr(k),A=[g(),u(),C(),()=>{o.pn=!0}],R=T();return Es(E,D),R(),ft(Dr,A)},b,k=>{const E=o.Kt;o.Kt=k,!k&&E!==k&&b({It:!0,zt:!0})},()=>{v({Dt:Sg(t,{},!1),vn:{},It:!1})},()=>({gn:o,hn:w,bn:h}),{yn:p,wn:S},m]},Gy=new WeakMap,n5=(e,t)=>{Gy.set(e,t)},r5=e=>{Gy.delete(e)},Aj=e=>Gy.get(e),us=(e,t,n)=>{const{tt:r}=Ls(),a=Th(e),o=a?e:e.target,c=Aj(o);if(t&&!c){const u=[],d={},h=$=>{const G=tj($),B=Sl(fR);return B?B(G,!0):G},p=Bt({},r(),h(t)),[m,g,x]=Ox(),[w,C,v]=Ox(n),S=($,G)=>{v($,G),x($,G)},[_,b,k,E,T,D,A]=t5(e,p,(({vn:$,It:G},{Zt:B,tn:H})=>{const{_t:q,Ct:Q,$t:J,xt:U,Ht:I,ft:O}=B,{nn:V,sn:z,en:Y,cn:X}=H;S("updated",[W,{updateHints:{sizeChanged:!!q,directionChanged:!!Q,heightIntrinsicChanged:!!J,overflowEdgeChanged:!!V,overflowAmountChanged:!!z,overflowStyleChanged:!!Y,scrollCoordinatesChanged:!!X,contentMutation:!!U,hostMutation:!!I,appear:!!O},changedOptions:$||{},force:!!G}])}),($=>S("scroll",[W,$]))),R=$=>{const{gn:G}=T(),{pn:B}=G;B||(r5(o),Dr(u),S("destroyed",[W,$]),g(),C())},W={options($,G){if($){const B=G?r():{},H=kj(p,Bt(B,h($)));My(H)||(Bt(p,H),b({vn:H}))}return Bt({},p)},on:w,off:($,G)=>{$&&G&&C($,G)},state(){const{gn:$,hn:G,bn:B}=T(),{pn:H,Kt:q}=$,{B:Q}=G,{Vt:J,Rt:U,rn:I,j:O,ln:V,_n:z,Tt:Y}=B;return Bt({},{overflowEdge:J,overflowAmount:U,overflowStyle:I,hasOverflow:O,scrollCoordinates:{start:Y.T,end:Y.k},padding:V,paddingAbsolute:z,directionRTL:Q,sleeping:q,destroyed:H})},elements(){const{dt:$,vt:G,ln:B,L:H,ht:q,gt:Q,Qt:J}=D.yn,{jt:U,Jt:I}=D.wn,O=z=>{const{kt:Y,Pt:X,Lt:Z}=z;return{scrollbar:Z,track:X,handle:Y}},V=z=>{const{Xt:Y,Yt:X}=z,Z=O(Y[0]);return Bt({},Z,{clone:()=>{const F=O(X());return E(),F}})};return Bt({},{target:$,host:G,padding:B||H,viewport:H,content:q||H,scrollOffsetElement:Q,scrollEventElement:J,scrollbarHorizontal:V(U),scrollbarVertical:V(I)})},update:$=>b({It:$,zt:!0}),destroy:ft(R,!1),sleep:k,plugin:$=>d[gr($)[0]]};return hn(u,[A]),n5(o,W),bj(xj,us,[W,m,d]),WR(D.yn.bt,!a&&e.cancel)?(R(!0),W):(hn(u,_()),S("initialized",[W]),W.update(),W)}return c};us.plugin=e=>{const t=Zr(e),n=t?e:[e],r=n.map((a=>bj(a,us)[0]));return dR(n),t?r:r[0]};us.valid=e=>{const t=e&&e.elements,n=ps(t)&&t();return Jc(n)&&!!Aj(n.target)};us.env=()=>{const{U:e,M:t,P:n,J:r,ot:a,st:o,K:c,Z:u,tt:d,nt:h}=Ls();return Bt({},{scrollbarsSize:e,scrollbarsOverlaid:t,scrollbarsHiding:n,scrollTimeline:r,staticDefaultInitialization:a,staticDefaultOptions:o,getDefaultInitialization:c,setDefaultInitialization:u,getDefaultOptions:d,setDefaultOptions:h})};us.nonce=zR;us.trustedTypePolicy=iR;const s5=()=>{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,p)=>{d(),e=c(r?()=>{d(),t=a(h)}:h,typeof p=="object"?p:{timeout:2233})},d]},i5=e=>{const{options:t,events:n,defer:r}=e||{},[a,o]=j.useMemo(s5,[]),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:p}=c;d.current=t,us.valid(p)&&p.options(t||{},!0)},[t]),j.useEffect(()=>{const{current:p}=c;h.current=n,us.valid(p)&&p.on(n||{},!0)},[n]),j.useEffect(()=>()=>{var p;o(),(p=c.current)==null||p.destroy()},[]),j.useMemo(()=>[p=>{const m=c.current;if(us.valid(m))return;const g=u.current,x=d.current||{},w=h.current||{},C=()=>c.current=us(p,x,w);g?a(C,g):C()},()=>c.current],[])},a5=(e,t)=>{const{element:n="div",options:r,events:a,defer:o,children:c,...u}=e,d=n,h=j.useRef(null),p=j.useRef(null),[m,g]=i5({options:r,events:a,defer:o});return j.useEffect(()=>{const{current:x}=h,{current:w}=p;if(!x)return;const C=x;return m(n==="body"?{target:C,cancel:{body:null}}:{target:C,elements:{viewport:w,content:w}}),()=>{var v;return(v=g())==null?void 0:v.destroy()}},[m,n]),j.useImperativeHandle(t,()=>({osInstance:g,getElement:()=>h.current}),[]),cs.createElement(d,{"data-overlayscrollbars-initialize":"",ref:h,...u},n==="body"?c:cs.createElement("div",{"data-overlayscrollbars-contents":"",ref:p},c))},o5=j.forwardRef(a5),ht=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:m=>{var _;(_=d.current)==null||_.call(d);const g=m.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 p;return(p=d.current)==null?void 0:p.call(d)},[]),s.jsx(o5,{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})});ht.displayName="ScrollArea";const Aw=e=>{let t;const n=new Set,r=(h,p)=>{const m=typeof h=="function"?h(t):h;if(!Object.is(m,t)){const g=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),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},l5=(e=>e?Aw(e):Aw),c5=e=>e;function u5(e,t=c5){const n=cs.useSyncExternalStore(e.subscribe,cs.useCallback(()=>t(e.getState()),[e,t]),cs.useCallback(()=>t(e.getInitialState()),[e,t]));return cs.useDebugValue(n),n}const Lw=e=>{const t=l5(e),n=r=>u5(t,r);return Object.assign(n,t),n},Kn=(e=>e?Lw(e):Lw);function d5(){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 Lj=d5();function ms(e){return e.startsWith("/")?`${Lj}${e}`||"/":e}async function xe(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(ms(e),{...t,headers:r})}async function Dw(e,t,n,r){try{return(await xe(`/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 Dj(e,t,n){try{const r=await xe(`/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 Hd(e,t){return n=>({loading:{...n.loading,[e]:t}})}function Rw(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const Wy=[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 Ds(){return{showThinking:Rt(e=>e.settings[Ne.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:Rt(e=>e.settings[Ne.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:Rt(e=>e.settings[Ne.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:Rt(e=>e.settings[Ne.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:Rt(e=>e.settings[Ne.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:Rt(e=>e.settings[Ne.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true",maxVisibleItems:Number(Rt(e=>e.settings[Ne.DISPLAY_MAX_VISIBLE_ITEMS]??"300")),useNativeScrollbars:Rt(e=>e.settings[Ne.DISPLAY_USE_NATIVE_SCROLLBARS]??"false")==="true",useNativeScrollbarsCodeBlocks:Rt(e=>e.settings[Ne.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS]??"false")==="true",collapseLargeToolCalls:Rt(e=>e.settings[Ne.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS]??"false")==="true",deferCodeHighlightWhileStreaming:Rt(e=>e.settings[Ne.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING]??"false")==="true",feedVirtualization:Rt(e=>e.settings[Ne.DISPLAY_FEED_VIRTUALIZATION]??"false")==="true"}}const Rt=Kn(e=>({settings:{},loading:{},getSetting:async t=>{e(Hd(t,!0));try{const r=await(await xe(`/api/settings/${t}`)).json();return e(Rw(t,r.value??"")),r.value}catch{return e(Hd(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const r=await(await xe(`/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(Hd(t,!0));try{const a=await(await xe(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(Rw(t,a.value??""))}catch{e(Hd(t,!1))}}})),Sc=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:Wy,SETTINGS_KEYS:Ne,useDisplaySettings:Ds,useSettingsStore:Rt},Symbol.toStringTag,{value:"Module"}));function h5(){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 Ow=1e4,fl=new Map;function f5(){const e=Date.now();for(const[t,n]of fl)n.expiresAt<e&&fl.delete(t)}function m5(e){if(fl.has(e))return;const t=localStorage.getItem("openfox_token"),n=fetch(ms(`/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}));fl.set(e,{promise:n,expiresAt:Date.now()+Ow}),setTimeout(f5,Ow)}function p5(e){const t=fl.get(e);if(t&&(fl.delete(e),!(t.expiresAt<Date.now())))return t.promise}function g5(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function vh(){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 x5{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,p,m;clearTimeout(u),this.lastCloseCode=d.code,((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(p=this.statusHandler)==null||p.call(this,"disconnected"),o(new Error(`Connection closed: ${d.code}`))):(this.connectingPromise=null,(m=this.statusHandler)==null||m.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);g5(h)&&this.handlers.forEach(p=>p(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=vh(),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 y5=window.location.protocol==="https:"?"wss:":"ws:";let Bx=window.location.port;Bx||(Bx=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const b5=`${y5}//${window.location.hostname}:${Bx}${ms("/ws")}`,zt=new x5(b5),v5=3e4;function Rj(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 wc=null;const en=Kn((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()=>wc||(e({loading:!0,error:null}),wc=(async()=>{try{const n=await xe("/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{wc=null}})(),wc),refreshModel:async()=>{try{const n=await xe("/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 xe(`/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 xe("/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 xe(`/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()},v5);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}})),Yt=Kn((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const r=await(await xe("/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 xe("/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 xe(`/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 xe(`/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 xe(`/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 xe(`/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})}})),Zi=async(e,t,n)=>{try{const r=await xe(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"}}},Sf=async(e,t,n)=>{try{const r=await xe(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 Oj(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let Fd=[];const Vc=Kn()((e,t)=>{function n(){if(Fd.length===0)return;const a=Fd;Fd=[],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=Oj(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 xe(`/api/sessions/${o}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,o,c)=>{Fd.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:p,status:m}=o;e(g=>({processes:[...g.processes,{id:c,sessionId:"",name:u,command:d,cwd:h,pid:p,status:m,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}}}}}),$c={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let Va=null,li=null,ol=null,qy=0;const Iw=16;function _5(e){Va=e}function zc(){return $c}function S5(){li!==null&&(ol==="raf"?cancelAnimationFrame(li):clearTimeout(li),li=null,ol=null)}function Cg(){li=null,ol=null,qy=Date.now(),Va==null||Va()}function kg(){if(li!==null)return;const e=Date.now()-qy;e>=Iw?typeof document<"u"&&document.hidden?(li=setTimeout(Cg,0),ol="timeout"):(li=requestAnimationFrame(Cg),ol="raf"):(li=setTimeout(Cg,Iw-e),ol="timeout")}function Ma(){S5(),Va==null||Va(),$c.messageId=null,$c.deltaContent="",$c.thinkingContent="",$c.toolOutput=[],qy=0}let Ud=[];const Jn=Kn()((e,t)=>{function n(){if(Ud.length===0)return;const a=Ud;Ud=[],e(o=>({logs:[...o.logs,...a]}))}const r=Oj(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 xe(`/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 xe(`/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 xe(`/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 xe(`/api/dev-server/clear-logs?workdir=${encodeURIComponent(a)}`,{method:"POST"}),e({logs:[]})}catch{}},insertMarker:async()=>{const a=t().workdir;if(a)try{await xe(`/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 xe(`/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 xe(`/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 xe(`/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 xe(`/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;Ud.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}}}}}),Mw={open:0,todo:0,inProgress:0,running:0,queued:0,done:0};function w5(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 Pt=Kn((e,t)=>({tasks:[],settings:{slotLimit:1,queuePaused:!1},counts:Mw,gates:[],summaries:{},loading:!1,activeProjectId:null,lastError:null,lastAutoLaunch:null,loadBoard:async n=>{e({loading:!0});try{const r=await xe(`/api/projects/${n}/tasks`);if(!r.ok){e({loading:!1});return}const a=await r.json();w5(e,n,a),e({loading:!1})}catch{e({loading:!1})}},loadCounts:async n=>{try{const r=await xe(`/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 xe(`/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 xe(`/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 xe(`/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 xe(`/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 xe(`/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 xe(`/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 xe(`/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 xe(`/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 xe(`/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 xe(`/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 xe(`/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:Mw,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}:{}}))}})),C5=[{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"}],k5=[{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"}],Ij={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"},qi={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},Mj={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},$x={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...qi},waiting_for_user:{...qi},phase_done:{...qi},phase_blocked:{...qi},new_message:{...Mj}},agentOverrides:{}};function Pj(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 Oa=Kn((e,t)=>({settings:$x,loaded:!1,load:()=>{Rt.getState().getSetting(Ne.NOTIFICATION_SETTINGS);const r=Rt.subscribe(o=>{const c=o.settings[Ne.NOTIFICATION_SETTINGS];if(c!==void 0)try{const u=JSON.parse(c);e({settings:Pw(u),loaded:!0})}catch{e({loaded:!0})}}),a=Rt.getState().settings[Ne.NOTIFICATION_SETTINGS];if(a)try{const o=JSON.parse(a);e({settings:Pw(o),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),jg(n)},updateEvent:(n,r)=>{const a=t().settings,o={...a,events:{...a.events,[n]:{...a.events[n],...r}}};e({settings:o}),jg(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}),jg(u)}}));function jg(e){Rt.getState().setSetting(Ne.NOTIFICATION_SETTINGS,JSON.stringify(e))}function Pw(e){var t,n,r,a,o;return{soundEnabled:e.soundEnabled??$x.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??$x.browserNotificationEnabled,events:{complete:{...qi,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...qi,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...qi,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...qi,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...Mj,...(o=e.events)==null?void 0:o.new_message}},agentOverrides:e.agentOverrides??{}}}const Bw=new Map;function j5(e){let t=Bw.get(e);return t||(t=new Audio(ms(e)),t.volume=.5,Bw.set(e,t)),t}let Bj=typeof Notification<"u"?Notification.permission:"denied";function E5(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(Bj=e,e))}const N5={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},T5={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 A5(e){typeof Notification>"u"||Bj==="granted"&&(document.hasFocus()||new Notification(N5[e],{body:T5[e],icon:ms("/fox.svg"),tag:`openfox-${e}`}))}function mu(e,t){const{settings:n}=Oa.getState(),r=Pj(n,e,t);if(n.soundEnabled&&r.soundEnabled){const a=r.customSoundUrl??Ij[e],o=j5(a);o.currentTime=0,o.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&A5(e)}const L5=e=>mu("complete",e),D5=e=>mu("phase_done",e),R5=e=>mu("phase_blocked",e),Eg=e=>mu("waiting_for_user",e),O5=e=>mu("new_message",e),$w=new Map;function Xo(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 I5(e,t){if(e.type==="chat.done"){const n=e.payload,r=Xo(t,e.sessionId),a=n.agentType??r;n.reason==="complete"&&L5(a),n.reason==="waiting_for_user"&&Eg(a);return}if(e.type==="chat.path_confirmation"){const n=Xo(t,e.sessionId);Eg(n);return}if(e.type==="session.confirmation_pending"){const n=Xo(t,e.sessionId);Eg(n);return}if(e.type==="task.completed"){const n=Xo(t,e.sessionId);D5(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=$w.get(e.sessionId)??null;if($w.set(e.sessionId,n.phase),r===n.phase)return;const a=Xo(t,e.sessionId);n.phase==="blocked"&&R5(a)}}const tu=Kn(e=>({servers:[],setServers:t=>e({servers:t}),fetchServers:async()=>{try{const t=await xe("/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{}}})),Ng=new Set;function vn(e,t){return t!==null&&e.sessionId===t}function M5(e,t,n){return e.id!==void 0||vn(e,t)||n===!0&&e.sessionId!==void 0}function P5(e,t){return e.includes(t)?e:[...e,t]}function zw(e,t){return e.filter(n=>n!==t)}function B5(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 Tg(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 $5(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 Hw(e,t,n,r){var u;const a=e.sessionId,o=(u=n().currentSession)==null?void 0:u.id,c=a&&a!==o;if(t(d=>({sessions:d.sessions.map(h=>h.id===a?r(h):h)})),!c){const d=n().currentSession;if(d){const h=r(d);t(()=>({currentSession:h}))}}}function Fw(e,t,n){var u,d,h,p,m,g,x,w,C,v,S,_,b,k,E,T,D,A,R,M,W,$,G;const r=n();I5(e,r);const a=((u=r.currentSession)==null?void 0:u.id)??null,o=()=>{const B=e.sessionId;!B||B===a||t(H=>({unreadSessionIds:P5(H.unreadSessionIds,B)}))},c=(B,H,q)=>({messages:B.messages.map(Q=>Q.id===H?q(Q):Q)});switch(e.type){case"session.state":{const B=e.payload;if(!M5(e,a,r.pendingSessionCreate))break;Ma();const H=n().pendingSessionCreate===!0,q=B.pendingConfirmations??[],Q=B.session.id,J={...n().crossSessionConfirmations};delete J[Q],t({currentSession:B.session,sessions:B5(n().sessions,B.session),unreadSessionIds:zw(n().unreadSessionIds,Q),messages:B.messages,hiddenCount:B.hiddenCount??0,currentTodos:[],pendingPathConfirmations:q,crossSessionConfirmations:J,sessionsWithPendingConfirmations:Object.keys(J),pendingQuestions:B.pendingQuestions??[],activeWorkflowExecution:B.activeWorkflowExecution??null,...H?{pendingSessionCreate:B.session.id}:{}});break}case"session.list":{const B=e.payload;t(H=>({sessions:$5(B.sessions,H.sessions,H.currentSession)}));break}case"session.created":{const B=e.payload;t(H=>({sessions:H.sessions.some(q=>q.id===B.session.id)?H.sessions.map(q=>q.id===B.session.id?{...q,...B.session}:q):[B.session,...H.sessions],searchSessions:null}));break}case"session.deleted":{const B=e.payload;t(H=>({unreadSessionIds:zw(H.unreadSessionIds,B.sessionId),searchSessions:null})),n().listSessions();break}case"session.deletedAll":{t({searchSessions:null}),n().listSessions();break}case"session.running":{const B=e.payload;Hw(e,t,n,H=>({...H,isRunning:B.isRunning})),B.isRunning||t({abortInProgress:!1,queuedMessages:[]}),B.isRunning&&t({restoredInput:null});break}case"chat.message":{if(!vn(e,((d=n().currentSession)==null?void 0:d.id)??null)){o();break}const B=e.payload;t(H=>{if(H.messages.some(Q=>Q.id===B.message.id))return H;const q=B.message.role==="user";return{messages:[...H.messages,B.message],sessions:H.sessions.map(Q=>Q.id===e.sessionId&&q?{...Q,messageCount:Q.messageCount+1}:Q)}});break}case"chat.message_updated":{if(!vn(e,((h=n().currentSession)==null?void 0:h.id)??null)){o();break}const B=e.payload,H=n().messages.find(Q=>Q.id===B.messageId);B.updates.isStreaming===!1&&(H==null?void 0:H.isStreaming)===!0&&Ma(),t(Q=>({messages:Q.messages.map(J=>J.id===B.messageId?{...J,...B.updates}:J)}));break}case"chat.delta":{if(!vn(e,((p=n().currentSession)==null?void 0:p.id)??null)){o();break}const B=e.payload;if(!Ng.has(B.messageId)){Ng.add(B.messageId);const q=B.subAgentType?"sub-agent":Xo(n(),e.sessionId);O5(q)}const H=zc();H.messageId=B.messageId,H.deltaContent+=B.content,kg();break}case"chat.thinking":{if(!vn(e,((m=n().currentSession)==null?void 0:m.id)??null)){o();break}const B=e.payload,H=zc();H.messageId=B.messageId,H.thinkingContent+=B.content,kg();break}case"chat.tool_preparing":{if(!vn(e,((g=n().currentSession)==null?void 0:g.id)??null)){o();break}const B=e.payload;t(H=>{var O;const q=H.messages.find(V=>V.id===B.messageId);if(!q)return{};if((O=q.toolCalls)==null?void 0:O.find((V,z)=>z===B.index))return{};const J=q.preparingToolCalls??[],U=J.findIndex(V=>V.index===B.index);let I;return U>=0?I=J.map((V,z)=>z===U?{...V,arguments:B.arguments}:V):I=[...J,{index:B.index,name:B.name,...B.arguments?{arguments:B.arguments}:{}}],{messages:H.messages.map(V=>V.id===B.messageId?{...V,preparingToolCalls:I}:V)}});break}case"chat.tool_call":{if(!vn(e,((x=n().currentSession)==null?void 0:x.id)??null)){o();break}const B=e.payload,H=q=>{var O;const Q=(q.toolCalls??[]).length,J=(O=q.preparingToolCalls)==null?void 0:O.filter(V=>V.index!==Q),U=zc(),I=U.toolOutput.filter(V=>V.callId===B.callId);return I.length>0&&(U.toolOutput=U.toolOutput.filter(V=>V.callId!==B.callId)),{...q,toolCalls:[...q.toolCalls??[],{id:B.callId,name:B.tool,arguments:B.args,startedAt:Date.now(),...I.length>0?{streamingOutput:I.map(V=>({stream:V.stream,content:V.content,timestamp:Date.now()}))}:{}}],...J&&J.length>0?{preparingToolCalls:J}:{preparingToolCalls:void 0}}};t(q=>c(q,B.messageId,H));break}case"chat.tool_output":{if(!vn(e,((w=n().currentSession)==null?void 0:w.id)??null)){o();break}const B=e.payload,H=zc();H.messageId=B.messageId,H.toolOutput.push({messageId:B.messageId,callId:B.callId,stream:B.stream,content:B.output}),kg();break}case"chat.tool_result":{if(!vn(e,((C=n().currentSession)==null?void 0:C.id)??null)){o();break}const B=e.payload,H=q=>{var J;const Q=(J=q.toolCalls)==null?void 0:J.map(U=>U.id===B.callId?{...U,result:B.result}:U);return{...q,toolCalls:Q}};t(q=>c(q,B.messageId,H));break}case"chat.vision_fallback":{if(!vn(e,((v=n().currentSession)==null?void 0:v.id)??null)){o();break}const B=e.payload;t(H=>{const q=`${B.messageId}-${B.attachmentId}`,Q={...H.visionFallbackByMessage};return Q[q]={type:B.type,attachmentId:B.attachmentId,filename:B.filename,description:B.description},{visionFallbackByMessage:Q}});break}case"chat.todo":{if(!vn(e,((S=n().currentSession)==null?void 0:S.id)??null)){o();break}const B=e.payload;t({currentTodos:B.todos});break}case"chat.progress":{if(!vn(e,((_=n().currentSession)==null?void 0:_.id)??null)){o();break}const B=e.payload;console.warn("Progress:",B.message,B.phase);break}case"chat.format_retry":{if(!vn(e,((b=n().currentSession)==null?void 0:b.id)??null)){o();break}const B=e.payload;console.warn("Format retry:",B.attempt,"/",B.maxAttempts);break}case"chat.done":{if(!vn(e,((k=n().currentSession)==null?void 0:k.id)??null)){o();break}Ma(),Ng.delete(e.payload.messageId);const B=e.payload,H=B.stats;t(q=>({messages:q.messages.map(Q=>Q.id===B.messageId?{...Q,isStreaming:!1,stats:H??Q.stats,completeReason:B.reason,preparingToolCalls:void 0}:Q),visionFallbackByMessage:{}}));break}case"chat.error":{if(!vn(e,((E=n().currentSession)==null?void 0:E.id)??null)){o();break}Ma();const B=e.payload;console.error("Chat error:",B.error,"recoverable:",B.recoverable),t(H=>({error:{code:"CHAT_ERROR",message:B.error},...B.recoverable?{}:{messages:H.messages}}));break}case"chat.path_confirmation":{const B=e.sessionId,H=B===(((T=n().currentSession)==null?void 0:T.id)??null),q=e.payload,Q={callId:q.callId,tool:q.tool,paths:q.paths,workdir:q.workdir,reason:q.reason};if(!H){o(),B&&t(J=>({crossSessionConfirmations:{...J.crossSessionConfirmations,[B]:Tg(J.crossSessionConfirmations[B]??[],Q)},sessionsWithPendingConfirmations:J.sessionsWithPendingConfirmations.includes(B)?J.sessionsWithPendingConfirmations:[...J.sessionsWithPendingConfirmations,B]}));break}t(J=>({pendingPathConfirmations:Tg(J.pendingPathConfirmations,Q)}));break}case"session.confirmation_pending":{const B=e.sessionId,H=e.payload,q={callId:H.callId,tool:H.tool,paths:H.paths,workdir:H.workdir,reason:H.reason};B&&t(Q=>({crossSessionConfirmations:{...Q.crossSessionConfirmations,[B]:Tg(Q.crossSessionConfirmations[B]??[],q)},sessionsWithPendingConfirmations:Q.sessionsWithPendingConfirmations.includes(B)?Q.sessionsWithPendingConfirmations:[...Q.sessionsWithPendingConfirmations,B]}));break}case"session.confirmation_resolved":{const B=e.sessionId,H=e.payload;B&&t(q=>{const J=(q.crossSessionConfirmations[B]??[]).filter(I=>I.callId!==H.callId),U={...q.crossSessionConfirmations};return J.length===0?delete U[B]:U[B]=J,{crossSessionConfirmations:U,sessionsWithPendingConfirmations:Object.keys(U)}});break}case"chat.ask_user":{if(!vn(e,((D=n().currentSession)==null?void 0:D.id)??null)){o();return}const B=e.payload,H={callId:B.callId,question:B.question,type:B.type??"text",options:B.options??void 0};t(q=>({pendingQuestions:[...q.pendingQuestions.filter(Q=>Q.callId!==B.callId),H]}));break}case"mode.changed":{if(!vn(e,((A=n().currentSession)==null?void 0:A.id)??null)){o();break}const B=e.payload;t(H=>({currentSession:H.currentSession?{...H.currentSession,mode:B.mode}:null}));break}case"phase.changed":{const B=e.payload;Hw(e,t,n,H=>({...H,phase:B.phase}));break}case"workflow.execution_changed":{if(!vn(e,((R=n().currentSession)==null?void 0:R.id)??null)){o();break}const B=e.payload,H={...B.currentStepId?{currentStepId:B.currentStepId}:{},...B.currentStepName?{currentStepName:B.currentStepName}:{},...B.pendingChoices?{pendingChoices:B.pendingChoices}:{}};t(q=>{const Q=q.activeWorkflowExecution;return Q?{activeWorkflowExecution:{...Q,status:B.status,...H}}:{activeWorkflowExecution:{id:B.executionId,sessionId:e.sessionId??"",workflowId:B.workflowId,workflowName:B.workflowName,...B.workflowColor?{workflowColor:B.workflowColor}:{},status:B.status,...H,stepOutput:{},params:{},createdAt:Date.now(),updatedAt:Date.now()}}});break}case"criteria.updated":{if(!vn(e,((M=n().currentSession)==null?void 0:M.id)??null)){o();break}const B=e.payload;t(H=>({currentSession:H.currentSession?{...H.currentSession,criteria:B.criteria}:null}));break}case"metadata.updated":{if(!vn(e,((W=n().currentSession)==null?void 0:W.id)??null)){o();break}const B=e.payload;t(H=>({currentSession:H.currentSession?{...H.currentSession,metadataEntries:{...H.currentSession.metadataEntries,[B.key]:B.entries}}:null}));break}case"context.state":{const B=e.payload,H=vn(e,(($=n().currentSession)==null?void 0:$.id)??null);B.subAgentId?H&&n().updateSubAgentContextState(B.subAgentId,B.context):H?t({contextState:B.context}):o();break}case"session.name_generated":{const B=e.payload,H=e.sessionId,q=(G=n().currentSession)==null?void 0:G.id;t(Q=>{const J=Q.sessions.map(I=>I.id===H?{...I,title:B.name}:I),U=q===H?Q.currentSession?{...Q.currentSession,metadata:{...Q.currentSession.metadata,title:B.name}}:null:Q.currentSession;return{sessions:J,currentSession:U}});break}case"queue.state":{const B=e.payload;t({queuedMessages:B.messages??[]});break}case"mcp.servers.changed":{const B=e.payload;if(B!=null&&B.servers){const H=[...B.servers].sort((q,Q)=>q.name.localeCompare(Q.name));tu.getState().setServers(H)}else window.dispatchEvent(new CustomEvent("mcp-servers-changed"));break}case"git.status":{const B=e.payload;t({gitStatus:{branch:B.branch,diff:B.diff}});break}case"devServer.output":case"devServer.state":{Jn.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{Vc.getState().handleMessage(e.type,e.payload);break}case"tasks.update":{Pt.getState().handleTasksUpdate(e.payload);break}case"error":{const B=e.payload;console.error("Server error:",B),t({error:{code:B.code,message:B.message}});break}}}let Cc=!1,vs=null;const Ag=new Set,Ca=new Set,Vd=new Map;let kc=null;function Uw(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()}))]})})}async function Vw(e,t,n,r,a){try{const c=await(await xe(`/api/sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,messageKind:r})})).json();c.queueState&&a({queuedMessages:c.queueState})}catch(o){console.error("Error queueing message:",o)}}function Gw(e,t){return e.map(n=>{var a,o;const r=t.sessions.find(c=>c.id===n.id);return{...n,title:n.title??(r==null?void 0:r.title),mode:((a=t.currentSession)==null?void 0:a.id)===n.id?t.currentSession.mode:(r==null?void 0:r.mode)??n.mode,phase:((o=t.currentSession)==null?void 0:o.id)===n.id?t.currentSession.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}}})}const Re=Kn((e,t)=>{_5(()=>{const r=zc();if(!r.messageId)return;const a=r.deltaContent.length>0,o=r.thinkingContent.length>0,c=r.toolOutput.length>0;if(!a&&!o&&!c)return;const u=r.deltaContent,d=r.thinkingContent,h=r.toolOutput;r.deltaContent="",r.thinkingContent="",r.toolOutput=[],e(p=>{const m=p.messages.find(g=>g.id===r.messageId);if(m){const g={...m};if(a&&(g.content=g.content+u),o&&(g.thinkingContent=(g.thinkingContent??"")+d),c){const x=new Set;g.toolCalls=Uw(g.toolCalls,h,x);const w=h.filter(C=>!x.has(C.callId));w.length>0&&r.toolOutput.push(...w)}return{messages:p.messages.map(x=>x.id===r.messageId?g:x)}}if(c){const g=new Set,x=p.messages.map(C=>C.id!==r.messageId?C:{...C,toolCalls:Uw(C.toolCalls,h,g)}),w=h.filter(C=>!g.has(C.callId));return w.length>0&&r.toolOutput.push(...w),{messages:x}}return p})});function n(r,a,o,c,u){return{workflowId:r.workflowId,resumeFrom:r.currentStepId,stepOutput:r.stepOutput,...r.params&&Object.keys(r.params).length>0?{params:r.params}:{},...r.subGroup?{subGroup:r.subGroup}:{},...u?{userChoice:u}:{},...a!=null&&a.trim()?{content:a}:{},...o&&o.length>0?{attachments:o}:{},...c?{messageKind:c}:{}}}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,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,pendingUpdate:!1,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let a=!1;try{a=(await(await xe("/api/auth")).json()).requiresAuth}catch{}if(a&&!zt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}zt.onStatusChange(o=>{var c,u;if(e({connectionStatus:o}),o==="connected"){const d=(c=t().currentSession)==null?void 0:c.projectId;d&&t().listSessions(d),Yt.getState().listProjects();const h=(u=t().currentSession)==null?void 0:u.id;h&&t().loadSession(h)}else(o==="disconnected"||o==="reconnecting")&&Ca.clear()});try{await zt.connect(),Cc||(Cc=!0,vs=zt.subscribe(o=>{Fw(o,e,t)}))}catch(o){console.error("Failed to connect:",o);const c=zt.getLastCloseCode();if(!zt.hasToken()&&(c===1006||c===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}vs&&(vs(),vs=null),Cc=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{zt.disconnect(),vs&&(vs(),vs=null),Cc=!1,Ca.clear(),e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{zt.disconnect(),vs&&(vs(),vs=null),Cc=!1,Ca.clear(),e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async r=>{try{const a=await fetch(ms("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:r})});if(!a.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:o}=await a.json();zt.setToken(o),e({showPasswordModal:!1}),t().connect();const{listProjects:c}=Yt.getState(),{fetchConfig:u}=en.getState();c(),u(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{zt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(r,a)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const c=await xe("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:r,title:a})});if(!c.ok)return e({pendingSessionCreate:!1}),null;const u=await c.json();e({searchSessions:null});try{zt.send("session.load",{sessionId:u.session.id})}catch{}return u.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async(r,a=!1)=>{if(!(!a&&Ag.has(r))&&!(!a&&Ca.has(r))){Ag.add(r);try{const o=t().currentSession;if(!o||o.id!==r){Ca.clear();const g=o==null?void 0:o.id,x=t().pendingPathConfirmations,C={...t().crossSessionConfirmations};g&&x.length>0&&(C[g]=[...C[g]??[],...x]),Ma(),e({currentSession:null,unreadSessionIds:t().unreadSessionIds.filter(v=>v!==r),subAgentContextStates:{},messages:[],currentTodos:[],contextState:null,pendingPathConfirmations:[],pendingQuestions:[],queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,gitStatus:null,pendingSessionCreate:!1,crossSessionConfirmations:C,sessionsWithPendingConfirmations:Object.keys(C)})}else e({unreadSessionIds:t().unreadSessionIds.filter(g=>g!==r)});const c=p5(r),u=c?c.then(async g=>{if(g.ok)return g.data;const x=await xe(`/api/sessions/${r}`);return x.ok?await x.json():null}):xe(`/api/sessions/${r}`).then(async g=>g.ok?await g.json():null),d=xe(`/api/sessions/${r}/background-processes`),h=await u;if(!h)return;const p=h.messages??[],m={...t().crossSessionConfirmations};delete m[r],e({currentSession:h.session,messages:p,hiddenCount:h.hiddenCount??0,contextState:h.contextState,queuedMessages:h.queueState??[],pendingPathConfirmations:h.pendingConfirmations??[],pendingQuestions:h.pendingQuestions??[],activeWorkflowExecution:h.activeWorkflowExecution??null,crossSessionConfirmations:m,sessionsWithPendingConfirmations:Object.keys(m)}),zt.send("session.load",{sessionId:r});try{const g=await d;if(g.ok){const x=await g.json();Vc.getState().setProcesses(x.processes??[])}}catch{}Ca.add(r)}catch{}finally{Ag.delete(r)}}},listSessions:async(r,a=20)=>{const o=r??"global";if(Vd.has(o))return Vd.get(o);const c=(async()=>{var u;try{const d=new URLSearchParams;d.set("limit",String(a)),r&&d.set("projectId",r);const p=await(await xe(`/api/sessions?${d.toString()}`)).json(),m=p.sessions??[];e(x=>({sessions:Gw(m,x),sessionsHasMore:r?p.hasMore??!1:!0}));const g=p.pendingConfirmationsBySession;if(g){const x=(u=t().currentSession)==null?void 0:u.id,w={};for(const[C,v]of Object.entries(g))C!==x&&(w[C]=v);e({crossSessionConfirmations:w,sessionsWithPendingConfirmations:Object.keys(w)})}}catch{}finally{Vd.delete(o)}})();return Vd.set(o,c),c},listHomeSessions:async()=>{try{const r=await xe("/api/sessions/home");if(!r.ok)return;const a=await r.json();e(o=>({sessions:Gw(a.sessions,o),sessionsHasMore:!1}))}catch{}},ensureFullSessionList:async()=>{if(!t().searchSessions)return kc||(kc=(async()=>{try{const o=(await(await xe("/api/sessions")).json()).sessions??[];e({searchSessions:o})}catch{}finally{kc=null}})(),kc)},loadMoreSessions:async r=>{const a=t();if(!(a.sessionsPaginationLoading||!a.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const o=new URLSearchParams;o.set("limit","20"),o.set("offset",String(a.sessions.length)),o.set("projectId",r);const u=await(await xe(`/api/sessions?${o.toString()}`)).json(),d=u.sessions??[];e(h=>({sessions:[...h.sessions,...d.map(p=>{const m=h.sessions.find(g=>g.id===p.id);return(m==null?void 0:m.isRunning)===!1?{...p,isRunning:!1}:p})],sessionsHasMore:u.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async r=>{var a;try{return(await xe(`/api/sessions/${r}`,{method:"DELETE"})).ok?(e({searchSessions:null}),await t().listSessions(),((a=t().currentSession)==null?void 0:a.id)===r&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(r,a)=>{var o;try{const c=await xe(`/api/sessions/${r}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:a})});if(!c.ok)return!1;if(e({searchSessions:null}),await t().listSessions(),((o=t().currentSession)==null?void 0:o.id)===r){const d=await c.json();d.session&&e({currentSession:d.session})}return!0}catch{return!1}},toggleFavorite:async(r,a)=>{e(o=>({sessions:o.sessions.map(c=>c.id===r?{...c,isFavorite:a}:c)}));try{const o=await xe(`/api/sessions/${r}/favorite`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isFavorite:a})});return o.ok?(await t().listSessions(),!0):(console.warn("Failed to toggle favorite",{sessionId:r,isFavorite:a,status:o.status}),e(c=>({sessions:c.sessions.map(u=>u.id===r?{...u,isFavorite:!a}:u)})),!1)}catch(o){return console.error("Error toggling favorite:",o),e(c=>({sessions:c.sessions.map(u=>u.id===r?{...u,isFavorite:!a}:u)})),!1}},deleteAllSessions:async r=>{try{return(await xe(`/api/projects/${r}/sessions`,{method:"DELETE"})).ok?(e({searchSessions:null}),await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{Ma(),Ca.clear(),e(r=>({currentSession:null,messages:[],hiddenCount:0,currentTodos:[],contextState:null,restoredInput:null,pendingSessionCreate:!1,unreadSessionIds:r.currentSession?r.unreadSessionIds.filter(a=>a!==r.currentSession.id):r.unreadSessionIds}))},sendMessage:async(r,a,o)=>{var d;e({error:null});const c=(d=t().currentSession)==null?void 0:d.id;if(!c)return;const u=t().activeWorkflowExecution;if(u&&u.status==="running"){zt.send("runner.launch",n(u,r,a,o==null?void 0:o.messageKind));return}try{const h=r==null?void 0:r.trim(),p=a&&a.length>0,m={};h&&(m.content=r),p&&(m.attachments=a),o!=null&&o.messageKind&&(m.messageKind=o.messageKind);const x=await(await xe(`/api/sessions/${c}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)})).json();x.queueState&&e({queuedMessages:x.queueState})}catch(h){console.error("Error sending message:",h)}},stopGeneration:async()=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r&&!t().abortInProgress){Ma(),e({abortInProgress:!0});try{const c=await(await xe(`/api/sessions/${r}/stop`,{method:"POST"})).json();if(c.queuedMessages&&c.queuedMessages.length>0){const u=c.queuedMessages.map(d=>d.content).join(`
|
|
67
|
+
`);e({restoredInput:u})}}catch(o){console.error("Error stopping generation:",o)}}},continueGeneration:async()=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r)try{await xe(`/api/sessions/${r}/continue`,{method:"POST"})}catch(o){console.error("Error continuing generation:",o)}},launchWorkflow:(r,a,o,c,u,d)=>{const h={};r!=null&&r.trim()&&(h.content=r),a&&a.length>0&&(h.attachments=a),o&&(h.workflowId=o),c&&(h.subGroup=c),u&&(h.params=u),h.scope=d??"auto",zt.send("runner.launch",h)},continueWorkflow:r=>{const o=t().activeWorkflowExecution;!o||o.status!=="waiting"||zt.send("runner.launch",n(o,void 0,void 0,void 0,r))},exitWorkflow:()=>{zt.send("workflow.exit",{})},switchMode:async r=>{var o;const a=(o=t().currentSession)==null?void 0:o.id;if(a)try{const c=await xe(`/api/sessions/${a}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:r})});if(!c.ok){console.error("Failed to switch mode:",await c.json());return}const u=await c.json();u.session&&e({currentSession:u.session}),u.messages&&e({messages:u.messages,hiddenCount:u.hiddenCount??0})}catch(c){console.error("Error switching mode:",c)}},switchDangerLevel:async r=>{var o;const a=(o=t().currentSession)==null?void 0:o.id;if(a)try{const c=await xe(`/api/sessions/${a}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:r})});if(!c.ok){console.error("Failed to switch danger level:",await c.json());return}const u=await c.json();u.session&&e({currentSession:u.session})}catch(c){console.error("Error switching danger level:",c)}},editCriteria:async r=>{var o;const a=(o=t().currentSession)==null?void 0:o.id;if(a)try{const c=await xe(`/api/sessions/${a}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:r})});c.ok||console.error("Failed to update criteria:",await c.json())}catch(c){console.error("Error updating criteria:",c)}},compactContext:()=>{zt.send("context.compact",{})},setSessionProvider:async(r,a)=>{var o;try{const c=(o=t().currentSession)==null?void 0:o.id;if(!c)return null;const u=await xe(`/api/sessions/${c}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:r,...a?{model:a}:{}})});if(!u.ok)return null;const d=await u.json();return e({currentSession:d.session,messages:d.messages??[],hiddenCount:d.hiddenCount??0,contextState:d.contextState}),d.session}catch{return null}},updateContextState:r=>{e({contextState:r})},updateSubAgentContextState:(r,a)=>{e(o=>({subAgentContextStates:{...o.subAgentContextStates,[r]:a}}))},clearSubAgentContextState:r=>{e(a=>{const o={...a.subAgentContextStates};return delete o[r],{subAgentContextStates:o}})},confirmPath:async(r,a,o=!1)=>{var u;const c=(u=t().currentSession)==null?void 0:u.id;if(c)try{const d=await xe(`/api/sessions/${c}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:r,approved:a,alwaysAllow:o})});if(!d.ok){const h=await d.json().catch(()=>({}));console.error("Error confirming path:",h.error??`HTTP ${d.status}`)}}catch(d){console.error("Error confirming path:",d)}},answerQuestion:async(r,a,o)=>{var u;const c=(u=t().currentSession)==null?void 0:u.id;if(c){try{await xe(`/api/sessions/${c}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:r,answer:a,skip:o})})}catch(d){console.error("Error answering question:",d)}e(d=>({pendingQuestions:d.pendingQuestions.filter(h=>h.callId!==r)}))}},queueAsap:async(r,a,o)=>{var u;const c=(u=t().currentSession)==null?void 0:u.id;c&&await Vw(c,r,a,o,e)},queueCompletion:async(r,a,o)=>{var u;const c=(u=t().currentSession)==null?void 0:u.id;c&&await Vw(c,r,a,o,e)},cancelQueued:async r=>{var o;const a=(o=t().currentSession)==null?void 0:o.id;if(a)try{const u=await(await xe(`/api/sessions/${a}/queue/${r}`,{method:"DELETE"})).json();u.queueState&&e({queuedMessages:u.queueState})}catch(c){console.error("Error canceling queued message:",c)}},clearError:()=>{e({error:null})},clearRestoredInput:()=>{e({restoredInput:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},queueUpdate:()=>{e({pendingUpdate:!0})},triggerPendingUpdate:()=>{t().pendingUpdate&&(e({pendingUpdate:!1}),zt.send("context.applyDynamic",{}))},handleServerMessage:r=>{Fw(r,e,t)}}});function wf(){return Re(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function z5(){return Re(e=>e.abortInProgress)}function H5(){const e=Re(a=>a.connect),t=Re(a=>a.connectionStatus),n=Oa(a=>a.load),r=vl("/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 F5="modulepreload",U5=function(e){return"/"+e},Ww={},ne=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let c=function(h){return Promise.all(h.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const 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=U5(h),h in Ww)return;Ww[h]=!0;const p=h.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":F5,p||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),p)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)})},V5=[{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"}],G5=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"}]'),$j={tokens:V5,presets:G5},zj=$j.tokens,ar=$j.presets;function qw(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}function W5(){try{const e=localStorage.getItem("openfox:systemThemePrefs");if(e)return JSON.parse(e)}catch{}return{darkPreset:"dark",lightPreset:"light"}}const Kt=Kn((e,t)=>{const n=W5();return{currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:qw(),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(ar.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,p=d.find(m=>m.id===h);e(p?{basePreset:"system",currentPreset:p.basePreset,customTokens:{...p.tokens},isCustom:!0,isCustomizing:!1,isSystem:!0,activeUserPresetId:p.id}:{basePreset:"system",currentPreset:h,customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!0,activeUserPresetId:null}),t().applyTheme()}else e({currentPreset:r,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!1,activeUserPresetId:null}),t().applyTheme()},startCustomizing:()=>{var o;const{currentPreset:r}=t(),a=((o=ar.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=ar.find(p=>p.id===r))==null?void 0:u.tokens)??{},...a};if(o)return{...zj.reduce((h,p)=>({...h,[p.key]:p.defaultValue}),{}),...a};const c=ar.find(h=>h.id===t().currentPreset);return(c==null?void 0:c.tokens)??((d=ar[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 ne(async()=>{const{useSettingsStore:o}=await Promise.resolve().then(()=>Sc);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}),ne(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Sc);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 p=c?d:h;t().applyPreset(p),t().saveTheme(JSON.stringify({preset:p}))},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=ar.find(m=>m.id===u),h={id:"custom-"+Date.now(),name:r,basePreset:u,mode:d==null?void 0:d.mode,tokens:{...o}},p=[...t().userPresets,h];e({userPresets:p}),t().saveUserPresets()},applyUserPreset:r=>{const a=t().userPresets[r];a&&(e({currentPreset:a.basePreset,basePreset:a.basePreset,customTokens:{...a.tokens},isCustom:!0,isCustomizing:!1,activeUserPresetId:a.id}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:a.basePreset,tokens:a.tokens})).catch(()=>{}))},deleteUserPreset:r=>{const a=t().userPresets.filter((o,c)=>c!==r);e({userPresets:a}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:qw()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),ne(async()=>{const{useSettingsStore:r}=await Promise.resolve().then(()=>Sc);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})),ne(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Sc);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})),ne(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:o}=await Promise.resolve().then(()=>Sc);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 q5({canLoad:e,projectId:t,currentProjectId:n}){const r=Yt(c=>c.loadProject),a=Re(c=>c.listSessions),o=Re(c=>c.clearSession);j.useEffect(()=>{e&&t&&(n!==t&&r(t),a(t),o())},[e,t,n,r,a,o])}function K5({canLoad:e,projectId:t,sessionId:n,currentProjectId:r,currentSessionId:a}){const o=Re(h=>h.loadSession),c=Yt(h=>h.loadProject),u=Re(h=>h.listSessions),d=Re(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 Y5({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 Cf({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 Hj({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 X5({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 Ga({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 Rs({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 Fj({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":"M19 9l-7 7-7-7"})})}function gn(e){return s.jsx(Fj,{direction:"down",...e})}function Uj(e){return s.jsx(Fj,{direction:"up",...e})}function J5({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 ml({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 Ky({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 Yy({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 Xy({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 Qr({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 Q5({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 Z5({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 e3({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 kf({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 t3({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 Kw({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 Vj({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 Jy({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 jf({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 es({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 n3({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 Ef({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 Gj({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 r3({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 nu({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 Nf({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 Qy({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 s3({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 Zy({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 Wj({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 i3({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 fi({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 hi({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 a3({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 zx({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 ta({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 eb({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 o3({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 l3({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 Yw({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 Hx(){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 Xw(e,t){const n=zt.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:Hx(),type:e,payload:t}))}const os=Kn((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 xe(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(r.ok){const a=await r.json();e({sessions:a});const o=zt.ws;if(o&&o.readyState===WebSocket.OPEN)for(const c of a)o.send(JSON.stringify({id:Hx(),type:"terminal.subscribe",payload:{sessionId:c.id}}))}}catch(r){console.error("Failed to fetch terminals:",r)}},createSession:async(n,r)=>{try{const a=await xe("/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=zt.ws;c&&c.readyState===WebSocket.OPEN&&c.send(JSON.stringify({id:Hx(),type:"terminal.subscribe",payload:{sessionId:o.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,r)=>{Xw("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,a)=>{Xw("terminal.resize",{sessionId:n,cols:r,rows:a})},killSession:async n=>{try{(await xe(`/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}}}}));zt.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&os.getState().handleMessage(e)});const ui=Kn((e,t)=>({status:"idle",current:null,latest:null,check:async n=>{if(!(!n&&t().status==="checking")){e({status:"checking"});try{const r=await fetch(ms(`/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"})}}}})),js={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 Fx(e){if(!e)return structuredClone(js);try{const t=JSON.parse(e),n=r=>t[r]===void 0?structuredClone(js[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(js)}}function Jw(e){return e.code.startsWith("Digit")?e.code.slice(-1):/^[a-zA-Z]$/.test(e.key)?e.key.toLowerCase():e.key}function Oh(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 c3(e){return e.type==="double-press"}function qj(e){return e.type==="chord"}function u3(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 Kj(e,t){const n=t.modifiers.includes("ctrl"),r=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),o=t.modifiers.includes("shift");return u3(e,t.key)&&e.ctrlKey===n&&e.metaKey===r&&e.altKey===a&&e.shiftKey===o}function pu(){const e=Rt(t=>t.settings[Ne.KEYBINDINGS]);return Fx(e)}function d3(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",p=e.key==="Alt",m=e.key==="Meta";if(!d&&u.ctrlKey||!h&&u.shiftKey||!p&&u.altKey||!m&&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 h3(e,t){const n=j.useRef(t);n.current=t,j.useEffect(()=>{if(!e)return;const r=a=>{Kj(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e])}function ru(e,t,n){d3(e&&c3(e)?e:void 0,t,n),h3(e&&qj(e)?e:void 0,t)}function f3(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&&qj(u)&&Kj(o,u)){o.preventDefault(),r.current(d.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var mi=Lk();const Tf=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})})}));Tf.displayName="IconButton";const m3="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",di=j.forwardRef((e,t)=>s.jsx(Tf,{ref:t,icon:m3,title:"Edit",...e}));di.displayName="EditButton";const p3="M6 18L18 6M6 6l12 12",tb=j.forwardRef((e,t)=>s.jsx(Tf,{ref:t,icon:p3,...e}));tb.displayName="CloseButton";const g3={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 wt({label:e,title:t,headerRight:n,size:r="md",minHeight:a,children:o,footer:c,className:u,onClose:d,isOpen:h,closeOnBackdropClick:p=!0,closeOnEscape:m=!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||!m)return;const E=T=>{if(T.key==="Escape"){const D=document.activeElement;if(D&&(D.tagName==="INPUT"||D.tagName==="TEXTAREA"))return;T.stopPropagation(),b()}};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[S,b,m]);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"?mi.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:p?b:void 0}),s.jsxs("div",{role:"dialog",className:`relative w-full ${g3[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(tb,{onClick:b,"aria-label":"Close"})]})]}),x?s.jsx(ht,{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 x3({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:k5.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 Qw=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function y3(){const e=Oa(d=>d.settings),t=Oa(d=>d.update),n=Oa(d=>d.updateEvent),r=Oa(d=>d.updateAgentOverride),a=Oa(d=>d.load);j.useEffect(()=>{a()},[a]);const o=async()=>{await E5()==="granted"&&t({...e,browserNotificationEnabled:!0})},c=(d,h,p,m)=>{d==="general"?n(h,{[p]:m}):r(d,h,{[p]:m})},u=(d,h,p)=>{d==="general"?n(h,{customSoundUrl:p}):r(d,h,{customSoundUrl:p})};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(Zw,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>t({...e,soundEnabled:d})}),s.jsx(Zw,{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"}),Qw.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:C5.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})}),Qw.map(h=>{const p=Pj(e,d.key,h.key==="general"?void 0:h.key),m=Ij[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:p.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:p.browserNotification,onChange:g=>c(h.key,d.key,"browserNotification",g.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&s.jsx(x3,{value:p.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:g=>u(h.key,d.key,g)})]})},h.key)})]},d.key))})]})})]})]})}function Zw({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 e1(e,t,n){try{const r=await xe(e,t);return r.ok?(await n(),{success:!0}):{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}}function ka(e,t){return t?`${e}?workdir=${encodeURIComponent(t)}`:e}const Hn=Kn((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 xe(ka("/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 xe(ka(`/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 xe(ka(`/api/skills/${n}`,t().workdir));return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await xe(`/api/skills/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(n,r)=>{const a=await Zi("POST",ka("/api/skills",t().workdir),{...n,destination:r});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,r)=>{const a=await Zi("PUT",ka(`/api/skills/${n}`,t().workdir),r);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const r=await xe(ka(`/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)=>Sf(ka(`/api/skills/${n}/duplicate`,t().workdir),()=>t().fetchSkills(),r),selectDirectory:async n=>e1("/api/skills/library",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})},t().fetchSkills),removeDirectory:async()=>{await xe("/api/skills/library",{method:"DELETE"}),await t().fetchSkills()},installSkill:async n=>{const r=new FormData;r.append("packageName",n.packageName),r.append("paths",JSON.stringify(n.files.map(a=>a.path)));for(const a of n.files)r.append("files",a.file,a.file.name);return e1("/api/skills/install",{method:"POST",body:r},t().fetchSkills)}}));function gu(){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 Ih({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 Mh({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(fi,{})})}function su({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(ml,{})})}function Xr({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 Yj({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 ll({message:e}){return s.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function Af({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 Xj({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 Jj({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 Qj({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 nb({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 Zj({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:p}){return s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(Xr,{label:n,value:e,onChange:h,placeholder:a,hint:c}),s.jsx(Xr,{label:r,value:t,onChange:p,readOnly:u,placeholder:o,hint:u?d:void 0,mono:!0})]})}function eE(e={}){const{initialData:t={}}=e,[n,r]=j.useState("list"),[a,o]=j.useState(null),[c,u]=j.useState(""),[d,h]=j.useState(!1),[p,m]=j.useState(t),g=j.useCallback(()=>{m(t),u(""),o(null)},[t]),x=j.useCallback(S=>{r(S),S==="list"&&g()},[g]),w=j.useCallback(S=>{m(_=>typeof S=="function"?S(_):S)},[]),C=j.useCallback((S,_={})=>{o(S),r("edit"),m({..._}),u("")},[]),v=j.useCallback(()=>{o(null),r("edit"),m(t),u("")},[t]);return{view:n,editingId:a,formError:c,saving:d,formData:p,setView:x,setEditingId:o,setFormError:u,setFormData:w,setSaving:h,resetForm:g,startEditing:C,startNew:v}}function pl({isOpen:e,onClose:t,onConfirm:n,title:r,message:a,confirmLabel:o="Confirm",confirmVariant:c="primary",disabled:u=!1}){return s.jsx(wt,{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 b3={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function na({size:e="md",className:t=""}){return s.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${b3[e]} ${t}`})}function v3({text:e,...t}){return s.jsxs("div",{className:"text-center",children:[s.jsx(na,{...t,className:"mx-auto mb-4"}),e&&s.jsx("div",{className:"text-text-secondary",children:e})]})}function xu(e){return e.split(/[\\/]/).filter(Boolean).pop()??""}function _3(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 tE(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 Ft(){return typeof window>"u"||typeof window.matchMedia!="function"?!0:!window.matchMedia("(hover: none) and (pointer: coarse)").matches}const Ns=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}));Ns.displayName="Input";function Lf({onSelect:e,onClose:t,initialPath:n}){const[r,a]=j.useState(null),[o,c]=j.useState(!0),[u,d]=j.useState(""),[h,p]=j.useState(-1),m=j.useRef(null),g=j.useRef(null),x=j.useCallback(async b=>{c(!0),d(""),p(-1);try{const k=b?`/api/directories?path=${encodeURIComponent(b)}`:"/api/directories",T=await(await xe(k)).json();a(T)}catch(k){console.error("Failed to load directories:",k)}finally{c(!1)}},[]);j.useEffect(()=>{x(n)},[n,x]);const w=_3((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(()=>{p(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(),p(E=>Math.min(E+1,v.length-1));else if(b.key==="ArrowUp")b.preventDefault(),p(E=>Math.max(E-1,0));else if(b.key==="Enter"){if(h<0||!v[h]||b.target instanceof HTMLElement&&b.target.dataset.select==="true")return;b.preventDefault(),b.shiftKey?x(v[h].path):e(v[h].path)}else b.key==="Escape"&&(d(""),Ft()&&((k=m.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(wt,{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(hi,{})}),s.jsx(Ns,{autoFocus:Ft(),ref:m,value:u,onChange:b=>d(b.target.value),placeholder:"Filter directories...",className:"w-full pl-9"})]})})]}),s.jsx(ht,{className:"flex-1",children:o?s.jsx("div",{className:"p-8 text-center",children:s.jsx(na,{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(Y5,{className:"w-5 h-5 text-text-muted shrink-0"}):s.jsx(Qr,{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 nE(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 S3(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 nE(r,t.map(a=>({path:a.webkitRelativePath.slice(r.length+1),file:a})))}function w3(e){return new Promise((t,n)=>e.file(t,n))}async function rE(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?rE(o,c):[{path:c,file:await w3(o)}]}))).flat()}async function C3(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 nE(n.name,await rE(n))}function k3({selectedDirectory:e,onSelect:t,onRemove:n,onRefresh:r,onInstall:a}){const[o,c]=j.useState(!1),[u,d]=j.useState(!1),[h,p]=j.useState(""),[m,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(!m||x)return;w(!0);const k=await t(m);if(k&&!k.success){p(k.error??"Cannot use selected folder."),w(!1);return}g(null),c(!1),w(!1)},_=async k=>{d(!0),p("");const E=await a(k);d(!1),E.success||p(E.error??"Failed to install skill package.")},b=async k=>{if(k.preventDefault(),!(!(e!=null&&e.available)||u))try{await _(await C3(k.dataTransfer))}catch(E){p(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{_(S3(k.target.files))}catch(T){p(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(Lf,{initialPath:(e==null?void 0:e.resolvedPath)??void 0,onSelect:v,onClose:()=>c(!1)}),s.jsx(pl,{isOpen:m!==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 ds({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 sE({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(di,{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(Xy,{})}),s.jsx(su,{onClick:a}),!e&&r&&s.jsx(di,{onClick:r}),!e&&o&&(t?s.jsx(Ih,{onConfirm:()=>{o==null||o()},onCancel:()=>c==null?void 0:c()}):s.jsx(Mh,{onClick:()=>o==null?void 0:o()})),u]})]})}function j3({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:a,onView:o,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h,actions:p}){return s.jsxs(sE,{isBuiltIn:r,isConfirmingDelete:a,onView:o,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h,actions:p,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 t1({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:o,onDelete:c,onToggle:u,readOnly:d=!1}){return s.jsx(j3,{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(ds,{enabled:e.enabled,onClick:u,label:`Activation for ${e.name}`})})}function E3({skill:e,deleting:t,error:n,onClose:r,onConfirm:a}){return s.jsxs(wt,{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 N3({isOpen:e}){const t=Hn(re=>re.defaults),n=Hn(re=>re.userItems),r=Hn(re=>re.projectItems),a=Hn(re=>re.items),o=Hn(re=>re.selectedDirectory),c=Hn(re=>re.diagnostics),u=Hn(re=>re.loading),d=Hn(re=>re.fetchSkills),h=Hn(re=>re.setWorkdir),p=Hn(re=>re.fetchSkill),m=Hn(re=>re.fetchDefaultContent),g=Hn(re=>re.createSkill),x=Hn(re=>re.updateSkill),w=Hn(re=>re.deleteSkill),C=Hn(re=>re.selectDirectory),v=Hn(re=>re.removeDirectory),S=Hn(re=>re.installSkill),_=Hn(re=>re.toggleSkill),b=Re(re=>re.currentSession),[k,E]=j.useState(null),[T,D]=j.useState(!1),[A,R]=j.useState(""),{view:M,editingId:W,formError:$,saving:G,formData:B,setView:H,setEditingId:q,setFormError:Q,setFormData:J,setSaving:U}=eE(),{clearConfirm:I}=gu();j.useEffect(()=>{if(e){const re=(b==null?void 0:b.workdir)??null;h(re),d(re),H("list"),q(null),I()}},[e,d,h,I,b==null?void 0:b.workdir]);const O=(re,ae,ye,_e)=>{J({name:_e??re.metadata.name,id:ye??re.metadata.id,description:re.metadata.description??"",version:re.metadata.version??"1.0.0",prompt:re.prompt,isReadOnly:ae,destination:"user"})},V=async re=>{if(t.some(ye=>ye.id===re)){const ye=await m(re);if(!ye)return;O(ye,!0),q(re),Q(""),H("edit")}else{const ye=await p(re);if(!ye)return;O(ye,!0),q(re),Q(""),H("edit")}},z=async re=>{const ye=t.some(Ie=>Ie.id===re)?await m(re):await p(re);if(!ye)return;const _e=`${re}-copy-${Date.now()}`;O(ye,!1,_e,`${ye.metadata.name} (copy)`),q(null),Q(""),H("edit")},Y=()=>{J({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),H("edit")},X=async re=>{const ae=await p(re);ae&&(O(ae,!1),q(re),Q(""),H("edit"))},Z=async()=>{if(!k)return;D(!0),R("");const re=await w(k.id);if(D(!1),!re.success){R(re.error??"Failed to delete skill.");return}await d(),E(null),I()},F=async()=>{const re=W??B.id;if(!re||!B.name||!B.prompt){Q("Name, ID, and prompt are required.");return}U(!0),Q("");const ae={metadata:{id:re,name:B.name,description:B.description,version:B.version},prompt:B.prompt},ye=W?await x(W,ae):await g(ae,B.destination);if(U(!1),!ye.success){Q(ye.error??"Failed to save skill.");return}H("list")},P=re=>{J(ae=>({...ae,name:re})),W||J(ae=>({...ae,id:re.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},te=B.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:te?B.name:W?"Edit Skill":"New Skill"}),s.jsx("button",{onClick:()=>H("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),$&&s.jsx(ll,{message:$}),s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsx(Zj,{name:B.name,id:B.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:P,onIdChange:()=>{}}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(Xr,{label:"Description",value:B.description,onChange:re=>J(ae=>({...ae,description:re})),placeholder:"What this skill does...",readOnly:te}),s.jsx(Xr,{label:"Version",value:B.version,onChange:re=>J(ae=>({...ae,version:re})),placeholder:"1.0.0",readOnly:te})]})]}),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:B.prompt,onChange:re=>J(ae=>({...ae,prompt:re.target.value})),readOnly:te,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"})]}),!W&&s.jsx(Af,{value:B.destination,onChange:re=>J(ae=>({...ae,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:()=>H("list"),children:"Cancel"}),te?s.jsx(ot,{variant:"primary",onClick:()=>{J(re=>({...re,name:re.name+" (copy)",id:`${W}-copy-${Date.now()}`,isReadOnly:!1})),q(null)},children:"Duplicate & Customize"}):s.jsx(ot,{variant:"primary",onClick:F,disabled:G||!B.name||!B.id||!B.prompt,children:G?"Saving...":"Save"})]})]});function se({items:re}){return re.map(ae=>s.jsx(t1,{skill:ae,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>V(ae.id),onEdit:()=>X(ae.id),onDuplicate:()=>z(ae.id),onDelete:()=>{R(""),E(ae)},onToggle:()=>_(ae.id),readOnly:ae.readOnly},ae.id))}return s.jsxs("div",{children:[s.jsx(E3,{skill:k,deleting:T,error:A,onClose:()=>{T||E(null)},onConfirm:Z}),s.jsx(k3,{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,ae)=>s.jsx("p",{children:re},`${re}-${ae}`))}),s.jsx(Qj,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:Y}),s.jsxs(nb,{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(t1,{skill:re,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>V(re.id),onDuplicate:()=>z(re.id),onToggle:()=>_(re.id)},re.id))})]}),n.length>0&&s.jsx(Jj,{children:s.jsx(se,{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(se,{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(se,{items:r})})]})]})]})}function ra(){const e=Rt(a=>a.settings),t=Rt(a=>a.loading),n=Rt(a=>a.getSetting),r=Rt(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function T3({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:a}=ra(),o=t[Ne.GLOBAL_INSTRUCTIONS]??"",c=n[Ne.GLOBAL_INSTRUCTIONS]??!1,[u,d]=j.useState(o),[h,p]=j.useState(!1),[m,g]=j.useState(!1);j.useEffect(()=>{e&&r(Ne.GLOBAL_INSTRUCTIONS)},[e,r]),j.useEffect(()=>{d(o),p(!1)},[o]);const x=async()=>{g(!0),await a(Ne.GLOBAL_INSTRUCTIONS,u),g(!1),p(!1)},w=()=>{d(o),p(!1)},C=c||m;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),p(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),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:m?"Saving...":"Save"})]})]})}function A3(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 _h(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 L3({isOpen:e,isNew:t,basePresetId:n,presetName:r,mode:a,initialTokens:o,onClose:c,onSave:u}){const[d,h]=j.useState(o),[p,m]=j.useState(r),[g,x]=j.useState(a);j.useEffect(()=>{h(o),m(r)},[o,r]);const w=(b,k)=>{const E=k.startsWith("#")?A3(k):k;h(T=>({...T,[b]:E}))},C=()=>{u(p.trim()||"Untitled",{...d},g)},v=zj.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"},_=ar.find(b=>b.id===n);return s.jsx(wt,{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:p,onChange:b=>m(b.target.value),className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),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:_h(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 n1({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":_h(e.tokens["color-bg-primary"]??"#000"),borderColor:_h(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:_h(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(ta,{className:"w-3 h-3"})})]})}function D3(){const[e,t]=j.useState(null),n=Kt($=>$.currentPreset),r=Kt($=>$.isCustom),a=Kt($=>$.basePreset),o=Kt($=>$.isSystem),c=Kt($=>$.systemDarkPreset),u=Kt($=>$.systemLightPreset),d=Kt($=>$.applyPreset),h=Kt($=>$.applyUserPreset),p=Kt($=>$.deleteUserPreset),m=Kt($=>$.saveTheme),g=Kt($=>$.setSystemDarkPreset),x=Kt($=>$.setSystemLightPreset),w=Kt($=>$.activeUserPresetId),C=Kt($=>$.userPresets),v=ar.filter($=>$.mode==="dark"),S=ar.filter($=>$.mode==="light"),_=$=>{var G;if(o){const B=C[$];if(!B)return;const H=B.mode??((G=ar.find(q=>q.id===B.basePreset))==null?void 0:G.mode);H==="dark"?g(B.id):H==="light"&&x(B.id)}else h($)},b=$=>{const G=ar.find(B=>B.id===$);G&&t({type:"new",presetIndex:C.length,basePresetId:$,presetName:G.name+" Copy",mode:G.mode??"dark",tokens:{...G.tokens}})},k=$=>{const G=C[$];if(!G)return;const B=ar.find(q=>q.id===G.basePreset),H=B?{...B.tokens,...G.tokens}:G.tokens;t({type:"edit",presetIndex:$,basePresetId:G.basePreset,presetName:G.name,mode:G.mode??"dark",tokens:H})},E=($,G,B)=>{if(!e)return;const H=[...C];if(e.type==="new"){const q={id:"custom-"+Date.now(),name:$,basePreset:e.basePresetId,mode:B,tokens:G};H.push(q);const Q=H.length-1;Kt.setState({userPresets:H}),Kt.getState().saveUserPresets(),Kt.getState().applyUserPreset(Q)}else{const q=H[e.presetIndex];q&&(H[e.presetIndex]={...q,name:$,mode:B,tokens:G}),Kt.setState({userPresets:H}),Kt.getState().saveUserPresets(),Kt.getState().applyUserPreset(e.presetIndex)}t(null)},T=()=>{t(null)},D=($,G)=>{$.stopPropagation(),p(G)},A=o?"system":r?a:n,R=()=>{o?(d(n),m(JSON.stringify({preset:n})).catch(()=>{})):(d("system"),m(JSON.stringify({preset:"system"})).catch(()=>{}))},M=$=>{if(o){const G=ar.find(B=>B.id===$);(G==null?void 0:G.mode)==="dark"?g($):(G==null?void 0:G.mode)==="light"&&x($)}else d($),m(JSON.stringify({preset:$})).catch(()=>{})},W=$=>{const G=ar.find(B=>B.id===$.basePreset);return G?{...G.tokens,...$.tokens}:$.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:R,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:$,mode:G})=>{const B=G==="dark"?v:S,H=C.filter(q=>{var J;return(q.mode??((J=ar.find(U=>U.id===q.basePreset))==null?void 0:J.mode))===G});return s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:$}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[B.map(q=>s.jsx(n1,{preset:q,isActive:q.id===A&&!r,isUnderlying:o&&(q.id===c||q.id===u),onClick:()=>M(q.id),onNewFrom:()=>b(q.id)},q.id)),H.map(q=>{const Q=C.indexOf(q),J=W(q);return s.jsx(n1,{preset:{id:q.id,name:q.name,tokens:J},isActive:w===q.id,isUnderlying:o&&(q.id===c||q.id===u),onClick:()=>_(Q),onEdit:()=>k(Q),onDelete:U=>D(U,Q)},q.id)})]})]},$)}),e&&s.jsx(L3,{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 R3=["monospace","serif","sans-serif"],iE=["JetBrains Mono","Cascadia Mono","Menlo","Consolas","DejaVu Sans Mono","Liberation Mono"],Sh=`${iE.map(e=>`"${e}"`).join(", ")}, monospace`,O3=["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"],I3="mmmmmmmmmmlliWWWW@0Oo",M3="72px";let jc;function P3(){if(jc!==void 0)return jc;try{jc=document.createElement("canvas").getContext("2d")}catch{jc=null}return jc}function rb(e){const t=P3();if(!t)throw new Error("Canvas 2D context unavailable");return t.font=`${M3} ${e}`,t.measureText(I3).width}function aE(e,t=rb){const n=e.trim();if(!n)return!1;try{return R3.some(r=>{const a=t(r);return t(`"${n}", ${r}`)!==a})}catch{return!1}}function B3(e=O3,t=rb){const n=new Set;for(const r of e)aE(r,t)&&n.add(r);return[...n].sort((r,a)=>r.localeCompare(a))}function $3(e=iE,t=rb){return e.find(n=>aE(n,t))??""}function z3(e){const t=e.trim();return t?`"${t}", monospace`:""}function H3(e){var n;return(((n=e.split(",")[0])==null?void 0:n.trim())??"").replace(/^['"]|['"]$/g,"")}function F3(){return s.jsx(D3,{})}function U3(){const{settings:e,loading:t,getSetting:n,setSetting:r}=ra(),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"}],p=[{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"}],m=[...h,...p],g=Object.fromEntries(h.map(_=>[_.key,e[_.key]??"true"])),x=Object.fromEntries(p.map(_=>[_.key,e[_.key]??_.defaultValue])),w={...g,...x},[C,v]=j.useState(()=>Object.fromEntries(m.map(_=>[_.key,w[_.key]==="true"])));j.useEffect(()=>{m.forEach(_=>n(_.key))},[n]),j.useEffect(()=>{v(Object.fromEntries(m.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(F3,{}),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(W3,{})]}),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:p,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(G3,{})]})]})}const V3="~/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 G3(){const{settings:e,getSetting:t,setSetting:n}=ra(),r=e[Ne.DISPLAY_TERMINAL_FONT]??Sh,[a,o]=j.useState(r),c=j.useMemo(()=>B3(),[]),u=j.useMemo(()=>$3(),[]);j.useEffect(()=>{t(Ne.DISPLAY_TERMINAL_FONT)},[t]),j.useEffect(()=>{o(r)},[r]);const h=r===Sh?u:H3(r),p=h!==""&&!c.includes(h),m=x=>{const w=x.target.value;w&&n(Ne.DISPLAY_TERMINAL_FONT,z3(w))},g=()=>{n(Ne.DISPLAY_TERMINAL_FONT,a.trim()||Sh)};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:p?"":h,onChange:m,className:"w-full px-2 py-1.5 text-sm text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",children:[p&&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(ht,{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:V3}),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 W3(){const{settings:e,getSetting:t,setSetting:n}=ra(),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 Ux(){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 q3(e){try{return new RegExp(e),!0}catch{return!1}}function K3({value:e,onChange:t}){const[n,r]=j.useState({}),a=(d,h)=>{const p=e.patterns.map((m,g)=>g===d?{...m,...h}:m);t({...e,patterns:p})},o=d=>{const h=e.patterns.filter((p,m)=>m!==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(p=>({...p,[d]:h.length>0&&!q3(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),p=isNaN(h)?10:Math.max(1,Math.min(100,h));t({...e,maxRetriesPerTurn:p})},className:"mt-1 block w-24 px-2 py-1 text-sm bg-bg-secondary border border-border rounded"})]}),e.patterns.length===0?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:p=>a(h,{field:p.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:p=>u(h,p.target.value),placeholder:"regex pattern",className:"flex-1 px-2 py-1 bg-bg-secondary border border-border rounded text-sm font-mono"}),d.pattern.length>0&&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 s1=1e3,Y3=3e4;function i1({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 oE({isOpen:e,onClose:t,versionInfo:n}){const[r,a]=j.useState("ready"),[o,c]=j.useState(""),[u,d]=j.useState(n),[h,p]=j.useState(null),[m,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),D=j.useRef(n);D.current=n,j.useEffect(()=>{if(!e)return;let J=!1;return(async()=>{try{const I=await(await fetch(ms("/api/auto-update/check"))).json();if(J)return;v(!!I.isService),!D.current&&I.current&&I.latest&&d({current:I.current,latest:I.latest})}catch{J||v(!1)}})(),()=>{J=!0}},[e]),j.useEffect(()=>{if(!e||r!=="updating"&&r!=="restarting")return;const J=setInterval(()=>{c(U=>U.length>=3?"":U+".")},400);return()=>clearInterval(J)},[e,r]);const A=j.useCallback(()=>{k.current!==null&&(clearTimeout(k.current),k.current=null),E.current=null},[]),R=j.useCallback(J=>{g(J),a("restartFailed")},[]),M=j.useCallback(J=>{b.current=J,_(J)},[]),W=j.useCallback(J=>{localStorage.setItem("openfox_updated_to",J),localStorage.setItem("update_pending","true")},[]),$=j.useCallback(async J=>{a("restarting"),g(null),A();try{await xe("/api/auto-update/restart",{method:"POST"})}catch{}if(!T.current)return;E.current=Date.now();const U=async()=>{if(!T.current){A();return}const I=E.current;if(I!==null&&Date.now()-I>=Y3){A(),R("OpenFox could not be reached after restart within 30 seconds. Please restart OpenFox manually.");return}try{const O=await fetch(ms("/api/auto-update/check?force=true"));if(!O.ok)throw new Error(`HTTP ${O.status}`);if((await O.json()).current===J){A(),W(J),window.location.reload();return}}catch{}if(!T.current){A();return}k.current=setTimeout(()=>{U()},s1)};k.current=setTimeout(()=>{U()},s1)},[A,R,W]),G=j.useCallback(async()=>{a("updating"),g(null);try{const U=await(await xe("/api/auto-update",{method:"POST"})).json();if(U.success){const I=U.version??"unknown";p(I),w(!!U.isService),b.current&&U.isService?$(I):a("complete")}else g(U.error??"Update failed"),a("failed")}catch(J){g(J instanceof Error?J.message:"Update request failed"),a("failed")}},[$]),B=j.useCallback(()=>{const J=h??(u==null?void 0:u.latest)??null;if(!J){R("Installed version unknown; cannot verify restart.");return}$(J)},[h,u,R,$]);j.useEffect(()=>(T.current=!0,()=>{T.current=!1,A()}),[A]),j.useEffect(()=>{e&&(c(""),A(),a("ready"),p(null),g(null),w(!1),v(!1),M(!1))},[e,A,M]);const H=r!=="updating"&&r!=="restarting",q=J=>J,Q=r==="failed"?"Update Failed":r==="restarting"?"Restarting…":r==="complete"?"Update Complete":r==="restartFailed"?"Restart Not Confirmed":"New OpenFox version available";return s.jsxs(wt,{isOpen:e,onClose:H?t:void 0,title:Q,size:"md",closeOnBackdropClick:H,showCloseButton:H,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:q(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(i1,{message:m,command:"openfox update",hint:"Run this command in your terminal to complete the update."}),r==="restartFailed"&&s.jsx(i1,{message:m,command:"openfox service restart",hint:"Run this command in your terminal to restart OpenFox."})]}),r==="ready"&&s.jsx("button",{onClick:G,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:B,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 cn({children:e,className:t="",horizontal:n=!1,style:r,scope:a="toolCalls"}){const{useNativeScrollbars:o,useNativeScrollbarsCodeBlocks:c}=Ds();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(ht,{horizontal:n,className:t,style:r,children:e})}function X3(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const J3=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Q3=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Z3={};function a1(e,t){return(Z3.jsx?Q3:J3).test(e)}const eO=/[ \t\n\f\r]/g;function tO(e){return typeof e=="object"?e.type==="text"?o1(e.value):!1:o1(e)}function o1(e){return e.replace(eO,"")===""}let yu=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};yu.prototype.normal={};yu.prototype.property={};yu.prototype.space=void 0;function lE(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new yu(n,r,t)}function Vx(e){return e.toLowerCase()}let br=class{constructor(t,n){this.attribute=n,this.property=t}};br.prototype.attribute="";br.prototype.booleanish=!1;br.prototype.boolean=!1;br.prototype.commaOrSpaceSeparated=!1;br.prototype.commaSeparated=!1;br.prototype.defined=!1;br.prototype.mustUseProperty=!1;br.prototype.number=!1;br.prototype.overloadedBoolean=!1;br.prototype.property="";br.prototype.spaceSeparated=!1;br.prototype.space=void 0;let nO=0;const pt=eo(),An=eo(),Gx=eo(),Ke=eo(),Qt=eo(),Wa=eo(),Nr=eo();function eo(){return 2**++nO}const Wx=Object.freeze(Object.defineProperty({__proto__:null,boolean:pt,booleanish:An,commaOrSpaceSeparated:Nr,commaSeparated:Wa,number:Ke,overloadedBoolean:Gx,spaceSeparated:Qt},Symbol.toStringTag,{value:"Module"})),Lg=Object.keys(Wx);let sb=class extends br{constructor(t,n,r,a){let o=-1;if(super(t,n),l1(this,"space",a),typeof r=="number")for(;++o<Lg.length;){const c=Lg[o];l1(this,Lg[o],(r&Wx[c])===Wx[c])}}};sb.prototype.defined=!0;function l1(e,t,n){n&&(e[t]=n)}function Cl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const o=new sb(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Vx(r)]=r,n[Vx(o.attribute)]=r}return new yu(t,n,e.space)}const cE=Cl({properties:{ariaActiveDescendant:null,ariaAtomic:An,ariaAutoComplete:null,ariaBusy:An,ariaChecked:An,ariaColCount:Ke,ariaColIndex:Ke,ariaColSpan:Ke,ariaControls:Qt,ariaCurrent:null,ariaDescribedBy:Qt,ariaDetails:null,ariaDisabled:An,ariaDropEffect:Qt,ariaErrorMessage:null,ariaExpanded:An,ariaFlowTo:Qt,ariaGrabbed:An,ariaHasPopup:null,ariaHidden:An,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Qt,ariaLevel:Ke,ariaLive:null,ariaModal:An,ariaMultiLine:An,ariaMultiSelectable:An,ariaOrientation:null,ariaOwns:Qt,ariaPlaceholder:null,ariaPosInSet:Ke,ariaPressed:An,ariaReadOnly:An,ariaRelevant:null,ariaRequired:An,ariaRoleDescription:Qt,ariaRowCount:Ke,ariaRowIndex:Ke,ariaRowSpan:Ke,ariaSelected:An,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 uE(e,t){return t in e?e[t]:t}function dE(e,t){return uE(e,t.toLowerCase())}const rO=Cl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Wa,acceptCharset:Qt,accessKey:Qt,action:null,allow:null,allowFullScreen:pt,allowPaymentRequest:pt,allowUserMedia:pt,alpha:pt,alt:null,as:null,async:pt,autoCapitalize:null,autoComplete:Qt,autoFocus:pt,autoPlay:pt,blocking:Qt,capture:null,charSet:null,checked:pt,cite:null,className:Qt,closedBy:null,colorSpace:null,cols:Ke,colSpan:Ke,command:null,commandFor:null,content:null,contentEditable:An,controls:pt,controlsList:Qt,coords:Ke|Wa,crossOrigin:null,data:null,dateTime:null,decoding:null,default:pt,defer:pt,dir:null,dirName:null,disabled:pt,download:Gx,draggable:An,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:pt,formTarget:null,headers:Qt,height:Ke,hidden:Gx,high:Ke,href:null,hrefLang:null,htmlFor:Qt,httpEquiv:Qt,id:null,imageSizes:null,imageSrcSet:null,inert:pt,inputMode:null,integrity:null,is:null,isMap:pt,itemId:null,itemProp:Qt,itemRef:Qt,itemScope:pt,itemType:Qt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:pt,low:Ke,manifest:null,max:null,maxLength:Ke,media:null,method:null,min:null,minLength:Ke,multiple:pt,muted:pt,name:null,nonce:null,noModule:pt,noValidate:pt,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:pt,optimum:Ke,pattern:null,ping:Qt,placeholder:null,playsInline:pt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:pt,referrerPolicy:null,rel:Qt,required:pt,reversed:pt,rows:Ke,rowSpan:Ke,sandbox:Qt,scope:null,scoped:pt,seamless:pt,selected:pt,shadowRootClonable:pt,shadowRootCustomElementRegistry:pt,shadowRootDelegatesFocus:pt,shadowRootMode:null,shadowRootSerializable:pt,shape:null,size:Ke,sizes:null,slot:null,span:Ke,spellCheck:An,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:pt,useMap:null,value:An,width:Ke,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Qt,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:pt,declare:pt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ke,leftMargin:Ke,link:null,longDesc:null,lowSrc:null,marginHeight:Ke,marginWidth:Ke,noResize:pt,noHref:pt,noShade:pt,noWrap:pt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ke,rules:null,scheme:null,scrolling:An,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:pt,disablePictureInPicture:pt,disableRemotePlayback:pt,exportParts:Wa,part:Qt,prefix:null,property:null,results:Ke,security:null,unselectable:null},space:"html",transform:dE}),sO=Cl({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:Nr,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:Qt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ke,diffuseConstant:Ke,direction:null,display:null,dur:null,divisor:Ke,dominantBaseline:null,download:pt,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:Wa,g2:Wa,glyphName:Wa,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:Nr,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:Qt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ke,pointsAtY:Ke,pointsAtZ:Ke,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Nr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Nr,rev:Nr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Nr,requiredFeatures:Nr,requiredFonts:Nr,requiredFormats:Nr,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:Nr,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:Nr,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:Nr,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:uE}),hE=Cl({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()}}),fE=Cl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:dE}),mE=Cl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),iO={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"},aO=/[A-Z]/g,c1=/-[a-z]/g,oO=/^data[-\w.:]+$/i;function lO(e,t){const n=Vx(t);let r=t,a=br;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&oO.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(c1,uO);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!c1.test(o)){let c=o.replace(aO,cO);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=sb}return new a(r,t)}function cO(e){return"-"+e.toLowerCase()}function uO(e){return e.charAt(1).toUpperCase()}const dO=lE([cE,rO,hE,fE,mE],"html"),ib=lE([cE,sO,hE,fE,mE],"svg");function hO(e){return e.join(" ").trim()}var Ho={},Dg,u1;function fO(){if(u1)return Dg;u1=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="/",p="*",m="",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(B){var H=B.match(t);H&&(_+=H.length);var q=B.lastIndexOf(d);b=~q?B.length-q:b+B.length}function E(){var B={line:_,column:b};return function(H){return H.position=new T(B),R(),H}}function T(B){this.start=B,this.end={line:_,column:b},this.source=S.source}T.prototype.content=v;function D(B){var H=new Error(S.source+":"+_+":"+b+": "+B);if(H.reason=B,H.filename=S.source,H.line=_,H.column=b,H.source=v,!S.silent)throw H}function A(B){var H=B.exec(v);if(H){var q=H[0];return k(q),v=v.slice(q.length),H}}function R(){A(n)}function M(B){var H;for(B=B||[];H=W();)H!==!1&&B.push(H);return B}function W(){var B=E();if(!(h!=v.charAt(0)||p!=v.charAt(1))){for(var H=2;m!=v.charAt(H)&&(p!=v.charAt(H)||h!=v.charAt(H+1));)++H;if(H+=2,m===v.charAt(H-1))return D("End of comment missing");var q=v.slice(2,H-2);return b+=2,k(q),v=v.slice(H),b+=2,B({type:g,comment:q})}}function $(){var B=E(),H=A(r);if(H){if(W(),!A(a))return D("property missing ':'");var q=A(o),Q=B({type:x,property:C(H[0].replace(e,m)),value:q?C(q[0].replace(e,m)):m});return A(c),Q}}function G(){var B=[];M(B);for(var H;H=$();)H!==!1&&(B.push(H),M(B));return B}return R(),G()}function C(v){return v?v.replace(u,m):m}return Dg=w,Dg}var d1;function mO(){if(d1)return Ho;d1=1;var e=Ho&&Ho.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ho,"__esModule",{value:!0}),Ho.default=n;const t=e(fO());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:p}=d;u?a(h,p,d):p&&(o=o||{},o[h]=p)}),o}return Ho}var Ec={},h1;function pO(){if(h1)return Ec;h1=1,Object.defineProperty(Ec,"__esModule",{value:!0}),Ec.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,p){return p.toUpperCase()},u=function(h,p){return"".concat(p,"-")},d=function(h,p){return p===void 0&&(p={}),o(h)?h:(h=h.toLowerCase(),p.reactCompat?h=h.replace(a,u):h=h.replace(r,u),h.replace(t,c))};return Ec.camelCase=d,Ec}var Nc,f1;function gO(){if(f1)return Nc;f1=1;var e=Nc&&Nc.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(mO()),n=pO();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,Nc=r,Nc}var xO=gO();const yO=uf(xO),pE=gE("end"),ab=gE("start");function gE(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 bO(e){const t=ab(e),n=pE(e);if(t&&n)return{start:t,end:n}}function Gc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?m1(e.position):"start"in e||"end"in e?m1(e):"line"in e||"column"in e?qx(e):""}function qx(e){return p1(e&&e.line)+":"+p1(e&&e.column)}function m1(e){return qx(e&&e.start)+"-"+qx(e&&e.end)}function p1(e){return e&&typeof e=="number"?e:1}class nr 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=Gc(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}}nr.prototype.file="";nr.prototype.name="";nr.prototype.reason="";nr.prototype.message="";nr.prototype.stack="";nr.prototype.column=void 0;nr.prototype.line=void 0;nr.prototype.ancestors=void 0;nr.prototype.cause=void 0;nr.prototype.fatal=void 0;nr.prototype.place=void 0;nr.prototype.ruleId=void 0;nr.prototype.source=void 0;const ob={}.hasOwnProperty,vO=new Map,_O=/[A-Z]/g,SO=new Set(["table","tbody","thead","tfoot","tr"]),wO=new Set(["td","th"]),xE="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function CO(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=DO(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=LO(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"?ib:dO,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=yE(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function yE(e,t,n){if(t.type==="element")return kO(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return jO(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return NO(e,t,n);if(t.type==="mdxjsEsm")return EO(e,t);if(t.type==="root")return TO(e,t,n);if(t.type==="text")return AO(e,t)}function kO(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=ib,e.schema=a),e.ancestors.push(t);const o=vE(e,t.tagName,!1),c=RO(e,t);let u=cb(e,t);return SO.has(t.tagName)&&(u=u.filter(function(d){return typeof d=="string"?!tO(d):!0})),bE(e,c,o,t),lb(c,u),e.ancestors.pop(),e.schema=r,e.create(t,o,c,n)}function jO(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)}iu(e,t.position)}function EO(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);iu(e,t.position)}function NO(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=ib,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:vE(e,t.name,!0),c=OO(e,t),u=cb(e,t);return bE(e,c,o,t),lb(c,u),e.ancestors.pop(),e.schema=r,e.create(t,o,c,n)}function TO(e,t,n){const r={};return lb(r,cb(e,t)),e.create(t,e.Fragment,r,n)}function AO(e,t){return t.value}function bE(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function lb(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function LO(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 DO(e,t){return n;function n(r,a,o,c){const u=Array.isArray(o.children),d=ab(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 RO(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&ob.call(t.properties,a)){const o=IO(e,a,t.properties[a]);if(o){const[c,u]=o;e.tableCellAlignToStyle&&c==="align"&&typeof u=="string"&&wO.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 OO(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 iu(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 iu(e,t.position);else o=r.value===null?!0:r.value;n[a]=o}return n}function cb(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:vO;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=yE(e,o,c);u!==void 0&&n.push(u)}return n}function IO(e,t,n){const r=lO(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?X3(n):hO(n)),r.property==="style"){let a=typeof n=="object"?n:MO(e,String(n));return e.stylePropertyNameCase==="css"&&(a=PO(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?iO[r.property]||r.property:r.attribute,n]}}function MO(e,t){try{return yO(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new nr("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=xE+"#cannot-parse-style-attribute",a}}function vE(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=a1(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=a1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return ob.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);iu(e)}function iu(e,t){const n=new nr("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=xE+"#cannot-handle-mdx-estrees-without-createevaluater",n}function PO(e){const t={};let n;for(n in e)ob.call(e,n)&&(t[BO(n)]=e[n]);return t}function BO(e){let t=e.replace(_O,$O);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function $O(e){return"-"+e.toLowerCase()}const Rg={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"]},zO={};function ub(e,t){const n=zO,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return _E(e,r,a)}function _E(e,t,n){if(HO(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 g1(e.children,t,n)}return Array.isArray(e)?g1(e,t,n):""}function g1(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=_E(e[a],t,n);return r.join("")}function HO(e){return!!(e&&typeof e=="object")}const x1=document.createElement("i");function db(e){const t="&"+e+";";x1.innerHTML=t;const n=x1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Rr(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 Wr(e,t){return e.length>0?(Rr(e,e.length,0,t),e):t}const y1={}.hasOwnProperty;function SE(e){const t={};let n=-1;for(;++n<e.length;)FO(t,e[n]);return t}function FO(e,t){let n;for(n in t){const a=(y1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let c;if(o)for(c in o){y1.call(a,c)||(a[c]=[]);const u=o[c];UO(a[c],Array.isArray(u)?u:u?[u]:[])}}}function UO(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Rr(e,0,0,r)}function wE(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 hs(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const or=sa(/[A-Za-z]/),tr=sa(/[\dA-Za-z]/),VO=sa(/[#-'*+\--9=?A-Z^-~]/);function Ph(e){return e!==null&&(e<32||e===127)}const Kx=sa(/\d/),GO=sa(/[\dA-Fa-f]/),WO=sa(/[!-/:-@[-`{-~]/);function ut(e){return e!==null&&e<-2}function tn(e){return e!==null&&(e<0||e===32)}function Et(e){return e===-2||e===-1||e===32}const Df=sa(new RegExp("\\p{P}|\\p{S}","u")),Xa=sa(/\s/);function sa(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function kl(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const o=e.charCodeAt(n);let c="";if(o===37&&tr(e.charCodeAt(n+1))&&tr(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 Lt(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(d){return Et(d)?(e.enter(n),u(d)):t(d)}function u(d){return Et(d)&&o++<a?(e.consume(d),u):(e.exit(n),t(d))}}const qO={tokenize:KO};function KO(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"),Lt(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 ut(u)?(e.consume(u),e.exit("chunkText"),o):(e.consume(u),c)}}const YO={tokenize:XO},b1={tokenize:JO};function XO(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 D=k;for(;D<t.events.length;)t.events[D][1].end={...T},D++;return Rr(t.events,E+1,0,t.events.slice(k)),t.events.length=D,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(b1,p,m)(b)}function p(b){return a&&_(),S(r),g(b)}function m(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(b1,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 ut(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 D=t.events.length;let A=D,R,M;for(;A--;)if(t.events[A][0]==="exit"&&t.events[A][1].type==="chunkFlow"){if(R){M=t.events[A][1].end;break}R=!0}for(S(r),T=D;T<t.events.length;)t.events[T][1].end={...M},T++;Rr(t.events,A+1,0,t.events.slice(D)),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 JO(e,t,n){return Lt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function gl(e){if(e===null||tn(e)||Xa(e))return 1;if(Df(e))return 2}function Rf(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 Yx={name:"attention",resolveAll:QO,tokenize:ZO};function QO(e,t){let n=-1,r,a,o,c,u,d,h,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;d=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const m={...e[r][1].end},g={...e[n][1].start};v1(m,-d),v1(g,d),c={type:d>1?"strongSequence":"emphasisSequence",start:m,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=Wr(h,[["enter",e[r][1],t],["exit",e[r][1],t]])),h=Wr(h,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),h=Wr(h,Rf(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),h=Wr(h,[["exit",o,t],["enter",u,t],["exit",u,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,h=Wr(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,Rr(e,r-1,n-r+3,h),n=r+h.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function ZO(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=gl(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"),p=gl(d),m=!p||p===2&&a||n.includes(d),g=!a||a===2&&p||n.includes(r);return h._open=!!(o===42?m:m&&(a||!g)),h._close=!!(o===42?g:g&&(p||!m)),t(d)}}function v1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const eI={name:"autolink",tokenize:tI};function tI(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 or(x)?(e.consume(x),c):x===64?n(x):h(x)}function c(x){return x===43||x===45||x===46||tr(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||tr(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||Ph(x)?n(x):(e.consume(x),d)}function h(x){return x===64?(e.consume(x),p):VO(x)?(e.consume(x),h):n(x)}function p(x){return tr(x)?m(x):n(x)}function m(x){return x===46?(e.consume(x),r=0,p):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||tr(x))&&r++<63){const w=x===45?g:m;return e.consume(x),w}return n(x)}}const bu={partial:!0,tokenize:nI};function nI(e,t,n){return r;function r(o){return Et(o)?Lt(e,a,"linePrefix")(o):a(o)}function a(o){return o===null||ut(o)?t(o):n(o)}}const CE={continuation:{tokenize:sI},exit:iI,name:"blockQuote",tokenize:rI};function rI(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 Et(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function sI(e,t,n){const r=this;return a;function a(c){return Et(c)?Lt(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):o(c)}function o(c){return e.attempt(CE,t,n)(c)}}function iI(e){e.exit("blockQuote")}const kE={name:"characterEscape",tokenize:aI};function aI(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 WO(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const jE={name:"characterReference",tokenize:oI};function oI(e,t,n){const r=this;let a=0,o,c;return u;function u(m){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),d}function d(m){return m===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(m),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),o=31,c=tr,p(m))}function h(m){return m===88||m===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(m),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,c=GO,p):(e.enter("characterReferenceValue"),o=7,c=Kx,p(m))}function p(m){if(m===59&&a){const g=e.exit("characterReferenceValue");return c===tr&&!db(r.sliceSerialize(g))?n(m):(e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(m)&&a++<o?(e.consume(m),p):n(m)}}const _1={partial:!0,tokenize:cI},S1={concrete:!0,name:"codeFenced",tokenize:lI};function lI(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 D=r.events[r.events.length-1];return o=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,u=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(T)}function p(T){return T===u?(c++,e.consume(T),p):c<3?n(T):(e.exit("codeFencedFenceSequence"),Et(T)?Lt(e,m,"whitespace")(T):m(T))}function m(T){return T===null||ut(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(_1,C,k)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(T))}function g(T){return T===null||ut(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),m(T)):Et(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Lt(e,x,"whitespace")(T)):T===96&&T===u?n(T):(e.consume(T),g)}function x(T){return T===null||ut(T)?m(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(T))}function w(T){return T===null||ut(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),m(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&&Et(T)?Lt(e,_,"linePrefix",o+1)(T):_(T)}function _(T){return T===null||ut(T)?e.check(_1,C,k)(T):(e.enter("codeFlowValue"),b(T))}function b(T){return T===null||ut(T)?(e.exit("codeFlowValue"),_(T)):(e.consume(T),b)}function k(T){return e.exit("codeFenced"),t(T)}function E(T,D,A){let R=0;return M;function M(H){return T.enter("lineEnding"),T.consume(H),T.exit("lineEnding"),W}function W(H){return T.enter("codeFencedFence"),Et(H)?Lt(T,$,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):$(H)}function $(H){return H===u?(T.enter("codeFencedFenceSequence"),G(H)):A(H)}function G(H){return H===u?(R++,T.consume(H),G):R>=c?(T.exit("codeFencedFenceSequence"),Et(H)?Lt(T,B,"whitespace")(H):B(H)):A(H)}function B(H){return H===null||ut(H)?(T.exit("codeFencedFence"),D(H)):A(H)}}}function cI(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 Og={name:"codeIndented",tokenize:dI},uI={partial:!0,tokenize:hI};function dI(e,t,n){const r=this;return a;function a(h){return e.enter("codeIndented"),Lt(e,o,"linePrefix",5)(h)}function o(h){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?c(h):n(h)}function c(h){return h===null?d(h):ut(h)?e.attempt(uI,c,d)(h):(e.enter("codeFlowValue"),u(h))}function u(h){return h===null||ut(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),u)}function d(h){return e.exit("codeIndented"),t(h)}}function hI(e,t,n){const r=this;return a;function a(c){return r.parser.lazy[r.now().line]?n(c):ut(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Lt(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):ut(c)?a(c):n(c)}}const fI={name:"codeText",previous:pI,resolve:mI,tokenize:gI};function mI(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 pI(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function gI(e,t,n){let r=0,a,o;return c;function c(m){return e.enter("codeText"),e.enter("codeTextSequence"),u(m)}function u(m){return m===96?(e.consume(m),r++,u):(e.exit("codeTextSequence"),d(m))}function d(m){return m===null?n(m):m===32?(e.enter("space"),e.consume(m),e.exit("space"),d):m===96?(o=e.enter("codeTextSequence"),a=0,p(m)):ut(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),d):(e.enter("codeTextData"),h(m))}function h(m){return m===null||m===32||m===96||ut(m)?(e.exit("codeTextData"),d(m)):(e.consume(m),h)}function p(m){return m===96?(e.consume(m),a++,p):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(m)):(o.type="codeTextData",h(m))}}class xI{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&&Tc(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),Tc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Tc(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);Tc(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Tc(this.left,n.reverse())}}}function Tc(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 EE(e){const t={};let n=-1,r,a,o,c,u,d,h;const p=new xI(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(d=r[1]._tokenizer.events,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,yI(p,n)),n=t[n],h=!0);else if(r[1]._container){for(o=n,a=void 0;o--;)if(c=p.get(o),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(a&&(p.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={...p.get(a)[1].start},u=p.slice(a,n),u.unshift(r),p.splice(a,n-a+1,u))}}return Rr(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!h}function yI(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 p,m,g=-1,x=n,w=0,C=0;const v=[C];for(;x;){for(;e.get(++a)[1]!==x;);o.push(a),x._tokenizer||(p=r.sliceStream(x),x.next||p.push(null),m&&c.defineSkip(x.start),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(p),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),m=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 bI={resolve:_I,tokenize:SI},vI={partial:!0,tokenize:wI};function _I(e){return EE(e),e}function SI(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):ut(u)?e.check(vI,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 wI(e,t,n){const r=this;return a;function a(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Lt(e,o,"linePrefix")}function o(c){if(c===null||ut(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 NE(e,t,n,r,a,o,c,u,d){const h=d||Number.POSITIVE_INFINITY;let p=0;return m;function m(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||Ph(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||ut(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!p&&(S===null||S===41||tn(S))?(e.exit("chunkString"),e.exit(u),e.exit(c),e.exit(r),t(S)):p<h&&S===40?(e.consume(S),p++,C):S===41?(e.consume(S),p--,C):S===null||S===32||S===40||Ph(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 TE(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),p}function p(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):ut(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===null||x===91||x===93||ut(x)||u++>999?(e.exit("chunkString"),p(x)):(e.consume(x),d||(d=!Et(x)),x===92?g:m)}function g(x){return x===91||x===92||x===93?(e.consume(x),u++,m):m(x)}}function AE(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):ut(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Lt(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===c||g===null||ut(g)?(e.exit("chunkString"),h(g)):(e.consume(g),g===92?m:p)}function m(g){return g===c||g===92?(e.consume(g),p):p(g)}}function Wc(e,t){let n;return r;function r(a){return ut(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):Et(a)?Lt(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const CI={name:"definition",tokenize:jI},kI={partial:!0,tokenize:EI};function jI(e,t,n){const r=this;let a;return o;function o(x){return e.enter("definition"),c(x)}function c(x){return TE.call(r,e,u,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function u(x){return a=hs(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 tn(x)?Wc(e,h)(x):h(x)}function h(x){return NE(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function p(x){return e.attempt(kI,m,m)(x)}function m(x){return Et(x)?Lt(e,g,"whitespace")(x):g(x)}function g(x){return x===null||ut(x)?(e.exit("definition"),r.parser.defined.push(a),t(x)):n(x)}}function EI(e,t,n){return r;function r(u){return tn(u)?Wc(e,a)(u):n(u)}function a(u){return AE(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function o(u){return Et(u)?Lt(e,c,"whitespace")(u):c(u)}function c(u){return u===null||ut(u)?t(u):n(u)}}const NI={name:"hardBreakEscape",tokenize:TI};function TI(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return ut(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const AI={name:"headingAtx",resolve:LI,tokenize:DI};function LI(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"},Rr(e,r,n-r+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function DI(e,t,n){let r=0;return a;function a(p){return e.enter("atxHeading"),o(p)}function o(p){return e.enter("atxHeadingSequence"),c(p)}function c(p){return p===35&&r++<6?(e.consume(p),c):p===null||tn(p)?(e.exit("atxHeadingSequence"),u(p)):n(p)}function u(p){return p===35?(e.enter("atxHeadingSequence"),d(p)):p===null||ut(p)?(e.exit("atxHeading"),t(p)):Et(p)?Lt(e,u,"whitespace")(p):(e.enter("atxHeadingText"),h(p))}function d(p){return p===35?(e.consume(p),d):(e.exit("atxHeadingSequence"),u(p))}function h(p){return p===null||p===35||tn(p)?(e.exit("atxHeadingText"),u(p)):(e.consume(p),h)}}const RI=["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"],w1=["pre","script","style","textarea"],OI={concrete:!0,name:"htmlFlow",resolveTo:PI,tokenize:BI},II={partial:!0,tokenize:zI},MI={partial:!0,tokenize:$I};function PI(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 BI(e,t,n){const r=this;let a,o,c,u,d;return h;function h(z){return p(z)}function p(z){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(z),m}function m(z){return z===33?(e.consume(z),g):z===47?(e.consume(z),o=!0,C):z===63?(e.consume(z),a=3,r.interrupt?t:I):or(z)?(e.consume(z),c=String.fromCharCode(z),v):n(z)}function g(z){return z===45?(e.consume(z),a=2,x):z===91?(e.consume(z),a=5,u=0,w):or(z)?(e.consume(z),a=4,r.interrupt?t:I):n(z)}function x(z){return z===45?(e.consume(z),r.interrupt?t:I):n(z)}function w(z){const Y="CDATA[";return z===Y.charCodeAt(u++)?(e.consume(z),u===Y.length?r.interrupt?t:$:w):n(z)}function C(z){return or(z)?(e.consume(z),c=String.fromCharCode(z),v):n(z)}function v(z){if(z===null||z===47||z===62||tn(z)){const Y=z===47,X=c.toLowerCase();return!Y&&!o&&w1.includes(X)?(a=1,r.interrupt?t(z):$(z)):RI.includes(c.toLowerCase())?(a=6,Y?(e.consume(z),S):r.interrupt?t(z):$(z)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(z):o?_(z):b(z))}return z===45||tr(z)?(e.consume(z),c+=String.fromCharCode(z),v):n(z)}function S(z){return z===62?(e.consume(z),r.interrupt?t:$):n(z)}function _(z){return Et(z)?(e.consume(z),_):M(z)}function b(z){return z===47?(e.consume(z),M):z===58||z===95||or(z)?(e.consume(z),k):Et(z)?(e.consume(z),b):M(z)}function k(z){return z===45||z===46||z===58||z===95||tr(z)?(e.consume(z),k):E(z)}function E(z){return z===61?(e.consume(z),T):Et(z)?(e.consume(z),E):b(z)}function T(z){return z===null||z===60||z===61||z===62||z===96?n(z):z===34||z===39?(e.consume(z),d=z,D):Et(z)?(e.consume(z),T):A(z)}function D(z){return z===d?(e.consume(z),d=null,R):z===null||ut(z)?n(z):(e.consume(z),D)}function A(z){return z===null||z===34||z===39||z===47||z===60||z===61||z===62||z===96||tn(z)?E(z):(e.consume(z),A)}function R(z){return z===47||z===62||Et(z)?b(z):n(z)}function M(z){return z===62?(e.consume(z),W):n(z)}function W(z){return z===null||ut(z)?$(z):Et(z)?(e.consume(z),W):n(z)}function $(z){return z===45&&a===2?(e.consume(z),q):z===60&&a===1?(e.consume(z),Q):z===62&&a===4?(e.consume(z),O):z===63&&a===3?(e.consume(z),I):z===93&&a===5?(e.consume(z),U):ut(z)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(II,V,G)(z)):z===null||ut(z)?(e.exit("htmlFlowData"),G(z)):(e.consume(z),$)}function G(z){return e.check(MI,B,V)(z)}function B(z){return e.enter("lineEnding"),e.consume(z),e.exit("lineEnding"),H}function H(z){return z===null||ut(z)?G(z):(e.enter("htmlFlowData"),$(z))}function q(z){return z===45?(e.consume(z),I):$(z)}function Q(z){return z===47?(e.consume(z),c="",J):$(z)}function J(z){if(z===62){const Y=c.toLowerCase();return w1.includes(Y)?(e.consume(z),O):$(z)}return or(z)&&c.length<8?(e.consume(z),c+=String.fromCharCode(z),J):$(z)}function U(z){return z===93?(e.consume(z),I):$(z)}function I(z){return z===62?(e.consume(z),O):z===45&&a===2?(e.consume(z),I):$(z)}function O(z){return z===null||ut(z)?(e.exit("htmlFlowData"),V(z)):(e.consume(z),O)}function V(z){return e.exit("htmlFlow"),t(z)}}function $I(e,t,n){const r=this;return a;function a(c){return ut(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 zI(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(bu,t,n)}}const HI={name:"htmlText",tokenize:FI};function FI(e,t,n){const r=this;let a,o,c;return u;function u(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),d}function d(I){return I===33?(e.consume(I),h):I===47?(e.consume(I),E):I===63?(e.consume(I),b):or(I)?(e.consume(I),A):n(I)}function h(I){return I===45?(e.consume(I),p):I===91?(e.consume(I),o=0,w):or(I)?(e.consume(I),_):n(I)}function p(I){return I===45?(e.consume(I),x):n(I)}function m(I){return I===null?n(I):I===45?(e.consume(I),g):ut(I)?(c=m,Q(I)):(e.consume(I),m)}function g(I){return I===45?(e.consume(I),x):m(I)}function x(I){return I===62?q(I):I===45?g(I):m(I)}function w(I){const O="CDATA[";return I===O.charCodeAt(o++)?(e.consume(I),o===O.length?C:w):n(I)}function C(I){return I===null?n(I):I===93?(e.consume(I),v):ut(I)?(c=C,Q(I)):(e.consume(I),C)}function v(I){return I===93?(e.consume(I),S):C(I)}function S(I){return I===62?q(I):I===93?(e.consume(I),S):C(I)}function _(I){return I===null||I===62?q(I):ut(I)?(c=_,Q(I)):(e.consume(I),_)}function b(I){return I===null?n(I):I===63?(e.consume(I),k):ut(I)?(c=b,Q(I)):(e.consume(I),b)}function k(I){return I===62?q(I):b(I)}function E(I){return or(I)?(e.consume(I),T):n(I)}function T(I){return I===45||tr(I)?(e.consume(I),T):D(I)}function D(I){return ut(I)?(c=D,Q(I)):Et(I)?(e.consume(I),D):q(I)}function A(I){return I===45||tr(I)?(e.consume(I),A):I===47||I===62||tn(I)?R(I):n(I)}function R(I){return I===47?(e.consume(I),q):I===58||I===95||or(I)?(e.consume(I),M):ut(I)?(c=R,Q(I)):Et(I)?(e.consume(I),R):q(I)}function M(I){return I===45||I===46||I===58||I===95||tr(I)?(e.consume(I),M):W(I)}function W(I){return I===61?(e.consume(I),$):ut(I)?(c=W,Q(I)):Et(I)?(e.consume(I),W):R(I)}function $(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),a=I,G):ut(I)?(c=$,Q(I)):Et(I)?(e.consume(I),$):(e.consume(I),B)}function G(I){return I===a?(e.consume(I),a=void 0,H):I===null?n(I):ut(I)?(c=G,Q(I)):(e.consume(I),G)}function B(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||tn(I)?R(I):(e.consume(I),B)}function H(I){return I===47||I===62||tn(I)?R(I):n(I)}function q(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function Q(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),J}function J(I){return Et(I)?Lt(e,U,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):U(I)}function U(I){return e.enter("htmlTextData"),c(I)}}const hb={name:"labelEnd",resolveAll:WI,resolveTo:qI,tokenize:KI},UI={tokenize:YI},VI={tokenize:XI},GI={tokenize:JI};function WI(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&&Rr(e,0,e.length,n),e}function qI(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}},p={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[c-2][1].start}};return u=[["enter",d,t],["enter",h,t]],u=Wr(u,e.slice(o+1,o+r+3)),u=Wr(u,[["enter",p,t]]),u=Wr(u,Rf(t.parser.constructs.insideSpan.null,e.slice(o+r+4,c-3),t)),u=Wr(u,[["exit",p,t],e[c-2],e[c-1],["exit",h,t]]),u=Wr(u,e.slice(c+1)),u=Wr(u,[["exit",d,t]]),Rr(e,o,e.length,u),e}function KI(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?m(g):(c=r.parser.defined.includes(hs(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(UI,p,c?p:m)(g):g===91?e.attempt(VI,p,c?h:m)(g):c?p(g):m(g)}function h(g){return e.attempt(GI,p,m)(g)}function p(g){return t(g)}function m(g){return o._balanced=!0,n(g)}}function YI(e,t,n){return r;function r(m){return e.enter("resource"),e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),a}function a(m){return tn(m)?Wc(e,o)(m):o(m)}function o(m){return m===41?p(m):NE(e,c,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function c(m){return tn(m)?Wc(e,d)(m):p(m)}function u(m){return n(m)}function d(m){return m===34||m===39||m===40?AE(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):p(m)}function h(m){return tn(m)?Wc(e,p)(m):p(m)}function p(m){return m===41?(e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),e.exit("resource"),t):n(m)}}function XI(e,t,n){const r=this;return a;function a(u){return TE.call(r,e,o,c,"reference","referenceMarker","referenceString")(u)}function o(u){return r.parser.defined.includes(hs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(u):n(u)}function c(u){return n(u)}}function JI(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 QI={name:"labelStartImage",resolveAll:hb.resolveAll,tokenize:ZI};function ZI(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 eM={name:"labelStartLink",resolveAll:hb.resolveAll,tokenize:tM};function tM(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 Ig={name:"lineEnding",tokenize:nM};function nM(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Lt(e,t,"linePrefix")}}const wh={name:"thematicBreak",tokenize:rM};function rM(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||ut(h))?(e.exit("thematicBreak"),t(h)):n(h)}function d(h){return h===a?(e.consume(h),r++,d):(e.exit("thematicBreakSequence"),Et(h)?Lt(e,u,"whitespace")(h):u(h))}}const pr={continuation:{tokenize:oM},exit:cM,name:"list",tokenize:aM},sM={partial:!0,tokenize:uM},iM={partial:!0,tokenize:lM};function aM(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:Kx(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(wh,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 Kx(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(bu,r.interrupt?n:p,e.attempt(sM,g,m))}function p(x){return r.containerState.initialBlankLine=!0,o++,g(x)}function m(x){return Et(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 oM(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(bu,a,o);function a(u){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Lt(e,t,"listItemIndent",r.containerState.size+1)(u)}function o(u){return r.containerState.furtherBlankLines||!Et(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(iM,t,c)(u))}function c(u){return r.containerState._closeFlow=!0,r.interrupt=void 0,Lt(e,e.attempt(pr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function lM(e,t,n){const r=this;return Lt(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 cM(e){e.exit(this.containerState.type)}function uM(e,t,n){const r=this;return Lt(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!Et(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const C1={name:"setextUnderline",resolveTo:dM,tokenize:hM};function dM(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 hM(e,t,n){const r=this;let a;return o;function o(h){let p=r.events.length,m;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){m=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||m)?(e.enter("setextHeadingLine"),a=h,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"),Et(h)?Lt(e,d,"lineSuffix")(h):d(h))}function d(h){return h===null||ut(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const fM={tokenize:mM};function mM(e){const t=this,n=e.attempt(bu,r,e.attempt(this.parser.constructs.flowInitial,a,Lt(e,e.attempt(this.parser.constructs.flow,a,e.attempt(bI,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 pM={resolveAll:DE()},gM=LE("string"),xM=LE("text");function LE(e){return{resolveAll:DE(e==="text"?yM: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(p){return h(p)?o(p):u(p)}function u(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),d}function d(p){return h(p)?(n.exit("data"),o(p)):(n.consume(p),d)}function h(p){if(p===null)return!0;const m=a[p];let g=-1;if(m)for(;++g<m.length;){const x=m[g];if(!x.previous||x.previous.call(r,r.previous))return!0}return!1}}}function DE(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 yM(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 bM={42:pr,43:pr,45:pr,48:pr,49:pr,50:pr,51:pr,52:pr,53:pr,54:pr,55:pr,56:pr,57:pr,62:CE},vM={91:CI},_M={[-2]:Og,[-1]:Og,32:Og},SM={35:AI,42:wh,45:[C1,wh],60:OI,61:C1,95:wh,96:S1,126:S1},wM={38:jE,92:kE},CM={[-5]:Ig,[-4]:Ig,[-3]:Ig,33:QI,38:jE,42:Yx,60:[eI,HI],91:eM,92:[NI,kE],93:hb,95:Yx,96:fI},kM={null:[Yx,pM]},jM={null:[42,95]},EM={null:[]},NM=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:jM,contentInitial:vM,disable:EM,document:bM,flow:SM,flowInitial:_M,insideSpan:kM,string:wM,text:CM},Symbol.toStringTag,{value:"Module"}));function TM(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:D(E),check:D(T),consume:_,enter:b,exit:k,interrupt:D(T,{interrupt:!0})},h={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:e,previous:null,sliceSerialize:g,sliceStream:x,write:m};let p=t.tokenize.call(h,d);return t.resolveAll&&o.push(t),h;function m(W){return c=Wr(c,W),v(),c[c.length-1]!==null?[]:(A(t,0),h.events=Rf(o,h.events,h),h.events)}function g(W,$){return LM(x(W),$)}function x(W){return AM(c,W)}function w(){const{_bufferIndex:W,_index:$,line:G,column:B,offset:H}=r;return{_bufferIndex:W,_index:$,line:G,column:B,offset:H}}function C(W){a[W.line]=W.column,M()}function v(){let W;for(;r._index<c.length;){const $=c[r._index];if(typeof $=="string")for(W=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===W&&r._bufferIndex<$.length;)S($.charCodeAt(r._bufferIndex));else S($)}}function S(W){p=p(W)}function _(W){ut(W)?(r.line++,r.column=1,r.offset+=W===-3?2:1,M()):W!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===c[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=W}function b(W,$){const G=$||{};return G.type=W,G.start=w(),h.events.push(["enter",G,h]),u.push(G),G}function k(W){const $=u.pop();return $.end=w(),h.events.push(["exit",$,h]),$}function E(W,$){A(W,$.from)}function T(W,$){$.restore()}function D(W,$){return G;function G(B,H,q){let Q,J,U,I;return Array.isArray(B)?V(B):"tokenize"in B?V([B]):O(B);function O(Z){return F;function F(P){const te=P!==null&&Z[P],se=P!==null&&Z.null,re=[...Array.isArray(te)?te:te?[te]:[],...Array.isArray(se)?se:se?[se]:[]];return V(re)(P)}}function V(Z){return Q=Z,J=0,Z.length===0?q:z(Z[J])}function z(Z){return F;function F(P){return I=R(),U=Z,Z.partial||(h.currentConstruct=Z),Z.name&&h.parser.constructs.disable.null.includes(Z.name)?X():Z.tokenize.call($?Object.assign(Object.create(h),$):h,d,Y,X)(P)}}function Y(Z){return W(U,I),H}function X(Z){return I.restore(),++J<Q.length?z(Q[J]):q}}}function A(W,$){W.resolveAll&&!o.includes(W)&&o.push(W),W.resolve&&Rr(h.events,$,h.events.length-$,W.resolve(h.events.slice($),h)),W.resolveTo&&(h.events=W.resolveTo(h.events,h))}function R(){const W=w(),$=h.previous,G=h.currentConstruct,B=h.events.length,H=Array.from(u);return{from:B,restore:q};function q(){r=W,h.previous=$,h.currentConstruct=G,h.events.length=B,u=H,M()}}function M(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function AM(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 LM(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 DM(e){const r={constructs:SE([NM,...(e||{}).extensions||[]]),content:a(qO),defined:[],document:a(YO),flow:a(fM),lazy:{},string:a(gM),text:a(xM)};return r;function a(o){return c;function c(u){return TM(r,o,u)}}}function RM(e){for(;!EE(e););return e}const k1=/[\0\t\n\r]/g;function OM(){let e=1,t="",n=!0,r;return a;function a(o,c,u){const d=[];let h,p,m,g,x;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(c||void 0).decode(o)),m=0,t="",n&&(o.charCodeAt(0)===65279&&m++,n=void 0);m<o.length;){if(k1.lastIndex=m,h=k1.exec(o),g=h&&h.index!==void 0?h.index:o.length,x=o.charCodeAt(g),!h){t=o.slice(m);break}if(x===10&&m===g&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),m<g&&(d.push(o.slice(m,g)),e+=g-m),x){case 0:{d.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,d.push(-2);e++<p;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:r=!0,e=1}m=g+1}return u&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const IM=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function MM(e){return e.replace(IM,PM)}function PM(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),o=a===120||a===88;return wE(n.slice(o?2:1),o?16:10)}return db(n)||e}const RE={}.hasOwnProperty;function BM(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),$M(n)(RM(DM(n).document().write(OM()(e,t,!0))))}function $M(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Ze),autolinkProtocol:R,autolinkEmail:R,atxHeading:o(Ie),blockQuote:o(se),characterEscape:R,characterReference:R,codeFenced:o(re),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:o(re,c),codeText:o(ae,c),codeTextData:R,data:R,codeFlowValue:R,definition:o(ye),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:o(_e),hardBreakEscape:o(He),hardBreakTrailing:o(He),htmlFlow:o(je,c),htmlFlowData:R,htmlText:o(je,c),htmlTextData:R,image:o(Ge),label:c,link:o(Ze),listItem:o(be),listItemValue:g,listOrdered:o(Se,m),listUnordered:o(Se),paragraph:o(de),reference:z,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:o(Ie),strong:o(ie),thematicBreak:o(Ue)},exit:{atxHeading:d(),atxHeadingSequence:E,autolink:d(),autolinkEmail:te,autolinkProtocol:P,blockQuote:d(),characterEscapeValue:M,characterReferenceMarkerHexadecimal:X,characterReferenceMarkerNumeric:X,characterReferenceValue:Z,characterReference:F,codeFenced:d(v),codeFencedFence:C,codeFencedFenceInfo:x,codeFencedFenceMeta:w,codeFlowValue:M,codeIndented:d(S),codeText:d(H),codeTextData:M,data:M,definition:d(),definitionDestinationString:k,definitionLabelString:_,definitionTitleString:b,emphasis:d(),hardBreakEscape:d($),hardBreakTrailing:d($),htmlFlow:d(G),htmlFlowData:M,htmlText:d(B),htmlTextData:M,image:d(Q),label:U,labelText:J,lineEnding:W,link:d(q),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:Y,resourceDestinationString:I,resourceTitleString:O,resource:V,setextHeading:d(A),setextHeadingLineSequence:D,setextHeadingText:T,strong:d(),thematicBreak:d()}};OE(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ue){let De={type:"root",children:[]};const qe={stack:[De],tokenStack:[],config:t,enter:u,exit:h,buffer:c,resume:p,data:n},pe=[];let he=-1;for(;++he<ue.length;)if(ue[he][1].type==="listOrdered"||ue[he][1].type==="listUnordered")if(ue[he][0]==="enter")pe.push(he);else{const We=pe.pop();he=a(ue,We,he)}for(he=-1;++he<ue.length;){const We=t[ue[he][0]];RE.call(We,ue[he][1].type)&&We[ue[he][1].type].call(Object.assign({sliceSerialize:ue[he][2].sliceSerialize},qe),ue[he][1])}if(qe.tokenStack.length>0){const We=qe.tokenStack[qe.tokenStack.length-1];(We[1]||j1).call(qe,void 0,We[0])}for(De.position={start:$i(ue.length>0?ue[0][1].start:{line:1,column:1,offset:0}),end:$i(ue.length>0?ue[ue.length-2][1].end:{line:1,column:1,offset:0})},he=-1;++he<t.transforms.length;)De=t.transforms[he](De)||De;return De}function a(ue,De,qe){let pe=De-1,he=-1,We=!1,Ve,et,it,ge;for(;++pe<=qe;){const fe=ue[pe];switch(fe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{fe[0]==="enter"?he++:he--,ge=void 0;break}case"lineEndingBlank":{fe[0]==="enter"&&(Ve&&!ge&&!he&&!it&&(it=pe),ge=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ge=void 0}if(!he&&fe[0]==="enter"&&fe[1].type==="listItemPrefix"||he===-1&&fe[0]==="exit"&&(fe[1].type==="listUnordered"||fe[1].type==="listOrdered")){if(Ve){let Fe=pe;for(et=void 0;Fe--;){const Xe=ue[Fe];if(Xe[1].type==="lineEnding"||Xe[1].type==="lineEndingBlank"){if(Xe[0]==="exit")continue;et&&(ue[et][1].type="lineEndingBlank",We=!0),Xe[1].type="lineEnding",et=Fe}else if(!(Xe[1].type==="linePrefix"||Xe[1].type==="blockQuotePrefix"||Xe[1].type==="blockQuotePrefixWhitespace"||Xe[1].type==="blockQuoteMarker"||Xe[1].type==="listItemIndent"))break}it&&(!et||it<et)&&(Ve._spread=!0),Ve.end=Object.assign({},et?ue[et][1].start:fe[1].end),ue.splice(et||pe,0,["exit",Ve,fe[2]]),pe++,qe++}if(fe[1].type==="listItemPrefix"){const Fe={type:"listItem",_spread:!1,start:Object.assign({},fe[1].start),end:void 0};Ve=Fe,ue.splice(pe,0,["enter",Fe,fe[2]]),pe++,qe++,it=void 0,ge=!0}}}return ue[De][1]._spread=We,qe}function o(ue,De){return qe;function qe(pe){u.call(this,ue(pe),pe),De&&De.call(this,pe)}}function c(){this.stack.push({type:"fragment",children:[]})}function u(ue,De,qe){this.stack[this.stack.length-1].children.push(ue),this.stack.push(ue),this.tokenStack.push([De,qe||void 0]),ue.position={start:$i(De.start),end:void 0}}function d(ue){return De;function De(qe){ue&&ue.call(this,qe),h.call(this,qe)}}function h(ue,De){const qe=this.stack.pop(),pe=this.tokenStack.pop();if(pe)pe[0].type!==ue.type&&(De?De.call(this,ue,pe[0]):(pe[1]||j1).call(this,ue,pe[0]));else throw new Error("Cannot close `"+ue.type+"` ("+Gc({start:ue.start,end:ue.end})+"): it’s not open");qe.position.end=$i(ue.end)}function p(){return ub(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function g(ue){if(this.data.expectingFirstListItemValue){const De=this.stack[this.stack.length-2];De.start=Number.parseInt(this.sliceSerialize(ue),10),this.data.expectingFirstListItemValue=void 0}}function x(){const ue=this.resume(),De=this.stack[this.stack.length-1];De.lang=ue}function w(){const ue=this.resume(),De=this.stack[this.stack.length-1];De.meta=ue}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const ue=this.resume(),De=this.stack[this.stack.length-1];De.value=ue.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const ue=this.resume(),De=this.stack[this.stack.length-1];De.value=ue.replace(/(\r?\n|\r)$/g,"")}function _(ue){const De=this.resume(),qe=this.stack[this.stack.length-1];qe.label=De,qe.identifier=hs(this.sliceSerialize(ue)).toLowerCase()}function b(){const ue=this.resume(),De=this.stack[this.stack.length-1];De.title=ue}function k(){const ue=this.resume(),De=this.stack[this.stack.length-1];De.url=ue}function E(ue){const De=this.stack[this.stack.length-1];if(!De.depth){const qe=this.sliceSerialize(ue).length;De.depth=qe}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function D(ue){const De=this.stack[this.stack.length-1];De.depth=this.sliceSerialize(ue).codePointAt(0)===61?1:2}function A(){this.data.setextHeadingSlurpLineEnding=void 0}function R(ue){const qe=this.stack[this.stack.length-1].children;let pe=qe[qe.length-1];(!pe||pe.type!=="text")&&(pe=Pe(),pe.position={start:$i(ue.start),end:void 0},qe.push(pe)),this.stack.push(pe)}function M(ue){const De=this.stack.pop();De.value+=this.sliceSerialize(ue),De.position.end=$i(ue.end)}function W(ue){const De=this.stack[this.stack.length-1];if(this.data.atHardBreak){const qe=De.children[De.children.length-1];qe.position.end=$i(ue.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(De.type)&&(R.call(this,ue),M.call(this,ue))}function $(){this.data.atHardBreak=!0}function G(){const ue=this.resume(),De=this.stack[this.stack.length-1];De.value=ue}function B(){const ue=this.resume(),De=this.stack[this.stack.length-1];De.value=ue}function H(){const ue=this.resume(),De=this.stack[this.stack.length-1];De.value=ue}function q(){const ue=this.stack[this.stack.length-1];if(this.data.inReference){const De=this.data.referenceType||"shortcut";ue.type+="Reference",ue.referenceType=De,delete ue.url,delete ue.title}else delete ue.identifier,delete ue.label;this.data.referenceType=void 0}function Q(){const ue=this.stack[this.stack.length-1];if(this.data.inReference){const De=this.data.referenceType||"shortcut";ue.type+="Reference",ue.referenceType=De,delete ue.url,delete ue.title}else delete ue.identifier,delete ue.label;this.data.referenceType=void 0}function J(ue){const De=this.sliceSerialize(ue),qe=this.stack[this.stack.length-2];qe.label=MM(De),qe.identifier=hs(De).toLowerCase()}function U(){const ue=this.stack[this.stack.length-1],De=this.resume(),qe=this.stack[this.stack.length-1];if(this.data.inReference=!0,qe.type==="link"){const pe=ue.children;qe.children=pe}else qe.alt=De}function I(){const ue=this.resume(),De=this.stack[this.stack.length-1];De.url=ue}function O(){const ue=this.resume(),De=this.stack[this.stack.length-1];De.title=ue}function V(){this.data.inReference=void 0}function z(){this.data.referenceType="collapsed"}function Y(ue){const De=this.resume(),qe=this.stack[this.stack.length-1];qe.label=De,qe.identifier=hs(this.sliceSerialize(ue)).toLowerCase(),this.data.referenceType="full"}function X(ue){this.data.characterReferenceType=ue.type}function Z(ue){const De=this.sliceSerialize(ue),qe=this.data.characterReferenceType;let pe;qe?(pe=wE(De,qe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):pe=db(De);const he=this.stack[this.stack.length-1];he.value+=pe}function F(ue){const De=this.stack.pop();De.position.end=$i(ue.end)}function P(ue){M.call(this,ue);const De=this.stack[this.stack.length-1];De.url=this.sliceSerialize(ue)}function te(ue){M.call(this,ue);const De=this.stack[this.stack.length-1];De.url="mailto:"+this.sliceSerialize(ue)}function se(){return{type:"blockquote",children:[]}}function re(){return{type:"code",lang:null,meta:null,value:""}}function ae(){return{type:"inlineCode",value:""}}function ye(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function _e(){return{type:"emphasis",children:[]}}function Ie(){return{type:"heading",depth:0,children:[]}}function He(){return{type:"break"}}function je(){return{type:"html",value:""}}function Ge(){return{type:"image",title:null,url:"",alt:null}}function Ze(){return{type:"link",title:null,url:"",children:[]}}function Se(ue){return{type:"list",ordered:ue.type==="listOrdered",start:null,spread:ue._spread,children:[]}}function be(ue){return{type:"listItem",spread:ue._spread,checked:null,children:[]}}function de(){return{type:"paragraph",children:[]}}function ie(){return{type:"strong",children:[]}}function Pe(){return{type:"text",value:""}}function Ue(){return{type:"thematicBreak"}}}function $i(e){return{line:e.line,column:e.column,offset:e.offset}}function OE(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?OE(e,r):zM(e,r)}}function zM(e,t){let n;for(n in t)if(RE.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 j1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Gc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Gc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Gc({start:t.start,end:t.end})+") is still open")}function HM(e){const t=this;t.parser=n;function n(r){return BM(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function FM(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 UM(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
71
|
+
`}]}function VM(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 GM(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function WM(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qM(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=kl(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 KM(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 YM(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function IE(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 XM(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return IE(e,t);const a={src:kl(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 JM(e,t){const n={src:kl(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 QM(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 ZM(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return IE(e,t);const a={href:kl(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 e4(e,t){const n={href:kl(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 t4(e,t,n){const r=e.all(t),a=n?n4(n):ME(t),o={},c=[];if(typeof t.checked=="boolean"){const p=r[0];let m;p&&p.type==="element"&&p.tagName==="p"?m=p:(m={type:"element",tagName:"p",properties:{},children:[]},r.unshift(m)),m.children.length>0&&m.children.unshift({type:"text",value:" "}),m.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let u=-1;for(;++u<r.length;){const p=r[u];(a||u!==0||p.type!=="element"||p.tagName!=="p")&&c.push({type:"text",value:`
|
|
73
|
+
`}),p.type==="element"&&p.tagName==="p"&&!a?c.push(...p.children):c.push(p)}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 n4(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=ME(n[r])}return t}function ME(e){const t=e.spread;return t??e.children.length>1}function r4(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 s4(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function i4(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function a4(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function o4(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=ab(t.children[1]),d=pE(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 l4(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 m=t.children[d],g={},x=c?c[d]:void 0;x&&(g.align=x);let w={type:"element",tagName:o,properties:g,children:[]};m&&(w.children=e.all(m),e.patch(m,w),w=e.applyData(m,w)),h.push(w)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,p),e.applyData(t,p)}function c4(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const E1=9,N1=32;function u4(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const o=[];for(;r;)o.push(T1(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return o.push(T1(t.slice(a),a>0,!1)),o.join("")}function T1(e,t,n){let r=0,a=e.length;if(t){let o=e.codePointAt(r);for(;o===E1||o===N1;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(a-1);for(;o===E1||o===N1;)a--,o=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}function d4(e,t){const n={type:"text",value:u4(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function h4(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const f4={blockquote:FM,break:UM,code:VM,delete:GM,emphasis:WM,footnoteReference:qM,heading:KM,html:YM,imageReference:XM,image:JM,inlineCode:QM,linkReference:ZM,link:e4,listItem:t4,list:r4,paragraph:s4,root:i4,strong:a4,table:o4,tableCell:c4,tableRow:l4,text:d4,thematicBreak:h4,toml:Gd,yaml:Gd,definition:Gd,footnoteDefinition:Gd};function Gd(){}const PE=-1,Of=0,qc=1,Bh=2,fb=3,mb=4,pb=5,gb=6,BE=7,$E=8,zE=typeof self=="object"?self:globalThis,A1=(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 zE[e](t)},m4=(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 Of:case PE:return n(c,a);case qc:{const u=n([],a);for(const d of c)u.push(r(d));return u}case Bh:{const u=n({},a);for(const[d,h]of c)u[r(d)]=r(h);return u}case fb:return n(new Date(c),a);case mb:{const{source:u,flags:d}=c;return n(new RegExp(u,d),a)}case pb:{const u=n(new Map,a);for(const[d,h]of c)u.set(r(d),r(h));return u}case gb:{const u=n(new Set,a);for(const d of c)u.add(r(d));return u}case BE:{const{name:u,message:d}=c;return n(typeof zE[u]=="function"?A1(u,d):new Error(d),a)}case $E: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(A1(o,c),a)};return r},L1=e=>m4(new Map,e)(0),Ra="",{toString:p4}={},{keys:g4}=Object,Ac=e=>{const t=typeof e;if(t!=="object"||!e)return[Of,t];const n=p4.call(e).slice(8,-1);switch(n){case"Array":return[qc,Ra];case"Object":return[Bh,Ra];case"Date":return[fb,Ra];case"RegExp":return[mb,Ra];case"Map":return[pb,Ra];case"Set":return[gb,Ra];case"DataView":return[qc,n]}return n.includes("Array")?[qc,n]:e instanceof Error?[BE,e.name||"Error"]:[Bh,n]},Wd=([e,t])=>e===Of&&(t==="function"||t==="symbol"),x4=(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]=Ac(c);switch(u){case Of:{let p=c;switch(d){case"bigint":u=$E,p=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return a([PE],c)}return a([u,p],c)}case qc:{if(d){let g=c;return d==="DataView"?g=new Uint8Array(c.buffer):d==="ArrayBuffer"&&(g=new Uint8Array(c)),a([d,[...g]],c)}const p=[],m=a([u,p],c);for(const g of c)p.push(o(g));return m}case Bh:{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 p=[],m=a([u,p],c);for(const g of g4(c))(e||!Wd(Ac(c[g])))&&p.push([o(g),o(c[g])]);return m}case fb:return a([u,isNaN(c.getTime())?Ra:c.toISOString()],c);case mb:{const{source:p,flags:m}=c;return a([u,{source:p,flags:m}],c)}case pb:{const p=[],m=a([u,p],c);for(const[g,x]of c)(e||!(Wd(Ac(g))||Wd(Ac(x))))&&p.push([o(g),o(x)]);return m}case gb:{const p=[],m=a([u,p],c);for(const g of c)(e||!Wd(Ac(g)))&&p.push(o(g));return m}}const{message:h}=c;return a([u,{name:d,message:h}],c)};return o},D1=(e,{json:t,lossy:n}={})=>{const r=[];return x4(!(t||n),!!t,new Map,r)(e),r},$h=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?L1(D1(e,t)):structuredClone(e):(e,t)=>L1(D1(e,t));function y4(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 b4(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function v4(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||y4,r=e.options.footnoteBackLabel||b4,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 p=e.all(h),m=String(h.identifier).toUpperCase(),g=kl(m.toLowerCase());let x=0;const w=[],C=e.footnoteCounts.get(m);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=p[p.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const _=v.children[v.children.length-1];_&&_.type==="text"?_.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...w)}else p.push(...w);const S={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(p,!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:{...$h(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 If=(function(e){if(e==null)return C4;if(typeof e=="function")return Mf(e);if(typeof e=="object")return Array.isArray(e)?_4(e):S4(e);if(typeof e=="string")return w4(e);throw new Error("Expected function, string, or object as test")});function _4(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=If(e[n]);return Mf(r);function r(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function S4(e){const t=e;return Mf(n);function n(r){const a=r;let o;for(o in e)if(a[o]!==t[o])return!1;return!0}}function w4(e){return Mf(t);function t(n){return n&&n.type===e}}function Mf(e){return t;function t(n,r,a){return!!(k4(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function C4(){return!0}function k4(e){return e!==null&&typeof e=="object"&&"type"in e}const HE=[],j4=!0,Xx=!1,E4="skip";function FE(e,t,n,r){let a;typeof t=="function"&&typeof n!="function"?(r=n,n=t):a=t;const o=If(a),c=r?-1:1;u(e,void 0,[])();function u(d,h,p){const m=d&&typeof d=="object"?d:{};if(typeof m.type=="string"){const x=typeof m.tagName=="string"?m.tagName:typeof m.name=="string"?m.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(d.type+(x?"<"+x+">":""))+")"})}return g;function g(){let x=HE,w,C,v;if((!t||o(d,h,p[p.length-1]||void 0))&&(x=N4(n(d,p)),x[0]===Xx))return x;if("children"in d&&d.children){const S=d;if(S.children&&x[0]!==E4)for(C=(r?S.children.length:-1)+c,v=p.concat(S);C>-1&&C<S.children.length;){const _=S.children[C];if(w=u(_,C,v)(),w[0]===Xx)return w;C=typeof w[1]=="number"?w[1]:C+c}}return x}}}function N4(e){return Array.isArray(e)?e:typeof e=="number"?[j4,e]:e==null?HE:[e]}function xb(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),FE(e,o,u,a);function u(d,h){const p=h[h.length-1],m=p?p.children.indexOf(d):void 0;return c(d,m,p)}}const Jx={}.hasOwnProperty,T4={};function A4(e,t){const n=t||T4,r=new Map,a=new Map,o=new Map,c={...f4,...n.handlers},u={all:h,applyData:D4,definitionById:r,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:c,one:d,options:n,patch:L4,wrap:O4};return xb(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const m=p.type==="definition"?r:a,g=String(p.identifier).toUpperCase();m.has(g)||m.set(g,p)}}),u;function d(p,m){const g=p.type,x=u.handlers[g];if(Jx.call(u.handlers,g)&&x)return x(u,p,m);if(u.options.passThrough&&u.options.passThrough.includes(g)){if("children"in p){const{children:C,...v}=p,S=$h(v);return S.children=u.all(p),S}return $h(p)}return(u.options.unknownHandler||R4)(u,p,m)}function h(p){const m=[];if("children"in p){const g=p.children;let x=-1;for(;++x<g.length;){const w=u.one(g[x],p);if(w){if(x&&g[x-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=R1(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=R1(C.value))}Array.isArray(w)?m.push(...w):m.push(w)}}}return m}}function L4(e,t){e.position&&(t.position=bO(e))}function D4(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,$h(o)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function R4(e,t){const n=t.data||{},r="value"in t&&!(Jx.call(n,"hProperties")||Jx.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 O4(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 R1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function O1(e,t){const n=A4(e,t),r=n.one(e,void 0),a=v4(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 I4(e,t){return e&&"run"in e?async function(n,r){const a=O1(n,{file:r,...t});await e.run(a,r)}:function(n,r){return O1(n,{file:r,...e||t})}}function I1(e){if(e)throw e}var Mg,M1;function M4(){if(M1)return Mg;M1=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 p=e.call(h,"constructor"),m=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!p&&!m)return!1;var g;for(g in h);return typeof g>"u"||e.call(h,g)},c=function(h,p){n&&p.name==="__proto__"?n(h,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):h[p.name]=p.newValue},u=function(h,p){if(p==="__proto__")if(e.call(h,p)){if(r)return r(h,p).value}else return;return h[p]};return Mg=function d(){var h,p,m,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(p in h)m=u(C,p),g=u(h,p),C!==g&&(_&&g&&(o(g)||(x=a(g)))?(x?(x=!1,w=m&&a(m)?m:[]):w=m&&o(m)?m:{},c(C,{name:p,newValue:d(_,w,g)})):typeof g<"u"&&c(C,{name:p,newValue:g}));return C},Mg}var P4=M4();const Pg=uf(P4);function Qx(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 B4(){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 p=e[++o];let m=-1;if(d){c(d);return}for(;++m<a.length;)(h[m]===null||h[m]===void 0)&&(h[m]=a[m]);a=h,p?$4(p,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 $4(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 p=h;if(u&&n)throw p;return a(p)}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 ks={basename:z4,dirname:H4,extname:F4,join:U4,sep:"/"};function z4(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');vu(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 H4(e){if(vu(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 F4(e){vu(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 U4(...e){let t=-1,n;for(;++t<e.length;)vu(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":V4(n)}function V4(e){vu(e);const t=e.codePointAt(0)===47;let n=G4(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function G4(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 vu(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const W4={cwd:q4};function q4(){return"/"}function Zx(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function K4(e){if(typeof e=="string")e=new URL(e);else if(!Zx(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 Y4(e)}function Y4(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 Bg=["history","path","basename","stem","extname","dirname"];class UE{constructor(t){let n;t?Zx(t)?n={path:t}:typeof t=="string"||X4(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":W4.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Bg.length;){const o=Bg[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)Bg.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?ks.basename(this.path):void 0}set basename(t){zg(t,"basename"),$g(t,"basename"),this.path=ks.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?ks.dirname(this.path):void 0}set dirname(t){P1(this.basename,"dirname"),this.path=ks.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?ks.extname(this.path):void 0}set extname(t){if($g(t,"extname"),P1(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=ks.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Zx(t)&&(t=K4(t)),zg(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?ks.basename(this.path,this.extname):void 0}set stem(t){zg(t,"stem"),$g(t,"stem"),this.path=ks.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 nr(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 $g(e,t){if(e&&e.includes(ks.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ks.sep+"`")}function zg(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function P1(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function X4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const J4=(function(e){const r=this.constructor.prototype,a=r[e],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,r),o}),Q4={}.hasOwnProperty;class yb extends J4{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=B4()}copy(){const t=new yb;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Pg(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Ug("data",this.frozen),this.namespace[t]=n,this):Q4.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Ug("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=qd(t),r=this.parser||this.Parser;return Hg("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Hg("process",this.parser||this.Parser),Fg("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(o,c){const u=qd(t),d=r.parse(u);r.run(d,u,function(p,m,g){if(p||!m||!g)return h(p);const x=m,w=r.stringify(x,g);tP(w)?g.value=w:g.result=w,h(p,g)});function h(p,m){p||!m?c(p):o?o(m):n(void 0,m)}}}processSync(t){let n=!1,r;return this.freeze(),Hg("processSync",this.parser||this.Parser),Fg("processSync",this.compiler||this.Compiler),this.process(t,a),$1("processSync","process",n),r;function a(o,c){n=!0,I1(o),r=c}}run(t,n,r){B1(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=qd(n);a.run(t,d,h);function h(p,m,g){const x=m||t;p?u(p):c?c(x):r(void 0,x,g)}}}runSync(t,n){let r=!1,a;return this.run(t,n,o),$1("runSync","run",r),a;function o(c,u){I1(c),a=u,r=!0}}stringify(t,n){this.freeze();const r=qd(n),a=this.compiler||this.Compiler;return Fg("stringify",a),B1(t),a(t,r)}use(t,...n){const r=this.attachers,a=this.namespace;if(Ug("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[p,...m]=h;d(p,m)}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=Pg(!0,a.settings,h.settings))}function u(h){let p=-1;if(h!=null)if(Array.isArray(h))for(;++p<h.length;){const m=h[p];o(m)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function d(h,p){let m=-1,g=-1;for(;++m<r.length;)if(r[m][0]===h){g=m;break}if(g===-1)r.push([h,...p]);else if(p.length>0){let[x,...w]=p;const C=r[g][1];Qx(C)&&Qx(x)&&(x=Pg(!0,C,x)),r[g]=[h,x,...w]}}}}const Z4=new yb().freeze();function Hg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Fg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Ug(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 B1(e){if(!Qx(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function $1(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function qd(e){return eP(e)?e:new UE(e)}function eP(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function tP(e){return typeof e=="string"||nP(e)}function nP(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const rP="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",z1=[],H1={allowDangerousHtml:!0},sP=/^(https?|ircs?|mailto|xmpp)$/i,iP=[{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 aP(e){const t=oP(e),n=lP(e);return cP(t.runSync(t.parse(n),n),e)}function oP(e){const t=e.rehypePlugins||z1,n=e.remarkPlugins||z1,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...H1}:H1;return Z4().use(HM).use(n).use(I4,r).use(t)}function lP(e){const t=e.children||"",n=new UE;return typeof t=="string"&&(n.value=t),n}function cP(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,u=t.unwrapDisallowed,d=t.urlTransform||uP;for(const p of iP)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+rP+p.id,void 0);return xb(e,h),CO(e,{Fragment:s.Fragment,components:a,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function h(p,m,g){if(p.type==="raw"&&g&&typeof m=="number")return c?g.children.splice(m,1):g.children[m]={type:"text",value:p.value},m;if(p.type==="element"){let x;for(x in Rg)if(Object.hasOwn(Rg,x)&&Object.hasOwn(p.properties,x)){const w=p.properties[x],C=Rg[x];(C===null||C.includes(p.tagName))&&(p.properties[x]=d(String(w||""),x,p))}}if(p.type==="element"){let x=n?!n.includes(p.tagName):o?o.includes(p.tagName):!1;if(!x&&r&&typeof m=="number"&&(x=!r(p,m,g)),x&&g&&typeof m=="number")return u&&p.children?g.children.splice(m,1,...p.children):g.children.splice(m,1),m}}}function uP(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||sP.test(e.slice(0,t))?e:""}function F1(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 dP(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function hP(e,t,n){const a=If((n||{}).ignore||[]),o=fP(t);let c=-1;for(;++c<o.length;)FE(e,"text",u);function u(h,p){let m=-1,g;for(;++m<p.length;){const x=p[m],w=g?g.children:void 0;if(a(x,w?w.indexOf(x):void 0,g))return;g=x}if(g)return d(h,p)}function d(h,p){const m=p[p.length-1],g=o[c][0],x=o[c][1];let w=0;const v=m.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:[...p,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)}),m.children.splice(v,1,..._)):_=[h],v+_.length}}function fP(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([mP(a[0]),pP(a[1])])}return t}function mP(e){return typeof e=="string"?new RegExp(dP(e),"g"):e}function pP(e){return typeof e=="function"?e:function(){return e}}const Vg="phrasing",Gg=["autolink","link","image","label"];function gP(){return{transforms:[wP],enter:{literalAutolink:yP,literalAutolinkEmail:Wg,literalAutolinkHttp:Wg,literalAutolinkWww:Wg},exit:{literalAutolink:SP,literalAutolinkEmail:_P,literalAutolinkHttp:bP,literalAutolinkWww:vP}}}function xP(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Vg,notInConstruct:Gg},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Vg,notInConstruct:Gg},{character:":",before:"[ps]",after:"\\/",inConstruct:Vg,notInConstruct:Gg}]}}function yP(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Wg(e){this.config.enter.autolinkProtocol.call(this,e)}function bP(e){this.config.exit.autolinkProtocol.call(this,e)}function vP(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 _P(e){this.config.exit.autolinkEmail.call(this,e)}function SP(e){this.exit(e)}function wP(e){hP(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,CP],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),kP]],{ignore:["link","linkReference"]})}function CP(e,t,n,r,a){let o="";if(!VE(a)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!jP(n)))return!1;const c=EP(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 kP(e,t,n,r){return!VE(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function jP(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 EP(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=F1(e,"(");let o=F1(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 VE(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Xa(n)||Df(n))&&(!t||n!==47)}GE.peek=MP;function NP(){this.buffer()}function TP(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function AP(){this.buffer()}function LP(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function DP(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=hs(this.sliceSerialize(e)).toLowerCase(),n.label=t}function RP(e){this.exit(e)}function OP(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=hs(this.sliceSerialize(e)).toLowerCase(),n.label=t}function IP(e){this.exit(e)}function MP(){return"["}function GE(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 PP(){return{enter:{gfmFootnoteCallString:NP,gfmFootnoteCall:TP,gfmFootnoteDefinitionLabelString:AP,gfmFootnoteDefinition:LP},exit:{gfmFootnoteCallString:DP,gfmFootnoteCall:RP,gfmFootnoteDefinitionLabelString:OP,gfmFootnoteDefinition:IP}}}function BP(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:GE},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"),p=o.enter("label");return d+=u.move(o.safe(o.associationId(r),{before:d,after:"]"})),p(),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?WE:$P))),h(),d}}function $P(e,t,n){return t===0?e:WE(e,t,n)}function WE(e,t,n){return(n?"":" ")+e}const zP=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];qE.peek=GP;function HP(){return{canContainEols:["delete"],enter:{strikethrough:UP},exit:{strikethrough:VP}}}function FP(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:zP}],handlers:{delete:qE}}}function UP(e){this.enter({type:"delete",children:[]},e)}function VP(e){this.exit(e)}function qE(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 GP(){return"~"}function WP(e){return e.length}function qP(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||WP,o=[],c=[],u=[],d=[];let h=0,p=-1;for(;++p<e.length;){const C=[],v=[];let S=-1;for(e[p].length>h&&(h=e[p].length);++S<e[p].length;){const _=KP(e[p][S]);if(n.alignDelimiters!==!1){const b=a(_);v[S]=b,(d[S]===void 0||b>d[S])&&(d[S]=b)}C.push(_)}c[p]=C,u[p]=v}let m=-1;if(typeof r=="object"&&"length"in r)for(;++m<h;)o[m]=U1(r[m]);else{const C=U1(r);for(;++m<h;)o[m]=C}m=-1;const g=[],x=[];for(;++m<h;){const C=o[m];let v="",S="";C===99?(v=":",S=":"):C===108?v=":":C===114&&(S=":");let _=n.alignDelimiters===!1?1:Math.max(1,d[m]-v.length-S.length);const b=v+"-".repeat(_)+S;n.alignDelimiters!==!1&&(_=v.length+_+S.length,_>d[m]&&(d[m]=_),x[m]=_),g[m]=b}c.splice(1,0,g),u.splice(1,0,x),p=-1;const w=[];for(;++p<c.length;){const C=c[p],v=u[p];m=-1;const S=[];for(;++m<h;){const _=C[m]||"";let b="",k="";if(n.alignDelimiters!==!1){const E=d[m]-(v[m]||0),T=o[m];T===114?b=" ".repeat(E):T===99?E%2?(b=" ".repeat(E/2+.5),k=" ".repeat(E/2-.5)):(b=" ".repeat(E/2),k=b):k=" ".repeat(E)}n.delimiterStart!==!1&&!m&&S.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||m)&&S.push(" "),n.alignDelimiters!==!1&&S.push(b),S.push(_),n.alignDelimiters!==!1&&S.push(k),n.padding!==!1&&S.push(" "),(n.delimiterEnd!==!1||m!==h-1)&&S.push("|")}w.push(n.delimiterEnd===!1?S.join("").replace(/ +$/,""):S.join(""))}return w.join(`
|
|
82
|
+
`)}function KP(e){return e==null?"":String(e)}function U1(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 YP(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()),XP);return a(),c}function XP(e,t,n){return">"+(n?"":" ")+e}function JP(e,t){return V1(e,t.inConstruct,!0)&&!V1(e,t.notInConstruct,!1)}function V1(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 G1(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
|
|
83
|
+
`&&JP(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
84
|
+
`}function QP(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 ZP(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 e6(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 t6(e,t,n,r){const a=e6(n),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(ZP(e,n)){const m=n.enter("codeIndented"),g=n.indentLines(o,n6);return m(),g}const u=n.createTracker(r),d=a.repeat(Math.max(QP(o,a)+1,3)),h=n.enter("codeFenced");let p=u.move(d);if(e.lang){const m=n.enter(`codeFencedLang${c}`);p+=u.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...u.current()})),m()}if(e.lang&&e.meta){const m=n.enter(`codeFencedMeta${c}`);p+=u.move(" "),p+=u.move(n.safe(e.meta,{before:p,after:`
|
|
85
|
+
`,encode:["`"],...u.current()})),m()}return p+=u.move(`
|
|
86
|
+
`),o&&(p+=u.move(o+`
|
|
87
|
+
`)),p+=u.move(d),h(),p}function n6(e,t,n){return(n?"":" ")+e}function bb(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 r6(e,t,n,r){const a=bb(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 s6(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 au(e){return"&#x"+e.toString(16).toUpperCase()+";"}function zh(e,t,n){const r=gl(e),a=gl(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}}KE.peek=i6;function KE(e,t,n,r){const a=s6(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),p=zh(r.before.charCodeAt(r.before.length-1),h,a);p.inside&&(d=au(h)+d.slice(1));const m=d.charCodeAt(d.length-1),g=zh(r.after.charCodeAt(0),m,a);g.inside&&(d=d.slice(0,-1)+au(m));const x=c.move(a);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},u+d+x}function i6(e,t,n){return n.options.emphasis||"*"}function a6(e,t){let n=!1;return xb(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Xx}),!!((!e.depth||e.depth<3)&&ub(e)&&(t.options.setext||n))}function o6(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(a6(e,n)){const p=n.enter("headingSetext"),m=n.enter("phrasing"),g=n.containerPhrasing(e,{...o.current(),before:`
|
|
89
|
+
`,after:`
|
|
90
|
+
`});return m(),p(),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=au(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,n.options.closeAtx&&(h+=" "+c),d(),u(),h}YE.peek=l6;function YE(e){return e.value||""}function l6(){return"<"}XE.peek=c6;function XE(e,t,n,r){const a=bb(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 c6(){return"!"}JE.peek=u6;function JE(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 p=n.stack;n.stack=[],c=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return c(),n.stack=p,o(),a==="full"||!h||h!==m?d+=u.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function u6(){return"!"}QE.peek=d6;function QE(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 d6(){return"`"}function ZE(e,t){const n=ub(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))}e2.peek=h6;function e2(e,t,n,r){const a=bb(n),o=a==='"'?"Quote":"Apostrophe",c=n.createTracker(r);let u,d;if(ZE(e,n)){const p=n.stack;n.stack=[],u=n.enter("autolink");let m=c.move("<");return m+=c.move(n.containerPhrasing(e,{before:m,after:">",...c.current()})),m+=c.move(">"),u(),n.stack=p,m}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 h6(e,t,n){return ZE(e,n)?"<":"["}t2.peek=f6;function t2(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 p=n.stack;n.stack=[],c=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return c(),n.stack=p,o(),a==="full"||!h||h!==m?d+=u.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function f6(){return"["}function vb(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 m6(e){const t=vb(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 p6(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 n2(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 g6(e,t,n,r){const a=n.enter("list"),o=n.bulletCurrent;let c=e.ordered?p6(n):vb(n);const u=e.ordered?c==="."?")":".":m6(n);let d=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(d=!0),n2(n)===c&&p){let m=-1;for(;++m<e.children.length;){const g=e.children[m];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 x6(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 y6(e,t,n,r){const a=x6(n);let o=n.bulletCurrent||vb(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()),p);return d(),h;function p(m,g,x){return g?(x?"":" ".repeat(c))+m:(x?o:o+" ".repeat(c-o.length))+m}}function b6(e,t,n,r){const a=n.enter("paragraph"),o=n.enter("phrasing"),c=n.containerPhrasing(e,r);return o(),a(),c}const v6=If(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function _6(e,t,n,r){return(e.children.some(function(c){return v6(c)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function S6(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}r2.peek=w6;function r2(e,t,n,r){const a=S6(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),p=zh(r.before.charCodeAt(r.before.length-1),h,a);p.inside&&(d=au(h)+d.slice(1));const m=d.charCodeAt(d.length-1),g=zh(r.after.charCodeAt(0),m,a);g.inside&&(d=d.slice(0,-1)+au(m));const x=c.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},u+d+x}function w6(e,t,n){return n.options.strong||"*"}function C6(e,t,n,r){return n.safe(e.value,r)}function k6(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 j6(e,t,n){const r=(n2(n)+(n.options.ruleSpaces?" ":"")).repeat(k6(n));return n.options.ruleSpaces?r.slice(0,-1):r}const s2={blockquote:YP,break:G1,code:t6,definition:r6,emphasis:KE,hardBreak:G1,heading:o6,html:YE,image:XE,imageReference:JE,inlineCode:QE,link:e2,linkReference:t2,list:g6,listItem:y6,paragraph:b6,root:_6,strong:r2,text:C6,thematicBreak:j6};function E6(){return{enter:{table:N6,tableData:W1,tableHeader:W1,tableRow:A6},exit:{codeText:L6,table:T6,tableData:qg,tableHeader:qg,tableRow:qg}}}function N6(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 T6(e){this.exit(e),this.data.inTable=void 0}function A6(e){this.enter({type:"tableRow",children:[]},e)}function qg(e){this.exit(e)}function W1(e){this.enter({type:"tableCell",children:[]},e)}function L6(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,D6));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function D6(e,t){return t==="|"?t:e}function R6(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(p(x,C,v),x.align)}function u(x,w,C,v){const S=m(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 qP(x,{align:w,alignDelimiters:r,padding:n,stringLength:a})}function p(x,w,C){const v=x.children;let S=-1;const _=[],b=w.enter("table");for(;++S<v.length;)_[S]=m(v[S],w,C);return b(),_}function m(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=s2.inlineCode(x,w,C);return C.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function O6(){return{exit:{taskListCheckValueChecked:q1,taskListCheckValueUnchecked:q1,paragraph:M6}}}function I6(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:P6}}}function q1(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function M6(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 P6(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=s2.listItem(e,t,n,{...r,...u.current()});return o&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),d;function h(p){return p+c}}function B6(){return[gP(),PP(),HP(),E6(),O6()]}function $6(e){return{extensions:[xP(),BP(e),FP(),R6(e),I6()]}}const z6={tokenize:W6,partial:!0},i2={tokenize:q6,partial:!0},a2={tokenize:K6,partial:!0},o2={tokenize:Y6,partial:!0},H6={tokenize:X6,partial:!0},l2={name:"wwwAutolink",tokenize:V6,previous:u2},c2={name:"protocolAutolink",tokenize:G6,previous:d2},pi={name:"emailAutolink",tokenize:U6,previous:h2},Os={};function F6(){return{text:Os}}let ja=48;for(;ja<123;)Os[ja]=pi,ja++,ja===58?ja=65:ja===91&&(ja=97);Os[43]=pi;Os[45]=pi;Os[46]=pi;Os[95]=pi;Os[72]=[pi,c2];Os[104]=[pi,c2];Os[87]=[pi,l2];Os[119]=[pi,l2];function U6(e,t,n){const r=this;let a,o;return c;function c(m){return!ey(m)||!h2.call(r,r.previous)||_b(r.events)?n(m):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(m))}function u(m){return ey(m)?(e.consume(m),u):m===64?(e.consume(m),d):n(m)}function d(m){return m===46?e.check(H6,p,h)(m):m===45||m===95||tr(m)?(o=!0,e.consume(m),d):p(m)}function h(m){return e.consume(m),a=!0,d}function p(m){return o&&a&&or(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function V6(e,t,n){const r=this;return a;function a(c){return c!==87&&c!==119||!u2.call(r,r.previous)||_b(r.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(z6,e.attempt(i2,e.attempt(a2,o),n),n)(c))}function o(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function G6(e,t,n){const r=this;let a="",o=!1;return c;function c(m){return(m===72||m===104)&&d2.call(r,r.previous)&&!_b(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),e.consume(m),u):n(m)}function u(m){if(or(m)&&a.length<5)return a+=String.fromCodePoint(m),e.consume(m),u;if(m===58){const g=a.toLowerCase();if(g==="http"||g==="https")return e.consume(m),d}return n(m)}function d(m){return m===47?(e.consume(m),o?h:(o=!0,d)):n(m)}function h(m){return m===null||Ph(m)||tn(m)||Xa(m)||Df(m)?n(m):e.attempt(i2,e.attempt(a2,p),n)(m)}function p(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function W6(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 q6(e,t,n){let r,a,o;return c;function c(h){return h===46||h===95?e.check(o2,d,u)(h):h===null||tn(h)||Xa(h)||h!==45&&Df(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 K6(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(o2,t,o)(c):c===null||tn(c)||Xa(c)?t(c):(e.consume(c),a)}function o(c){return c===41&&r++,e.consume(c),a}}function Y6(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||tn(u)||Xa(u)?t(u):n(u)}function a(u){return u===null||u===40||u===91||tn(u)||Xa(u)?t(u):r(u)}function o(u){return or(u)?c(u):n(u)}function c(u){return u===59?(e.consume(u),r):or(u)?(e.consume(u),c):n(u)}}function X6(e,t,n){return r;function r(o){return e.consume(o),a}function a(o){return tr(o)?n(o):t(o)}}function u2(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||tn(e)}function d2(e){return!or(e)}function h2(e){return!(e===47||ey(e))}function ey(e){return e===43||e===45||e===46||e===95||tr(e)}function _b(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 J6={tokenize:iB,partial:!0};function Q6(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:nB,continuation:{tokenize:rB},exit:sB}},text:{91:{name:"gfmFootnoteCall",tokenize:tB},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Z6,resolveTo:eB}}}}function Z6(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=hs(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 eB(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 tB(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,c;return u;function u(m){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),d}function d(m){return m!==94?n(m):(e.enter("gfmFootnoteCallMarker"),e.consume(m),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(m){if(o>999||m===93&&!c||m===null||m===91||tn(m))return n(m);if(m===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return a.includes(hs(r.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return tn(m)||(c=!0),o++,e.consume(m),m===92?p:h}function p(m){return m===91||m===92||m===93?(e.consume(m),o++,h):h(m)}}function nB(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",p):n(w)}function p(w){if(c>999||w===93&&!u||w===null||w===91||tn(w))return n(w);if(w===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return o=hs(r.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return tn(w)||(u=!0),c++,e.consume(w),w===92?m:p}function m(w){return w===91||w===92||w===93?(e.consume(w),c++,p):p(w)}function g(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(o)||a.push(o),Lt(e,x,"gfmFootnoteDefinitionWhitespace")):n(w)}function x(w){return t(w)}}function rB(e,t,n){return e.check(bu,t,e.attempt(J6,t,n))}function sB(e){e.exit("gfmFootnoteDefinition")}function iB(e,t,n){const r=this;return Lt(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 aB(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 p={type:"strikethrough",start:Object.assign({},c[h][1].start),end:Object.assign({},c[d][1].end)},m={type:"strikethroughText",start:Object.assign({},c[h][1].end),end:Object.assign({},c[d][1].start)},g=[["enter",p,u],["enter",c[h][1],u],["exit",c[h][1],u],["enter",m,u]],x=u.parser.constructs.insideSpan.null;x&&Rr(g,g.length,0,Rf(x,c.slice(h+1,d),u)),Rr(g,g.length,0,[["exit",m,u],["enter",c[d][1],u],["exit",c[d][1],u],["exit",p,u]]),Rr(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,p=this.events;let m=0;return g;function g(w){return h===126&&p[p.length-1][1].type!=="characterEscape"?d(w):(c.enter("strikethroughSequenceTemporary"),x(w))}function x(w){const C=gl(h);if(w===126)return m>1?d(w):(c.consume(w),m++,x);if(m<2&&!n)return d(w);const v=c.exit("strikethroughSequenceTemporary"),S=gl(w);return v._open=!S||S===2&&!!C,v._close=!C||C===2&&!!S,u(w)}}}class oB{constructor(){this.map=[]}add(t,n,r){lB(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 lB(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 cB(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 uB(){return{flow:{null:{name:"table",tokenize:dB,resolveAll:hB}}}}function dB(e,t,n){const r=this;let a=0,o=0,c;return u;function u(M){let W=r.events.length-1;for(;W>-1;){const B=r.events[W][1].type;if(B==="lineEnding"||B==="linePrefix")W--;else break}const $=W>-1?r.events[W][1].type:null,G=$==="tableHead"||$==="tableRow"?T:d;return G===T&&r.parser.lazy[r.now().line]?n(M):G(M)}function d(M){return e.enter("tableHead"),e.enter("tableRow"),h(M)}function h(M){return M===124||(c=!0,o+=1),p(M)}function p(M){return M===null?n(M):ut(M)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),x):n(M):Et(M)?Lt(e,p,"whitespace")(M):(o+=1,c&&(c=!1,a+=1),M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),c=!0,p):(e.enter("data"),m(M)))}function m(M){return M===null||M===124||tn(M)?(e.exit("data"),p(M)):(e.consume(M),M===92?g:m)}function g(M){return M===92||M===124?(e.consume(M),m):m(M)}function x(M){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(M):(e.enter("tableDelimiterRow"),c=!1,Et(M)?Lt(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 Et(M)?Lt(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||ut(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 Et(M)?Lt(e,k,"whitespace")(M):k(M)}function k(M){return M===124?w(M):M===null||ut(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"),D(M)}function D(M){return M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),D):M===null||ut(M)?(e.exit("tableRow"),t(M)):Et(M)?Lt(e,D,"whitespace")(M):(e.enter("data"),A(M))}function A(M){return M===null||M===124||tn(M)?(e.exit("data"),D(M)):(e.consume(M),M===92?R:A)}function R(M){return M===92||M===124?(e.consume(M),A):A(M)}}function hB(e,t){let n=-1,r=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],u=!1,d=0,h,p,m;const g=new oB;for(;++n<e.length;){const x=e[n],w=x[1];x[0]==="enter"?w.type==="tableHead"?(u=!1,d!==0&&(K1(g,t,d,h,p),p=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,m=void 0,o=[0,0,0,0],c=[0,n+1,0,0],u&&(u=!1,p={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(n,0,[["enter",p,t]])),a=w.type==="tableDelimiterRow"?2:p?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,c[2]===0&&(o[1]!==0&&(c[0]=c[1],m=Kd(g,t,o,a,void 0,m),o=[0,0,0,0]),c[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(c[0]=c[1],m=Kd(g,t,o,a,void 0,m)),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],m=Kd(g,t,o,a,n,m)):c[1]!==0&&(m=Kd(g,t,c,a,n,m)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(c[3]=n)}for(d!==0&&K1(g,t,d,h,p),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=cB(t.events,n))}return e}function Kd(e,t,n,r,a,o){const c=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(o.end=Object.assign({},Jo(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const d=Jo(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=Jo(t.events,n[2]),p=Jo(t.events,n[3]),m={type:u,start:Object.assign({},h),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",m,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",m,t]])}return a!==void 0&&(o.end=Object.assign({},Jo(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function K1(e,t,n,r,a){const o=[],c=Jo(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 Jo(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const fB={name:"tasklistCheck",tokenize:pB};function mB(){return{text:{91:fB}}}function pB(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 tn(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 ut(d)?t(d):Et(d)?e.check({tokenize:gB},t,n)(d):n(d)}}function gB(e,t,n){return Lt(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function xB(e){return SE([F6(),Q6(),aB(e),uB(),mB()])}const yB={};function bB(e){const t=this,n=e||yB,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),c=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(xB(n)),o.push(B6()),c.push($6(n))}var ty=Object.defineProperty,vB=Object.getOwnPropertyDescriptor,_B=Object.getOwnPropertyNames,SB=Object.prototype.hasOwnProperty,Sb=(e,t)=>{let n={};for(var r in e)ty(n,r,{get:e[r],enumerable:!0});return ty(n,Symbol.toStringTag,{value:"Module"}),n},wB=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=_B(t),o=0,c=a.length,u;o<c;o++)u=a[o],!SB.call(e,u)&&u!==n&&ty(e,u,{get:(d=>t[d]).bind(null,u),enumerable:!(r=vB(t,u))||r.enumerable});return e},f2=(e,t,n)=>(wB(e,t,"default"),n);const Pf=[{id:"abap",name:"ABAP",import:(()=>ne(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>ne(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>ne(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>ne(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>ne(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>ne(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>ne(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>ne(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>ne(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>ne(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>ne(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>ne(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>ne(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>ne(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>ne(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>ne(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>ne(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>ne(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>ne(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>ne(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>ne(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>ne(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>ne(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>ne(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>ne(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>ne(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>ne(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>ne(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>ne(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>ne(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>ne(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>ne(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>ne(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>ne(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>ne(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>ne(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>ne(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>ne(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>ne(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>ne(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>ne(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>ne(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>ne(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>ne(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>ne(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>ne(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>ne(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>ne(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>ne(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>ne(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>ne(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>ne(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>ne(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>ne(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>ne(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>ne(()=>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:(()=>ne(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>ne(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>ne(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>ne(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>ne(()=>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:(()=>ne(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>ne(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>ne(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>ne(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>ne(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>ne(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>ne(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>ne(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>ne(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>ne(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>ne(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>ne(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>ne(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>ne(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>ne(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>ne(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>ne(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>ne(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>ne(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>ne(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>ne(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>ne(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>ne(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>ne(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>ne(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>ne(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>ne(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>ne(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>ne(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>ne(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>ne(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>ne(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>ne(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>ne(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>ne(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>ne(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>ne(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>ne(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>ne(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>ne(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>ne(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>ne(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>ne(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>ne(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>ne(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>ne(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>ne(()=>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:(()=>ne(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>ne(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>ne(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>ne(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>ne(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>ne(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>ne(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>ne(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>ne(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>ne(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>ne(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>ne(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>ne(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>ne(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>ne(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>ne(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>ne(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>ne(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>ne(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>ne(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>ne(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>ne(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>ne(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>ne(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>ne(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>ne(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>ne(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>ne(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>ne(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>ne(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>ne(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>ne(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>ne(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>ne(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>ne(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>ne(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>ne(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>ne(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>ne(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>ne(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>ne(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>ne(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>ne(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>ne(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>ne(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>ne(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>ne(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>ne(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>ne(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>ne(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>ne(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>ne(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>ne(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>ne(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>ne(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>ne(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>ne(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>ne(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>ne(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>ne(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>ne(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>ne(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>ne(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>ne(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>ne(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>ne(()=>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:(()=>ne(()=>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:(()=>ne(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>ne(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>ne(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>ne(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>ne(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>ne(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>ne(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>ne(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>ne(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>ne(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>ne(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>ne(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>ne(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>ne(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>ne(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>ne(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>ne(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>ne(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>ne(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>ne(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>ne(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>ne(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>ne(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>ne(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>ne(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>ne(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>ne(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>ne(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>ne(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>ne(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>ne(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>ne(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>ne(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>ne(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>ne(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>ne(()=>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:(()=>ne(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>ne(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>ne(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>ne(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>ne(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>ne(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>ne(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>ne(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>ne(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>ne(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>ne(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>ne(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>ne(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>ne(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>ne(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>ne(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>ne(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>ne(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>ne(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>ne(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>ne(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>ne(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>ne(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>ne(()=>import("./zig-VOosw3JB.js"),[]))}],wb=Object.fromEntries(Pf.map(e=>[e.id,e.import])),Cb=Object.fromEntries(Pf.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),Bf={...wb,...Cb},kb=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>ne(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>ne(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>ne(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>ne(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>ne(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>ne(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>ne(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>ne(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>ne(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>ne(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>ne(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>ne(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>ne(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>ne(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>ne(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>ne(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>ne(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>ne(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>ne(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>ne(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>ne(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>ne(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>ne(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>ne(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>ne(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>ne(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>ne(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>ne(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>ne(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>ne(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>ne(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>ne(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>ne(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>ne(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>ne(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>ne(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>ne(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>ne(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>ne(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>ne(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>ne(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>ne(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>ne(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>ne(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>ne(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>ne(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>ne(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>ne(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>ne(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>ne(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>ne(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>ne(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>ne(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>ne(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>ne(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>ne(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>ne(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>ne(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>ne(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>ne(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>ne(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>ne(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>ne(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>ne(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>ne(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],jb=Object.fromEntries(kb.map(e=>[e.id,e.import]));var Eb=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function CB(){return 2147483648}function kB(){return typeof performance<"u"?performance.now():Date.now()}const jB=(e,t)=>e+(t-e%t)%t;async function EB(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=CB();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,jB(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 p(x,w){return x?h(r.HEAPU8,x,w):""}const m={emscripten_get_now:kB,emscripten_memcpy_big:o,emscripten_resize_heap:u,fd_write:()=>0};async function g(){const w=await e({env:m,wasi_snapshot_preview1:m});t=w.memory,a(t.buffer),Object.assign(r,w),r.UTF8ToString=p}return await g(),r}var NB=Object.defineProperty,TB=(e,t,n)=>t in e?NB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,In=(e,t,n)=>TB(e,typeof t!="symbol"?t+"":t,n);let Fn=null;function AB(e){throw new Eb(e.UTF8ToString(e.getLastOnigError()))}class $f{constructor(t){In(this,"utf16Length"),In(this,"utf8Length"),In(this,"utf16Value"),In(this,"utf8Value"),In(this,"utf16OffsetToUtf8"),In(this,"utf8OffsetToUtf16");const n=t.length,r=$f._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 p=t.charCodeAt(h);let m=p,g=!1;if(p>=55296&&p<=56319&&h+1<n){const x=t.charCodeAt(h+1);x>=56320&&x<=57343&&(m=(p-55296<<10)+65536|x-56320,g=!0)}a&&(o[h]=d,g&&(o[h+1]=d),m<=127?c[d+0]=h:m<=2047?(c[d+0]=h,c[d+1]=h):m<=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)),m<=127?u[d++]=m:m<=2047?(u[d++]=192|(m&1984)>>>6,u[d++]=128|(m&63)>>>0):m<=65535?(u[d++]=224|(m&61440)>>>12,u[d++]=128|(m&4032)>>>6,u[d++]=128|(m&63)>>>0):(u[d++]=240|(m&1835008)>>>18,u[d++]=128|(m&258048)>>>12,u[d++]=128|(m&4032)>>>6,u[d++]=128|(m&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 zf=class ws{constructor(t){if(In(this,"id",++ws.LAST_ID),In(this,"_onigBinding"),In(this,"content"),In(this,"utf16Length"),In(this,"utf8Length"),In(this,"utf16OffsetToUtf8"),In(this,"utf8OffsetToUtf16"),In(this,"ptr"),!Fn)throw new Eb("Must invoke loadWasm first.");this._onigBinding=Fn,this.content=t;const n=new $f(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!ws._sharedPtrInUse?(ws._sharedPtr||(ws._sharedPtr=Fn.omalloc(1e4)),ws._sharedPtrInUse=!0,Fn.HEAPU8.set(n.utf8Value,ws._sharedPtr),this.ptr=ws._sharedPtr):this.ptr=n.createString(Fn)}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===ws._sharedPtr?ws._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};In(zf,"LAST_ID",0);In(zf,"_sharedPtr",0);In(zf,"_sharedPtrInUse",!1);let m2=zf;class LB{constructor(t){if(In(this,"_onigBinding"),In(this,"_ptr"),!Fn)throw new Eb("Must invoke loadWasm first.");const n=[],r=[];for(let u=0,d=t.length;u<d;u++){const h=new $f(t[u]);n[u]=h.createString(Fn),r[u]=h.utf8Length}const a=Fn.omalloc(4*t.length);Fn.HEAPU32.set(n,a/4);const o=Fn.omalloc(4*t.length);Fn.HEAPU32.set(r,o/4);const c=Fn.createOnigScanner(a,o,t.length);for(let u=0,d=t.length;u<d;u++)Fn.ofree(n[u]);Fn.ofree(o),Fn.ofree(a),c===0&&AB(Fn),this._onigBinding=Fn,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 m2(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++],p=u[d++],m=[];for(let g=0;g<p;g++){const x=t.convertUtf8OffsetToUtf16(u[d++]),w=t.convertUtf8OffsetToUtf16(u[d++]);m[g]={start:x,end:w,length:w-x}}return{index:h,captureIndices:m}}}function DB(e){return typeof e.instantiator=="function"}function RB(e){return typeof e.default=="function"}function OB(e){return typeof e.data<"u"}function IB(e){return typeof Response<"u"&&e instanceof Response}function MB(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 Yd;function Nb(e){if(Yd)return Yd;async function t(){Fn=await EB(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),DB(r)?r=await r.instantiator(n):RB(r)?r=await r.default(n):(OB(r)&&(r=r.data),IB(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await PB(r)(n):r=await BB(r)(n):MB(r)?r=await Kg(r)(n):r instanceof WebAssembly.Module?r=await Kg(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await Kg(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return Yd=t(),Yd}function Kg(e){return t=>WebAssembly.instantiate(e,t)}function PB(e){return t=>WebAssembly.instantiateStreaming(e,t)}function BB(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let p2;function $B(e){p2=e}function zB(){return p2}async function g2(e){return e&&await Nb(e),{createScanner(t){return new LB(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new m2(t)}}}const HB=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:g2,getDefaultWasmLoader:zB,loadWasm:Nb,setDefaultWasmLoader:$B},Symbol.toStringTag,{value:"Module"}));var x2=Sb({});f2(x2,HB);var nn=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function FB(e){return Tb(e)}function Tb(e){return Array.isArray(e)?UB(e):e instanceof RegExp?e:typeof e=="object"?VB(e):e}function UB(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Tb(e[n]);return t}function VB(e){let t={};for(let n in e)t[n]=Tb(e[n]);return t}function y2(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function b2(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?b2(e.substring(0,e.length-1)):e.substr(~t+1)}var Yg=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Xd=class{static hasCaptures(e){return e===null?!1:(Yg.lastIndex=0,Yg.test(e))}static replaceCaptures(e,t,n){return e.replace(Yg,(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 v2(e,t){return e<t?-1:e>t?1:0}function _2(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=v2(e[a],t[a]);if(o!==0)return o}return 0}return n-r}function Y1(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 S2(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var w2=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}},Hh=class{constructor(e,t,n){Le(this,"_cachedMatchRoot",new w2(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(qB(e),t)}static createFromParsedTheme(e,t){return YB(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=>GB(e.parent,a.parentScopes));return r?new C2(r.fontStyle,r.foreground,r.background):null}},Xg=class Ch{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new Ch(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Ch(n,t[r]);return n}push(t){return new Ch(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 GB(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&&!WB(e.scopeName,r);){if(a)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function WB(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var C2=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function qB(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 m=c.scope;m=m.replace(/^[,]+/,""),m=m.replace(/[,]+$/,""),u=m.split(",")}else Array.isArray(c.scope)?u=c.scope:u=[""];let d=-1;if(typeof c.settings.fontStyle=="string"){d=0;let m=c.settings.fontStyle.split(" ");for(let g=0,x=m.length;g<x;g++)switch(m[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"&&Y1(c.settings.foreground)&&(h=c.settings.foreground);let p=null;typeof c.settings.background=="string"&&Y1(c.settings.background)&&(p=c.settings.background);for(let m=0,g=u.length;m<g;m++){let w=u[m].trim().split(" "),C=w[w.length-1],v=null;w.length>1&&(v=w.slice(0,w.length-1),v.reverse()),n[r++]=new KB(C,v,a,d,h,p)}}return n}var KB=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}},er=(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))(er||{});function YB(e,t){e.sort((d,h)=>{let p=v2(d.scope,h.scope);return p!==0||(p=_2(d.parentScopes,h.parentScopes),p!==0)?p:d.index-h.index});let n=0,r="#000000",a="#ffffff";for(;e.length>=1&&e[0].scope==="";){let d=e.shift();d.fontStyle!==-1&&(n=d.fontStyle),d.foreground!==null&&(r=d.foreground),d.background!==null&&(a=d.background)}let o=new XB(t),c=new C2(n,o.getId(r),o.getId(a)),u=new QB(new ny(0,null,-1,0,0),[]);for(let d=0,h=e.length;d<h;d++){let p=e[d];u.insert(0,p.scope,p.parentScopes,p.fontStyle,o.getId(p.foreground),o.getId(p.background))}return new Hh(o,c,u)}var XB=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)}},JB=Object.freeze([]),ny=class k2{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||JB,this.fontStyle=r,this.foreground=a,this.background=o}clone(){return new k2(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)}},QB=class ry{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(ry._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 p;this._children.hasOwnProperty(d)?p=this._children[d]:(p=new ry(this._mainRule.clone(),ny.cloneArr(this._rulesWithParentScopes)),this._children[d]=p),p.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(_2(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 ny(t,n,r,a,o))}},qa=class Gr{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=Gr.getLanguageId(t),r=Gr.getTokenType(t),a=Gr.getFontStyle(t),o=Gr.getForeground(t),c=Gr.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=Gr.getLanguageId(t),h=Gr.getTokenType(t),p=Gr.containsBalancedBrackets(t)?1:0,m=Gr.getFontStyle(t),g=Gr.getForeground(t),x=Gr.getBackground(t);return n!==0&&(d=n),r!==8&&(h=r),a!==null&&(p=a?1:0),o!==-1&&(m=o),c!==0&&(g=c),u!==0&&(x=u),(d<<0|h<<8|p<<10|m<<11|g<<15|x<<24)>>>0}};function Fh(e,t){const n=[],r=ZB(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(X1(a)){const d=[];do d.push(a),a=r.next();while(X1(a));return h=>t(d,h)}return null}function c(){const d=[];let h=o();for(;h;)d.push(h),h=o();return p=>d.every(m=>m(p))}function u(){const d=[];let h=c();for(;h&&(d.push(h),a==="|"||a===",");){do a=r.next();while(a==="|"||a===",");h=c()}return p=>d.some(m=>m(p))}}function X1(e){return!!e&&!!e.match(/[\w\.:]+/)}function ZB(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 j2(e){typeof e.dispose=="function"&&e.dispose()}var ou=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},e8=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},t8=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))}},n8=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 ou(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new t8;for(const n of e)r8(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof ou){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 r8(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 ou?kh({baseGrammar:o,selfGrammar:a},r):sy(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 ou(u))}function sy(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];Uh([r],t,n)}}function kh(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Uh(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Uh(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Uh(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const a=r.repository?y2({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Uh(r.patterns,{...t,repository:a},n);const o=r.include;if(!o)continue;const c=E2(o);switch(c.kind){case 0:kh({...t,selfGrammar:t.baseGrammar},n);break;case 1:kh(t,n);break;case 2:sy(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?sy(c.ruleName,d,n):kh(d,n)}else c.kind===4?n.add(new e8(c.scopeName,c.ruleName)):n.add(new ou(c.scopeName));break}}}var s8=class{constructor(){Le(this,"kind",0)}},i8=class{constructor(){Le(this,"kind",1)}},a8=class{constructor(e){Le(this,"kind",2);this.ruleName=e}},o8=class{constructor(e){Le(this,"kind",3);this.scopeName=e}},l8=class{constructor(e,t){Le(this,"kind",4);this.scopeName=e,this.ruleName=t}};function E2(e){if(e==="$base")return new s8;if(e==="$self")return new i8;const t=e.indexOf("#");if(t===-1)return new o8(e);if(t===0)return new a8(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new l8(n,r)}}var c8=/\\(\d+)/,J1=/\\(\d+)/g,u8=-1,N2=-2;var _u=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=Xd.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Xd.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${b2(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:Xd.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Xd.replaceCaptures(this._contentName,e,t)}},d8=class extends _u{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!")}},h8=class extends _u{constructor(t,n,r,a,o){super(t,n,r,null);Le(this,"_match");Le(this,"captures");Le(this,"_cachedCompiledPatterns");this._match=new lu(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 cu,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Q1=class extends _u{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 cu,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},iy=class extends _u{constructor(t,n,r,a,o,c,u,d,h,p){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 lu(o,this.id),this.beginCaptures=c,this._end=new lu(u||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=d,this.applyEndPatternLast=h||!1,this.patterns=p.patterns,this.hasMissingPatterns=p.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,n){return this._end.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t,n).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t,n).compileAG(t,r,a)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new cu;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}},Vh=class extends _u{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 lu(o,this.id),this.beginCaptures=c,this.whileCaptures=d,this._while=new lu(u,N2),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 cu;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 cu,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||""),this._cachedCompiledWhilePatterns}},T2=class Xn{static createCaptureRule(t,n,r,a,o){return t.registerRule(c=>new d8(n,c,r,a,o))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(a=>{if(t.id=a,t.match)return new h8(t.$vscodeTextmateLocation,t.id,t.name,t.match,Xn._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=y2({},r,t.repository));let o=t.patterns;return typeof o>"u"&&t.include&&(o=[{include:t.include}]),new Q1(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Xn._compilePatterns(o,n,r))}return t.while?new Vh(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Xn._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,Xn._compileCaptures(t.whileCaptures||t.captures,n,r),Xn._compilePatterns(t.patterns,n,r)):new iy(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Xn._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,Xn._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,Xn._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=Xn.getCompiledRuleId(t[c],n,r)),a[u]=Xn.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=E2(u.include);switch(h.kind){case 0:case 1:d=Xn.getCompiledRuleId(r[u.include],n,r);break;case 2:let p=r[h.ruleName];p&&(d=Xn.getCompiledRuleId(p,n,r));break;case 3:case 4:const m=h.scopeName,g=h.kind===4?h.ruleName:null,x=n.getExternalGrammar(m,r);if(x)if(g){let w=x.repository[g];w&&(d=Xn.getCompiledRuleId(w,n,x.repository))}else d=Xn.getCompiledRuleId(x.repository.$self,n,x.repository);break}}else d=Xn.getCompiledRuleId(u,n,r);if(d!==-1){const h=n.getRule(d);let p=!1;if((h instanceof Q1||h instanceof iy||h instanceof Vh)&&h.hasMissingPatterns&&h.patterns.length===0&&(p=!0),p)continue;a.push(d)}}return{patterns:a,hasMissingPatterns:(t?t.length:0)!==a.length}}},lu=class A2{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=c8.test(this.source):this.hasBackReferences=!1}clone(){return new A2(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 J1.lastIndex=0,this.source.replace(J1,(a,o)=>S2(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}},cu=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 Z1(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 Z1(e,r,this._items.map(a=>a.ruleId))}},Z1=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}},Jg=class{constructor(e,t){this.languageId=e,this.tokenType=t}},oi,f8=(oi=class{constructor(t,n){Le(this,"_defaultAttributes");Le(this,"_embeddedLanguagesMatcher");Le(this,"_getBasicScopeAttributes",new w2(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new Jg(n,r)}));this._defaultAttributes=new Jg(t,8),this._embeddedLanguagesMatcher=new m8(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?oi._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(oi.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(oi,"_NULL_SCOPE_METADATA",new Jg(0,0)),Le(oi,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),oi),m8=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])=>S2(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])}},eC=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function L2(e,t,n,r,a,o,c,u){const d=t.content.length;let h=!1,p=-1;if(c){const x=p8(e,t,n,r,a,o);a=x.stack,r=x.linePos,n=x.isFirstLine,p=x.anchorPosition}const m=Date.now();for(;!h;){if(u!==0&&Date.now()-m>u)return new eC(a,!0);g()}return new eC(a,!1);function g(){const x=g8(e,t,n,r,a,p);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===u8){const S=a.getRule(e);o.produce(a,w[0].start),a=a.withContentNameScopesList(a.nameScopesList),Hc(e,t,n,a,o,S.endCaptures,w),o.produce(a,w[0].end);const _=a;if(a=a.parent,p=_.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,p,w[0].end===d,null,k,k),S instanceof iy){const E=S;Hc(e,t,n,a,o,E.beginCaptures,w),o.produce(a,w[0].end),p=w[0].end;const T=E.getContentName(t.content,w),D=k.pushAttributed(T,e);if(a=a.withContentNameScopesList(D),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 Vh){const E=S;Hc(e,t,n,a,o,E.beginCaptures,w),o.produce(a,w[0].end),p=w[0].end;const T=E.getContentName(t.content,w),D=k.pushAttributed(T,e);if(a=a.withContentNameScopesList(D),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(Hc(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 p8(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 Vh&&u.push({rule:h,stack:d})}for(let d=u.pop();d;d=u.pop()){const{ruleScanner:h,findOptions:p}=b8(d.rule,e,d.stack.endRule,n,r===c),m=h.findNextMatchSync(t,r,p);if(m){if(m.ruleId!==N2){a=d.stack.pop();break}m.captureIndices&&m.captureIndices.length&&(o.produce(d.stack,m.captureIndices[0].start),Hc(e,t,n,d.stack,o,d.rule.whileCaptures,m.captureIndices),o.produce(d.stack,m.captureIndices[0].end),c=m.captureIndices[0].end,m.captureIndices[0].end>r&&(r=m.captureIndices[0].end,n=!1))}else{a=d.stack.pop();break}}return{stack:a,linePos:r,anchorPosition:c,isFirstLine:n}}function g8(e,t,n,r,a,o){const c=x8(e,t,n,r,a,o),u=e.getInjections();if(u.length===0)return c;const d=y8(u,e,t,n,r,a,o);if(!d)return c;if(!c)return d;const h=c.captureIndices[0].start,p=d.captureIndices[0].start;return p<h||d.priorityMatch&&p===h?d:c}function x8(e,t,n,r,a,o){const c=a.getRule(e),{ruleScanner:u,findOptions:d}=D2(c,e,a.endRule,n,r===o),h=u.findNextMatchSync(t,r,d);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function y8(e,t,n,r,a,o,c){let u=Number.MAX_VALUE,d=null,h,p=0;const m=o.contentNameScopesList.getScopeNames();for(let g=0,x=e.length;g<x;g++){const w=e[g];if(!w.matcher(m))continue;const C=t.getRule(w.ruleId),{ruleScanner:v,findOptions:S}=D2(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,p=w.priority,u===a))break}return d?{priorityMatch:p===-1,captureIndices:d,matchedRuleId:h}:null}function D2(e,t,n,r,a){return{ruleScanner:e.compileAG(t,n,r,a),findOptions:0}}function b8(e,t,n,r,a){return{ruleScanner:e.compileWhileAG(t,n,r,a),findOptions:0}}function Hc(e,t,n,r,a,o,c){if(o.length===0)return;const u=t.content,d=Math.min(o.length,c.length),h=[],p=c[0].end;for(let m=0;m<d;m++){const g=o[m];if(g===null)continue;const x=c[m];if(x.length===0)continue;if(x.start>p)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));L2(e,k,n&&x.start===0,x.start,b,a,!1,0),j2(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 v8(v,x.end))}}for(;h.length>0;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var v8=class{constructor(e,t){Le(this,"scopes");Le(this,"endPos");this.scopes=e,this.endPos=t}};function _8(e,t,n,r,a,o,c,u){return new w8(e,t,n,r,a,o,c,u)}function tC(e,t,n,r,a){const o=Fh(t,Gh),c=T2.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 Gh(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(S8(t[a],r))return n=a+1,!0;return!1})}function S8(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 w8=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 f8(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=c,this._grammar=nC(t,null),this._injections=null,this._tokenTypeMatchers=[],a)for(const d of Object.keys(a)){const h=Fh(d,Gh);for(const p of h)this._tokenTypeMatchers.push({matcher:p.matcher,type:a[d]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:a=>a===this._rootScopeName?this._grammar:this.getExternalGrammar(a),injections:a=>this._grammarRepository.injections(a)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const a=r.injections;if(a)for(let c in a)tC(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&&tC(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]=nC(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=T2.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(),p=this.themeProvider.getDefaults(),m=qa.set(0,h.languageId,h.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),g=this.getRule(this._rootId).getName(null,null);let x;g?x=Kc.createRootAndLookUpScopeName(g,m,this):x=Kc.createRoot("unknown",m),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 k8(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),d=L2(this,o,a,0,t,u,!0,r);return j2(o),{lineLength:c,lineTokens:u,ruleStack:d.stack,stoppedEarly:d.stoppedEarly}}};function nC(e,t){return e=FB(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 Kc=class Cs{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=Xg.push(a,o.scopeNames),r=new Cs(r,a,o.encodedTokenAttributes);return r}static createRoot(t,n){return new Cs(null,new Xg(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const a=r.getMetadataForScope(t),o=new Xg(null,t),c=r.themeProvider.themeMatch(o),u=Cs.mergeAttributes(n,a,c);return new Cs(null,o,u)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Cs.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),qa.set(t,n.languageId,n.tokenType,null,a,o,c)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Cs._pushAttributed(this,t,n);const r=t.split(/ /g);let a=this;for(const o of r)a=Cs._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=Cs.mergeAttributes(t.tokenAttributes,a,c);return new Cs(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}},Kr,ay=(Kr=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:Kr._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Kc.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(){Kr._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,a,o,c,u){return new Kr(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 Kr(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=Kc.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new Kr(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Kc.fromExtension(r,n.contentNameScopesList))}},Le(Kr,"NULL",new Kr(null,0,0,0,!1,null,null,null)),Kr),C8=class{constructor(e,t){Le(this,"balancedBracketScopes");Le(this,"unbalancedBracketScopes");Le(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Fh(n,Gh).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>Fh(n,Gh).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}},k8=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=qa.set(a,0,u.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(c))}if(o&&(a=qa.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}},j8=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,_8(e,o,t,n,r,a,this,this._onigLib))}return this._grammars.get(e)}},E8=class{constructor(t){Le(this,"_options");Le(this,"_syncRegistry");Le(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new j8(Hh.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(Hh.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 C8(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,a,o){const c=new n8(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)}},oy=ay.NULL;function Wh(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 Ji(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function N8(e){return Array.isArray(e)?e:[e]}async function R2(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Hf(e){return!e||["plaintext","txt","text","plain"].includes(e)}function O2(e){return e==="ansi"||Hf(e)}function Ff(e){return e==="none"}function I2(e){return Ff(e)}const T8=/(\r?\n)/g;function Uf(e,t=!1){var o;if(e.length===0)return[["",0]];const n=e.split(T8);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"},sC={light:"#fffffe",dark:"#1e1e1e"},iC="__shiki_resolved";function Ab(e){var u,d,h,p,m;if(e!=null&&e[iC])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&&((p=t==null?void 0:t.colors)!=null&&p["editor.background"])&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?rC.light:rC.dark),n||(n=t.type==="light"?sC.light:sC.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"))&&!((m=t.colors[g])!=null&&m.startsWith("#"))){const x=c(t.colors[g]);t.colorReplacements[x]=t.colors[g],t.colors[g]=x}return Object.defineProperty(t,iC,{enumerable:!1,writable:!1,value:!0}),t}async function M2(e){return[...new Set((await Promise.all(e.filter(t=>!O2(t)).map(async t=>await R2(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function P2(e){return(await Promise.all(e.map(async t=>I2(t)?null:Ab(await R2(t))))).filter(t=>!!t)}function B2(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 nn(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var A8=class extends E8{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=Ab(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=Hh.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=B2(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 p;return(p=h.embeddedLangsLazy)==null?void 0:p.includes(t.name)}));this._resolver.addLanguage(t);const r={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const a=this.loadGrammarWithConfiguration(t.scopeName,1,r);if(a.name=t.name,this._resolvedGrammars.set(t.name,a),t.aliases&&t.aliases.forEach(h=>{this._alias[h]=t.name}),this._loadedLanguagesCache=null,n.size)for(const h of n)this._resolvedGrammars.delete(h.name),this._loadedLanguagesCache=null,(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 nn(`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))}},L8=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 Lc=0;function D8(e){Lc+=1,e.warnings!==!1&&Lc>=10&&Lc%10===0&&console.warn(`[Shiki] ${Lc} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new nn("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Ab),a=new A8(new L8(e.engine,n),r,n,e.langAlias);let o;function c(_){return B2(_,e.langAlias)}function u(_){v();const b=a.getGrammar(typeof _=="string"?_:_.name);if(!b)throw new nn(`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 nn(`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 p(){return v(),a.getLoadedThemes()}function m(){return v(),a.getLoadedLanguages()}function g(..._){v(),a.loadLanguages(_.flat(1))}async function x(..._){return g(await M2(_))}function w(..._){v();for(const b of _.flat(1))a.loadTheme(b)}async function C(..._){return v(),w(await P2(_))}function v(){if(t)throw new nn("Shiki instance has been disposed")}function S(){t||(t=!0,a.dispose(),Lc-=1)}return{setTheme:h,getTheme:d,getLanguage:u,getLoadedThemes:p,getLoadedLanguages:m,resolveLangAlias:c,loadLanguage:x,loadLanguageSync:g,loadTheme:C,loadThemeSync:w,dispose:S,[Symbol.dispose]:S}}async function R8(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([P2(e.themes||[]),M2(e.langs||[]),e.engine]);return D8({...e,themes:t,langs:n,engine:r})}const $2=new WeakMap;function Vf(e,t){$2.set(e,t)}function uu(e){return $2.get(e)}var Gf=class z2{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 z2(Object.fromEntries(N8(n).map(r=>[r,oy])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return O8(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function O8(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 I8(e,t){if(!(e instanceof Gf))throw new nn("Invalid grammar state");return e.getInternalStack(t)}const M8=/,/,P8=/ /;function H2(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(Hf(e.resolveLangAlias(n.lang||"text"))||Ff(r))return Uf(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 nn(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${c.name}"`);if(!n.grammarState.themes.includes(a.name))throw new nn(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return $8(t,c,a,o,n)}function B8(...e){if(e.length===2)return uu(e[1]);const[t,n,r={}]=e,{lang:a="text",theme:o=t.getLoadedThemes()[0]}=r;if(Hf(a)||Ff(o))throw new nn("Plain language does not have grammar state");if(a==="ansi")throw new nn("ANSI language does not have grammar state");const{theme:c,colorMap:u}=t.setTheme(o),d=t.getLanguage(a);return new Gf(Lb(n,d,c,u,r).stateStack,d.name,c.name)}function $8(e,t,n,r,a){const o=Lb(e,t,n,r,a),c=new Gf(o.stateStack,t.name,n.name);return Vf(o.tokens,c),o.tokens}function Lb(e,t,n,r,a){const o=Wh(n,a),{tokenizeMaxLineLength:c=0,tokenizeTimeLimit:u=500,includeExplanation:d=!1}=a,h=Uf(e);let p=a.grammarState?I8(a.grammarState,n.name)??oy:a.grammarContextCode!=null?Lb(a.grammarContextCode,t,n,r,{...a,grammarState:void 0,grammarContextCode:void 0}).stateStack:oy,m=[];const g=[];for(let x=0,w=h.length;x<w;x++){const[C,v]=h[x];if(C===""){m=[],g.push([]);continue}if(c>0&&C.length>=c){m=[],g.push([{content:C,offset:v,color:"",fontStyle:0}]);continue}let S,_,b;d&&d!=="tokenType"&&(S=t.tokenizeLine(C,p,u),_=S.tokens,b=0);const k=t.tokenizeLine2(C,p,u),E=k.tokens.length/2;for(let T=0;T<E;T++){const D=k.tokens[2*T],A=T+1<E?k.tokens[2*T+2]:C.length;if(D===A)continue;const R=k.tokens[2*T+1],M=Ji(r[qa.getForeground(R)],o),W=qa.getFontStyle(R),$={content:C.substring(D,A),offset:v+D,color:M,fontStyle:W};if(d==="tokenType")$.type=qa.getTokenType(R);else if(d){const G=[];if(d!=="scopeName")for(const H of n.settings){let q;switch(typeof H.scope){case"string":q=H.scope.split(M8).map(Q=>Q.trim());break;case"object":q=H.scope;break;default:continue}G.push({settings:H,selectors:q.map(Q=>Q.split(P8))})}$.explanation=[];let B=0;for(;D+B<A;){const H=_[b],q=C.substring(H.startIndex,H.endIndex);B+=q.length,$.explanation.push({content:q,scopes:d==="scopeName"?z8(H.scopes):H8(G,H.scopes)}),b+=1}}m.push($)}g.push(m),m=[],p=k.ruleStack}return{tokens:g,stateStack:p}}function z8(e){return e.map(t=>({scopeName:t}))}function H8(e,t){const n=[];for(let r=0,a=t.length;r<a;r++){const o=t[r];n[r]={scopeName:o,themeMatches:U8(e,o,t.slice(0,r))}}return n}function aC(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function F8(e,t,n){if(!aC(e.at(-1),t))return!1;let r=e.length-2,a=n.length-1;for(;r>=0&&a>=0;)aC(e[r],n[a])&&(r-=1),a-=1;return r===-1}function U8(e,t,n){const r=[];for(const{selectors:a,settings:o}of e)for(const c of a)if(F8(c,t,n)){r.push(o);break}return r}function F2(e,t,n,r=H2){const a=Object.entries(n.themes).filter(h=>h[1]).map(h=>({color:h[0],theme:h[1]})),o=a.map(h=>{const p=r(e,t,{...n,theme:h.theme});return{tokens:p,state:uu(p),theme:typeof h.theme=="string"?h.theme:h.theme.name}}),c=V8(...o.map(h=>h.tokens)),u=c[0].map((h,p)=>h.map((m,g)=>{const x={content:m.content,variants:{},offset:m.offset};return"includeExplanation"in n&&n.includeExplanation&&(x.explanation=m.explanation),c.forEach((w,C)=>{const{content:v,explanation:S,offset:_,...b}=w[p][g];x.variants[a[C].color]=b}),x})),d=o[0].state?new Gf(Object.fromEntries(o.map(h=>{var p;return[h.theme,(p=h.state)==null?void 0:p.getInternalStack(h.theme)]})),o[0].state.lang):void 0;return d&&Vf(u,d),u}function V8(...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 p=u[h];p.content.length===d?(o[h].push(p),c[h]+=1,u[h]=a[h][c[h]]):(o[h].push({...p,content:p.content.slice(0,d)}),u[h]={...p,content:p.content.slice(d),offset:p.offset+d})}}}return t}const G8=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Su{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Su.prototype.normal={};Su.prototype.property={};Su.prototype.space=void 0;function U2(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Su(n,r,t)}function ly(e){return e.toLowerCase()}class vr{constructor(t,n){this.attribute=n,this.property=t}}vr.prototype.attribute="";vr.prototype.booleanish=!1;vr.prototype.boolean=!1;vr.prototype.commaOrSpaceSeparated=!1;vr.prototype.commaSeparated=!1;vr.prototype.defined=!1;vr.prototype.mustUseProperty=!1;vr.prototype.number=!1;vr.prototype.overloadedBoolean=!1;vr.prototype.property="";vr.prototype.spaceSeparated=!1;vr.prototype.space=void 0;let W8=0;const gt=to(),Ln=to(),cy=to(),Ye=to(),Zt=to(),Ka=to(),Tr=to();function to(){return 2**++W8}const uy=Object.freeze(Object.defineProperty({__proto__:null,boolean:gt,booleanish:Ln,commaOrSpaceSeparated:Tr,commaSeparated:Ka,number:Ye,overloadedBoolean:cy,spaceSeparated:Zt},Symbol.toStringTag,{value:"Module"})),Qg=Object.keys(uy);class Db extends vr{constructor(t,n,r,a){let o=-1;if(super(t,n),oC(this,"space",a),typeof r=="number")for(;++o<Qg.length;){const c=Qg[o];oC(this,Qg[o],(r&uy[c])===uy[c])}}}Db.prototype.defined=!0;function oC(e,t,n){n&&(e[t]=n)}function jl(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[ly(r)]=r,n[ly(o.attribute)]=r}return new Su(t,n,e.space)}const V2=jl({properties:{ariaActiveDescendant:null,ariaAtomic:Ln,ariaAutoComplete:null,ariaBusy:Ln,ariaChecked:Ln,ariaColCount:Ye,ariaColIndex:Ye,ariaColSpan:Ye,ariaControls:Zt,ariaCurrent:null,ariaDescribedBy:Zt,ariaDetails:null,ariaDisabled:Ln,ariaDropEffect:Zt,ariaErrorMessage:null,ariaExpanded:Ln,ariaFlowTo:Zt,ariaGrabbed:Ln,ariaHasPopup:null,ariaHidden:Ln,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Zt,ariaLevel:Ye,ariaLive:null,ariaModal:Ln,ariaMultiLine:Ln,ariaMultiSelectable:Ln,ariaOrientation:null,ariaOwns:Zt,ariaPlaceholder:null,ariaPosInSet:Ye,ariaPressed:Ln,ariaReadOnly:Ln,ariaRelevant:null,ariaRequired:Ln,ariaRoleDescription:Zt,ariaRowCount:Ye,ariaRowIndex:Ye,ariaRowSpan:Ye,ariaSelected:Ln,ariaSetSize:Ye,ariaSort:null,ariaValueMax:Ye,ariaValueMin:Ye,ariaValueNow:Ye,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function G2(e,t){return t in e?e[t]:t}function W2(e,t){return G2(e,t.toLowerCase())}const q8=jl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ka,acceptCharset:Zt,accessKey:Zt,action:null,allow:null,allowFullScreen:gt,allowPaymentRequest:gt,allowUserMedia:gt,alpha:gt,alt:null,as:null,async:gt,autoCapitalize:null,autoComplete:Zt,autoFocus:gt,autoPlay:gt,blocking:Zt,capture:null,charSet:null,checked:gt,cite:null,className:Zt,closedBy:null,colorSpace:null,cols:Ye,colSpan:Ye,command:null,commandFor:null,content:null,contentEditable:Ln,controls:gt,controlsList:Zt,coords:Ye|Ka,crossOrigin:null,data:null,dateTime:null,decoding:null,default:gt,defer:gt,dir:null,dirName:null,disabled:gt,download:cy,draggable:Ln,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:gt,formTarget:null,headers:Zt,height:Ye,hidden:cy,high:Ye,href:null,hrefLang:null,htmlFor:Zt,httpEquiv:Zt,id:null,imageSizes:null,imageSrcSet:null,inert:gt,inputMode:null,integrity:null,is:null,isMap:gt,itemId:null,itemProp:Zt,itemRef:Zt,itemScope:gt,itemType:Zt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:gt,low:Ye,manifest:null,max:null,maxLength:Ye,media:null,method:null,min:null,minLength:Ye,multiple:gt,muted:gt,name:null,nonce:null,noModule:gt,noValidate:gt,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:gt,optimum:Ye,pattern:null,ping:Zt,placeholder:null,playsInline:gt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:gt,referrerPolicy:null,rel:Zt,required:gt,reversed:gt,rows:Ye,rowSpan:Ye,sandbox:Zt,scope:null,scoped:gt,seamless:gt,selected:gt,shadowRootClonable:gt,shadowRootCustomElementRegistry:gt,shadowRootDelegatesFocus:gt,shadowRootMode:null,shadowRootSerializable:gt,shape:null,size:Ye,sizes:null,slot:null,span:Ye,spellCheck:Ln,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ye,step:null,style:null,tabIndex:Ye,target:null,title:null,translate:null,type:null,typeMustMatch:gt,useMap:null,value:Ln,width:Ye,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Zt,axis:null,background:null,bgColor:null,border:Ye,borderColor:null,bottomMargin:Ye,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:gt,declare:gt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ye,leftMargin:Ye,link:null,longDesc:null,lowSrc:null,marginHeight:Ye,marginWidth:Ye,noResize:gt,noHref:gt,noShade:gt,noWrap:gt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ye,rules:null,scheme:null,scrolling:Ln,standby:null,summary:null,text:null,topMargin:Ye,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ye,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:gt,disablePictureInPicture:gt,disableRemotePlayback:gt,exportParts:Ka,part:Zt,prefix:null,property:null,results:Ye,security:null,unselectable:null},space:"html",transform:W2}),K8=jl({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:Tr,accentHeight:Ye,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ye,amplitude:Ye,arabicForm:null,ascent:Ye,attributeName:null,attributeType:null,azimuth:Ye,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ye,by:null,calcMode:null,capHeight:Ye,className:Zt,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:Ye,diffuseConstant:Ye,direction:null,display:null,dur:null,divisor:Ye,dominantBaseline:null,download:gt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ye,enableBackground:null,end:null,event:null,exponent:Ye,externalResourcesRequired:null,fill:null,fillOpacity:Ye,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:Ka,g2:Ka,glyphName:Ka,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ye,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ye,horizOriginX:Ye,horizOriginY:Ye,id:null,ideographic:Ye,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ye,k:Ye,k1:Ye,k2:Ye,k3:Ye,k4:Ye,kernelMatrix:Tr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ye,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:Ye,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:Ye,overlineThickness:Ye,paintOrder:null,panose1:null,path:null,pathLength:Ye,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Zt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ye,pointsAtY:Ye,pointsAtZ:Ye,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Tr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Tr,rev:Tr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Tr,requiredFeatures:Tr,requiredFonts:Tr,requiredFormats:Tr,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:Ye,specularExponent:Ye,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ye,strikethroughThickness:Ye,string:null,stroke:null,strokeDashArray:Tr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ye,strokeOpacity:Ye,strokeWidth:null,style:null,surfaceScale:Ye,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Tr,tabIndex:Ye,tableValues:null,target:null,targetX:Ye,targetY:Ye,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Tr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ye,underlineThickness:Ye,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ye,values:null,vAlphabetic:Ye,vMathematical:Ye,vectorEffect:null,vHanging:Ye,vIdeographic:Ye,version:null,vertAdvY:Ye,vertOriginX:Ye,vertOriginY:Ye,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ye,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:G2}),q2=jl({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()}}),K2=jl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:W2}),Y2=jl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Y8=/[A-Z]/g,lC=/-[a-z]/g,X8=/^data[-\w.:]+$/i;function J8(e,t){const n=ly(t);let r=t,a=vr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&X8.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(lC,Z8);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!lC.test(o)){let c=o.replace(Y8,Q8);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Db}return new a(r,t)}function Q8(e){return"-"+e.toLowerCase()}function Z8(e){return e.charAt(1).toUpperCase()}const e$=U2([V2,q8,q2,K2,Y2],"html"),X2=U2([V2,K8,q2,K2,Y2],"svg"),cC={}.hasOwnProperty;function t$(e,t){const n=t||{};function r(a,...o){let c=r.invalid;const u=r.handlers;if(a&&cC.call(a,e)){const d=String(a[e]);c=cC.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 n$=/["&'<>`]/g,r$=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,s$=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,i$=/[|\\{}()[\]^$+*?.]/g,uC=new WeakMap;function a$(e,t){if(e=e.replace(t.subset?o$(t.subset):n$,r),t.subset||t.escapeOnly)return e;return e.replace(r$,n).replace(s$,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 o$(e){let t=uC.get(e);return t||(t=l$(e),uC.set(e,t)),t}function l$(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(i$,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const c$=/[\dA-Fa-f]/;function u$(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!c$.test(String.fromCharCode(t))?r:r+";"}const d$=/\d/;function h$(e,t,n){const r="&#"+String(e);return n&&t&&!d$.test(String.fromCharCode(t))?r:r+";"}const f$=["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"],Zg={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:"€"},m$=["cent","copy","divide","gt","lt","not","para","times"],J2={}.hasOwnProperty,dy={};let Jd;for(Jd in Zg)J2.call(Zg,Jd)&&(dy[Zg[Jd]]=Jd);const p$=/[^\dA-Za-z]/;function g$(e,t,n,r){const a=String.fromCharCode(e);if(J2.call(dy,a)){const o=dy[a],c="&"+o;return n&&f$.includes(o)&&!m$.includes(o)&&(!r||t&&t!==61&&p$.test(String.fromCharCode(t)))?c:c+";"}return""}function x$(e,t,n){let r=u$(e,t,n.omitOptionalSemicolons),a;if((n.useNamedReferences||n.useShortestReferences)&&(a=g$(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!a)&&n.useShortestReferences){const o=h$(e,t,n.omitOptionalSemicolons);o.length<r.length&&(r=o)}return a&&(!n.useShortestReferences||a.length<r.length)?a:r}function cl(e,t){return a$(e,Object.assign({format:x$},t))}const y$=/^>|^->|<!--|-->|--!>|<!-$/g,b$=[">"],v$=["<",">"];function _$(e,t,n,r){return r.settings.bogusComments?"<?"+cl(e.value,Object.assign({},r.settings.characterReferences,{subset:b$}))+">":"<!--"+e.value.replace(y$,a)+"-->";function a(o){return cl(o,Object.assign({},r.settings.characterReferences,{subset:v$}))}}function S$(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function dC(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 w$(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function C$(e){return e.join(" ").trim()}const k$=/[ \t\n\f\r]/g;function Rb(e){return typeof e=="object"?e.type==="text"?hC(e.value):!1:hC(e)}function hC(e){return e.replace(k$,"")===""}const Bn=Z2(1),Q2=Z2(-1),j$=[];function Z2(e){return t;function t(n,r,a){const o=n?n.children:j$;let c=(r||0)+e,u=o[c];if(!a)for(;u&&Rb(u);)c+=e,u=o[c];return u}}const E$={}.hasOwnProperty;function eN(e){return t;function t(n,r,a){return E$.call(e,n.tagName)&&e[n.tagName](n,r,a)}}const Ob=eN({body:T$,caption:ex,colgroup:ex,dd:R$,dt:D$,head:ex,html:N$,li:L$,optgroup:O$,option:I$,p:A$,rp:fC,rt:fC,tbody:P$,td:mC,tfoot:B$,th:mC,thead:M$,tr:$$});function ex(e,t,n){const r=Bn(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&Rb(r.value.charAt(0)))}function N$(e,t,n){const r=Bn(n,t);return!r||r.type!=="comment"}function T$(e,t,n){const r=Bn(n,t);return!r||r.type!=="comment"}function A$(e,t,n){const r=Bn(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 L$(e,t,n){const r=Bn(n,t);return!r||r.type==="element"&&r.tagName==="li"}function D$(e,t,n){const r=Bn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function R$(e,t,n){const r=Bn(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function fC(e,t,n){const r=Bn(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function O$(e,t,n){const r=Bn(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function I$(e,t,n){const r=Bn(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function M$(e,t,n){const r=Bn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function P$(e,t,n){const r=Bn(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function B$(e,t,n){return!Bn(n,t)}function $$(e,t,n){const r=Bn(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function mC(e,t,n){const r=Bn(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const z$=eN({body:U$,colgroup:V$,head:F$,html:H$,tbody:G$});function H$(e){const t=Bn(e,-1);return!t||t.type!=="comment"}function F$(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 U$(e){const t=Bn(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Rb(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function V$(e,t,n){const r=Q2(n,t),a=Bn(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Ob(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="col")}function G$(e,t,n){const r=Q2(n,t),a=Bn(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Ob(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="tr")}const Qd={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 W$(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=X2);const h=q$(r,e.properties),p=r.all(a.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=a,p&&(c=!1),(h||!o||!z$(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(p),!c&&(!o||!Ob(e,t,n))&&u.push("</"+e.tagName+">"),u.join("")}function q$(e,t){const n=[];let r=-1,a;if(t){for(a in t)if(t[a]!==null&&t[a]!==void 0){const o=K$(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 K$(e,t,n){const r=J8(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=cl(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Qd.name[a][o]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?w$:C$)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?d:(e.settings.preferUnquoted&&(u=cl(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Qd.unquoted[a][o]}))),u!==n&&(e.settings.quoteSmart&&dC(n,c)>dC(n,e.alternative)&&(c=e.alternative),u=c+cl(n,Object.assign({},e.settings.characterReferences,{subset:(c==="'"?Qd.single:Qd.double)[a][o],attribute:!0}))+c),d+(u&&"="+u))}const Y$=["<","&"];function tN(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:cl(e.value,Object.assign({},r.settings.characterReferences,{subset:Y$}))}function X$(e,t,n,r){return r.settings.allowDangerousHtml?e.value:tN(e,t,n,r)}function J$(e,t,n,r){return r.all(e)}const Q$=t$("type",{invalid:Z$,unknown:ez,handlers:{comment:_$,doctype:S$,element:W$,raw:X$,root:J$,text:tN}});function Z$(e){throw new Error("Expected node, not `"+e+"`")}function ez(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const tz={},nz={},rz=[];function sz(e,t){const n=t||tz,r=n.quote||'"',a=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:iz,all:az,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||G8,characterReferences:n.characterReferences||nz,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?X2:e$,quote:r,alternative:a}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function iz(e,t,n){return Q$(e,t,n,this)}function az(e){const t=[],n=e&&e.children||rz;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}const pC=/\s+/g;function nN(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(pC)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(pC);for(const a of n)a&&!e.properties.class.includes(a)&&e.properties.class.push(a);return e}const oz=/:?lang=["']([^"']+)["']/g,lz=/(?:```|~~~)([\w-]+)/g,cz=/\\begin\{([\w-]+)\}/g,uz=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function dz(e){const t=Uf(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 hz(e,t,n){const r=new Set;for(const o of e.matchAll(oz)){const c=o[1].toLowerCase().trim();c&&r.add(c)}for(const o of e.matchAll(lz)){const c=o[1].toLowerCase().trim();c&&r.add(c)}for(const o of e.matchAll(cz)){const c=o[1].toLowerCase().trim();c&&r.add(c)}for(const o of e.matchAll(uz)){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 fz=["color","background-color"];function mz(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 pz(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?mz(a,o):a})):e}function gz(e,t,n,r,a="css-vars"){const o={content:e.content,explanation:e.explanation,offset:e.offset},c=t.map(p=>qh(e.variants[p])),u=new Set(c.flatMap(p=>Object.keys(p))),d={},h=(p,m)=>{const g=m==="color"?"":m==="background-color"?"-bg":`-${m}`;return n+t[p]+(m==="color"?"":g)};return c.forEach((p,m)=>{for(const g of u){const x=p[g]||"inherit";if(m===0&&r&&fz.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 nn('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(m,g)]=x)}else d[g]=x;else a==="css-vars"&&(d[h(m,g)]=x)}}),o.htmlStyle=d,o}function qh(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&er.Italic&&(t["font-style"]="italic"),e.fontStyle&er.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&er.Underline&&n.push("underline"),e.fontStyle&er.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function hy(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function xz(){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 nn(`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 nn(`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 nn(`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=dz(n.source),c=(n.options.decorations||[]).map(u=>({...u,start:o(u.start),end:o(u.end)}));yz(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 pz(n,t(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]))},code(n){var p;if(!((p=this.options.decorations)!=null&&p.length))return;const r=t(this),a=[...n.children].filter(m=>m.type==="element"&&m.tagName==="span");if(a.length!==r.converter.lines.length)throw new nn(`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(m,g,x,w){const C=a[m];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+=rN(C.children[k]),S===-1&&v.length===g&&(S=k+1),_===-1&&v.length===x&&(_=k+1);if(S===-1)throw new nn(`Failed to find start index for decoration ${JSON.stringify(w.start)}`);if(_===-1)throw new nn(`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(m,g){a[m]=u(a[m],g,"line")}function u(m,g,x){var v;const w=g.properties||{},C=g.transform||(S=>S);return m.tagName=g.tagName||"span",m.properties={...m.properties,...w,class:m.properties.class},(v=g.properties)!=null&&v.class&&nN(m,g.properties.class),m=C(m,x)||m,m}const d=[],h=r.decorations.sort((m,g)=>g.start.offset-m.start.offset||m.end.offset-g.end.offset);for(const m of h){const{start:g,end:x}=m;if(g.line===x.line)o(g.line,g.character,x.character,m);else if(g.line<x.line){o(g.line,g.character,Number.POSITIVE_INFINITY,m);for(let w=g.line+1;w<x.line;w++)d.unshift(()=>c(w,m));o(x.line,0,x.character,m)}}d.forEach(m=>m())}}}function yz(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new nn(`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 nn(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(a.start)} intersect.`)}}}}function rN(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(rN).join(""):""}const bz=[xz()];function Kh(e){const t=vz(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...bz]}function vz(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 Pa=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],tx={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function _z(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 gC(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 Sz(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)tx[r]&&t.push({type:"setDecoration",value:tx[r]});else if(r<=29){const a=tx[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:Pa[r-30]}});else if(r===38){const a=gC(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:Pa[r-40]}});else if(r===48){const a=gC(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:Pa[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Pa[r-100+8]}})}return t}function wz(){let e=null,t=null,n=new Set;return{parse(r){const a=[];let o=0;do{const c=_z(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=Sz(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 Cz={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 kz(e=Cz){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<Pa.length;h++)r.push(t(Pa[h]));let u=[0,95,135,175,215,255];for(let h=0;h<6;h++)for(let p=0;p<6;p++)for(let m=0;m<6;m++)r.push(n([u[h],u[p],u[m]]));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 jz=/#([0-9a-f]{3,8})/i,Ez=/var\((--[\w-]+-ansi-[\w-]+)\)/,Nz={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 Tz(e,t,n){const r=Wh(e,n),a=Uf(t),o=kz(Object.fromEntries(Pa.map(u=>{var h;const d=`terminal.ansi${u[0].toUpperCase()}${u.substring(1)}`;return[u,((h=e.colors)==null?void 0:h[d])||Nz[u]]}))),c=wz();return a.map(u=>c.parse(u[0]).map(d=>{let h,p;d.decorations.has("reverse")?(h=d.background?o.value(d.background):e.bg,p=d.foreground?o.value(d.foreground):e.fg):(h=d.foreground?o.value(d.foreground):e.fg,p=d.background?o.value(d.background):void 0),h=Ji(h,r),p=Ji(p,r),d.decorations.has("dim")&&(h=Az(h));let m=er.None;return d.decorations.has("bold")&&(m|=er.Bold),d.decorations.has("italic")&&(m|=er.Italic),d.decorations.has("underline")&&(m|=er.Underline),d.decorations.has("strikethrough")&&(m|=er.Strikethrough),{content:d.value,offset:u[1],color:h,bgColor:p,fontStyle:m}}))}function Az(e){const t=e.match(jz);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(Ez);return n?`var(${n[1]}-dim)`:e}function fy(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:a=e.getLoadedThemes()[0]}=n;if(!Hf(r)&&!Ff(a)&&r==="ansi"){const{theme:o}=e.setTheme(a);return Tz(o,t,n)}return H2(e,t,n)}function Yh(e,t,n){let r,a,o,c,u,d;if("themes"in n){const{defaultColor:h="light",cssVariablePrefix:p="--shiki-",colorsRendering:m="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 nn("`themes` option must not be empty");const x=F2(e,t,n,fy);if(d=uu(x),h&&h!=="light-dark()"&&!g.some(S=>S.color===h))throw new nn(`\`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(_=>gz(_,C,p,h,m))),d&&Vf(o,d);const v=g.map(S=>Wh(S.theme,n));a=xC(g,w,v,p,h,"fg",m),r=xC(g,w,v,p,h,"bg",m),c=`shiki-themes ${w.map(S=>S.name).join(" ")}`,u=h?void 0:[a,r].join(";")}else if("theme"in n){const h=Wh(n.theme,n);o=fy(e,t,n);const p=e.getTheme(n.theme);r=Ji(p.bg,h),a=Ji(p.fg,h),c=p.name,d=uu(o)}else throw new nn("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:a,bg:r,themeName:c,rootStyle:u,grammarState:d}}function xC(e,t,n,r,a,o,c){return e.map((u,d)=>{const h=Ji(t[d][o],n[d])||"inherit",p=`${r+u.color}${o==="bg"?"-bg":""}:${h}`;if(d===0&&a){if(a==="light-dark()"&&e.length>1){const m=e.findIndex(x=>x.color==="light"),g=e.findIndex(x=>x.color==="dark");if(m===-1||g===-1)throw new nn('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Ji(t[m][o],n[m])||"inherit"}, ${Ji(t[g][o],n[g])||"inherit"});${p}`}return h}return c==="css-vars"?p:null}).filter(u=>!!u).join(";")}const sN=/^\s+$/,Lz=/^(\s*)(.*?)(\s*)$/;function Xh(e,t,n,r={meta:{},options:n,codeToHast:(a,o)=>Xh(e,a,o),codeToTokens:(a,o)=>Yh(e,a,o)}){var w,C;let a=t;for(const v of Kh(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:p}=Yh(e,a,n);const{mergeWhitespaces:m=!0,mergeSameStyleTokens:g=!1}=n;m===!0?o=Rz(o):m==="never"&&(o=Oz(o)),g&&(o=Iz(o));const x={...r,get source(){return a}};for(const v of Kh(n))o=((C=v.tokens)==null?void 0:C.call(x,o))||o;return Dz(o,{...n,fg:c,bg:u,themeName:d,rootStyle:n.rootStyle===!1?!1:n.rootStyle??h},x,p)}function Dz(e,t,n,r=uu(e)){var C,v,S,_;const a=Kh(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 p={type:"element",tagName:"pre",properties:h,children:[],data:t.data},m={type:"element",tagName:"code",properties:{},children:o};const g=[],x={...n,structure:u,addClassToHast:nN,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return c},get pre(){return p},get code(){return m},get lines(){return g}};if(e.forEach((b,k)=>{var D,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 R of b){let M={type:"element",tagName:"span",properties:{...R.htmlAttrs},children:[{type:"text",value:R.content}]};const W=hy(R.htmlStyle||qh(R));W&&(M.properties.style=W);for(const $ of a)M=((D=$==null?void 0:$.span)==null?void 0:D.call(x,M,k+1,T,E,R))||M;u==="inline"?c.children.push(M):u==="classic"&&E.children.push(M),T+=R.content.length}if(u==="classic"){for(const R of a)E=((A=R==null?void 0:R.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)m=((C=b==null?void 0:b.code)==null?void 0:C.call(x,m))||m;p.children.push(m);for(const b of a)p=((v=b==null?void 0:b.pre)==null?void 0:v.call(x,p))||p;c.children.push(p)}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 D=E.children[T];D.type==="element"&&c.children.push(...D.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&&Vf(w,r),w}function Rz(e){return e.map(t=>{const n=[];let r="",a;return t.forEach((o,c)=>{const u=!(o.fontStyle&&(o.fontStyle&er.Underline||o.fontStyle&er.Strikethrough));u&&sN.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 Oz(e){return e.map(t=>t.flatMap(n=>{if(sN.test(n.content))return n;const r=n.content.match(Lz);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 Iz(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=hy(a.htmlStyle||qh(a)),c=hy(r.htmlStyle||qh(r)),u=a.fontStyle&&(a.fontStyle&er.Underline||a.fontStyle&er.Strikethrough),d=r.fontStyle&&(r.fontStyle&er.Underline||r.fontStyle&er.Strikethrough);!u&&!d&&o===c?a.content+=r.content:n.push({...r})}return n})}const Mz=sz;function Pz(e,t,n){var o;const r={meta:{},options:n,codeToHast:(c,u)=>Xh(e,c,u),codeToTokens:(c,u)=>Yh(e,c,u)};let a=Mz(Xh(e,t,n,r));for(const c of Kh(n))a=((o=c.postprocess)==null?void 0:o.call(r,a,n))||a;return a}async function Bz(e){const t=await R8(e);return{getLastGrammarState:(...n)=>B8(t,...n),codeToTokensBase:(n,r)=>fy(t,n,r),codeToTokensWithThemes:(n,r)=>F2(t,n,r),codeToTokens:(n,r)=>Yh(t,n,r),codeToHast:(n,r)=>Xh(t,n,r),codeToHtml:(n,r)=>Pz(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function $z(e){const t=e.langs,n=e.themes,r=e.engine;async function a(o){function c(m){var g;if(typeof m=="string"){if(m=((g=o.langAlias)==null?void 0:g[m])||m,O2(m))return[];const x=t[m];if(!x)throw new nn(`Language \`${m}\` is not included in this bundle. You may want to load it from external source.`);return x}return m}function u(m){if(I2(m))return"none";if(typeof m=="string"){const g=n[m];if(!g)throw new nn(`Theme \`${m}\` is not included in this bundle. You may want to load it from external source.`);return g}return m}const d=(o.themes??[]).map(m=>u(m)),h=(o.langs??[]).map(m=>c(m)),p=await Bz({engine:o.engine??r(),...o,themes:d,langs:h});return{...p,loadLanguage(...m){return p.loadLanguage(...m.map(c))},loadTheme(...m){return p.loadTheme(...m.map(u))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return a}function zz(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 Hz(e,t){const n=zz(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 Fz=Sb({bundledLanguages:()=>Bf,bundledLanguagesAlias:()=>Cb,bundledLanguagesBase:()=>wb,bundledLanguagesInfo:()=>Pf,bundledThemes:()=>jb,bundledThemesInfo:()=>kb,codeToHast:()=>aN,codeToHtml:()=>iN,codeToTokens:()=>oN,codeToTokensBase:()=>lN,codeToTokensWithThemes:()=>cN,createHighlighter:()=>Wf,getLastGrammarState:()=>dN,getSingletonHighlighter:()=>uN});const Wf=$z({langs:Bf,themes:jb,engine:()=>(0,x2.createOnigurumaEngine)(ne(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:iN,codeToHast:aN,codeToTokens:oN,codeToTokensBase:lN,codeToTokensWithThemes:cN,getSingletonHighlighter:uN,getLastGrammarState:dN}=Hz(Wf,{guessEmbeddedLanguages:hz}),yC=4294967295;var Uz=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:yC,end:yC,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 El(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function Vz(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const Ib=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),Un=String.raw;function Nl(e,t){if(e==null)throw new Error(t??"Value expected");return e}const hN=Un`\[\^?`,fN=`c.? | C(?:-.?)?|${Un`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${Un`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${Un`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${Un`o\{[^\}]*\}?`}|${Un`\d{1,3}`}`,Mb=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Zd=new RegExp(Un`
|
|
107
|
+
\\ (?:
|
|
108
|
+
${fN}
|
|
109
|
+
| [gk]<[^>]*>?
|
|
110
|
+
| [gk]'[^']*'?
|
|
111
|
+
| .
|
|
112
|
+
)
|
|
113
|
+
| \( (?:
|
|
114
|
+
\? (?:
|
|
115
|
+
[:=!>({]
|
|
116
|
+
| <[=!]
|
|
117
|
+
| <[^>]*>
|
|
118
|
+
| '[^']*'
|
|
119
|
+
| ~\|?
|
|
120
|
+
| #(?:[^)\\]|\\.?)*
|
|
121
|
+
| [^:)]*[:)]
|
|
122
|
+
)?
|
|
123
|
+
| \*[^\)]*\)?
|
|
124
|
+
)?
|
|
125
|
+
| (?:${Mb.source})+
|
|
126
|
+
| ${hN}
|
|
127
|
+
| .
|
|
128
|
+
`.replace(/\s+/g,""),"gsu"),nx=new RegExp(Un`
|
|
129
|
+
\\ (?:
|
|
130
|
+
${fN}
|
|
131
|
+
| .
|
|
132
|
+
)
|
|
133
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
134
|
+
| ${hN}
|
|
135
|
+
| &&
|
|
136
|
+
| .
|
|
137
|
+
`.replace(/\s+/g,""),"gsu");function Gz(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=uH(n.flags),a=[r.extended],o={captureGroup:n.rules.captureGroup,getCurrentModX(){return a.at(-1)},numOpenGroups:0,popModX(){a.pop()},pushModX(m){a.push(m)},replaceCurrentModX(m){a[a.length-1]=m},singleline:n.rules.singleline};let c=[],u;for(Zd.lastIndex=0;u=Zd.exec(e);){const m=Wz(o,e,u[0],Zd.lastIndex);m.tokens?c.push(...m.tokens):m.token&&c.push(m.token),m.lastIndex!==void 0&&(Zd.lastIndex=m.lastIndex)}const d=[];let h=0;c.filter(m=>m.type==="GroupOpen").forEach(m=>{m.kind==="capturing"?m.number=++h:m.raw==="("&&d.push(m)}),h||d.forEach((m,g)=>{m.kind="capturing",m.number=g+1});const p=h||d.length;return{tokens:c.map(m=>m.type==="EscapedNumber"?hH(m,p):m).flat(),flags:r}}function Wz(e,t,n,r){const[a,o]=n;if(n==="["||n==="[^"){const c=qz(t,n,r);return{tokens:c.tokens,lastIndex:c.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(o))return{token:bC(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:rH(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:pN(n)}}if(o==="K")return{token:gN("keep",n)};if(o==="N"||o==="R")return{token:Ba("newline",n,{negate:o==="N"})};if(o==="O")return{token:Ba("any",n)};if(o==="X")return{token:Ba("text_segment",n)};const c=mN(n,{inCharClass:!1});return Array.isArray(c)?{tokens:c}:{token:c}}if(a==="("){if(o==="*")return{token:oH(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:aH(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Qo("group",n)};if(n==="(?>")return{token:Qo("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Qo(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Qo("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Qo("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:eH(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:Ba("dot",n)};if(n==="^"||n==="$"){const c=e.singleline?{"^":Un`\A`,$:Un`\Z`}[n]:n;return{token:bC(c,n)}}return n==="|"?{token:Yz(n)}:Mb.test(n)?{tokens:fH(n)}:{token:ci(El(n),n)}}function qz(e,t,n){const r=[vC(t[1]==="^",t)];let a=1,o;for(nx.lastIndex=n;o=nx.exec(e);){const c=o[0];if(c[0]==="["&&c[1]!==":")a++,r.push(vC(c[1]==="^",c));else if(c==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(ci(93,c));else if(a--,r.push(Xz(c)),!a)break}else{const u=Kz(c);Array.isArray(u)?r.push(...u):r.push(u)}}return{tokens:r,lastIndex:nx.lastIndex||e.length}}function Kz(e){if(e[0]==="\\")return mN(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Ib.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Ba("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?Jz(e):e==="&&"?Qz(e):ci(El(e),e)}function mN(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return iH(e);if("dDhHsSwW".includes(n))return lH(e);if(e.startsWith(Un`\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 cH(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 ci(El(c),u)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return ci(dH(e),e);if(_C.has(n))return ci(_C.get(n),e);if(/\d/.test(n))return Zz(t,e);if(e==="\\")throw new Error(Un`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return ci(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Yz(e){return{type:"Alternator",raw:e}}function bC(e,t){return{type:"Assertion",kind:e,raw:t}}function pN(e){return{type:"Backreference",raw:e}}function ci(e,t){return{type:"Character",value:e,raw:t}}function Xz(e){return{type:"CharacterClassClose",raw:e}}function Jz(e){return{type:"CharacterClassHyphen",raw:e}}function Qz(e){return{type:"CharacterClassIntersector",raw:e}}function vC(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Ba(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function gN(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Nl(n.flags),raw:t}}function Zz(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function eH(e){return{type:"GroupClose",raw:e}}function Qo(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function tH(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function nH(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function rH(e){return{type:"Subroutine",raw:e}}const sH=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),_C=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function iH(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 ci(El(t.toUpperCase())-64,e)}function aH(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=wC(n),c=wC(r),u={};if(o&&(u.enable=o),c&&(u.disable=c),e.endsWith(")"))return t.replaceCurrentModX(a),gN("flags",e,{flags:u});if(e.endsWith(":"))return t.pushModX(a),t.numOpenGroups++,Qo("group",e,{...(o||c)&&{flags:u}});throw new Error(`Unexpected flag modifier "${e}"`)}function oH(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(p=>p!=="").map(p=>/^[+-]?\d+$/.test(p)?+p:p):[],[c,u,d]=o,h=sH.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 tH(h,r??null,(a==null?void 0:a.split(","))??null,e)}function SC(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 nH(t,n,r,e)}function lH(e){const t=e[1].toLowerCase();return Ba({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function cH(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Ba("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function wC(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 uH(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 dH(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 hH(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[pN(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(Un`Octal encoded byte above 177 unsupported "${n}"`)}else h=El(d);o.push(ci(h,(u===0?"\\":"")+d))}return o}function fH(e){const t=[],n=new RegExp(Mb,"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(SC(a.slice(0,-1)));continue}}}t.push(SC(a))}return t}function xN(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 mH(e){return pH.has(e.type)}const pH=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function yN(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=Gz(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 Ja();case"Assertion":return gH(w);case"Backreference":return xH(w,o);case"Character":return qf(w.value,{useLastValid:!!x.isCheckingRangeEnd});case"CharacterClassHyphen":return yH(w,o,x);case"CharacterClassOpen":return bH(w,o,x);case"CharacterSet":return vH(w,o);case"Directive":return jH(w.kind,{flags:w.flags});case"GroupOpen":return _H(w,o,x);case"NamedCallout":return NH(w.kind,w.tag,w.arguments);case"Quantifier":return SH(w,o);case"Subroutine":return wH(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=AH(EH(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:p,subroutines:m}=o;if(h&&p.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:g}of m)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(p.has(g)){if(p.get(g).length>1)throw new Error(Un`Subroutine uses a duplicate group name "\g<${g}>"`);p.get(g)[0].isSubroutined=!0}else throw new Error(Un`Subroutine uses a group name that's not defined "\g<${g}>"`);return c}function gH({kind:e}){return my(Nl({"^":"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===Un`\B`||e===Un`\Y`})}function xH({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,py(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 py(r)}return a(+r)}function yH(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(),kH(c,d);throw new Error("Invalid character class range")}return qf(El("-"))}function bH({negate:e},t,n){const{tokens:r,walk:a}=t,o=[jh()],c=r[t.nextIndex];let u=jC(c);for(;u.type!=="CharacterClassClose";){if(u.type==="CharacterClassIntersector")o.push(jh()),t.nextIndex++;else{const h=o.at(-1);h.body.push(a(h,n))}u=jC(r[t.nextIndex],c)}const d=jh({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 vH({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:o,unicodePropertyMap:c}=r;if(e==="property"){const u=Kf(n);if(Ib.has(u)&&!(c!=null&&c.has(u)))e="posix",n=u;else return Zo(n,{negate:t,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:o,unicodePropertyMap:c})}return e==="posix"?TH(n,{negate:t}):gy(e,{negate:t})}function _H(e,t,n){const{tokens:r,capturingGroups:a,namedGroupsByName:o,skipLookbehindValidation:c,walk:u}=t,d=LH(e),h=d.type==="AbsenceFunction",p=kC(d),m=p&&d.negate;if(d.type==="CapturingGroup"&&(a.push(d),d.name&&Vz(o,d.name,[]).push(d)),h&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let g=EC(r[t.nextIndex]);for(;g.type!=="GroupClose";){if(g.type==="Alternator")d.body.push(Ja()),t.nextIndex++;else{const x=d.body.at(-1),w=u(x,{...n,isInAbsenceFunction:n.isInAbsenceFunction||h,isInLookbehind:n.isInLookbehind||p,isInNegLookbehind:n.isInNegLookbehind||m});if(x.body.push(w),(p||n.isInLookbehind)&&!c){const C="Lookbehind includes a pattern not allowed by Oniguruma";if(m||n.isInNegLookbehind){if(CC(w)||w.type==="CapturingGroup")throw new Error(C)}else if(CC(w)||kC(w)&&w.negate)throw new Error(C)}}g=EC(r[t.nextIndex])}return t.nextIndex++,d}function SH({kind:e,min:t,max:n},r){const a=r.parent,o=a.body.at(-1);if(!o||!mH(o))throw new Error("Quantifier requires a repeatable token");const c=vN(e,t,n,o);return a.body.pop(),c}function wH({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=_N(a);return r.push(c),c}function CH(e,t){return{type:"AbsenceFunction",kind:e,body:wu(t==null?void 0:t.body)}}function Ja(e){return{type:"Alternative",body:SN(e==null?void 0:e.body)}}function my(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function py(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function bN(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!DH(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:wu(t==null?void 0:t.body)}}function qf(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 jh(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:SN(e==null?void 0:e.body)}}function kH(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function gy(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 jH(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Nl(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function EH(e){return{type:"Flags",...e}}function ls(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:wu(e==null?void 0:e.body)}}function Ia(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:wu(e==null?void 0:e.body)}}function NH(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function TH(e,t){const n=!!(t!=null&&t.negate);if(!Ib.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function vN(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 AH(e,t){return{type:"Regex",body:wu(t==null?void 0:t.body),flags:e}}function _N(e){return{type:"Subroutine",ref:e}}function Zo(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(Kf(e));if(!r){if(n.normalizeUnknownPropertyNames)r=RH(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(Un`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function LH({flags:e,kind:t,name:n,negate:r,number:a}){switch(t){case"absence_repeater":return CH("repeater");case"atomic":return ls({atomic:!0});case"capturing":return bN(a,{name:n});case"group":return ls({flags:e});case"lookahead":case"lookbehind":return Ia({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function wu(e){if(e===void 0)e=[Ja()];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 SN(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 CC(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function kC(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function DH(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function RH(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 Kf(e){return e.replace(/[- _]+/g,"").toLowerCase()}function jC(e,t){const n=t;return Nl(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function EC(e){return Nl(e,"Unclosed group")}function Yc(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,p=!1;const m={node:o,parent:c,key:u,container:d,root:e,remove(){eh(d).splice(Math.max(0,Fo(u)+h),1),h--,p=!0},removeAllNextSiblings(){return eh(d).splice(Fo(u)+1)},removeAllPrevSiblings(){const b=Fo(u)+h;return h-=b,eh(d).splice(0,Math.max(0,b))},replaceWith(b,k={}){const E=!!k.traverse;d?d[Math.max(0,Fo(u)+h)]=b:Nl(c,"Can't replace root node")[u]=b,E&&a(b,c,u,d),p=!0},replaceWithMultiple(b,k={}){const E=!!k.traverse;if(eh(d).splice(Math.max(0,Fo(u)+h),1,...b),h+=b.length-1,E){let T=0;for(let D=0;D<b.length;D++)T+=a(b[D],c,Fo(u)+D+T,d)}p=!0},skip(){p=!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(m,n),v==null||v(m,n),!p)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,m,n),(_=x==null?void 0:x.exit)==null||_.call(x,m,n),h}return a(e),e}function eh(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Fo(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const OH=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function IH(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function MH(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const Jr=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Pb(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:p}}=d;if(!p&&(!r||r===Jr.DEFAULT==!c)){n instanceof Function?u+=n(d,{context:c?Jr.CHAR_CLASS:Jr.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 wN(e,t,n,r){Pb(e,t,n,r)}function PH(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===Jr.DEFAULT==!o))return c;u==="["?o++:u==="]"&&o&&o--,a.lastIndex==c.index&&a.lastIndex++}return null}function th(e,t,n){return!!PH(e,t,0,n)}function BH(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 NC=new RegExp(String.raw`(?<noncapturingStart>${OH})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function $H(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,p=NaN,m;do{m=!1;let g=0,x=0,w=!1,C;for(NC.lastIndex=Number.isNaN(p)?0:p+o.length;C=NC.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)p=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,p)}${o}${e.slice(p+a.length,S)}))<$$${k}>)${e.slice(S+1)}`,m=!0,u.push(k),IH(n,k),r.size){const E=new Map;r.forEach((T,D)=>{E.set(D>=k?D+1:D,T.map(A=>A>=k?A+1:A))}),r=E}break}x--}}}while(m);return n.push(...u),e=Pb(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}`},Jr.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const CN=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,rx=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>${CN})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
152
|
+
| \\?.
|
|
153
|
+
`.replace(/\s+/g,""),"gsu");function zH(e){if(!new RegExp(`${CN}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,a="",o=0,c;for(rx.lastIndex=0;c=rx.exec(e);){const{0:u,index:d,groups:{qBase:h,qMod:p,invalidQ:m}}=c;if(u==="[")o||(r=d),o++;else if(u==="]")o?o--:r=null;else if(!o)if(p==="+"&&a&&!a.startsWith("(")){if(m)throw new Error(`Invalid quantifier "${u}"`);let g=-1;if(/^\{\d+\}$/.test(h))e=MH(e,d+h.length,p,"");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}rx.lastIndex+=g}else u[0]==="("?t.push(d):u===")"&&(n=t.length?t.pop():null);a=u}return{pattern:e}}const Yr=String.raw,HH=Yr`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,xy=Yr`\(\?R=(?<rDepth>[^\)]+)\)|${HH}`,Yf=Yr`\(\?<(?![=!])(?<captureName>[^>]+)>`,kN=Yr`${Yf}|(?<unnamed>\()(?!\?)`,Ea=new RegExp(Yr`${Yf}|${xy}|\(\?|\\?.`,"gsu"),sx="Cannot use multiple overlapping recursions";function FH(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let a=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(xy,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if(r==="plugin"&&th(e,Yr`\(\?\(DEFINE\)`,Jr.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const o=[],c=th(e,Yr`\\[1-9]`,Jr.DEFAULT),u=new Map,d=[];let h=!1,p=0,m=0,g;for(Ea.lastIndex=0;g=Ea.exec(e);){const{0:x,groups:{captureName:w,rDepth:C,gRNameOrNum:v,gRDepth:S}}=g;if(x==="[")p++;else if(p)x==="]"&&p--;else if(C){if(TC(C),h)throw new Error(sx);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(Ea.lastIndex);if(th(b,xy,Jr.DEFAULT))throw new Error(sx);const k=+C-1;e=AC(_,b,k,!1,n,o,m),a=DC(a,_,k,o.length,0,m);break}else if(v){TC(S);let _=!1;for(const $ of d)if($.name===v||$.num===+v){if(_=!0,$.hasRecursedWithin)throw new Error(sx);break}if(!_)throw new Error(Yr`Recursive \g cannot be used outside the referenced group "${r==="external"?v:Yr`\g<${v}&R=${S}>`}"`);const b=u.get(v),k=BH(e,b);if(c&&th(k,Yr`${Yf}|\((?!\?)`,Jr.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),D=o.length,A=+S-1,R=AC(E,T,A,!0,n,o,m);a=DC(a,E,A,o.length-D,D,m);const M=e.slice(0,b),W=e.slice(b+k.length);e=`${M}${R}${W}`,Ea.lastIndex+=R.length-x.length-E.length-T.length,d.forEach($=>$.hasRecursedWithin=!0),h=!0}else if(w)m++,u.set(String(m),Ea.lastIndex),u.set(w,Ea.lastIndex),d.push({num:m,name:w});else if(x[0]==="("){const _=x==="(";_&&(m++,u.set(String(m),Ea.lastIndex)),d.push(_?{num:m}:{})}else x===")"&&d.pop()}return n.push(...o),{pattern:e,captureTransfers:a,hiddenCaptures:n}}function TC(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 AC(e,t,n,r,a,o,c){const u=new Set;r&&wN(e+t,Yf,({groups:{captureName:h}})=>{u.add(h)},Jr.DEFAULT);const d=[n,r?u:null,a,o,c];return`${e}${LC(`(?:${e}`,"forward",...d)}(?:)${LC(`${t})`,"backward",...d)}${t}`}function LC(e,t,n,r,a,o,c){const d=p=>t==="forward"?p+2:n-p+2-1;let h="";for(let p=0;p<n;p++){const m=d(p);h+=Pb(e,Yr`${kN}|\\k<(?<backref>[^>]+)>`,({0:g,groups:{captureName:x,unnamed:w,backref:C}})=>{if(C&&r&&!r.has(C))return g;const v=`_$${m}`;if(w||x){const S=c+o.length+1;return o.push(S),UH(a,S),w?g:`(?<${x}${v}>`}return Yr`\k<${C}${v}>`},Jr.DEFAULT)}return h}function UH(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function DC(e,t,n,r,a,o){if(e.size&&r){let c=0;wN(t,kN,()=>c++,Jr.DEFAULT);const u=o-c+a,d=new Map;return e.forEach((h,p)=>{const m=(r-c*n)/n,g=c*n,x=p>u+c?p+r:p,w=[];for(const C of h)if(C<=u)w.push(C);else if(C>u+c+m)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+m*v);d.set(x,w)}),d}return e}var Mn=String.fromCodePoint,yt=String.raw,fs={},Xf=globalThis.RegExp;fs.flagGroups=(()=>{try{new Xf("(?i:)")}catch{return!1}return!0})();fs.unicodeSets=(()=>{try{new Xf("[[]]","v")}catch{return!1}return!0})();fs.bugFlagVLiteralHyphenIsRange=fs.unicodeSets?(()=>{try{new Xf(yt`[\d\-a]`,"v")}catch{return!0}return!1})():!1;fs.bugNestedClassIgnoresNegation=fs.unicodeSets&&new Xf("[[^a]]","v").test("a");function Jh(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 du(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function yy(e,t){return RC[e]>=RC[t]}function VH(e,t){if(e==null)throw new Error(t??"Value expected");return e}var RC={ES2025:2025,ES2024:2024,ES2018:2018},GH={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function jN(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!GH[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=fs.flagGroups?"ES2025":fs.unicodeSets?"ES2024":"ES2018"),t}var WH="[ -\r ]",qH=new Set([Mn(304),Mn(305)]),Zs=yt`[\p{L}\p{M}\p{N}\p{Pc}]`;function EN(e){if(qH.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),a=XH.get(n),o=KH.get(n),c=YH.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 Bb=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=>[Kf(e),e])),KH=new Map([["s",Mn(383)],[Mn(383),"s"]]),YH=new Map([[Mn(223),Mn(7838)],[Mn(107),Mn(8490)],[Mn(229),Mn(8491)],[Mn(969),Mn(8486)]]),XH=new Map([Fi(453),Fi(456),Fi(459),Fi(498),...ix(8072,8079),...ix(8088,8095),...ix(8104,8111),Fi(8124),Fi(8140),Fi(8188)]),JH=new Map([["alnum",yt`[\p{Alpha}\p{Nd}]`],["alpha",yt`\p{Alpha}`],["ascii",yt`\p{ASCII}`],["blank",yt`[\p{Zs}\t]`],["cntrl",yt`\p{Cc}`],["digit",yt`\p{Nd}`],["graph",yt`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",yt`\p{Lower}`],["print",yt`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",yt`[\p{P}\p{S}]`],["space",yt`\p{space}`],["upper",yt`\p{Upper}`],["word",yt`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",yt`\p{AHex}`]]);function QH(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Fi(e){const t=Mn(e);return[t.toLowerCase(),t]}function ix(e,t){return QH(e,t).map(n=>Fi(n))}var NN=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function ZH(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};TN(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:yy(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};Yc(e,eF,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};Yc(e,tF,o);const c={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return Yc(e,nF,c),e._originMap=o.groupOriginByCopy,e._strategy=r.strategy,e}var eF={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:a}=e;if(a==="repeater"){const o=ls();o.body[0].body.push(Ia({negate:!0,body:r}),Zo("Any"));const c=ls();c.body[0].body.push(vN("greedy",0,1/0,o)),n(_n(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];du(r,c,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const r=LN(t.get(e));if(r){const a=ls({flags:r});a.body[0].body=e.body,e.body=[_n(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:p,avoidSubclass:m,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(_n(Ia({body:[Ja({body:[my("string_end")]}),Ja({body:[qf(10)]})]}),t));else if(d==="line_start")c(_n(ei(yt`(?<=\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&&lF(w))c(_n(Ia({negate:!0}),t));else{if(m)throw new Error(yt`Uses "\G" in a way that requires a subclass`);c(Ui(my("string_start"),t)),u.strategy="clip_search"}}else if(!(d==="string_end"||d==="string_start"))if(d==="string_end_newline")c(_n(ei(yt`(?=\n?\z)`),t));else if(d==="word_boundary"){if(!x&&!p){const w=`(?:(?<=${Zs})(?!${Zs})|(?<!${Zs})(?=${Zs}))`,C=`(?:(?<=${Zs})(?=${Zs})|(?<!${Zs})(?!${Zs}))`;c(_n(ei(h?C:w),t))}}else throw new Error(`Unexpected assertion kind "${d}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!ox(n)&&(n=ax(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!ox(r)&&(r=ax(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=jh({body:[e]});n(_n(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:p}=e;if(o&&(d==="digit"||p==="digit")){n(Ui(gy("digit",{negate:h}),t));return}if(c&&(d==="space"||p==="space")){n(_n(lx(ei(WH),h),t));return}if(u&&(d==="word"||p==="word")){n(Ui(gy("word",{negate:h}),t));return}if(d==="any")n(Ui(Zo("Any"),t));else if(d==="digit")n(Ui(Zo("Nd",{negate:h}),t));else if(d!=="dot")if(d==="text_segment"){if(r==="strict")throw new Error(yt`Use of "\X" requires non-strict accuracy`);const m="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",g=yt`\p{RI}{2}|${m}(?:\u200D${m})*`;n(_n(ei(yt`(?>\r\n|${a?yt`\p{RGI_Emoji}`:g}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(d==="hex")n(Ui(Zo("AHex",{negate:h}),t));else if(d==="newline")n(_n(ei(h?`[^
|
|
244
|
+
]`:`(?>\r
|
|
245
|
+
?|[
|
|
246
|
+
\v\f
\u2028\u2029])`),t));else if(d==="posix")if(!a&&(p==="graph"||p==="print")){if(r==="strict")throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);let m={graph:"!-~",print:" -~"}[p];h&&(m=`\0-${Mn(m.codePointAt(0)-1)}${Mn(m.codePointAt(2)+1)}-`),n(_n(ei(`[${m}]`),t))}else n(_n(lx(ei(JH.get(p)),h),t));else if(d==="property")Bb.has(Kf(p))||(e.key="sc");else if(d==="space")n(Ui(Zo("space",{negate:h}),t));else if(d==="word")n(_n(lx(ei(Zs),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=ls({flags:d});h.body[0].body=c(),a(_n(h,t),{traverse:!0})}else if(u==="keep"){const h=n.body[0],m=n.body.length===1&&xN(h,{type:"Group"})&&h.body[0].body.length===1?h.body[0]:n;if(t.parent!==m||m.body.length>1)throw new Error(yt`Uses "\K" in a way that's unsupported`);const g=Ia({behind:!0});g.body[0].body=o(),a(_n(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(_n(Ia({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=ls();t.body[0].body.push(e.body),e.body=_n(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=RN(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(yt`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!ox(n)&&(n=ax(n,t),e.ref=n)}},tF={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 m=Ui(OC(e.number),t);d.set(m,u.get(e.number)),n(m);return}u.set(e.number,e),c.set(e.number,[]),e.name&&du(c,e.name,[]);const p=c.get(e.name??e.number);for(let m=0;m<p.length;m++){const g=p[m];if(h===g.node||h&&h===g.origin||e===g.origin){p.splice(m,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 m=du(o,e.name,new Map);let g=!1;if(h)g=!0;else for(const x of m.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=Jh(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 p=t;for(;(p=p.parent)&&!(p.type==="CapturingGroup"&&(p.name===o||p.number===o)););r.reffedNodesByReferencer.set(e,p);return}const c=r.subroutineRefMap.get(o),u=o===0,d=u?OC(0):AN(c,r.groupOriginByCopy,null);let h=d;if(!u){const p=LN(iF(c,g=>g.type==="Group"&&!!g.flags)),m=p?Jh(r.globalFlags,p):r.globalFlags;rF(m,r.currentFlags)||(h=ls({flags:aF(m)}),h.body[0].body.push(d))}n(_n(h,t),{traverse:!u})}},nF={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=>sF(c,e));if(!o.length)n(_n(Ia({negate:!0}),t));else if(o.length>1){const c=ls({atomic:!0,body:o.reverse().map(u=>Ja({body:[py(u.number)]}))});n(_n(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=bN();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function TN(e){Yc(e,{"*"({node:t,parent:n}){t.parent=n}})}function rF(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function sF(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=DN(n.parent);for(const a of r){if(a===n)break;if(a===e||ON(a,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function AN(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]=AN(c,t,a,n):(o==="type"&&c==="CapturingGroup"&&t.set(a,t.get(e)??e),a[o]=c);return a}function OC(e){const t=_N(e);return t.isRecursive=!0,t}function iF(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function ax(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 LN(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 aF({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 DN(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function RN(e){const t=e.find(n=>n.kind==="search_start"||cF(n,{negate:!1})||!oF(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=RN(r.body);if(!a)return null;Array.isArray(a)?n.push(...a):n.push(a)}return n}return null}function ON(e,t){const n=DN(e)??[];for(const r of n)if(r===t||ON(r,t))return!0;return!1}function oF({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function lF(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function cF(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&xN(e.body[0],{type:"Assertion",kind:"search_start"})}function ox(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function ei(e,t){const r=yN(e,{...t,unicodePropertyMap:Bb}).body;return r.length>1||r[0].body.length>1?ls({body:r}):r[0].body[0]}function lx(e,t){return e.negate=t,e}function Ui(e,t){return e.parent=t,e}function _n(e,t){return TN(e),e.parent=t,e}function uF(e,t){const n=jN(t),r=yy(n.target,"ES2024"),a=yy(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];Yc(e,dF,{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 p={accuracy:n.accuracy,appliedGlobalFlags:d,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:h,originMap:e._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!a&&c&&u),useFlagMods:a,useFlagV:r,verbose:n.verbose};function m(x){return p.lastNode=h,h=x,VH(hF[x.type],`Unexpected node type "${x.type}"`)(x,p,m)}const g={pattern:e.body.map(m).join("|"),flags:m(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=[],p.captureMap.forEach((x,w)=>{x.hidden&&g._hiddenCaptures.push(w),x.transferTo&&du(g._captureTransfers,x.transferTo,[]).push(w)}),g}var dF={"*":{enter({node:e},t){if(MC(e)){const n=t.getCurrentModI();t.pushModI(e.flags?Jh({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){MC(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){$b(Mn(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),IN(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&NN.has(e.value)&&t.setHasCasedChar()}},hF={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?yt`\B`:yt`\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=Mn(e),r=Uo(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&$b(n)){const a=EN(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");fs.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&c.some(PC)&&(c=[qf(45),...c.filter(h=>!PC(h))]);const u=()=>`[${a?"^":""}${c.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||fs.bugNestedClassIgnoresNegation)&&!a){const p=c.filter(m=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(p.length){const m=ls(),g=m.body[0];return m.parent=o,g.parent=m,c=c.filter(x=>!p.includes(x)),e.body=c,c.length?(e.parent=g,g.body.push(e)):m.body.pop(),p.forEach(x=>{const w=Ja({body:[x]});x.parent=w,w.parent=m,m.body.push(w)}),n(m)}}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"&&!(fs.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=Uo(n,a),c=Uo(r,a),u=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const d=IN(e);xF(d).forEach(p=>{u.add(Array.isArray(p)?`${Uo(p[0],a)}-${Uo(p[1],a)}`:Uo(p,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?".":"[^]":yt`[^\n]`;if(e==="digit")return t?yt`\D`:yt`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&NN.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?yt`\P`:yt`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?yt`\W`:yt`\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=Jh(c,n));const u=t.map(o).join("|"),d=!a.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!a.useFlagMods||!n)?u:`(?${yF(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)+bF(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})`:yt`\g<${t}&R=${r}>`}},fF=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),mF=new Set(["-","\\","]","^","["]),pF=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),IC=new Map([[9,yt`\t`],[10,yt`\n`],[11,yt`\v`],[12,yt`\f`],[13,yt`\r`],[8232,yt`\u2028`],[8233,yt`\u2029`],[65279,yt`\uFEFF`]]),gF=new RegExp("^\\p{Cased}$","u");function $b(e){return gF.test(e)}function IN(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=Mn(c);if(!$b(u))continue;const d=EN(u).filter(h=>{const p=h.codePointAt(0);return p<r||p>a});if(d.length&&(o.push(...d),n))break}return o}function Uo(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(IC.has(e))return IC.get(e);if(e<32||e>126&&e<160||e>262143||t&&vF(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=n?r?pF:mF:fF,o=Mn(e);return(a.has(o)?"\\":"")+o}function xF(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 yF(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 bF({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 MC({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function vF(e){return e>47&&e<58}function PC({type:e,value:t}){return e==="Character"&&t===45}var Vi,ii,za,Gi,Ha,fu,by,Qi,_F=(Qi=class extends RegExp{constructor(n,r,a){var t=(...qW)=>(super(...qW),Sa(this,fu),Sa(this,Vi,new Map),Sa(this,ii,null),Sa(this,za),Sa(this,Gi,null),Sa(this,Ha,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),ss(this,za,c.source),c instanceof Qi&&(ss(this,Vi,ir(c,Vi)),ss(this,Gi,ir(c,Gi)),ss(this,Ha,ir(c,Ha)),this.rawOptions=c.rawOptions)}else{const c={hiddenCaptures:[],strategy:null,transfers:[],...a};t(o?"":n,r),ss(this,za,n),ss(this,Vi,wF(c.hiddenCaptures,c.transfers)),ss(this,Ha,c.strategy),this.rawOptions=a??{}}o||ss(this,ii,this)}get source(){return ir(this,za)||"(?:)"}exec(n){if(!ir(this,ii)){const{lazyCompile:o,...c}=this.rawOptions;ss(this,ii,new Qi(ir(this,za),this.flags,c))}const r=this.global||this.sticky,a=this.lastIndex;if(ir(this,Ha)==="clip_search"&&r&&a){this.lastIndex=0;const o=cg(this,fu,by).call(this,n.slice(a));return o&&(SF(o,a,n,this.hasIndices),this.lastIndex+=a),o}return cg(this,fu,by).call(this,n)}},Vi=new WeakMap,ii=new WeakMap,za=new WeakMap,Gi=new WeakMap,Ha=new WeakMap,fu=new WeakSet,by=function(n){ir(this,ii).lastIndex=this.lastIndex;const r=KS(Qi.prototype,this,"exec").call(ir(this,ii),n);if(this.lastIndex=ir(this,ii).lastIndex,!r||!ir(this,Vi).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}=ir(this,Vi).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 p=c[h];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(r[p]=a[u],this.hasIndices&&(r.indices[p]=o[u]),r.groups){ir(this,Gi)||ss(this,Gi,CF(this.source));const m=ir(this,Gi).get(h);m&&(r.groups[m]=a[u],this.hasIndices&&(r.indices.groups[m]=o[u]))}}}return r},Qi);function SF(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 wF(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)du(n,o,{}).transferTo=r;return n}function CF(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 kF(e,t){const n=jF(e,t);return n.options?new _F(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function jF(e,t){const n=jN(t),r=yN(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Bb}),a=ZH(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=uF(a,n),c=FH(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),u=zH(c.pattern),d=$H(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 p=d.hiddenCaptures.sort((w,C)=>w-C),m=Array.from(d.captureTransfers),g=a._strategy,x=h.pattern.length>=n.lazyCompileLength;(p.length||m.length||g||x)&&(h.options={...p.length&&{hiddenCaptures:p},...m.length&&{transfers:m},...g&&{strategy:g},...x&&{lazyCompile:x}})}return h}function MN(e,t){return kF(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function EF(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>MN(n,{target:t.target})),{createScanner(n){return new Uz(n,t)},createString(n){return{content:n}}}}f2(Sb({bundledLanguages:()=>Bf,bundledLanguagesAlias:()=>Cb,bundledLanguagesBase:()=>wb,bundledLanguagesInfo:()=>Pf,bundledThemes:()=>jb,bundledThemesInfo:()=>kb,codeToHast:()=>aN,codeToHtml:()=>iN,codeToTokens:()=>oN,codeToTokensBase:()=>lN,codeToTokensWithThemes:()=>cN,createHighlighter:()=>Wf,createJavaScriptRegexEngine:()=>EF,createOnigurumaEngine:()=>g2,defaultJavaScriptRegexConstructor:()=>MN,getLastGrammarState:()=>dN,getSingletonHighlighter:()=>uN,loadWasm:()=>Nb}),Fz);let cx=null;const Xc=new Set,nh=new Map,BC=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],NF=["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"],ux={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 TF(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function PN(){return cx||(cx=Wf({themes:NF,langs:BC}).then(e=>(BC.forEach(t=>Xc.add(t)),e))),cx}async function AF(e){if(Xc.has(e))return;if(nh.has(e))return nh.get(e);const t=(async()=>{const n=await PN(),r=Bf[e];if(r){await n.loadLanguage(r),Xc.add(e);return}try{const a=await ne(()=>import(`shiki/langs/${e}.mjs`),[]);a.default&&(await n.loadLanguage(a.default),Xc.add(e))}catch(a){console.warn(`Failed to load language ${e}:`,a)}})();nh.set(e,t),await t,nh.delete(e)}const Dc=new Map,LF=50;function DF(e,t,n){return`${e}|${t}|${n}`}async function BN(e,t,n="github-dark-default"){t!=="text"&&!Xc.has(t)&&await AF(t);const r=DF(e,t,n),a=Dc.get(r);if(a)return a;const c=(await PN()).codeToHtml(e,{lang:t,theme:n,transformers:[TF()]});if(Dc.size>=LF){const u=Dc.keys().next().value;u&&Dc.delete(u)}return Dc.set(r,c),c}const RF={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 Jf(e){var a;if(!e)return"text";const t=xu(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?RF[r]??"text":"text"}function $N(){const e=Kt(r=>r.currentPreset),t=Kt(r=>r.isCustom),n=Kt(r=>r.basePreset);return OF(e,t,n)}function OF(e,t,n){return t?n&&n!=="system"&&ux[n]?ux[n]??"github-dark-default":"github-dark-default":ux[e]??"github-dark-default"}function zN(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 IF=5e3,Fc=new Map,MF=100,PF=20*1024*1024;let BF=PF,dx=0;function $F(e,t){for(Fc.set(e,t),dx+=e.length;Fc.size>MF||dx>BF;){const n=Fc.keys().next().value;if(n===void 0)break;Fc.delete(n),dx-=n.length}return t}const zF=j.memo(function({language:t,codeString:n,showSyntaxHighlighting:r,deferHighlight:a}){const{copied:o,copy:c}=zN(),[u,d]=j.useState(null),h=$N(),p=j.useRef(n),m=t==="text"||n.length>IF;return j.useEffect(()=>{!r||a||m||(p.current=n,BN(n,t,h).then(g=>{p.current===n&&d(g)}))},[n,t,h,r,a,m]),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(Rs,{}):s.jsx(ml,{})})]}),r&&u?s.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:u}}):s.jsx(cn,{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 HF(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 p=(d==null?void 0:d[1])||"text",m=String(c).replace(/\n$/,"");return s.jsx(zF,{language:p,codeString:m,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(cn,{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 Qn=j.memo(function({content:t,className:n="",muted:r=!1,isStreaming:a=!1}){const{showSyntaxHighlighting:o,deferCodeHighlightWhileStreaming:c}=Ds(),u=j.useMemo(()=>a&&c&&FN(t)%2===1,[a,c,t]),d=j.useMemo(()=>HF(r,o,u),[r,o,u]),h=j.useMemo(()=>{const p=FF(t);if(!VF(p)){if(!p.trim())return null;const m=r?"text-text-muted":"text-text-primary";return s.jsx("p",{className:`${m} mb-1.5 last:mb-0 leading-tight break-words whitespace-pre-line`,children:UF(p)})}return a?HN(p,d):GF(p,d,r,o)},[t,a,d,r,o]);return s.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:h})});function FF(e){let t=WF(e);return t=qF(t),t.trimEnd()}function UF(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 VF(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 HN(e,t){return s.jsx(aP,{remarkPlugins:[bB],components:t,children:e})}function GF(e,t,n,r){const a=`${n?"m":"n"}|${r?"h":"p"}|${e}`,o=Fc.get(a);if(o!==void 0)return o;const c=HN(e,t);return $F(a,c)}function WF(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 FN(e){var t;return((t=e.match(/```/g))==null?void 0:t.length)??0}function qF(e){if(FN(e)%2===1){const n=e.lastIndexOf("```");return e.slice(n+3).includes(`
|
|
248
|
+
`),e+"\n```"}return e}function UN({isOpen:e,onClose:t}){const[n,r]=j.useState(null),[a,o]=j.useState(!1),{settings:c,getSetting:u,setSetting:d}=ra(),h=c[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]!=="false";j.useEffect(()=>{e&&u(Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE)},[e,u]),j.useEffect(()=>{e&&(o(!0),xe("/api/changelog").then(m=>m.json()).then(m=>{r(m.content)}).catch(()=>{r(`# Changelog
|
|
249
|
+
|
|
250
|
+
Failed to load changelog.`)}).finally(()=>o(!1)))},[e]);const p=j.useCallback(()=>{const m=h?"false":"true";d(Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,m)},[h,d]);return s.jsx(wt,{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(ds,{enabled:h,onClick:p}),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:a?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(Qn,{content:n??""})})})})}const KF="#6b7280";function Qa(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??KF}const Vo=(e,t)=>t?`${e}?workdir=${encodeURIComponent(t)}`:e,ct=Kn(e=>{const t=async n=>{e({loading:!0});try{const a=await(await xe(Vo("/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 xe(Vo(`/api/agents/${n}`,r));return a.ok?await a.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await xe(`/api/agents/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createAgent:async(n,r,a)=>{const o=await Zi("POST",Vo("/api/agents",a),{...n,destination:r});return o.success&&await t(a),o},updateAgent:async(n,r,a)=>{const o=await Zi("PUT",Vo(`/api/agents/${n}`,a),r);return o.success&&await t(a),o},deleteAgent:async(n,r)=>{try{const a=await xe(Vo(`/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)=>Sf(Vo(`/api/agents/${n}/duplicate`,a),()=>t(a),r)}});function YF({onClose:e}){const[,t]=Pn(),{settings:n,getSetting:r,setSetting:a}=ra(),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}),[p,m]=j.useState({patterns:[],maxRetriesPerTurn:10}),[g,x]=j.useState(""),[w,C]=j.useState(""),[v,S]=j.useState(!1),[_,b,k,E]=Ux(),[T,D]=j.useState(!1),[A,R]=j.useState(!1),M=en(P=>P.version),W=ui(P=>P.status),$=ui(P=>P.latest),G=ui(P=>P.check),B=M&&$?{current:M,latest:$}:null,[H,q]=j.useState(!1),Q=ct(P=>P.defaults),J=ct(P=>P.userItems),U=ct(P=>P.fetchAgents),I=[...Q,...J].filter(P=>!P.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 P=n[Ne.RETRY_PATTERNS];if(P)try{m(JSON.parse(P))}catch{}},[n]),j.useEffect(()=>{const P=n[Ne.PROXY_URL];P!==void 0&&x(P)},[n]),j.useEffect(()=>{U().catch(()=>{})},[U]),j.useEffect(()=>{r(Ne.DEFAULT_AGENT)},[r]),j.useEffect(()=>{const P=n[Ne.DEFAULT_AGENT];P!==void 0&&(C(P),S(!0))},[n]);const O=j.useCallback(P=>{m(P),a(Ne.RETRY_PATTERNS,JSON.stringify(P))},[a]),V=P=>{x(P),a(Ne.PROXY_URL,P)};function z(){E(async()=>(await xe("/api/proxy/test",{method:"POST"})).json())}const Y=()=>{const P=!d.openInEditor;h(te=>({...te,openInEditor:P})),a(Ne.DISPLAY_SHOW_OPEN_IN_EDITOR,String(P))},X=()=>{const P=!d.dynamicPrompt;h(te=>({...te,dynamicPrompt:P})),a(Ne.LLM_DYNAMIC_SYSTEM_PROMPT,String(P))},Z=()=>{const P=!d.cacheWarming;h(te=>({...te,cacheWarming:P})),a(Ne.CACHE_WARMING,String(P))};function F(){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:[W==="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:()=>{q(!0),G()},disabled:W==="checking",children:W==="checking"?"Checking…":"Check for Updates"}),H&&W==="upToDate"&&s.jsx("span",{className:"text-sm text-text-muted",children:"Up to date"}),W==="error"&&s.jsx("span",{className:"text-sm text-text-muted",children:"Update check failed"}),W==="available"&&s.jsxs("button",{onClick:()=>D(!0),className:"text-sm text-accent-primary hover:underline",children:["Update to v",$," →"]})]})]}),s.jsx(oE,{isOpen:T,onClose:()=>D(!1),versionInfo:B}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("button",{onClick:()=>R(!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(ds,{enabled:(n[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true",onClick:()=>{const te=(n[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true"?"false":"true";a(Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,te)}})]})]}),s.jsx(UN,{isOpen:A,onClose:()=>R(!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:P=>{const te=P.target.value;C(te),a(Ne.DEFAULT_AGENT,te)},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)"}),I.map(P=>s.jsx("option",{value:P.id,children:P.name},P.id))]}),I.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:F,children:"Launch Onboarding"})]}),s.jsx("hr",{className:"border-border"}),s.jsx("div",{children:s.jsx(hx,{title:'Show "Open in VSCode" links',description:"Display a link on file reads to open the file directly in VS Code.",enabled:d.openInEditor,onToggle:Y})}),s.jsx("hr",{className:"border-border"}),s.jsx(hx,{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:Z,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(Ns,{type:"text",value:g,onChange:P=>V(P.target.value),placeholder:"http://proxy:8080",className:"flex-1"}),s.jsx(ot,{variant:"secondary",onClick:z,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(K3,{value:p,onChange:O})]}),s.jsx("hr",{className:"border-border"}),s.jsx(hx,{title:"Dynamic System Prompt",description:"Rebuild the system prompt on every turn. Recommended value: off.",enabled:d.dynamicPrompt,onToggle:X,boldTitle:!0})]})}function hx({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(ds,{enabled:n,onClick:r})})]})}function XF(e,t){return e===null&&t===null?!0:e===null||t===null?!1:JSON.stringify(e)===JSON.stringify(t)}function JF({label:e,binding:t,defaultBinding:n,isRecording:r,onStartRecording:a,onBindingRecorded:o,onClear:c,onReset:u,onCancelRecording:d}){const h=j.useRef(null),p=j.useRef(0),m=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===m.current&&b-p.current<400){o({type:"double-press",key:v.key,threshold:300});return}p.current=b,m.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:Jw(v),modifiers:b});return}const S=Date.now(),_=Jw(v);if(_===m.current&&S-p.current<400){o({type:"double-press",key:_,threshold:300});return}p.current=S,m.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?Oh(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(eb,{className:"w-3.5 h-3.5"})}),!XF(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(Ef,{className:"w-3.5 h-3.5"})})]})})]})}function QF(){const{settings:e,loading:t,setSetting:n}=ra(),r=e[Ne.KEYBINDINGS],a=t[Ne.KEYBINDINGS]??!1,o=Fx(r),[c,u]=j.useState(null),d=[{id:"terminalToggle",label:"Toggle Terminal",binding:o.terminalToggle,defaultBinding:js.terminalToggle},{id:"quickAction",label:"Quick Action",binding:o.quickAction,defaultBinding:js.quickAction},{id:"modelSelector",label:"Select Model",binding:o.modelSelector,defaultBinding:js.modelSelector},{id:"sessionSearch",label:"Search Sessions",binding:o.sessionSearch,defaultBinding:js.sessionSearch},{id:"criteriaSidebar",label:"Toggle Criteria Sidebar",binding:o.criteriaSidebar,defaultBinding:js.criteriaSidebar},...o.agentSwitching.map((x,w)=>({id:`agentSwitching.${w}`,label:`Switch to Agent ${w+1}`,binding:x,defaultBinding:js.agentSwitching[w]??null}))],h=x=>{u(x)},p=j.useCallback((x,w)=>{const C=Fx(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]),m=j.useCallback(x=>{c&&(u(null),p(c,x))},[c,p]),g=()=>{n(Ne.KEYBINDINGS,JSON.stringify(js))};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(JF,{label:x.label,binding:x.binding,defaultBinding:x.defaultBinding,isRecording:c===x.id,onStartRecording:()=>h(x.id),onBindingRecorded:m,onClear:()=>p(x.id,null),onReset:()=>p(x.id,x.defaultBinding),onCancelRecording:()=>u(null)},x.id))})]})}function zb(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 Hb(e){switch(e){case"connected":return"●";case"error":return"✕";default:return"○"}}function Qh(e){return e>=1e3?`~${(e/1e3).toFixed(1)}K`:`~${e}`}function VN({server:e,expanded:t,onToggleExpand:n,serverToggleEnabled:r,onServerToggle:a,tools:o,onToolToggle:c,statusDot:u,statusColor:d,actions:h,authPanel:p}){var w;const[m,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:[Qh(e.estimatedTokens)," tokens"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ds,{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}),p,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:m.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:Qh(C.estimatedTokens)}),s.jsx(ds,{enabled:C.enabled,onClick:()=>c(C.name)})]}),C.description&&C.description.length>80&&m.has(C.name)&&s.jsx("div",{className:"text-xs text-text-muted mt-1 ml-1",children:C.description})]},C.name))})]})]},x)}function $C(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 zC({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(Xr,{label:"Command",value:e.command,onChange:n=>t({...e,command:n}),placeholder:"e.g. npx"}),s.jsx(Xr,{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(Xr,{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(Xr,{label:"Timeout (seconds)",value:e.timeout,onChange:n=>t({...e,timeout:n}),placeholder:"optional, e.g. 30"})]})}const fx="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 ZF({serverName:e,onChanged:t}){const[n,r]=j.useState(!1),[a,o]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(""),p=`/api/mcp/servers/${encodeURIComponent(e)}/oauth`,m=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 xe(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=()=>m(async()=>{const v=await g(`${p}/start`);if(v.status!=="redirect"){t();return}o(v.redirectUri??""),window.open(v.authorizationUrl,"_blank","noopener,noreferrer")}),w=()=>m(async()=>{await g(`${p}/complete`,{response:c}),u(""),o(""),t()}),C=()=>m(async()=>{if(!(await xe(p,{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:fx,children:"Authorize"}),s.jsx("button",{onClick:C,disabled:n,className:fx,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:fx,children:"Finish"})]})]}),d&&s.jsx("div",{className:"text-xs text-accent-error",children:d})]})}function mx(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 HC({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 e7(){const{settings:e,getSetting:t,setSetting:n}=ra(),[r,a]=j.useState(""),[o,c]=j.useState(""),[u,d]=j.useState(""),[h,p]=j.useState("");mx(o,Ne.SEARCH_TAVILY_API_KEY,n),mx(u,Ne.SEARCH_SEARXNG_URL,n),mx(h,Ne.SEARCH_SEARXNG_API_KEY,n);const[m,g,x,w]=Ux(),[C,v,S,_]=Ux();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]??""),p(e[Ne.SEARCH_SEARXNG_API_KEY]??""))},[e]);function b(ie){a(ie),n(Ne.SEARCH_ENGINE,ie)}function k(){w(async()=>(await xe("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"tavily",tavilyApiKey:o||void 0})})).json())}function E(){_(async()=>(await xe("/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,D]=j.useState("checking");j.useEffect(()=>{xe("/api/tools/rtk-check").then(ie=>ie.json()).then(ie=>D(ie.available?"available":"unavailable")).catch(()=>D("unavailable"))},[]);const[A,R]=j.useState([]);j.useEffect(()=>{t(Ne.TOOLS_SHELL),xe("/api/tools/shells").then(ie=>ie.json()).then(ie=>R(ie.shells??[])).catch(()=>R([]))},[t]);const M=e[Ne.TOOLS_SHELL]||"cmd",[W,$]=j.useState([]),[G,B]=j.useState(!0),[H,q]=j.useState(!1),[Q,J]=j.useState(null),[U,I]=j.useState(new Set),[O,V]=j.useState({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",oauth:!1,timeout:""}),[z,Y]=j.useState(""),[X,Z]=j.useState(""),[F,P]=j.useState(!1),{requestDelete:te,clearConfirm:se,isConfirming:re}=gu(),ae=j.useCallback(async()=>{try{const Ue=((await(await xe("/api/mcp/servers")).json()).servers??[]).sort((ue,De)=>ue.name.localeCompare(De.name));$(Ue)}catch{}B(!1)},[]);j.useEffect(()=>{ae()},[ae]),j.useEffect(()=>{const ie=()=>ae();return window.addEventListener("mcp-servers-changed",ie),()=>window.removeEventListener("mcp-servers-changed",ie)},[ae]);const ye=ie=>{I(Pe=>{const Ue=new Set(Pe);return Ue.has(ie)?(Ue.delete(ie),Ue):(Ue.add(ie),Ue)})};function _e(){if(O.transport==="stdio"&&!O.command)return"Command is required for stdio transport";if(O.transport==="http"&&!O.url)return"URL is required for HTTP transport";if(O.timeout){const ie=parseFloat(O.timeout);if(isNaN(ie)||ie<=0)return"Timeout must be a positive number"}return null}function Ie(ie){const Pe=ie?{name:O.name,transport:O.transport}:{transport:O.transport};if(O.transport==="stdio"?(Pe.command=O.command,Pe.args=O.args?O.args.split(" ").filter(Boolean):[],Pe.env=$C(O.env)):(Pe.url=O.url,Pe.headers=$C(O.headers),Pe.oauth=O.oauth),O.timeout){const Ue=parseFloat(O.timeout);!isNaN(Ue)&&Ue>0&&(Pe.timeout=Ue)}return Pe}const He={name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",oauth:!1,timeout:""},je=async()=>{if(Y(""),!O.name){Y("Name is required");return}const ie=_e();if(ie){Y(ie);return}P(!0);try{const Pe=Ie(!0),Ue=await xe("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Pe)});if(!Ue.ok){const ue=await Ue.json();throw new Error(ue.error??"Failed to add server")}q(!1),V(He),await ae()}catch(Pe){Y(Pe instanceof Error?Pe.message:String(Pe))}finally{P(!1)}},Ge=ie=>{var Pe;V({name:ie.name,transport:ie.config.transport,command:ie.config.command??"",args:((Pe=ie.config.args)==null?void 0:Pe.join(" "))??"",env:ie.config.env?Object.entries(ie.config.env).map(([Ue,ue])=>`${Ue}=${ue}`).join(`
|
|
252
|
+
`):"",url:ie.config.url??"",headers:ie.config.headers?Object.entries(ie.config.headers).map(([Ue,ue])=>`${Ue}=${ue}`).join(`
|
|
253
|
+
`):"",oauth:ie.config.oauth??!1,timeout:ie.config.timeout!==void 0?String(ie.config.timeout):""}),Y(""),J(ie.name)},Ze=async()=>{Y("");const ie=_e();if(ie){Y(ie);return}P(!0);try{const Pe=Ie(!1),Ue=await xe(`/api/mcp/servers/${encodeURIComponent(Q)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Pe)});if(!Ue.ok){const ue=await Ue.json();throw new Error(ue.error??"Failed to update server")}J(null),V(He),await ae()}catch(Pe){Y(Pe instanceof Error?Pe.message:String(Pe))}finally{P(!1)}},Se=async ie=>{try{const Pe=await xe(`/api/mcp/servers/${encodeURIComponent(ie)}`,{method:"DELETE"});if(!Pe.ok){const Ue=await Pe.json().catch(()=>({}));throw new Error(Ue.error??"Failed to remove server")}se(),Z(""),await ae()}catch(Pe){Z(Pe instanceof Error?Pe.message:String(Pe))}},be=async(ie,Pe,Ue)=>{try{const ue=await xe(`/api/mcp/servers/${encodeURIComponent(ie)}/tools/${encodeURIComponent(Pe)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ue})});if(!ue.ok){const De=await ue.json().catch(()=>({}));throw new Error(De.error??"Failed to toggle tool")}Z(""),await ae()}catch(ue){Z(ue instanceof Error?ue.message:String(ue))}},de=async(ie,Pe)=>{try{const Ue=await xe(`/api/mcp/servers/${encodeURIComponent(ie)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:Pe})});if(!Ue.ok){const ue=await Ue.json().catch(()=>({}));throw new Error(ue.error??"Failed to toggle server")}Z(""),await ae()}catch(Ue){Z(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(ie=>s.jsx("button",{onClick:()=>b(ie),className:`px-3 py-1.5 rounded text-sm border transition-colors ${r===ie?"bg-accent-primary/10 border-accent-primary text-accent-primary":"border-border text-text-muted hover:text-text-primary"}`,children:ie||"Off"},ie))})]}),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(Ns,{type:"password",value:o,onChange:ie=>c(ie.target.value),placeholder:"tvly-...",className:"flex-1"}),s.jsx(ot,{variant:"secondary",onClick:k,style:x?{color:"rgb(63, 185, 80)"}:void 0,children:m})]}),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(Ns,{type:"url",value:u,onChange:ie=>d(ie.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(Ns,{type:"password",value:h,onChange:ie=>p(ie.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(ie=>s.jsxs("button",{onClick:()=>n(Ne.TOOLS_SHELL,ie.id),disabled:!ie.available,title:ie.available?void 0:"Not found on this machine",className:`px-3 py-1.5 rounded text-sm border transition-colors ${M===ie.id?"bg-accent-primary/10 border-accent-primary text-accent-primary":ie.available?"border-border text-text-muted hover:text-text-primary":"border-border text-text-muted opacity-50 cursor-not-allowed"}`,children:[ie.label,!ie.available&&" (not found)"]},ie.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(ds,{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(ds,{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:()=>q(!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(ds,{enabled:e[Ne.FEATURES_PER_SESSION_MCP]==="true",onClick:()=>n(Ne.FEATURES_PER_SESSION_MCP,e[Ne.FEATURES_PER_SESSION_MCP]==="true"?"false":"true")})]}),X&&s.jsx(ll,{message:X}),s.jsx(nb,{loading:G,hasItems:W.length>0,loadingLabel:"Loading MCP servers...",emptyLabel:"No MCP servers configured.",children:W.map(ie=>{const Pe=U.has(ie.name)?re(ie.name,"delete")?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:ue=>{ue.stopPropagation(),Se(ie.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:ue=>{ue.stopPropagation(),se()},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:ue=>{ue.stopPropagation(),Ge(ie)},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:ue=>{ue.stopPropagation(),te(ie.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=ie.status==="error"&&ie.error?s.jsx("span",{className:"text-xs text-accent-error truncate max-w-[200px]",title:ie.error,children:ie.error}):null;return s.jsx(VN,{server:ie,expanded:U.has(ie.name),onToggleExpand:ye,serverToggleEnabled:!ie.config.disabled,onServerToggle:()=>de(ie.name,!ie.config.disabled),tools:ie.tools,onToolToggle:ue=>{var De;return be(ie.name,ue,!((De=ie.tools.find(qe=>qe.name===ue))!=null&&De.enabled))},statusDot:Hb(ie.status),statusColor:zb(ie.status),authPanel:ie.config.oauth?s.jsx(ZF,{serverName:ie.name,onChanged:ae}):null,actions:s.jsxs(s.Fragment,{children:[Ue,Pe]})},ie.name)})}),H&&s.jsx(wt,{isOpen:H,onClose:()=>{q(!1),Y("")},title:"Add MCP Server",size:"sm",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(Xr,{label:"Name",value:O.name,onChange:ie=>V({...O,name:ie}),placeholder:"e.g. filesystem"}),s.jsx(zC,{formData:O,onChange:V}),z&&s.jsx(ll,{message:z}),s.jsx(HC,{saving:F,saveLabel:"Add",savingLabel:"Adding...",onCancel:()=>{q(!1),Y(""),P(!1),V(He)},onSave:je})]})}),Q!==null&&s.jsx(wt,{isOpen:!0,onClose:()=>{J(null),Y("")},title:`Edit MCP Server: ${Q}`,size:"sm",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(zC,{formData:O,onChange:V}),z&&s.jsx(ll,{message:z}),s.jsx(HC,{saving:F,saveLabel:"Save",savingLabel:"Saving...",onCancel:()=>{J(null),Y(""),P(!1),V(He)},onSave:Ze})]})})]})]})}const GN="openfox_user_plugins";function t7(e){const t=e.match(/github\.com\/([^/]+)\/([^/]+?)(?:\/|$)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,"")}:null}async function px(e){const t=t7(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 rh(){try{return JSON.parse(localStorage.getItem(GN)??"[]")}catch{return[]}}function FC(e){localStorage.setItem(GN,JSON.stringify(e))}function n7({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 r7({plugin:e,initiallyInstalled:t,installedVersion:n,onRemove:r,onOpenFolder:a}){const[o,c]=j.useState(t?"installed":"idle"),[u,d]=j.useState(!1),[h,p]=j.useState(""),[m,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 xe("/api/plugins/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({githubUrl:e.githubUrl})}),W=await M.json();if(M.ok)c("installed"),e.latestVersion&&g(e.latestVersion),W.loaded||p(W.loadError??"Plugin installed but failed to load");else throw new Error(W.error??"Install failed")},[e.githubUrl,e.name]),_=async()=>{c("installing"),p("");try{await S()}catch(M){c("error"),p(M instanceof Error?M.message:"Connection error")}},b=()=>{w(!0)},k=async()=>{v(!0);try{(await xe(`/api/plugins/${e.name}`,{method:"DELETE"})).ok&&(c("idle"),r(e.name))}catch{}v(!1),w(!1)},E=async()=>{d(!0),p("");try{await S()}catch(M){p(M instanceof Error?M.message:"Update failed")}d(!1)},T=m??n,D=e.latestVersion&&T&&T!=="unknown"&&e.latestVersion!==T,A=o==="installing"?"Installing…":u?"Updating…":o==="installed"?"Installed ✓":"Install",R=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:R,children:A}),D&&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(pl,{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 s7(){const[e,t]=j.useState([]),[n,r]=j.useState([]),[a,o]=j.useState({}),[c,u]=j.useState(!0),[d,h]=j.useState(""),[p,m]=j.useState("");j.useEffect(()=>{let S=!1;Promise.all([xe("/api/plugins/registry").then(b=>{if(!b.ok)throw new Error(`HTTP ${b.status}`);return b.json()}),xe("/api/plugins/installed").then(b=>b.ok?b.json():{installed:[]})]).then(([b,k])=>{if(S)return;const E={},T=k.installed;for(const W of T)E[W.name]=W.version;o(E);const D=b.plugins.map(W=>({...W,latestVersion:null,versionLoading:!0}));t(D),D.forEach(W=>{px(W.githubUrl).then($=>{S||t(G=>G.map(B=>B.name===W.name?{...B,latestVersion:$,versionLoading:!1}:B))})});const A=new Set(D.map(W=>W.name)),R=rh(),M=[];for(const W of T)!A.has(W.name)&&!R.some($=>$.name===W.name)&&M.push({name:W.name,displayName:W.name,description:"Found on disk",githubUrl:"",latestVersion:null,versionLoading:!1});M.length>0&&r(W=>[...W,...M])}).catch(b=>{S||h(b instanceof Error?b.message:"Failed to load plugins")}).finally(()=>{S||u(!1)});const _=rh();return _.length>0&&(r(_.map(b=>({...b,latestVersion:null,versionLoading:!0}))),_.forEach(b=>{px(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 xe(`/api/plugins/${S}/open-folder`):await xe("/api/plugins/open-folder")}catch{}},x=j.useCallback(S=>{o(k=>{const E={...k};return delete E[S],E});const _=rh(),b=_.filter(k=>k.name!==S);b.length!==_.length&&FC(b),r(k=>k.filter(E=>E.name!==S))},[]),w=j.useCallback(S=>{if(new Set(e.map(k=>k.name)).has(S.name)){m(`"${S.displayName}" is already listed in the registry and won't be added again.`);return}const b=rh();FC([...b,S]),r(k=>[...k,{...S,latestVersion:null,versionLoading:!0}]),px(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]}),p&&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:p}),s.jsx("button",{onClick:()=>m(""),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(n7,{onAdd:w})]}),v.length===0&&!d&&s.jsx("div",{className:"text-sm text-text-muted",children:"No plugins found."}),v.map(S=>s.jsx(r7,{plugin:S,initiallyInstalled:S.name in a,installedVersion:a[S.name]??null,onRemove:x,onOpenFolder:g},S.name))]})}function i7({isOpen:e,onClose:t}){const[n,r]=j.useState("instructions"),a=ui(c=>c.status==="available"),o=()=>{try{zt.send("context.checkDynamic",{})}catch{}t()};return s.jsx(wt,{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(ht,{horizontal:!0,options:{scrollbars:{visibility:"hidden"}},className:"flex border-b border-border mb-4 flex-shrink-0 px-4 pt-4",children:[s.jsx(zi,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),s.jsx(zi,{label:"Tools",active:n==="tools",onClick:()=>r("tools")}),s.jsx(zi,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),s.jsx(zi,{label:"Plugins",active:n==="plugins",onClick:()=>r("plugins")}),s.jsx(zi,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),s.jsx(zi,{label:"Display",active:n==="display",onClick:()=>r("display")}),s.jsx(zi,{label:"Keybindings",active:n==="keybindings",onClick:()=>r("keybindings")}),s.jsx(zi,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced"),showDot:a})]}),s.jsxs(ht,{className:"flex-1 min-h-0 px-4 pb-4",children:[n==="instructions"&&s.jsx(T3,{isOpen:e}),n==="skills"&&s.jsx(N3,{isOpen:e}),n==="plugins"&&s.jsx(s7,{}),n==="notifications"&&s.jsx(y3,{}),n==="display"&&s.jsx(U3,{}),n==="keybindings"&&s.jsx(QF,{}),n==="tools"&&s.jsx(e7,{}),n==="advanced"&&s.jsx(YF,{onClose:t})]})]})})}function zi({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 gx={exports:{}},UC;function a7(){return UC||(UC=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,D=arguments.length,A=D<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 R=_.length-1;R>=0;R--)(T=_[R])&&(A=(D<3?T(A):D>3?T(b,k,A):T(b,k))||A);return D>3&&A&&Object.defineProperty(b,k,A),A},p=this&&this.__param||function(_,b){return function(k,E){b(k,E,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.AccessibilityManager=void 0;const m=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+=m.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(_){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(_)||this._charsToConsume.push(_)}_refreshRows(_,b){this._liveRegionDebouncer.refresh(_,b,this._terminal.rows)}_renderRows(_,b){const k=this._terminal.buffer,E=k.lines.length.toString();for(let T=_;T<=b;T++){const D=k.lines.get(k.ydisp+T),A=[],R=(D==null?void 0:D.translateToString(!0,void 0,void 0,A))||"",M=(k.ydisp+T+1).toString(),W=this._rowElements[T];W&&(R.length===0?(W.innerText=" ",this._rowColumns.set(W,[0,1])):(W.textContent=R,this._rowColumns.set(W,A)),W.setAttribute("aria-posinset",M),W.setAttribute("aria-setsize",E))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(_,b){const k=_.target,E=this._rowElements[b===0?1:this._rowElements.length-2];if(k.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||_.relatedTarget!==E)return;let T,D;if(b===0?(T=k,D=this._rowElements.pop(),this._rowContainer.removeChild(D)):(T=this._rowElements.shift(),D=k,this._rowContainer.removeChild(T)),T.removeEventListener("focus",this._topBoundaryFocusListener),D.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const 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 R;if(this._rowElements.length===0)return;const _=document.getSelection();if(!_)return;if(_.isCollapsed)return void(this._rowContainer.contains(_.anchorNode)&&this._terminal.clearSelection());if(!_.anchorNode||!_.focusNode)return void console.error("anchorNode and/or focusNode are null");let b={node:_.anchorNode,offset:_.anchorOffset},k={node:_.focusNode,offset:_.focusOffset};if((b.node.compareDocumentPosition(k.node)&Node.DOCUMENT_POSITION_PRECEDING||b.node===k.node&&b.offset>k.offset)&&([b,k]=[k,b]),b.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(b={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(b.node))return;const E=this._rowElements.slice(-1)[0];if(k.node.compareDocumentPosition(E)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(k={node:E,offset:((R=E.textContent)==null?void 0:R.length)??0}),!this._rowContainer.contains(k.node))return;const T=({node:M,offset:W})=>{const $=M instanceof Text?M.parentNode:M;let G=parseInt($==null?void 0:$.getAttribute("aria-posinset"),10)-1;if(isNaN(G))return console.warn("row is invalid. Race condition?"),null;const B=this._rowColumns.get($);if(!B)return console.warn("columns is null. Race condition?"),null;let H=W<B.length?B[W]:B.slice(-1)[0]+1;return H>=this._terminal.cols&&(++G,H=0),{row:G,column:H}},D=T(b),A=T(k);if(D&&A){if(D.row>A.row||D.row===A.row&&D.column>=A.column)throw new Error("invalid range");this._terminal.select(D.column,D.row,(A.row-D.row)*this._terminal.cols-D.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([p(1,C.IInstantiationService),p(2,w.ICoreBrowserService),p(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 p(g,x,w,C){g=h(g=d(g),w.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(g,!0),x.value=""}function m(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&&p(g.clipboardData.getData("text/plain"),x,w,C)},u.paste=p,u.moveTextAreaUnderMouseCursor=m,u.rightClickHandler=function(g,x,w,C,v){m(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(p,m,g){this._css.set(p,m,g)}getCss(p,m){return this._css.get(p,m)}setColor(p,m,g){this._color.set(p,m,g)}getColor(p,m){return this._color.get(p,m)}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,p,m){d.addEventListener(h,p,m);let g=!1;return{dispose:()=>{g||(g=!0,d.removeEventListener(h,p,m))}}}},3551:function(c,u,d){var h=this&&this.__decorate||function(S,_,b,k){var E,T=arguments.length,D=T<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,b):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,_,b,k);else for(var A=S.length-1;A>=0;A--)(E=S[A])&&(D=(T<3?E(D):T>3?E(_,b,D):E(_,b))||D);return T>3&&D&&Object.defineProperty(_,b,D),D},p=this&&this.__param||function(S,_){return function(b,k){_(b,k,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.Linkifier=void 0;const m=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,m.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,m.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(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((D=>{D.link.dispose&&D.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=S.y);let b=!1;for(const[T,D]of this._linkProviderService.linkProviders.entries())_?(E=this._activeProviderReplies)!=null&&E.get(T)&&(b=this._checkLinkProviderResult(T,S,b)):D.provideLinks(S.y,(A=>{var M,W;if(this._isMouseOut)return;const R=A==null?void 0:A.map(($=>({link:$})));(M=this._activeProviderReplies)==null||M.set(T,R),b=this._checkLinkProviderResult(T,S,b),((W=this._activeProviderReplies)==null?void 0:W.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 D=E[T],A=D.link.range.start.y<S?0:D.link.range.start.x,R=D.link.range.end.y>S?this._bufferService.cols:D.link.range.end.x;for(let M=A;M<=R;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 D=0;D<S;D++)this._activeProviderReplies.has(D)&&!this._activeProviderReplies.get(D)||(E=!0);if(!E&&k){const D=k.find((A=>this._linkAtPosition(A.link,_)));D&&(b=!0,this._handleNewLink(D))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!b)for(let D=0;D<this._activeProviderReplies.size;D++){const A=(T=this._activeProviderReplies.get(D))==null?void 0:T.find((R=>this._linkAtPosition(R.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([p(1,C.IMouseService),p(2,C.IRenderService),p(3,w.IBufferService),p(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},p=this&&this.__param||function(C,v){return function(S,_){v(S,_,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OscLinkProvider=void 0;const m=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 R;const S=this._bufferService.buffer.lines.get(C-1);if(!S)return void v(void 0);const _=[],b=this._optionsService.rawOptions.linkHandler,k=new m.CellData,E=S.getTrimmedLength();let T=-1,D=-1,A=!1;for(let M=0;M<E;M++)if(D!==-1||S.hasContent(M)){if(S.loadCell(M,k),k.hasExtendedAttrs()&&k.extended.urlId){if(D===-1){D=M,T=k.extended.urlId;continue}A=k.extended.urlId!==T}else D!==-1&&(A=!0);if(A||D!==-1&&M===E-1){const W=(R=this._oscLinkService.getLinkData(T))==null?void 0:R.uri;if(W){const $={start:{x:D+1,y:C},end:{x:M+(A||M!==E-1?0:1),y:C}};let G=!1;if(!(b!=null&&b.allowNonHttpProtocols))try{const B=new URL(W);["http:","https:"].includes(B.protocol)||(G=!0)}catch{G=!0}G||_.push({text:W,range:$,activate:(B,H)=>b?b.activate(B,H,$):w(0,H),hover:(B,H)=>{var q;return(q=b==null?void 0:b.hover)==null?void 0:q.call(b,B,H,$)},leave:(B,H)=>{var q;return(q=b==null?void 0:b.leave)==null?void 0:q.call(b,B,H,$)}})}A=!1,k.hasExtendedAttrs()&&k.extended.urlId?(D=M,T=k.extended.urlId):(D=-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([p(0,g.IBufferService),p(1,g.IOptionsService),p(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,p){this._rowCount=p,d=d!==void 0?d:0,h=h!==void 0?h:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,d):d,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,h):h,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const d=Math.max(this._rowStart,0),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,h),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const d of this._refreshCallbacks)d(0);this._refreshCallbacks=[]}}},3236:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.Terminal=void 0;const h=d(3614),p=d(3656),m=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),D=d(3230),A=d(9312),R=d(4725),M=d(6731),W=d(8055),$=d(8969),G=d(8460),B=d(844),H=d(6114),q=d(8437),Q=d(2584),J=d(7399),U=d(5941),I=d(9074),O=d(2585),V=d(5435),z=d(4567),Y=d(779);class X extends $.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(F={}){super(F),this.browser=H,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new B.MutableDisposable),this._onCursorMove=this.register(new G.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new G.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new G.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new G.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new G.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new G.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new G.EventEmitter),this._onBlur=this.register(new G.EventEmitter),this._onA11yCharEmitter=this.register(new G.EventEmitter),this._onA11yTabEmitter=this.register(new G.EventEmitter),this._onWillOpen=this.register(new G.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(I.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Y.LinkProviderService),this._instantiationService.setService(R.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((P,te)=>this.refresh(P,te)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((P=>this._reportWindowsOptions(P)))),this.register(this._inputHandler.onColor((P=>this._handleColorEvent(P)))),this.register((0,G.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,G.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,G.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,G.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((P=>this._afterResize(P.cols,P.rows)))),this.register((0,B.toDisposable)((()=>{var P,te;this._customKeyEventHandler=void 0,(te=(P=this.element)==null?void 0:P.parentNode)==null||te.removeChild(this.element)})))}_handleColorEvent(F){if(this._themeService)for(const P of F){let te,se="";switch(P.index){case 256:te="foreground",se="10";break;case 257:te="background",se="11";break;case 258:te="cursor",se="12";break;default:te="ansi",se="4;"+P.index}switch(P.type){case 0:const re=W.color.toColorRGB(te==="ansi"?this._themeService.colors.ansi[P.index]:this._themeService.colors[te]);this.coreService.triggerDataEvent(`${Q.C0.ESC}]${se};${(0,U.toRgbString)(re)}${Q.C1_ESCAPED.ST}`);break;case 1:if(te==="ansi")this._themeService.modifyColors((ae=>ae.ansi[P.index]=W.channels.toColor(...P.color)));else{const ae=te;this._themeService.modifyColors((ye=>ye[ae]=W.channels.toColor(...P.color)))}break;case 2:this._themeService.restoreColor(P.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(F){F?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(z.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(F){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var F;return(F=this.textarea)==null?void 0:F.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.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 F=this.buffer.ybase+this.buffer.y,P=this.buffer.lines.get(F);if(!P)return;const te=Math.min(this.buffer.x,this.cols-1),se=this._renderService.dimensions.css.cell.height,re=P.getWidth(te),ae=this._renderService.dimensions.css.cell.width*re,ye=this.buffer.y*this._renderService.dimensions.css.cell.height,_e=te*this._renderService.dimensions.css.cell.width;this.textarea.style.left=_e+"px",this.textarea.style.top=ye+"px",this.textarea.style.width=ae+"px",this.textarea.style.height=se+"px",this.textarea.style.lineHeight=se+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,p.addDisposableDomListener)(this.element,"copy",(P=>{this.hasSelection()&&(0,h.copyHandler)(P,this._selectionService)})));const F=P=>(0,h.handlePasteEvent)(P,this.textarea,this.coreService,this.optionsService);this.register((0,p.addDisposableDomListener)(this.textarea,"paste",F)),this.register((0,p.addDisposableDomListener)(this.element,"paste",F)),H.isFirefox?this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(P=>{P.button===2&&(0,h.rightClickHandler)(P,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,p.addDisposableDomListener)(this.element,"contextmenu",(P=>{(0,h.rightClickHandler)(P,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),H.isLinux&&this.register((0,p.addDisposableDomListener)(this.element,"auxclick",(P=>{P.button===1&&(0,h.moveTextAreaUnderMouseCursor)(P,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,p.addDisposableDomListener)(this.textarea,"keyup",(F=>this._keyUp(F)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keydown",(F=>this._keyDown(F)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keypress",(F=>this._keyPress(F)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionupdate",(F=>this._compositionHelper.compositionupdate(F)))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,p.addDisposableDomListener)(this.textarea,"input",(F=>this._inputEvent(F)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(F){var te;if(!F)throw new Error("Terminal requires a parent element.");if(F.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((te=this.element)==null?void 0:te.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=F.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"),F.appendChild(this.element);const P=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),P.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,p.addDisposableDomListener)(this.screenElement,"mousemove",(se=>this.updateCursorStyle(se)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),P.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),H.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,F.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(R.ICoreBrowserService,this._coreBrowserService),this.register((0,p.addDisposableDomListener)(this.textarea,"focus",(se=>this._handleTextAreaFocus(se)))),this.register((0,p.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(b.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(R.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(M.ThemeService),this._instantiationService.setService(R.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(k.CharacterJoinerService),this._instantiationService.setService(R.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(D.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(R.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((se=>this._onRender.fire(se)))),this.onResize((se=>this._renderService.resize(se.cols,se.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(R.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(m.Linkifier,this.screenElement)),this.element.appendChild(P);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(w.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((se=>this.scrollLines(se.amount,se.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(R.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((se=>this.scrollLines(se.amount,se.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((se=>this._renderService.handleSelectionChanged(se.start,se.end,se.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((se=>{this.textarea.value=se,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((se=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,p.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(C.BufferDecorationRenderer,this.screenElement)),this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(se=>this._selectionService.handleMouseDown(se)))),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(z.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(se=>this._handleScreenReaderModeOptionChange(se)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(v.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(se=>{!this._overviewRulerRenderer&&se&&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 F=this,P=this.element;function te(ae){const ye=F._mouseService.getMouseReportCoords(ae,F.screenElement);if(!ye)return!1;let _e,Ie;switch(ae.overrideType||ae.type){case"mousemove":Ie=32,ae.buttons===void 0?(_e=3,ae.button!==void 0&&(_e=ae.button<3?ae.button:3)):_e=1&ae.buttons?0:4&ae.buttons?1:2&ae.buttons?2:3;break;case"mouseup":Ie=0,_e=ae.button<3?ae.button:3;break;case"mousedown":Ie=1,_e=ae.button<3?ae.button:3;break;case"wheel":if(F._customWheelEventHandler&&F._customWheelEventHandler(ae)===!1||F.viewport.getLinesScrolled(ae)===0)return!1;Ie=ae.deltaY<0?0:1,_e=4;break;default:return!1}return!(Ie===void 0||_e===void 0||_e>4)&&F.coreMouseService.triggerMouseEvent({col:ye.col,row:ye.row,x:ye.x,y:ye.y,button:_e,action:Ie,ctrl:ae.ctrlKey,alt:ae.altKey,shift:ae.shiftKey})}const se={mouseup:null,wheel:null,mousedrag:null,mousemove:null},re={mouseup:ae=>(te(ae),ae.buttons||(this._document.removeEventListener("mouseup",se.mouseup),se.mousedrag&&this._document.removeEventListener("mousemove",se.mousedrag)),this.cancel(ae)),wheel:ae=>(te(ae),this.cancel(ae,!0)),mousedrag:ae=>{ae.buttons&&te(ae)},mousemove:ae=>{ae.buttons||te(ae)}};this.register(this.coreMouseService.onProtocolChange((ae=>{ae?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(ae)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&ae?se.mousemove||(P.addEventListener("mousemove",re.mousemove),se.mousemove=re.mousemove):(P.removeEventListener("mousemove",se.mousemove),se.mousemove=null),16&ae?se.wheel||(P.addEventListener("wheel",re.wheel,{passive:!1}),se.wheel=re.wheel):(P.removeEventListener("wheel",se.wheel),se.wheel=null),2&ae?se.mouseup||(se.mouseup=re.mouseup):(this._document.removeEventListener("mouseup",se.mouseup),se.mouseup=null),4&ae?se.mousedrag||(se.mousedrag=re.mousedrag):(this._document.removeEventListener("mousemove",se.mousedrag),se.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,p.addDisposableDomListener)(P,"mousedown",(ae=>{if(ae.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(ae))return te(ae),se.mouseup&&this._document.addEventListener("mouseup",se.mouseup),se.mousedrag&&this._document.addEventListener("mousemove",se.mousedrag),this.cancel(ae)}))),this.register((0,p.addDisposableDomListener)(P,"wheel",(ae=>{if(!se.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(ae)===!1)return!1;if(!this.buffer.hasScrollback){const ye=this.viewport.getLinesScrolled(ae);if(ye===0)return;const _e=Q.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(ae.deltaY<0?"A":"B");let Ie="";for(let He=0;He<Math.abs(ye);He++)Ie+=_e;return this.coreService.triggerDataEvent(Ie,!0),this.cancel(ae,!0)}return this.viewport.handleWheel(ae)?this.cancel(ae):void 0}}),{passive:!1})),this.register((0,p.addDisposableDomListener)(P,"touchstart",(ae=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(ae),this.cancel(ae)}),{passive:!0})),this.register((0,p.addDisposableDomListener)(P,"touchmove",(ae=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(ae)?void 0:this.cancel(ae)}),{passive:!1}))}refresh(F,P){var te;(te=this._renderService)==null||te.refreshRows(F,P)}updateCursorStyle(F){var P;(P=this._selectionService)!=null&&P.shouldColumnSelect(F)?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(F,P,te=0){var se;te===1?(super.scrollLines(F,P,te),this.refresh(0,this.rows-1)):(se=this.viewport)==null||se.scrollLines(F)}paste(F){(0,h.paste)(F,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(F){this._customKeyEventHandler=F}attachCustomWheelEventHandler(F){this._customWheelEventHandler=F}registerLinkProvider(F){return this._linkProviderService.registerLinkProvider(F)}registerCharacterJoiner(F){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const P=this._characterJoinerService.register(F);return this.refresh(0,this.rows-1),P}deregisterCharacterJoiner(F){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(F)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(F){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+F)}registerDecoration(F){return this._decorationService.registerDecoration(F)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(F,P,te){this._selectionService.setSelection(F,P,te)}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 F;(F=this._selectionService)==null||F.clearSelection()}selectAll(){var F;(F=this._selectionService)==null||F.selectAll()}selectLines(F,P){var te;(te=this._selectionService)==null||te.selectLines(F,P)}_keyDown(F){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(F)===!1)return!1;const P=this.browser.isMac&&this.options.macOptionIsMeta&&F.altKey;if(!P&&!this._compositionHelper.keydown(F))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;P||F.key!=="Dead"&&F.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const te=(0,J.evaluateKeyboardEvent)(F,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(F),te.type===3||te.type===2){const se=this.rows-1;return this.scrollLines(te.type===2?-se:se),this.cancel(F,!0)}return te.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,F)||(te.cancel&&this.cancel(F,!0),!te.key||!!(F.key&&!F.ctrlKey&&!F.altKey&&!F.metaKey&&F.key.length===1&&F.key.charCodeAt(0)>=65&&F.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(te.key!==Q.C0.ETX&&te.key!==Q.C0.CR||(this.textarea.value=""),this._onKey.fire({key:te.key,domEvent:F}),this._showCursor(),this.coreService.triggerDataEvent(te.key,!0),!this.optionsService.rawOptions.screenReaderMode||F.altKey||F.ctrlKey?this.cancel(F,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(F,P){const te=F.isMac&&!this.options.macOptionIsMeta&&P.altKey&&!P.ctrlKey&&!P.metaKey||F.isWindows&&P.altKey&&P.ctrlKey&&!P.metaKey||F.isWindows&&P.getModifierState("AltGraph");return P.type==="keypress"?te:te&&(!P.keyCode||P.keyCode>47)}_keyUp(F){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(F)===!1||((function(P){return P.keyCode===16||P.keyCode===17||P.keyCode===18})(F)||this.focus(),this.updateCursorStyle(F),this._keyPressHandled=!1)}_keyPress(F){let P;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(F)===!1)return!1;if(this.cancel(F),F.charCode)P=F.charCode;else if(F.which===null||F.which===void 0)P=F.keyCode;else{if(F.which===0||F.charCode===0)return!1;P=F.which}return!(!P||(F.altKey||F.ctrlKey||F.metaKey)&&!this._isThirdLevelShift(this.browser,F)||(P=String.fromCharCode(P),this._onKey.fire({key:P,domEvent:F}),this._showCursor(),this.coreService.triggerDataEvent(P,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(F){if(F.data&&F.inputType==="insertText"&&(!F.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const P=F.data;return this.coreService.triggerDataEvent(P,!0),this.cancel(F),!0}return!1}resize(F,P){F!==this.cols||P!==this.rows?super.resize(F,P):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(F,P){var te,se;(te=this._charSizeService)==null||te.measure(),(se=this.viewport)==null||se.syncScrollArea(!0)}clear(){var F;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let P=1;P<this.rows;P++)this.buffer.lines.push(this.buffer.getBlankLine(q.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(F=this.viewport)==null||F.reset(),this.refresh(0,this.rows-1)}}reset(){var P,te;this.options.rows=this.rows,this.options.cols=this.cols;const F=this._customKeyEventHandler;this._setup(),super.reset(),(P=this._selectionService)==null||P.reset(),this._decorationService.reset(),(te=this.viewport)==null||te.reset(),this._customKeyEventHandler=F,this.refresh(0,this.rows-1)}clearTextureAtlas(){var F;(F=this._renderService)==null||F.clearTextureAtlas()}_reportFocus(){var F;(F=this.element)!=null&&F.classList.contains("focus")?this.coreService.triggerDataEvent(Q.C0.ESC+"[I"):this.coreService.triggerDataEvent(Q.C0.ESC+"[O")}_reportWindowsOptions(F){if(this._renderService)switch(F){case V.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const P=this._renderService.dimensions.css.canvas.width.toFixed(0),te=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.C0.ESC}[4;${te};${P}t`);break;case V.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const se=this._renderService.dimensions.css.cell.width.toFixed(0),re=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.C0.ESC}[6;${re};${se}t`)}}cancel(F,P){if(this.options.cancelEvents||P)return F.preventDefault(),F.stopPropagation(),!1}}u.Terminal=X},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,p){this._rowCount=p,d=d!==void 0?d:0,h=h!==void 0?h:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,d):d,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,h):h;const m=Date.now();if(m-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=m,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=m-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,D=T<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,b):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,_,b,k);else for(var A=S.length-1;A>=0;A--)(E=S[A])&&(D=(T<3?E(D):T>3?E(_,b,D):E(_,b))||D);return T>3&&D&&Object.defineProperty(_,b,D),D},p=this&&this.__param||function(S,_){return function(b,k){_(b,k,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.Viewport=void 0;const m=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,D,A){super(),this._viewportElement=S,this._scrollArea=_,this._bufferService=b,this._optionsService=k,this._charSizeService=E,this._renderService=T,this._coreBrowserService=D,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,m.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((R=>this._activeBuffer=R.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((R=>this._renderDimensions=R))),this._handleThemeChange(A.colors),this.register(A.onChangeColors((R=>this._handleThemeChange(R)))),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,D=this._bufferService.buffer.lines;for(let R=S;R<T;R++){const M=D.get(R);if(!M)continue;const W=(A=D.get(R+1))==null?void 0:A.isWrapped;if(k+=M.translateToString(!W),!W||R===D.length-1){const $=document.createElement("div");$.textContent=k,E.push($),k.length>0&&(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([p(2,C.IBufferService),p(3,C.IOptionsService),p(4,g.ICharSizeService),p(5,g.IRenderService),p(6,g.ICoreBrowserService),p(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},p=this&&this.__param||function(C,v){return function(S,_){v(S,_,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.BufferDecorationRenderer=void 0;const m=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([p(1,x.IBufferService),p(2,m.ICoreBrowserService),p(3,x.IDecorationService),p(4,m.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,p){return h>=d.startBufferLine-this._linePadding[p||"full"]&&h<=d.endBufferLine+this._linePadding[p||"full"]}_addLineToZone(d,h){d.startBufferLine=Math.min(d.startBufferLine,h),d.endBufferLine=Math.max(d.endBufferLine,h)}}},5744:function(c,u,d){var h=this&&this.__decorate||function(b,k,E,T){var D,A=arguments.length,R=A<3?k:T===null?T=Object.getOwnPropertyDescriptor(k,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,k,E,T);else for(var M=b.length-1;M>=0;M--)(D=b[M])&&(R=(A<3?D(R):A>3?D(k,E,R):D(k,E))||R);return A>3&&R&&Object.defineProperty(k,E,R),R},p=this&&this.__param||function(b,k){return function(E,T){k(E,T,b)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OverviewRulerRenderer=void 0;const m=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,D,A,R){var W;super(),this._viewportElement=b,this._screenElement=k,this._bufferService=E,this._decorationService=T,this._renderService=D,this._optionsService=A,this._coreBrowserService=R,this._colorZoneStore=new m.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(W=this._viewportElement.parentElement)==null||W.insertBefore(this._canvas,this._viewportElement);const M=this._canvas.getContext("2d");if(!M)throw new Error("Ctx cannot be null");this._ctx=M,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,x.toDisposable)((()=>{var $;($=this._canvas)==null||$.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([p(2,w.IBufferService),p(3,w.IDecorationService),p(4,g.IRenderService),p(5,w.IOptionsService),p(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},p=this&&this.__param||function(C,v){return function(S,_){v(S,_,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CompositionHelper=void 0;const m=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([p(2,g.IBufferService),p(3,g.IOptionsService),p(4,g.ICoreService),p(5,m.IRenderService)],w)},9806:(c,u)=>{function d(h,p,m){const g=m.getBoundingClientRect(),x=h.getComputedStyle(m),w=parseInt(x.getPropertyValue("padding-left")),C=parseInt(x.getPropertyValue("padding-top"));return[p.clientX-g.left-w,p.clientY-g.top-C]}Object.defineProperty(u,"__esModule",{value:!0}),u.getCoords=u.getCoordsRelativeToElement=void 0,u.getCoordsRelativeToElement=d,u.getCoords=function(h,p,m,g,x,w,C,v,S){if(!w)return;const _=d(h,p,m);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 p(v,S,_,b){const k=v-m(v,_),E=S-m(S,_),T=Math.abs(k-E)-(function(D,A,R){let M=0;const W=D-m(D,R),$=A-m(A,R);for(let G=0;G<Math.abs(W-$);G++){const B=g(D,A)==="A"?-1:1,H=R.buffer.lines.get(W+B*G);H!=null&&H.isWrapped&&M++}return M})(v,S,_);return C(T,w(g(v,S),b))}function m(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,D=S,A="";for(;T!==_||D!==b;)T+=k?1:-1,k&&T>E.cols-1?(A+=E.buffer.translateBufferLineToString(D,!1,v,T),T=0,v=0,D++):!k&&T<0&&(A+=E.buffer.translateBufferLineToString(D,!1,0,v+1),T=E.cols-1,v=T,D--);return A+E.buffer.translateBufferLineToString(D,!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,R,M,W,$,G){return p(R,W,$,G).length===0?"":C(x(A,R,A,R-m(R,$),!1,$).length,w("D",G))})(k,E,0,S,_,b)+p(E,S,_,b)+(function(A,R,M,W,$,G){let B;B=p(R,W,$,G).length>0?W-m(W,$):R;const H=W,q=(function(Q,J,U,I,O,V){let z;return z=p(U,I,O,V).length>0?I-m(I,O):J,Q<U&&z<=I||Q>=U&&z<I?"C":"D"})(A,R,M,W,$,G);return C(x(A,B,M,H,q==="C",$).length,w(q,G))})(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 D=Math.abs(E-S);return C((function(A,R){return R.cols-A})(E>S?v:k,_)+(D-1)*_.cols+1+((E>S?k:v)-1),w(T,b))}},1296:function(c,u,d){var h=this&&this.__decorate||function(G,B,H,q){var Q,J=arguments.length,U=J<3?B:q===null?q=Object.getOwnPropertyDescriptor(B,H):q;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(G,B,H,q);else for(var I=G.length-1;I>=0;I--)(Q=G[I])&&(U=(J<3?Q(U):J>3?Q(B,H,U):Q(B,H))||U);return J>3&&U&&Object.defineProperty(B,H,U),U},p=this&&this.__param||function(G,B){return function(H,q){B(H,q,G)}};Object.defineProperty(u,"__esModule",{value:!0}),u.DomRenderer=void 0;const m=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",D="xterm-fg-",A="xterm-bg-",R="xterm-focus",M="xterm-selection";let W=1,$=u.DomRenderer=class extends b.Disposable{constructor(G,B,H,q,Q,J,U,I,O,V,z,Y,X){super(),this._terminal=G,this._document=B,this._element=H,this._screenElement=q,this._viewportElement=Q,this._helperContainer=J,this._linkifier2=U,this._charSizeService=O,this._optionsService=V,this._bufferService=z,this._coreBrowserService=Y,this._themeService=X,this._terminalClass=W++,this._rowElements=[],this._selectionRenderModel=(0,C.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new _.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(T),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(M),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,w.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((Z=>this._injectCss(Z)))),this._injectCss(this._themeService.colors),this._rowFactory=I.createInstance(m.DomRendererRowFactory,document),this._element.classList.add(E+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((Z=>this._handleLinkHover(Z)))),this.register(this._linkifier2.onHideLinkUnderline((Z=>this._handleLinkLeave(Z)))),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 G=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*G,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*G),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/G),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/G),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 H of this._rowElements)H.style.width=`${this.dimensions.css.canvas.width}px`,H.style.height=`${this.dimensions.css.cell.height}px`,H.style.lineHeight=`${this.dimensions.css.cell.height}px`,H.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const B=`${this._terminalSelector} .${T} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=B,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(G){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let B=`${this._terminalSelector} .${T} { color: ${G.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;B+=`${this._terminalSelector} .${T} .xterm-dim { color: ${S.color.multiplyOpacity(G.foreground,.5).css};}`,B+=`${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 H=`blink_underline_${this._terminalClass}`,q=`blink_bar_${this._terminalClass}`,Q=`blink_block_${this._terminalClass}`;B+=`@keyframes ${H} { 50% { border-bottom-style: hidden; }}`,B+=`@keyframes ${q} { 50% { box-shadow: none; }}`,B+=`@keyframes ${Q} { 0% { background-color: ${G.cursor.css}; color: ${G.cursorAccent.css}; } 50% { background-color: inherit; color: ${G.cursor.css}; }}`,B+=`${this._terminalSelector} .${T}.${R} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${H} 1s step-end infinite;}${this._terminalSelector} .${T}.${R} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${q} 1s step-end infinite;}${this._terminalSelector} .${T}.${R} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${Q} 1s step-end infinite;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block { background-color: ${G.cursor.css}; color: ${G.cursorAccent.css};}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${G.cursor.css} !important; color: ${G.cursorAccent.css} !important;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${G.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${G.cursor.css} inset;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${G.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,B+=`${this._terminalSelector} .${M} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${M} div { position: absolute; background-color: ${G.selectionBackgroundOpaque.css};}${this._terminalSelector} .${M} div { position: absolute; background-color: ${G.selectionInactiveBackgroundOpaque.css};}`;for(const[J,U]of G.ansi.entries())B+=`${this._terminalSelector} .${D}${J} { color: ${U.css}; }${this._terminalSelector} .${D}${J}.xterm-dim { color: ${S.color.multiplyOpacity(U,.5).css}; }${this._terminalSelector} .${A}${J} { background-color: ${U.css}; }`;B+=`${this._terminalSelector} .${D}${x.INVERTED_DEFAULT_COLOR} { color: ${S.color.opaque(G.background).css}; }${this._terminalSelector} .${D}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${S.color.multiplyOpacity(S.color.opaque(G.background),.5).css}; }${this._terminalSelector} .${A}${x.INVERTED_DEFAULT_COLOR} { background-color: ${G.foreground.css}; }`,this._themeStyleElement.textContent=B}_setDefaultSpacing(){const G=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${G}px`,this._rowFactory.defaultSpacing=G}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(G,B){for(let H=this._rowElements.length;H<=B;H++){const q=this._document.createElement("div");this._rowContainer.appendChild(q),this._rowElements.push(q)}for(;this._rowElements.length>B;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(G,B){this._refreshRowElements(G,B),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(R),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(R),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(G,B,H){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(G,B,H),this.renderRows(0,this._bufferService.rows-1),!G||!B)return;this._selectionRenderModel.update(this._terminal,G,B,H);const q=this._selectionRenderModel.viewportStartRow,Q=this._selectionRenderModel.viewportEndRow,J=this._selectionRenderModel.viewportCappedStartRow,U=this._selectionRenderModel.viewportCappedEndRow;if(J>=this._bufferService.rows||U<0)return;const I=this._document.createDocumentFragment();if(H){const O=G[0]>B[0];I.appendChild(this._createSelectionElement(J,O?B[0]:G[0],O?G[0]:B[0],U-J+1))}else{const O=q===J?G[0]:0,V=J===Q?B[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(J,O,V));const z=U-J-1;if(I.appendChild(this._createSelectionElement(J+1,0,this._bufferService.cols,z)),J!==U){const Y=Q===U?B[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(U,0,Y))}}this._selectionContainer.appendChild(I)}_createSelectionElement(G,B,H,q=1){const Q=this._document.createElement("div"),J=B*this.dimensions.css.cell.width;let U=this.dimensions.css.cell.width*(H-B);return J+U>this.dimensions.css.canvas.width&&(U=this.dimensions.css.canvas.width-J),Q.style.height=q*this.dimensions.css.cell.height+"px",Q.style.top=G*this.dimensions.css.cell.height+"px",Q.style.left=`${J}px`,Q.style.width=`${U}px`,Q}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 G of this._rowElements)G.replaceChildren()}renderRows(G,B){const H=this._bufferService.buffer,q=H.ybase+H.y,Q=Math.min(H.x,this._bufferService.cols-1),J=this._optionsService.rawOptions.cursorBlink,U=this._optionsService.rawOptions.cursorStyle,I=this._optionsService.rawOptions.cursorInactiveStyle;for(let O=G;O<=B;O++){const V=O+H.ydisp,z=this._rowElements[O],Y=H.lines.get(V);if(!z||!Y)break;z.replaceChildren(...this._rowFactory.createRow(Y,V,V===q,U,I,Q,J,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${E}${this._terminalClass}`}_handleLinkHover(G){this._setCellUnderline(G.x1,G.x2,G.y1,G.y2,G.cols,!0)}_handleLinkLeave(G){this._setCellUnderline(G.x1,G.x2,G.y1,G.y2,G.cols,!1)}_setCellUnderline(G,B,H,q,Q,J){H<0&&(G=0),q<0&&(B=0);const U=this._bufferService.rows-1;H=Math.max(Math.min(H,U),0),q=Math.max(Math.min(q,U),0),Q=Math.min(Q,this._bufferService.cols);const I=this._bufferService.buffer,O=I.ybase+I.y,V=Math.min(I.x,Q-1),z=this._optionsService.rawOptions.cursorBlink,Y=this._optionsService.rawOptions.cursorStyle,X=this._optionsService.rawOptions.cursorInactiveStyle;for(let Z=H;Z<=q;++Z){const F=Z+I.ydisp,P=this._rowElements[Z],te=I.lines.get(F);if(!P||!te)break;P.replaceChildren(...this._rowFactory.createRow(te,F,F===O,Y,X,V,z,this.dimensions.css.cell.width,this._widthCache,J?Z===H?G:0:-1,J?(Z===q?B:Q)-1:-1))}}};u.DomRenderer=$=h([p(7,k.IInstantiationService),p(8,v.ICharSizeService),p(9,k.IOptionsService),p(10,k.IBufferService),p(11,v.ICoreBrowserService),p(12,v.IThemeService)],$)},3787:function(c,u,d){var h=this&&this.__decorate||function(T,D,A,R){var M,W=arguments.length,$=W<3?D:R===null?R=Object.getOwnPropertyDescriptor(D,A):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")$=Reflect.decorate(T,D,A,R);else for(var G=T.length-1;G>=0;G--)(M=T[G])&&($=(W<3?M($):W>3?M(D,A,$):M(D,A))||$);return W>3&&$&&Object.defineProperty(D,A,$),$},p=this&&this.__param||function(T,D){return function(A,R){D(A,R,T)}};Object.defineProperty(u,"__esModule",{value:!0}),u.DomRendererRowFactory=void 0;const m=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,D,A,R,M,W,$){this._document=T,this._characterJoinerService=D,this._optionsService=A,this._coreBrowserService=R,this._coreService=M,this._decorationService=W,this._themeService=$,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(T,D,A){this._selectionStart=T,this._selectionEnd=D,this._columnSelectMode=A}createRow(T,D,A,R,M,W,$,G,B,H,q){const Q=[],J=this._characterJoinerService.getJoinedCharacters(D),U=this._themeService.colors;let I,O=T.getNoBgTrimmedLength();A&&O<W+1&&(O=W+1);let V=0,z="",Y=0,X=0,Z=0,F=!1,P=0,te=!1,se=0;const re=[],ae=H!==-1&&q!==-1;for(let ye=0;ye<O;ye++){T.loadCell(ye,this._workCell);let _e=this._workCell.getWidth();if(_e===0)continue;let Ie=!1,He=ye,je=this._workCell;if(J.length>0&&ye===J[0][0]){Ie=!0;const Ve=J.shift();je=new S.JoinedCellData(this._workCell,T.translateToString(!0,Ve[0],Ve[1]),Ve[1]-Ve[0]),He=Ve[1]-1,_e=je.getWidth()}const Ge=this._isCellInSelection(ye,D),Ze=A&&ye===W,Se=ae&&ye>=H&&ye<=q;let be=!1;this._decorationService.forEachDecorationAtCell(ye,D,void 0,(Ve=>{be=!0}));let de=je.getChars()||g.WHITESPACE_CELL_CHAR;if(de===" "&&(je.isUnderline()||je.isOverline())&&(de=" "),se=_e*G-B.get(de,je.isBold(),je.isItalic()),I){if(V&&(Ge&&te||!Ge&&!te&&je.bg===Y)&&(Ge&&te&&U.selectionForeground||je.fg===X)&&je.extended.ext===Z&&Se===F&&se===P&&!Ze&&!Ie&&!be){je.isInvisible()?z+=g.WHITESPACE_CELL_CHAR:z+=de,V++;continue}V&&(I.textContent=z),I=this._document.createElement("span"),V=0,z=""}else I=this._document.createElement("span");if(Y=je.bg,X=je.fg,Z=je.extended.ext,F=Se,P=se,te=Ge,Ie&&W>=ye&&W<=He&&(W=ye),!this._coreService.isCursorHidden&&Ze&&this._coreService.isCursorInitialized){if(re.push("xterm-cursor"),this._coreBrowserService.isFocused)$&&re.push("xterm-cursor-blink"),re.push(R==="bar"?"xterm-cursor-bar":R==="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(je.isBold()&&re.push("xterm-bold"),je.isItalic()&&re.push("xterm-italic"),je.isDim()&&re.push("xterm-dim"),z=je.isInvisible()?g.WHITESPACE_CELL_CHAR:je.getChars()||g.WHITESPACE_CELL_CHAR,je.isUnderline()&&(re.push(`xterm-underline-${je.extended.underlineStyle}`),z===" "&&(z=" "),!je.isUnderlineColorDefault()))if(je.isUnderlineColorRGB())I.style.textDecorationColor=`rgb(${b.AttributeData.toColorRGB(je.getUnderlineColor()).join(",")})`;else{let Ve=je.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&je.isBold()&&Ve<8&&(Ve+=8),I.style.textDecorationColor=U.ansi[Ve].css}je.isOverline()&&(re.push("xterm-overline"),z===" "&&(z=" ")),je.isStrikethrough()&&re.push("xterm-strikethrough"),Se&&(I.style.textDecoration="underline");let ie=je.getFgColor(),Pe=je.getFgColorMode(),Ue=je.getBgColor(),ue=je.getBgColorMode();const De=!!je.isInverse();if(De){const Ve=ie;ie=Ue,Ue=Ve;const et=Pe;Pe=ue,ue=et}let qe,pe,he,We=!1;switch(this._decorationService.forEachDecorationAtCell(ye,D,void 0,(Ve=>{Ve.options.layer!=="top"&&We||(Ve.backgroundColorRGB&&(ue=50331648,Ue=Ve.backgroundColorRGB.rgba>>8&16777215,qe=Ve.backgroundColorRGB),Ve.foregroundColorRGB&&(Pe=50331648,ie=Ve.foregroundColorRGB.rgba>>8&16777215,pe=Ve.foregroundColorRGB),We=Ve.options.layer==="top")})),!We&&Ge&&(qe=this._coreBrowserService.isFocused?U.selectionBackgroundOpaque:U.selectionInactiveBackgroundOpaque,Ue=qe.rgba>>8&16777215,ue=50331648,We=!0,U.selectionForeground&&(Pe=50331648,ie=U.selectionForeground.rgba>>8&16777215,pe=U.selectionForeground)),We&&re.push("xterm-decoration-top"),ue){case 16777216:case 33554432:he=U.ansi[Ue],re.push(`xterm-bg-${Ue}`);break;case 50331648:he=C.channels.toColor(Ue>>16,Ue>>8&255,255&Ue),this._addStyle(I,`background-color:#${E((Ue>>>0).toString(16),"0",6)}`);break;default:De?(he=U.foreground,re.push(`xterm-bg-${m.INVERTED_DEFAULT_COLOR}`)):he=U.background}switch(qe||je.isDim()&&(qe=C.color.multiplyOpacity(he,.5)),Pe){case 16777216:case 33554432:je.isBold()&&ie<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ie+=8),this._applyMinimumContrast(I,he,U.ansi[ie],je,qe,void 0)||re.push(`xterm-fg-${ie}`);break;case 50331648:const Ve=C.channels.toColor(ie>>16&255,ie>>8&255,255&ie);this._applyMinimumContrast(I,he,Ve,je,qe,pe)||this._addStyle(I,`color:#${E(ie.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(I,he,U.foreground,je,qe,pe)||De&&re.push(`xterm-fg-${m.INVERTED_DEFAULT_COLOR}`)}re.length&&(I.className=re.join(" "),re.length=0),Ze||Ie||be?I.textContent=z:V++,se!==this.defaultSpacing&&(I.style.letterSpacing=`${se}px`),Q.push(I),ye=He}return I&&V&&(I.textContent=z),Q}_applyMinimumContrast(T,D,A,R,M,W){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,_.treatGlyphAsBackgroundColor)(R.getCode()))return!1;const $=this._getContrastCache(R);let G;if(M||W||(G=$.getColor(D.rgba,A.rgba)),G===void 0){const B=this._optionsService.rawOptions.minimumContrastRatio/(R.isDim()?2:1);G=C.color.ensureContrastRatio(M||D,W||A,B),$.setColor((M||D).rgba,(W||A).rgba,G??null)}return!!G&&(this._addStyle(T,`color:${G.css}`),!0)}_getContrastCache(T){return T.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(T,D){T.setAttribute("style",`${T.getAttribute("style")||""}${D};`)}_isCellInSelection(T,D){const A=this._selectionStart,R=this._selectionEnd;return!(!A||!R)&&(this._columnSelectMode?A[0]<=R[0]?T>=A[0]&&D>=A[1]&&T<R[0]&&D<=R[1]:T<A[0]&&D>=A[1]&&T>=R[0]&&D<=R[1]:D>A[1]&&D<R[1]||A[1]===R[1]&&D===A[1]&&T>=A[0]&&T<R[0]||A[1]<R[1]&&D===R[1]&&T<R[0]||A[1]<R[1]&&D===A[1]&&T>=A[0])}};function E(T,D,A){for(;T.length<A;)T=D+T;return T}u.DomRendererRowFactory=k=h([p(1,v.ICharacterJoinerService),p(2,w.IOptionsService),p(3,v.ICoreBrowserService),p(4,w.ICoreService),p(5,w.IDecorationService),p(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 p=d.createElement("span");p.classList.add("xterm-char-measure-element");const m=d.createElement("span");m.classList.add("xterm-char-measure-element"),m.style.fontWeight="bold";const 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=[p,m,g,x],this._container.appendChild(p),this._container.appendChild(m),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,p,m){d===this._font&&h===this._fontSize&&p===this._weight&&m===this._weightBold||(this._font=d,this._fontSize=h,this._weight=p,this._weightBold=m,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${p}`,this._measureElements[1].style.fontWeight=`${m}`,this._measureElements[2].style.fontWeight=`${p}`,this._measureElements[3].style.fontWeight=`${m}`,this.clear())}get(d,h,p){let m=0;if(!h&&!p&&d.length===1&&(m=d.charCodeAt(0))<256){if(this._flat[m]!==-9999)return this._flat[m];const w=this._measure(d,0);return w>0&&(this._flat[m]=w),w}let g=d;h&&(g+="B"),p&&(g+="I");let x=this._holey.get(g);if(x===void 0){let w=0;h&&(w|=1),p&&(w|=2),x=this._measure(d,w),x>0&&this._holey.set(g,x)}return x}_measure(d,h){const p=this._measureElements[h];return p.textContent=d.repeat(32),p.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(p){return 57508<=p&&p<=57558}function h(p){return p>=128512&&p<=128591||p>=127744&&p<=128511||p>=128640&&p<=128767||p>=9728&&p<=9983||p>=9984&&p<=10175||p>=65024&&p<=65039||p>=129280&&p<=129535||p>=127462&&p<=127487}Object.defineProperty(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(p){if(!p)throw new Error("value must not be falsy");return p},u.isPowerlineGlyph=d,u.isRestrictedPowerlineGlyph=function(p){return 57520<=p&&p<=57527},u.isEmoji=h,u.allowRescaling=function(p,m,g,x){return m===1&&g>Math.ceil(1.5*x)&&p!==void 0&&p>255&&!h(p)&&!d(p)&&!(function(w){return 57344<=w&&w<=63743})(p)},u.treatGlyphAsBackgroundColor=function(p){return d(p)||(function(m){return 9472<=m&&m<=9631})(p)},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(p,m,g=0){return(p-(2*Math.round(m)-g))%(2*Math.round(m))}},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(p,m,g,x=!1){if(this.selectionStart=m,this.selectionEnd=g,!m||!g||m[0]===g[0]&&m[1]===g[1])return void this.clear();const w=p.buffers.active.ydisp,C=m[1]-w,v=g[1]-w,S=Math.max(C,0),_=Math.min(v,p.rows-1);S>=p.rows||_<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=x,this.viewportStartRow=C,this.viewportEndRow=v,this.viewportCappedStartRow=S,this.viewportCappedEndRow=_,this.startCol=m[0],this.endCol=g[0])}isCellSelected(p,m,g){return!!this.hasSelection&&(g-=p.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?m>=this.startCol&&g>=this.viewportCappedStartRow&&m<this.endCol&&g<=this.viewportCappedEndRow:m<this.startCol&&g>=this.viewportCappedStartRow&&m>=this.endCol&&g<=this.viewportCappedEndRow:g>this.viewportStartRow&&g<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&g===this.viewportStartRow&&m>=this.startCol&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&g===this.viewportEndRow&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&g===this.viewportStartRow&&m>=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,D=arguments.length,A=D<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 R=_.length-1;R>=0;R--)(T=_[R])&&(A=(D<3?T(A):D>3?T(b,k,A):T(b,k))||A);return D>3&&A&&Object.defineProperty(b,k,A),A},p=this&&this.__param||function(_,b){return function(k,E){b(k,E,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CharSizeService=void 0;const m=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([p(2,m.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,D=T<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,b):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,_,b,k);else for(var A=S.length-1;A>=0;A--)(E=S[A])&&(D=(T<3?E(D):T>3?E(_,b,D):E(_,b))||D);return T>3&&D&&Object.defineProperty(_,b,D),D},p=this&&this.__param||function(S,_){return function(b,k){_(b,k,S)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CharacterJoinerService=u.JoinedCellData=void 0;const m=d(3734),g=d(643),x=d(511),w=d(2585);class C extends m.AttributeData{constructor(_,b,k){super(),this.content=0,this.combinedData="",this.fg=_.fg,this.bg=_.bg,this.combinedData=b,this._width=k}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(_){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}u.JoinedCellData=C;let v=u.CharacterJoinerService=class WN{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,D=0,A=0,R=b.getFg(0),M=b.getBg(0);for(let W=0;W<b.getTrimmedLength();W++)if(b.loadCell(W,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==R||this._workCell.bg!==M){if(W-T>1){const $=this._getJoinedRanges(E,A,D,b,T);for(let G=0;G<$.length;G++)k.push($[G])}T=W,A=D,R=this._workCell.fg,M=this._workCell.bg}D+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-T>1){const W=this._getJoinedRanges(E,A,D,b,T);for(let $=0;$<W.length;$++)k.push(W[$])}return k}_getJoinedRanges(_,b,k,E,T){const D=_.substring(b,k);let A=[];try{A=this._characterJoiners[0].handler(D)}catch(R){console.error(R)}for(let R=1;R<this._characterJoiners.length;R++)try{const M=this._characterJoiners[R].handler(D);for(let W=0;W<M.length;W++)WN._mergeRanges(A,M[W])}catch(M){console.error(M)}return this._stringRangesToCellRanges(A,E,T),A}_stringRangesToCellRanges(_,b,k){let E=0,T=!1,D=0,A=_[E];if(A){for(let R=k;R<this._bufferService.cols;R++){const M=b.getWidth(R),W=b.getString(R).length||g.WHITESPACE_CELL_CHAR.length;if(M!==0){if(!T&&A[0]<=D&&(A[0]=R,T=!0),A[1]<=D){if(A[1]=R,A=_[++E],!A)break;A[0]<=D?(A[0]=R,T=!0):T=!1}D+=W}}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([p(0,w.IBufferService)],v)},5114:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CoreBrowserService=void 0;const h=d(844),p=d(8460),m=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 p.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new p.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((_=>this._screenDprMonitor.setWindow(_)))),this.register((0,p.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(C){this._window!==C&&(this._window=C,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}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 p.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,h.toDisposable)((()=>this.clearListener())))}setWindow(C){this._parentWindow=C,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,m.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var C;this._outerListener&&((C=this._resolutionMediaMatchList)==null||C.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.LinkProviderService=void 0;const h=d(844);class p extends h.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,h.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(g){return this.linkProviders.push(g),{dispose:()=>{const x=this.linkProviders.indexOf(g);x!==-1&&this.linkProviders.splice(x,1)}}}}u.LinkProviderService=p},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},p=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 m=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([p(0,m.IRenderService),p(1,m.ICharSizeService)],x)},3230:function(c,u,d){var h=this&&this.__decorate||function(_,b,k,E){var T,D=arguments.length,A=D<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 R=_.length-1;R>=0;R--)(T=_[R])&&(A=(D<3?T(A):D>3?T(b,k,A):T(b,k))||A);return D>3&&A&&Object.defineProperty(b,k,A),A},p=this&&this.__param||function(_,b){return function(k,E){b(k,E,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.RenderService=void 0;const m=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,D,A,R){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 m.RenderDebouncer(((M,W)=>this._renderRows(M,W)),A),this.register(this._renderDebouncer),this.register(A.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(D.onResize((()=>this._fullRefresh()))),this.register(D.buffers.onBufferActivate((()=>{var M;return(M=this._renderer.value)==null?void 0:M.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(T.onDecorationRegistered((()=>this._fullRefresh()))),this.register(T.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(D.cols,D.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(D.buffer.y,D.buffer.y,!0)))),this.register(R.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(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([p(2,v.IOptionsService),p(3,g.ICharSizeService),p(4,v.IDecorationService),p(5,v.IBufferService),p(6,g.ICoreBrowserService),p(7,g.IThemeService)],S)},9312:function(c,u,d){var h=this&&this.__decorate||function(A,R,M,W){var $,G=arguments.length,B=G<3?R:W===null?W=Object.getOwnPropertyDescriptor(R,M):W;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(A,R,M,W);else for(var H=A.length-1;H>=0;H--)($=A[H])&&(B=(G<3?$(B):G>3?$(R,M,B):$(R,M))||B);return G>3&&B&&Object.defineProperty(R,M,B),B},p=this&&this.__param||function(A,R){return function(M,W){R(M,W,A)}};Object.defineProperty(u,"__esModule",{value:!0}),u.SelectionService=void 0;const m=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 D=u.SelectionService=class extends v.Disposable{constructor(A,R,M,W,$,G,B,H,q){super(),this._element=A,this._screenElement=R,this._linkifier=M,this._bufferService=W,this._coreService=$,this._mouseService=G,this._optionsService=B,this._renderService=H,this._coreBrowserService=q,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=Q=>this._handleMouseMove(Q),this._mouseUpListener=Q=>this._handleMouseUp(Q),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((Q=>this._handleTrim(Q))),this.register(this._bufferService.buffers.onBufferActivate((Q=>this._handleBufferActivate(Q)))),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,R=this._model.finalSelectionEnd;return!(!A||!R||A[0]===R[0]&&A[1]===R[1])}get selectionText(){const A=this._model.finalSelectionStart,R=this._model.finalSelectionEnd;if(!A||!R)return"";const M=this._bufferService.buffer,W=[];if(this._activeSelectionMode===3){if(A[0]===R[0])return"";const $=A[0]<R[0]?A[0]:R[0],G=A[0]<R[0]?R[0]:A[0];for(let B=A[1];B<=R[1];B++){const H=M.translateBufferLineToString(B,!0,$,G);W.push(H)}}else{const $=A[1]===R[1]?R[0]:void 0;W.push(M.translateBufferLineToString(A[1],!0,A[0],$));for(let G=A[1]+1;G<=R[1]-1;G++){const B=M.lines.get(G),H=M.translateBufferLineToString(G,!0);B!=null&&B.isWrapped?W[W.length-1]+=H:W.push(H)}if(A[1]!==R[1]){const G=M.lines.get(R[1]),B=M.translateBufferLineToString(R[1],!0,0,R[0]);G&&G.isWrapped?W[W.length-1]+=B:W.push(B)}}return W.map(($=>$.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 R=this._getMouseBufferCoords(A),M=this._model.finalSelectionStart,W=this._model.finalSelectionEnd;return!!(M&&W&&R)&&this._areCoordsInSelection(R,M,W)}isCellInSelection(A,R){const M=this._model.finalSelectionStart,W=this._model.finalSelectionEnd;return!(!M||!W)&&this._areCoordsInSelection([A,R],M,W)}_areCoordsInSelection(A,R,M){return A[1]>R[1]&&A[1]<M[1]||R[1]===M[1]&&A[1]===R[1]&&A[0]>=R[0]&&A[0]<M[0]||R[1]<M[1]&&A[1]===M[1]&&A[0]<M[0]||R[1]<M[1]&&A[1]===R[1]&&A[0]>=R[0]}_selectWordAtCursor(A,R){var $,G;const M=(G=($=this._linkifier.currentLink)==null?void 0:$.link)==null?void 0:G.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,_.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const W=this._getMouseBufferCoords(A);return!!W&&(this._selectWordAt(W,R),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(A,R){this._model.clearSelection(),A=Math.max(A,0),R=Math.min(R,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,A],this._model.selectionEnd=[this._bufferService.cols,R],this.refresh(),this._onSelectionChange.fire()}_handleTrim(A){this._model.handleTrim(A)&&this.refresh()}_getMouseBufferCoords(A){const R=this._mouseService.getCoords(A,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(R)return R[0]--,R[1]--,R[1]+=this._bufferService.buffer.ydisp,R}_getMouseEventScrollAmount(A){let R=(0,m.getCoordsRelativeToElement)(this._coreBrowserService.window,A,this._screenElement)[1];const M=this._renderService.dimensions.css.canvas.height;return R>=0&&R<=M?0:(R>M&&(R-=M),R=Math.min(Math.max(R,-50),50),R/=50,R/Math.abs(R)+Math.round(14*R))}shouldForceSelection(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 R=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);R&&R.length!==this._model.selectionStart[0]&&R.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(A){this._selectWordAtCursor(A,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(A){const R=this._getMouseBufferCoords(A);R&&(this._activeSelectionMode=2,this._selectLineAt(R[1]))}shouldColumnSelect(A){return A.altKey&&!(S.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(A){if(A.stopImmediatePropagation(),!this._model.selectionStart)return;const R=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(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 W=M.lines.get(this._model.selectionEnd[1]);W&&W.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}R&&R[0]===this._model.selectionEnd[0]&&R[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const 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 R=A.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&R<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 W=(0,g.moveToCellSequence)(M[0]-1,M[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(W,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const A=this._model.finalSelectionStart,R=this._model.finalSelectionEnd,M=!(!A||!R||A[0]===R[0]&&A[1]===R[1]);M?A&&R&&(this._oldSelectionStart&&this._oldSelectionEnd&&A[0]===this._oldSelectionStart[0]&&A[1]===this._oldSelectionStart[1]&&R[0]===this._oldSelectionEnd[0]&&R[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(A,R,M)):this._oldHasSelection&&this._fireOnSelectionChange(A,R,M)}_fireOnSelectionChange(A,R,M){this._oldSelectionStart=A,this._oldSelectionEnd=R,this._oldHasSelection=M,this._onSelectionChange.fire()}_handleBufferActivate(A){this.clearSelection(),this._trimListener.dispose(),this._trimListener=A.activeBuffer.lines.onTrim((R=>this._handleTrim(R)))}_convertViewportColToCharacterIndex(A,R){let M=R;for(let W=0;R>=W;W++){const $=A.loadCell(W,this._workCell).getChars().length;this._workCell.getWidth()===0?M--:$>1&&R!==W&&(M+=$-1)}return M}setSelection(A,R,M){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[A,R],this._model.selectionStartLength=M,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(A){this._isClickInSelection(A)||(this._selectWordAtCursor(A,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(A,R,M=!0,W=!0){if(A[0]>=this._bufferService.cols)return;const $=this._bufferService.buffer,G=$.lines.get(A[1]);if(!G)return;const B=$.translateBufferLineToString(A[1],!1);let H=this._convertViewportColToCharacterIndex(G,A[0]),q=H;const Q=A[0]-H;let J=0,U=0,I=0,O=0;if(B.charAt(H)===" "){for(;H>0&&B.charAt(H-1)===" ";)H--;for(;q<B.length&&B.charAt(q+1)===" ";)q++}else{let Y=A[0],X=A[0];G.getWidth(Y)===0&&(J++,Y--),G.getWidth(X)===2&&(U++,X++);const Z=G.getString(X).length;for(Z>1&&(O+=Z-1,q+=Z-1);Y>0&&H>0&&!this._isCharWordSeparator(G.loadCell(Y-1,this._workCell));){G.loadCell(Y-1,this._workCell);const F=this._workCell.getChars().length;this._workCell.getWidth()===0?(J++,Y--):F>1&&(I+=F-1,H-=F-1),H--,Y--}for(;X<G.length&&q+1<B.length&&!this._isCharWordSeparator(G.loadCell(X+1,this._workCell));){G.loadCell(X+1,this._workCell);const F=this._workCell.getChars().length;this._workCell.getWidth()===2?(U++,X++):F>1&&(O+=F-1,q+=F-1),q++,X++}}q++;let V=H+Q-J+I,z=Math.min(this._bufferService.cols,q-H+J+U-I-O);if(R||B.slice(H,q).trim()!==""){if(M&&V===0&&G.getCodePoint(0)!==32){const Y=$.lines.get(A[1]-1);if(Y&&G.isWrapped&&Y.getCodePoint(this._bufferService.cols-1)!==32){const X=this._getWordAt([this._bufferService.cols-1,A[1]-1],!1,!0,!1);if(X){const Z=this._bufferService.cols-X.start;V-=Z,z+=Z}}}if(W&&V+z===this._bufferService.cols&&G.getCodePoint(this._bufferService.cols-1)!==32){const Y=$.lines.get(A[1]+1);if(Y!=null&&Y.isWrapped&&Y.getCodePoint(0)!==32){const X=this._getWordAt([0,A[1]+1],!1,!1,!0);X&&(z+=X.length)}}return{start:V,length:z}}}_selectWordAt(A,R){const M=this._getWordAt(A,R);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 R=this._getWordAt(A,!0);if(R){let M=A[1];for(;R.start<0;)R.start+=this._bufferService.cols,M--;if(!this._model.areSelectionValuesReversed())for(;R.start+R.length>this._bufferService.cols;)R.length-=this._bufferService.cols,M++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?R.start:R.start+R.length,M]}}_isCharWordSeparator(A){return A.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(A.getChars())>=0}_selectLineAt(A){const R=this._bufferService.buffer.getWrappedRangeForLine(A),M={start:{x:0,y:R.first},end:{x:this._bufferService.cols-1,y:R.last}};this._model.selectionStart=[0,R.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,_.getRangeLength)(M,this._bufferService.cols)}};u.SelectionService=D=h([p(3,k.IBufferService),p(4,k.ICoreService),p(5,w.IMouseService),p(6,k.IOptionsService),p(7,w.IRenderService),p(8,w.ICoreBrowserService)],D)},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(D,A,R,M){var W,$=arguments.length,G=$<3?A:M===null?M=Object.getOwnPropertyDescriptor(A,R):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")G=Reflect.decorate(D,A,R,M);else for(var B=D.length-1;B>=0;B--)(W=D[B])&&(G=($<3?W(G):$>3?W(A,R,G):W(A,R))||G);return $>3&&G&&Object.defineProperty(A,R,G),G},p=this&&this.__param||function(D,A){return function(R,M){A(R,M,D)}};Object.defineProperty(u,"__esModule",{value:!0}),u.ThemeService=u.DEFAULT_ANSI_COLORS=void 0;const m=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 D=[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 R=0;R<216;R++){const M=A[R/36%6|0],W=A[R/6%6|0],$=A[R%6];D.push({css:g.channels.toCss(M,W,$),rgba:g.channels.toRgba(M,W,$)})}for(let R=0;R<24;R++){const M=8+10*R;D.push({css:g.channels.toCss(M,M,M),rgba:g.channels.toRgba(M,M,M)})}return D})());let E=u.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(D){super(),this._optionsService=D,this._contrastCache=new m.ColorContrastCache,this._halfContrastCache=new m.ColorContrastCache,this._onChangeColors=this.register(new 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(D={}){const A=this._colors;if(A.foreground=T(D.foreground,v),A.background=T(D.background,S),A.cursor=T(D.cursor,_),A.cursorAccent=T(D.cursorAccent,b),A.selectionBackgroundTransparent=T(D.selectionBackground,k),A.selectionBackgroundOpaque=g.color.blend(A.background,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundTransparent=T(D.selectionInactiveBackground,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundOpaque=g.color.blend(A.background,A.selectionInactiveBackgroundTransparent),A.selectionForeground=D.selectionForeground?T(D.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(D.black,u.DEFAULT_ANSI_COLORS[0]),A.ansi[1]=T(D.red,u.DEFAULT_ANSI_COLORS[1]),A.ansi[2]=T(D.green,u.DEFAULT_ANSI_COLORS[2]),A.ansi[3]=T(D.yellow,u.DEFAULT_ANSI_COLORS[3]),A.ansi[4]=T(D.blue,u.DEFAULT_ANSI_COLORS[4]),A.ansi[5]=T(D.magenta,u.DEFAULT_ANSI_COLORS[5]),A.ansi[6]=T(D.cyan,u.DEFAULT_ANSI_COLORS[6]),A.ansi[7]=T(D.white,u.DEFAULT_ANSI_COLORS[7]),A.ansi[8]=T(D.brightBlack,u.DEFAULT_ANSI_COLORS[8]),A.ansi[9]=T(D.brightRed,u.DEFAULT_ANSI_COLORS[9]),A.ansi[10]=T(D.brightGreen,u.DEFAULT_ANSI_COLORS[10]),A.ansi[11]=T(D.brightYellow,u.DEFAULT_ANSI_COLORS[11]),A.ansi[12]=T(D.brightBlue,u.DEFAULT_ANSI_COLORS[12]),A.ansi[13]=T(D.brightMagenta,u.DEFAULT_ANSI_COLORS[13]),A.ansi[14]=T(D.brightCyan,u.DEFAULT_ANSI_COLORS[14]),A.ansi[15]=T(D.brightWhite,u.DEFAULT_ANSI_COLORS[15]),D.extendedAnsi){const R=Math.min(A.ansi.length-16,D.extendedAnsi.length);for(let M=0;M<R;M++)A.ansi[M+16]=T(D.extendedAnsi[M],u.DEFAULT_ANSI_COLORS[M+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(D){this._restoreColor(D),this._onChangeColors.fire(this.colors)}_restoreColor(D){if(D!==void 0)switch(D){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[D]=this._restoreColors.ansi[D]}else for(let A=0;A<this._restoreColors.ansi.length;++A)this._colors.ansi[A]=this._restoreColors.ansi[A]}modifyColors(D){D(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function T(D,A){if(D!==void 0)try{return g.css.toColor(D)}catch{}return A}u.ThemeService=E=h([p(0,C.IOptionsService)],E)},6349:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.CircularList=void 0;const h=d(8460),p=d(844);class m extends p.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=m},1439:(c,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.clone=void 0,u.clone=function d(h,p=5){if(typeof h!="object")return h;const m=Array.isArray(h)?[]:{};for(const g in h)m[g]=p<=1?h[g]:h[g]&&d(h[g],p-1);return m}},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,p=0,m=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,D){return D!==void 0?`#${S(k)}${S(E)}${S(T)}${S(D)}`:`#${S(k)}${S(E)}${S(T)}`},b.toRgba=function(k,E,T,D=255){return(k<<24|E<<16|T<<8|D)>>>0},b.toColor=function(k,E,T,D){return{css:b.toCss(k,E,T,D),rgba:b.toRgba(k,E,T,D)}}})(g||(u.channels=g={})),(function(b){function k(E,T){return m=Math.round(255*T),[d,h,p]=v.toChannels(E.rgba),{css:g.toCss(d,h,p,m),rgba:g.toRgba(d,h,p,m)}}b.blend=function(E,T){if(m=(255&T.rgba)/255,m===1)return{css:T.css,rgba:T.rgba};const D=T.rgba>>24&255,A=T.rgba>>16&255,R=T.rgba>>8&255,M=E.rgba>>24&255,W=E.rgba>>16&255,$=E.rgba>>8&255;return d=M+Math.round((D-M)*m),h=W+Math.round((A-W)*m),p=$+Math.round((R-$)*m),{css:g.toCss(d,h,p),rgba:g.toRgba(d,h,p)}},b.isOpaque=function(E){return(255&E.rgba)==255},b.ensureContrastRatio=function(E,T,D){const A=v.ensureContrastRatio(E.rgba,T.rgba,D);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,p]=v.toChannels(T),{css:g.toCss(d,h,p),rgba:T}},b.opacity=k,b.multiplyOpacity=function(E,T){return m=255&E.rgba,k(E,m*T/255)},b.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(x||(u.color=x={})),(function(b){let k,E;try{const T=document.createElement("canvas");T.width=1,T.height=1;const D=T.getContext("2d",{willReadFrequently:!0});D&&(k=D,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}catch{}b.toColor=function(T){if(T.match(/#[\da-f]{3,8}/i))switch(T.length){case 4:return d=parseInt(T.slice(1,2).repeat(2),16),h=parseInt(T.slice(2,3).repeat(2),16),p=parseInt(T.slice(3,4).repeat(2),16),g.toColor(d,h,p);case 5:return d=parseInt(T.slice(1,2).repeat(2),16),h=parseInt(T.slice(2,3).repeat(2),16),p=parseInt(T.slice(3,4).repeat(2),16),m=parseInt(T.slice(4,5).repeat(2),16),g.toColor(d,h,p,m);case 7:return{css:T,rgba:(parseInt(T.slice(1),16)<<8|255)>>>0};case 9:return{css:T,rgba:parseInt(T.slice(1),16)>>>0}}const D=T.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(D)return d=parseInt(D[1]),h=parseInt(D[2]),p=parseInt(D[3]),m=Math.round(255*(D[5]===void 0?1:parseFloat(D[5]))),g.toColor(d,h,p,m);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=T,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[d,h,p,m]=k.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:g.toRgba(d,h,p,m),css:T}}})(w||(u.css=w={})),(function(b){function k(E,T,D){const A=E/255,R=T/255,M=D/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}b.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},b.relativeLuminance2=k})(C||(u.rgb=C={})),(function(b){function k(T,D,A){const R=T>>24&255,M=T>>16&255,W=T>>8&255;let $=D>>24&255,G=D>>16&255,B=D>>8&255,H=_(C.relativeLuminance2($,G,B),C.relativeLuminance2(R,M,W));for(;H<A&&($>0||G>0||B>0);)$-=Math.max(0,Math.ceil(.1*$)),G-=Math.max(0,Math.ceil(.1*G)),B-=Math.max(0,Math.ceil(.1*B)),H=_(C.relativeLuminance2($,G,B),C.relativeLuminance2(R,M,W));return($<<24|G<<16|B<<8|255)>>>0}function E(T,D,A){const R=T>>24&255,M=T>>16&255,W=T>>8&255;let $=D>>24&255,G=D>>16&255,B=D>>8&255,H=_(C.relativeLuminance2($,G,B),C.relativeLuminance2(R,M,W));for(;H<A&&($<255||G<255||B<255);)$=Math.min(255,$+Math.ceil(.1*(255-$))),G=Math.min(255,G+Math.ceil(.1*(255-G))),B=Math.min(255,B+Math.ceil(.1*(255-B))),H=_(C.relativeLuminance2($,G,B),C.relativeLuminance2(R,M,W));return($<<24|G<<16|B<<8|255)>>>0}b.blend=function(T,D){if(m=(255&D)/255,m===1)return D;const A=D>>24&255,R=D>>16&255,M=D>>8&255,W=T>>24&255,$=T>>16&255,G=T>>8&255;return d=W+Math.round((A-W)*m),h=$+Math.round((R-$)*m),p=G+Math.round((M-G)*m),g.toRgba(d,h,p)},b.ensureContrastRatio=function(T,D,A){const R=C.relativeLuminance(T>>8),M=C.relativeLuminance(D>>8);if(_(R,M)<A){if(M<R){const G=k(T,D,A),B=_(R,C.relativeLuminance(G>>8));if(B<A){const H=E(T,D,A);return B>_(R,C.relativeLuminance(H>>8))?G:H}return G}const W=E(T,D,A),$=_(R,C.relativeLuminance(W>>8));if($<A){const G=k(T,D,A);return $>_(R,C.relativeLuminance(G>>8))?W:G}return W}},b.reduceLuminance=k,b.increaseLuminance=E,b.toChannels=function(T){return[T>>24&255,T>>16&255,T>>8&255,255&T]}})(v||(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),p=d(2585),m=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),D=d(2660);let A=!1;class R extends h.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new v.EventEmitter),this._onScroll.event((W=>{var $;($=this._onScrollApi)==null||$.fire(W.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(W){for(const $ in W)this.optionsService.options[$]=W[$]}constructor(W){super(),this._windowsWrappingHeuristics=this.register(new h.MutableDisposable),this._onBinary=this.register(new v.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new v.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new v.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new v.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new v.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new v.EventEmitter),this._instantiationService=new m.InstantiationService,this.optionsService=this.register(new w.OptionsService(W)),this._instantiationService.setService(p.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(x.BufferService)),this._instantiationService.setService(p.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(p.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(C.CoreService)),this._instantiationService.setService(p.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(S.CoreMouseService)),this._instantiationService.setService(p.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(_.UnicodeService)),this._instantiationService.setService(p.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(b.CharsetService),this._instantiationService.setService(p.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(D.OscLinkService),this._instantiationService.setService(p.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new E.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,v.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,v.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,v.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,v.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll(($=>{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(($=>{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((($,G)=>this._inputHandler.parse($,G)))),this.register((0,v.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(W,$){this._writeBuffer.write(W,$)}writeSync(W,$){this._logService.logLevel<=p.LogLevelEnum.WARN&&!A&&(this._logService.warn("writeSync is unreliable and will be removed soon."),A=!0),this._writeBuffer.writeSync(W,$)}input(W,$=!0){this.coreService.triggerDataEvent(W,$)}resize(W,$){isNaN(W)||isNaN($)||(W=Math.max(W,x.MINIMUM_COLS),$=Math.max($,x.MINIMUM_ROWS),this._bufferService.resize(W,$))}scroll(W,$=!1){this._bufferService.scroll(W,$)}scrollLines(W,$,G){this._bufferService.scrollLines(W,$,G)}scrollPages(W){this.scrollLines(W*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(W){const $=W-this._bufferService.buffer.ydisp;$!==0&&this.scrollLines($)}registerEscHandler(W,$){return this._inputHandler.registerEscHandler(W,$)}registerDcsHandler(W,$){return this._inputHandler.registerDcsHandler(W,$)}registerCsiHandler(W,$){return this._inputHandler.registerCsiHandler(W,$)}registerOscHandler(W,$){return this._inputHandler.registerOscHandler(W,$)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let W=!1;const $=this.optionsService.rawOptions.windowsPty;$&&$.buildNumber!==void 0&&$.buildNumber!==void 0?W=$.backend==="conpty"&&$.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(W=!0),W?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const W=[];W.push(this.onLineFeed(k.updateWindowsModeWrappedState.bind(null,this._bufferService))),W.push(this.registerCsiHandler({final:"H"},(()=>((0,k.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,h.toDisposable)((()=>{for(const $ of W)$.dispose()}))}}}u.CoreTerminal=R},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 p=[];for(let m=0;m<this._listeners.length;m++)p.push(this._listeners[m]);for(let m=0;m<p.length;m++)p[m].call(void 0,d,h)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},u.forwardEvent=function(d,h){return d((p=>h.fire(p)))},u.runAndSubscribe=function(d,h){return h(void 0),d((p=>h(p)))}},5435:function(c,u,d){var h=this&&this.__decorate||function(J,U,I,O){var V,z=arguments.length,Y=z<3?U:O===null?O=Object.getOwnPropertyDescriptor(U,I):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Y=Reflect.decorate(J,U,I,O);else for(var X=J.length-1;X>=0;X--)(V=J[X])&&(Y=(z<3?V(Y):z>3?V(U,I,Y):V(U,I))||Y);return z>3&&Y&&Object.defineProperty(U,I,Y),Y},p=this&&this.__param||function(J,U){return function(I,O){U(I,O,J)}};Object.defineProperty(u,"__esModule",{value:!0}),u.InputHandler=u.WindowsOptionsReportType=void 0;const m=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),D=d(6242),A=d(6351),R=d(5941),M={"(":0,")":1,"*":2,"+":3,"-":1,".":2},W=131072;function $(J,U){if(J>24)return U.setWinLines||!1;switch(J){case 1:return!!U.restoreWin;case 2:return!!U.minimizeWin;case 3:return!!U.setWinPosition;case 4:return!!U.setWinSizePixels;case 5:return!!U.raiseWin;case 6:return!!U.lowerWin;case 7:return!!U.refreshWin;case 8:return!!U.setWinSizeChars;case 9:return!!U.maximizeWin;case 10:return!!U.fullscreenWin;case 11:return!!U.getWinState;case 13:return!!U.getWinPosition;case 14:return!!U.getWinSizePixels;case 15:return!!U.getScreenSizePixels;case 16:return!!U.getCellSizePixels;case 18:return!!U.getWinSizeChars;case 19:return!!U.getScreenSizeChars;case 20:return!!U.getIconTitle;case 21:return!!U.getWinTitle;case 22:return!!U.pushTitle;case 23:return!!U.popTitle;case 24:return!!U.setWinLines}return!1}var G;(function(J){J[J.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",J[J.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(G||(u.WindowsOptionsReportType=G={}));let B=0;class H extends w.Disposable{getAttrData(){return this._curAttrData}constructor(U,I,O,V,z,Y,X,Z,F=new x.EscapeSequenceParser){super(),this._bufferService=U,this._charsetService=I,this._coreService=O,this._logService=V,this._optionsService=z,this._oscLinkService=Y,this._coreMouseService=X,this._unicodeService=Z,this._parser=F,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 q(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((P=>this._activeBuffer=P.activeBuffer))),this._parser.setCsiHandlerFallback(((P,te)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(P),params:te.toArray()})})),this._parser.setEscHandlerFallback((P=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(P)})})),this._parser.setExecuteHandlerFallback((P=>{this._logService.debug("Unknown EXECUTE code: ",{code:P})})),this._parser.setOscHandlerFallback(((P,te,se)=>{this._logService.debug("Unknown OSC code: ",{identifier:P,action:te,data:se})})),this._parser.setDcsHandlerFallback(((P,te,se)=>{te==="HOOK"&&(se=se.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(P),action:te,payload:se})})),this._parser.setPrintHandler(((P,te,se)=>this.print(P,te,se))),this._parser.registerCsiHandler({final:"@"},(P=>this.insertChars(P))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(P=>this.scrollLeft(P))),this._parser.registerCsiHandler({final:"A"},(P=>this.cursorUp(P))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(P=>this.scrollRight(P))),this._parser.registerCsiHandler({final:"B"},(P=>this.cursorDown(P))),this._parser.registerCsiHandler({final:"C"},(P=>this.cursorForward(P))),this._parser.registerCsiHandler({final:"D"},(P=>this.cursorBackward(P))),this._parser.registerCsiHandler({final:"E"},(P=>this.cursorNextLine(P))),this._parser.registerCsiHandler({final:"F"},(P=>this.cursorPrecedingLine(P))),this._parser.registerCsiHandler({final:"G"},(P=>this.cursorCharAbsolute(P))),this._parser.registerCsiHandler({final:"H"},(P=>this.cursorPosition(P))),this._parser.registerCsiHandler({final:"I"},(P=>this.cursorForwardTab(P))),this._parser.registerCsiHandler({final:"J"},(P=>this.eraseInDisplay(P,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(P=>this.eraseInDisplay(P,!0))),this._parser.registerCsiHandler({final:"K"},(P=>this.eraseInLine(P,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(P=>this.eraseInLine(P,!0))),this._parser.registerCsiHandler({final:"L"},(P=>this.insertLines(P))),this._parser.registerCsiHandler({final:"M"},(P=>this.deleteLines(P))),this._parser.registerCsiHandler({final:"P"},(P=>this.deleteChars(P))),this._parser.registerCsiHandler({final:"S"},(P=>this.scrollUp(P))),this._parser.registerCsiHandler({final:"T"},(P=>this.scrollDown(P))),this._parser.registerCsiHandler({final:"X"},(P=>this.eraseChars(P))),this._parser.registerCsiHandler({final:"Z"},(P=>this.cursorBackwardTab(P))),this._parser.registerCsiHandler({final:"`"},(P=>this.charPosAbsolute(P))),this._parser.registerCsiHandler({final:"a"},(P=>this.hPositionRelative(P))),this._parser.registerCsiHandler({final:"b"},(P=>this.repeatPrecedingCharacter(P))),this._parser.registerCsiHandler({final:"c"},(P=>this.sendDeviceAttributesPrimary(P))),this._parser.registerCsiHandler({prefix:">",final:"c"},(P=>this.sendDeviceAttributesSecondary(P))),this._parser.registerCsiHandler({final:"d"},(P=>this.linePosAbsolute(P))),this._parser.registerCsiHandler({final:"e"},(P=>this.vPositionRelative(P))),this._parser.registerCsiHandler({final:"f"},(P=>this.hVPosition(P))),this._parser.registerCsiHandler({final:"g"},(P=>this.tabClear(P))),this._parser.registerCsiHandler({final:"h"},(P=>this.setMode(P))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(P=>this.setModePrivate(P))),this._parser.registerCsiHandler({final:"l"},(P=>this.resetMode(P))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(P=>this.resetModePrivate(P))),this._parser.registerCsiHandler({final:"m"},(P=>this.charAttributes(P))),this._parser.registerCsiHandler({final:"n"},(P=>this.deviceStatus(P))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(P=>this.deviceStatusPrivate(P))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(P=>this.softReset(P))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(P=>this.setCursorStyle(P))),this._parser.registerCsiHandler({final:"r"},(P=>this.setScrollRegion(P))),this._parser.registerCsiHandler({final:"s"},(P=>this.saveCursor(P))),this._parser.registerCsiHandler({final:"t"},(P=>this.windowOptions(P))),this._parser.registerCsiHandler({final:"u"},(P=>this.restoreCursor(P))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(P=>this.insertColumns(P))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(P=>this.deleteColumns(P))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(P=>this.selectProtected(P))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(P=>this.requestMode(P,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(P=>this.requestMode(P,!1))),this._parser.setExecuteHandler(m.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(m.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(m.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(m.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(m.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(m.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(m.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(m.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(m.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new D.OscHandler((P=>(this.setTitle(P),this.setIconName(P),!0)))),this._parser.registerOscHandler(1,new D.OscHandler((P=>this.setIconName(P)))),this._parser.registerOscHandler(2,new D.OscHandler((P=>this.setTitle(P)))),this._parser.registerOscHandler(4,new D.OscHandler((P=>this.setOrReportIndexedColor(P)))),this._parser.registerOscHandler(8,new D.OscHandler((P=>this.setHyperlink(P)))),this._parser.registerOscHandler(10,new D.OscHandler((P=>this.setOrReportFgColor(P)))),this._parser.registerOscHandler(11,new D.OscHandler((P=>this.setOrReportBgColor(P)))),this._parser.registerOscHandler(12,new D.OscHandler((P=>this.setOrReportCursorColor(P)))),this._parser.registerOscHandler(104,new D.OscHandler((P=>this.restoreIndexedColor(P)))),this._parser.registerOscHandler(110,new D.OscHandler((P=>this.restoreFgColor(P)))),this._parser.registerOscHandler(111,new D.OscHandler((P=>this.restoreBgColor(P)))),this._parser.registerOscHandler(112,new D.OscHandler((P=>this.restoreCursorColor(P)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const P in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:P},(()=>this.selectCharset("("+P))),this._parser.registerEscHandler({intermediates:")",final:P},(()=>this.selectCharset(")"+P))),this._parser.registerEscHandler({intermediates:"*",final:P},(()=>this.selectCharset("*"+P))),this._parser.registerEscHandler({intermediates:"+",final:P},(()=>this.selectCharset("+"+P))),this._parser.registerEscHandler({intermediates:"-",final:P},(()=>this.selectCharset("-"+P))),this._parser.registerEscHandler({intermediates:".",final:P},(()=>this.selectCharset("."+P))),this._parser.registerEscHandler({intermediates:"/",final:P},(()=>this.selectCharset("/"+P)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((P=>(this._logService.error("Parsing error: ",P),P))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new A.DcsHandler(((P,te)=>this.requestStatusString(P,te))))}_preserveStack(U,I,O,V){this._parseStack.paused=!0,this._parseStack.cursorStartX=U,this._parseStack.cursorStartY=I,this._parseStack.decodedLength=O,this._parseStack.position=V}_logSlowResolvingAsync(U){this._logService.logLevel<=E.LogLevelEnum.WARN&&Promise.race([U,new Promise(((I,O)=>setTimeout((()=>O("#SLOW_TIMEOUT")),5e3)))]).catch((I=>{if(I!=="#SLOW_TIMEOUT")throw I;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(U,I){let O,V=this._activeBuffer.x,z=this._activeBuffer.y,Y=0;const X=this._parseStack.paused;if(X){if(O=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,I))return this._logSlowResolvingAsync(O),O;V=this._parseStack.cursorStartX,z=this._parseStack.cursorStartY,this._parseStack.paused=!1,U.length>W&&(Y=this._parseStack.position+W)}if(this._logService.logLevel<=E.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof U=="string"?` "${U}"`:` "${Array.prototype.map.call(U,(P=>String.fromCharCode(P))).join("")}"`),typeof U=="string"?U.split("").map((P=>P.charCodeAt(0))):U),this._parseBuffer.length<U.length&&this._parseBuffer.length<W&&(this._parseBuffer=new Uint32Array(Math.min(U.length,W))),X||this._dirtyRowTracker.clearRange(),U.length>W)for(let P=Y;P<U.length;P+=W){const te=P+W<U.length?P+W:U.length,se=typeof U=="string"?this._stringDecoder.decode(U.substring(P,te),this._parseBuffer):this._utf8Decoder.decode(U.subarray(P,te),this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,se))return this._preserveStack(V,z,se,P),this._logSlowResolvingAsync(O),O}else if(!X){const P=typeof U=="string"?this._stringDecoder.decode(U,this._parseBuffer):this._utf8Decoder.decode(U,this._parseBuffer);if(O=this._parser.parse(this._parseBuffer,P))return this._preserveStack(V,z,P,0),this._logSlowResolvingAsync(O),O}this._activeBuffer.x===V&&this._activeBuffer.y===z||this._onCursorMove.fire();const Z=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),F=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);F<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(F,this._bufferService.rows-1),Math.min(Z,this._bufferService.rows-1))}print(U,I,O){let V,z;const Y=this._charsetService.charset,X=this._optionsService.rawOptions.screenReaderMode,Z=this._bufferService.cols,F=this._coreService.decPrivateModes.wraparound,P=this._coreService.modes.insertMode,te=this._curAttrData;let se=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&O-I>0&&se.getWidth(this._activeBuffer.x-1)===2&&se.setCellFromCodepoint(this._activeBuffer.x-1,0,1,te);let re=this._parser.precedingJoinState;for(let ae=I;ae<O;++ae){if(V=U[ae],V<127&&Y){const He=Y[String.fromCharCode(V)];He&&(V=He.charCodeAt(0))}const ye=this._unicodeService.charProperties(V,re);z=T.UnicodeService.extractWidth(ye);const _e=T.UnicodeService.extractShouldJoin(ye),Ie=_e?T.UnicodeService.extractWidth(re):0;if(re=ye,X&&this._onA11yChar.fire((0,C.stringFromCodePoint)(V)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+z-Ie>Z){if(F){const He=se;let je=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),se=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),Ie>0&&se instanceof v.BufferLine&&se.copyCellsFrom(He,je,0,Ie,!1);je<Z;)He.setCellFromCodepoint(je++,0,1,te)}else if(this._activeBuffer.x=Z-1,z===2)continue}if(_e&&this._activeBuffer.x){const He=se.getWidth(this._activeBuffer.x-1)?1:2;se.addCodepointToCell(this._activeBuffer.x-He,V,z);for(let je=z-Ie;--je>=0;)se.setCellFromCodepoint(this._activeBuffer.x++,0,0,te)}else if(P&&(se.insertCells(this._activeBuffer.x,z-Ie,this._activeBuffer.getNullCell(te)),se.getWidth(Z-1)===2&&se.setCellFromCodepoint(Z-1,_.NULL_CELL_CODE,_.NULL_CELL_WIDTH,te)),se.setCellFromCodepoint(this._activeBuffer.x++,V,z,te),z>0)for(;--z;)se.setCellFromCodepoint(this._activeBuffer.x++,0,0,te)}this._parser.precedingJoinState=re,this._activeBuffer.x<Z&&O-I>0&&se.getWidth(this._activeBuffer.x)===0&&!se.hasContent(this._activeBuffer.x)&&se.setCellFromCodepoint(this._activeBuffer.x,0,1,te),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(U,I){return U.final!=="t"||U.prefix||U.intermediates?this._parser.registerCsiHandler(U,I):this._parser.registerCsiHandler(U,(O=>!$(O.params[0],this._optionsService.rawOptions.windowOptions)||I(O)))}registerDcsHandler(U,I){return this._parser.registerDcsHandler(U,new A.DcsHandler(I))}registerEscHandler(U,I){return this._parser.registerEscHandler(U,I)}registerOscHandler(U,I){return this._parser.registerOscHandler(U,new D.OscHandler(I))}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 U;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&&((U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&U.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);I.hasWidth(this._activeBuffer.x)&&!I.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const U=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-U),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(U=this._bufferService.cols-1){this._activeBuffer.x=Math.min(U,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(U,I){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=U,this._activeBuffer.y=this._activeBuffer.scrollTop+I):(this._activeBuffer.x=U,this._activeBuffer.y=I),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(U,I){this._restrictCursor(),this._setCursor(this._activeBuffer.x+U,this._activeBuffer.y+I)}cursorUp(U){const I=this._activeBuffer.y-this._activeBuffer.scrollTop;return I>=0?this._moveCursor(0,-Math.min(I,U.params[0]||1)):this._moveCursor(0,-(U.params[0]||1)),!0}cursorDown(U){const I=this._activeBuffer.scrollBottom-this._activeBuffer.y;return I>=0?this._moveCursor(0,Math.min(I,U.params[0]||1)):this._moveCursor(0,U.params[0]||1),!0}cursorForward(U){return this._moveCursor(U.params[0]||1,0),!0}cursorBackward(U){return this._moveCursor(-(U.params[0]||1),0),!0}cursorNextLine(U){return this.cursorDown(U),this._activeBuffer.x=0,!0}cursorPrecedingLine(U){return this.cursorUp(U),this._activeBuffer.x=0,!0}cursorCharAbsolute(U){return this._setCursor((U.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(U){return this._setCursor(U.length>=2?(U.params[1]||1)-1:0,(U.params[0]||1)-1),!0}charPosAbsolute(U){return this._setCursor((U.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(U){return this._moveCursor(U.params[0]||1,0),!0}linePosAbsolute(U){return this._setCursor(this._activeBuffer.x,(U.params[0]||1)-1),!0}vPositionRelative(U){return this._moveCursor(0,U.params[0]||1),!0}hVPosition(U){return this.cursorPosition(U),!0}tabClear(U){const I=U.params[0];return I===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:I===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(U){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=U.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(U){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=U.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(U){const I=U.params[0];return I===1&&(this._curAttrData.bg|=536870912),I!==2&&I!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(U,I,O,V=!1,z=!1){const Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+U);Y.replaceCells(I,O,this._activeBuffer.getNullCell(this._eraseAttrData()),z),V&&(Y.isWrapped=!1)}_resetBufferLine(U,I=!1){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+U);O&&(O.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),I),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+U),O.isWrapped=!1)}eraseInDisplay(U,I=!1){let O;switch(this._restrictCursor(this._bufferService.cols),U.params[0]){case 0:for(O=this._activeBuffer.y,this._dirtyRowTracker.markDirty(O),this._eraseInBufferLine(O++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);O<this._bufferService.rows;O++)this._resetBufferLine(O,I);this._dirtyRowTracker.markDirty(O);break;case 1:for(O=this._activeBuffer.y,this._dirtyRowTracker.markDirty(O),this._eraseInBufferLine(O,0,this._activeBuffer.x+1,!0,I),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(O+1).isWrapped=!1);O--;)this._resetBufferLine(O,I);this._dirtyRowTracker.markDirty(0);break;case 2:for(O=this._bufferService.rows,this._dirtyRowTracker.markDirty(O-1);O--;)this._resetBufferLine(O,I);this._dirtyRowTracker.markDirty(0);break;case 3:const V=this._activeBuffer.lines.length-this._bufferService.rows;V>0&&(this._activeBuffer.lines.trimStart(V),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-V,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-V,0),this._onScroll.fire(0))}return!0}eraseInLine(U,I=!1){switch(this._restrictCursor(this._bufferService.cols),U.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,I);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,I)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(U){this._restrictCursor();let I=U.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=this._activeBuffer.ybase+this._activeBuffer.y,V=this._bufferService.rows-1-this._activeBuffer.scrollBottom,z=this._bufferService.rows-1+this._activeBuffer.ybase-V+1;for(;I--;)this._activeBuffer.lines.splice(z-1,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(U){this._restrictCursor();let I=U.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=this._activeBuffer.ybase+this._activeBuffer.y;let V;for(V=this._bufferService.rows-1-this._activeBuffer.scrollBottom,V=this._bufferService.rows-1+this._activeBuffer.ybase-V;I--;)this._activeBuffer.lines.splice(O,1),this._activeBuffer.lines.splice(V,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(U){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.insertCells(this._activeBuffer.x,U.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(U){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.deleteCells(this._activeBuffer.x,U.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(U){let I=U.params[0]||1;for(;I--;)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(U){let I=U.params[0]||1;for(;I--;)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(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=U.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);V.deleteCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),V.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=U.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);V.insertCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),V.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=U.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);V.insertCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),V.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=U.params[0]||1;for(let O=this._activeBuffer.scrollTop;O<=this._activeBuffer.scrollBottom;++O){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);V.deleteCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),V.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(U){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(U.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(U){const I=this._parser.precedingJoinState;if(!I)return!0;const O=U.params[0]||1,V=T.UnicodeService.extractWidth(I),z=this._activeBuffer.x-V,Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(z),X=new Uint32Array(Y.length*O);let Z=0;for(let P=0;P<Y.length;){const te=Y.codePointAt(P)||0;X[Z++]=te,P+=te>65535?2:1}let F=Z;for(let P=1;P<O;++P)X.copyWithin(F,0,Z),F+=Z;return this.print(X,0,F),!0}sendDeviceAttributesPrimary(U){return U.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(m.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(m.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(U){return U.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(m.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(m.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(U.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(m.C0.ESC+"[>83;40003;0c")),!0}_is(U){return(this._optionsService.rawOptions.termName+"").indexOf(U)===0}setMode(U){for(let I=0;I<U.length;I++)switch(U.params[I]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(U){for(let I=0;I<U.length;I++)switch(U.params[I]){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(U){for(let I=0;I<U.length;I++)switch(U.params[I]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(U){for(let I=0;I<U.length;I++)switch(U.params[I]){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(),U.params[I]===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(U,I){const O=this._coreService.decPrivateModes,{activeProtocol:V,activeEncoding:z}=this._coreMouseService,Y=this._coreService,{buffers:X,cols:Z}=this._bufferService,{active:F,alt:P}=X,te=this._optionsService.rawOptions,se=_e=>_e?1:2,re=U.params[0];return ae=re,ye=I?re===2?4:re===4?se(Y.modes.insertMode):re===12?3:re===20?se(te.convertEol):0:re===1?se(O.applicationCursorKeys):re===3?te.windowOptions.setWinLines?Z===80?2:Z===132?1:0:0:re===6?se(O.origin):re===7?se(O.wraparound):re===8?3:re===9?se(V==="X10"):re===12?se(te.cursorBlink):re===25?se(!Y.isCursorHidden):re===45?se(O.reverseWraparound):re===66?se(O.applicationKeypad):re===67?4:re===1e3?se(V==="VT200"):re===1002?se(V==="DRAG"):re===1003?se(V==="ANY"):re===1004?se(O.sendFocus):re===1005?4:re===1006?se(z==="SGR"):re===1015?4:re===1016?se(z==="SGR_PIXELS"):re===1048?1:re===47||re===1047||re===1049?se(F===P):re===2004?se(O.bracketedPasteMode):0,Y.triggerDataEvent(`${m.C0.ESC}[${I?"":"?"}${ae};${ye}$y`),!0;var ae,ye}_updateAttrColor(U,I,O,V,z){return I===2?(U|=50331648,U&=-16777216,U|=k.AttributeData.fromColorRGB([O,V,z])):I===5&&(U&=-50331904,U|=33554432|255&O),U}_extractColor(U,I,O){const V=[0,0,-1,0,0,0];let z=0,Y=0;do{if(V[Y+z]=U.params[I+Y],U.hasSubParams(I+Y)){const X=U.getSubParams(I+Y);let Z=0;do V[1]===5&&(z=1),V[Y+Z+1+z]=X[Z];while(++Z<X.length&&Z+Y+1+z<V.length);break}if(V[1]===5&&Y+z>=2||V[1]===2&&Y+z>=5)break;V[1]&&(z=1)}while(++Y+I<U.length&&Y+z<V.length);for(let X=2;X<V.length;++X)V[X]===-1&&(V[X]=0);switch(V[0]){case 38:O.fg=this._updateAttrColor(O.fg,V[1],V[3],V[4],V[5]);break;case 48:O.bg=this._updateAttrColor(O.bg,V[1],V[3],V[4],V[5]);break;case 58:O.extended=O.extended.clone(),O.extended.underlineColor=this._updateAttrColor(O.extended.underlineColor,V[1],V[3],V[4],V[5])}return Y}_processUnderline(U,I){I.extended=I.extended.clone(),(!~U||U>5)&&(U=1),I.extended.underlineStyle=U,I.fg|=268435456,U===0&&(I.fg&=-268435457),I.updateExtended()}_processSGR0(U){U.fg=v.DEFAULT_ATTR_DATA.fg,U.bg=v.DEFAULT_ATTR_DATA.bg,U.extended=U.extended.clone(),U.extended.underlineStyle=0,U.extended.underlineColor&=-67108864,U.updateExtended()}charAttributes(U){if(U.length===1&&U.params[0]===0)return this._processSGR0(this._curAttrData),!0;const I=U.length;let O;const V=this._curAttrData;for(let z=0;z<I;z++)O=U.params[z],O>=30&&O<=37?(V.fg&=-50331904,V.fg|=16777216|O-30):O>=40&&O<=47?(V.bg&=-50331904,V.bg|=16777216|O-40):O>=90&&O<=97?(V.fg&=-50331904,V.fg|=16777224|O-90):O>=100&&O<=107?(V.bg&=-50331904,V.bg|=16777224|O-100):O===0?this._processSGR0(V):O===1?V.fg|=134217728:O===3?V.bg|=67108864:O===4?(V.fg|=268435456,this._processUnderline(U.hasSubParams(z)?U.getSubParams(z)[0]:1,V)):O===5?V.fg|=536870912:O===7?V.fg|=67108864:O===8?V.fg|=1073741824:O===9?V.fg|=2147483648:O===2?V.bg|=134217728:O===21?this._processUnderline(2,V):O===22?(V.fg&=-134217729,V.bg&=-134217729):O===23?V.bg&=-67108865:O===24?(V.fg&=-268435457,this._processUnderline(0,V)):O===25?V.fg&=-536870913:O===27?V.fg&=-67108865:O===28?V.fg&=-1073741825:O===29?V.fg&=2147483647:O===39?(V.fg&=-67108864,V.fg|=16777215&v.DEFAULT_ATTR_DATA.fg):O===49?(V.bg&=-67108864,V.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):O===38||O===48||O===58?z+=this._extractColor(U,z,V):O===53?V.bg|=1073741824:O===55?V.bg&=-1073741825:O===59?(V.extended=V.extended.clone(),V.extended.underlineColor=-1,V.updateExtended()):O===100?(V.fg&=-67108864,V.fg|=16777215&v.DEFAULT_ATTR_DATA.fg,V.bg&=-67108864,V.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",O);return!0}deviceStatus(U){switch(U.params[0]){case 5:this._coreService.triggerDataEvent(`${m.C0.ESC}[0n`);break;case 6:const I=this._activeBuffer.y+1,O=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[${I};${O}R`)}return!0}deviceStatusPrivate(U){if(U.params[0]===6){const I=this._activeBuffer.y+1,O=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[?${I};${O}R`)}return!0}softReset(U){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(U){const I=U.params[0]||1;switch(I){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 O=I%2==1;return this._optionsService.options.cursorBlink=O,!0}setScrollRegion(U){const I=U.params[0]||1;let O;return(U.length<2||(O=U.params[1])>this._bufferService.rows||O===0)&&(O=this._bufferService.rows),O>I&&(this._activeBuffer.scrollTop=I-1,this._activeBuffer.scrollBottom=O-1,this._setCursor(0,0)),!0}windowOptions(U){if(!$(U.params[0],this._optionsService.rawOptions.windowOptions))return!0;const I=U.length>1?U.params[1]:0;switch(U.params[0]){case 14:I!==2&&this._onRequestWindowsOptionsReport.fire(G.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(G.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${m.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:I!==0&&I!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),I!==0&&I!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:I!==0&&I!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),I!==0&&I!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(U){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(U){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(U){return this._windowTitle=U,this._onTitleChange.fire(U),!0}setIconName(U){return this._iconName=U,!0}setOrReportIndexedColor(U){const I=[],O=U.split(";");for(;O.length>1;){const V=O.shift(),z=O.shift();if(/^\d+$/.exec(V)){const Y=parseInt(V);if(Q(Y))if(z==="?")I.push({type:0,index:Y});else{const X=(0,R.parseColor)(z);X&&I.push({type:1,index:Y,color:X})}}}return I.length&&this._onColor.fire(I),!0}setHyperlink(U){const I=U.split(";");return!(I.length<2)&&(I[1]?this._createHyperlink(I[0],I[1]):!I[0]&&this._finishHyperlink())}_createHyperlink(U,I){this._getCurrentLinkId()&&this._finishHyperlink();const O=U.split(":");let V;const z=O.findIndex((Y=>Y.startsWith("id=")));return z!==-1&&(V=O[z].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:V,uri:I}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(U,I){const O=U.split(";");for(let V=0;V<O.length&&!(I>=this._specialColors.length);++V,++I)if(O[V]==="?")this._onColor.fire([{type:0,index:this._specialColors[I]}]);else{const z=(0,R.parseColor)(O[V]);z&&this._onColor.fire([{type:1,index:this._specialColors[I],color:z}])}return!0}setOrReportFgColor(U){return this._setOrReportSpecialColor(U,0)}setOrReportBgColor(U){return this._setOrReportSpecialColor(U,1)}setOrReportCursorColor(U){return this._setOrReportSpecialColor(U,2)}restoreIndexedColor(U){if(!U)return this._onColor.fire([{type:2}]),!0;const I=[],O=U.split(";");for(let V=0;V<O.length;++V)if(/^\d+$/.exec(O[V])){const z=parseInt(O[V]);Q(z)&&I.push({type:2,index:z})}return I.length&&this._onColor.fire(I),!0}restoreFgColor(U){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(U){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(U){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(U){return U.length!==2?(this.selectDefaultCharset(),!0):(U[0]==="/"||this._charsetService.setgCharset(M[U[0]],g.CHARSETS[U[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 U=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,U,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(U){return this._charsetService.setgLevel(U),!0}screenAlignmentPattern(){const U=new b.CellData;U.content=4194373,U.fg=this._curAttrData.fg,U.bg=this._curAttrData.bg,this._setCursor(0,0);for(let I=0;I<this._bufferService.rows;++I){const O=this._activeBuffer.ybase+this._activeBuffer.y+I,V=this._activeBuffer.lines.get(O);V&&(V.fill(U),V.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(U,I){const O=this._bufferService.buffer,V=this._optionsService.rawOptions;return(z=>(this._coreService.triggerDataEvent(`${m.C0.ESC}${z}${m.C0.ESC}\\`),!0))(U==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:U==='"p'?'P1$r61;1"p':U==="r"?`P1$r${O.scrollTop+1};${O.scrollBottom+1}r`:U==="m"?"P1$r0m":U===" q"?`P1$r${{block:2,underline:4,bar:6}[V.cursorStyle]-(V.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(U,I){this._dirtyRowTracker.markRangeDirty(U,I)}}u.InputHandler=H;let q=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,U){J>U&&(B=J,J=U,U=B),J<this.start&&(this.start=J),U>this.end&&(this.end=U)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Q(J){return 0<=J&&J<256}q=h([p(0,E.IBufferService)],q)},844:(c,u)=>{function d(h){for(const p of h)p.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 p=this._disposables.indexOf(h);p!==-1&&this._disposables.splice(p,1)}},u.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(h){var p;this._isDisposed||h===this._value||((p=this._value)==null||p.dispose(),this._value=h)}clear(){this.value=void 0}dispose(){var h;this._isDisposed=!0,(h=this._value)==null||h.dispose(),this._value=void 0}},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(p,m,g){this._data[p]||(this._data[p]={}),this._data[p][m]=g}get(p,m){return this._data[p]?this._data[p][m]:void 0}clear(){this._data={}}}u.TwoKeyMap=d,u.FourKeyMap=class{constructor(){this._data=new d}set(h,p,m,g,x){this._data.get(h,p)||this._data.set(h,p,new d),this._data.get(h,p).set(m,g,x)}get(h,p,m,g){var x;return(x=this._data.get(h,p))==null?void 0:x.get(m,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 p=d.match(/Version\/(\d+)/);return p===null||p.length<2?0:parseInt(p[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 p=this._getKey(h);if(p===void 0||(d=this._search(p),d===-1)||this._getKey(this._array[d])!==p)return!1;do if(this._array[d]===h)return this._array.splice(d,1),!0;while(++d<this._array.length&&this._getKey(this._array[d])===p);return!1}*getKeyIterator(h){if(this._array.length!==0&&(d=this._search(h),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===h))do yield this._array[d];while(++d<this._array.length&&this._getKey(this._array[d])===h)}forEachByKey(h,p){if(this._array.length!==0&&(d=this._search(h),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===h))do p(this._array[d]);while(++d<this._array.length&&this._getKey(this._array[d])===h)}values(){return[...this._array].values()}_search(h){let p=0,m=this._array.length-1;for(;m>=p;){let g=p+m>>1;const x=this._getKey(this._array[g]);if(x>h)m=g-1;else{if(!(x<h)){for(;g>0&&this._getKey(this._array[g-1])===h;)g--;return g}p=g+1}}return p}}},7226:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DebouncedIdleTask=u.IdleTaskQueue=u.PriorityTaskQueue=void 0;const h=d(6114);class p{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 m extends p{_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=m,u.IdleTaskQueue=!h.isNode&&"requestIdleCallback"in window?class extends p{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:m,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(p){const m=p.buffer.lines.get(p.buffer.ybase+p.buffer.y-1),g=m==null?void 0:m.get(p.cols-1),x=p.buffer.lines.get(p.buffer.ybase+p.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(m){return[m>>>16&255,m>>>8&255,255&m]}static fromColorRGB(m){return(255&m[0])<<16|(255&m[1])<<8|255&m[2]}clone(){const m=new d;return m.fg=this.fg,m.bg=this.bg,m.extended=this.extended.clone(),m}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}u.AttributeData=d;class h{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(m){this._ext=m}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(m){this._ext&=-469762049,this._ext|=m<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(m){this._ext&=-67108864,this._ext|=67108863&m}get urlId(){return this._urlId}set urlId(m){this._urlId=m}get underlineVariantOffset(){const m=(3758096384&this._ext)>>29;return m<0?4294967288^m:m}set underlineVariantOffset(m){this._ext&=536870911,this._ext|=m<<29&3758096384}constructor(m=0,g=0){this._ext=0,this._urlId=0,this._ext=m,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),p=d(7226),m=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 p.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(_){return _?(this._nullCell.fg=_.fg,this._nullCell.bg=_.bg,this._nullCell.extended=_.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new m.ExtendedAttrs),this._nullCell}getWhitespaceCell(_){return _?(this._whitespaceCell.fg=_.fg,this._whitespaceCell.bg=_.bg,this._whitespaceCell.extended=_.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new m.ExtendedAttrs),this._whitespaceCell}getBlankLine(_,b){return new 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 D=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+D+1?(this.ybase--,D++,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),D&&(this.y+=D),this.savedX=Math.min(this.savedX,_-1),this.scrollTop=0}if(this.scrollBottom=b-1,this._isReflowEnabled&&(this._reflow(_,b),this._cols>_))for(let D=0;D<this.lines.length;D++)E+=+this.lines.get(D).resize(_,k);this._cols=_,this._rows=b,this._memoryCleanupQueue.clear(),E>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let _=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,_=!1);let b=0;for(;this._memoryCleanupPosition<this.lines.length;)if(b+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),b>100)return!0;return _}get _isReflowEnabled(){const _=this._optionsService.rawOptions.windowsPty;return _&&_.buildNumber?this._hasScrollback&&_.backend==="conpty"&&_.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(_,b){this._cols!==_&&(_>this._cols?this._reflowLarger(_,b):this._reflowSmaller(_,b))}_reflowLarger(_,b){const k=(0,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 D=this.lines.length-1;D>=0;D--){let A=this.lines.get(D);if(!A||!A.isWrapped&&A.getTrimmedLength()<=_)continue;const R=[A];for(;A.isWrapped&&D>0;)A=this.lines.get(--D),R.unshift(A);const M=this.ybase+this.y;if(M>=D&&M<D+R.length)continue;const W=R[R.length-1].getTrimmedLength(),$=(0,x.reflowSmallerGetNewLineLengths)(R,this._cols,_),G=$.length-R.length;let B;B=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+G):Math.max(0,this.lines.length-this.lines.maxLength+G);const H=[];for(let O=0;O<G;O++){const V=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);H.push(V)}H.length>0&&(E.push({start:D+R.length+T,newLines:H}),T+=H.length),R.push(...H);let q=$.length-1,Q=$[q];Q===0&&(q--,Q=$[q]);let J=R.length-G-1,U=W;for(;J>=0;){const O=Math.min(U,Q);if(R[q]===void 0)break;if(R[q].copyCellsFrom(R[J],U-O,Q-O,O,!0),Q-=O,Q===0&&(q--,Q=$[q]),U-=O,U===0){J--;const V=Math.max(J,0);U=(0,x.getWrappedLineTrimmedLength)(R,V,this._cols)}}for(let O=0;O<R.length;O++)$[O]<_&&R[O].setCell($[O],k);let I=G-B;for(;I-- >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+G,this.ybase+b-1)}if(E.length>0){const D=[],A=[];for(let q=0;q<this.lines.length;q++)A.push(this.lines.get(q));const R=this.lines.length;let M=R-1,W=0,$=E[W];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+T);let G=0;for(let q=Math.min(this.lines.maxLength-1,R+T-1);q>=0;q--)if($&&$.start>M+G){for(let Q=$.newLines.length-1;Q>=0;Q--)this.lines.set(q--,$.newLines[Q]);q++,D.push({index:M+1,amount:$.newLines.length}),G+=$.newLines.length,$=E[++W]}else this.lines.set(q,A[M--]);let B=0;for(let q=D.length-1;q>=0;q--)D[q].index+=B,this.lines.onInsertEmitter.fire(D[q]),B+=D[q].amount;const H=Math.max(0,R+T-this.lines.maxLength);H>0&&this.lines.onTrimEmitter.fire(H)}}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),p=d(511),m=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||p.CellData.fromCharData([0,m.NULL_CELL_CHAR,m.NULL_CELL_WIDTH,m.NULL_CELL_CODE]);for(let k=0;k<v;++k)this.setCell(k,b);this.length=v}get(v){const 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[m.CHAR_DATA_ATTR_INDEX],S[m.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[v]=S[1],this._data[3*v+0]=2097152|v|S[m.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*v+0]=S[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[m.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(v){return this._data[3*v+0]>>22}hasWidth(v){return 12582912&this._data[3*v+0]}getFg(v){return this._data[3*v+1]}getBg(v){return this._data[3*v+2]}hasContent(v){return 4194303&this._data[3*v+0]}getCodePoint(v){const 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 p.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 p.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 D=b-1;D>=0;D--){for(let A=0;A<3;A++)this._data[3*(_+D)+A]=E[3*(S+D)+A];268435456&E[3*(S+D)+2]&&(this._extendedAttrs[_+D]=v._extendedAttrs[S+D])}else for(let D=0;D<b;D++){for(let A=0;A<3;A++)this._data[3*(_+D)+A]=E[3*(S+D)+A];268435456&E[3*(S+D)+2]&&(this._extendedAttrs[_+D]=v._extendedAttrs[S+D])}const T=Object.keys(v._combined);for(let D=0;D<T.length;D++){const A=parseInt(T[D],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,D=2097152&E?this._combined[S]:T?(0,g.stringFromCodePoint)(T):m.WHITESPACE_CELL_CHAR;if(k+=D,b)for(let A=0;A<D.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,p,m){if(p===h.length-1)return h[p].getTrimmedLength();const g=!h[p].hasContent(m-1)&&h[p].getWidth(m-1)===1,x=h[p+1].getWidth(0)===2;return g&&x?m-1:m}Object.defineProperty(u,"__esModule",{value:!0}),u.getWrappedLineTrimmedLength=u.reflowSmallerGetNewLineLengths=u.reflowLargerApplyNewLayout=u.reflowLargerCreateNewLayout=u.reflowLargerGetLinesToRemove=void 0,u.reflowLargerGetLinesToRemove=function(h,p,m,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,p),E=1,T=0;for(;E<_.length;){const A=d(_,E,p),R=A-T,M=m-k,W=Math.min(R,M);_[b].copyCellsFrom(_[E],T,k,W,!1),k+=W,k===m&&(b++,k=0),T+=W,T===A&&(E++,T=0),k===0&&b!==0&&_[b-1].getWidth(m-1)===2&&(_[b].copyCellsFrom(_[b-1],m-1,k++,1,!1),_[b-1].setCell(m-1,x))}_[b].replaceCells(k,m,x);let D=0;for(let A=_.length-1;A>0&&(A>b||_[A].getTrimmedLength()===0);A--)D++;D>0&&(w.push(C+_.length-D),w.push(D)),C+=_.length-1}return w},u.reflowLargerCreateNewLayout=function(h,p){const m=[];let g=0,x=p[g],w=0;for(let C=0;C<h.length;C++)if(x===C){const v=p[++g];h.onDeleteEmitter.fire({index:C-w,amount:v}),C+=v-1,w+=v,x=p[++g]}else m.push(C);return{layout:m,countRemoved:w}},u.reflowLargerApplyNewLayout=function(h,p){const m=[];for(let g=0;g<p.length;g++)m.push(h.get(p[g]));for(let g=0;g<m.length;g++)h.set(g,m[g]);h.length=p.length},u.reflowSmallerGetNewLineLengths=function(h,p,m){const g=[],x=h.map(((S,_)=>d(h,_,p))).reduce(((S,_)=>S+_));let w=0,C=0,v=0;for(;v<x;){if(x-v<m){g.push(x-v);break}w+=m;const S=d(h,C,p);w>S&&(w-=S,C++);const _=h[C].getWidth(w-1)===2;_&&w--;const b=_?m-1:m;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),p=d(844),m=d(9092);class g extends p.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 m.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new m.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(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),p=d(643),m=d(3734);class g extends m.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new m.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[p.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(w[p.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(w[p.CHAR_DATA_CHAR_INDEX].length===2){const v=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=v&&v<=56319){const S=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=S&&S<=57343?this.content=1024*(v-55296)+S-56320+65536|w[p.CHAR_DATA_WIDTH_INDEX]<<22:C=!0}else C=!0}else this.content=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[p.CHAR_DATA_WIDTH_INDEX]<<22;C&&(this.combinedData=w[p.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[p.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),p=d(844);class m{get id(){return this._id}constructor(x){this.line=x,this.isDisposed=!1,this._disposables=[],this._id=m._nextId++,this._onDispose=this.register(new h.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,p.disposeArray)(this._disposables),this._disposables.length=0)}register(x){return this._disposables.push(x),x}}u.Marker=m,m._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,p;Object.defineProperty(u,"__esModule",{value:!0}),u.C1_ESCAPED=u.C1=u.C0=void 0,(function(m){m.NUL="\0",m.SOH="",m.STX="",m.ETX="",m.EOT="",m.ENQ="",m.ACK="",m.BEL="\x07",m.BS="\b",m.HT=" ",m.LF=`
|
|
260
|
+
`,m.VT="\v",m.FF="\f",m.CR="\r",m.SO="",m.SI="",m.DLE="",m.DC1="",m.DC2="",m.DC3="",m.DC4="",m.NAK="",m.SYN="",m.ETB="",m.CAN="",m.EM="",m.SUB="",m.ESC="\x1B",m.FS="",m.GS="",m.RS="",m.US="",m.SP=" ",m.DEL=""})(d||(u.C0=d={})),(function(m){m.PAD="",m.HOP="",m.BPH="",m.NBH="",m.IND="",m.NEL="
",m.SSA="",m.ESA="",m.HTS="",m.HTJ="",m.VTS="",m.PLD="",m.PLU="",m.RI="",m.SS2="",m.SS3="",m.DCS="",m.PU1="",m.PU2="",m.STS="",m.CCH="",m.MW="",m.SPA="",m.EPA="",m.SOS="",m.SGCI="",m.SCI="",m.CSI="",m.ST="",m.OSC="",m.PM="",m.APC=""})(h||(u.C1=h={})),(function(m){m.ST=`${d.ESC}\\`})(p||(u.C1_ESCAPED=p={}))},7399:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.evaluateKeyboardEvent=void 0;const h=d(2584),p={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};u.evaluateKeyboardEvent=function(m,g,x,w){const C={type:0,cancel:!1,key:void 0},v=(m.shiftKey?1:0)|(m.altKey?2:0)|(m.ctrlKey?4:0)|(m.metaKey?8:0);switch(m.keyCode){case 0:m.key==="UIKeyInputUpArrow"?C.key=g?h.C0.ESC+"OA":h.C0.ESC+"[A":m.key==="UIKeyInputLeftArrow"?C.key=g?h.C0.ESC+"OD":h.C0.ESC+"[D":m.key==="UIKeyInputRightArrow"?C.key=g?h.C0.ESC+"OC":h.C0.ESC+"[C":m.key==="UIKeyInputDownArrow"&&(C.key=g?h.C0.ESC+"OB":h.C0.ESC+"[B");break;case 8:C.key=m.ctrlKey?"\b":h.C0.DEL,m.altKey&&(C.key=h.C0.ESC+C.key);break;case 9:if(m.shiftKey){C.key=h.C0.ESC+"[Z";break}C.key=h.C0.HT,C.cancel=!0;break;case 13:C.key=m.altKey?h.C0.ESC+h.C0.CR:h.C0.CR,C.cancel=!0;break;case 27:C.key=h.C0.ESC,m.altKey&&(C.key=h.C0.ESC+h.C0.ESC),C.cancel=!0;break;case 37:if(m.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"D",C.key===h.C0.ESC+"[1;3D"&&(C.key=h.C0.ESC+(x?"b":"[1;5D"))):C.key=g?h.C0.ESC+"OD":h.C0.ESC+"[D";break;case 39:if(m.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"C",C.key===h.C0.ESC+"[1;3C"&&(C.key=h.C0.ESC+(x?"f":"[1;5C"))):C.key=g?h.C0.ESC+"OC":h.C0.ESC+"[C";break;case 38:if(m.metaKey)break;v?(C.key=h.C0.ESC+"[1;"+(v+1)+"A",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(m.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:m.shiftKey||m.ctrlKey||(C.key=h.C0.ESC+"[2~");break;case 46:C.key=v?h.C0.ESC+"[3;"+(v+1)+"~":h.C0.ESC+"[3~";break;case 36:C.key=v?h.C0.ESC+"[1;"+(v+1)+"H":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:m.shiftKey?C.type=2:m.ctrlKey?C.key=h.C0.ESC+"[5;"+(v+1)+"~":C.key=h.C0.ESC+"[5~";break;case 34:m.shiftKey?C.type=3:m.ctrlKey?C.key=h.C0.ESC+"[6;"+(v+1)+"~":C.key=h.C0.ESC+"[6~";break;case 112:C.key=v?h.C0.ESC+"[1;"+(v+1)+"P":h.C0.ESC+"OP";break;case 113:C.key=v?h.C0.ESC+"[1;"+(v+1)+"Q":h.C0.ESC+"OQ";break;case 114:C.key=v?h.C0.ESC+"[1;"+(v+1)+"R":h.C0.ESC+"OR";break;case 115:C.key=v?h.C0.ESC+"[1;"+(v+1)+"S":h.C0.ESC+"OS";break;case 116:C.key=v?h.C0.ESC+"[15;"+(v+1)+"~":h.C0.ESC+"[15~";break;case 117:C.key=v?h.C0.ESC+"[17;"+(v+1)+"~":h.C0.ESC+"[17~";break;case 118:C.key=v?h.C0.ESC+"[18;"+(v+1)+"~":h.C0.ESC+"[18~";break;case 119:C.key=v?h.C0.ESC+"[19;"+(v+1)+"~":h.C0.ESC+"[19~";break;case 120:C.key=v?h.C0.ESC+"[20;"+(v+1)+"~":h.C0.ESC+"[20~";break;case 121:C.key=v?h.C0.ESC+"[21;"+(v+1)+"~":h.C0.ESC+"[21~";break;case 122:C.key=v?h.C0.ESC+"[23;"+(v+1)+"~":h.C0.ESC+"[23~";break;case 123:C.key=v?h.C0.ESC+"[24;"+(v+1)+"~":h.C0.ESC+"[24~";break;default:if(!m.ctrlKey||m.shiftKey||m.altKey||m.metaKey)if(x&&!w||!m.altKey||m.metaKey)!x||m.altKey||m.ctrlKey||m.shiftKey||!m.metaKey?m.key&&!m.ctrlKey&&!m.altKey&&!m.metaKey&&m.keyCode>=48&&m.key.length===1?C.key=m.key:m.key&&m.ctrlKey&&(m.key==="_"&&(C.key=h.C0.US),m.key==="@"&&(C.key=h.C0.NUL)):m.keyCode===65&&(C.type=1);else{const S=p[m.keyCode],_=S==null?void 0:S[m.shiftKey?1:0];if(_)C.key=h.C0.ESC+_;else if(m.keyCode>=65&&m.keyCode<=90){const b=m.ctrlKey?m.keyCode-64:m.keyCode+32;let k=String.fromCharCode(b);m.shiftKey&&(k=k.toUpperCase()),C.key=h.C0.ESC+k}else if(m.keyCode===32)C.key=h.C0.ESC+(m.ctrlKey?h.C0.NUL:" ");else if(m.key==="Dead"&&m.code.startsWith("Key")){let b=m.code.slice(3,4);m.shiftKey||(b=b.toLowerCase()),C.key=h.C0.ESC+b,C.cancel=!0}}else m.keyCode>=65&&m.keyCode<=90?C.key=String.fromCharCode(m.keyCode-64):m.keyCode===32?C.key=h.C0.NUL:m.keyCode>=51&&m.keyCode<=55?C.key=String.fromCharCode(m.keyCode-51+27):m.keyCode===56?C.key=h.C0.DEL:m.keyCode===219?C.key=h.C0.ESC:m.keyCode===220?C.key=h.C0.FS:m.keyCode===221&&(C.key=h.C0.GS)}return C}},482:(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,p=d.length){let m="";for(let g=h;g<p;++g){let x=d[g];x>65535?(x-=65536,m+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):m+=String.fromCharCode(x)}return m},u.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(d,h){const p=d.length;if(!p)return 0;let m=0,g=0;if(this._interim){const x=d.charCodeAt(g++);56320<=x&&x<=57343?h[m++]=1024*(this._interim-55296)+x-56320+65536:(h[m++]=this._interim,h[m++]=x),this._interim=0}for(let x=g;x<p;++x){const w=d.charCodeAt(x);if(55296<=w&&w<=56319){if(++x>=p)return this._interim=w,m;const C=d.charCodeAt(x);56320<=C&&C<=57343?h[m++]=1024*(w-55296)+C-56320+65536:(h[m++]=w,h[m++]=C)}else w!==65279&&(h[m++]=w)}return m}},u.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(d,h){const p=d.length;if(!p)return 0;let m,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,D=0;for(;(T=63&this.interim[++D])&&D<4;)E<<=6,E|=T;const A=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,R=A-D;for(;S<R;){if(S>=p)return 0;if(T=d[S++],(192&T)!=128){S--,k=!0;break}this.interim[D++]=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 _=p-4;let b=S;for(;b<p;){for(;!(!(b<_)||128&(m=d[b])||128&(g=d[b+1])||128&(x=d[b+2])||128&(w=d[b+3]));)h[C++]=m,h[C++]=g,h[C++]=x,h[C++]=w,b+=4;if(m=d[b++],m<128)h[C++]=m;else if((224&m)==192){if(b>=p)return this.interim[0]=m,C;if(g=d[b++],(192&g)!=128){b--;continue}if(v=(31&m)<<6|63&g,v<128){b--;continue}h[C++]=v}else if((240&m)==224){if(b>=p)return this.interim[0]=m,C;if(g=d[b++],(192&g)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=g,C;if(x=d[b++],(192&x)!=128){b--;continue}if(v=(15&m)<<12|(63&g)<<6|63&x,v<2048||v>=55296&&v<=57343||v===65279)continue;h[C++]=v}else if((248&m)==240){if(b>=p)return this.interim[0]=m,C;if(g=d[b++],(192&g)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=g,C;if(x=d[b++],(192&x)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=g,this.interim[2]=x,C;if(w=d[b++],(192&w)!=128){b--;continue}if(v=(7&m)<<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),p=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],m=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let 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<p.length;++x)g.fill(0,p[x][0],p[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,m)?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),p=d(844);class m extends p.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=m},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 p(m,g){const x=m.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(m){if(!m)return;let g=m.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(m,g=16){const[x,w,C]=m;return`rgb:${p(x,g)}/${p(w,g)}/${p(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),p=d(8742),m=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 p.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>m.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),p=d(8742),m=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(((D,A)=>A)),_=(D,A)=>S.slice(D,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 p.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(_,b,k)=>{},this._executeHandlerFb=_=>{},this._csiHandlerFb=(_,b)=>{},this._escHandlerFb=_=>{},this._errorHandlerFb=_=>_,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,h.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new m.OscParser),this._dcsParser=this.register(new 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,D=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,D=this._parseStack.chunkPos+1;else{if(b===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const A=this._parseStack.handlers;let R=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(b===!1&&R>-1){for(;R>=0&&(k=A[R](this._params),k!==!0);R--)if(k instanceof Promise)return this._parseStack.handlerPos=R,k}this._parseStack.handlers=[];break;case 4:if(b===!1&&R>-1){for(;R>=0&&(k=A[R](),k!==!0);R--)if(k instanceof Promise)return this._parseStack.handlerPos=R,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,D=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let A=D;A<_;++A){switch(E=S[A],T=this._transitions.table[this.currentState<<8|(E<160?E:w)],T>>4){case 2:for(let G=A+1;;++G){if(G>=_||(E=S[G])<32||E>126&&E<w){this._printHandler(S,A,G),A=G-1;break}if(++G>=_||(E=S[G])<32||E>126&&E<w){this._printHandler(S,A,G),A=G-1;break}if(++G>=_||(E=S[G])<32||E>126&&E<w){this._printHandler(S,A,G),A=G-1;break}if(++G>=_||(E=S[G])<32||E>126&&E<w){this._printHandler(S,A,G),A=G-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 R=this._csiHandlers[this._collect<<8|E];let M=R?R.length-1:-1;for(;M>=0&&(k=R[M](this._params),k!==!0);M--)if(k instanceof Promise)return this._preserveStack(3,R,M,T,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 W=this._escHandlers[this._collect<<8|E];let $=W?W.length-1:-1;for(;$>=0&&(k=W[$](),k!==!0);$--)if(k instanceof Promise)return this._preserveStack(4,W,$,T,A),k;$<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 G=A+1;;++G)if(G>=_||(E=S[G])===24||E===26||E===27||E>127&&E<w){this._dcsParser.put(S,A,G),A=G-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 G=A+1;;G++)if(G>=_||(E=S[G])<32||E>127&&E<w){this._oscParser.put(S,A,G),A=G-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),p=d(482),m=[];u.OscParser=class{constructor(){this._state=0,this._active=m,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(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=m}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=m,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||m,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,p.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=m,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,p.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(m){const g=new h;if(!m.length)return g;for(let x=Array.isArray(m[0])?1:0;x<m.length;++x){const w=m[x];if(Array.isArray(w))for(let C=0;C<w.length;++C)g.addSubParam(w[C]);else g.addParam(w)}return g}constructor(m=32,g=32){if(this.maxLength=m,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(m),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(m),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const m=new h(this.maxLength,this.maxSubParamsLength);return m.params.set(this.params),m.length=this.length,m._subParams.set(this._subParams),m._subParamsLength=this._subParamsLength,m._subParamsIdx.set(this._subParamsIdx),m._rejectDigits=this._rejectDigits,m._rejectSubDigits=this._rejectSubDigits,m._digitIsSub=this._digitIsSub,m}toArray(){const m=[];for(let g=0;g<this.length;++g){m.push(this.params[g]);const x=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-x>0&&m.push(Array.prototype.slice.call(this._subParams,x,w))}return m}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(m){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(m<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=m>d?d:m}}addSubParam(m){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(m<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=m>d?d:m,this._subParamsIdx[this.length-1]++}}hasSubParams(m){return(255&this._subParamsIdx[m])-(this._subParamsIdx[m]>>8)>0}getSubParams(m){const g=this._subParamsIdx[m]>>8,x=255&this._subParamsIdx[m];return x-g>0?this._subParams.subarray(g,x):null}getSubParamsAll(){const m={};for(let g=0;g<this.length;++g){const x=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-x>0&&(m[g]=this._subParams.slice(x,w))}return m}addDigit(m){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+m,d):m}}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 p={instance:h,dispose:h.dispose,isDisposed:!1};this._addons.push(p),h.dispose=()=>this._wrappedAddonDispose(p),h.activate(d)}_wrappedAddonDispose(d){if(d.isDisposed)return;let h=-1;for(let p=0;p<this._addons.length;p++)if(this._addons[p]===d){h=p;break}if(h===-1)throw new Error("Could not dispose an addon that has not been loaded");d.isDisposed=!0,d.dispose.apply(d.instance),this._addons.splice(h,1)}}},8771:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferApiView=void 0;const h=d(3785),p=d(511);u.BufferApiView=class{constructor(m,g){this._buffer=m,this.type=g}init(m){return this._buffer=m,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(m){const g=this._buffer.lines.get(m);if(g)return new h.BufferLineApiView(g)}getNullCell(){return new p.CellData}}},3785:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferLineApiView=void 0;const h=d(511);u.BufferLineApiView=class{constructor(p){this._line=p}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(p,m){if(!(p<0||p>=this._line.length))return m?(this._line.loadCell(p,m),m):this._line.loadCell(p,new h.CellData)}translateToString(p,m,g){return this._line.translateToString(p,m,g)}}},8285:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.BufferNamespaceApi=void 0;const h=d(8771),p=d(8460),m=d(844);class g extends m.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new p.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new h.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new h.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}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,(p=>h(p.toArray())))}addCsiHandler(d,h){return this.registerCsiHandler(d,h)}registerDcsHandler(d,h){return this._core.registerDcsHandler(d,((p,m)=>h(p,m.toArray())))}addDcsHandler(d,h){return this.registerDcsHandler(d,h)}registerEscHandler(d,h){return this._core.registerEscHandler(d,h)}addEscHandler(d,h){return this.registerEscHandler(d,h)}registerOscHandler(d,h){return this._core.registerOscHandler(d,h)}addOscHandler(d,h){return this.registerOscHandler(d,h)}}},7090:(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 D=v.length-1;D>=0;D--)(k=v[D])&&(T=(E<3?k(T):E>3?k(S,_,T):k(S,_))||T);return E>3&&T&&Object.defineProperty(S,_,T),T},p=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 m=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 m.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new m.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(v.rawOptions.cols||0,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([p(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 D,A=arguments.length,R=A<3?k:T===null?T=Object.getOwnPropertyDescriptor(k,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,k,E,T);else for(var M=b.length-1;M>=0;M--)(D=b[M])&&(R=(A<3?D(R):A>3?D(k,E,R):D(k,E))||R);return A>3&&R&&Object.defineProperty(k,E,R),R},p=this&&this.__param||function(b,k){return function(E,T){k(E,T,b)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CoreMouseService=void 0;const m=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([p(0,m.IBufferService),p(1,m.ICoreService)],_)},6975:function(c,u,d){var h=this&&this.__decorate||function(_,b,k,E){var T,D=arguments.length,A=D<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 R=_.length-1;R>=0;R--)(T=_[R])&&(A=(D<3?T(A):D>3?T(b,k,A):T(b,k))||A);return D>3&&A&&Object.defineProperty(b,k,A),A},p=this&&this.__param||function(_,b){return function(k,E){b(k,E,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.CoreService=void 0;const m=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,m.clone)(C),this.decPrivateModes=(0,m.clone)(v)}reset(){this.modes=(0,m.clone)(C),this.decPrivateModes=(0,m.clone)(v)}triggerDataEvent(_,b=!1){if(this._optionsService.rawOptions.disableStdin)return;const k=this._bufferService.buffer;b&&this._optionsService.rawOptions.scrollOnUserInput&&k.ybase!==k.ydisp&&this._onRequestScrollToBottom.fire(),b&&this._onUserInput.fire(),this._logService.debug(`sending data "${_}"`,(()=>_.split("").map((E=>E.charCodeAt(0))))),this._onData.fire(_)}triggerBinaryEvent(_){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${_}"`,(()=>_.split("").map((b=>b.charCodeAt(0))))),this._onBinary.fire(_))}};u.CoreService=S=h([p(0,w.IBufferService),p(1,w.ILogService),p(2,w.IOptionsService)],S)},9074:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.DecorationService=void 0;const h=d(8055),p=d(8460),m=d(844),g=d(6106);let x=0,w=0;class C extends m.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((_=>_==null?void 0:_.marker.line)),this._onDecorationRegistered=this.register(new p.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new p.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,m.toDisposable)((()=>this.reset())))}registerDecoration(_){if(_.marker.isDisposed)return;const b=new v(_);if(b){const k=b.marker.onDispose((()=>b.dispose()));b.onDispose((()=>{b&&(this._decorations.delete(b)&&this._onDecorationRemoved.fire(b),k.dispose())})),this._decorations.insert(b),this._onDecorationRegistered.fire(b)}return b}reset(){for(const _ of this._decorations.values())_.dispose();this._decorations.clear()}*getDecorationsAtCell(_,b,k){let E=0,T=0;for(const D of this._decorations.getKeyIterator(b))E=D.options.x??0,T=E+(D.options.width??1),_>=E&&_<T&&(!k||(D.options.layer??"bottom")===k)&&(yield D)}forEachDecorationAtCell(_,b,k,E){this._decorations.forEachByKey(b,(T=>{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 m.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=h.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=h.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(_){super(),this.options=_,this.onRenderEmitter=this.register(new p.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new p.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=_.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(c,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.InstantiationService=u.ServiceCollection=void 0;const h=d(2585),p=d(8343);class m{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=m,u.InstantiationService=class{constructor(){this._services=new m,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,p.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 D=v.length-1;D>=0;D--)(k=v[D])&&(T=(E<3?k(T):E>3?k(S,_,T):k(S,_))||T);return E>3&&T&&Object.defineProperty(S,_,T),T},p=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 m=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 m.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([p(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),p=d(844),m=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:m.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 p.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,p.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},p=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 m=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([p(0,m.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(p){return p[h]||[]},u.createDecorator=function(p){if(u.serviceRegistry.has(p))return u.serviceRegistry.get(p);const m=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)})(m,g,w)};return m.toString=()=>p,u.serviceRegistry.set(p,m),m}},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 p;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(m){m[m.TRACE=0]="TRACE",m[m.DEBUG=1]="DEBUG",m[m.INFO=2]="INFO",m[m.WARN=3]="WARN",m[m.ERROR=4]="ERROR",m[m.OFF=5]="OFF"})(p||(u.LogLevelEnum=p={})),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),p=d(225);class m{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 p.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=m.extractWidth(b);m.extractShouldJoin(b)&&(k-=m.extractWidth(C)),w+=k,C=b}return w}charProperties(x,w){return this._activeProvider.charProperties(x,w)}}u.UnicodeService=m}},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),p=a(5741),m=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 p.AddonManager),this._publicOptions={...this._core.options};const _=k=>this._core.options[k],b=(k,E)=>{this._checkReadonlyOptions(k),this._core.options[k]=E};for(const k in this._core.options){const E={get:_.bind(this,k),set:b.bind(this,k)};Object.defineProperty(this._publicOptions,k,E)}}_checkReadonlyOptions(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 m.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})()))})(gx)),gx.exports}var o7=a7();/**
|
|
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 l7=2,c7=1,u7=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var m;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((m=this._terminal.options.overviewRuler)==null?void 0:m.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),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,p=a-d-t;return{cols:Math.max(l7,Math.floor(p/e.css.cell.width)),rows:Math.max(c7,Math.floor(h/e.css.cell.height))}}};function d7({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=os(m=>m.writeSession),h=os(m=>m.resizeSession),p=Rt(m=>m.settings[Ne.DISPLAY_TERMINAL_FONT]??Sh);return j.useEffect(()=>{o.current=e},[e]),j.useEffect(()=>{Rt.getState().getSetting(Ne.DISPLAY_TERMINAL_FONT)},[]),j.useEffect(()=>{if(!n)return;const m=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),n())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[n]),j.useEffect(()=>{if(!a.current)return;const m=new o7.Terminal({fontFamily:p,fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),g=new u7;m.loadAddon(g),c.current={term:m,fitAddon:g},a.current.addEventListener("keydown",v=>{v.key==="Escape"&&n&&(v.preventDefault(),v.stopPropagation(),n())}),m.open(a.current);const x=a.current.querySelector(".xterm");x&&(x.style.padding="8px"),g.fit(),r&&setTimeout(()=>{m.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),m.onData(v=>{if(v==="\x1B"&&n){n();return}d(o.current,v)}),m.onKey(v=>{v.key==="\x1B"&&n&&(v.domEvent.stopPropagation(),n())});const C=zt.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;_&&m.write(_)}});return()=>{C(),w.disconnect(),u.current&&clearTimeout(u.current),m.dispose(),c.current=null}},[e,d,h]),j.useEffect(()=>{const m=c.current;if(!m)return;m.term.options.fontFamily=p,m.fitAddon.fit();const{cols:g,rows:x}=m.term;g>0&&x>0&&h(o.current,g,x)},[p,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(eb,{})})]}),s.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:m=>{m.key==="Escape"&&n&&(m.preventDefault(),m.stopPropagation(),n())}})]})}const qN="openfox-chat-textarea";function hu(e){if(!Ft())return;const t=document.getElementById(qN);t&&(e===void 0?t.focus():t.focus({preventScroll:e}))}function h7(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 f7({isOpen:e,onClose:t}){const n=os(C=>C.createSession),r=os(C=>C.killSession),a=os(C=>C.sessions),o=os(C=>C.setWorkdir),c=os(C=>C.fetchSessions),u=Yt(C=>C.currentProject),d=Re(C=>C.currentSession),[h,p]=j.useState(!0),m=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?(p(!0),c(u==null?void 0:u.id).finally(()=>p(!1))):hu()},[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;Ft()&&((C=m.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:m,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:C=>C.stopPropagation(),onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),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(n3,{})}),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(ta,{})})]})]}),s.jsx(ht,{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 ${h7(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(C=>s.jsx(d7,{sessionId:C.id,onClose:()=>r(C.id),onEscape:w,autoFocus:a.length===1&&Ft()},C.id))})})]})]}):null}function Tl({items:e,footerItems:t=[],trigger:n,minWidth:r="120px",align:a="left",isOpen:o,onOpenChange:c,labelActionClassName:u}){const[d,h]=j.useState(!1),p=o!==void 0,m=p?o:d,g=H=>{if(p){const q=typeof H=="function"?H(d):H;c==null||c(q)}else h(H)},[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 H=C.current.getBoundingClientRect(),q=200,Q=Number.parseInt(r,10)||120,U=window.innerHeight-H.bottom<q;w({top:U?H.top-q-4:H.bottom+4,left:a==="right"?H.right-Q:H.left,alignToTop:U})},[a,r]);j.useEffect(()=>{E.current=k},[k]),j.useEffect(()=>{function H(q){if(v.current){const Q=q.target;v.current.contains(Q)||g(!1)}}return m&&document.addEventListener("mousedown",H),()=>{document.removeEventListener("mousedown",H)}},[m]),j.useEffect(()=>{m&&T()},[m,T]),j.useEffect(()=>{if(!m)return;setTimeout(()=>{var q;(q=v.current)==null||q.focus()},0);function H(q){const Q=E.current,J=Q.filter(I=>!D(I)),U=A(b.current,Q);switch(q.key){case"ArrowDown":if(q.preventDefault(),q.stopPropagation(),U<J.length-1){const I=R(b.current+1,Q);b.current=I,_(I)}break;case"ArrowUp":if(q.preventDefault(),q.stopPropagation(),U>0){const I=M(b.current-1,Q);b.current=I,_(I)}break;case"Enter":q.preventDefault(),q.stopPropagation(),W(b.current,Q);break;case"Escape":q.preventDefault(),q.stopPropagation(),g(!1);break}}return window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)},[m,k]);function D(H){var J;const q=H.label;return q?String(((J=q.props)==null?void 0:J.className)??"").includes("cursor-default"):!1}function A(H,q){let Q=0;for(let J=0;J<H;J++){const U=q[J];U&&!D(U)&&Q++}return Q}function R(H,q){for(let Q=H;Q<q.length;Q++){const J=q[Q];if(J&&!D(J))return Q}return H}function M(H,q){for(let Q=H;Q>=0;Q--){const J=q[Q];if(J&&!D(J))return Q}return H}function W(H,q){var J;const Q=q[H];!Q||D(Q)||((J=Q.onClick)==null||J.call(Q),Q.href&&(window.history.pushState(null,"",Q.href),window.dispatchEvent(new PopStateEvent("popstate"))),g(!1))}j.useEffect(()=>{m&&(_(k.findIndex(H=>!D(H))),b.current=k.findIndex(H=>!D(H)))},[m,k]);const $=H=>{H.stopPropagation(),m||T(),g(!m)};function G(H,q,Q,J){const I=!D(H)&&J===S,O=s.jsxs(s.Fragment,{children:[H.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:H.icon}),s.jsx("span",{className:"min-w-0",children:H.label})]}),z=q!==Q-1?"border-b border-border":"",X=`px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${H.danger?"text-accent-error hover:bg-accent-error/10":I?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"}`,Z=H.href?s.jsx(lr,{href:H.href,onClick:F=>{var P;(P=H.onClick)==null||P.call(H,F),g(!1)},onAuxClick:()=>g(!1),className:`w-full ${X}`,children:O}):s.jsx("button",{onClick:F=>{var P;(P=H.onClick)==null||P.call(H,F),H.closeOnClick!==!1&&g(!1)},className:`w-full ${X}`,children:O});return H.labelAction?s.jsxs("div",{className:`flex items-center gap-1 pr-1 ${z} ${u??""}`,children:[Z,s.jsx("span",{className:"flex-shrink-0",children:H.labelAction})]},J):s.jsx("div",{className:z,children:Z},J)}const B=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(ht,{className:"max-h-[60vh]",children:e.map((H,q)=>G(H,q,e.length,q))}),t.length>0&&s.jsx("div",{className:"border-t border-border",children:t.map((H,q)=>G(H,q,t.length,e.length+q))})]});return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative",children:s.jsx("div",{ref:C,onClick:$,children:n})}),m&&mi.createPortal(B,document.body)]})}function m7(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 KN({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&&p()},[e]);const p=async()=>{try{const k=await(await xe("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();h({sudoAvailable:k.sudoAvailable,userInGroup:k.userInGroup,groupHasWrite:k.groupHasWrite,groupName:k.groupName||null})}catch{h({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},m=j.useCallback(async b=>{o(!0),u(null);try{const E=await(await xe("/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(wt,{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:()=>m("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:()=>m("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:()=>m("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 YN({isOpen:e,onClose:t}){const[,n]=Pn(),r=Yt(E=>E.listProjects),[a,o]=j.useState(""),[c,u]=j.useState(null),[d,h]=j.useState(!1),[p,m]=j.useState(""),[g,x]=j.useState(null),w=j.useRef(null);j.useEffect(()=>{e&&(xe("/api/config").then(E=>E.json()).then(E=>{E.workdir&&m(E.workdir)}),o(""),u(null),h(!1),x(null),setTimeout(()=>{var E;Ft()&&((E=w.current)==null||E.focus())},100))},[e]);const C=j.useCallback(async E=>{E.preventDefault();const T=m7(a);if(!T.valid){u(T.error);return}const D=`${p}/${a}`;await _(D)},[a,n,t,p]),v=j.useCallback(()=>{x(null)},[]),S=j.useCallback(async()=>{const E=`${p}/${a}`;await _(E)},[p,a,n,t,x,u,h]);async function _(E){h(!0),u(null),x(null);try{const T=await xe("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,workdir:E})});if(!T.ok){const R=await T.json().catch(()=>({}));if(R.code==="EACCES"){x(E),h(!1);return}throw new Error(R.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?`${p}/${a}`:"";return s.jsxs(s.Fragment,{children:[s.jsx(wt,{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(Ns,{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(es,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),g&&s.jsx(KN,{isOpen:!!g,onClose:v,path:g,onRetry:S})]})}function XN(){return en(e=>e.workdir)}function VC({projects:e,currentProject:t}){const[,n]=Pn(),r=Yt(v=>v.loadProject),a=Yt(v=>v.toggleStar),o=Yt(v=>v.createProject),c=Yt(v=>v.listProjects),[u,d]=j.useState(!1),[h,p]=j.useState(!1),m=XN(),g=j.useCallback(async v=>{const S=xu(v),_=await o(S,v);return _&&"id"in _?(await c(),p(!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(nu,{className:"w-3.5 h-3.5 text-yellow-500"}):s.jsx(Nf,{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(Rs,{}):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(Qr,{className:"w-4 h-4"}),s.jsx("span",{children:"Open Project"})]}),onClick:()=>p(!0)},{label:s.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[s.jsx(es,{className:"w-4 h-4"}),s.jsx("span",{children:"New Project"})]}),onClick:()=>d(!0)}];return s.jsxs(s.Fragment,{children:[s.jsx(Tl,{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(YN,{isOpen:u,onClose:()=>d(!1)}),h&&s.jsx(Lf,{initialPath:m??void 0,onSelect:g,onClose:()=>p(!1)})]})}function JN(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 Qf(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function p7(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=Qf(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 QN(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 g7(e){const{year:t,month:n,day:r}=QN(e);return`${t}-${n}-${r}`}function ZN(e){const t=new Map;for(const a of e){const o=g7(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 x7(e){const{year:t,month:n,day:r}=QN(e);return`${t}/${n}/${r} ${Qf(e)}`}function Zh(e,t){return e.length<=t?e:e.substring(0,t)+"..."}function y7({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:a}){var w;const o=Re(C=>C.loadSession),c=Re(C=>C.toggleFavorite),u=50,d=e.filter(C=>C.projectId===t.id).slice(0,15),h=d.filter(C=>C.isFavorite),p=d.filter(C=>!C.isFavorite),m=j.useMemo(()=>{const C=[];C.push({label:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(es,{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:Zh(_.title??_.id.slice(0,8),u)}),b&&s.jsx("div",{className:"text-text-muted text-xs",children:Qf(_.updatedAt)})]}),icon:_.id===(n==null?void 0:n.id)?s.jsx(Rs,{}):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(nu,{className:"w-3.5 h-3.5 text-yellow-500"}):s.jsx(Nf,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})})},S=_=>{const b=ZN(_);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:JN(T.updatedAt)}),onClick:()=>{}});for(const D of E)v(D,!0)}}};if(h.length>0)for(const _ of h)v(_,!1);return S(p),C},[t.id,h,p,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?Zh(g,u):"No session selected";return s.jsx(Tl,{items:m,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 b7({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===lr?c.label:null;if(d){const h=d.props.href||"";return s.jsxs(lr,{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 v7({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(lr,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[s.jsx(es,{className:"w-3 h-3 text-accent-primary"}),s.jsx("span",{className:"text-sm",children:"New Session"})]})},...a.map(c=>({label:s.jsx(lr,{href:`/p/${e.id}/s/${c.id}`,className:"flex items-center gap-2 truncate text-sm",children:s.jsx("span",{children:Zh(c.title??c.id.slice(0,8),50)})}),icon:c.id===(n==null?void 0:n.id)?s.jsx(Rs,{className:"w-3 h-3"}):void 0})),{label:s.jsxs(lr,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[s.jsx(X5,{className:"w-3 h-3"}),s.jsx("span",{className:"text-sm",children:"Projects"})]})}];return s.jsx(b7,{items:o,trigger:s.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function eT(){const e=ct(a=>a.defaults),t=ct(a=>a.userItems),n=ct(a=>a.projectItems),r=ct(a=>a.fetchAgents);return{agents:[...e,...t,...n],fetchAgents:r}}function _7({task:e,projectId:t,agents:n,queuePosition:r,onEdit:a,onMove:o,onMoveUp:c,onMoveDown:u,onDuplicate:d,onDelete:h,onDragStart:p,onDropOnCard:m,onOpenSession:g}){const[x,w]=j.useState(!1),C=n.find(E=>E.id===e.agentId),v=e.agentId?Qa(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(Ky,{className:"w-3.5 h-3.5"}),onClick:()=>a(e)},{label:"History & evidence",icon:s.jsx(kf,{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(Uj,{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(ml,{className:"w-3.5 h-3.5"}),onClick:()=>d(e)},{label:"Delete",icon:s.jsx(fi,{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",p(e)},onDragOver:E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},onDrop:E=>{E.preventDefault(),m(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(jf,{className:"w-2.5 h-2.5"}):s.jsx(Wj,{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(Tl,{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(Yy,{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(lr,{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(Jy,{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 S7({title:e,accentClass:t,hint:n,tasks:r,projectId:a,agents:o,queuePositionOf:c,headerAction:u,footer:d,onEdit:h,onMove:p,onMoveUp:m,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(_7,{task:b,projectId:a,agents:o,queuePosition:c(b),onEdit:h,onMove:p,onMoveUp:m,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 w7={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},C7="M6 18L18 6M6 6l12 12";function Cu({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(Tf,{onClick:e,icon:C7,iconSize:w7[n],className:`${c} ${t}`,title:o,...a!==void 0?{"aria-label":a}:{}})}const k7=["text/"],j7=["application/json","application/xml","application/yaml","application/x-yaml","application/javascript","application/xhtml+xml","application/x-sh","image/svg+xml"];function Eh(e){return e.startsWith("image/")}function tT(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function Fb(e){return j7.includes(e)||k7.some(t=>e.startsWith(t))}function sl(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function nT(e){const t=e.lastIndexOf(".");return t<=0||t>=e.length-1?"FILE":e.slice(t+1).toUpperCase()}const E7={"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 N7(e){var t;return E7[e]||((t=e.split("/")[1])==null?void 0:t.split("+")[0])||"file"}function T7(e){return Eh(e)||Fb(e)||e==="application/pdf"}function Ub({attachment:e,onRemove:t}){const n=nT(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(Cu,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),tT(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:sl(e.size)})]})}function A7(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function L7(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 GC(e){return e.models.some(n=>n.selected)?e.models.filter(n=>n.selected):e.models}function rT({providerId:e,modelConfig:t,isActive:n,isDefault:r,disabled:a,hasSession:o,settingDefault:c,highlighted:u,onModelClick:d,onSetDefault:h,onEditModel:p}){var m;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??((m=t.id.split("/").pop())==null?void 0:m.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:A7(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(nu,{className:"w-3.5 h-3.5 text-accent-warning"}):s.jsx(Nf,{className:"w-3.5 h-3.5 text-text-muted hover:text-accent-warning"})}),p&&s.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),p(e,t)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:s.jsx(Ky,{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(Rs,{className:"w-3.5 h-3.5"})})]})]})}function sT({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),p=j.useMemo(()=>a.trim()?e.map(w=>({provider:w,models:GC(w).filter(C=>L7(C,a))})).filter(w=>w.models.length>0):e.map(w=>({provider:w,models:GC(w)})),[e,a]),m=j.useMemo(()=>p.flatMap(w=>w.models.map(C=>({providerId:w.provider.id,modelConfig:C}))),[p]),g=m.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:p,flatItems:m,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<m.length){const C=m[c];C&&t(C.providerId,C.modelConfig.id)}break}},highlightedRef:d,inputRef:h}}function Vb({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({}),p=t==null?void 0:t.split("/").slice(1).join("/"),m=p?((T=p.split("/").pop())==null?void 0:T.replace(/-/g," "))??p:void 0,{searchQuery:g,setSearchQuery:x,highlightedIndex:w,setHighlightedIndex:C,visibleGroups:v,flatItems:S,handleSearchKeyDown:_,highlightedRef:b,inputRef:k}=sT({providers:e,onSelect:(D,A)=>{n(`${D}/${A}`),o(!1)},onEscape:()=>o(!1)}),E=j.useCallback(()=>{if(!a||!u.current)return;const D=u.current.getBoundingClientRect();h({position:"fixed",top:`${D.bottom+4}px`,left:`${D.left}px`,width:`${Math.max(D.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 D(R){var M;c.current&&!c.current.contains(R.target)&&!((M=R.target)!=null&&M.closest("[data-model-picker-dropdown]"))&&(o(!1),x(""),C(-1))}const A=setTimeout(()=>{document.addEventListener("mousedown",D)},0);return()=>{clearTimeout(A),document.removeEventListener("mousedown",D)}},[a,x,C]),j.useEffect(()=>{var D;a?(E(),Ft()&&((D=k.current)==null||D.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:m?"text-text-primary":"text-text-muted",children:m??r}),s.jsx(gn,{className:`w-3 h-3 text-text-muted transition-transform ${a?"rotate-180":""}`})]}),a&&typeof document<"u"&&mi.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(hi,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("input",{ref:k,type:"text",value:g,onInput:D=>{x(D.currentTarget.value),C(-1)},onKeyDown:_,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),s.jsxs(ht,{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(D=>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:D.provider.name}),D.models.map(A=>{const M=S.findIndex($=>$.providerId===D.provider.id&&$.modelConfig.id===A.id)===w,W=t===`${D.provider.id}/${A.id}`;return s.jsx("div",{ref:M?b:void 0,children:s.jsx(rT,{providerId:D.provider.id,modelConfig:A,isActive:W,highlighted:M,onModelClick:($,G)=>{n(`${$}/${G}`),o(!1)}})},`${D.provider.id}/${A.id}`)})]},D.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 D7(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 Gb={builtin:"Built-in",user:"Global",project:"Project"};function ef(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)??ef(e,t):ef(e,t)}const iT=j.forwardRef(function({text:t,cursorPos:n,workflows:r,commands:a,onSelect:o},c){const u=D7(t,n),[d,h]=j.useState(0),p=j.useRef(null),m=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=m.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=m.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:p,className:"absolute bottom-full left-0 right-0 mb-2 z-50",role:"listbox",children:s.jsx(ht,{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=>{m.current[_]=b},role:"option","aria-selected":_===d,className:`w-full text-left px-3 py-2 flex items-center gap-2 text-sm ${_===d?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{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:Gb[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 R7(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 aT=j.forwardRef(function({text:t,cursorPos:n,workdir:r,onSelect:a},o){const c=R7(t,n),[u,d]=j.useState([]),[h,p]=j.useState(!1),[m,g]=j.useState(0),x=j.useRef(null),w=j.useRef([]),C=j.useRef(0),v=j.useRef([]);j.useEffect(()=>{C.current=m},[m]),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=>{p(!0);try{const k=new URLSearchParams({q:b});r&&k.set("workdir",r);const T=await(await xe(`/api/files?${k.toString()}`)).json();d(T),g(0),C.current=0}catch(k){console.error("File search failed:",k),d([])}finally{p(!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(na,{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(ht,{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===m?"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(Qr,{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}),WC=e=>Symbol.iterator in e,qC=e=>"entries"in e,KC=(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},O7=(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 I7(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:WC(e)&&WC(t)?qC(e)&&qC(t)?KC(e,t):O7(e,t):KC({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function M7(e){const t=cs.useRef(void 0);return n=>{const r=e(n);return I7(t.current,r)?t.current:t.current=r}}const Na=e=>e?`?workdir=${encodeURIComponent(e)}`:"",xx=e=>e?`&scope=${e}`:"",Za=e=>[...e.defaults,...e.userItems,...e.projectItems],Zf=()=>Ht(M7(Za)),Ht=Kn((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],setWorkdir:n=>e({workdir:n}),fetchTemplateVariables:async()=>{try{const r=await(await xe("/api/workflows/template-variables")).json();e({templateVariables:r.variables??[]})}catch{}},fetchWorkflows:async n=>{e({loading:!0});try{const a=await(await xe(`/api/workflows${Na(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 xe(`/api/workflows/${n}${Na(r??t().workdir)}${xx(a)}`);return o.ok?await o.json():null}catch{return null}},fetchDefaultContent:async(n,r)=>{try{const a=await xe(`/api/workflows/defaults/${n}${Na(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 Zi("POST",`/api/workflows${Na(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 Zi("PUT",`/api/workflows/${n}${Na(c)}${xx(o)}`,r);return u.success&&await t().fetchWorkflows(c),u},deleteWorkflow:async(n,r,a)=>{try{const o=await xe(`/api/workflows/${n}${Na(a??t().workdir)}${xx(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 Sf(`/api/workflows/${n}/duplicate${Na(o)}`,()=>t().fetchWorkflows(o),r)}}));async function P7(e,t,n){t({loading:!0});try{const a=await(await xe(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const Go=(e,t)=>t?`${e}?workdir=${encodeURIComponent(t)}`:e,ln=Kn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async n=>{await P7(Go("/api/commands",n),e,!0)},fetchCommand:async(n,r)=>{try{const a=await xe(Go(`/api/commands/${n}`,r));return a.ok?await a.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await xe(`/api/commands/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createCommand:async(n,r,a)=>{const o=await Zi("POST",Go("/api/commands",a),{...n,destination:r});return o.success&&await t().fetchCommands(a),o},updateCommand:async(n,r,a)=>{const o=await Zi("PUT",Go(`/api/commands/${n}`,a),r);return o.success&&await t().fetchCommands(a),o},deleteCommand:async(n,r)=>{try{const a=await xe(Go(`/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)=>Sf(Go(`/api/commands/${n}/duplicate`,a),()=>t().fetchCommands(a),r)}));function Zn(e,t){const n=new Set(t.map(r=>r.id));return[...e.filter(r=>!n.has(r.id)),...t]}function _y(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 p=o;p<o+r.length;p++)a[p]=!0;else{let p=0;for(let m=0;m<e.length&&p<r.length;m++)n[m]===r[p]&&(a[m]=!0,p++)}const c=Array.from(e),u=[];let d="",h=a[0]??!1;for(let p=0;p<c.length;p++){const m=c[p]??"";a[p]===h?d+=m:(u.push(h?s.jsx("span",{className:"font-semibold text-accent-primary",children:d},u.length):d),d=m,h=a[p]??!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 Ki(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 oT(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 tf(e,t,n,r){const a=e.slice(0,n),o=e.slice(t);return{newText:`${a}${r}${o}`,newCursorPos:n+r.length}}function nf(e,t){e&&(e.selectionStart=t,e.selectionEnd=t,e.focus())}function lT(e){if(e.type==="workflow"){const r=Za(Ht.getState()).find(a=>a.id===e.id&&a.scope===e.scope);return((r==null?void 0:r.parameters)??[]).map(a=>a.id)}const t=ln.getState(),n=Zn(Zn(t.defaults,t.userItems),t.projectItems).find(r=>r.id===e.id);return(n==null?void 0:n.paramNames)??[]}const B7={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function $7(e,t={}){const n={...B7,...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=W7(a),c=`data:${e.type};base64,${o}`,u=await cT(c);return{dataUrl:c,mimeType:e.type,size:e.size,width:u.width,height:u.height}}return await z7(e,n)}async function z7(e,t){const n=await F7(e),r=await cT(n),{width:a,height:o}=H7(r.width,r.height,t.maxWidth,t.maxHeight),c=U7();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 m=0;m<10&&(h=c.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,d),!(YC(h)<=t.maxSizeBytes||d<=.3));m++)d-=.1;const p=YC(h);return{dataUrl:h,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:p,width:a,height:o}}function H7(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 F7(e){return new Promise((t,n)=>{const r=G7(),a=new r;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function cT(e){return new Promise((t,n)=>{const r=V7(),a=new r;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function U7(){var t;const e=Wb();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function V7(){const e=Wb();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function G7(){const e=Wb();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function Wb(){return globalThis}function W7(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 YC(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}const XC=50*1024*1024,JC=1024*1024,q7=["image/png","image/jpeg","image/gif"];function K7(e){return e==="application/pdf"}function Y7(e){return q7.includes(e.type)}async function X7(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 Sy(e,t,n){try{if(Fb(e.type)){if(e.size>JC){n(`Text file too large (${sl(e.size)}). Maximum is ${sl(JC)}.`);return}const r=await e.text(),a={id:vh(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}else if(Eh(e.type)||K7(e.type)){if(e.size>XC){const r=Eh(e.type)?"Image":"PDF";n(`${r} file too large (${sl(e.size)}). Maximum is ${sl(XC)}.`);return}if(Eh(e.type)&&Y7(e)){const r=await $7(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),a={id:vh(),filename:e.name||"unnamed-file",mimeType:r.mimeType,size:r.size,data:r.dataUrl};t(a)}else{const r=await X7(e),a={id:vh(),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 J7="openfox:task-draft";function Q7({projectId:e,initialTask:t,onClose:n,onSaved:r}){var Ze;const a=!!t,o=Pt(Se=>Se.createTask),c=Pt(Se=>Se.updateTask),u=Pt(Se=>Se.lastError),{agents:d,fetchAgents:h}=eT(),p=d.filter(Se=>!Se.subagent),m=en(Se=>Se.providers),x=(Ze=Yt(Se=>Se.projects).find(Se=>Se.id===e))==null?void 0:Ze.workdir;j.useEffect(()=>{h()},[h]);const w=`${J7}:${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),[D,A]=j.useState(()=>t==null?void 0:t.model),[R,M]=j.useState(null),[W,$]=j.useState(!1),[G,B]=j.useState([]),H=j.useRef(null),q=j.useRef(null),Q=j.useRef(null),J=j.useRef(null),U=j.useRef(0),I=j.useRef([]),[O,V]=j.useState(!1);j.useEffect(()=>{if(x)return;let Se=!1;return xe(`/api/projects/${e}`).then(be=>be.ok?be.json():null).then(be=>{var de;!Se&&((de=be==null?void 0:be.project)!=null&&de.workdir)&&Yt.setState({currentProject:be.project})}).catch(()=>{}),()=>{Se=!0}},[e,x]),j.useEffect(()=>{try{const Se=localStorage.getItem(w);if(Se){const be=JSON.parse(Se);be.prompt&&v(be.prompt)}}catch{}},[]),j.useEffect(()=>{const Se=setTimeout(()=>{try{localStorage.setItem(w,JSON.stringify({prompt:C}))}catch{}},300);return()=>clearTimeout(Se)},[C,w]);const z=j.useCallback(Se=>{for(const be of Array.from(Se))Sy(be,de=>_(ie=>[...ie,de]),de=>M(de))},[]),Y=Se=>{Se.clipboardData.files.length>0&&z(Se.clipboardData.files)},X=Se=>{Se.preventDefault()},Z=Se=>{Se.preventDefault(),Se.dataTransfer.files.length>0&&z(Se.dataTransfer.files)},F=Se=>{I.current.push(Se),I.current.length>50&&I.current.shift(),V(!0)},P=Se=>{Se!==C&&(F(C),v(Se))},te=()=>{var be;const Se=I.current.pop();Se!==void 0&&(v(Se),V(I.current.length>0),(be=H.current)==null||be.focus())},se=j.useCallback((Se,be)=>{const{newText:de,newCursorPos:ie}=tf(C,U.current,be,`/${Se.id} `);F(C),v(de),U.current=ie,nf(H.current,ie),B(lT(Se))},[C]),re=j.useCallback((Se,be)=>{const ie=Se.type==="directory"?"/":" ",{newText:Pe,newCursorPos:Ue}=tf(C,U.current,be,`@${Se.path}${ie}`);F(C),v(Pe),U.current=Ue,nf(H.current,Ue)},[C]),ae=async()=>{const Se=C.trim().length>0,be=S.length>0;if(!Se&&!be){M("Add a prompt or an attachment");return}$(!0),M(null);const de={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)&&!D?{model:null}:D?{model:D}:{}},ie=a?await c(e,t.id,de):await o(e,de);if($(!1),ie){try{localStorage.removeItem(w)}catch{}r(ie)}else M(u??"Could not save the task")},ye=Se=>{var be,de;if(!((be=J.current)!=null&&be.handleKeyDown(Se))&&!((de=Q.current)!=null&&de.handleKeyDown(Se))){if(Se.key==="z"&&(Se.metaKey||Se.ctrlKey)){Se.preventDefault(),te();return}Se.key==="Enter"&&!Se.shiftKey&&!Se.nativeEvent.isComposing&&(Se.preventDefault(),ae())}},_e=Za(Ht.getState()),Ie=(()=>{const Se=ln.getState();return Zn(Zn(Se.defaults,Se.userItems),Se.projectItems)})(),He=(()=>{if(G.length===0)return 0;const Se=C.match(/\/(\w+)\s+(.*)$/),de=(Se?Se[2].trim().split(/\s+/):[]).filter(Boolean).length;return G[de]?G.length-de:0})(),je=E&&D?`${E}/${D}`:void 0,Ge=a&&t.status==="in_progress"&&t.runState==="running";return s.jsxs(wt,{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 ae(),disabled:W,children:W?"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:X,onDrop:Z,children:[s.jsx("textarea",{ref:H,value:C,onChange:Se=>P(Se.target.value),onSelect:Se=>{U.current=Se.currentTarget.selectionStart},onPaste:Y,onKeyDown:ye,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(aT,{ref:Q,text:C,cursorPos:U.current,workdir:x,onSelect:re}),s.jsx(iT,{ref:J,text:C,cursorPos:U.current,workflows:_e,commands:Ie,onSelect:se}),G.length>0&&He>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:[He," required param",He>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:te,disabled:!O,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 Se;return(Se=q.current)==null?void 0:Se.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(Hj,{})})]}),s.jsx("input",{ref:q,type:"file",multiple:!0,className:"hidden",onChange:Se=>{Se.target.files&&z(Se.target.files),Se.target.value=""}})]})]}),S.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:S.map(Se=>s.jsx(Ub,{attachment:Se,onRemove:be=>_(de=>de.filter(ie=>ie.id!==be))},Se.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:Se=>k(Se.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"}),p.map(Se=>s.jsx("option",{value:Se.id,children:Se.name},Se.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-muted mb-1",children:"Model"}),s.jsx(Vb,{providers:m,value:je,onChange:Se=>{if(Se){const be=Se.indexOf("/");T(Se.slice(0,be)),A(Se.slice(be+1))}else T(void 0),A(void 0)}})]})]}),R&&s.jsx("div",{className:"text-sm text-accent-error",children:R})]})]})}const Z7=()=>`gate_${crypto.randomUUID().slice(0,8)}`;function eU({projectId:e,onClose:t}){const n=Pt(x=>x.gates),r=Pt(x=>x.loadGates),a=Pt(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))},p=()=>{c(x=>[...x,{id:Z7(),name:"",description:"",required:!0,variant:"done"}])},m=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(wt,{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(Ns,{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:()=>m(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(fi,{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:p,children:[s.jsx(es,{className:"w-3.5 h-3.5 mr-1 inline-block"})," Add gate"]})]})})}function qb({isOpen:e,onClose:t,projectId:n}){const[,r]=Pn(),a=Pt(F=>F.tasks),o=Pt(F=>F.settings),c=Pt(F=>F.loadBoard),u=Pt(F=>F.loadGates),d=Pt(F=>F.moveTask),h=Pt(F=>F.reorderTask),p=Pt(F=>F.deleteTask),m=Pt(F=>F.duplicateTask),g=Pt(F=>F.setSettings),x=Pt(F=>F.lastError),{agents:w,fetchAgents:C}=eT(),[v,S]=j.useState(null),[_,b]=j.useState(!1),[k,E]=j.useState(""),[T,D]=j.useState(null),A=j.useRef(null);j.useEffect(()=>{e&&(c(n),u(n),C())},[e,n,c,u,C]);const R=j.useMemo(()=>{if(!k.trim())return a;const F=k.toLowerCase();return a.filter(P=>P.prompt.toLowerCase().includes(F))},[a,k]),M=j.useMemo(()=>{const F=R.filter(se=>se.status==="todo").sort((se,re)=>se.position-re.position),P=R.filter(se=>se.status==="in_progress").sort((se,re)=>se.runState==="running"!=(re.runState==="running")?se.runState==="running"?-1:1:se.position-re.position),te=R.filter(se=>se.status==="done").sort((se,re)=>se.position-re.position);return{todo:F,in_progress:P,done:te}},[R]),W=j.useMemo(()=>{const F=a.filter(te=>te.status==="in_progress"&&te.runState==="queued").sort((te,se)=>te.position-se.position),P=new Map;return F.forEach((te,se)=>P.set(te.id,se+1)),P},[a]),$=j.useMemo(()=>a.filter(F=>F.status==="in_progress"&&F.runState==="running").length,[a]),G=j.useMemo(()=>a.filter(F=>F.status==="in_progress"&&F.runState==="queued").length,[a]),B=j.useCallback(F=>{if(F.runState==="queued")return F.queuePosition!==void 0?F.queuePosition:W.get(F.id)},[W]),H=j.useCallback(async(F,P)=>{const te=await d(n,F.id,P);te!=null&&te.sessionId&&r(`/p/${n}/s/${te.sessionId}`)},[d,n,r]),q=j.useCallback(async F=>{const P=A.current;A.current=null,P&&P.task.status!==F&&await H(P.task,F)},[H]),Q=j.useCallback(async F=>{const P=A.current;if(A.current=null,!P||P.task.id===F.task.id)return;const te=M[F.task.status].findIndex(se=>se.id===F.task.id);te<0||(P.task.status===F.task.status?await h(n,P.task.id,F.task.status,te):(await H(P.task,F.task.status),await h(n,P.task.id,F.task.status,te)))},[M,h,n,H]),J=j.useCallback(F=>{const P=M[F.status].findIndex(te=>te.id===F.id);P>0&&h(n,F.id,F.status,P-1)},[M,h,n]),U=j.useCallback(F=>{const P=M[F.status].findIndex(te=>te.id===F.id);P>=0&&P<M[F.status].length-1&&h(n,F.id,F.status,P+1)},[M,h,n]),I=j.useCallback(F=>{m(n,F.id)},[m,n]),O=j.useCallback(async()=>{T&&(await p(n,T.id),D(null))},[T,p,n]),V=F=>{const P=Pt.getState().settings.slotLimit,te=Math.max(1,Math.min(10,P+F));te!==P&&g(n,{slotLimit:te})},z=()=>{const F=Pt.getState().settings.queuePaused;g(n,{queuePaused:!F})},Y={projectId:n,agents:w,queuePositionOf:B,onEdit:F=>S({mode:"edit",task:F}),onMove:(F,P)=>void H(F,P),onMoveUp:J,onMoveDown:U,onDuplicate:I,onDelete:F=>D(F),onDragStart:F=>{A.current={task:F}},onOpenSession:()=>t()},X=F=>{const P={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"}}[F];return s.jsx(S7,{title:P.title,accentClass:P.accentClass,hint:"hint"in P?P.hint:void 0,tasks:M[F],headerAction:F==="todo"?s.jsxs(ot,{variant:"primary",onClick:()=>S({mode:"create"}),children:[s.jsx(es,{className:"w-4 h-4 mr-1 inline-block"})," New Task"]}):F==="done"?s.jsx(ot,{onClick:()=>b(!0),children:"Gates"}):void 0,footer:F==="in_progress"?Z:void 0,onDropOnColumn:()=>void q(F),onDropOnCard:te=>void Q({task:te}),...Y},F)},Z=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:()=>V(-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:()=>V(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:$})," / ",o.slotLimit," running"]}),G>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:G})," queued"]})]}),s.jsxs(ot,{size:"sm",onClick:z,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(jf,{className:"w-3 h-3"}):s.jsx(Wj,{className:"w-3 h-3"}),o.queuePaused?"Resume":"Pause"]})]})})]});return s.jsxs(s.Fragment,{children:[s.jsxs(wt,{isOpen:e,onClose:t,title:"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(hi,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-text-muted"}),s.jsx(Ns,{type:"text",value:k,onChange:F=>E(F.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:()=>Pt.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")]})]}),v&&s.jsx(Q7,{projectId:n,initialTask:v.mode==="edit"?v.task:null,onClose:()=>S(null),onSaved:()=>S(null)}),_&&s.jsx(eU,{projectId:n,onClose:()=>b(!1)}),T&&s.jsx(pl,{isOpen:!0,onClose:()=>D(null),onConfirm:()=>void O(),title:"Delete task?",message:`“${T.prompt.slice(0,60)}” will be removed from the board. Its sessions and history stay untouched.`,confirmLabel:"Delete task",confirmVariant:"danger"})]})}function tU({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=j.useState(!1),[a,o]=j.useState(!1),[c,u]=j.useState(!!document.fullscreenElement),[d,h]=Pn(),[p,m]=j.useState(!1),g=Pt(B=>B.counts.open),x=Pt(B=>B.loadCounts),w=Pt(B=>B.activeProjectId),C=Pt(B=>B.lastAutoLaunch),v=Pt(B=>B.clearAutoLaunch);j.useEffect(()=>{const B=()=>u(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",B),()=>document.removeEventListener("fullscreenchange",B)},[]);const S=d.startsWith("/p/"),_=/^\/p\/[^/]+\/s\/[^/]+$/.test(d),b=Re(B=>B.currentSession),k=Re(B=>B.sessions),E=Yt(B=>B.currentProject),T=Yt(B=>B.projects),D=en(B=>B.startAutoRefresh),A=en(B=>B.stopAutoRefresh),R=os(B=>B.setOpen),M=os(B=>B.isOpen),W=ui(B=>B.status==="available"),$=ui(B=>B.check);j.useEffect(()=>{ui.getState().status==="idle"&&$()},[$]),j.useEffect(()=>{const B=()=>o(!0);return window.addEventListener("open-session-dropdown",B),()=>window.removeEventListener("open-session-dropdown",B)},[]);const G=pu();return ru(G.terminalToggle,()=>{os.getState().toggleOpen()},{capture:!0}),j.useEffect(()=>{E!=null&&E.id&&w!==E.id&&x(E.id)},[E==null?void 0:E.id,w,x]),j.useEffect(()=>(D(),()=>A()),[D,A]),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&&_&&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:G.sessionSearch?`Toggle session list (${Oh(G.sessionSearch)})`:"Toggle session list",children:s.jsx(Kw,{})}),s.jsx(lr,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),E&&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(VC,{projects:T,currentProject:E})}),s.jsx("span",{className:"md:hidden",children:s.jsx(v7,{currentProject:E,sessions:k,currentSession:b,projectIdFromUrl:S&&d.split("/")[2]||null},E==null?void 0:E.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(y7,{sessions:k,currentProject:E,currentSession:b,isOpen:a,onOpenChange:o})})]}),!E&&s.jsx("span",{className:"hidden md:inline",children:s.jsx(VC,{projects:T})})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[_&&s.jsx("button",{onClick:()=>{var B,H,q;document.fullscreenElement?(B=document.exitFullscreen)==null||B.call(document):(q=(H=document.documentElement).requestFullscreen)==null||q.call(H)},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(Q5,{}):s.jsx(Z5,{})}),S&&s.jsxs("button",{onClick:()=>m(!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(Zy,{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-primary text-white text-[9px] font-semibold flex items-center justify-center",children:g>99?"99+":g})]}),S&&s.jsx("button",{onClick:()=>R(!M),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${M?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:s.jsx(i3,{})}),S&&E&&s.jsx("button",{onClick:()=>xe(`/api/projects/${E.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(Qr,{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:W?"Settings — update available":"Settings",children:[s.jsx(Gj,{}),W&&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(t3,{})}),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 (${Oh(G.criteriaSidebar)})`:"Toggle criteria sidebar",children:s.jsx(Kw,{})})]}),s.jsx(i7,{isOpen:n,onClose:()=>r(!1)}),s.jsx(f7,{isOpen:M,onClose:()=>R(!1)}),E&&s.jsx(qb,{isOpen:p,onClose:()=>m(!1),projectId:E.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 B=C.sessionId,H=C.projectId;v(),h(`/p/${H}/s/${B}`)},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(Cf,{className:"w-3 h-3"})]}),s.jsx("button",{type:"button",onClick:v,className:"text-xs text-text-muted underline",children:"Dismiss"})]})]})}function uT({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 sh=Kn()(e=>({config:null,loading:!1,fetchConfig:async t=>{e({loading:!0});try{const r=await(await xe(`/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 xe(`/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})}})),nU=["/","/etc","/bin","/sbin","/lib","/lib64","/usr","/var","/opt","/root","/run","/tmp","/home","/mnt","/media"],rU=["/proc/","/sys/","/dev/","/boot/","/etc/","/lost+found/"],dT=/^[a-zA-Z]:$/;function sU(e,t=nU,n=rU){if(!e)return null;const r=e.replace(/[\\/]+$/,"")||"/";if(dT.test(r)||t.includes(r))return"exact";for(const a of n)if(r.startsWith(a))return"virtual_fs";return null}function hT(e){const t=e.replace(/[\\/]+$/,"");return t?dT.test(t)?`${t}\\`:t:"/"}function iU(e,t){const n=hT(e);return/[\\/]$/.test(n)?`${n}${t}`:`${n}/${t}`}function aU({isOpen:e,onClose:t,project:n}){const r=Yt(ge=>ge.updateProject),a=sh(ge=>ge.config),o=sh(ge=>ge.loading),c=sh(ge=>ge.fetchConfig),u=sh(ge=>ge.saveConfig),d=ct(ge=>ge.defaults),h=ct(ge=>ge.userItems),p=ct(ge=>ge.fetchAgents),m=[...d,...h].filter(ge=>!ge.subagent),g=()=>{try{zt.send("context.checkDynamic",{})}catch{}t()},[x,w]=j.useState(n.customInstructions??""),[C,v]=j.useState(n.dangerLevel??""),[S,_]=j.useState(n.defaultAgent??""),[b,k]=j.useState(!1),[E,T]=j.useState(!1),[D,A]=j.useState(!1),[R,M]=j.useState(!1),[W,$]=j.useState(null),G=S!==""&&!m.some(ge=>ge.id===S),[B,H]=j.useState(""),[q,Q]=j.useState(!1),[J,U]=j.useState(""),[I,O]=j.useState(!1),[V,z]=j.useState(""),[Y,X]=j.useState(!1),[Z,F]=j.useState(!1),[P,te]=j.useState([]),[se,re]=j.useState(""),[ae,ye]=j.useState({}),[_e,Ie]=j.useState(!1),[He,je]=j.useState(new Set),Ge=b||E||D||q||I||_e;j.useEffect(()=>{e&&(w(n.customInstructions??""),v(n.dangerLevel??""),_(n.defaultAgent??""),k(!1),T(!1),A(!1),Q(!1),O(!1),Ie(!1),je(new Set),c(n.workdir),p().catch(()=>{}))},[e,n,c,p]),j.useEffect(()=>{a!=null&&a.setup&&a.setup.length>0?H(a.setup.join(" && ")):H(""),U((a==null?void 0:a.rootDir)??""),ye((a==null?void 0:a.mcpOverrides)??{})},[a]);const Ze=tu(ge=>ge.servers),Se=ge=>ae[ge]??{},be=ge=>{var Xe;const fe=Se(ge);if(fe.disabled!==void 0)return fe.disabled;const Fe=Ze.find(_t=>_t.name===ge);return!!((Xe=Fe==null?void 0:Fe.config)!=null&&Xe.disabled)},de=(ge,fe)=>{var Xe;return((Xe=Se(ge).disabledTools)==null?void 0:Xe.includes(fe))??!1},ie=ge=>{ye(fe=>({...fe,[ge]:{...fe[ge],disabled:!be(ge)}})),Ie(!0)},Pe=(ge,fe)=>{ye(Fe=>{const Xe=Fe[ge]??{},_t=Xe.disabledTools??[],Dt=_t.includes(fe)?_t.filter(Ct=>Ct!==fe):[..._t,fe];return{...Fe,[ge]:{...Xe,disabledTools:Dt.length>0?Dt:void 0}}}),Ie(!0)},Ue=ge=>{je(fe=>{if(fe.has(ge)){const Xe=new Set(fe);return Xe.delete(ge),Xe}const Fe=new Set(fe);return Fe.add(ge),Fe})},ue=ge=>{w(ge.target.value),k(!0)},De=ge=>{v(ge),T(!0)},qe=ge=>{H(ge.target.value),Q(!0)},pe=ge=>{U(ge.target.value),O(!0)},he=j.useCallback(async()=>{const fe={customInstructions:x||null,dangerLevel:C===""?null:C};if(D&&(fe.defaultAgent=S===""?null:S),await r(n.id,fe),q||I||_e){const Fe=B.trim()?B.split("&&").map(_t=>_t.trim()).filter(Boolean):[],Xe={};q&&(Xe.setup=Fe),I&&(Xe.rootDir=J.trim()),Object.keys(ae).length>0&&(Xe.mcpOverrides=ae),await u(n.workdir,Xe)}k(!1),T(!1),A(!1),Q(!1),O(!1),Ie(!1),g()},[n.id,C,x,S,D,B,J,ae,q,I,_e,r,u,n.workdir,g]),We=async()=>{const ge=J.trim(),fe=(a==null?void 0:a.rootDir)??"";if(ge){const Fe=sU(ge);if(Fe==="exact"){const Xe=hT(ge);$(`Cannot use "${Xe}" directly as workspace root. Use a subdirectory like "${iU(ge,n.name)}" instead.`);return}if(Fe==="virtual_fs"){$(`Cannot use paths under "${ge}" for workspaces.`);return}}if(!I||!ge||ge===fe){M(!0),$(null);try{await he()}catch(Fe){$(Fe instanceof Error?Fe.message:"Failed to save settings")}finally{M(!1)}return}z(ge),M(!0),$(null);try{const Fe=await xe(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:ge,workdir:n.workdir,projectName:n.name})});if(!Fe.ok){const _t=await Fe.json().catch(()=>({}));$((_t==null?void 0:_t.error)??"Failed to validate workspace root directory");return}const Xe=await Fe.json();if(!Xe.exists){re(Xe.resolvedPath),X(!0);return}if(Xe.workspaces&&Xe.workspaces.length>0){te(Xe.workspaces),F(!0);return}$(null),await he()}catch(Fe){$(Fe instanceof Error?Fe.message:"Failed to validate settings")}finally{M(!1)}},Ve=async()=>{X(!1),M(!0);try{const ge=await xe(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:V,workdir:n.workdir,projectName:n.name,createIfMissing:!0})});if(!ge.ok){const Fe=await ge.json().catch(()=>({}));$((Fe==null?void 0:Fe.error)??"Failed to create directory"),M(!1);return}const fe=await ge.json();if(fe.workspaces&&fe.workspaces.length>0){te(fe.workspaces),F(!0),M(!1);return}await he()}catch(ge){$(ge instanceof Error?ge.message:"Failed to create directory")}finally{M(!1)}},et=async()=>{F(!1),M(!0),$(null);try{await he()}catch(ge){$(ge instanceof Error?ge.message:"Failed to save settings")}finally{M(!1)}},it=()=>{X(!1),F(!1),w(n.customInstructions??""),v(n.dangerLevel??""),_(n.defaultAgent??""),k(!1),T(!1),A(!1),Q(!1),O(!1),g()};return s.jsxs(wt,{isOpen:e,onClose:it,title:`${n.name} Settings`,size:"lg",footer:s.jsx(uT,{onCancel:it,onSave:We,saving:R,saveDisabled:!Ge||R}),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:()=>De(""),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${C===""?"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:()=>De("normal"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${C==="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:()=>De("dangerous"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${C==="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:S,onChange:ge=>{_(ge.target.value),A(!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:R,children:[s.jsx("option",{value:"",children:"Use system default"}),G&&s.jsxs("option",{value:S,children:[S," (missing agent)"]}),m.map(ge=>s.jsx("option",{value:ge.id,children:ge.name},ge.id))]}),G&&s.jsxs("p",{className:"text-xs text-red-400 mt-1",children:['The stored default agent "',S,'" no longer exists. Pick another agent to restore a valid default.']}),m.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:x,onChange:ue,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:R})]}),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:B,onChange:qe,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||R})]}),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:J,onChange:pe,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||R})]}),Ze.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:Ze.map(ge=>{const fe=be(ge.name);return s.jsx(VN,{server:ge,expanded:He.has(ge.name),onToggleExpand:Ue,serverToggleEnabled:!fe,onServerToggle:()=>ie(ge.name),tools:ge.tools.map(Fe=>({...Fe,enabled:!de(ge.name,Fe.name)})),onToolToggle:Fe=>Pe(ge.name,Fe),statusDot:Hb(fe?"disabled":ge.status),statusColor:zb(fe?"disabled":ge.status)},ge.name)})})]}),W&&s.jsx("div",{className:"text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded px-3 py-2",children:W})]}),Y&&s.jsxs(wt,{isOpen:Y,onClose:()=>X(!1),title:"Directory not found",size:"md",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>X(!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:Ve,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:se})," does not exist."]}),s.jsx("p",{className:"text-sm text-text-muted mt-2",children:"Would you like to create it?"})]}),Z&&s.jsxs(wt,{isOpen:Z,onClose:()=>F(!1),title:"Orphaned workspaces",size:"md",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>F(!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:et,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:[P.length," existing workspace(s) will not be migrated and will become inaccessible:"]}),s.jsx("ul",{className:"mt-2 space-y-1",children:P.map(ge=>s.jsx("li",{className:"text-sm font-mono text-text-muted",children:ge.name},ge.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 fT({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(p=>{p.preventDefault(),p.stopPropagation(),d.current={startX:p.clientX,startWidth:a},u(!0)},[a]);return j.useEffect(()=>{if(!c)return;const p=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,_)))},m=()=>{u(!1)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",m);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",p),document.removeEventListener("mouseup",m),document.body.style.userSelect=g,document.body.style.cursor=x}},[c,r,t,n]),{width:a,isResizing:c,handleMouseDown:h}}function mT({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 pT({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=Pn(),[a,o]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(null),[p,m]=j.useState(""),[g,x]=j.useState(!1),w=Re(be=>be.sessions),C=Re(be=>be.currentSession),v=Re(be=>be.unreadSessionIds),S=Re(be=>be.deleteSession),_=Re(be=>be.deleteAllSessions),b=Re(be=>be.loadMoreSessions),k=Re(be=>be.sessionsHasMore),E=Re(be=>be.sessionsPaginationLoading),T=Re(be=>be.sessionsWithPendingConfirmations),D=Re(be=>be.pendingPathConfirmations),A=Re(be=>be.toggleFavorite),R=Yt(be=>be.currentProject),[M,W]=j.useState(""),[$,G]=j.useState(-1),B=j.useRef(null),H=j.useRef(null),{width:q,handleMouseDown:Q}=fT({initialWidth:300,minWidth:200,maxWidth:600,direction:"left"}),J=j.useRef(!1),U=pu();ru(U.sessionSearch,()=>{var be;if(t&&document.activeElement===B.current){n==null||n();return}t||(J.current=!0,n==null||n()),Ft()&&((be=B.current)==null||be.focus())});const I=j.useRef(null),O=j.useCallback(()=>{k&&!E&&R&&b(R.id)},[k,E,R,b]);j.useEffect(()=>{if(!I.current||!k)return;const be=new IntersectionObserver(de=>{const ie=de[0];ie&&ie.isIntersecting&&O()},{threshold:.1});return be.observe(I.current),()=>be.disconnect()},[k,O]);const V=w.filter(be=>be.projectId===(R==null?void 0:R.id)),[z,Y]=j.useMemo(()=>{const be=[],de=[];for(const ie of V)ie.isFavorite?be.push(ie):de.push(ie);return[be,de]},[V]),X=be=>M?be.filter(de=>{var Ue;const ie=de.title??"",Pe=(((Ue=de.recentUserPrompts)==null?void 0:Ue.map(ue=>ue.content))??[]).join(" ");return Ki(ie,M)||Ki(Pe,M)}):be,Z=j.useMemo(()=>X(z),[z,M]),F=j.useMemo(()=>X(Y),[Y,M]),P=[...Z,...F],te=M.length>0,se=te&&P.length===0;j.useEffect(()=>{G(P.length>0?0:-1)},[P.length]),j.useEffect(()=>{var de;if($<0)return;const be=(de=H.current)==null?void 0:de.querySelector(`[data-sidx="${$}"]`);be==null||be.scrollIntoView({block:"nearest"})},[$]);const re=(be,de)=>{de==null||de.stopPropagation(),u(be)},ae=()=>{c&&(S(c),(C==null?void 0:C.id)===c&&r(`/p/${e}`),u(null))},ye=(be,de)=>{de==null||de.stopPropagation();const ie=w.find(Ue=>Ue.id===be),Pe=(ie==null?void 0:ie.title)??be.slice(0,6);m(Pe),h(be)},_e=()=>{if(!d||p.trim()==="")return;const be=Re.getState().renameSession;be(d,p.trim()),h(null),m("")},Ie=()=>{x(!0)},He=()=>{_(e),r(`/p/${e}`),x(!1)},je=(be,de)=>{A(be,!de)},Ge=be=>{if(!J.current)return;be.target.closest('a[href*="/s/"]')&&(J.current=!1,n==null||n())},Ze=()=>{var be;W(""),Ft()&&((be=B.current)==null||be.focus())},Se=be=>{var de;switch(be.key){case"Escape":W(""),(de=B.current)==null||de.blur();break;case"ArrowDown":be.preventDefault(),G(ie=>ie<P.length-1?ie+1:ie);break;case"ArrowUp":be.preventDefault(),G(ie=>ie>0?ie-1:0);break;case"Enter":{be.preventDefault();const ie=P[$];ie&&(r(`/p/${e}/s/${ie.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 be=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[s.jsx(lr,{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(Tl,{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(Yy,{})})}),n&&s.jsx(Cu,{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(hi,{className:"absolute left-2.5 w-3.5 h-3.5 text-text-muted pointer-events-none"}),s.jsx("input",{ref:B,type:"text",value:M,onChange:de=>W(de.target.value),onKeyDown:Se,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:Ze,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(ta,{className:"w-3.5 h-3.5"})})]}),te&&!se&&s.jsxs("div",{className:"mt-1 text-xs text-text-muted px-1",children:[P.length," ",P.length===1?"match":"matches"]})]}),R&&s.jsx(aU,{isOpen:a,onClose:()=>o(!1),project:R}),s.jsx(pl,{isOpen:c!==null,onClose:()=>u(null),onConfirm:ae,title:"Delete session?",message:"This session will be permanently deleted.",confirmLabel:"Delete session",confirmVariant:"danger"}),s.jsx(pl,{isOpen:g,onClose:()=>x(!1),onConfirm:He,title:"Delete all sessions?",message:"Delete all sessions in this project? This cannot be undone.",confirmLabel:"Delete all",confirmVariant:"danger"}),s.jsx(wt,{isOpen:d!==null,onClose:()=>{h(null),m("")},title:"Rename session",size:"sm",footer:s.jsx(uT,{onCancel:()=>{h(null),m("")},onSave:_e,saving:!1,saveDisabled:p.trim()==="",saveLabel:"Rename"}),children:s.jsx("input",{type:"text",value:p,onChange:de=>m(de.target.value),onKeyDown:de=>{de.key==="Enter"&&_e()},onFocus:de=>de.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:Ft()})}),s.jsx(ht,{className:"flex-1",children:P.length===0?s.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:te?"No matching sessions":"No sessions"}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"divide-y divide-border",ref:H,onClick:Ge,children:oU(Z,F,C,v,re,ye,je,e,T,D,M,$)}),E&&s.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),s.jsx("div",{ref:I,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":`${q}px`},children:[be,t&&s.jsx(mT,{side:"right",onMouseDown:Q,className:"hidden md:block"})]})})()]})}function oU(e,t,n,r,a,o,c,u,d,h,p,m){let g=0;const x=C=>{const v=g++,S=(n==null?void 0:n.id)===C.id,_=v===m,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(lr,{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:p?_y(C.title??C.id.slice(0,6),p):C.title??C.id.slice(0,6)}),s.jsx("div",{className:"flex items-center gap-1",children:s.jsx(Tl,{items:[{label:E?"Remove from favorites":"Add to favorites",icon:E?s.jsx(nu,{className:"w-3.5 h-3.5 text-amber-400"}):s.jsx(Nf,{className:"w-3.5 h-3.5"}),onClick:()=>c(C.id,E)},{label:"Rename session",onClick:D=>o(C.id,D)},{label:"Delete session",onClick:D=>a(C.id,D),danger:!0}],trigger:s.jsx("button",{onClick:D=>{D.preventDefault()},className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:s.jsx(Yy,{})})})})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[T?s.jsx("span",{title:"Awaiting confirmation",children:s.jsx(Qy,{className:"w-3 h-3 text-red-400 flex-shrink-0"})}):k?s.jsx(r3,{}):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:Qf(C.updatedAt)}),s.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[C.messageCount," messages"]})]})]})},C.id)},w=C=>{const v=ZN(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:JN(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(nu,{className:"w-3 h-3 text-amber-400"}),"Favorites"]}),e.map(C=>x(C))]}),t.length>0&&w(t)]})}const QC=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"];function lU(){var c;const e=Yt(u=>u.currentProject),t=Re(u=>u.currentSession),n=wf(),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)%QC.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 p;const d=(p=t==null?void 0:t.metadata)==null?void 0:p.title,h=n?`${QC[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}function gT({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const a=()=>{r(),t()};return s.jsx(pl,{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 cU({isOpen:e,onClose:t}){const[,n]=Pn(),[r,a]=j.useState(!1),o=XN(),[c,u]=j.useState(!1),d=Yt(A=>A.projects),h=Yt(A=>A.createProject),p=Yt(A=>A.listProjects),m=Yt(A=>A.deleteProject),[g,x]=j.useState(null),[w,C]=j.useState(null);j.useEffect(()=>{e&&p()},[e,p]);const v=A=>{n(`/p/${A}`),t()},S=(A,R)=>{R.stopPropagation(),x(A)},_=()=>{g&&(m(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 R=xu(A),M=await h(R,A);return p(),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)},[]),D=j.useCallback(async()=>{const A=w;C(null),A&&await E(A)},[w]);return e?s.jsxs(wt,{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(ht,{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(Qr,{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:tE(A.workdir,32)})]})]}),s.jsx("button",{onClick:R=>S(A,R),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:s.jsx(fi,{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(YN,{isOpen:r,onClose:()=>a(!1)}),g&&s.jsx(gT,{isOpen:!0,onClose:()=>x(null),projectName:g.name,onConfirm:_}),c&&s.jsx(Lf,{initialPath:o??void 0,onSelect:A=>{b(A)},onClose:()=>u(!1)}),w&&s.jsx(KN,{isOpen:!0,onClose:T,path:w,onRetry:D})]}):null}const uU=[{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 dU({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:uU.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 hU(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,o]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(null),p=j.useRef(null),m=Re(O=>O.searchSessions??O.sessions),g=Re(O=>O.searchSessions!==null),x=Yt(O=>O.projects),w=Yt(O=>O.loading),C=Yt(O=>O.listProjects),v=Re(O=>O.listHomeSessions),S=Re(O=>O.ensureFullSessionList),_=Yt(O=>O.deleteProject),b=Re(O=>O.connectionStatus),k=Pt(O=>O.summaries),E=Pt(O=>O.loadSummaries);j.useEffect(()=>{b==="connected"&&(C(),v())},[b,C,v]);const T=x.map(O=>O.id).sort().join(",");j.useEffect(()=>{T&&E(T.split(","))},[T,E]),j.useEffect(()=>{const O=setTimeout(()=>u(a),150);return()=>clearTimeout(O)},[a]),j.useEffect(()=>{c&&!g&&S()},[c,g,S]);const{matchCount:D,filteredSessionIds:A,relevanceScores:R,matchTypes:M,promptSnippets:W}=j.useMemo(()=>{if(!c)return{matchCount:0,filteredSessionIds:null,relevanceScores:null,matchTypes:null,promptSnippets:null};const O=new Map(x.map(Z=>[Z.id,Z])),V=new Map,z=new Map,Y=new Map,X=m.filter(Z=>{var _e;const F=O.get(Z.projectId),P=(F==null?void 0:F.name)??"",te=Z.title??"",se=((_e=Z.recentUserPrompts)==null?void 0:_e.map(Ie=>Ie.content))??[],re=se.join(" ");let ae=0,ye="";if(Ki(te,c)&&(ae+=10,ye="title"),Ki(re,c)){ae+=3,ye=ye==="title"?"title":"prompts";const Ie=se.find(He=>Ki(He,c));if(Ie){const He=Ie.toLowerCase().indexOf(c.toLowerCase());if(He>=0){const je=Math.max(0,He-30),Ge=Math.min(Ie.length,He+c.length+30);Y.set(Z.id,(je>0?"…":"")+Ie.slice(je,Ge)+(Ge<Ie.length?"…":""))}else Y.set(Z.id,Ie.slice(0,80)+(Ie.length>80?"…":""))}}return Ki(P,c)&&(ae+=1,ye=ye||"project"),V.set(Z.id,ae),z.set(Z.id,ye),ae>0});return{matchCount:X.length,filteredSessionIds:new Set(X.map(Z=>Z.id)),relevanceScores:V,matchTypes:z,promptSnippets:Y}},[m,c,x]),$=j.useMemo(()=>{const O=new Map;for(const V of m){const z=new Date(V.updatedAt).getTime(),Y=O.get(V.projectId)??0;z>Y&&O.set(V.projectId,z)}return O},[m]),G=j.useMemo(()=>{const O=new Map;for(const V of m){const z=O.get(V.projectId);z?z.push(V):O.set(V.projectId,[V])}for(const[,V]of O)V.sort((z,Y)=>new Date(Y.updatedAt).getTime()-new Date(z.updatedAt).getTime());return O},[m]),B=j.useMemo(()=>{let O=x;return c&&A&&(O=x.filter(V=>{const z=G.get(V.id);return z==null?void 0:z.some(Y=>A.has(Y.id))})),[...O].sort((V,z)=>{const Y=$.get(V.id)??new Date(V.updatedAt).getTime();return($.get(z.id)??new Date(z.updatedAt).getTime())-Y})},[x,G,c,A,$]),H=j.useCallback(O=>{const V=G.get(O);return V?c&&A&&R?V.filter(z=>A.has(z.id)).sort((z,Y)=>{const X=(R.get(Y.id)??0)-(R.get(z.id)??0);return X!==0?X:new Date(Y.updatedAt).getTime()-new Date(z.updatedAt).getTime()}):V.slice(0,5):[]},[G,c,A,R]),q=()=>{t(!0)},Q=()=>{var O;o(""),u(""),Ft()&&((O=p.current)==null||O.focus())},J=O=>{var V;O.key==="Escape"&&(Q(),(V=p.current)==null||V.blur())},U=c.length>0,I=U&&D===0;return s.jsxs(ht,{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.jsx(ot,{variant:"primary",onClick:q,children:"Open Project"})]}),m.length>0&&s.jsxs("div",{className:"mb-4 md:mb-6 relative",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(hi,{className:"absolute left-3 w-4 h-4 text-text-muted pointer-events-none"}),s.jsx("input",{ref:p,type:"text",value:a,onChange:O=>o(O.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:Q,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(ta,{className:"w-4 h-4"})})]}),U&&!I&&s.jsxs("div",{className:"mt-1.5 text-xs text-text-muted px-1",children:[D," ",D===1?"match":"matches"]})]}),I?s.jsxs("div",{className:"text-center py-16 text-text-muted",children:[s.jsx(hi,{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"})]}):B.map(O=>{const V=H(O.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(lr,{href:`/p/${O.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[s.jsx(Qr,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),s.jsx("span",{className:"text-text-primary font-semibold",children:O.name})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs(ot,{variant:"secondary",size:"sm",onClick:()=>h(O.id),title:`Tasks for ${O.name}`,"aria-label":`Tasks for ${O.name}`,className:"flex items-center gap-1.5",children:[s.jsx(Zy,{className:"w-4 h-4"}),s.jsx("span",{children:"Tasks"}),s.jsx(dU,{counts:k[O.id]})]}),s.jsx(lr,{href:`/p/${O.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:O.id,name:O.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(fi,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"divide-y divide-border",children:V.length>0?V.map(z=>{const Y=x.find(P=>z.projectId===P.id),X=Y?`/p/${Y.id}/s/${z.id}`:"#",Z=z.title??z.id.slice(0,8),F=M==null?void 0:M.get(z.id);return s.jsx(lr,{href:X,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:U&&F==="title"?_y(Z,c):Z}),U&&F&&F!=="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:F==="prompts"?"prompts":"project"}),F==="prompts"&&(W==null?void 0:W.get(z.id))&&s.jsx("span",{className:"text-[11px] text-text-muted truncate max-w-[250px]",children:_y(W.get(z.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:p7(z.updatedAt)}),s.jsxs("span",{className:"text-text-muted text-xs",children:[z.messageCount," msgs"]})]})]})},z.id)}):s.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},O.id)}),!U&&B.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(na,{})})]}),e&&s.jsx(cU,{isOpen:e,onClose:()=>t(!1)}),d&&s.jsx(qb,{isOpen:!0,onClose:()=>h(null),projectId:d}),n&&s.jsx(gT,{isOpen:!0,onClose:()=>r(null),projectName:n.name,onConfirm:()=>_(n.id)})]})}function fU(){const[,e]=vl("/p/:projectId/new"),[,t]=Pn(),n=e==null?void 0:e.projectId,r=Re(c=>c.createSession),a=Re(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(na,{})})}function mU(){const e=Yt(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(lr,{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 Rc=e=>Math.round(e*10)/10;function pU(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function wy(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function gU(e){return`${e.providerId}::${e.model}`}function xU(e){return`${e.providerName} > ${e.model}`}function ZC(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=wy(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 p=o>0?Rc(r/o):0,m=c>0?Rc(a/c):0;return{totalTime:Rc(t),aiTime:Rc(t-n),toolTime:Rc(n),prefillTokens:r,generationTokens:a,avgPrefillSpeed:p,avgGenerationSpeed:m,responseCount:e.length,llmCallCount:d.length,dataPoints:u,callDataPoints:d}}function yU(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null&&pU(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=gU(wy(a.stats)),c=n.get(o)??[];n.set(o,[...c,a])}const r=Array.from(n.entries()).map(([a,o])=>{const c=wy(o[0].stats),u=ZC(o);return{...c,key:a,label:xU(c),...u}});return{...ZC(t),modelGroups:r}}function bU(e){return j.useMemo(()=>yU(e),[e])}function Kb(){var a;const e=Re(o=>o.gitStatus),t=Re(o=>o.currentSession),[n,r]=j.useState(!0);return j.useEffect(()=>{t!=null&&t.workdir&&r(!1)},[t==null?void 0:t.workdir]),{branch:(e==null?void 0:e.branch)??null,diff:{files:((a=e==null?void 0:e.diff)==null?void 0:a.files)??[],loading:n,error:null}}}function xl(e){return e.toLocaleString("en-US").replace(/,/g," ")}function ek(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function Ts(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 tk=Object.assign(Object.create(null),{criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"}),nk=Object.assign(Object.create(null),{criteria:"criteria",review_findings:"review findings",todos:"tasks"});function ul(e){return Object.hasOwn(tk,e)?tk[e]:e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function vU(e){return Object.hasOwn(nk,e)?nk[e]:e.replace(/_/g," ")}const rk=["▁","▂","▃","▄","▅","▆","▇","█"];function _U(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 SU(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 wU(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}=SU(o,c),h=Math.max(0,u),p=Array.from({length:t},()=>" "),m=new Map;for(const g of n){const x=a===r?0:Math.round((g.x-r)/(a-r)*(t-1)),w=m.get(x)??[];m.set(x,[...w,g.y])}for(const[g,x]of m){const w=Math.max(...x);p[g]=rk[_U(w,u,d)]??rk[0]}return{blocks:p.join(""),minX:r,maxX:a,minY:h,maxY:d}}function sk(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function ik({data:e,width:t=60,height:n=78,label:r,xLabel:a,yLabel:o,showAxes:c=!0,formatY:u=sk,formatX:d=sk}){const h=j.useMemo(()=>{const p=wU(e,t),m=Math.max(t*6,240),g=10,x=8,C=[...e].sort((b,k)=>b.x-k.x).map(b=>{const k=p.maxX===p.minX?m/2:g+(b.x-p.minX)/(p.maxX-p.minX)*(m-g*2),E=p.maxY===p.minY?n/2:x+(p.maxY-b.y)/(p.maxY-p.minY)*(n-x*2);return{...b,cx:k,cy:E,leftPercent:k/m*100,topPercent:E/n*100}}),v=C.map((b,k)=>`${k===0?"M":"L"} ${b.cx.toFixed(1)} ${b.cy.toFixed(1)}`).join(" "),_=[p.maxY,(p.maxY+p.minY)/2,p.minY].map(b=>({value:b,y:p.maxY===p.minY?n/2:x+(p.maxY-b)/(p.maxY-p.minY)*(n-x*2)}));return{...p,chartWidth:m,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(p=>s.jsx("span",{children:u(p.value)},`${p.value}-${p.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(p=>s.jsx("line",{x1:"0",x2:h.chartWidth,y1:p.y,y2:p.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${p.y}`)),h.points.map(p=>s.jsx("line",{x1:p.cx,x2:p.cx,y1:n-4,y2:p.cy,stroke:"currentColor",className:"text-border/40"},`guide-${p.cx}-${p.cy}`)),h.points.length>1&&s.jsx("path",{d:h.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),h.points.map(p=>s.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${p.leftPercent}%`,top:`${p.topPercent}%`},title:`${d(p.x)} -> ${u(p.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-${p.x}-${p.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 CU({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(ik,{data:o,width:a,label:t,xLabel:r}),s.jsx(ik,{data:c,width:a,label:n,xLabel:r})]})}function kU(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 jU(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 EU(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 NU(e){return e.callDataPoints.length>0?EU(e):jU(e)}function Ya(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function Uc(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function TU(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${Ya(t)} ctx`:`${Ya(t)}-${Ya(n)} ctx`}function rf(e){return`${Uc(e)} t/s`}function xT(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function AU(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 LU({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?kU(d):[],[d]),p=j.useMemo(()=>d?NU(d):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[d]),m=j.useCallback(w=>{o(C=>({...C,[w]:!C[w]}))},[]),g=j.useCallback(()=>{if(!d)return;const w=AU(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 ne(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(wt,{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(ti,{label:"AI Time",value:Ts(d.aiTime)}),s.jsx(ti,{label:"Total Time",value:Ts(d.totalTime)}),s.jsx(ti,{label:"Tool Time",value:Ts(d.toolTime)}),s.jsx(ti,{label:"Responses",value:d.responseCount.toString()}),s.jsx(ti,{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(ti,{label:"Prefill Tokens",value:Ya(d.prefillTokens),subValue:`@ ${Uc(d.avgPrefillSpeed)} tok/s`}),s.jsx(ti,{label:"Gen Tokens",value:Ya(d.generationTokens),subValue:`@ ${Uc(d.avgGenerationSpeed)} tok/s`}),s.jsx(ti,{label:"Avg PP Speed",value:`${Uc(d.avgPrefillSpeed)}`,subValue:"tok/s"}),s.jsx(ti,{label:"Avg TG Speed",value:`${Uc(d.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),d&&p.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(CU,{data:p.points,width:50,prefillLabel:p.prefillLabel,generationLabel:p.generationLabel,xLabel:p.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(ht,{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(DU,{row:w,index:C,isExpanded:a[w.messageId]??!1,onToggle:w.isExpandable?()=>m(w.messageId):void 0}),(a[w.messageId]??!1)&&w.calls.map((v,S)=>s.jsx(RU,{dataPoint:v,index:S},`${v.messageId}-${v.callIndex}`))]},w.messageId))})]})})]})]})})}function ti({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 DU({row:e,index:t,isExpanded:n,onToggle:r}){const a=e.calls.length>0?TU(e.calls.map(o=>o.promptTokens)):`${Ya(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:xT(e.timestamp)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Ts(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:rf(e.prefillSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:rf(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 RU({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:xT(e.timestamp)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Ts(e.totalTime)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Ya(e.promptTokens)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:rf(e.prefillSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:rf(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 OU={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"}},yT=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function IU(e){return OU[e]??{icon:"○",color:"text-text-muted"}}function Yb(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const Al=j.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:r,color:a}=IU(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:yT.map(r=>{const a=n[r];return a?s.jsxs("span",{className:"flex items-center gap-0.5",children:[s.jsx(Al,{status:r}),s.jsx("span",{children:a})]},r):null})})]})}const bT=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(Al,{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,"]"]})," ",Yb(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(fi,{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"})]})]})})]})]})}),MU={criteria:["pending","completed","passed","failed"],todos:["pending","in_progress","completed"],review_findings:["open","resolved","dismissed"]},PU=["pending","completed","failed","dismissed"];function BU(e){return MU[e]??PU}function $U(e,t){const n=t.indexOf(e);return n===-1?t[0]??"pending":t[(n+1)%t.length]??"pending"}function vT({entries:e,sessionId:t,metadataKey:n,title:r,isOpen:a,onClose:o}){const[c,u]=j.useState(e),[d,h]=j.useState(null),[p,m]=j.useState(""),[g,x]=j.useState(!1),[w,C]=j.useState(""),v=j.useRef(null),S=j.useRef(null),_=j.useCallback(()=>{const $=S.current;$&&($.style.height="auto",$.style.height=$.scrollHeight+"px")},[]);j.useEffect(()=>{u(e)},[e]),j.useEffect(()=>{var $;d&&(_(),Ft()&&(($=S.current)==null||$.focus()))},[d,_]),j.useEffect(()=>{var $;g&&Ft()&&(($=v.current)==null||$.focus())},[g]);const b=j.useCallback($=>{u($),xe(`/api/sessions/${t}/metadata/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:$})}).catch(G=>console.error(`Failed to sync ${n}:`,G))},[t,n]),k=j.useCallback($=>{const G=BU(n),B=c.map(H=>H.id===$?{...H,status:$U(H.status,G)}:H);b(B)},[c,n,b]),E=j.useCallback(($,G)=>{h($),m(G)},[]),T=j.useCallback(($,G,B)=>{var Q;const H=(G.trim()||((Q=B.find(J=>J.id===$))==null?void 0:Q.description))??"",q=B.map(J=>J.id===$?{...J,description:H}:J);b(q)},[b]),D=j.useCallback(()=>{d&&(T(d,p,c),h(null))},[d,p,c,T]),A=j.useCallback($=>{$.key==="Enter"&&D(),$.key==="Escape"&&($.stopPropagation(),h(null))},[D]),R=j.useCallback($=>{b(c.filter(G=>G.id!==$))},[c,b]),M=j.useCallback(()=>{const $=w.trim();if(!$)return;const G=c.map(H=>Number(H.id)).filter(H=>Number.isInteger(H)&&H>=0),B=String(Math.max(-1,...G)+1);b([...c,{id:B,description:$,status:"pending"}]),C("")},[w,c,b]),W=j.useCallback($=>{$.key==="Enter"&&($.preventDefault(),M()),$.key==="Escape"&&(x(!1),C(""))},[M]);return s.jsxs(wt,{isOpen:a,onClose:o,title:r,size:"full",showCloseButton:!0,closeOnEscape:!0,children:[s.jsxs("ul",{className:"space-y-1",children:[c.map(($,G)=>{const B=d===$.id,H=s.jsxs("button",{onClick:()=>E($.id,$.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:["[",$.id,"]"]})," ",s.jsx("span",{children:Yb($.description)})]}),q=B?s.jsx("textarea",{ref:S,value:p,onChange:Q=>{m(Q.target.value),_()},onBlur:D,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}):H;return s.jsxs("li",{className:`flex items-start gap-2 px-2 py-1.5 ${G>0?"border-t border-border":""}`,children:[s.jsx("button",{onClick:()=>k($.id),className:"flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity mt-0.5",title:"Click to cycle status",children:s.jsx(Al,{status:$.status})}),s.jsx("div",{className:"flex-1 min-w-0",children:q}),s.jsx("button",{onClick:()=>R($.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(ta,{className:"w-4 h-4"})})})]},$.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:$=>C($.target.value),onKeyDown:W,placeholder:"New entry...",className:"flex-1 bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"}),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(es,{className:"w-4 h-4"}),"Add"]})]})})]})}const zU={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function HU(e,t){await xe(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function ih({id:e,agents:t}){const n=Qa(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 FU({id:e}){const t=Ht(c=>c.defaults),n=Ht(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 _T({entries:e,sessionId:t}){const[n,r]=j.useState(e),[a,o]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState(""),[p,m]=j.useState(""),[g,x]=j.useState(!1),[w,C]=j.useState(!1),v=ct(J=>J.defaults),S=ct(J=>J.userItems),_=ct(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&&Ft()&&((J=k.current)==null||J.focus())},[a]),j.useEffect(()=>{var J;c&&Ft()&&((J=E.current)==null||J.focus())},[c]);const T=j.useCallback(J=>{r(J),HU(t,J)},[t]),D=j.useCallback(J=>{var z;const U=J.map(Y=>Y.trim()).filter(Boolean);if(U.length===0)return;const I=n.map(Y=>Number(Y.id)).filter(Y=>Number.isInteger(Y)&&Y>=0),O=Math.max(-1,...I)+1,V=U.map((Y,X)=>({id:String(O+X),description:Y,status:"pending"}));T([...n,...V]),h(""),Ft()&&((z=k.current)==null||z.focus())},[n,T]),A=j.useCallback(()=>{D([d])},[D,d]),R=j.useCallback(J=>{const U=J.clipboardData.getData("text/plain").split(/\r\n|\r|\n/);U.length<2||(J.preventDefault(),D(U))},[D]),M=j.useCallback(()=>{o(!1),h("")},[]),W=j.useCallback((J,U)=>{u(J),m(U)},[]),$=j.useCallback(()=>{if(!c)return;const J=p.trim(),U=n.map(I=>I.id===c?{...I,description:J||I.description}:I);T(U),u(null)},[c,p,n,T]),G=j.useCallback(J=>{const U=n.map(I=>I.id===J?{...I,status:zU[I.status]??"pending"}:I);T(U)},[n,T]),B=j.useCallback(J=>{T(n.filter(U=>U.id!==J))},[n,T]),H=j.useCallback(()=>{T([]),x(!1)},[T]),q=j.useCallback(J=>{J.key==="Enter"&&(J.preventDefault(),A()),J.key==="Escape"&&M()},[A,M]),Q=j.useCallback(J=>{J.key==="Enter"&&$(),J.key==="Escape"&&u(null)},[$]);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,U)=>{const I=J.status,O=c===J.id;return s.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${U>0?"border-t border-border":""}`,children:[s.jsx("button",{onClick:()=>G(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(Al,{status:I})}),s.jsx("div",{className:"flex-1 min-w-0",children:O?s.jsx("input",{ref:E,value:p,onChange:V=>m(V.target.value),onBlur:$,onKeyDown:Q,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:()=>W(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,"] ",Yb(J.description)]})}),s.jsx("button",{onClick:()=>B(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(ta,{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:q,onPaste:R,placeholder:"New criterion...",className:"flex-1 bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"})]})}),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(es,{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(es,{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:H,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(fi,{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(kf,{className:"w-3 h-3"})})]}),s.jsx(wt,{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(ih,{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(FU,{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(ih,{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(ih,{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(ih,{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 ST({isOpen:e,onClose:t}){const n=Jn(C=>C.config),r=Jn(C=>C.saveConfig),[a,o]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(!1),[p,m]=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),m((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:p}),x(!1),t())};return s.jsx(wt,{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:p,onChange:C=>m(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 ak={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"},UU={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"},ok={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},VU="text-text-primary";function GU(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 p=ak[h];p&&d.push(p)}else if(h>=40&&h<=47){const p=UU[h];p&&d.push(p)}else if(h>=90&&h<=97){const p=ak[h];p&&d.push(p)}else if(h in ok){const p=ok[h];p&&d.push(p)}else h===39?d.push(VU):h===49&&(a=a.split(" ").filter(p=>!p.startsWith("bg-")).join(" "));d.length>0&&(a=d.join(" ")),r=n.lastIndex}if(r<e.length){const 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:WU(e),className:"text-text-primary"}]}}function WU(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function af(e){const t=GU(e),n=[];return t.forEach((r,a)=>{const o=r.text.split(`
|
|
285
|
+
`);o.forEach((c,u)=>{n.push(cs.createElement("span",{key:`${a}-${u}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},c)),u<o.length-1&&n.push(cs.createElement("br",{key:`${a}-${u}-br`}))})}),n.length===1?n[0]:n}function wT({logs:e,preRef:t,preClassName:n="text-sm font-mono",scrollAreaRef:r,onScrollbarGesture:a}){return s.jsx(ht,{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:af(o.content)},c))})})}function Xb({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 qU=100,KU=6,YU=1500,CT=(e,t)=>e==="down"?!1:t!==null&&t<=KU,ku=(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,p]=j.useState(!0),m=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,p(b)},[]),x=j.useCallback(()=>{g(!1)},[g]),w=j.useCallback(()=>{if(!r.current)return;const b=m();b&&(u.current=!0,b.scrollTop=b.scrollHeight,requestAnimationFrame(()=>{requestAnimationFrame(()=>{u.current=!1})}),c.current=Date.now())},[m]),C=j.useCallback((b,k)=>{b==="down"&&(o.current=!0);const E=CT(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=m();if(!b)return;const k=()=>{const $=d.current;requestAnimationFrame(()=>{requestAnimationFrame(()=>{if($!==d.current)return;b.scrollHeight-b.scrollTop-b.offsetHeight<qU&&(c.current=Date.now(),g(!0))})})},E=$=>{if($.deltaY>0){k();return}x()},T=$=>{$.touches[0]&&(a.current=$.touches[0].clientY)},D=$=>{if(a.current===null)return;const G=$.touches[0];if(!G)return;if(G.clientY-a.current>0){x();return}k()},A=()=>{o.current||u.current||Date.now()-c.current<=YU||g(!1)},R=$=>{if(!($.ctrlKey||$.metaKey||$.altKey)){if($.key==="ArrowUp"||$.key==="PageUp"||$.key==="Home"){x();return}($.key==="ArrowDown"||$.key==="PageDown"||$.key==="End")&&k()}},M=new MutationObserver(()=>{r.current&&requestAnimationFrame(w)}),W=setInterval(()=>{r.current&&w()},1e3);return b.addEventListener("wheel",E,{passive:!0}),b.addEventListener("touchstart",T,{passive:!0}),b.addEventListener("touchmove",D,{passive:!0}),b.addEventListener("scroll",A,{passive:!0}),b.addEventListener("keydown",R),b.tabIndex=-1,M.observe(b,{childList:!0,subtree:!0,characterData:!0}),()=>{b.removeEventListener("wheel",E),b.removeEventListener("touchstart",T),b.removeEventListener("touchmove",D),b.removeEventListener("scroll",A),b.removeEventListener("keydown",R),M.disconnect(),clearInterval(W)}},[t==null?void 0:t.id,m,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}},ju=e=>j.useCallback(()=>{var t,n;return((n=(t=e.current)==null?void 0:t.osInstance())==null?void 0:n.elements().viewport)??null},[e]),Jb=j.memo(function({title:t,subtitle:n,logs:r,onClose:a,onClear:o,onInsertMarker:c,preClassName:u}){const d=j.useRef(null),h=ju(d),{isAutoScrollActive:p,setAutoScroll:m,handleScrollbarGesture:g}=ku(d,null,h);return s.jsxs(wt,{isOpen:!0,onClose:a,title:t,size:"full",scrollable:!1,headerRight:s.jsx(Xb,{isActive:p,onToggle:m,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(es,{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(fi,{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(ht,{ref:d,className:"flex-1 -m-4 p-4",onScrollbarGesture:g,children:s.jsx(wT,{logs:r,preClassName:u})})]})}),XU=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 p=j.useCallback((g,x)=>{o(CT(g,x))},[o]),m=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=m();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)},[m]),j.useEffect(()=>{const g=m();g&&a&&(g.scrollTop=g.scrollHeight)},[t,a,c,m]),s.jsx("div",{className:`relative ${c?"":"hidden"}`,children:s.jsx(ht,{ref:d,className:"fixed z-40 text-sm font-mono text-text-primary bg-bg-primary p-2 rounded border border-border transition-all duration-150 ease-out select-text",onScrollbarGesture:p,style: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:af(g.content)},x))})})})}),kT=j.memo(function({workdir:t,compact:n,onExpand:r,onConfigure:a}){const o=Jn(O=>O.setWorkdir),c=Jn(O=>O.status),u=Jn(O=>O.config),d=Jn(O=>O.logs),h=Jn(O=>O.start),p=Jn(O=>O.stop),m=Jn(O=>O.fetchLogs),g=Jn(O=>O.clearLogs),x=Jn(O=>O.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),D=j.useRef(null),A=j.useRef(null),R=j.useCallback(()=>{var O,V;return((V=(O=A.current)==null?void 0:O.osInstance())==null?void 0:V.elements().viewport)??null},[]),{isAutoScrollActive:M,setAutoScroll:W,handleScrollbarGesture:$}=ku(A,null,R),G=j.useRef(null),B=j.useRef(null),H=j.useRef(null),q=()=>{const O=c==null?void 0:c.inspectProxyPort;if(!O){c!=null&&c.url&&window.open(c.url,"_blank");return}const V=`${window.location.protocol}//${window.location.hostname}:${O}`;window.open(V,"_blank")},Q=(c==null?void 0:c.state)??"off",J=u!==null,U=Q==="running"||Q==="warning";j.useEffect(()=>{o(t??null)},[t,o]),j.useEffect(()=>{U&&m()},[U,m]);const I=()=>{U?p():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 ${Q==="running"?"bg-accent-success":Q==="warning"?"bg-accent-warning":Q==="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(e3,{})})]}),J?s.jsx(s.Fragment,{children:Q==="running"||Q==="warning"?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:I,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(Qy,{}),"Stop"]}),(c==null?void 0:c.url)&&s.jsxs("button",{onClick:()=>q(),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(Jy,{}),"Open"]})]}):s.jsx("button",{onClick:I,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:H,className:`relative ${J&&U?"":"hidden"}`,onMouseEnter:()=>{!J||!U||n||(B.current&&clearTimeout(B.current),G.current=setTimeout(()=>{k(!0),T(!1)},500))},onMouseLeave:()=>{G.current&&clearTimeout(G.current),T(!0),B.current=setTimeout(()=>k(!1),150)},children:[s.jsx(wT,{logs:d,preRef:D,preClassName:"text-sm bg-bg-primary p-2 rounded max-h-[200px] border border-border",scrollAreaRef:A,onScrollbarGesture:$}),J&&U&&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(Xb,{isActive:M,onToggle:W,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),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)&&H.current&&mi.createPortal(s.jsx(XU,{logs:d,anchorRef:H,isHiding:E,isAutoScrollActive:M,onSetAutoScroll:W}),document.body)]})]}),!a&&s.jsx(ST,{isOpen:C,onClose:()=>v(!1)}),S&&s.jsx(Jb,{title:"Dev Server Logs",logs:d,onClose:()=>_(!1),onClear:w,onInsertMarker:x})]})}),JU=j.memo(function({sessionId:t}){const n=Vc(x=>x.processes),r=Vc(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 p=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"}},m=x=>{const w=Vc.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 ${p(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:()=>m(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(Jb,{title:(x==null?void 0:x.name)??"",subtitle:x==null?void 0:x.command,logs:c,onClose:()=>{o(null),u([])}})})()]})});function jT(){return en.getState().platform??null}function ET(e){const t=e.replace(/\\/g,"/");return encodeURI(t).replace(/#/g,"%23").replace(/\?/g,"%3F")}function NT(e,t,n){const r=jT(),a=e.startsWith("/")||e.match(/^[a-zA-Z]:[/\\]/)?e:n?`${n.replace(/\\/g,"/").replace(/\/$/,"")}/${e}`:e,o=ET(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 QU(e){const t=jT(),n=ET(e.replace(/\\/g,"/"));return t!=null&&t.isWSL&&t.wslDistro?`vscode://vscode-remote/wsl+${t.wslDistro}${n}`:`vscode://file/${n}`}function ZU({file:e,showEditorLink:t,workdir:n}){const r=tE(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?NT(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 e9(){const{diff:e}=Kb(),t=Rt(a=>a.settings[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",n=Re(a=>a.currentSession),r=(n==null?void 0:n.workspace)??(n==null?void 0:n.workdir);return e.loading?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(ht,{className:"mt-3 max-h-[150px]",children:s.jsx("div",{className:"pr-1",children:e.files.map((a,o)=>s.jsx(ZU,{file:a,showEditorLink:t,workdir:r},o))})})}function TT(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]),p=u.trim().length>0&&!t,m=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:p,resetState:m}}function AT({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(wt,{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(na,{})}):o})}function LT({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 DT({isOpen:e,onClose:t,projectId:n,sessionId:r,currentWorkspace:a,currentBranch:o}){const c=Re(G=>G.loadSession),{busy:u,setBusy:d,error:h,setError:p,loading:m,setLoading:g,newName:x,setNewName:w,handleClose:C,canCreate:v,resetState:S}=TT(t),[_,b]=j.useState([]),[k,E]=j.useState(null),[T,D]=j.useState(null),[A,R]=j.useState(!1);j.useEffect(()=>{e&&(S(),E(null),D(null),R(!1),xe(`/api/projects/${n}/workspaces`).then(G=>G.json()).then(G=>{b(G.workspaces),g(!1)}).catch(()=>{b([]),g(!1)}))},[e,n,S,g]);const M=j.useCallback(async G=>{p(null),d(!0);try{const B=await xe(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:G})});if(!B.ok){const H=await B.json().catch(()=>({error:"Failed to switch workspace"}));p(H.error),d(!1);return}await c(r,!0),t()}catch(B){p(B instanceof Error?B.message:"Failed to switch workspace"),d(!1)}},[r,c,t,p,d]),W=j.useCallback(async(G,B)=>{p(null),D(null),R((B==null?void 0:B.force)===!0),d(!0);try{const H=await xe(`/api/sessions/${r}/delete-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:G,force:(B==null?void 0:B.force)===!0})});if(!H.ok){const J=await H.json().catch(()=>({error:"Failed to delete workspace"}));p(J.error),J.conflictingSessionIds&&D(J.conflictingSessionIds),R(!1),d(!1);return}E(null),R(!1),await c(r,!0);const Q=await(await xe(`/api/projects/${n}/workspaces`)).json();b(Q.workspaces),d(!1),g(!1)}catch(H){p(H instanceof Error?H.message:"Failed to delete workspace"),R(!1),d(!1)}},[r,n,c,p,d]),$=j.useCallback(async()=>{p(null),d(!0);try{const G=await xe(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:x.trim()})});if(!G.ok){const B=await G.json().catch(()=>({error:"Failed to create workspace"}));p(B.error),d(!1);return}await c(r),t()}catch(G){p(G instanceof Error?G.message:"Failed to create workspace"),d(!1)}},[x,r,c,t,p,d]);return s.jsx(AT,{isOpen:e,onClose:C,title:"Switch Workspace",busy:u,loading:m,children:s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Workspaces"}),s.jsxs(ht,{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(Qr,{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((G,B)=>G.name===a?-1:B.name===a?1:G.name.localeCompare(B.name)).map(G=>s.jsx("div",{className:"group relative",children:k===G.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 ",G.name,"?"]}),s.jsx("button",{onClick:()=>W(G.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&&G.name!==a&&M(G.name)},disabled:u||G.name===a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${G.name===a?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"} ${u?"opacity-70":""}`,children:[s.jsx(Qr,{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:G.name}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:G.branch??"unknown"}),G.name===a&&s.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),G.name!==a&&!u&&s.jsx("button",{onClick:B=>{B.stopPropagation(),p(null),D(null),E(G.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:"✕"})]})},G.path))]}),s.jsx(LT,{icon:s.jsx(Qr,{}),title:"Create new workspace",placeholder:"workspace name",buttonLabel:"Create Workspace",value:x,onChange:w,onCreate:$,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(G=>s.jsx("li",{children:s.jsx(lr,{href:`/p/${n}/s/${G}`,className:"text-xs font-mono text-accent-primary hover:underline break-all",children:G})},G))}),s.jsx("button",{onClick:()=>W(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 RT({isOpen:e,onClose:t,sessionId:n}){const r=Re(D=>D.loadSession),{busy:a,setBusy:o,error:c,setError:u,loading:d,setLoading:h,newName:p,setNewName:m,handleClose:g,canCreate:x,resetState:w}=TT(t),[C,v]=j.useState([]),[S,_]=j.useState(""),[b,k]=j.useState("");j.useEffect(()=>{e&&(w(),_(""),v([]),k(""),xe(`/api/sessions/${n}/branches`).then(D=>D.json()).then(D=>{v(D.branches),k(D.defaultBranch??""),h(!1)}).catch(()=>{v([]),h(!1)}))},[e,n,w,h]);const E=j.useCallback(async D=>{u(null),o(!0);try{const A=await xe(`/api/sessions/${n}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:D})});if(!A.ok){const R=await A.json().catch(()=>({error:"Failed to switch branch"}));u(R.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 D={name:p.trim()};S&&(D.sourceBranch=S);const A=await xe(`/api/sessions/${n}/checkout-new`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)});if(!A.ok){const R=await A.json().catch(()=>({error:"Failed to create branch"}));u(R.error),o(!1);return}await r(n),t()}catch(D){u(D instanceof Error?D.message:"Failed to create branch"),o(!1)}},[p,S,n,r,t,u,o]);return s.jsx(AT,{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(ht,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2",children:C.map(D=>s.jsxs("button",{onClick:()=>{D.current||E(D.name)},disabled:a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${D.current?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"}`,children:[s.jsx(Ga,{className:"w-3.5 h-3.5 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:D.name}),D.current&&s.jsx("span",{className:"ml-auto text-xs text-text-muted",children:"(current)"}),!D.current&&s.jsx("span",{className:"ml-auto text-xs text-accent-primary",children:"Switch"})]},D.name))})]}),s.jsx(LT,{icon:s.jsx(Ga,{}),title:"Create new branch",placeholder:"feature/my-branch",buttonLabel:"Create Branch",value:p,onChange:m,onCreate:T,canCreate:x,busy:a}),p.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(Ga,{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:D=>_(D.target.value),placeholder:b||"main",className:"w-full text-sm bg-bg-primary border border-border-default rounded pl-8 pr-2 py-1.5 text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]}),c&&s.jsx("p",{className:"mt-3 text-sm text-accent-error bg-accent-error/10 p-2 rounded",children:c})]})})}function OT({workspaceName:e,branch:t,workdir:n,showEditorLink:r,sessionId:a,projectId:o,onEditWorkspace:c,onEditBranch:u}){const[d,h]=j.useState(!1),[p,m]=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:QU(n),className:"flex items-center gap-2 min-w-0 flex-1 no-underline group",title:"Open workspace in VSCode",children:[s.jsx(Qr,{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(Qr,{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(Ga,{}),s.jsx("span",{className:"truncate text-text-secondary",children:t}),s.jsx("button",{onClick:()=>{u?u():m(!0)},className:"ml-auto px-2 py-0.5 text-xs rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Edit"})]})]}),s.jsx(e9,{}),!c&&s.jsx(DT,{isOpen:d,onClose:()=>h(!1),projectId:o,sessionId:a,currentWorkspace:e,currentBranch:t}),!u&&s.jsx(RT,{isOpen:p,onClose:()=>m(!1),sessionId:a})]})}function t9(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function n9(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function Qb({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 ${n9(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function r9({dangerZone:e,size:t="md"}){return e?s.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function s9({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 yl=j.memo(function({code:t,language:n,variant:r,showLineNumbers:a=!1,startLine:o=1}){const{showSyntaxHighlighting:c}=Ds(),[u,d]=j.useState(null),h=$N(),p=j.useRef(t);if(j.useEffect(()=>{c&&(p.current=t,BN(t,n,h).then(g=>{p.current===t&&d(g)}))},[t,n,h,c]),!c||!u)return s.jsx(s9,{code:t,variant:r});if(r==="inline")return s.jsx("span",{dangerouslySetInnerHTML:{__html:u}});const m=a?"":"shiki-plain";return s.jsx("div",{className:m,style:{"--shiki-start":o},dangerouslySetInnerHTML:{__html:u}})});function IT({src:e,alt:t,isOpen:n,onClose:r}){return n?s.jsx(wt,{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 of=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})})})}),i9=j.memo(function({oldString:t,newString:n,filePath:r}){const a=j.useMemo(()=>Jf(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(of,{type:"removed",children:s.jsx(yl,{code:t,language:a,variant:"block",showLineNumbers:!0})}),c&&s.jsx(of,{type:"added",children:s.jsx(yl,{code:n,language:a,variant:"block",showLineNumbers:!0})})]})}),a9=j.memo(function({content:t,filePath:n}){const r=j.useMemo(()=>Jf(n),[n]);return s.jsx(cn,{className:"rounded border border-border max-h-[45vh]",children:s.jsx(of,{type:"added",children:s.jsx(yl,{code:t,language:r,variant:"block",showLineNumbers:!0})})})}),o9=j.memo(function({regions:t,filePath:n}){const r=j.useMemo(()=>Jf(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(c9,{region:a,language:r},o))})});function l9(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 c9=j.memo(function({region:t,language:n}){const r=l9(t);return s.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((a,o)=>s.jsx(u9,{section:a,language:n},o))})}),u9=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(yl,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):s.jsx(of,{type:t.type,children:s.jsx(yl,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function lk(e){return e.split(`
|
|
289
|
+
`).filter(t=>!t.startsWith(`
|
|
290
|
+
[`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+\|/,"")).join(`
|
|
291
|
+
`)}const d9=j.memo(function({result:t,metadata:n,filePath:r}){const[a,o]=j.useState(!1),c=j.useMemo(()=>Jf(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(IT,{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=lk(h);return s.jsx(cn,{className:"rounded border border-border max-h-[45vh] p-2",children:s.jsx(Qn,{content:w})})}const p=lk(h),m=h.split(`
|
|
292
|
+
`)[0],g=m==null?void 0:m.match(/^(\d+)\|/),x=g?parseInt(g[1],10):1;return s.jsx(cn,{className:"rounded border border-border max-h-[45vh]",children:s.jsx(yl,{code:p,language:c,variant:"block",showLineNumbers:!0,startLine:x})})});function h9({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 f9({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(h9,{type:r.type,content:r.content},a))})]})}function Zb({isOpen:e,onClose:t,isRunning:n,onApply:r}){const[a,o]=j.useState(null),[c,u]=j.useState(!1),d=j.useRef(null),h=j.useCallback(()=>{u(!0);const p=zt.send("context.applyDynamic.preview",{});d.current=p;const m=zt.subscribe(g=>{if(g.id===p&&g.type==="context.preview"){const x=g.payload;o(x.diff??[]),u(!1),d.current=null,m()}});setTimeout(()=>{d.current===p&&(u(!1),d.current=null,m())},5e3)},[]);return j.useEffect(()=>{e&&(o(null),u(!0),h())},[e,h]),s.jsxs(wt,{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."]})]}),c?s.jsx("div",{className:"py-8 text-center text-text-muted",children:"Loading diff..."}):a&&a.length>0?s.jsx(ht,{className:"max-h-[60vh] border border-border rounded-lg",children:s.jsx(f9,{diff:a})}):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 MT({variant:e="popover",onUpdateSystemPrompt:t}){const n=Re(D=>D.contextState),r=Re(D=>D.currentSession),a=Re(D=>D.compactContext),o=Re(D=>D.queueUpdate),[c,u]=j.useState(!1),[d,h]=j.useState(!1);if(!n||!r)return null;const{currentTokens:p,maxTokens:m,compactionCount:g,dangerZone:x,dynamicContextChanged:w}=n,C=Math.round(p/m*100),v=r.isRunning,S=()=>{v?o():zt.send("context.applyDynamic",{}),u(!1)},_=e==="sidebar",b=s.jsxs("span",{className:t9(C,x),children:[xl(p)," / ",xl(m)," (",C,"%)"]}),k=s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qb,{percent:C,dangerZone:x,className:"flex-1"}),s.jsx(r9,{dangerZone:x}),g>0&&s.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[g,"x"]})]}),E=s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>h(!d),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:s.jsx(Vj,{})}),d&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>h(!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:()=>{v||a(),h(!1)},disabled:v,className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:v?"Cannot compact while running":"Compact context",children:s.jsx("span",{className:x?"text-accent-error":"",children:"Compact"})}),w&&s.jsx("button",{onClick:()=>{h(!1),t?t():u(!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"})})]})]})]}),T=t?null:s.jsx(Zb,{isOpen:c,onClose:()=>u(!1),isRunning:v,onApply:S});return _?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:b}),k]}),s.jsx("div",{className:"shrink-0 pt-0.5",children:E})]}),T]}):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:b}),k]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("button",{onClick:()=>{v||a()},disabled:v,className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors disabled:opacity-40 disabled:cursor-not-allowed rounded",title:v?"Cannot compact while running":"Compact context",children:s.jsx("span",{className:x?"text-accent-error":"",children:"Compact"})}),w&&s.jsx("button",{onClick:()=>{t?t():u(!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"})})]}),T]})}function ck({messages:e,workdir:t}){var _,b,k;const[n,r]=j.useState(!1),[a,o]=j.useState(!1),[c,u]=j.useState(null),d=bU(e),{branch:h}=Kb(),p=en(E=>E.version),m=Re(E=>E.currentSession),g=xu((m==null?void 0:m.workspace)??"")||null,x=Rt(E=>E.settings[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",w=ui(E=>E.status),C=ui(E=>E.check),[v,S]=j.useState(!1);return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx(MT,{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:Ts(d.aiTime)}),s.jsx("span",{className:"w-px h-3 bg-border"}),s.jsx("span",{className:"text-text-secondary",children:ek(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:ek(d.avgGenerationSpeed)}),s.jsx("span",{children:"tg"})]})}),s.jsx(LU,{isOpen:n,onClose:()=>r(!1),stats:d})]}),s.jsx(ht,{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:((_=m==null?void 0:m.metadataEntries)==null?void 0:_.criteria)??[],title:"Acceptance Criteria"})}),m&&s.jsx(_T,{entries:((b=m==null?void 0:m.metadataEntries)==null?void 0:b.criteria)??[],sessionId:m.id}),m&&(()=>{const E=["review_findings","todos"],T=m.metadataEntries??{},D=E.filter(R=>R in T),A=Object.keys(T).filter(R=>R!=="criteria"&&!E.includes(R)).sort();return[...D,...A].filter(R=>{var M;return(((M=T[R])==null?void 0:M.length)??0)>0}).map(R=>s.jsxs("div",{className:"mt-6",children:[s.jsx("button",{onClick:()=>u(R),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(sf,{entries:T[R],title:ul(R)})}),s.jsx(bT,{entries:T[R],onClearAll:async()=>{try{await xe(`/api/sessions/${m.id}/metadata/${R}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:[]})})}catch(M){console.error(`Failed to clear ${R}:`,M)}}})]},R))})()]})}),s.jsx(OT,{workspaceName:g??"original",branch:h,workdir:t,showEditorLink:x,sessionId:(m==null?void 0:m.id)??"",projectId:(m==null?void 0:m.projectId)??""}),s.jsx(kT,{workdir:t}),s.jsx(JU,{sessionId:m==null?void 0:m.id}),p&&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",p]}),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(Ef,{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(oE,{isOpen:a,onClose:()=>o(!1),versionInfo:null}),s.jsx(vT,{isOpen:c!==null,onClose:()=>u(null),entries:((k=m==null?void 0:m.metadataEntries)==null?void 0:k[c??""])??[],sessionId:(m==null?void 0:m.id)??"",metadataKey:c??"",title:ul(c??"")})]})}function m9({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r}){const a=Re(u=>u.currentSession),{width:o,handleMouseDown:c}=fT({initialWidth:320,minWidth:240,maxWidth:600,direction:"right"});return s.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&s.jsx("div",{className:"fixed 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:o},children:[s.jsx(mT,{side:"left",onMouseDown:c}),s.jsx(ht,{className:"h-full p-4",children:s.jsx(ck,{messages:r,workdir:(a==null?void 0:a.workspace)??(a==null?void 0:a.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
|
+
fixed right-0 top-[32px] h-[calc(100vh-32px)] 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(ht,{className:"h-full",children:s.jsx(ck,{messages:r,workdir:(a==null?void 0:a.workspace)??(a==null?void 0:a.workdir)})})})})]})]})}function p9(){const e=Re(w=>w.contextState),t=Re(w=>w.currentSession),n=Re(w=>w.pendingUpdate),r=Re(w=>w.triggerPendingUpdate),a=Re(w=>w.queueUpdate),[o,c]=j.useState(!1),[u,d]=j.useState(!1),h=j.useRef(!1),p=j.useRef(!1);if(j.useEffect(()=>{e!=null&&e.dynamicContextChanged&&!h.current&&c(!1),h.current=(e==null?void 0:e.dynamicContextChanged)??!1},[e==null?void 0:e.dynamicContextChanged]),j.useEffect(()=>{const w=(t==null?void 0:t.isRunning)??!1;p.current&&!w&&n&&r(),p.current=w},[t==null?void 0:t.isRunning,n,r]),!e||!t)return null;const{dynamicContextChanged:m}=e,g=t.isRunning,x=()=>{g?a():zt.send("context.applyDynamic",{}),c(!0),d(!1)};return s.jsxs(s.Fragment,{children:[m&&!o&&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:()=>d(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),s.jsx("button",{onClick:()=>c(!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(ta,{})})]})}),s.jsx(Zb,{isOpen:u,onClose:()=>d(!1),isRunning:g,onApply:x})]})}function g9({stats:e,onClose:t}){var u;const n=ct(d=>d.defaults),r=ct(d=>d.userItems),o=[...n,...r].find(d=>d.id===e.mode),c=(o==null?void 0:o.name)??e.mode;return s.jsx(wt,{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(ah,{label:"Total Time",value:Ts(e.totalTime)}),s.jsx(ah,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),s.jsx(ah,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),s.jsx(ah,{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(oh,{label:"temp",value:d.temperature.toFixed(2)}),d.topP!==void 0&&s.jsx(oh,{label:"topP",value:d.topP.toFixed(2)}),d.topK!==void 0&&s.jsx(oh,{label:"topK",value:String(d.topK)}),d.maxTokens!==void 0&&s.jsx(oh,{label:"maxTok",value:String(d.maxTokens)})]})]})]},h))]})]})})}function ah({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 oh({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 x9=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(cn,{horizontal:!0,className:"ml-1.5 mt-0.5",children:s.jsx(Qn,{content:t})})]}):s.jsx(cn,{horizontal:!0,className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item",children:s.jsx(Qn,{content:t,muted:!0})})});function PT({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 y9={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"}},uk=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(cn,{className:"max-h-48",children:t.map((o,c)=>{const u=y9[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)})})]})}),b9=j.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:a,status:o,result:c,error:u,durationMs:d}){const h=j.useRef(null),[p,m]=j.useState(0),g=ju(h),{setAutoScroll:x,force_scroll_to_bottom:w,handleScrollbarGesture:C}=ku(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(()=>{m(Date.now()-r)},100);return()=>clearInterval(b)},[o,r]);const v=n/1e3,S=o==="pending"?p/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,p/n*100)}%`}})}),(_||o==="pending")&&s.jsx(ht,{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:af(b.content)},k)):af(_)}),o==="error"&&u&&s.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:u})]})}),Oc=j.memo(function({className:t=""}){return s.jsx("div",{className:`text-[10px] text-accent-warning ${t}`,children:"Output truncated"})});function BT(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(ht,{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 v9=j.memo(function({result:t,action:n}){const r=BT(t,"DevServerView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?_9(a):S9(a)});function _9(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(cn,{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 S9(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 w9=j.memo(function({result:t,action:n}){const r=BT(t,"BackgroundProcessView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?C9(a):n==="list"?k9(a):n==="status"?j9(a):n==="start"||n==="stop"?E9(a):s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"text-accent-warning",children:["Unknown action: ",n]}),s.jsx(cn,{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 C9(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(cn,{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 k9(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($T,{process:a},a.id)),n!=null&&r!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:[n," of ",r," slots used"]})]})}function j9(e){const t=e.process,n=e.uptime;return t?s.jsxs("div",{className:"space-y-2",children:[s.jsx($T,{process:t}),n!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Uptime: ",N9(n)]})]}):s.jsx("div",{className:"text-xs text-text-muted italic",children:"Process not found"})}function E9(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 $T({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 N9(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 T9=j.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return s.jsx(cn,{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 A9(r);case"switch":case"delete":return L9(r);default:return s.jsx(cn,{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 A9(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 yx({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 L9(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(yx,{label:"Name",value:e.workspace,mono:!0}),e.path&&s.jsx(yx,{label:"Path",value:e.path,mono:!0}),e.branch&&s.jsx(yx,{label:"Branch",value:e.branch,mono:!0})]})}const D9={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"}},R9=new Set(["get","create","edit","move","set_gate_value","duplicate","reorder"]),O9=j.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return s.jsx(bx,{result:t})}if(n==="list")return s.jsx(cn,{className:"max-h-[60vh]",children:s.jsx(I9,{data:r})});if(n==="set_gates"){const a=r.gates;return s.jsx(cn,{className:"max-h-[60vh]",children:s.jsx(M9,{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(bx,{result:t})}return R9.has(n)?s.jsx(cn,{className:"max-h-[60vh]",children:s.jsx(zT,{task:FT(r)})}):s.jsx(bx,{result:t})});function bx({result:e}){return s.jsx(cn,{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 I9({data:e}){const t=(e.tasks??[]).map(FT),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(lh,{title:"To Do",tasks:r}),s.jsx(lh,{title:"In Progress",tasks:a}),s.jsx(lh,{title:"Done",tasks:o}),s.jsx(lh,{title:"Other",tasks:c})]})]})}function lh({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(zT,{task:n},n.id))]})}function zT({task:e}){const t=D9[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 M9({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 HT(e){return typeof e=="object"&&e!==null?e:null}function Hi(e){return typeof e=="string"?e:""}function dk(e){return typeof e=="number"?e:void 0}function P9(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const r=HT(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 FT(e){const t=HT(e)??{},n=Hi(t.runState),r=dk(t.queuePosition),a=dk(t.attachments);return{id:Hi(t.id),prompt:Hi(t.prompt),status:Hi(t.status),...n?{runState:n}:{},...r!==void 0?{queuePosition:r}:{},...Hi(t.boundSession)?{boundSession:Hi(t.boundSession)}:{},...Hi(t.model)?{model:Hi(t.model)}:{},...a!==void 0?{attachments:a}:{},gates:P9(t.gateValues)}}function B9(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 $9({confirmation:e}){const t=Re(m=>m.confirmPath),n=Re(m=>m.currentSession),r=Re(m=>m.switchDangerLevel),{title:a,description:o}=B9(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",p=()=>{n!=null&&n.id&&r("dangerous"),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(zx,{}),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(ht,{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((m,g)=>s.jsx("li",{className:`text-xs font-mono ${c?"text-red-300":"text-amber-300"} break-all`,children:m},g))})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>t(e.callId,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border transition-colors",children:"Deny"}),s.jsx("button",{onClick:()=>t(e.callId,!0,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-accent-primary hover:bg-accent-primary/80 text-text-primary transition-colors",children:"Allow"}),s.jsx("button",{onClick:p,className:`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors ${h?"hidden":"bg-red-600 hover:bg-red-700 text-white"}`,title:"Enable dangerous mode and allow this request",children:"Allow Everything"})]})]})}function z9(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=z9(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 H9(e){return JSON.stringify(e,null,2)}const fk={ssh:"SSH",scp:"SCP",sftp:"SFTP",mosh:"MOSH"},F9=new Set(["-C","--close-from","-D","--chdir","-g","--group","-h","--host","-p","--prompt","-R","--chroot","-T","--command-timeout","-u","--user"]),U9=new Set(["-C","--chdir","-S","--split-string","-u","--unset"]),V9=new Set(["-p","-f","-d","-P"]);function mk(e){return e.split(/[\\/]/).pop()??e}function G9(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,p=!1,m=!0;for(;c<e.length;){const g=e[c];if(!h&&/\s|[;&|(){}<>]/.test(g))break;if(g==="'"||g==='"'){m=!1,h===g?(h=null,p=!1):h===null&&(h=g),c+=1;continue}if(!h&&g==="$"&&e[c+1]==="'"){m=!1,p=!0,h="'",c+=2;continue}if(g==="\\"&&c+1<e.length){if(m=!1,p){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:m}),a=c}return t}function W9(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(...G9(o))}return{command:n.join(`
|
|
303
|
+
`),expandableBodies:r}}function pk(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,p=null,m=!1;for(let g=u+2;g<e.length;g+=1){const x=e[g];if(m){m=!1;continue}if(x==="\\"&&p!=="'"){m=!0;continue}if(x==="'"||x==='"'){p=p===x?null:p===null?x:p;continue}if(!p&&(x==="("&&(h+=1),x===")"&&(h-=1),h===0)){n.push(e.slice(u+2,g)),u=g;break}}}}}return n}function q9(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 p=1;const m=d;for(let g=d+3;g<e.length-1;g+=1)if(e.slice(g,g+2)==="(("&&(p+=1),e.slice(g,g+2)==="))"&&(p-=1),p===0){r=!0,n+=e.slice(m,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 Wo(e,t,n){for(;t<e.length;){const r=e[t];if(r==="--")return t+1;if(!r.startsWith("-")||r==="-")return t;t+=1,!r.includes("=")&&n.has(r)&&(t+=1)}return t}function qr(e,t=0){if(t>8)return null;let n=0;for(;n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;const r=mk(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?$a(h,t+1):null}const d=u.match(/^--split-string=(.*)$/s);if(d)return $a(d[1],t+1)}for(n=Wo(e,n+1,U9);n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;return qr(e.slice(n),t+1)}if(r==="sudo")return n=Wo(e,n+1,F9),qr(e.slice(n),t+1);if(r==="sshpass")return n=Wo(e,n+1,V9),qr(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 $a(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],p=h.indexOf("#");if(p!==-1){const m=mk(h.slice(p+1).split("@")[0]),g=fk[m.toLowerCase()];if(g)return g}}return null}return null}return null}const a=r,o=fk[a];if(o)return o;if(a==="command"){if(e.slice(n+1).some(u=>u==="-v"||u==="-V"))return null;const c=Wo(e,n+1,new Set);return qr(e.slice(c),t+1)}if(a==="setsid"||a==="nohup"){const c=Wo(e,n+1,new Set);return qr(e.slice(c),t+1)}if(a==="timeout"){const c=Wo(e,n+1,new Set(["-k","--kill-after","-s","--signal"]));return qr(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?$a(h,t+1):null}if(!u.startsWith("-"))break}}return null}function $a(e,t=0){if(t>8)return null;const{command:n,expandableBodies:r}=W9(e),a=[...pk(n),...r.flatMap(m=>pk(m,!1))];for(const m of a){const g=$a(m,t+1);if(g)return g}const o=q9(n);let c=[];const u=new Set([";","|","&","(",")","{","}"]),d=new Set(["then","do","else","elif","if","while","until"]);let h=!1,p=!1;for(const m of o){if(m==="for"||m==="select"){const g=qr(c,t);if(g)return g;c=[],h=!0;continue}if(m==="case"){const g=qr(c,t);if(g)return g;c=[],p=!0;continue}if(h){m==="do"&&(h=!1);continue}if(p&&m===")"){c=[];continue}if(u.has(m)){const g=qr(c,t);if(g)return g;c=[]}else if(d.has(m)){const g=qr(c,t);if(g)return g;c=[]}else if(m==="fi"||m==="done"||m==="esac"){const g=qr(c,t);if(g)return g;c=[],m==="esac"&&(p=!1)}else c.push(m)}return qr(c,t)}function K9(e,t){return e!=="run_command"||typeof t.command!="string"?null:$a(t.command)}const Y9=600;function X9(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 J9={dev_server:v9,workspace:T9,project_tasks:O9,background_process:w9},Q9={pending:{icon:"●",color:"text-accent-warning",animate:!0},success:{icon:"✓",color:"text-accent-success",animate:!1},error:{icon:"✗",color:"text-accent-error",animate:!1},interrupted:{icon:"✗",color:"text-text-tool-error",animate:!1}},Z9=j.memo(function({tool:t,args:n,status:r,variant:a="compact",forceCompact:o,result:c,error:u,durationMs:d,diagnostics:h,editContext:p,startedAt:m,streamingOutput:g,metadata:x,truncated:w,callId:C}){var M;const{collapseLargeToolCalls:v}=Ds(),S=!o&&(!v||r==="pending"||X9(c,g,n)<Y9),[_,b]=j.useState(S),k=Q9[r],E=K9(t,n),T=Rt(W=>W.settings[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",D=t==="edit_file"?(M=p==null?void 0:p.regions[0])==null?void 0:M.startLine:t==="read_file"?(()=>{const W=c==null?void 0:c.split(`
|
|
307
|
+
`)[0],$=W==null?void 0:W.match(/^(\d+): /);return $?parseInt($[1],10):void 0})():void 0,A=Re(W=>W.pendingPathConfirmations),R=C?A.find(W=>W.callId===C||W.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(PT,{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(b9,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:m,streamingOutput:g,status:r,result:c,error:u,durationMs:d}),t==="edit_file"&&r==="success"&&s.jsxs(s.Fragment,{children:[p&&p.regions.length>0?s.jsx(o9,{regions:p.regions,filePath:String(n.path??"")}):s.jsx(i9,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),h&&h.length>0&&s.jsx(uk,{diagnostics:h})]}),t==="write_file"&&r==="success"&&s.jsxs(s.Fragment,{children:[s.jsx(a9,{content:String(n.content??""),filePath:String(n.path??"")}),h&&h.length>0&&s.jsx(uk,{diagnostics:h})]}),t==="read_file"&&r==="success"&&s.jsx(d9,{result:c,metadata:x,filePath:String(n.path??"")}),t==="return_value"&&(()=>{const W=(g==null?void 0:g.map(G=>G.content).join(""))??"",$=r==="pending"&&W?W: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(Qn,{content:$})})]})})(),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(cn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(Qn,{content:String(n.prompt??"")})})]}),t==="web_search"&&r==="success"&&s.jsxs("div",{children:[s.jsx(cn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(Qn,{content:c??""})}),w&&s.jsx(Oc,{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(cn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(Qn,{content:c??""})}),w&&s.jsx(Oc,{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(cn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(Qn,{content:c??""})}),w&&s.jsx(Oc,{})]}),(()=>{const W=J9[t];return!W||r!=="success"||!c?null:s.jsx(W,{result:c,action:String(n.action??"")})})(),t==="mcp_config"&&r==="success"&&s.jsxs("div",{children:[s.jsx(cn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(Qn,{content:c??""})}),w&&s.jsx(Oc,{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(cn,{horizontal:!0,children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:H9(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(cn,{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(Oc,{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:NT(String((x==null?void 0:x.path)??n.path),D),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})]}),R&&s.jsx($9,{confirmation:R})]})]})}),eV={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 tV(e,t){const n=eV[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const a=JSON.parse(t).key;if(a){const o=vU(a);return`${n} ${o}`}}catch{}return n}function nV(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 rV=j.memo(function({name:t,arguments:n}){let a=tV(t,n)+"...",o=null;if(t==="run_command"&&n){const c=nV(n);c&&(a=c,o=$a(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(PT,{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})]})})}),sV={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},iV=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=sV[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 aV(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 oV({toolCall:e}){var E;const t=Re(T=>T.pendingQuestions),n=Re(T=>T.answerQuestion),[r,a]=j.useState(""),o=j.useRef(null),c=j.useRef(null),u=t.find(T=>T.callId===e.id),d=e.arguments.question??(u==null?void 0:u.question)??"",h=e.arguments.type??(u==null?void 0:u.type)??"text",p=e.arguments.options??(u==null?void 0:u.options)??void 0,m=aV(p),g=e.result!==void 0,x=u!==void 0&&!g,w=((E=e.result)==null?void 0:E.output)??"",C=w==="[user skipped]";j.useEffect(()=>{x&&Ft()&&o.current&&o.current.focus()},[x]),j.useEffect(()=>{x&&c.current&&c.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[x]);const v=j.useCallback(()=>{u&&n(u.callId,r)},[u,r,n]),S=j.useCallback(()=>{u&&n(u.callId,"",!0)},[u,n]),_=j.useCallback(T=>{T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),v()),T.key==="Escape"&&!T.shiftKey&&(T.preventDefault(),S())},[v,S]),b=j.useCallback(T=>{u&&n(u.callId,T)},[u,n]),k="px-3 py-1.5 text-xs font-medium rounded transition-colors";return s.jsxs("div",{ref:c,className:"my-1",children:[s.jsx("div",{className:"text-sm text-text-primary",children:d}),x&&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:h==="confirm"?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>b("yes"),className:`${k} 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:()=>b("no"),className:`${k} 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:S,className:`${k} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]}):h==="choice"&&m!==void 0&&m.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex flex-col gap-1.5",children:m.map((T,D)=>s.jsxs("button",{onClick:()=>b(T.value),className:`${k} 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:T.label}),T.description!==void 0&&s.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:T.description})]},D))}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("textarea",{ref:o,value:r,onChange:T=>a(T.target.value),onKeyDown:_,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:v,disabled:!r.trim(),className:`${k} 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:S,className:`${k} 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:o,value:r,onChange:T=>a(T.target.value),onKeyDown:_,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:Ft()}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:S,className:`${k} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"}),s.jsx("button",{onClick:v,disabled:!r.trim(),className:`${k} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send Answer"})]})]})})}),g&&s.jsx("div",{className:"mt-1 flex items-center gap-2",children:s.jsx("span",{className:`text-xs ${C?"text-amber-400":"text-accent-success"}`,children:C?"Skipped":`Answered: ${w}`})})]})}const gk={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"}},lV=new Set(["get","list","schema"]),cV=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=>lV.has(String(u.arguments.action))?dV(u):[uV(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?ul(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 uV(e,t){return{key:e.id,node:s.jsx(hV,{tc:e,criteriaMap:t})}}function dV(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(Qn,{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(Qn,{content:t})})]})}]}function hV({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,p=a?`${(n&&{add:"Added",update:"Updated",remove:"Removed",complete:"Completed",pass:"Passed",fail:"Failed"}[n])??"Managed"} item`:"Criterion updated",m=u??(d==null?void 0:d.description)??(o&&c?`[${c}]`:p),g=r.reason,x=n==="fail";return s.jsxs(s.Fragment,{children:[a?s.jsx(Al,{status:r.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const w=n&&gk[n]?gk[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(Qn,{content:m})}),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 fV(e){return e==="criterion"||e==="session_metadata"}const mV="[interrupted by user]";function pV(e){if(!e)return"pending";const t=e.output??"";return!e.success&&t.trimEnd().endsWith(mV)?"interrupted":e.success?"success":"error"}async function UT(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 gV({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 p;if(!t)return;function d(m){r.current&&!r.current.contains(m.target)&&n()}function h(m){var g;switch(m.key){case"Escape":m.preventDefault(),n();break;case"ArrowDown":m.preventDefault(),o(x=>x<e.length-1?x+1:0);break;case"ArrowUp":m.preventDefault(),o(x=>x>0?x-1:e.length-1);break;case"Enter":m.preventDefault(),(g=e[a])==null||g.onClick(),n();break}}return document.addEventListener("mousedown",d),window.addEventListener("keydown",h,!0),window.addEventListener("blur",n),(p=r.current)==null||p.focus(),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",h,!0),window.removeEventListener("blur",n)}},[t,e,a,n]),!t)return null;let 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),mi.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(ht,{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 VT(){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(gV,{position:e,onClose:()=>t(null),items:a})}}function xV(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"&&fV(a.toolCall.name)?n.push(a.toolCall):(r(),t.push(a));return r(),t}function yV(e,t){if(e.segments&&e.segments.length>0)return bV(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 bV(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 ev=j.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:a=!0,sessionId:o}){const c=Re(T=>{var D,A;return(A=(D=T.currentSession)==null?void 0:D.metadataEntries)==null?void 0:A.criteria}),u=ct(T=>T.defaults),d=ct(T=>T.userItems),h=[...u,...d],p=yV(t,n),m=r?p:p.filter(T=>T.type!=="thinking"),g=xV(m),[x,w]=j.useState(!1),[C,v]=j.useState(null),[,S]=Pn(),{onContextMenu:_,contextMenu:b}=VT();if(g.length===0)return null;const k=()=>{UT(t.content)},E=async()=>{if(!o||x)return;w(!0),v(null);const T=await Dj(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,D)=>{switch(T.type){case"thinking":return s.jsx(x9,{content:T.content},D);case"text":return s.jsx("div",{className:"prose prose-sm prose-invert max-w-none feed-item",children:s.jsx(Qn,{content:T.content,isStreaming:t.isStreaming})},D);case"preparing_tool_call":return s.jsx(rV,{name:T.preparing.name,arguments:T.preparing.arguments},`preparing-${T.preparing.index}`);case"tool_call":{const A=T.toolCall,R=A.result;if(A.name==="ask_user")return s.jsx(oV,{toolCall:A},D);if(A.name==="todo_write"){const W=A.arguments.todos,$=Array.isArray(W)?W:[];return s.jsx(iV,{todos:$},D)}const M=pV(R);return s.jsx(Z9,{tool:A.name,args:A.arguments,status:M,variant:"expandable",forceCompact:!a,result:R==null?void 0:R.output,error:R==null?void 0:R.error,durationMs:R==null?void 0:R.durationMs,diagnostics:R==null?void 0:R.diagnostics,editContext:R==null?void 0:R.editContext,startedAt:A.startedAt,streamingOutput:A.streamingOutput,metadata:R==null?void 0:R.metadata,truncated:(R==null?void 0:R.truncated)??!1,callId:A.id},D)}case"criteria_group":return s.jsx(cV,{toolCalls:T.toolCalls,criteria:c},D);case"stats":{const A=T.stats;if(!A||"error"in A)return null;const R=A.model.split("/").pop()??A.model,M=Qa(h,A.mode),W=h.find(H=>H.id===A.mode),$=(W==null?void 0:W.name)??A.mode,G=H=>H>=1e3?`${(H/1e3).toFixed(1)}k`:H.toString(),B=H=>H>=1e3?`${(H/1e3).toFixed(1)}k`:H.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:R}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{style:{color:M},children:$}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{children:Ts(A.totalTime)}),A.toolTime>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[Ts(A.toolTime)," tools"]})]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[G(A.prefillTokens)," @ ",B(A.prefillSpeed)," pp"]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[G(A.generationTokens)," @ ",B(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 H=new CustomEvent("open-turn-stats",{detail:{stats:A}});window.dispatchEvent(H)},children:s.jsx(kf,{className:"w-3 h-3"})}),s.jsx("span",{className:"flex-1 h-px bg-border"})]},D)}}}),t.partial&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[s.jsx(zx,{}),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(zx,{}),s.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]}),b([{label:"Copy",icon:s.jsx(ml,{className:"w-4 h-4"}),onClick:()=>k()},{label:"Fork session from here",icon:s.jsx(Ga,{className:"w-4 h-4"}),onClick:()=>void E()}])]})});function lf(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 vV(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const _V=j.memo(function({data:t}){var a;const n=Zf(),r=(t.workflowId?(a=ef(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:lf(r,.3),backgroundColor:lf(r,.08)},children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(s3,{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(Ic,{label:"Iterations",value:String(t.iterations)}),s.jsx(Ic,{label:"Total time",value:Ts(t.totalTimeSeconds)}),s.jsx(Ic,{label:"Tool calls",value:String(t.totalToolCalls)}),s.jsx(Ic,{label:"Tokens",value:vV(t.totalTokensGenerated)}),s.jsx(Ic,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function Ic({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 SV=j.memo(function({data:t}){var a;const n=Zf(),r=((a=ef(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:lf(r,.3),backgroundColor:lf(r,.08)},children:[s.jsx(jf,{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 wV({attachments:e,messageId:t}){const[n,r]=j.useState(null),a=Re(p=>p.visionFallbackByMessage),o=Re(p=>p.messages),c=j.useMemo(()=>{const p=o.findIndex(m=>m.id===t);if(p===-1)return null;for(let m=p+1;m<o.length;m++){const g=o[m];if(g&&g.role==="assistant")return g.id}return null},[o,t]),u=p=>{r(p)},d=()=>{r(null)},h=p=>{const m=`${t}-${p}`;if(a[m])return a[m];if(c){const g=`${c}-${p}`;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(p=>{const m=h(p.id);return tT(p.mimeType)?s.jsxs("div",{className:"relative inline-block",children:[s.jsxs("button",{onClick:()=>u(p.data),className:"group relative inline-block",title:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,disabled:(m==null?void 0:m.type)==="start",children:[s.jsx("img",{src:p.data,alt:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(m==null?void 0:m.type)==="start"&&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..."})})]}),(m==null?void 0:m.type)==="done"&&m.description&&s.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[m.description.slice(0,200),m.description.length>200?"...":""]})]},p.id):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:nT(p.filename)}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-xs text-text-primary truncate font-medium",title:p.filename,children:p.filename}),s.jsx("div",{className:"text-[10px] text-text-muted",children:sl(p.size)}),Fb(p.mimeType)&&p.data&&s.jsxs("div",{className:"mt-1.5 text-[10px] text-text-muted leading-relaxed line-clamp-3 font-mono break-all",children:[p.data.slice(0,200),p.data.length>200?"...":""]})]})]},p.id)})}),n&&s.jsx(IT,{src:n,alt:"Attached image",isOpen:!0,onClose:d})]})}function CV({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(ht,{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(wt,{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(ht,{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 Cy="openfox:feed-reveal",cf="openfox:autoscroll-rearm";function kV({message:e,messageId:t,sessionId:n}){const r=e.messageKind==="auto-prompt",a=e.messageKind==="command",o=e.isSystemGenerated,c=Re(O=>O.loadSession),[,u]=Pn(),[d,h]=j.useState(!1),[p,m]=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,D]=j.useState(null),[A,R]=j.useState(null),M=j.useRef(null),{onContextMenu:W,contextMenu:$}=VT(),G=j.useCallback(()=>{const O=M.current;O&&(O.style.height="auto",O.style.height=`${O.scrollHeight}px`)},[]),B=async()=>{try{await UT(e.content),m(!0),window.setTimeout(()=>m(!1),1500)}catch{}},H=async()=>{if(!n||!t||k)return;E(!0),D(null);const O=await Dj(n,t);if(E(!1),O!=null&&O.session){const V=O.session.projectId;u(`/p/${V}/s/${O.session.id}`)}else D("Failed to fork session")},q=async()=>{if(!n||!t||_)return;b(!0),R(null);const O=await Dw(n,t);b(!1),O?(window.dispatchEvent(new CustomEvent(cf)),c(n,!0)):R("Failed to replay")},Q=async()=>{if(!n||!t||!w.trim()||_)return;b(!0),R(null);const O=await Dw(n,t,w,v);b(!1),O?(window.dispatchEvent(new CustomEvent(cf)),c(n,!0),x(!1)):R("Failed to send")},J=()=>{C(e.content),S(e.attachments??[]),x(!1),R(null)},I=`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:O=>W(O,!!n&&!!t),children:[!o&&s.jsxs("div",{className:I,children:[s.jsx("button",{onClick:()=>{B()},title:"Copy",disabled:_,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:p?s.jsx(Rs,{className:"w-3.5 h-3.5 text-accent-success"}):s.jsx(ml,{className:"w-3.5 h-3.5"})}),n&&t&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{R(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(Ky,{className:"w-3.5 h-3.5"})}),s.jsx("button",{onClick:()=>{q()},title:"Replay",disabled:_,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:s.jsx(Ef,{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:O=>{M.current=O,O&&(O.style.height="auto",O.style.height=`${O.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:O=>{C(O.target.value),G()},onKeyDown:O=>{O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),Q()),O.key==="Escape"&&J()},disabled:_,autoFocus:Ft()}),v.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(O=>s.jsx(Ub,{attachment:O,onRemove:V=>S(z=>z.filter(Y=>Y.id!==V))},O.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:()=>{Q()},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(wV,{attachments:e.attachments,messageId:e.id})]})]}),$([{label:"Copy",icon:s.jsx(ml,{className:"w-4 h-4"}),onClick:()=>void B()},{label:"Fork session from here",icon:s.jsx(Ga,{className:"w-4 h-4"}),onClick:()=>void H()}])]})}const GT=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(ev,{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(cn,{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(SV,{data:h})}catch{}if(t.messageKind==="task-completed")try{const h=JSON.parse(t.content);return s.jsx(_V,{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(CV,{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(kV,{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(Qn,{content:t.content})})})}),jV={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function EV(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function xk(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function NV({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:xk(o,a),children:[xl(t),"/",xl(n)]}),s.jsxs("span",{className:xk(o,a),children:["(",o,"%)"]}),s.jsx(Qb,{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 TV=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=ct(R=>R.defaults),p=ct(R=>R.userItems),m=[...h,...p],g=Re(R=>R.subAgentContextStates[r]),{showThinking:x,showVerboseToolOutput:w}=Ds(),C=ju(c),{isAutoScrollActive:v,setAutoScroll:S,handleScrollbarGesture:_}=ku(c,null,C),b=j.useCallback(()=>{const R=!u;d(R),R&&setTimeout(()=>{var M;(M=o.current)==null||M.scrollIntoView({block:"start",behavior:"smooth"})},220)},[u]),k=m.find(R=>R.id===n),E=(k==null?void 0:k.name)??jV[n]??n,T=Qa(m,n),D=EV(T),A=t.filter(R=>R.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:D,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(NV,{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(ht,{ref:c,className:`${u?"max-h-[calc(100vh-10rem)]":"max-h-80"} p-2 transition-[max-height] duration-200`,onScrollbarGesture:_,children:A.map(R=>R.role==="assistant"?s.jsx(ev,{message:R,showStats:!0,showThinking:x,showVerboseToolOutput:w},R.id):s.jsx(GT,{message:R,isLastAssistantMessage:!1},R.id))})]})}),AV={contentVisibility:"auto",containIntrinsicSize:"auto 200px"},LV={contentVisibility:"auto",containIntrinsicSize:"160px",minHeight:"160px"},ch=30,vx=20,DV=10,RV=5;function uh(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 WT=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 p=t.length,{feedVirtualization:m}=Ds(),[g,x]=j.useState(()=>Math.max(0,p-ch)),w=j.useRef(null),C=j.useRef(t.length),v=j.useRef(!1),S=m?g:0,_=m?AV:void 0;j.useEffect(()=>{m&&(x(Math.max(0,t.length-ch)),v.current=!1)},[r]),j.useEffect(()=>{const E=C.current;C.current=t.length,m&&t.length-E>=RV&&!v.current&&x(Math.max(0,t.length-ch))},[t.length,m]),j.useEffect(()=>{m&&g>0&&g>=t.length&&x(Math.max(0,t.length-ch))},[t.length,g,m]),j.useEffect(()=>{if(!m||g<=0||typeof IntersectionObserver>"u")return;const E=w.current;if(!E)return;const T=new IntersectionObserver(D=>{D.some(A=>A.isIntersecting)&&x(A=>Math.max(0,A-vx))},{rootMargin:"0px 0px 300px 0px"});return T.observe(E),()=>T.disconnect()},[g,m]);const b=j.useRef(g);b.current=g,j.useEffect(()=>{var A,R;if(!m)return;const E=a==null?void 0:a.current;if(!E)return;const T=(R=(A=E.osInstance)==null?void 0:A.call(E))==null?void 0:R.elements().viewport;if(!T)return;const D=()=>{if(T.scrollTop>4){v.current=!0;return}b.current>0&&x(M=>Math.max(0,M-vx))};return T.addEventListener("scroll",D,{passive:!0}),()=>T.removeEventListener("scroll",D)},[a,m]),j.useEffect(()=>{var D,A;if(!m||g<=0||!v.current)return;const E=a==null?void 0:a.current,T=(A=(D=E==null?void 0:E.osInstance)==null?void 0:D.call(E))==null?void 0:A.elements().viewport;T&&T.scrollTop<=4&&x(R=>Math.max(0,R-vx))},[g,a,m]),j.useEffect(()=>{if(!m)return;const E=T=>{var A;const D=(A=T.detail)==null?void 0:A.index;typeof D=="number"&&x(R=>Math.min(R,Math.max(0,D-DV)))};return window.addEventListener(Cy,E),()=>window.removeEventListener(Cy,E)},[m]);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:LV},`ph-${T}`)),s.jsx("div",{ref:w,"data-testid":"feed-sentinel",style:{height:1}})]}),k.map((E,T)=>{const D=S+T;if(E.type==="context-divider")return s.jsxs("div",{"data-item-index":D,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"})]},uh(E));if(E.type==="subagent"){const W=E.messages.some($=>$.isStreaming);return s.jsx("div",{"data-item-index":D,className:"px-2 md:px-4",style:_,children:s.jsx(TV,{messages:E.messages,subAgentType:E.subAgentType,subAgentId:E.subAgentId,isStreaming:W})},uh(E))}const A=E.message;if(A.role==="assistant")return s.jsx("div",{"data-item-index":D,className:"px-2 md:px-4",style:_,children:s.jsx(ev,{message:A,showStats:u,showThinking:o,showVerboseToolOutput:c,sessionId:r??void 0})},uh(E));const R=!d&&A.messageKind==="auto-prompt",M=!h&&(A.messageKind==="workflow-started"||A.messageKind==="task-completed");return R||M?null:s.jsx("div",{"data-item-index":D,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(GT,{message:A,messageId:A.id,sessionId:r??void 0,isLastAssistantMessage:!1})})},uh(E))})]})});function em(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 OV=[],IV=j.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r,onLaunchWorkflow:a,onScrollToTop:o,hiddenCount:c=0,onScrollbarGesture:u,emptyState:d}){const h=Re(Z=>{var F,P;return((P=(F=Z.currentSession)==null?void 0:F.metadataEntries)==null?void 0:P.criteria)??OV}),p=Re(Z=>{var F;return(F=Z.currentSession)==null?void 0:F.id}),m=Re(Z=>{var F;return(F=Z.currentSession)==null?void 0:F.phase}),g=Re(Z=>Z.error),x=Re(Z=>Z.clearError),w=wf(),C=Re(Z=>Z.activeWorkflowExecution),v=Re(Z=>Z.continueWorkflow),{showThinking:S,showVerboseToolOutput:_,showStats:b,showAgentDefinitions:k,showWorkflowBars:E}=Ds(),T=Zf(),D=h.some(Z=>Z.status==="pending"),A=m==="done",R=t.some(Z=>Z.type==="message"&&Z.message.role==="assistant"),M=(C==null?void 0:C.status)==="running"||(C==null?void 0:C.status)==="waiting",W=D&&!w&&R&&!A&&!M,$=(C==null?void 0:C.status)==="waiting"&&!w,G=Re(Z=>{var F;return(F=Z.currentSession)==null?void 0:F.projectId}),[B,H]=j.useState(!1),[q,Q]=j.useState(!1),[J,U]=j.useState(!1),I=ju(n);j.useLayoutEffect(()=>{const Z=I();Z&&Q(Z.scrollHeight>Z.clientHeight+1)},[I,t]),j.useEffect(()=>{const Z=I();if(!Z)return;const F=()=>U(Z.scrollTop>4);return F(),Z.addEventListener("scroll",F,{passive:!0}),()=>Z.removeEventListener("scroll",F)},[I]);const O=()=>{if(!G||!p)return;H(!1),window.open(`/p/${G}/s/${p}/readonly`,"_blank")||H(!0)},[V,z]=j.useState(!1),Y=j.useCallback(Z=>{V||(z(!0),v(Z),setTimeout(()=>z(!1),5e3))},[V,v]),X=j.useCallback(()=>{var Z;o==null||o(),(Z=I())==null||Z.scrollTo({top:0,behavior:"smooth"})},[I,o]);return s.jsxs("div",{className:"relative flex-1 min-w-0 group",children:[s.jsx(ht,{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:O,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"]}),B&&s.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Popup blocked."," ",s.jsx("a",{href:G&&p?`/p/${G}/s/${p}/readonly`:"#",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-text-primary",children:"Open manually"})]})]}),s.jsx(WT,{displayItems:t,highlightedMessageId:r,sessionId:p,scrollContainerRef:n,showThinking:S,showVerboseToolOutput:_,showStats:b,showAgentDefinitions:k,showWorkflowBars:E})]}),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:[g&&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:g.code}),s.jsx("div",{className:"text-text-tool-error/80 text-xs mt-0.5",children:g.message})]}),s.jsx(Cu,{onClick:x,className:"text-text-tool-error hover:text-text-tool-error/80 p-0.5",size:"sm"})]})}),$&&C&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:(C.pendingChoices&&C.pendingChoices.length>0?C.pendingChoices:[{id:void 0,label:`▶ Continue ${C.workflowName} (${C.currentStepName??"..."})`,goto:"",nextStepName:void 0}]).map(Z=>s.jsx("button",{onClick:()=>Y(Z.id),disabled:V,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:V?"⏳ Continuing...":Z.id==="continue"?`▶ Continue ${C.workflowName} (${Z.nextStepName??C.currentStepName??"..."})`:Z.label},Z.id??"continue"))}),W&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:T.map(Z=>{const F=Z.color??"#3b82f6",P=parseInt(F.slice(1,3),16),te=parseInt(F.slice(3,5),16),se=parseInt(F.slice(5,7),16),re=`rgba(${P},${te},${se},0.12)`,ae=`rgba(${P},${te},${se},0.22)`,ye=`rgba(${P},${te},${se},0.25)`;return s.jsx(MV,{workflowName:Z.name,scope:Z.scope,color:F,bg:re,bgHover:ae,border:ye,subGroups:Z.subGroups,onLaunch:_e=>a(Z.id,_e,void 0,Z.scope)},`${Z.id}-${Z.scope}`)})})]})]})}),q&&J&&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:X,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(Uj,{className:"w-3 h-3"}),"scroll to top"]})})]})});function MV({workflowName:e,scope:t,color:n,bg:r,bgHover:a,border:o,subGroups:c,onLaunch:u}){const[d,h]=j.useState(!1),p=j.useRef(null);em(p,()=>h(!1),d);const m=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 ${m?"rounded-l":"rounded"}`,style:{backgroundColor:r,color:n,border:`1px solid ${o}`,...m?{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:Gb[t]})]}),m&&s.jsxs("div",{ref:p,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 PV(){const e=Re(r=>r.connectionStatus),t=Re(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(a3,{}),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 BV(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function $V({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(Xy,{})})}function qT({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){const a=ln(de=>de.defaults),o=ln(de=>de.userItems),c=ln(de=>de.projectItems),u=ln(de=>de.loading),d=ln(de=>de.fetchCommands),h=ln(de=>de.fetchCommand),p=ln(de=>de.fetchDefaultContent),m=ln(de=>de.createCommand),g=ln(de=>de.updateCommand),x=ln(de=>de.deleteCommand),[w,C]=j.useState(null),[v,S]=j.useState(null),{view:_,editingId:b,formError:k,saving:E,formData:T,setView:D,setEditingId:A,setFormError:R,setFormData:M,setSaving:W}=eE(),{requestDelete:$,clearConfirm:G,isConfirming:B}=gu(),H=j.useRef(!1),q=ct(de=>de.defaults),Q=ct(de=>de.userItems),J=ct(de=>de.fetchAgents),I=[...q,...Q].filter(de=>!de.subagent),O=j.useRef(d),V=j.useRef(J),z=j.useRef(h),Y=j.useRef(p),X=j.useRef(r),Z=j.useRef(n),F=j.useRef(D),P=j.useRef(A),te=j.useRef(R),se=j.useRef(G);j.useEffect(()=>{O.current=d,V.current=J,z.current=h,Y.current=p,X.current=r,Z.current=n,F.current=D,P.current=A,te.current=R,se.current=G}),j.useEffect(()=>{if(e)if(O.current(X.current),V.current(X.current),H.current||(se.current(),H.current=!0),Z.current){const de=a.some(ie=>ie.id===Z.current);F.current("edit"),P.current(Z.current),te.current(""),de?Y.current(Z.current).then(ie=>{ie&&M({name:ie.metadata.name+" (copy)",id:`${Z.current}-copy-${Date.now()}`,prompt:ie.prompt,agentMode:ie.metadata.agentMode??"",isDefault:!0,destination:"user"})}):z.current(Z.current,X.current).then(ie=>{ie&&M({name:ie.metadata.name,id:ie.metadata.id,prompt:ie.prompt,agentMode:ie.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else F.current("list"),P.current(null);else H.current=!1},[e]);const re=async de=>{C(de);const ie=await p(de);S((ie==null?void 0:ie.prompt)??null)},ae=async de=>{if(a.some(Pe=>Pe.id===de)){const Pe=await p(de);Pe&&(A(null),M({name:`${Pe.metadata.name} (copy)`,id:`${de}-copy-${Date.now()}`,prompt:Pe.prompt,agentMode:Pe.metadata.agentMode??"",isDefault:!0,destination:"user"}),R(""),D("edit"))}else{const Pe=await h(de,r);Pe&&(A(null),M({name:`${Pe.metadata.name} (copy)`,id:`${de}-copy-${Date.now()}`,prompt:Pe.prompt,agentMode:Pe.metadata.agentMode??"",isDefault:!1,destination:"user"}),R(""),D("edit"))}},ye=()=>{M({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),A(null),D("edit")},_e=async de=>{const ie=await h(de,r);ie&&(A(de),M({name:ie.metadata.name,id:ie.metadata.id,prompt:ie.prompt,agentMode:ie.metadata.agentMode??"",isDefault:!1,destination:"user"}),R(""),D("edit"))},Ie=async de=>{await x(de,r),G()},He=async()=>{const de=b??T.id;if(!de||!T.name||!T.prompt){R("Name and message are required.");return}W(!0),R("");const ie={metadata:{id:de,name:T.name,...T.agentMode?{agentMode:T.agentMode}:{}},prompt:T.prompt},Pe=b?await g(b,ie,r):await m(ie,T.destination,r);if(W(!1),!Pe.success){R(Pe.error??"Failed to save command.");return}n?t():D("list")},je=()=>{n?t():(D("list"),C(null),S(null))},Ge=de=>{M(ie=>({...ie,name:de})),(!b||T.isDefault)&&M(ie=>({...ie,id:BV(de)}))},Ze=()=>{C(null),S(null),D("list")},Se=()=>{w&&(C(null),D("edit"),A(w),p(w).then(de=>{de&&M({name:`${de.metadata.name} (copy)`,id:`${w}-copy-${Date.now()}`,prompt:de.prompt,agentMode:de.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(w){const de=a.find(ie=>ie.id===w);return s.jsx(wt,{isOpen:e,onClose:Ze,title:`Default: ${(de==null?void 0:de.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:de==null?void 0:de.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:(de==null?void 0:de.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:Ze,children:"Close"}),s.jsx(ot,{variant:"primary",onClick:Se,children:"Duplicate & Customize"})]})]})})}if(_==="edit")return s.jsx(wt,{isOpen:e,onClose:je,title:b?"Edit Command":"New Command",size:"xl",footer:s.jsx(Yj,{onCancel:je,onSave:He,saving:E,saveDisabled:!T.name||!T.prompt}),children:s.jsxs("div",{className:"flex flex-col h-full",children:[k&&s.jsx(ll,{message:k}),s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsx(Zj,{name:T.name,id:T.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!b&&!T.isDefault,onNameChange:Ge,onIdChange:de=>M(ie=>({...ie,id:de}))}),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:de=>M(ie=>({...ie,agentMode:de.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)"}),I.map(de=>s.jsx("option",{value:de.id,children:de.name},de.id))]})]}),!b&&s.jsx(Af,{value:T.destination,onChange:de=>M(ie=>({...ie,destination:de}))})]}),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:de=>M(ie=>({...ie,prompt:de.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 be=de=>de.map(ie=>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:ie.name})})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(di,{onClick:()=>_e(ie.id)}),s.jsx(su,{onClick:()=>ae(ie.id)}),B(ie.id,"delete")?s.jsx(Ih,{onConfirm:()=>Ie(ie.id),onCancel:G}):s.jsx(Mh,{onClick:()=>$(ie.id)})]})]},ie.id));return s.jsxs(wt,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[s.jsx(Qj,{description:"Commands are pre-defined messages you can send with a single click.",onNew:ye}),s.jsxs(nb,{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(de=>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:de.name})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx($V,{onClick:()=>re(de.id)}),s.jsx(su,{onClick:()=>ae(de.id)})]})]},de.id))})]}),o.length>0&&s.jsx(Jj,{children:be(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:be(c)})]})]})]})}function zV({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 Ta=150,ni=54,dh=80,is=30,qo=70,yk=100,Aa=50,hh=50,bk=4,KT={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},YT=[{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)"}],HV=[{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 FV(e,t,n,r){const a=hh+Aa+Ta+yk+Ta+Aa+hh,o=a/2,c=hh+Aa+Ta/2,u=hh+Aa+Ta+yk+Ta/2,d=[],h=[],p=new Map,m=e.filter(H=>H.type==="agent"||H.type==="shell"||H.type==="user"),g=e.filter(H=>H.type==="sub_agent"),x=g.length>0,w=x?c:o,C=m.length>0?u:o,v=Aa+is/2;d.push({id:"$start",type:"terminal",label:"Start",cx:w,cy:v,w:dh,h:is}),p.set("$start",{cx:w,cy:v,w:dh,h:is});const S=H=>{d.push({id:"$done",type:"terminal",label:"Done",cx:w,cy:H,w:dh,h:is}),p.set("$done",{cx:w,cy:H,w:dh,h:is})};if(e.length===0){const H=v+is/2+qo*2+is/2;return S(H),{nodes:d,edges:h,width:a,height:H+is/2+Aa,posMap:p}}const _=v+is/2+qo,b=(H,q)=>{H.forEach((Q,J)=>{const U=_+J*(ni+qo)+ni/2,{name:I,color:O}=tv(Q,r);d.push({id:Q.id,type:"step",label:I,color:O,cx:q,cy:U,w:Ta,h:ni}),p.set(Q.id,{cx:q,cy:U,w:Ta,h:ni})})};b(m,w),b(g,C);const k=m.length>0?_+(m.length-1)*(ni+qo)+ni/2:v,E=x?_+(g.length-1)*(ni+qo)+ni/2:v,T=Math.max(k,E)+ni/2+qo+is/2;S(T);const D=[];t&&p.has(t)&&D.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let A=0;for(const H of e)H.transitions.forEach((q,Q)=>{var z;if(!q.goto||!p.has(q.goto))return;const J=p.get(H.id),U=p.get(q.goto),I=q.when.type==="step_result"?`${q.when.result}`:q.when.type==="metadata_all_match"?`${q.when.key??"?"}=${q.when.value??"?"}`:q.when.type==="metadata_all_in"?`${q.when.key??"?"} in [${((z=q.when.values)==null?void 0:z.join(","))??"?"}]`:KT[q.when.type]??q.when.type,O=H.id===q.goto;let V;O?V="back":U.cy>J.cy+1?V="down":U.cy<J.cy-1?V="back":V="same",D.push({from:H.id,to:q.goto,label:I,edgeKey:`${H.id}:${Q}`,direction:V,backEdgeIndex:V==="back"?A++:0})});const R=new Map,M=new Map,W=new Map,$=new Map;for(const H of D)H.direction==="down"&&(R.set(H.from,(R.get(H.from)??0)+1),M.set(H.to,(M.get(H.to)??0)+1));const G=new Map,B=new Map;for(const H of D){if(H.direction!=="same")continue;const q=[H.from,H.to].sort().join("|");G.set(q,(G.get(q)??0)+1)}for(const H of D){if(H.direction==="back"||H.direction==="same"){let V=0;if(H.direction==="same"){const z=[H.from,H.to].sort().join("|");V=B.get(z)??0,B.set(z,V+1)}h.push({...H,fromPort:0,toPort:0,sameEdgeIndex:V});continue}const q=R.get(H.from)??1,Q=M.get(H.to)??1,J=W.get(H.from)??0,U=$.get(H.to)??0;W.set(H.from,J+1),$.set(H.to,U+1);const I=q===1?0:-.6+1.2*J/(q-1),O=Q===1?0:-.6+1.2*U/(Q-1);h.push({...H,fromPort:I,toPort:O,sameEdgeIndex:0})}return{nodes:d,edges:h,width:a,height:T+is/2+Aa,posMap:p}}function UV({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:a,agentTypes:o,isReadOnly:c,onSelectNode:u,onSelectEdge:d,onRemoveStep:h,onCreateTransition:p,onReconnectTo:m,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:D,width:A,height:R,posMap:M}=j.useMemo(()=>FV(e,t,a,o),[e,t,a,o]),W=j.useCallback(X=>{var se;const Z=w.current;if(!Z)return{x:0,y:0};const F=Z.createSVGPoint();F.x=X.clientX,F.y=X.clientY;const P=(se=Z.getScreenCTM())==null?void 0:se.inverse();if(!P)return{x:0,y:0};const te=F.matrixTransform(P);return{x:te.x,y:te.y}},[]),$=j.useCallback(X=>!X||!_||X==="$start"?!1:_.type==="reconnect-from"?X!=="$done":!0,[_]),G=j.useCallback((X,Z)=>{if(c)return;X.stopPropagation(),X.preventDefault();const F=W(X);b({type:"new",fromNodeId:Z,mouseX:F.x,mouseY:F.y})},[W,c]),B=j.useCallback((X,Z)=>{if(c)return;X.stopPropagation(),X.preventDefault();const F=W(X);b({type:"reconnect-to",fromNodeId:Z.from,edgeKey:Z.edgeKey,mouseX:F.x,mouseY:F.y})},[W,c]),H=j.useCallback((X,Z)=>{if(c)return;X.stopPropagation(),X.preventDefault();const F=W(X);b({type:"reconnect-from",fromNodeId:Z.from,fixedTargetId:Z.to,edgeKey:Z.edgeKey,mouseX:F.x,mouseY:F.y})},[W,c]),q=j.useCallback(X=>{if(!_)return;const Z=W(X);b(F=>F?{...F,mouseX:Z.x,mouseY:Z.y}:null)},[_,W]),Q=j.useCallback(()=>{_&&(C.current=!0,k&&$(k)&&(_.type==="new"?p(_.fromNodeId,k):_.type==="reconnect-to"?m(_.edgeKey,k):_.type==="reconnect-from"&&g(_.edgeKey,k)),b(null),E(null))},[_,k,$,p,m,g]),J=j.useCallback(()=>{if(C.current){C.current=!1;return}u(null),d(null)},[u,d]);j.useEffect(()=>{if(c)return;const X=Z=>{Z.target instanceof HTMLInputElement||Z.target instanceof HTMLTextAreaElement||Z.target instanceof HTMLSelectElement||(Z.key==="Delete"||Z.key==="Backspace")&&r&&r!=="start"&&(Z.preventDefault(),x(r),d(null))};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[c,r,x,d]);const U=X=>{const Z=M.get(X.from),F=M.get(X.to);if(!Z||!F)return null;let P,te,se,re="middle",ae,ye;if(X.direction==="down"){const _e=Z.cx+X.fromPort*(Z.w/2-10),Ie=Z.cy+Z.h/2,He=F.cx+X.toPort*(F.w/2-10),je=F.cy-F.h/2,Ge=je-Ie,Ze=He-_e;P=`M ${_e} ${Ie} C ${_e} ${Ie+Ge*.4}, ${He-Ze*.2} ${je-Ge*.1}, ${He} ${je}`,te=_e+(He-_e)*.5,se=Ie+Ge*.6,ae={x:_e,y:Ie},ye={x:He,y:je}}else if(X.direction==="back"){const _e=X.from===X.to,Ie=Z.cx>=A/2,He=X.backEdgeIndex*16,je=Ie?A-20-He:20+He;if(_e){const Ge=Z.cx>=A/2,Ze=30+X.backEdgeIndex*14,Se=Z.cy-Z.h/2,be=Ge?Z.cx+Z.w/2:Z.cx-Z.w/2,de=Ge?be+Ze:be-Ze,ie=Z.cx+(Ge?Z.w/4:-Z.w/4),Pe=Se-20-X.backEdgeIndex*10;P=`M ${be} ${Z.cy} C ${de} ${Z.cy}, ${de} ${Pe}, ${ie} ${Se}`,te=de+10,se=Pe+4,re="middle",ae={x:be,y:Z.cy},ye={x:ie,y:Se}}else{const Ge=Ie?Z.cx+Z.w/2:Z.cx-Z.w/2,Ze=F.cx+(Ie?F.w/4:-F.w/4),Se=Math.min(Z.cy,F.cy)-F.h/2-18-X.backEdgeIndex*14;P=`M ${Ge} ${Z.cy} L ${je} ${Z.cy} L ${je} ${Se} L ${Ze} ${Se} L ${Ze} ${F.cy-F.h/2}`,te=je,se=(Z.cy+Se)/2,re=Ie?"start":"end",ae={x:Ge,y:Z.cy},ye={x:Ze,y:F.cy-F.h/2}}}else{const _e=F.cx>Z.cx,Ie=X.sameEdgeIndex===0?-12:12,He=_e?Z.cx+Z.w/2:Z.cx-Z.w/2,je=_e?F.cx-F.w/2:F.cx+F.w/2,Ge=Z.cy+Ie,Ze=F.cy+Ie,Se=(He+je)/2;P=`M ${He} ${Ge} C ${Se} ${Ge}, ${Se} ${Ze}, ${je} ${Ze}`,te=Se,se=(Ge+Ze)/2-6,ae={x:He,y:Ge},ye={x:je,y:Ze}}return{path:P,labelX:te,labelY:se,labelAnchor:re,fromPt:ae,toPt:ye}},I=(X,Z)=>{const F=U(X);if(!F)return null;const{path:P,labelX:te,labelY:se,labelAnchor:re}=F,ae=r===X.edgeKey,ye=X.label&&X.label!=="otherwise";return s.jsxs("g",{children:[s.jsx("path",{d:P,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:_e=>{_e.stopPropagation(),c||d(ae?null:X.edgeKey)}}),s.jsx("path",{d:P,fill:"none",stroke:ae?"#58a6ff":"#484f58",strokeWidth:ae?2.2:1.2,markerEnd:ae?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),ye&&s.jsx("text",{x:te+(re==="start"?5:re==="end"?-5:0),y:se+3,textAnchor:re,className:"text-[8px]",fill:ae?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:X.label})]},Z)},O=()=>{if(!r||_)return null;const X=D.find(se=>se.edgeKey===r);if(!X)return null;const Z=U(X);if(!Z)return null;const{fromPt:F,toPt:P}=Z,te=6;return s.jsxs(s.Fragment,{children:[X.edgeKey!=="start"&&s.jsx("circle",{cx:F.x,cy:F.y,r:te,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:se=>H(se,X)}),s.jsx("circle",{cx:P.x,cy:P.y,r:te,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:se=>B(se,X)})]})},V=()=>{if(!_)return null;let X,Z,F,P;if(_.type==="reconnect-from"){const re=M.get(_.fixedTargetId);if(!re)return null;X=_.mouseX,Z=_.mouseY,F=re.cx,P=re.cy-re.h/2}else{const re=M.get(_.fromNodeId);if(!re)return null;X=re.cx,Z=re.cy+re.h/2,F=_.mouseX,P=_.mouseY}const te=P-Z,se=Math.abs(te)>10?`M ${X} ${Z} C ${X} ${Z+te*.4}, ${F} ${P-te*.4}, ${F} ${P}`:`M ${X} ${Z} L ${F} ${P}`;return s.jsx("path",{d:se,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},z=X=>{const Z=X.cy+X.h/2,F=(_==null?void 0:_.fromNodeId)===X.id;return s.jsx("circle",{cx:X.cx,cy:Z,r:bk,fill:F?"#58a6ff":"#1c2128",stroke:F?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:F?1:.5,className:"cursor-crosshair",onMouseDown:P=>G(P,X.id)})},Y=X=>{const Z=X.cy-X.h/2,F=_&&k===X.id&&$(X.id);return s.jsx("circle",{cx:X.cx,cy:Z,r:bk,fill:F?"#3fb950":"#1c2128",stroke:F?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:F?1:.5})};return s.jsxs("svg",{ref:w,viewBox:`0 0 ${A} ${R}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:q,onMouseUp:Q,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"})})]}),D.map((X,Z)=>I(X,Z)),T.map(X=>{const Z=n===X.id,F=X.cx-X.w/2,P=X.cy-X.h/2,te=v===X.id,se=_&&k===X.id&&$(X.id);if(X.type==="terminal"){const ae=X.id==="$start",ye=ae?"#58a6ff":"#3fb950",_e=ae,Ie=!ae;return s.jsxs("g",{onClick:He=>{He.stopPropagation(),ae&&!c&&d("start")},className:ae&&!c?"cursor-pointer":void 0,children:[se&&s.jsx("rect",{x:F-3,y:P-3,width:X.w+6,height:X.h+6,rx:X.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),ae&&r==="start"&&s.jsx("rect",{x:F-3,y:P-3,width:X.w+6,height:X.h+6,rx:X.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),s.jsx("rect",{x:F,y:P,width:X.w,height:X.h,rx:X.h/2,fill:ye,fillOpacity:.08,stroke:ye,strokeOpacity:.4,strokeWidth:1.5}),s.jsx("text",{x:X.cx,y:X.cy+4,textAnchor:"middle",fill:ye,className:"text-[10px] font-medium",pointerEvents:"none",children:X.label}),_e&&z(X),Ie&&Y(X)]},X.id)}const re=X.color??"#6b7280";return s.jsxs("g",{onClick:ae=>{ae.stopPropagation(),c||u(Z?null:X.id)},onMouseEnter:()=>S(X.id),onMouseLeave:()=>S(null),className:c?void 0:"cursor-pointer",children:[se&&s.jsx("rect",{x:F-3,y:P-3,width:X.w+6,height:X.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),Z&&s.jsx("rect",{x:F-3,y:P-3,width:X.w+6,height:X.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),s.jsx("rect",{x:F,y:P,width:X.w,height:X.h,rx:10,fill:re,fillOpacity:.08,stroke:re,strokeOpacity:.6,strokeWidth:Z?2:1.5}),s.jsx("text",{x:X.cx,y:X.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:X.label}),!c&&z(X),!c&&Y(X),te&&!_&&!c&&s.jsxs("g",{onClick:ae=>{ae.stopPropagation(),h(X.id)},className:"cursor-pointer",children:[s.jsx("circle",{cx:F+X.w-2,cy:P+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),s.jsx("line",{x1:F+X.w-5,y1:P-1,x2:F+X.w+1,y2:P+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),s.jsx("line",{x1:F+X.w+1,y1:P-1,x2:F+X.w-5,y2:P+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},X.id)}),_&&T.map(X=>$(X.id)?s.jsx("rect",{x:X.cx-X.w/2-8,y:X.cy-X.h/2-8,width:X.w+16,height:X.h+16,fill:"transparent",rx:12,onMouseEnter:()=>E(X.id),onMouseLeave:()=>E(null),onMouseUp:Z=>{Z.stopPropagation(),Q()}},`drop-${X.id}`):null),V(),O()]})}const fh="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Mc="block text-[11px] text-text-secondary mb-0.5";function VV({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:Mc,children:"Name"}),s.jsx("input",{value:e,onChange:p=>c(p.target.value),placeholder:"Workflow name",className:`${fh} ${o?"opacity-50":""}`,readOnly:o})]}),s.jsxs("div",{className:"min-w-[100px]",children:[s.jsx("label",{className:Mc,children:"ID"}),s.jsx("input",{value:t,readOnly:!0,className:`${fh} font-mono opacity-50`})]}),s.jsxs("div",{className:"flex-1 min-w-[140px]",children:[s.jsx("label",{className:Mc,children:"Description"}),s.jsx("input",{value:n,onChange:p=>!o&&u(p.target.value),readOnly:o,placeholder:"What does this workflow do?",className:`${fh} ${o?"opacity-50":""}`})]}),s.jsxs("div",{className:"w-20",children:[s.jsx("label",{className:Mc,children:"Max Iter."}),s.jsx("input",{type:"number",value:r,onChange:p=>!o&&d(Number(p.target.value)),readOnly:o,className:`${fh} font-mono ${o?"opacity-50":""}`})]}),s.jsxs("div",{children:[s.jsx("label",{className:Mc,children:"Color"}),s.jsx("input",{type:"color",value:a,onChange:p=>!o&&h(p.target.value),disabled:o,className:`w-8 h-8 rounded border border-border bg-transparent ${o?"opacity-50":"cursor-pointer"}`})]})]})}function GV({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 _x({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(GV,{name:r.name,id:r.id,color:r.color??"#3b82f6",description:r.description,actions:n(r)},r.id))})]})}const La="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",Sx="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",_s="block text-[11px] text-text-secondary mb-0.5";function wx({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 WV({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:_s,children:"Name"}),s.jsx("input",{value:e.name,onChange:p=>o({...e,name:p.target.value}),placeholder:"Step name",className:La})]}),s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Type"}),s.jsx("select",{value:e.type,onChange:p=>{const m=p.target.value,g=m==="sub_agent"?"verification":"build";if(m==="agent"){const x=n.find(w=>!w.subagent);o({...e,type:m,phase:g,agentId:(x==null?void 0:x.id)??"builder",name:(x==null?void 0:x.name)??"Agent"})}else if(m==="sub_agent"){const x=n.find(w=>w.subagent);o({...e,type:m,phase:g,subAgentType:(x==null?void 0:x.id)??"",name:(x==null?void 0:x.name)??"Sub-Agent"})}else o(m==="user"?{...e,type:m,phase:g,name:"User"}:{...e,type:m,phase:g,name:"Shell"})},className:Sx,children:HV.map(p=>s.jsx("option",{value:p.value,children:p.label},p.value))})]}),e.type==="agent"&&s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Agent Type"}),s.jsx("select",{value:e.agentId??"builder",onChange:p=>{const m=n.find(g=>g.id===p.target.value);o({...e,agentId:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:Sx,children:n.filter(p=>!p.subagent).map(p=>s.jsx("option",{value:p.id,children:p.name},p.id))})]}),e.type==="sub_agent"&&s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Sub-Agent Type"}),s.jsxs("select",{value:e.subAgentType??"",onChange:p=>{const m=n.find(g=>g.id===p.target.value);o({...e,subAgentType:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:Sx,children:[s.jsx("option",{value:"",children:"— select —"}),n.filter(p=>p.subagent).map(p=>s.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Prompt"}),s.jsx("textarea",{value:e.prompt??"",onChange:p=>o({...e,prompt:p.target.value||void 0}),rows:6,className:`${La} resize-y text-xs`,placeholder:"Injected on first entry..."}),s.jsx(wx,{variables:a,onInsert:p=>o({...e,prompt:(e.prompt??"")+`{{${p}}}`})})]}),s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Nudge Prompt"}),s.jsx("textarea",{value:e.nudgePrompt??"",onChange:p=>o({...e,nudgePrompt:p.target.value||void 0}),rows:6,className:`${La} resize-y text-xs`,placeholder:"Injected on re-entry..."}),s.jsx(wx,{variables:a,onInsert:p=>o({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${p}}}`})})]})]}),e.type==="shell"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Command"}),s.jsx("textarea",{value:e.command??"",onChange:p=>o({...e,command:p.target.value}),rows:3,className:`${La} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),s.jsx(wx,{variables:a,onInsert:p=>o({...e,command:(e.command??"")+`{{${p}}}`})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Timeout (ms)"}),s.jsx("input",{type:"number",value:e.timeout??6e4,onChange:p=>o({...e,timeout:Number(p.target.value)}),className:`${La} font-mono text-xs`})]}),s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Success Codes"}),s.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:p=>o({...e,successExitCodes:p.target.value.split(",").map(m=>Number(m.trim())).filter(m=>!isNaN(m))}),className:`${La} font-mono text-xs`})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:_s,children:"Sub-group"}),s.jsx("input",{value:e.subGroup??"",onChange:p=>o({...e,subGroup:p.target.value||void 0}),placeholder:"e.g. build, verify, review",className:La})]}),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 Ko="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",vk="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",Da="block text-[11px] text-text-secondary mb-0.5";function qV({fromLabel:e,toLabel:t,condition:n,subGroup:r,fromStep:a,agentTypes:o,transitionIndex:c,totalTransitions:u,onUpdateCondition:d,onUpdateSubGroup:h,onDelete:p,onMoveUp:m,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:m,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:p,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(Cf,{}),s.jsx("span",{className:"font-medium text-text-primary",children:t})]}),s.jsxs("div",{children:[s.jsx("label",{className:Da,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:vk,children:YT.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:Da,children:"Result"}),w?s.jsx("select",{value:n.result??x.results[0],onChange:v=>{d({type:"step_result",result:v.target.value})},className:vk,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:Ko})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:Da,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:Ko})]}),s.jsxs("div",{children:[s.jsx("label",{className:Da,children:"Field"}),s.jsx("input",{type:"text",value:n.field??"",onChange:v=>d({...n,field:v.target.value}),placeholder:"e.g. status",className:Ko})]}),n.type==="metadata_all_match"?s.jsxs("div",{children:[s.jsx("label",{className:Da,children:"Value"}),s.jsx("input",{type:"text",value:n.value??"",onChange:v=>d({...n,value:v.target.value}),placeholder:"e.g. passed, resolved",className:Ko})]}):s.jsxs("div",{children:[s.jsx("label",{className:Da,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:Ko})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:Da,children:"Sub-group"}),s.jsx("input",{type:"text",value:r??"",onChange:v=>h(v.target.value||void 0),placeholder:"e.g. build, verify",className:Ko})]}),(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 KV(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function YV(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const Pc="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",_k="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",Yo="block text-[11px] text-text-secondary mb-0.5",Sk=[];function XT({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){var Ot,rn;const a=Ht(Te=>Te.defaults),o=Ht(Te=>Te.userItems),c=Ht(Te=>Te.projectItems),u=Ht(Te=>Te.loading),d=Ht(Te=>Te.templateVariables),h=Ht(Te=>Te.fetchWorkflows),p=Ht(Te=>Te.fetchWorkflow),m=Ht(Te=>Te.fetchDefaultContent),g=Ht(Te=>Te.fetchTemplateVariables),x=Ht(Te=>Te.createWorkflow),w=Ht(Te=>Te.updateWorkflow),C=Ht(Te=>Te.deleteWorkflow),{requestDelete:v,clearConfirm:S,isConfirming:_}=gu(),[b,k]=j.useState("list"),[E,T]=j.useState(null),[D,A]=j.useState(void 0),[R,M]=j.useState(!1),[W,$]=j.useState(null),[G,B]=j.useState(null),[H,q]=j.useState(""),[Q,J]=j.useState(""),[U,I]=j.useState(""),[O,V]=j.useState("1.0.0"),[z,Y]=j.useState("#3b82f6"),[X,Z]=j.useState(""),[F,P]=j.useState(50),[te,se]=j.useState(Sk),[re,ae]=j.useState({type:"always"}),[ye,_e]=j.useState([]),[Ie,He]=j.useState("user"),[je,Ge]=j.useState(""),[Ze,Se]=j.useState(!1),be=ct(Te=>Te.defaults),de=ct(Te=>Te.userItems),ie=ct(Te=>Te.projectItems),Pe=j.useMemo(()=>[...be,...de,...ie],[be,de,ie]),Ue=ct(Te=>Te.fetchAgents),[ue]=j.useState(null);j.useEffect(()=>{e&&(h(r),g(),Ue(),$(null),B(null),n?a.some(Ae=>Ae.id===n)?m(n,r).then(Ae=>{Ae&&De({...Ae,metadata:{...Ae.metadata,name:Ae.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):p(n,r).then(Ae=>{Ae&&De(Ae,{editingId:n,isReadOnly:!1})}):(k("list"),T(null),M(!1)))},[e,h,p,m,g,n,r]);const De=(Te,Ae)=>{q(Te.metadata.name),J(Te.metadata.id),I(Te.metadata.description),V(Te.metadata.version),Y(Te.metadata.color??"#3b82f6"),Z(Te.entryStep),P(Te.settings.maxIterations),se(Te.steps),ae(Te.startCondition??{type:"always"}),_e(Te.metadata.parameters??[]),Ge(""),(Ae==null?void 0:Ae.editingId)!==void 0&&T(Ae.editingId),(Ae==null?void 0:Ae.isReadOnly)!==void 0&&M(Ae.isReadOnly),(Ae==null?void 0:Ae.selectedNodeKey)!==void 0&&$(null),(Ae==null?void 0:Ae.selectedEdgeKey)!==void 0&&B(null),k("edit")},qe=async(Te,Ae)=>{A(Ae);const $e=await p(Te,r,Ae);$e&&De($e,{editingId:Te,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},pe=async()=>{var mt;const Te=E??Q;if(!Te||!H)return Ge("Name is required."),!1;if(te.length===0)return Ge("Add at least one step."),!1;const Ae=ye.find(St=>!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(St.id));if(Ae)return Ge(`Invalid parameter ID "${Ae.id}". Use letters, digits, and underscores only.`),!1;let $e=X;if(!$e||!te.some(St=>St.id===$e)){if($e=((mt=te.find(St=>St.id))==null?void 0:mt.id)??"",!$e)return Ge("All steps need an ID."),!1;Z($e)}Se(!0),Ge("");const Qe={metadata:{id:Te,name:H,description:U,version:O||"1.0.0",color:z,...ye.length>0?{parameters:ye}:{}},entryStep:$e,settings:{maxIterations:F},steps:te,startCondition:re},rt=E?await w(E,Qe,r,D):await x(Qe,Ie,r);return Se(!1),rt.success?(E||T(Te),!0):(Ge(rt.error??"Failed to save."),!1)},he=async()=>{await pe()},We=async()=>{await pe()&&(n?t():k("list"))},Ve=()=>{n?t():k("list")},et=Te=>{q(Te),E||J(KV(Te))},it=async(Te,Ae)=>a.some(Qe=>Qe.id===Te)?await m(Te,r):await p(Te,r,Ae),ge=async(Te,Ae)=>{const $e=await it(Te,Ae);$e&&De({...$e,metadata:{...$e.metadata,name:$e.metadata.name+" (copy)",id:`${Te}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},fe=()=>{T(null),A(void 0),q(""),J(""),I(""),V("1.0.0"),Y("#3b82f6"),Z(""),P(50),se(structuredClone(Sk)),ae({type:"always"}),_e([]),He("user"),Ge(""),$(null),B(null),M(!1),k("edit")},Fe=async(Te,Ae)=>{await C(Te,Ae,r),S()},Xe=j.useCallback(Te=>{$(Te),B(null)},[]),_t=j.useCallback(Te=>{B(Te),$(null)},[]),Dt=W!==null?Number(W):-1,Ct=Dt>=0?te[Dt]??null:null,Sn=j.useCallback(Te=>{se(Ae=>Ae.map(($e,Qe)=>Qe===Dt?Te:$e))},[Dt]),wn=re.type==="step_result"?`${re.result}`:re.type==="metadata_all_match"?`${re.key??"?"}=${re.value??"?"}`:re.type==="metadata_all_in"?`${re.key??"?"} in [${((Ot=re.values)==null?void 0:Ot.join(","))??"?"}]`:KT[re.type]??re.type,fn=()=>{const Te=te.length,Ae=YV(te),$e=Pe.find(Qe=>!Qe.subagent);se([...te,{id:Ae,name:($e==null?void 0:$e.name)??"Agent",type:"agent",phase:"build",agentId:($e==null?void 0:$e.id)??"builder",transitions:[]}]),X||Z(Ae),Xe(String(Te))},Dn=j.useCallback((Te,Ae)=>{Te==="$start"?(Z(Ae),_t("start")):se($e=>{const Qe=$e.find(mt=>mt.id===Te),rt=Qe?Qe.transitions.length:0;return _t(`${Te}:${rt}`),$e.map(mt=>mt.id===Te?{...mt,transitions:[...mt.transitions,{when:{type:"always"},goto:Ae}]}:mt)})},[_t]),Cn=Te=>{if(Te==="start")return null;const Ae=Te.lastIndexOf(":"),$e=Te.slice(0,Ae),Qe=parseInt(Te.slice(Ae+1));return{stepId:$e,transIdx:Qe}},dn=j.useCallback((Te,Ae)=>{const $e=Cn(Te);$e&&se(Qe=>Qe.map(rt=>rt.id===$e.stepId?{...rt,transitions:rt.transitions.map((mt,St)=>St===$e.transIdx?Ae(mt):mt)}:rt))},[]),rr=j.useCallback((Te,Ae)=>{if(Te==="start"){Z(Ae);return}dn(Te,$e=>({...$e,goto:Ae}))},[dn]),Ce=j.useCallback((Te,Ae)=>{const $e=Cn(Te);$e&&(se(Qe=>{const rt=Qe.find(St=>St.id===$e.stepId);if(!rt)return Qe;const mt=rt.transitions[$e.transIdx];return mt?Qe.map(St=>St.id===$e.stepId?{...St,transitions:St.transitions.filter((Rn,xn)=>xn!==$e.transIdx)}:St.id===Ae?{...St,transitions:[...St.transitions,mt]}:St):Qe}),B(null))},[]),nt=j.useCallback(Te=>{if(Te==="start"){Z(""),B(null);return}const Ae=Cn(Te);Ae&&(se($e=>$e.map(Qe=>Qe.id===Ae.stepId?{...Qe,transitions:Qe.transitions.filter((rt,mt)=>mt!==Ae.transIdx)}:Qe)),B(null))},[]),Je=j.useCallback((Te,Ae)=>{if(Te==="start"){ae(Ae);return}dn(Te,$e=>({...$e,when:Ae}))},[dn]),oe=j.useCallback((Te,Ae)=>{Te!=="start"&&dn(Te,$e=>({...$e,subGroup:Ae||void 0}))},[dn]),Be=Te=>tv(Te,Pe).name,tt=()=>{if(!G)return null;if(G==="start"){const Rn=te.find(xn=>xn.id===X);return{type:"start",fromLabel:"Start",toLabel:Rn?Be(Rn):"(none)",condition:re}}const Te=G.lastIndexOf(":"),Ae=G.slice(0,Te),$e=parseInt(G.slice(Te+1)),Qe=te.find(Rn=>Rn.id===Ae);if(!Qe)return null;const rt=Qe.transitions[$e];if(!rt)return null;const mt=te.find(Rn=>Rn.id===rt.goto),St=rt.goto==="$done"?"Done":mt?Be(mt):rt.goto;return{type:"step",fromLabel:Be(Qe),toLabel:St,condition:rt.when,subGroup:rt.subGroup}};if(b==="edit"){const Te=tt();return s.jsxs(wt,{isOpen:e,onClose:Ve,title:R?H:E?"Edit Workflow":"New Workflow",size:"full",children:[je&&s.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:je}),s.jsx(VV,{formName:H,formId:Q,formDescription:U,formMaxIterations:F,formColor:z,isReadOnly:R,onNameChange:et,onDescriptionChange:I,onMaxIterationsChange:P,onColorChange:Y}),!R&&s.jsx("div",{className:"mb-3 pb-3 border-b border-border",children:s.jsxs(zV,{title:`Parameters (${ye.length})`,children:[ye.map((Ae,$e)=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{value:Ae.id,onChange:Qe=>{const rt=[...ye];rt[$e]={...Ae,id:Qe.target.value},_e(rt)},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:Ae.label,onChange:Qe=>{const rt=[...ye];rt[$e]={...Ae,label:Qe.target.value},_e(rt)},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:Ae.description??"",onChange:Qe=>{const rt=[...ye];rt[$e]={...Ae,description:Qe.target.value||void 0},_e(rt)},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:Ae.required??!1,onChange:Qe=>{const rt=[...ye];rt[$e]={...Ae,required:Qe.target.checked||void 0},_e(rt)},className:"rounded border-border"}),"Req."]}),s.jsxs("div",{className:"flex gap-0.5",children:[s.jsx("button",{onClick:()=>{$e!==0&&_e(ye.map((Qe,rt)=>rt===$e?{...ye[$e-1],position:rt}:rt===$e-1?{...ye[$e],position:rt}:{...Qe,position:rt}))},disabled:$e===0,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move up","aria-label":`Move ${Ae.label||Ae.id} up`,children:"▲"}),s.jsx("button",{onClick:()=>{$e!==ye.length-1&&_e(ye.map((Qe,rt)=>rt===$e?{...ye[$e+1],position:rt}:rt===$e+1?{...ye[$e],position:rt}:{...Qe,position:rt}))},disabled:$e===ye.length-1,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move down","aria-label":`Move ${Ae.label||Ae.id} down`,children:"▼"})]}),s.jsx("button",{onClick:()=>_e(ye.filter((Qe,rt)=>rt!==$e)),className:"p-1 text-text-muted hover:text-accent-error transition-colors",title:"Remove parameter",children:"✕"})]},Ae.id)),s.jsx("button",{onClick:()=>{const Ae=`param_${ye.length+1}`;_e([...ye,{id:Ae,label:"",description:"",required:!1}])},className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:"+ Add parameter"})]})}),!E&&!R&&s.jsx(Af,{value:Ie,onChange:He}),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"}),!R&&s.jsx("button",{onClick:fn,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),s.jsxs(ht,{className:"flex-1 min-h-0 p-2",children:[s.jsx(UV,{steps:te,entryStep:X,selectedNodeId:(Ct==null?void 0:Ct.id)??null,selectedEdgeKey:G,startConditionLabel:wn,agentTypes:Pe,isReadOnly:R,onSelectNode:Ae=>{if(Ae===null){Xe(null);return}const $e=te.findIndex(Qe=>Qe.id===Ae);Xe($e>=0?String($e):null)},onSelectEdge:_t,onRemoveStep:Ae=>{var Qe;const $e=te.findIndex(rt=>rt.id===Ae);if(se(rt=>rt.filter(mt=>mt.id!==Ae)),Dt===$e&&Xe(null),X===Ae){const rt=te.filter(mt=>mt.id!==Ae);Z(((Qe=rt[0])==null?void 0:Qe.id)??"")}},onCreateTransition:Dn,onReconnectTo:rr,onReconnectFrom:Ce,onDeleteTransition:nt}),te.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:fn,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(ht,{className:"p-3 flex-1 min-h-0",children:R&&(Te||Ct)?s.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):Te?Te.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"})}),X&&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(Cf,{}),s.jsx("span",{className:"text-text-primary font-medium",children:Te.toLabel})]}),s.jsxs("div",{children:[s.jsx("label",{className:Yo,children:"Activation Condition"}),s.jsx("select",{value:re.type,onChange:Ae=>ae(Ae.target.value==="step_result"?{type:"step_result",result:"success"}:Ae.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:Ae.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:Ae.target.value}),className:_k,children:YT.map(Ae=>s.jsx("option",{value:Ae.value,children:Ae.label},Ae.value))})]}),re.type==="step_result"&&s.jsxs("div",{children:[s.jsx("label",{className:Yo,children:"Result"}),X&&(()=>{const Ae=te.find(mt=>mt.id===X),$e=Ae&&(Ae.type==="sub_agent"||Ae.type==="agent")?Pe.find(mt=>mt.id===(Ae.type==="sub_agent"?Ae.subAgentType:Ae.agentId)):void 0,Qe=($e==null?void 0:$e.results)&&$e.results.length>0,rt=($e==null?void 0:$e.results)??[];return Qe?s.jsx("select",{value:re.result??rt[0],onChange:mt=>ae({type:"step_result",result:mt.target.value}),className:_k,children:rt.map(mt=>s.jsx("option",{value:mt,children:mt},mt))}):s.jsx("input",{type:"text",value:re.result??"success",onChange:mt=>ae({type:"step_result",result:mt.target.value}),placeholder:"e.g. success, passed, failed",className:Pc})})()]}),(re.type==="metadata_all_match"||re.type==="metadata_all_in")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:Yo,children:"Metadata Key"}),s.jsx("input",{type:"text",value:re.key??"",onChange:Ae=>ae({...re,key:Ae.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Pc})]}),s.jsxs("div",{children:[s.jsx("label",{className:Yo,children:"Field"}),s.jsx("input",{type:"text",value:re.field??"",onChange:Ae=>ae({...re,field:Ae.target.value}),placeholder:"e.g. status",className:Pc})]}),re.type==="metadata_all_match"?s.jsxs("div",{children:[s.jsx("label",{className:Yo,children:"Value"}),s.jsx("input",{type:"text",value:re.value??"",onChange:Ae=>ae({...re,value:Ae.target.value}),placeholder:"e.g. passed, resolved",className:Pc})]}):s.jsxs("div",{children:[s.jsx("label",{className:Yo,children:"Values (comma-separated)"}),s.jsx("input",{type:"text",value:((rn=re.values)==null?void 0:rn.join(", "))??"",onChange:Ae=>ae({...re,values:Ae.target.value.split(",").map($e=>$e.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Pc})]})]}),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 Ae=Cn(G),$e=Ae==null?void 0:Ae.stepId,Qe=(Ae==null?void 0:Ae.transIdx)??0,rt=$e?te.find(St=>St.id===$e):void 0,mt=(rt==null?void 0:rt.transitions.length)??0;return s.jsx(qV,{fromLabel:Te.fromLabel,toLabel:Te.toLabel,condition:Te.condition,subGroup:"subGroup"in Te?Te.subGroup:void 0,fromStep:Te.type==="step"?te.find(St=>St.id===Te.fromLabel):void 0,agentTypes:Pe,transitionIndex:Qe,totalTransitions:mt,onUpdateCondition:St=>Je(G,St),onUpdateSubGroup:St=>oe(G,St),onDelete:()=>nt(G),onMoveUp:()=>{se(St=>{const Rn=St.find(kn=>kn.id===$e);if(!Rn||Qe===0)return St;const xn=[...Rn.transitions];return[xn[Qe-1],xn[Qe]]=[xn[Qe],xn[Qe-1]],St.map(kn=>kn.id===$e?{...kn,transitions:xn}:kn)}),B(`${$e}:${Qe-1}`)},onMoveDown:()=>{se(St=>{const Rn=St.find(kn=>kn.id===$e);if(!Rn||Qe===Rn.transitions.length-1)return St;const xn=[...Rn.transitions];return[xn[Qe],xn[Qe+1]]=[xn[Qe+1],xn[Qe]],St.map(kn=>kn.id===$e?{...kn,transitions:xn}:kn)}),B(`${$e}:${Qe+1}`)}})})():Ct?s.jsx(WV,{step:Ct,isEntry:Ct.id===X,agentTypes:Pe,transitionCount:Ct.transitions.length,templateVariables:d,onUpdate:Sn,onRemove:()=>{var Ae;if(Ct&&(se(te.filter(($e,Qe)=>Qe!==Dt)),Xe(null),X===Ct.id)){const $e=te.filter((Qe,rt)=>rt!==Dt);Z(((Ae=$e[0])==null?void 0:Ae.id)??"")}},onSetEntry:()=>Z(Ct.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:Ve,children:"Close"}),R?s.jsx(ot,{variant:"primary",onClick:()=>{q(H+" (copy)"),J(`${E}-copy-${Date.now()}`),T(null),M(!1)},children:"Duplicate & Customize"}):s.jsxs(s.Fragment,{children:[s.jsx(ot,{variant:"primary",onClick:he,children:"Save"}),s.jsx(ot,{variant:"primary",onClick:We,children:"Save & Close"})]})]})]})}return s.jsx(wt,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:s.jsx(Xj,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:fe,loading:u,hasItems:a.length>0||o.length>0||c.length>0,children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(_x,{title:"Built-in",items:a,renderActions:Te=>s.jsx(s.Fragment,{children:s.jsx(di,{onClick:()=>ge(Te.id),children:s.jsx(Xy,{})})})}),s.jsx(_x,{title:"Custom",items:o,renderActions:Te=>s.jsxs(s.Fragment,{children:[s.jsx(di,{onClick:()=>qe(Te.id,"user"),children:s.jsx("span",{className:"text-[10px]",children:"Edit"})}),s.jsx(su,{onClick:()=>ge(Te.id,"user")}),_(`user:${Te.id}`,"delete")?s.jsx(Ih,{onConfirm:()=>Fe(Te.id,"user"),onCancel:S}):s.jsx(Mh,{onClick:()=>v(`user:${Te.id}`)})]})}),c.length>0&&s.jsx(_x,{title:"Project",items:c,renderActions:Te=>s.jsxs(s.Fragment,{children:[s.jsx(di,{onClick:()=>qe(Te.id,"project"),children:s.jsx("span",{className:"text-[10px]",children:"Edit"})}),s.jsx(su,{onClick:()=>ge(Te.id,"project")}),_(`project:${Te.id}`,"delete")?s.jsx(Ih,{onConfirm:()=>Fe(Te.id,"project"),onCancel:S}):s.jsx(Mh,{onClick:()=>v(`project:${Te.id}`)})]})})]})})})}function XV(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function JV({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:a,onCloseCompleteAction:o,textareaContent:c,onSearchMessages:u,onToggleAutoScroll:d,isAutoScrollActive:h}){const[,p]=Pn(),m=ln(Y=>Y.fetchCommands),g=Ht(Y=>Y.fetchWorkflows),x=ct(Y=>Y.fetchAgents),w=ln(Y=>Y.defaults),C=ln(Y=>Y.userItems),v=ln(Y=>Y.projectItems),S=Ht(Y=>Y.defaults),_=Ht(Y=>Y.userItems),b=Ht(Y=>Y.projectItems),k=ct(Y=>Y.defaults),E=ct(Y=>Y.userItems),T=ct(Y=>Y.projectItems),D=Re(Y=>{var X;return(X=Y.currentSession)==null?void 0:X.mode}),A=Re(Y=>{var X;return((X=Y.currentSession)==null?void 0:X.dangerLevel)??"normal"}),R=Re(Y=>Y.switchMode),M=Re(Y=>Y.switchDangerLevel),W=Re(Y=>{var X;return(X=Y.currentSession)==null?void 0:X.projectId}),$=Re(Y=>{var X;return(X=Y.currentSession)==null?void 0:X.workdir}),G=j.useRef(void 0),[B,H]=j.useState(""),[q,Q]=j.useState(0),J=j.useRef(null),U=j.useRef(!1);j.useEffect(()=>{e&&(U.current=!0)},[e]),j.useEffect(()=>{if(e){m($),g($),x($),H(""),Q(0);const Y=setTimeout(()=>{var X;Ft()&&((X=J.current)==null||X.focus())},50);return()=>clearTimeout(Y)}},[e,m,g,x,$]),j.useEffect(()=>{var Y;!e&&U.current&&(n==null||n(),(Y=G.current)==null||Y.call(G),G.current=void 0)},[e,n]);const O=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const Y=W??XV(window.location.pathname);Y&&p(`/p/${Y}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{G.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)}},...Zn(Zn(k,E),T).filter(Y=>!Y.subagent&&Y.id!==D).map(Y=>({id:Y.id,name:Y.name,prefix:"Agent > Switch to",action:()=>R(Y.id)})),...Zn(Zn(w,C),v).map(Y=>({id:Y.id,name:Y.name,prefix:"Command > Launch",action:()=>r(Y.id,c)})),...Zn(Zn(S,_),b).map(Y=>({id:Y.id,name:Y.name,prefix:"Workflow > Run",action:()=>a(Y.id,Y.scope)})),...["normal","dangerous"].filter(Y=>Y!==A).map(Y=>({id:Y,name:Y.charAt(0).toUpperCase()+Y.slice(1),prefix:"Mode > Switch to",action:()=>M(Y)}))].filter(Y=>Ki(`${Y.prefix} ${Y.name}`,B)),V=O.length-1,z=Y=>{oT(Y,V,Q,()=>{var X;(X=O[q])==null||X.action(),t()},t)};return e?mi.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:J,type:"text",value:B,onChange:Y=>{H(Y.target.value),Q(0)},onKeyDown:z,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),s.jsx(tb,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),s.jsx(ht,{className:"max-h-[60vh] p-2",children:O.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"}):O.map((Y,X)=>s.jsxs("button",{type:"button",onClick:()=>{Y.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${X===q?"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:[Y.prefix," "]}),s.jsx("span",{children:Y.name})]},Y.id))})]})]}),document.body):null}const JT="openfox-message-search-filters",QV=[{key:"user",label:"User prompts"},{key:"thinking",label:"Thinking"},{key:"response",label:"Responses"}];function ZV(){try{const e=localStorage.getItem(JT);if(e){const t=JSON.parse(e);return new Set(t)}}catch{}return new Set(["user","thinking","response"])}function eG(e){localStorage.setItem(JT,JSON.stringify([...e]))}function tG(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 nG(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 rG(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 sG(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 iG(e){var n,r;if(e.type!=="message")return s.jsx(Yw,{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(l3,{className:"w-3.5 h-3.5"}):s.jsx(Yw,{className:"w-3.5 h-3.5"}):s.jsx(o3,{className:"w-3.5 h-3.5"})}function wk(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 aG({isOpen:e,onClose:t,displayItems:n,onNavigate:r}){const[a,o]=j.useState(""),[c,u]=j.useState(0),[d,h]=j.useState(ZV),p=j.useRef(null),m=j.useRef(null),g=j.useRef(null),x=E=>{h(T=>{const D=new Set(T);return D.has(E)?D.delete(E):D.add(E),eG(D),D})},w=j.useMemo(()=>n.filter(E=>{var T,D;return!(E.type==="context-divider"||E.type==="message"&&(E.message.messageKind==="auto-prompt"||E.message.role==="assistant"&&!((T=E.message.content)!=null&&T.trim())&&!((D=E.message.thinkingContent)!=null&&D.trim())))}),[n]),C=j.useMemo(()=>w.filter(E=>{const T=tG(E);return!(T&&!d.has(T))}),[w,d]),v=j.useMemo(()=>a?w.filter(E=>{const T=wk(E);return Ki(T,a)}):C,[C,a]),S=v.length-1;j.useEffect(()=>{if(e){o(""),u(0);const E=setTimeout(()=>{var T;Ft()&&((T=p.current)==null||T.focus())},50);return()=>clearTimeout(E)}},[e]),j.useEffect(()=>{var E;if(e&&m.current){const T=(E=m.current.osInstance())==null?void 0:E.elements().viewport;T&&(T.scrollTop=T.scrollHeight)}},[e]),j.useEffect(()=>{g.current&&g.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[c]);const _=E=>{oT(E,S,u,()=>{const T=v[c];if(T){const D=n.indexOf(T);D>=0&&r(D),t()}},t)},b=E=>{const T=n.indexOf(E);T>=0&&r(T),t()},k=E=>n.indexOf(E);return e?mi.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(hi,{}),s.jsx("input",{ref:p,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(ta,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"flex gap-1.5 px-4 py-2 border-b border-border",children:QV.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(ht,{ref:m,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 D=k(E),A=iG(E),R=wk(E),M=sG(E),W=rG(E),$=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":$?"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:R})]}),W&&s.jsx("span",{className:"text-text-muted text-xs shrink-0",children:nG(W)})]})},`${D}-${E.type}`)})})]})]}),document.body):null}function QT(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 oG(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((p,m)=>(p.position??0)-(m.position??0)).forEach((p,m)=>{c[m]!==void 0&&(u[p.id]=c[m])}):c.forEach((h,p)=>{u[String(p)]=h}),{workflowId:o,params:u}):n&&n.find(p=>p.id===o)?(c.forEach((p,m)=>{u[String(m)]=p}),{commandId:o,params:u}):null}function lG({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(ht,{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,p)=>s.jsxs("div",{ref:p===t?c:null,role:"listitem",onClick:()=>d(h.content),className:`
|
|
317
|
+
p-2 rounded cursor-pointer transition-colors
|
|
318
|
+
${p===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 cG(){const e=z5(),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 uG(){const e=Re(c=>c.activeWorkflowExecution),t=Re(c=>c.exitWorkflow),[n,r]=j.useState(!1);j.useEffect(()=>{r(!1)},[e==null?void 0:e.id]);const a=j.useCallback(()=>{n||(r(!0),t())},[n,t]);if(!e||e.status!=="running"&&e.status!=="waiting")return null;const o=e.workflowColor&&/^#[0-9a-fA-F]{6}$/.test(e.workflowColor)?e.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:o}}),s.jsx("span",{className:"font-medium text-text-primary truncate",children:e.workflowName}),e.currentStepName&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{className:"text-text-muted truncate",children:e.currentStepName})]}),s.jsx("div",{className:"ml-auto shrink-0",children:s.jsx("button",{onClick:a,disabled:n,className:"text-xs px-2 py-0.5 rounded text-text-tool-error hover:bg-text-tool-error/10 transition-colors disabled:opacity-50",children:n?"Exiting...":"✕ Exit"})})]})}function ZT(e){const t=Re(o=>o.sendMessage),n=Re(o=>o.launchWorkflow),r=j.useCallback((o,c,u)=>{e(!0),t(o,c,u)},[e,t]),a=j.useCallback((o,c,u,d,h,p="auto")=>{e(!0),n(o,c,u,d,h,p)},[e,n]);return{sendMessage:r,launchWorkflow:a}}function dG({children:e}){return mi.createPortal(e,document.body)}function hG(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 fG({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:r,onOpenWorkflowsManager:a,onAttach:o,textareaContent:c,attachments:u}){const[d,h]=j.useState(!1),[p,m]=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=ln(V=>V.defaults),D=ln(V=>V.userItems),A=ln(V=>V.projectItems),R=ln(V=>V.fetchCommands),M=Ht(V=>V.fetchWorkflows),W=Re(V=>{var z;return(z=V.currentSession)==null?void 0:z.workdir}),$=Zn(Zn(T,D),A),G=Zf();j.useEffect(()=>{d&&(p==="commands"?R(W):p==="workflows"&&M(W))},[d,p,R,M,W]),j.useEffect(()=>{d&&(x(""),C(0),requestAnimationFrame(()=>{var V;Ft()&&((V=k.current)==null||V.focus())}))},[d,p]),j.useEffect(()=>{if(!d)return;const V=z=>{var Y;(Y=E.current)!=null&&Y.contains(z.target)||h(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[d]);const B=V=>{switch(V.key){case"ArrowDown":V.preventDefault(),C(z=>{const X=(p==="commands"?$:G).filter(Z=>{const F=g.toLowerCase();return!F||Z.name.toLowerCase().includes(F)});return Math.min(z+1,X.length-1)});break;case"ArrowUp":V.preventDefault(),C(z=>Math.max(z-1,0));break;case"Enter":V.preventDefault();break;case"Escape":V.preventDefault(),h(!1);break}},H=V=>{x(V),C(0)},q=$.filter(V=>!g||V.name.toLowerCase().includes(g.toLowerCase())),Q=G.filter(V=>!g||V.name.toLowerCase().includes(g.toLowerCase())),J=async V=>{const z=await ln.getState().fetchCommand(V,W);z&&e(z.prompt,z.metadata.agentMode,c,u),h(!1)},U=(V,z)=>{t(V,z),h(!1)},I=(V,z)=>{z.stopPropagation(),h(!1),S(V)},O=(V,z)=>{z.stopPropagation(),h(!1),b(V)};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(Vj,{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:()=>{m("commands"),x(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="commands"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Commands"}),s.jsx("button",{type:"button",onClick:()=>{m("workflows"),x(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="workflows"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Workflows"}),s.jsx("button",{type:"button",onClick:()=>m("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),p!=="attach"&&s.jsx("div",{className:"p-2 border-b border-border",children:s.jsx("input",{ref:k,value:g,onChange:V=>H(V.target.value),onKeyDown:B,placeholder:p==="commands"?"Search commands...":"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),s.jsx(ht,{className:"max-h-64 p-1",children:p==="commands"?q.length===0?s.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:$.length===0?"No commands yet":"No matches"}):q.map((V,z)=>s.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${z===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[s.jsx("button",{type:"button",onClick:()=>J(V.id),className:"flex-1 text-left",children:s.jsx("div",{className:"text-sm text-text-primary font-medium",children:V.name})}),s.jsx(di,{className:"opacity-0 group-hover:opacity-100",onClick:Y=>I(V.id,Y)})]},V.id)):p==="workflows"?Q.length===0?s.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:G.length===0?"No workflows yet":"No matches"}):Q.map((V,z)=>{const Y=hG(V),X=V.color??"#3b82f6";return s.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${z===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[s.jsxs("button",{type:"button",onClick:()=>U(V.id,V.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:X}}),s.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:V.name}),s.jsx("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded whitespace-nowrap",children:Gb[V.scope]}),Y!==null&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:Y?"#22c55e":"#6b7280"},title:Y?"Entry condition met":"Entry condition not met"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[V.subGroups&&V.subGroups.length>0&&s.jsx(mG,{subGroups:V.subGroups,onSelect:Z=>{h(!1),n(V.id,Z,V.scope)}}),s.jsx(di,{className:"opacity-0 group-hover:opacity-100",onClick:Z=>O(V.id,Z)})]})]},`${V.id}-${V.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(Hj,{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"})]})}),p!=="attach"&&s.jsx("div",{className:"border-t border-border p-1",children:s.jsx("button",{type:"button",onClick:()=>{h(!1),p==="commands"?r():a()},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:p==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),s.jsx(qT,{isOpen:!!v,onClose:()=>S(null),initialEditId:v,projectDir:W}),s.jsx(XT,{isOpen:!!_,onClose:()=>b(null),initialEditId:_})]})}function mG({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);em(u,()=>r(!1),n);const d=h=>{if(h.stopPropagation(),!n&&c.current){const p=c.current.getBoundingClientRect();o({top:p.bottom+4,right:window.innerWidth-p.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(dG,{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:p=>{p.stopPropagation(),t(h)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:h},h))})})]})}function pG({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(Cu,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function gG({agent:e,isBuiltIn:t,isConfirmingDelete:n,alwaysAllowedNames:r,model:a,onView:o,onEdit:c,onDuplicate:u,onDelete:d,onCancelDelete:h}){var g;const p=e.allowedTools.filter(x=>!(r!=null&&r.has(x))),m=a?(g=a.split("/").pop())==null?void 0:g.replace(/-/g," "):void 0;return s.jsxs(sE,{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"}),m&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-accent-primary/10 text-accent-primary",children:m})]}),e.description&&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:[p.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)),p.length>5&&s.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",p.length-5," more"]})]})]})}function Ck({title:e,agentTitle:t="Agents",subagentTitle:n="Sub-agents",agents:r,subagents:a,isBuiltIn:o,alwaysAllowedNames:c,modelOverrides:u,onView:d,onDuplicate:h,onEdit:p,onDelete:m,onCancelDelete:g,isConfirmingDelete:x}){if(r.length===0&&a.length===0)return null;const w=C=>s.jsx(gG,{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:p?()=>p(C.id):void 0,onDuplicate:()=>h(C.id),onDelete:o?void 0:()=>m==null?void 0:m(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 xG(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 mh(e){const t=[];for(const[n,r]of e)r.size===0?t.push(n):t.push(`${n}:${[...r].join(",")}`);return t}function yG({formName:e,formId:t,formDescription:n,formSubagent:r,formTools:a,formColor:o,formModel:c,formPrompt:u,formError:d,isReadOnly:h,availableTools:p,providers:m,onNameChange:g,onIdChange:x,onDescriptionChange:w,onSubagentChange:C,onToolsChange:v,onColorChange:S,onModelChange:_,onPromptChange:b}){const k=xG(a),E=p.filter(M=>!(r&&M.topLevelOnly)&&!M.isMcp),T=p.filter(M=>M.isMcp&&!(r&&M.topLevelOnly)),D=new Map;for(const M of T){const W=M.mcpServer??M.name,$=D.get(W)??[];$.push(M),D.set(W,$)}const A=(M,W)=>{const $=new Map(k),G=$.get(M)||new Set,B=new Set(G);B.has(W)?B.delete(W):B.add(W),B.size===0?$.set(M,new Set):$.set(M,B),v(mh($))},R=M=>{const W=new Map(k);W.has(M)?W.delete(M):W.set(M,new Set),v(mh(W))};return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"space-y-3",children:[d&&s.jsx(ll,{message:d}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(Xr,{label:"Name",value:e,onChange:g,placeholder:"My Agent",readOnly:h}),s.jsx(Xr,{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(Xr,{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(Vb,{providers:m,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(ht,{className:"flex flex-wrap gap-1.5 p-2 bg-bg-tertiary border border-border rounded max-h-32",children:E.map(M=>{const W=k.has(M.name),$=M.actions.length>0,G=k.get(M.name)||new Set;return $?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(Tl,{trigger:s.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${W?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} cursor-pointer`,children:[s.jsx("span",{children:M.name}),G.size>0&&s.jsx("span",{className:"text-[10px]",children:"*"})]}),minWidth:"160px",items:[...M.actions.map(B=>({label:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${M.name}-${B}`,children:[s.jsx("input",{type:"checkbox",id:`${M.name}-${B}`,checked:G.has(B),onChange:()=>A(M.name,B),disabled:h,className:"w-3 h-3 rounded accent-accent-primary"}),s.jsx("span",{children:B})]}),closeOnClick:!1})),{label:W?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(W)R(M.name);else{const B=new Map(k);B.set(M.name,new Set(M.actions)),v(mh(B))}}}]},M.name):s.jsx("button",{onClick:()=>!h&&R(M.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${W?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none":"cursor-pointer"}`,children:s.jsx("span",{children:M.name})},M.name)})})]}),D.size>0&&(()=>{const M=new Set(T.map(H=>H.name)),W=k.has("__mcp_none__"),$=[...k.keys()].some(H=>M.has(H)),G=W?"none":$?"partial":"all",B=H=>{const q=new Map(k);for(const Q of q.keys())(Q==="__mcp_none__"||M.has(Q))&&q.delete(Q);if(H==="none"&&q.set("__mcp_none__",new Set),H==="partial")for(const Q of M)q.set(Q,new Set);v(mh(q))};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(H=>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:G===H,onChange:()=>B(H),disabled:h,className:"w-3 h-3 accent-accent-primary"}),s.jsxs("span",{className:G===H?"text-text-primary font-medium":"text-text-muted",children:[H.charAt(0).toUpperCase()+H.slice(1),H==="partial"&&M.size>0&&s.jsxs("span",{className:"ml-1 text-text-muted font-normal",children:["(",[...k.keys()].filter(q=>M.has(q)).length,"/",M.size,")"]})]})]},H))}),G==="partial"&&(()=>{const[H,q]=j.useState(""),[Q,J]=j.useState(0),U=j.useRef(null),I=z=>{var X;const Y=(X=U.current)==null?void 0:X.querySelector(`[data-idx="${z}"]`);Y==null||Y.scrollIntoView({block:"nearest"})};j.useEffect(()=>{I(Q)},[Q]);const O=H?T.filter(z=>z.name.toLowerCase().includes(H.toLowerCase())):T,V=z=>{z.key==="ArrowDown"?(z.preventDefault(),J(Y=>Math.min(Y+1,O.length-1))):z.key==="ArrowUp"?(z.preventDefault(),J(Y=>Math.max(Y-1,0))):z.key==="Enter"&&O[Q]&&(z.preventDefault(),R(O[Q].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:H,onChange:z=>{q(z.target.value),J(0)},onKeyDown:V,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(ht,{className:"max-h-60",children:s.jsxs("div",{ref:U,children:[O.map((z,Y)=>{const X=k.has(z.name),Z=Y===Q;return s.jsxs("div",{"data-idx":Y,className:`flex items-center justify-between px-3 py-1.5 transition-colors ${Z?"bg-bg-primary":"hover:bg-bg-primary/30"}`,onMouseEnter:()=>J(Y),children:[s.jsx("span",{className:`text-xs font-mono ${X?"text-text-primary":"text-text-muted"}`,children:z.name}),s.jsx(ds,{enabled:X,onClick:()=>R(z.name),label:z.name})]},z.name)}),O.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 bG(e){const t=e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"");return t?`custom-${t}`:""}function vG({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){const a=ct(fe=>fe.defaults),o=ct(fe=>fe.userItems),c=ct(fe=>fe.projectItems),u=ct(fe=>fe.loading),d=ct(fe=>fe.fetchAgents),h=ct(fe=>fe.fetchAgent),p=ct(fe=>fe.fetchDefaultContent),m=ct(fe=>fe.createAgent),g=ct(fe=>fe.updateAgent),x=ct(fe=>fe.deleteAgent),[w,C]=j.useState("list"),[v,S]=j.useState(null),[_,b]=j.useState(!1),[k,E]=j.useState(""),[T,D]=j.useState(""),[A,R]=j.useState(""),[M,W]=j.useState(!1),[$,G]=j.useState([]),[B,H]=j.useState("#6b7280"),[q,Q]=j.useState(void 0),[J,U]=j.useState(""),[I,O]=j.useState("user"),[V,z]=j.useState(""),[Y,X]=j.useState(!1),[Z,F]=j.useState(!1),[P,te]=j.useState(null),[se,re]=j.useState([]),[ae,ye]=j.useState(new Set),{requestDelete:_e,clearConfirm:Ie,isConfirming:He}=gu(),je=fe=>{E(fe.metadata.name),D(fe.metadata.id),R(fe.metadata.description),W(fe.metadata.subagent),G(fe.metadata.allowedTools),H(fe.metadata.color??"#6b7280"),U(fe.prompt),z(""),F(!0),xe(`/api/agents/${fe.metadata.id}/model`).then(Fe=>Fe.json()).then(Fe=>{Fe.providerId&&Fe.model?Q(`${Fe.providerId}/${Fe.model}`):Q(void 0)}).catch(()=>Q(void 0)).finally(()=>F(!1))},Ge=(fe,Fe,Xe)=>{E(fe.metadata.name+" (copy)"),D(`${Fe}-copy-${Date.now()}`),R(fe.metadata.description),W(fe.metadata.subagent),G(fe.metadata.allowedTools),H(fe.metadata.color??"#6b7280"),U(fe.prompt),z(""),S(null),b(!1),C("edit")},Ze=(fe,Fe)=>{je(fe),S(Fe),b(!0),C("edit")};j.useEffect(()=>{e&&(d(r),xe("/api/tools").then(fe=>fe.json()).then(fe=>{const Fe=fe.tools||[];ye(new Set(Fe.filter(Xe=>Xe.alwaysAllowed).map(Xe=>Xe.name))),re(Fe.filter(Xe=>!Xe.alwaysAllowed))}).catch(()=>{re([]),ye(new Set)}),n?a.some(Fe=>Fe.id===n)?p(n).then(Fe=>{Fe&&Ge(Fe,n)}):h(n,r).then(Fe=>{Fe&&(je(Fe),S(n),b(!1),C("edit"))}):(C("list"),S(null),b(!1)))},[e,d,h,p,n,r]);const Se=async fe=>{if(a.some(Xe=>Xe.id===fe)){const Xe=await p(fe);if(!Xe)return;Ze(Xe,fe)}else{const Xe=await h(fe,r);if(!Xe)return;Ze(Xe,fe)}},be=async fe=>{let Fe=await p(fe);Fe||(Fe=await h(fe,r)),Fe&&Ge(Fe,fe)},de=()=>{S(null),E(""),D(""),R(""),W(!1),G(["read_file"]),H("#6b7280"),U(""),O("user"),z(""),b(!1),C("edit")},ie=async fe=>{const Fe=await h(fe,r);Fe&&(je(Fe),S(fe),b(!1),C("edit"))},Pe=fe=>{te(fe)},Ue=async fe=>{await x(fe,r)},ue=async()=>{const fe=v??T;if(!fe||!k||!J){z("Name and prompt are required.");return}X(!0),z("");const Fe={metadata:{id:fe,name:k,description:A,subagent:M,allowedTools:$.filter(Ct=>!ae.has(Ct)),color:B},prompt:J},Xe=v?await g(v,Fe,r):await m(Fe,I,r);if(!Xe.success){X(!1),z(Xe.error??"Failed to save agent.");return}await eA(v??T,q),await d(r);const _t=v??T,Dt=Re.getState().currentSession;if((Dt==null?void 0:Dt.mode)===_t&&q){const{providerId:Ct,model:Sn}=nv(q);Re.getState().setSessionProvider(Ct,Sn)}X(!1),n?t():C("list")},De=()=>{n?t():(C("list"),b(!1))},qe=fe=>{E(fe),v||D(bG(fe))},pe=ct(fe=>fe.modelOverrides),he=a.filter(fe=>fe.subagent),We=a.filter(fe=>!fe.subagent),Ve=o.filter(fe=>fe.subagent),et=o.filter(fe=>!fe.subagent),it=c.filter(fe=>fe.subagent),ge=c.filter(fe=>!fe.subagent);return w==="edit"?s.jsxs(s.Fragment,{children:[s.jsxs(wt,{isOpen:e,onClose:De,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)"),D(`${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(Yj,{onCancel:De,onSave:ue,saving:Y,saveDisabled:!k||!J||Z}),children:[!v&&!_&&s.jsx(Af,{value:I,onChange:O}),s.jsx(yG,{formName:k,formId:T,formDescription:A,formSubagent:M,formTools:$,formColor:B,formModel:q,formPrompt:J,formError:V,isReadOnly:_,availableTools:se,providers:en.getState().providers,onNameChange:qe,onIdChange:D,onDescriptionChange:R,onSubagentChange:fe=>{W(fe),fe&&G(Fe=>Fe.filter(Xe=>{var _t;return!((_t=se.find(Dt=>Dt.name===Xe))!=null&&_t.topLevelOnly)}))},onToolsChange:G,onColorChange:H,onModelChange:Q,onPromptChange:U})]}),s.jsx(kk,{agentId:P,onClose:()=>te(null),onSaved:()=>d(r)})]}):s.jsxs(s.Fragment,{children:[s.jsx(wt,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:s.jsx(Xj,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:de,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(Ck,{title:"Built-in",agents:We,subagents:he,isBuiltIn:!0,alwaysAllowedNames:ae,modelOverrides:pe,onView:Se,onEdit:Pe,onDuplicate:be}),(et.length>0||Ve.length>0||ge.length>0||it.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:et,subagents:Ve},{title:"Project",agents:ge,subagents:it}].map(fe=>(fe.agents.length>0||fe.subagents.length>0)&&s.jsx(Ck,{title:fe.title,agents:fe.agents,subagents:fe.subagents,isBuiltIn:!1,alwaysAllowedNames:ae,modelOverrides:pe,isConfirmingDelete:Fe=>He(Fe,"delete"),onView:Se,onDuplicate:be,onEdit:ie,onDelete:Fe=>{He(Fe,"delete")?(Ue(Fe),Ie()):_e(Fe)},onCancelDelete:Ie},fe.title))})]})]})})}),s.jsx(kk,{agentId:P,onClose:()=>te(null),onSaved:()=>d(r)})]})}function nv(e){const t=e.indexOf("/");return t>0?{providerId:e.substring(0,t),model:e.substring(t+1)}:{providerId:e,model:e}}async function eA(e,t){if(t){const{providerId:n,model:r}=nv(t);await xe(`/api/agents/${e}/model`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})})}else await xe(`/api/agents/${e}/model`,{method:"DELETE"})}function kk({agentId:e,onClose:t,onSaved:n}){const[r,a]=j.useState(void 0),[o,c]=j.useState(!1),[u,d]=j.useState(!1),[h,p]=j.useState(null),m=ct(_=>_.defaults),g=ct(_=>_.userItems),x=ct(_=>_.projectItems),w=[...m,...g,...x],C=e?w.find(_=>_.id===e):void 0,v=en(_=>_.providers);j.useEffect(()=>{e&&(c(!0),xe(`/api/agents/${e}/model`).then(_=>_.json()).then(_=>{a(_.providerId&&_.model?`${_.providerId}/${_.model}`:void 0)}).catch(()=>a(void 0)).finally(()=>c(!1)))},[e]);const S=async()=>{if(e){d(!0),p(null);try{await eA(e,r);const _=Re.getState().currentSession;if((_==null?void 0:_.mode)===e&&r){const{providerId:b,model:k}=nv(r);Re.getState().setSessionProvider(b,k)}n(),t()}catch{p("Failed to save. Please try again.")}d(!1)}};return s.jsx(wt,{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(Vb,{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:S,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 _G(){const e=Re(k=>{var E;return(E=k.currentSession)==null?void 0:E.mode}),t=Re(k=>{var E;return(E=k.currentSession)==null?void 0:E.workdir}),n=Re(k=>k.switchMode),r=ct(k=>k.defaults),a=ct(k=>k.userItems),o=ct(k=>k.projectItems),c=ct(k=>k.fetchAgents),u=[...r,...a,...o],[d,h]=j.useState(!1),[p,m]=j.useState(!1),[g,x]=j.useState(null),w=j.useRef(null);j.useEffect(()=>{c(t)},[c,t]),em(w,()=>h(!1));const C=pu();if(!e)return null;const v=u.filter(k=>!k.subagent),S=v.find(k=>k.id===e),_=(S==null?void 0:S.name)??e,b=Qa(u,e);return s.jsxs("div",{className:"relative",ref:w,children:[s.jsxs("button",{type:"button",onClick:()=>h(!d),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:b},children:_}),s.jsx(gn,{className:`w-3 h-3 text-text-muted transition-transform ${d?"rotate-180":""}`})]}),d&&v.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:[v.map((k,E)=>{const T=k.id===e,D=Qa(u,k.id),A=C.agentSwitching[E],R=A?Oh(A):null;return s.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors group ${T?"bg-bg-tertiary":"hover:bg-bg-tertiary cursor-pointer"}`,children:[s.jsxs("button",{type:"button",onClick:()=>{T||n(k.id),h(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",style:{color:D},children:k.name}),T&&s.jsx(Rs,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),R&&s.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:R})]},k.id)}),s.jsx("div",{className:"border-t border-border p-1",children:s.jsx("button",{type:"button",onClick:()=>{h(!1),m(!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(vG,{isOpen:p,onClose:()=>{m(!1),x(null)},initialEditId:g,projectDir:t})]})}function SG(){const e=Re(r=>r.currentSession),t=Re(r=>r.switchDangerLevel);if(!e)return null;const n=e.dangerLevel??"normal";return 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:()=>t("normal"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="normal"?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),s.jsx("button",{type:"button",onClick:()=>t("dangerous"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="dangerous"?"bg-red-500/20 text-red-400":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})}function jk({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 wG=[8080,11434,8e3,1234];function ky(e){if(e!=null&&e.length)return e.includes("medium")?"medium":e[0]}function tA(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 CG({model:e,modelConfigs:t,autoConfigState:n,testResults:r,onUpdateConfig:a,onRunAutoConfig:o,onTestParams:c,onShowRaw:u}){var d,h,p,m,g,x,w,C,v,S,_,b,k,E,T,D,A,R,M,W,$,G,B,H,q,Q,J,U,I,O,V,z,Y,X,Z,F,P,te,se,re,ae,ye,_e,Ie,He;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:je=>a(e.id,{contextWindow:parseInt(je.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:je=>a(e.id,{supportsVision:je.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:(p=r[e.id+"-thinking"])==null?void 0:p.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(m=r[e.id+"-thinking"])!=null&&m.loading?"Testing...":"Test thinking"}),((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:je=>a(e.id,{thinkingEnabled:je.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"})]}),((D=t[e.id])==null?void 0:D.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:((R=t[e.id])==null?void 0:R.thinkingLevel)??ky(e.reasoningEfforts),onChange:je=>a(e.id,{thinkingLevel:je.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(je=>s.jsx("option",{value:je,children:je},je))}):s.jsx("input",{type:"text","aria-label":"Reasoning effort",value:((M=t[e.id])==null?void 0:M.thinkingLevel)??"",onChange:je=>a(e.id,{thinkingLevel:je.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),s.jsx(jk,{value:(W=t[e.id])==null?void 0:W.thinkingQueryParams,onChange:je=>a(e.id,{thinkingQueryParams:je})})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:(($=t[e.id])==null?void 0:$.nonThinkingEnabled)??!1,onChange:je=>a(e.id,{nonThinkingEnabled:je.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"})]}),((G=t[e.id])==null?void 0:G.nonThinkingEnabled)&&s.jsx("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:s.jsx(jk,{value:(B=t[e.id])==null?void 0:B.nonThinkingQueryParams,onChange:je=>a(e.id,{nonThinkingQueryParams:je})})})]}),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:((H=t[e.id])==null?void 0:H.temperature)??"",onChange:je=>a(e.id,{temperature:je.target.value?parseFloat(je.target.value):void 0}),placeholder:((Q=(q=t[e.id])==null?void 0:q.defaultTemperature)==null?void 0:Q.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((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: ",(U=t[e.id])==null?void 0:U.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:((I=t[e.id])==null?void 0:I.topP)??"",onChange:je=>a(e.id,{topP:je.target.value?parseFloat(je.target.value):void 0}),placeholder:((V=(O=t[e.id])==null?void 0:O.defaultTopP)==null?void 0:V.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((z=t[e.id])==null?void 0:z.defaultTopP)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Y=t[e.id])==null?void 0:Y.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:((X=t[e.id])==null?void 0:X.topK)??"",onChange:je=>a(e.id,{topK:je.target.value?parseInt(je.target.value):void 0}),placeholder:((F=(Z=t[e.id])==null?void 0:Z.defaultTopK)==null?void 0:F.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((P=t[e.id])==null?void 0:P.defaultTopK)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(te=t[e.id])==null?void 0:te.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:((se=t[e.id])==null?void 0:se.maxTokens)??"",onChange:je=>a(e.id,{maxTokens:je.target.value?parseInt(je.target.value):void 0}),placeholder:((ae=(re=t[e.id])==null?void 0:re.defaultMaxTokens)==null?void 0:ae.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((ye=t[e.id])==null?void 0:ye.defaultMaxTokens)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(_e=t[e.id])==null?void 0:_e.defaultMaxTokens]})]})]})]}),s.jsx("div",{className:"pt-3 border-t border-border",children:s.jsx(kG,{value:(Ie=t[e.id])==null?void 0:Ie.compactionThreshold,maxTokens:((He=t[e.id])==null?void 0:He.contextWindow)??e.contextWindow,onChange:je=>a(e.id,{compactionThreshold:je})})})]})]})}function kG({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 m=Math.min(e??.85,o/100);h(Math.round(m*100))},[e,o]);const p=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,"% · ",xl(p)]}),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:m=>h(Number(m.target.value)),onMouseUp:()=>n(d/100),onTouchEnd:()=>n(d/100),onBlur:()=>n(d/100),onKeyUp:()=>n(d/100),className:"w-full"}),s.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:["Minimum ",xl(15e3)," tokens · maximum ",o,"% · default 85%"]})]})}function nA({isOpen:e,onClose:t,onSave:n,initialStep:r=1,editProvider:a,editModelId:o}){const[c,u]=j.useState(r),[d,h]=j.useState(""),[p,m]=j.useState(""),[g,x]=j.useState("unknown"),[w,C]=j.useState(""),[v,S]=j.useState(!1),[_,b]=j.useState(),[k,E]=j.useState(),[T,D]=j.useState(!1),[A,R]=j.useState(null),[M,W]=j.useState([]),[$,G]=j.useState(null),[B,H]=j.useState(!1),[q,Q]=j.useState(""),[J,U]=j.useState(!0),[I,O]=j.useState({}),[V,z]=j.useState({loading:!1,progress:{}}),[Y,X]=j.useState({}),[Z,F]=j.useState(null),[P,te]=j.useState(new Set),[se,re]=j.useState(""),[ae,ye]=j.useState(null),[_e,Ie]=j.useState("disconnected"),[He,je]=j.useState(!1),[Ge,Ze]=j.useState(null),[Se,be]=j.useState([]),[de,ie]=j.useState(!1),[Pe,Ue]=j.useState(!1),[ue,De]=j.useState(""),[qe,pe]=j.useState(null),he=j.useRef(null),We=j.useRef(!1),Ve=j.useRef(null),et=j.useRef(null);j.useEffect(()=>{c===1&&e&&requestAnimationFrame(()=>{var Ce;Ft()&&((Ce=Ve.current)==null||Ce.focus())})},[c,e]),j.useEffect(()=>()=>{he.current!==null&&window.clearTimeout(he.current)},[]),j.useEffect(()=>{e&&xe("/api/provider-presets").then(async Ce=>Ce.ok?await Ce.json():{presets:[]}).then(Ce=>be(Ce.presets)).catch(()=>be([]))},[e]);function it(Ce,nt){O(Je=>({...Je,[Ce]:{...Je[Ce],...nt}}))}function ge(Ce){te(nt=>new Set(nt).add(Ce.id)),O(nt=>({...nt,[Ce.id]:{contextWindow:Ce.contextWindow,...nt[Ce.id]}}))}function fe(Ce){if(!Ce.trim())return M;const nt=Ce.toLowerCase().split(/\s+/).filter(Boolean);return M.filter(Je=>nt.every(oe=>Je.id.toLowerCase().includes(oe)))}function Fe(){const Ce=ue.trim();if(!Ce){pe("Enter a model name");return}const nt=tt=>tt.toLowerCase().replace(/[-_\s:.]+/g,""),Je=nt(Ce),oe=M.find(tt=>nt(tt.id)===Je);if(oe){ge(oe),pe(`"${oe.id}" is already in the list`),De(""),!_&&V.progress[oe.id]!=="probing"&&fn(oe.id);return}const Be={id:Ce,contextWindow:2e5};W(tt=>[...tt,Be]),te(tt=>new Set(tt).add(Be.id)),O(tt=>({...tt,[Be.id]:{contextWindow:Be.contextWindow,thinkingEnabled:!0}})),G(Be.id),De(""),pe(null),R(null)}j.useEffect(()=>{var Ce,nt;if(e)if(u(r),h((a==null?void 0:a.name)??""),m((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),R(null),Q((a==null?void 0:a.thinkingField)??""),U((a==null?void 0:a.sendReasoningInMessages)??!0),X({}),F(null),ye(null),Ie("disconnected"),Ze(null),ie(!1),Ue(!1),De(""),pe(null),(Ce=a==null?void 0:a.models)!=null&&Ce.length){const Je={},oe=new Set;for(const Be of a.models)Je[Be.id]={contextWindow:Be.contextWindow,supportsVision:Be.supportsVision,thinkingEnabled:Be.thinkingEnabled,thinkingLevel:Be.thinkingLevel??ky(Be.reasoningEfforts),nonThinkingEnabled:Be.nonThinkingEnabled,thinkingQueryParams:Be.thinkingQueryParams,nonThinkingQueryParams:Be.nonThinkingQueryParams,defaultTemperature:Be.defaultTemperature,defaultTopP:Be.defaultTopP,defaultTopK:Be.defaultTopK,defaultMaxTokens:Be.defaultMaxTokens,temperature:Be.temperature,topP:Be.topP,topK:Be.topK,maxTokens:Be.maxTokens,compactionThreshold:Be.compactionThreshold},Be.selected&&oe.add(Be.id);if(oe.size===0)for(const Be of a.models)oe.add(Be.id);te(oe),O(Je),W(a.models),G(o??((nt=a.models[0])==null?void 0:nt.id)??null)}else W([]),O({}),G(null),te(new Set)},[e,r,a==null?void 0:a.id,o]),j.useEffect(()=>{const Ce=!!_;c===2&&p&&M.length===0&&!T&&!A&&(!Ce||_e==="connected")&&wn(p)},[c,_e]),j.useEffect(()=>{!e||!_||!(a!=null&&a.id)||_t(a.id)},[e,k,a==null?void 0:a.id]),j.useEffect(()=>{if(!Ge)return;const Ce=(a==null?void 0:a.id)??ae;if(!Ce)return;let nt=!1;const Je=async()=>{const Be=await _t(Ce);nt||Be!=="connected"||(Ze(null),ie(!1),Ue(!1),await wn(p))};Je();const oe=window.setInterval(()=>void Je(),2e3);return()=>{nt=!0,window.clearInterval(oe)}},[Ge,ae,a==null?void 0:a.id]);async function Xe(){if(a!=null&&a.id)return a.id;if(ae)return ae;const Ce=await xe("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d||"Provider",url:p,backend:g,authAdapter:_,transportAdapter:k,isLocal:!1,models:[]})});if(!Ce.ok)throw new Error("Unable to create provider");const nt=await Ce.json();return ye(nt.provider.id),nt.provider.id}async function _t(Ce){const nt=await xe(`/api/provider-auth/${Ce}/status`);if(!nt.ok)return"error";const Je=await nt.json(),oe=Je.state==="connected"?"connected":Je.state==="pending"?"pending":Je.state==="error"?"error":"disconnected";return Ie(oe),oe}async function Dt(){je(!0),Ie("pending");try{const Ce=await Xe(),nt=await xe(`/api/provider-auth/${Ce}/login`,{method:"POST"});if(!nt.ok)throw new Error("Unable to start provider sign-in");const Je=await nt.json();Ze(Je)}catch{Ie("error")}finally{je(!1)}}async function Ct(){var Ce;Ge!=null&&Ge.userCode&&(await((Ce=navigator.clipboard)==null?void 0:Ce.writeText(Ge.userCode)),he.current!==null&&window.clearTimeout(he.current),Ue(!1),requestAnimationFrame(()=>Ue(!0)),he.current=window.setTimeout(()=>{Ue(!1),he.current=null},1500))}function Sn(){Ge&&(window.open(Ge.directUrl??Ge.verificationUrl,"_blank","noopener,noreferrer"),ie(!0))}async function wn(Ce){var nt,Je;D(!0),R(null),W([]);try{const oe=new URLSearchParams({url:Ce});w&&oe.set("apiKey",w),g&&oe.set("backend",g);const Be=k?await xe(`/api/providers/${await Xe()}/models`):await xe(`/api/providers/models?${oe.toString()}`);if(Be.ok){const tt=await Be.json();if((nt=tt.models)!=null&&nt.length){W(tt.models),G(((Je=tt.models[0])==null?void 0:Je.id)??null);const Ot={};for(const rn of tt.models)Ot[rn.id]={contextWindow:rn.contextWindow,thinkingEnabled:!0,thinkingLevel:ky(rn.reasoningEfforts),defaultTemperature:rn.defaultTemperature,defaultTopP:rn.defaultTopP,defaultTopK:rn.defaultTopK,defaultMaxTokens:rn.defaultMaxTokens};O(Ot),tt.models.length===1&&(te(new Set([tt.models[0].id])),G(tt.models[0].id),fn(tt.models[0].id))}}else{const tt=await Be.json();R(tt.error??`Failed to fetch models from ${Ce}`)}}catch(oe){R(`Failed to fetch models from ${Ce}: ${oe instanceof Error?oe.message:"Unknown error"}`)}D(!1)}async function fn(Ce){z(nt=>({loading:!0,progress:{...nt.progress,[Ce]:"probing"}}));try{const nt=await xe("/api/providers/auto-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,apiKey:w||void 0,backend:g||"unknown",models:[{id:Ce}]})});if(!nt.ok){const oe=await nt.json();throw new Error(oe.error??"Auto-config failed")}const Je=await nt.json();for(const oe of Je.models){const Be={};oe.contextSource!=="default"&&(Be.contextWindow=oe.contextWindow,Be.supportsVision=oe.supportsVision),oe.thinkingConfig&&(Be.thinkingEnabled=!0,Be.thinkingQueryParams=JSON.stringify(oe.thinkingConfig)),oe.nonThinkingConfig&&(Be.nonThinkingEnabled=!0,Be.nonThinkingQueryParams=JSON.stringify(oe.nonThinkingConfig)),it(oe.id,Be),z(tt=>({...tt,progress:{...tt.progress,[oe.id]:"done"}}))}}catch(nt){console.error("Auto-config error:",nt),z(Je=>({...Je,progress:{...Je.progress,[Ce]:"error"}}))}finally{z(nt=>({...nt,loading:!1}))}}async function Dn(Ce,nt){const Je=Ce+"-"+nt;X(oe=>({...oe,[Je]:{loading:!0}}));try{const oe=I[Ce],Be=await xe("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,providerId:(a==null?void 0:a.id)??ae??void 0,transportAdapter:k,model:Ce,apiKey:w||void 0,backend:g||"unknown",thinkingField:q||void 0,mode:nt,modelConfig:{temperature:oe==null?void 0:oe.temperature,topP:oe==null?void 0:oe.topP,topK:oe==null?void 0:oe.topK,maxTokens:oe==null?void 0:oe.maxTokens,supportsVision:oe==null?void 0:oe.supportsVision,thinkingEnabled:oe==null?void 0:oe.thinkingEnabled,thinkingLevel:oe==null?void 0:oe.thinkingLevel,nonThinkingEnabled:oe==null?void 0:oe.nonThinkingEnabled,thinkingQueryParams:oe==null?void 0:oe.thinkingQueryParams,nonThinkingQueryParams:oe==null?void 0:oe.nonThinkingQueryParams}})}),tt=await Be.json();Be.ok?X(Ot=>({...Ot,[Je]:{loading:!1,result:JSON.stringify(tt,null,2),message:tt.message}})):X(Ot=>({...Ot,[Je]:{loading:!1,error:tt.error??"Test failed"}}))}catch(oe){X(Be=>({...Be,[Je]:{loading:!1,error:oe instanceof Error?oe.message:"Request failed"}}))}}function Cn(){W([]),O({}),z({loading:!1,progress:{}}),X({}),F(null),te(new Set),re(""),De(""),pe(null)}function dn(){ae&&!We.current&&xe(`/api/providers/${ae}`,{method:"DELETE"}).catch(Ce=>{console.warn("Failed to clean up draft provider",Ce)}),t()}function rr(){const Ce=d||"Provider",nt=(a==null?void 0:a.id)??ae??`temp-${Date.now()}`;n({id:nt,name:Ce,url:p,backend:g||"unknown",apiKey:w||void 0,isLocal:v,thinkingField:q||void 0,sendReasoningInMessages:J,authAdapter:_,transportAdapter:k,models:M.map(Je=>{var oe,Be,tt,Ot,rn,Te,Ae,$e,Qe,rt,mt,St,Rn,xn,kn,no;return{id:Je.id,name:Je.name,apiModelId:Je.apiModelId,requestBody:Je.requestBody,reasoningEfforts:Je.reasoningEfforts,contextWindow:((oe=I[Je.id])==null?void 0:oe.contextWindow)??Je.contextWindow,selected:P.has(Je.id)||void 0,supportsVision:(Be=I[Je.id])==null?void 0:Be.supportsVision,thinkingEnabled:(tt=I[Je.id])==null?void 0:tt.thinkingEnabled,thinkingLevel:(Ot=I[Je.id])==null?void 0:Ot.thinkingLevel,nonThinkingEnabled:(rn=I[Je.id])==null?void 0:rn.nonThinkingEnabled,thinkingQueryParams:(Te=I[Je.id])==null?void 0:Te.thinkingQueryParams,nonThinkingQueryParams:(Ae=I[Je.id])==null?void 0:Ae.nonThinkingQueryParams,temperature:($e=I[Je.id])==null?void 0:$e.temperature,topP:(Qe=I[Je.id])==null?void 0:Qe.topP,topK:(rt=I[Je.id])==null?void 0:rt.topK,maxTokens:(mt=I[Je.id])==null?void 0:mt.maxTokens,defaultMaxTokens:(St=I[Je.id])==null?void 0:St.defaultMaxTokens,defaultTemperature:(Rn=I[Je.id])==null?void 0:Rn.defaultTemperature,defaultTopP:(xn=I[Je.id])==null?void 0:xn.defaultTopP,defaultTopK:(kn=I[Je.id])==null?void 0:kn.defaultTopK,compactionThreshold:(no=I[Je.id])==null?void 0:no.compactionThreshold}})}),We.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(ht,{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:dn,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(Ce=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Ce<c?"bg-accent-success":Ce===c?"bg-accent-primary":"bg-border"}`},Ce))}),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:[Se.map(Ce=>s.jsx("button",{type:"button",onClick:()=>{h(Ce.defaults.name??Ce.name),m(Ce.defaults.url),x(Ce.defaults.backend),S(!1),C(""),b(Ce.authAdapter),E(Ce.transportAdapter),R(null),Cn()},className:`p-2 rounded border text-center text-sm transition-colors ${k&&k===Ce.transportAdapter?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:Ce.name},Ce.id)),s.jsx("button",{type:"button",onClick:()=>{x("unknown"),S(!1),b(void 0),E(void 0),R(null),Cn()},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"),wG.map(Ce=>{const nt={8e3:"vllm",11434:"ollama",8080:"llamacpp",1234:"lmstudio"},Je={8e3:"vLLM",11434:"Ollama",8080:"llama.cpp",1234:"LM Studio"};return s.jsx("button",{type:"button",onClick:()=>{h(oe=>oe||(Je[Ce]??"")),m(oe=>oe||`http://localhost:${Ce}`),x(nt[Ce]??""),S(!0),b(void 0),E(void 0),R(null),Cn()},className:`p-2 rounded border text-center text-sm transition-colors ${g===nt[Ce]?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:Je[Ce]??`localhost:${Ce}`},Ce)})]})]}),!_&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider URL"}),s.jsx("input",{ref:Ve,type:"text",value:p,"data-testid":"provider-modal-url",onChange:Ce=>{m(Ce.target.value),R(null),W([]),O({})},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:Ce=>h(Ce.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:Ce=>C(Ce.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:Ce=>S(Ce.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:()=>H(!0),className:"p-1.5 text-text-muted hover:text-text-primary rounded transition-colors",title:"Provider-level defaults",children:s.jsx(Gj,{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."})]}),_e==="connected"?s.jsx("span",{className:"text-sm font-medium text-accent-success",children:"Connected ✓"}):s.jsx("button",{type:"button",onClick:()=>void Dt(),disabled:He||_e==="pending",className:"rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary disabled:opacity-50",children:He||_e==="pending"?"Connecting...":_e==="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 Ct(),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 Ct(),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:Sn,className:"flex-1 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:de?"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:Sn,className:"w-full rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:de?"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: ",p]}),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("button",{onClick:()=>wn(p),className:"text-xs text-accent-primary hover:underline",children:"Retry"}),s.jsx("button",{onClick:()=>{Cn(),u(1)},className:"text-xs text-accent-primary hover:underline",children:"Edit URL"}),!_&&s.jsx("button",{onClick:()=>{var Ce;return(Ce=et.current)==null?void 0:Ce.focus()},className:"text-xs text-accent-primary hover:underline",children:"Add model manually"})]})]}),g&&(!_||_e==="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:et,type:"text",value:ue,onChange:Ce=>{De(Ce.target.value),qe&&pe(null)},onKeyDown:Ce=>{Ce.key==="Enter"&&(Ce.preventDefault(),Fe())},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:Fe,"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"})]}),qe&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:qe})]}),M.length>0&&g&&(!_||_e==="connected")&&s.jsxs(s.Fragment,{children:[P.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 (",P.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(Ce=>P.has(Ce.id)).map(Ce=>{var nt;return s.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[s.jsxs("div",{onClick:()=>G($===Ce.id?null:Ce.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:Ce.name??Ce.id.split("/").pop()}),s.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[(((nt=I[Ce.id])==null?void 0:nt.contextWindow)??Ce.contextWindow).toLocaleString()," ctx"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[V.progress[Ce.id]==="probing"?s.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}):V.progress[Ce.id]==="done"?s.jsx("span",{className:"text-xs text-accent-success font-medium",children:"Configured ✓"}):V.progress[Ce.id]==="error"?s.jsx("span",{className:"text-xs text-red-500 font-medium",children:"Failed ✗"}):_?null:s.jsx("button",{onClick:Je=>{Je.stopPropagation(),fn(Ce.id)},className:"text-xs text-accent-primary hover:underline",children:"Auto-config"}),M.length>1&&s.jsx("button",{onClick:Je=>{Je.stopPropagation();const oe=new Set(P);oe.delete(Ce.id),te(oe),$===Ce.id&&G(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 ${$===Ce.id?"rotate-180":""}`})]})]}),$===Ce.id&&s.jsx(CG,{model:Ce,modelConfigs:I,autoConfigState:V,testResults:Y,onUpdateConfig:it,onRunAutoConfig:fn,onTestParams:Dn,onShowRaw:F})]},Ce.id)})})]}),M.length>1&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Available Models"}),P.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:se,onChange:Ce=>re(Ce.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"}),se&&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 ",fe(se).length," of ",M.length," models"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>{const Ce=new Set(P),nt=fe(se);for(const Je of nt)Ce.add(Je.id);if(te(Ce),O(Je=>{const oe={...Je};for(const Be of nt)oe[Be.id]={contextWindow:Be.contextWindow,...oe[Be.id]};return oe}),!_)for(const Je of nt)V.progress[Je.id]!=="probing"&&V.progress[Je.id]!=="done"&&fn(Je.id)},className:"text-xs text-accent-primary hover:underline",children:"Select all"}),s.jsx("button",{onClick:()=>{const Ce=new Set(P),nt=fe(se);for(const Je of nt)Ce.delete(Je.id);te(Ce)},className:"text-xs text-text-muted hover:text-text-secondary",children:"Deselect all"})]})]}),s.jsxs(ht,{className:"space-y-1 max-h-48 border border-border rounded-lg bg-bg-primary",children:[fe(se).map(Ce=>{var Je;const nt=P.has(Ce.id);return s.jsxs("div",{role:"checkbox","aria-checked":nt,tabIndex:0,className:`flex items-center gap-3 px-4 py-2 hover:bg-bg-tertiary transition-colors cursor-pointer ${nt?"bg-accent-primary/5":""}`,onClick:()=>{if(nt){const oe=new Set(P);oe.delete(Ce.id),te(oe)}else ge(Ce),_||fn(Ce.id)},onKeyDown:oe=>{(oe.key==="Enter"||oe.key===" ")&&(oe.preventDefault(),oe.currentTarget.click())},children:[s.jsx("input",{type:"checkbox",checked:nt,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:Ce.name??Ce.id.split("/").pop()}),s.jsxs("span",{className:"text-xs text-text-muted flex-shrink-0",children:[(((Je=I[Ce.id])==null?void 0:Je.contextWindow)??Ce.contextWindow).toLocaleString()," ctx"]}),V.progress[Ce.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"}),V.progress[Ce.id]==="done"&&s.jsx("span",{className:"text-xs text-accent-success flex-shrink-0",children:"✓"}),V.progress[Ce.id]==="error"&&s.jsx("span",{className:"text-xs text-red-500 flex-shrink-0",children:"✗"})]},Ce.id)}),fe(se).length===0&&s.jsxs("div",{className:"px-4 py-6 text-center text-sm text-text-muted",children:["No models match “",se,"”"]})]})]})]})]}),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&&Cn(),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:dn,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:!p,"data-testid":"provider-modal-next",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:"Next — Test & Configure"}):s.jsx("button",{onClick:rr,disabled:V.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:V.loading?"Configuring...":"Save Provider"})]})]})]}),B&&s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:Ce=>{Ce.target===Ce.currentTarget&&H(!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:()=>H(!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:q,onChange:Ce=>Q(Ce.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:Ce=>U(Ce.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:()=>H(!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"})})]})}),Z&&s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:Ce=>{Ce.target===Ce.currentTarget&&F(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:()=>F(null),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsx(ht,{horizontal:!0,children:s.jsx("pre",{className:"px-6 py-4 text-xs text-text-secondary font-mono whitespace-pre-wrap break-all",children:Z})})]})})]}):null}function Ek({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 jG(){var Je;const[,e]=Pn(),t=Re(oe=>oe.currentSession),n=Re(oe=>oe.setSessionProvider),[r,a]=j.useState(!1),[o,c]=j.useState([]),[u,d]=j.useState(null),h=j.useRef(null),[p,m]=j.useState(null),[g,x]=j.useState(!1),[w,C]=j.useState({}),[v,S]=j.useState(null),[_,b]=j.useState(null),[k,E]=j.useState(!1),T=j.useRef(null),[D,A]=j.useState(!1),R=j.useRef(new Set),M=en(oe=>oe.providers),W=en(oe=>oe.activeProviderId),$=en(oe=>oe.defaultModelSelection),G=en(oe=>oe.activating),B=en(oe=>oe.activateProvider),H=en(oe=>oe.refreshModel),q=en(oe=>oe.refreshProviderModels),Q=en(oe=>oe.setDefaultModel),J=en(oe=>oe.fetchConfig),U=pu();ru(U.modelSelector,()=>a(oe=>!oe));const I=(t==null?void 0:t.providerId)??null,O=(t==null?void 0:t.providerModel)??null,V=($==null?void 0:$.split("/")[0])??null,z=($==null?void 0:$.split("/").slice(1).join("/"))??null,Y=ct(oe=>oe.defaults),X=ct(oe=>oe.userItems),Z=ct(oe=>oe.modelOverrides),F=t==null?void 0:t.mode,P=F?Y.find(oe=>oe.id===F)??X.find(oe=>oe.id===F):void 0,te=F?Z[F]??void 0:void 0,se=te?te.split("/")[0]??null:null,re=te?te.split("/").slice(1).join("/")??null:null,ae=F?Qa([...Y,...X],F):void 0,ye=!!te,_e=se??I??V,Ie=re??O??z,He=Ie?((Je=Ie.split("/").pop())==null?void 0:Je.replace(/-/g," "))??Ie:"No model",[je,Ge]=j.useState(!1);j.useEffect(()=>{function oe(Be){h.current&&!h.current.contains(Be.target)&&(a(!1),c([]),R.current=new Set)}return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[]),j.useEffect(()=>()=>{T.current!==null&&window.clearTimeout(T.current)},[]),j.useEffect(()=>{r||(Ct(""),wn(-1))},[r]),j.useEffect(()=>{var oe;r&&Ft()&&((oe=rr.current)==null||oe.focus())},[r]),j.useEffect(()=>{if(r){const oe=M.map(Be=>Be.id);c(oe),M.filter(Be=>!!Be.authAdapter).forEach(Be=>void qe(Be.id)),oe.forEach(Be=>{R.current.has(Be)||(R.current.add(Be),ie(Be))})}},[r,M]),j.useEffect(()=>{if(!_)return;let oe=!1;const Be=async()=>{const Ot=await qe(_.providerId);oe||Ot==="connected"&&(b(null),E(!1),A(!1),await J(),R.current.delete(_.providerId),await ie(_.providerId))};Be();const tt=window.setInterval(()=>void Be(),2e3);return()=>{oe=!0,window.clearInterval(tt)}},[_]);const Ze=M.find(oe=>oe.id===_e),Se=(Ze==null?void 0:Ze.status)==="disconnected",be=(oe,Be)=>t?t.providerId===oe&&t.providerModel===Be:!1,de=(oe,Be)=>$?$===`${oe}/${Be}`:!1,ie=async oe=>{d(oe);try{await q(oe)}catch{}finally{d(null)}},Pe=oe=>{o.includes(oe.id)?c(o.filter(Be=>Be!==oe.id)):(c([...o,oe.id]),ie(oe.id))},Ue=async oe=>{if(oe.id===W){Pe(oe);return}t?(n(oe.id,void 0),a(!1),c([])):await B(oe.id)&&(a(!1),c([]))},ue=oe=>{Pe(oe)},De=async(oe,Be)=>{oe.stopPropagation(),R.current.delete(Be),await ie(Be)},qe=async oe=>{const Be=await xe(`/api/provider-auth/${oe}/status`);if(!Be.ok)return"error";const tt=await Be.json();return C(Ot=>({...Ot,[oe]:tt.state})),tt.state},pe=async(oe,Be)=>{oe.stopPropagation(),S(Be),C(tt=>({...tt,[Be]:"pending"})),E(!1),A(!1);try{const tt=await xe(`/api/provider-auth/${Be}/login`,{method:"POST"});if(!tt.ok)throw new Error("Unable to start provider sign-in");const Ot=await tt.json();b({providerId:Be,...Ot})}catch{C(tt=>({...tt,[Be]:"error"}))}finally{S(null)}},he=async()=>{var oe;_!=null&&_.userCode&&(await((oe=navigator.clipboard)==null?void 0:oe.writeText(_.userCode)),T.current!==null&&window.clearTimeout(T.current),E(!1),requestAnimationFrame(()=>E(!0)),T.current=window.setTimeout(()=>{E(!1),T.current=null},1500))},We=()=>{_&&(window.open(_.directUrl??_.verificationUrl,"_blank","noopener,noreferrer"),A(!0))},Ve=()=>{b(null),E(!1),A(!1)},et=async(oe,Be)=>{oe.stopPropagation(),S(Be);try{if(!(await xe(`/api/provider-auth/${Be}/logout`,{method:"POST"})).ok)throw new Error("Unable to disconnect provider account");C(Ot=>({...Ot,[Be]:"disconnected"})),await J()}finally{S(null)}},it=(oe,Be)=>{m({providerId:oe,model:Be}),x(!0)},ge=p?M.find(oe=>oe.id===p.providerId):void 0,fe=()=>{m(null),x(!1)},Fe=async oe=>{try{if(!(await xe(`/api/providers/${oe.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(tA(oe))})).ok)throw new Error("Failed to update provider");await en.getState().fetchConfig()}catch{}m(null),x(!1)},Xe=async(oe,Be)=>{if(F&&te&&te!==`${oe}/${Be}`&&(xe(`/api/agents/${F}/model`,{method:"DELETE"}).catch(()=>{}),ct.setState(Ot=>{const rn={...Ot.modelOverrides};return delete rn[F],{modelOverrides:rn}})),t){Re.setState(Ot=>({currentSession:Ot.currentSession?{...Ot.currentSession,providerId:oe,providerModel:Be}:null})),n(oe,Be),c([]),a(!1),hu();return}await B(oe)&&(c([]),a(!1),hu())},_t=async(oe,Be,tt)=>{oe.stopPropagation(),Ge(!0);try{await Q(Be,tt)}catch{}finally{Ge(!1)}},{searchQuery:Dt,setSearchQuery:Ct,highlightedIndex:Sn,setHighlightedIndex:wn,visibleGroups:fn,flatItems:Dn,handleSearchKeyDown:Cn,highlightedRef:dn,inputRef:rr}=sT({providers:M,onSelect:Xe,onEscape:()=>a(!1),extraItemCount:1}),Ce=Sn===Dn.length,nt=oe=>{if(oe.key==="Enter"&&Sn===Dn.length){oe.preventDefault(),e("/onboarding"),a(!1);return}Cn(oe)};return M.length===0?s.jsxs("button",{type:"button",onClick:()=>H(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:Se?"LLM server is offline. Click to retry.":He??"Click to refresh model",children:[Se?s.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):s.jsx(Ek,{activeProvider:Ze,shortModelName:He,agentOverrideActive:ye,agentColor:ae,agentName:P==null?void 0:P.name}),s.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):s.jsxs("div",{className:"relative",ref:h,children:[s.jsxs("button",{type:"button",onClick:()=>a(!r),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:"Click to switch provider or model",children:[Se?s.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):s.jsx(Ek,{activeProvider:Ze,shortModelName:He,agentOverrideActive:ye,agentColor:ae,agentName:P==null?void 0:P.name}),s.jsx(gn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:r?180:0})]}),r&&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(hi,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("input",{ref:rr,type:"text",value:Dt,onInput:oe=>{Ct(oe.currentTarget.value),wn(-1)},onKeyDown:nt,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),s.jsx(ht,{className:"flex-1 min-h-0",children:s.jsxs("div",{children:[fn.map(oe=>{const Be=Dt.trim().length>0||o.includes(oe.provider.id);return s.jsxs("div",{children:[s.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${oe.provider.id===_e?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${G?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[s.jsxs("div",{onClick:()=>!G&&Ue(oe.provider),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[s.jsx("span",{className:`text-sm font-medium truncate ${oe.provider.id===_e?"text-accent-primary":"text-text-primary"}`,children:oe.provider.name}),s.jsx("span",{className:"text-xs text-text-muted truncate",children:oe.provider.backend!=="unknown"&&Rj(oe.provider.backend)})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!!oe.provider.authAdapter&&(w[oe.provider.id]==="connected"||oe.provider.credentialRef?s.jsx("button",{type:"button",onClick:tt=>et(tt,oe.provider.id),disabled:v===oe.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:tt=>pe(tt,oe.provider.id),disabled:v===oe.provider.id,className:"text-[10px] px-1.5 py-0.5 rounded border border-accent-primary/40 text-accent-primary hover:bg-accent-primary/10 disabled:opacity-50",title:"Connect provider account",children:v===oe.provider.id?"Starting…":w[oe.provider.id]==="error"||w[oe.provider.id]==="expired"?"Retry":"Connect"})),oe.provider.id===_e?s.jsx("span",{className:"text-accent-success",title:"Active provider",children:s.jsx(Rs,{className:"w-4 h-4"})}):s.jsx("span",{className:"w-4"}),s.jsx("button",{type:"button",onClick:tt=>{tt.stopPropagation(),De(tt,oe.provider.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:s.jsx(Ef,{className:`w-4 h-4 ${u===oe.provider.id?"animate-spin":""} ${oe.provider.id===W?"text-accent-primary":"text-text-muted"}`})}),s.jsx("button",{type:"button",onClick:tt=>{tt.stopPropagation(),ue(oe.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 ${Be?"rotate-180":""} ${oe.provider.id===W?"text-accent-primary":"text-text-muted"}`})})]})]}),Be&&s.jsx(ht,{className:"bg-bg-primary border-t border-border max-h-40",children:u===oe.provider.id?s.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):oe.models.length>0?oe.models.map(tt=>{const rn=Dn.findIndex(Te=>Te.providerId===oe.provider.id&&Te.modelConfig.id===tt.id)===Sn;return s.jsx("div",{ref:rn?dn:void 0,children:s.jsx(rT,{providerId:oe.provider.id,modelConfig:tt,isActive:be(oe.provider.id,tt.id),isDefault:de(oe.provider.id,tt.id),disabled:u==="activating",hasSession:!!t,settingDefault:je,highlighted:rn,onModelClick:Xe,onSetDefault:_t,onEditModel:it})},`${oe.provider.id}/${tt.id}`)}):s.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},oe.provider.id)}),fn.length===0&&Dt.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 ${Ce?"bg-bg-tertiary":""} flex-shrink-0`,children:s.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),_&&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:oe=>{oe.target===oe.currentTarget&&Ve()},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:Ve,className:"rounded px-2 py-1 text-xl leading-none text-text-muted hover:bg-bg-tertiary hover:text-text-primary","aria-label":"Close",children:"×"})]}),_.mode!=="browser"?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:he,className:"mt-6 w-full select-all rounded-lg border border-accent-primary/40 bg-bg-primary px-4 py-5 font-mono text-3xl font-semibold tracking-[0.2em] text-accent-primary hover:bg-bg-tertiary",title:"Copy code",children:_.userCode??"Continue"}),s.jsx("div",{className:"mt-3 text-center text-xs text-text-muted",children:k?"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:he,className:"flex-1 rounded-lg border border-border px-4 py-2 text-sm text-text-primary hover:bg-bg-tertiary",children:k?"Copied":"Copy code"}),s.jsx("button",{type:"button",onClick:We,className:"flex-1 rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:D?"Reopen authorization":"Open authorization"})]}),s.jsx("p",{className:"mt-4 text-center text-xs text-text-muted",children:D?"If the browser blocked or closed the tab, reopen authorization.":"OpenFox stays open while you complete authorization in the other tab."})]}):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:_.instructions}),s.jsx("div",{className:"mt-6 flex gap-3",children:s.jsx("button",{type:"button",onClick:We,className:"w-full rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:D?"Reopen authorization":"Open authorization"})})]})]})}),p&&g&&s.jsx(nA,{isOpen:!0,onClose:fe,onSave:Fe,initialStep:2,editProvider:{id:p.providerId,name:(ge==null?void 0:ge.name)??"",url:(ge==null?void 0:ge.url)??"",backend:(ge==null?void 0:ge.backend)??"unknown",apiKey:ge==null?void 0:ge.apiKey,isLocal:ge==null?void 0:ge.isLocal,thinkingField:ge==null?void 0:ge.thinkingField,sendReasoningInMessages:ge==null?void 0:ge.sendReasoningInMessages,authAdapter:ge==null?void 0:ge.authAdapter,transportAdapter:ge==null?void 0:ge.transportAdapter,models:ge==null?void 0:ge.models},editModelId:p.model.id})]})}function EG(){const e=tu(k=>k.servers),t=tu(k=>k.fetchServers),n=Re(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),[p,m]=j.useState(new Set),g=j.useRef(null),x=j.useCallback(async()=>{if(r)try{const k=await xe(`/api/sessions/${r}/mcp/overrides`);if(k.ok){const E=await k.json();m(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]),em(g,()=>o(!1));const C=k=>p.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(p);E?T.add(k):T.delete(k);const D=await xe(`/api/sessions/${r}/mcp/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabledServers:Array.from(T)})});if(!D.ok){const A=await D.json().catch(()=>({}));throw new Error(A.error??"Toggle failed")}m(T),await t()}catch(T){u(T instanceof Error?T.message:String(T))}finally{h(T=>{const D=new Set(T);return D.delete(k),D})}}};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 (${Qh(_)})`:"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(ht,{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 ${zb(E?"disabled":k.status)}`,children:Hb(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:[Qh(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(ds,{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"]})})]})]})}function NG({input:e,setInput:t,attachments:n,setAttachments:r,dragOver:a,setDragOver:o,errorMessage:c,setErrorMessage:u,scrollToBottom:d,sessionId:h,showHistory:p,history:m,selectedIndex:g,openHistory:x,closeHistory:w,navigateUp:C,navigateDown:v,selectCurrent:S,isAutoScrollActive:_,setAutoScroll:b,onOpenMessageSearch:k,onOpenCommandsModal:E,onOpenWorkflowsModal:T,onSelectWorkflow:D,onSelectWorkflowWithSubGroup:A,onSendCommand:R,clearInput:M}){const W=j.useRef(null),$=j.useRef(null),G=j.useRef(0),B=j.useRef(0),H=j.useRef(null),q=j.useRef(null),Q=wf(),J=Re(pe=>pe.stopGeneration),U=Re(pe=>pe.cancelQueued),I=Re(pe=>pe.queuedMessages),O=Re(pe=>pe.restoredInput),V=Re(pe=>pe.clearRestoredInput),z=Re(pe=>{var he;return(he=pe.currentSession)==null?void 0:he.workdir}),Y=Re(pe=>pe.currentSession),X=j.useRef(!1),Z=j.useRef(void 0),F=j.useRef(!1),[P,te]=j.useState([]),se=j.useRef(null),{sendMessage:re,launchWorkflow:ae}=ZT(b);j.useEffect(()=>{Z.current!==z&&(Z.current=z,Ht.getState().fetchWorkflows(z),ln.getState().fetchCommands(z))},[z]),j.useEffect(()=>{e||te([])},[e]),j.useEffect(()=>{var pe;O!==null&&(t(O),V(),Ft()&&((pe=W.current)==null||pe.focus()))},[O,t,V]);const ye=j.useCallback(()=>{const pe=W.current;if(!pe)return;const he=e.length>=G.current;G.current=e.length,he||(pe.style.height="auto"),pe.style.height=`${Math.min(200,pe.scrollHeight)}px`},[e]);j.useEffect(()=>{if(!h)return;const pe=`openfox:draft:${h}`,he=localStorage.getItem(pe);he!==null&&t(he)},[h,t]),j.useEffect(()=>{var pe;Ft()&&((pe=W.current)==null||pe.focus()),ye()},[h,ye]),j.useEffect(()=>{if(!h)return;const pe=`openfox:draft:${h}`,he=setTimeout(()=>{e?localStorage.setItem(pe,e):localStorage.removeItem(pe)},500);return()=>clearTimeout(he)},[h,e]),j.useEffect(()=>{ye()},[e,ye]),j.useEffect(()=>{const pe=W.current;if(!pe)return;const he=async We=>{var it;if(document.activeElement!==pe)return;const Ve=(it=We.clipboardData)==null?void 0:it.items;if(!Ve)return;const et=[];for(const ge of Array.from(Ve)){let fe=ge.getAsFile();if(fe&&T7(fe.type)){if(We.preventDefault(),!fe.name){const Fe=N7(fe.type);fe=new File([fe],`pasted-file.${Fe}`,{type:fe.type})}await Sy(fe,Fe=>et.push(Fe),u)}}et.length>0&&r(ge=>[...ge,...et])};return pe.addEventListener("paste",he),()=>pe.removeEventListener("paste",he)},[r,u]);const _e=pe=>{pe.preventDefault(),!(!e.trim()&&n.length===0)&&ie()},Ie=pe=>{var he,We;if(!((he=q.current)!=null&&he.handleKeyDown(pe))&&!((We=H.current)!=null&&We.handleKeyDown(pe))){if(p)switch(pe.key){case"Enter":{pe.preventDefault();const Ve=S();Ve&&(t(Ve),w());return}case"Escape":pe.preventDefault(),w(),Q&&J();return;case"ArrowUp":pe.preventDefault(),C();return;case"ArrowDown":pe.preventDefault(),v();return}if(pe.key==="ArrowUp"&&e.trim()===""&&!p){pe.preventDefault(),x();return}pe.key==="Enter"&&!pe.shiftKey&&(pe.preventDefault(),_e(pe))}};async function He(pe,he,We){const Ve=[];for(const et of Array.from(pe))await Sy(et,it=>Ve.push(it),We);Ve.length>0&&he(et=>[...et,...Ve])}const je=j.useCallback(async pe=>{const he=pe.target.files;!he||he.length===0||(u(null),await He(he,r,u),$.current&&($.current.value=""))},[r,u]),Ge=j.useCallback(pe=>{var he;(he=pe.dataTransfer.types)!=null&&he.includes("Files")&&(pe.preventDefault(),pe.stopPropagation(),o(!0))},[o]),Ze=j.useCallback(pe=>{pe.preventDefault(),pe.stopPropagation(),o(!1)},[o]),Se=j.useCallback(async pe=>{pe.preventDefault(),pe.stopPropagation(),o(!1),u(null);const he=pe.dataTransfer.files;!he||he.length===0||await He(he,r,u)},[r,o,u]),be=j.useCallback(pe=>{r(n.filter(he=>he.id!==pe))},[n,r]),de=j.useCallback(()=>{var pe;(pe=$.current)==null||pe.click()},[]),ie=()=>{if(F.current||!e.trim()&&n.length===0)return;if(F.current=!0,d==null||d(),e.trim().startsWith("/")){const he=Za(Ht.getState()),We=ln.getState(),Ve=Zn(Zn(We.defaults,We.userItems),We.projectItems),et=oG(e,he,Ve);if(et!=null&&et.workflowId){const it=se.current,ge=it&&it.id===et.workflowId?it.scope:"auto";se.current=null;const fe=vy(he,et.workflowId,ge),Fe=((fe==null?void 0:fe.parameters)??[]).filter(Xe=>Xe.required&&!(Xe.id in et.params));if(Fe.length>0){const Xe=Fe.map(_t=>_t.label||_t.id).join(", ");u(`Missing required parameter${Fe.length>1?"s":""}: ${Xe}`),F.current=!1;return}ae(void 0,void 0,et.workflowId,void 0,et.params,ge),M(),F.current=!1;return}if(et!=null&&et.commandId){We.fetchCommand(et.commandId,z).then(it=>{if(it){const ge=QT(it.prompt),fe={};for(const[Xe,_t]of Object.entries(et.params)){const Dt=parseInt(Xe,10),Ct=ge[Dt];Ct&&(fe[Ct]=_t)}let Fe=it.prompt;for(const[Xe,_t]of Object.entries(fe))Fe=Fe.replaceAll(`{{${Xe}}}`,_t);R(Fe,it.metadata.agentMode),M()}F.current=!1});return}}re(e,n),M(),F.current=!1},Pe=j.useCallback((pe,he)=>{const Ve=pe.type==="directory"?"/":" ",{newText:et,newCursorPos:it}=tf(e,B.current,he,`@${pe.path}${Ve}`);t(et),B.current=it,nf(W.current,it)},[e,t]),Ue=j.useCallback((pe,he)=>{const{newText:We,newCursorPos:Ve}=tf(e,B.current,he,`/${pe.id} `);t(We),B.current=Ve,nf(W.current,Ve),pe.type==="workflow"&&(se.current={id:pe.id,scope:pe.scope}),te(lT(pe))},[e,t]),ue=j.useCallback(pe=>{const he=pe.target.value;t(he),p&&w(),B.current=pe.target.selectionStart;const We=se.current;if(We){const Ve=he.match(/^\/(\S+)/),et=Ve?Ve[1]:void 0;(!et||et!==We.id)&&(se.current=null)}P.length>0&&(!he.startsWith("/")||!he.includes(" "))&&te([]),!X.current&&h&&he&&Y&&(Y.messageCount??0)===0&&(X.current=!0,xe(`/api/sessions/${h}/warmup`,{method:"POST"}).catch(()=>{}))},[t,p,w,h,Y,P]),De=j.useCallback(pe=>{B.current=pe.target.selectionStart},[]),qe=j.useCallback(pe=>{B.current=pe.currentTarget.selectionStart},[]);return s.jsxs("div",{className:"relative",children:[Q&&s.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:s.jsx(cG,{})}),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(Xb,{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(hi,{}),"Browse history"]})]}),s.jsx(uG,{}),s.jsxs("form",{onSubmit:_e,className:"p-2 md:p-4 bg-secondary rounded-lg",children:[s.jsx("input",{ref:$,type:"file",accept:"image/*,text/*,.pdf,.json,.xml,.yaml,.yml,.js,.sh,.xhtml",onChange:je,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(pe=>s.jsx(Ub,{attachment:pe,onRemove:be},pe.id))}),p&&s.jsx(lG,{history:m,selectedIndex:g,onSelect:pe=>{t(pe),w()},onEscape:w,onNavigate:pe=>{pe==="up"?C():v()}}),s.jsx(pG,{messages:I,onCancel:U}),s.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${a?"bg-accent-primary/10":"bg-primary"}`,onDragOver:Ge,onDragLeave:Ze,onDrop:Se,children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx("textarea",{id:qN,ref:W,value:e,onChange:ue,onKeyDown:Ie,onSelect:De,onKeyUp:qe,placeholder:"What would you like to build?","data-testid":"chat-input-textarea",className:"w-full bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:"24px",maxHeight:"200px"},spellCheck:!1}),s.jsx(aT,{ref:H,text:e,cursorPos:B.current,workdir:z,onSelect:Pe}),s.jsx(iT,{ref:q,text:e,cursorPos:B.current,workflows:Za(Ht.getState()),commands:(()=>{const pe=ln.getState();return Zn(Zn(pe.defaults,pe.userItems),pe.projectItems)})(),onSelect:Ue}),P.length>0&&(()=>{const pe=e.match(/\/(\w+)\s+(.*)$/),We=(pe?pe[2].trim().split(/\s+/):[]).filter(Boolean).length,Ve=P[We];return Ve?s.jsxs("span",{className:"absolute left-3 top-[26px] text-sm text-text-muted/40 pointer-events-none select-none","aria-hidden":!0,children:[Ve,"=?"]}):null})()]}),s.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[Q&&s.jsxs("button",{type:"button",onClick:()=>J(),"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(Qy,{}),"Abort"]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{type:"button",onClick:ie,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(fG,{onSendCommand:R,onSelectWorkflow:D,onSelectWorkflowWithSubGroup:A,onOpenCommandsManager:E,onOpenWorkflowsManager:T,onAttach:de,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(_G,{}),s.jsx(SG,{})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Rt(pe=>pe.settings)[Ne.FEATURES_PER_SESSION_MCP]==="true"&&s.jsx(EG,{}),s.jsx(jG,{})]})]})]})]})}const TG=4;function AG({projectId:e}){const[,t]=Pn(),n=Pt(w=>w.tasks),r=Pt(w=>w.activeProjectId),a=Pt(w=>w.loadBoard),o=Pt(w=>w.moveTask),c=Pt(w=>w.lastError),[u,d]=j.useState(!1),[h,p]=j.useState(null);j.useEffect(()=>{r!==e&&a(e)},[r,e,a]);const m=j.useMemo(()=>n.filter(w=>w.status==="todo"&&w.sessionIds.length===0).sort((w,C)=>w.position-C.position).slice(0,TG),[n]),g=j.useMemo(()=>n.filter(w=>w.status==="in_progress"&&w.runState==="running").length,[n]);if(m.length===0)return null;const x=async w=>{var v;p(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"&&p({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(Zy,{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:()=>p(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:m.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(Cf,{className:"w-3 h-3"})]})]},w.id))}),c&&s.jsx("div",{className:"mt-3 text-sm text-accent-error",children:c})]}),s.jsx(qb,{isOpen:u,onClose:()=>d(!1),projectId:e})]})}function Nk({workflowName:e,parameters:t,onConfirm:n,onCancel:r,confirmLabel:a="Run workflow"}){const[o,c]=j.useState({}),u=[...t].sort((p,m)=>(p.position??0)-(m.position??0)),d=()=>{var m;const p={};for(const g of u){const x=(m=o[g.id])==null?void 0:m.trim();x&&(p[g.id]=x)}n(p)},h=u.every(p=>{var m;return!p.required||(((m=o[p.id])==null?void 0:m.trim())??"")!==""});return s.jsxs(wt,{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(p=>s.jsxs("label",{className:"block",children:[s.jsxs("span",{className:"text-sm text-text-primary font-medium",children:[p.label||p.id,p.required&&s.jsx("span",{className:"text-accent-error ml-1",children:"*"})]}),p.description&&s.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:p.description}),s.jsx("input",{value:o[p.id]??"",onChange:m=>c(g=>({...g,[p.id]:m.target.value})),placeholder:p.label||p.id,className:"mt-1 w-full px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-accent-primary",autoFocus:(p.position===0||p===u[0])&&Ft()})]},p.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 Tk=9999,ph=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 p=j.useCallback(m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),a?h():(d.current=document.activeElement,o(!0))),m.key==="Escape"&&a&&h()},[a,h]);return j.useEffect(()=>{var w;if(!a){Ft()&&((w=d.current)==null||w.focus()),d.current=null;return}const m=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",m),document.addEventListener("keydown",g),window.addEventListener("blur",x),()=>{document.removeEventListener("mousedown",m),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(m=>!m)},onKeyDown:p,children:t}),a&&mi.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:Tk,top:0,left:0};const m=c.current.getBoundingClientRect(),g=320,x=8;let w=m.left;return w+g>window.innerWidth-x&&(w=m.right-g),w=Math.max(x,Math.min(w,window.innerWidth-g-x)),{zIndex:Tk,top:m.bottom+4,left:w}})(),children:s.jsx(ht,{className:"max-h-full",children:n})}),document.body)]})});function LG({entries:e}){const t=new Map;for(const r of e)t.set(r.status,(t.get(r.status)??0)+1);const n=yT.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(Al,{status:r}),s.jsx("span",{className:"text-text-muted",children:t.get(r)})]},r))})}function DG({visible:e}){const t=Re(P=>P.currentSession),n=Jn(P=>P.status),r=Jn(P=>P.config),a=Jn(P=>P.start),o=Re(P=>P.contextState),c=Re(P=>P.queueUpdate),u=Jn(P=>P.logs),{branch:d,diff:h}=Kb(),[p,m]=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),D=j.useRef(null),A=j.useRef(null),R=j.useRef(null),M=Rt(P=>P.settings[Ne.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true";if(!e||!t)return null;const W=xu(t.workspace??"")||"original",$=t.workspace??t.workdir,G=t.metadataEntries??{},B=G.criteria??[],H=["review_findings","todos"],q=H.filter(P=>{var te;return P in G&&(((te=G[P])==null?void 0:te.length)??0)>0}),Q=Object.keys(G).filter(P=>P!=="criteria"&&!H.includes(P)).filter(P=>{var te;return(((te=G[P])==null?void 0:te.length)??0)>0}),J=[...q,...Q].reduce((P,te)=>{var se;return P+(((se=G[te])==null?void 0:se.length)??0)},0),U=[...q,...Q].map(ul),I=h.files,O=I.reduce((P,te)=>P+te.additions,0),V=I.reduce((P,te)=>P+te.deletions,0),z=(n==null?void 0:n.state)??"off",Y=z==="running"||z==="warning",X=r!==null,Z=P=>{P.stopPropagation(),a()},F=P=>{P.stopPropagation(),n!=null&&n.url&&window.open(n.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(Qr,{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:W}),s.jsx("span",{className:"text-text-muted",children:"/"}),s.jsx(Ga,{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??"-"}),I.length>0?s.jsxs("span",{className:"text-text-muted shrink-0 font-mono",children:["+",O," -",V]}):s.jsx("span",{className:"shrink-0"}),s.jsx(ph,{ref:R,trigger:s.jsx(gn,{className:"w-3 h-3"}),children:s.jsx(OT,{workspaceName:W,branch:d,workdir:$,showEditorLink:M,sessionId:t.id,projectId:t.projectId,onEditWorkspace:()=>{var P;(P=R.current)==null||P.close(),b(!0)},onEditBranch:()=>{var P;(P=R.current)==null||P.close(),E(!0)}})})]}),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(LG,{entries:B}),J>0&&s.jsxs("span",{className:"text-text-muted text-xs bg-bg-tertiary px-1 py-0.5 rounded leading-none",title:U.join(", "),children:["+",J]}),s.jsx(ph,{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 P;(P=A.current)==null||P.close(),S("criteria")},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(sf,{entries:B,title:"Acceptance Criteria"})}),s.jsx(_T,{entries:B,sessionId:t.id})]}),[...q,...Q].map(P=>{const te=G[P];return s.jsxs("div",{children:[s.jsx("button",{onClick:()=>{var se;(se=A.current)==null||se.close(),S(P)},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(sf,{entries:te,title:ul(P)})}),s.jsx(bT,{entries:te})]},P)})]})})]}),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:o&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted text-xs font-mono tabular-nums",children:o.currentTokens>=1e3?`${Math.round(o.currentTokens/1e3)}K`:o.currentTokens}),s.jsx(Qb,{percent:Math.round(o.currentTokens/o.maxTokens*100),dangerZone:o.dangerZone,size:"sm"}),s.jsx(ph,{ref:D,trigger:s.jsx(gn,{className:"w-3 h-3"}),children:s.jsx(MT,{onUpdateSystemPrompt:()=>{var P;(P=D.current)==null||P.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 ${z==="running"?"bg-accent-success":z==="warning"?"bg-accent-warning":z==="error"?"bg-accent-error":"bg-text-muted"}`}),X?Y?s.jsx("button",{onClick:F,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(Jy,{className:"w-3.5 h-3.5"})}):s.jsx("button",{onClick:Z,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(jf,{className:"w-3.5 h-3.5"})}):s.jsx("span",{className:"text-text-muted text-xs",children:"No config"}),s.jsx(ph,{ref:T,trigger:s.jsx(gn,{className:"w-3 h-3"}),children:s.jsx(kT,{workdir:$,compact:!0,onExpand:()=>m(!0),onConfigure:()=>{var P;(P=T.current)==null||P.close(),x(!0)}})})]})]}),p&&s.jsx(Jb,{title:"Dev Server Logs",logs:u,onClose:()=>m(!1)}),g&&s.jsx(ST,{isOpen:!0,onClose:()=>x(!1)}),v&&t&&s.jsx(vT,{isOpen:!0,onClose:()=>S(null),entries:G[v]??[],sessionId:t.id,metadataKey:v,title:ul(v)}),_&&s.jsx(DT,{isOpen:!0,onClose:()=>b(!1),projectId:t.projectId,sessionId:t.id,currentWorkspace:W,currentBranch:d}),k&&s.jsx(RT,{isOpen:!0,onClose:()=>E(!1),sessionId:t.id}),w&&o&&s.jsx(Zb,{isOpen:!0,onClose:()=>C(!1),isRunning:t.isRunning,onApply:()=>{t.isRunning?c():zt.send("context.applyDynamic",{}),C(!1)}})]})}function RG(e){return(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="f"&&document.querySelector("[data-global-settings]")===null}function rA(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 p=0;for(const g of e)g.role!=="tool"&&g.contextWindowId===o&&(g.subAgentId&&!h.has(g.subAgentId)&&h.set(g.subAgentId,p),p++);const m=[...u.entries()].sort((g,x)=>(h.get(g[0])??0)-(h.get(x[0])??0));for(const[g,x]of m){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 p=e[h];if(p.role!=="tool")if(p.contextWindowId&&o&&p.contextWindowId!==o&&(d(),c++,a.push({type:"context-divider",windowSequence:c})),o=p.contextWindowId,p.subAgentId&&p.subAgentType){u||(u=new Map);let m=u.get(p.subAgentId);m||(m={subAgentType:p.subAgentType,messages:[]},u.set(p.subAgentId,m)),m.messages.push(p)}else{d();const m=n.get(p.id);(m==null?void 0:m.type)==="message"&&m.message===p?a.push(m):a.push({type:"message",message:p})}}return d(),a}const OG=10,IG=150;function MG(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 PG(e){return[...e].sort((r,a)=>new Date(a.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,OG).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:x7(r.timestamp),trimmedContent:Zh(r.content,IG),sessionId:r.sessionId,sessionName:r.sessionName}))}function BG(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(...MG(o));return PG(r)}function $G(e,t=[],n=null){const[r,a]=j.useState(0),[o,c]=j.useState(!1),u=j.useMemo(()=>BG(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)},[]),p=j.useCallback(()=>{a(x=>u.length===0?x:x===0?u.length-1:x-1)},[u.length]),m=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:p,navigateDown:m,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(Qn,{content:t.description})})]})]})});function zG({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t,rawMessages:n,hiddenCount:r}={}){const a=e??!0,[o,c]=j.useState(""),[u,d]=j.useState([]),[h,p]=j.useState(!1),[m,g]=j.useState(null),[x,w]=j.useState(!1),[C,v]=j.useState(!1),[S,_]=j.useState(!1),[b,k]=j.useState(!1),[E,T]=j.useState(null),D=j.useRef(null),A=ju(D),R=Re(he=>he.currentSession),M=Re(he=>he.messages),W=Re(he=>he.hiddenCount),$=Re(he=>he.sessions),G=wf(),B=Re(he=>he.stopGeneration),H=n??M,{maxVisibleItems:q}=Ds(),Q=ct(he=>he.defaults),J=ct(he=>he.userItems),U=[...Q,...J].filter(he=>!he.subagent),{history:I,selectedIndex:O,showHistory:V,openHistory:z,closeHistory:Y,navigateUp:X,navigateDown:Z,selectCurrent:F}=$G(H,$,R==null?void 0:R.id);j.useEffect(()=>{const he=We=>{T(We.detail.stats)};return window.addEventListener("open-turn-stats",he),()=>window.removeEventListener("open-turn-stats",he)},[]);const P=R==null?void 0:R.workdir;j.useEffect(()=>{Ht.getState().setWorkdir(P),P&&Ht.getState().fetchWorkflows()},[P]),j.useEffect(()=>{Ht.getState().fetchWorkflows()},[]),j.useEffect(()=>{const he=We=>{RG(We)&&(We.preventDefault(),k(!0))};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[]);const te=j.useRef([]),{displayItems:se,hiddenCount:re}=j.useMemo(()=>{const he=rA(H,te.current);return te.current=he,q>0&&he.length>q?{displayItems:he.slice(-q),hiddenCount:he.length-q}:{displayItems:he,hiddenCount:0}},[H,q]),ae=r??W??re,{isAutoScrollActive:ye,setAutoScroll:_e,handleScrollbarGesture:Ie}=ku(D,R,A),{sendMessage:He,launchWorkflow:je}=ZT(_e);j.useEffect(()=>{const he=()=>_e(!0);return window.addEventListener(cf,he),()=>window.removeEventListener(cf,he)},[_e]);const[Ge,Ze]=j.useState(null),[Se,be]=j.useState(null),de=j.useCallback((he,We,Ve,et="auto")=>{const it=Za(Ht.getState()),ge=vy(it,he,et);((ge==null?void 0:ge.parameters)??[]).filter(Fe=>Fe.position!==void 0||Fe.required).length>0?Ze({id:he,name:(ge==null?void 0:ge.name)??he,subGroup:We,scope:et}):je(void 0,void 0,he,We,Ve,et)},[je]),ie=j.useCallback((he,We,Ve,et)=>{de(he,We,Ve,et)},[de]),Pe=j.useCallback(he=>{_e(!1);const We=document.querySelector(`[data-item-index="${he}"]`);We&&(We.hasAttribute("data-placeholder")?(window.dispatchEvent(new CustomEvent(Cy,{detail:{index:he}})),requestAnimationFrame(()=>requestAnimationFrame(()=>{var Ve;(Ve=document.querySelector(`[data-item-index="${he}"]`))==null||Ve.scrollIntoView({behavior:"smooth",block:"center"})}))):We.scrollIntoView({behavior:"smooth",block:"center"}))},[_e]);j.useEffect(()=>{const he=We=>{const Ve=S||x||C||b||E;We.key==="Escape"&&G&&!Ve&&B(),We.key==="ScrollLock"&&_e(!ye)};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[G,B,ye,S,x,C,b,E]);const Ue=pu();ru(Ue.quickAction,()=>{_(!0)}),ru(Ue.criteriaSidebar,()=>{t==null||t()}),f3(Ue.agentSwitching,U,he=>{Re.getState().switchMode(he)});const ue=(he,We)=>{de(he,void 0,void 0,We),qe()},De=(he,We,Ve)=>{de(he,We,void 0,Ve),qe()},qe=()=>{c(""),d([]),R!=null&&R.id&&localStorage.removeItem(`openfox:draft:${R.id}`)},pe=j.useCallback(async(he,We,Ve,et)=>{const it=QT(he);if(it.length>0)be({prompt:he,paramKeys:it,agentMode:We,textareaContent:Ve,attachments:et});else{We&&(R==null?void 0:R.mode)!==We&&await Re.getState().switchMode(We);const ge=Ve&&Ve.trim()?`${Ve.trim()}
|
|
321
|
+
|
|
322
|
+
${he}`:he;He(ge,et!=null&&et.length?et:void 0,{messageKind:"command",isSystemGenerated:!0}),qe()}},[He,qe,R]);return s.jsxs(s.Fragment,{children:[s.jsxs(m9,{criteriaSidebarOpen:a,onCriteriaSidebarToggle:t,messages:H,children:[s.jsx(DG,{visible:!a}),s.jsx(p9,{}),E&&s.jsx(g9,{stats:E,onClose:()=>T(null)}),s.jsx(PV,{}),s.jsx(IV,{displayItems:se,scrollContainerRef:D,highlightedMessageId:null,onLaunchWorkflow:ie,onScrollToTop:()=>_e(!1),hiddenCount:ae,onScrollbarGesture:Ie,emptyState:H.length===0&&(R!=null&&R.projectId)?s.jsx(AG,{projectId:R.projectId}):void 0}),s.jsx(NG,{input:o,setInput:c,attachments:u,setAttachments:d,dragOver:h,setDragOver:p,errorMessage:m,setErrorMessage:g,scrollToBottom:()=>{var he,We;return(We=A())==null?void 0:We.scrollTo({top:((he=A())==null?void 0:he.scrollHeight)??0,behavior:"smooth"})},sessionId:R==null?void 0:R.id,showHistory:V,history:I,selectedIndex:O,openHistory:z,closeHistory:Y,navigateUp:X,navigateDown:Z,selectCurrent:F,isAutoScrollActive:ye,setAutoScroll:_e,onOpenMessageSearch:()=>k(!0),onOpenCommandsModal:()=>w(!0),onOpenWorkflowsModal:()=>v(!0),onSelectWorkflow:ue,onSelectWorkflowWithSubGroup:De,onSendCommand:pe,clearInput:qe}),s.jsx(qT,{isOpen:x,onClose:()=>w(!1),projectDir:R==null?void 0:R.workdir}),s.jsx(XT,{isOpen:C,onClose:()=>v(!1),projectDir:R==null?void 0:R.workdir}),s.jsx(JV,{isOpen:S,onClose:()=>_(!1),onSearchMessages:()=>k(!0),isAutoScrollActive:ye,onToggleAutoScroll:_e,textareaContent:o,onCloseComplete:hu,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(he,We)=>{const Ve=await ln.getState().fetchCommand(he,R==null?void 0:R.workdir);Ve&&pe(Ve.prompt,Ve.metadata.agentMode,We)},onSelectWorkflow:(he,We)=>{de(he,void 0,void 0,We),qe()}}),Ge&&s.jsx(Nk,{workflowName:Ge.name,parameters:(()=>{var We;const he=Za(Ht.getState());return((We=vy(he,Ge.id,Ge.scope))==null?void 0:We.parameters)??[]})(),onConfirm:he=>{je(void 0,void 0,Ge.id,Ge.subGroup,he,Ge.scope),Ze(null)},onCancel:()=>Ze(null)}),Se&&s.jsx(Nk,{workflowName:"Command",confirmLabel:"Launch command",parameters:Se.paramKeys.map((he,We)=>({id:he,label:he,position:We})),onConfirm:he=>{let We=Se.prompt;for(const[fe,Fe]of Object.entries(he))We=We.replaceAll(`{{${fe}}}`,Fe);const{agentMode:Ve,textareaContent:et,attachments:it}=Se;Ve&&(R==null?void 0:R.mode)!==Ve&&Re.getState().switchMode(Ve);const ge=et&&et.trim()?`${et.trim()}
|
|
323
|
+
|
|
324
|
+
${We}`:We;He(ge,it!=null&&it.length?it:void 0,{messageKind:"command",isSystemGenerated:!0}),qe(),be(null)},onCancel:()=>be(null)})]}),b&&s.jsx(aG,{isOpen:b,onClose:()=>{k(!1),hu(!0)},displayItems:se,onNavigate:Pe})]})}function HG(){var b;const[,e]=vl("/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),[p,m]=j.useState(null),g=async()=>{if(t){h(!0),m(null);try{const k=await xe(`/api/sessions/${t}?full=true`);if(!k.ok){m(`Failed to load session (${k.status})`),h(!1);return}const E=await k.json();r(E.session??null),o(E.messages??[]),u(E.hiddenCount??0)}catch(k){m(k instanceof Error?k.message:"Unknown error")}finally{h(!1)}}};j.useEffect(()=>{Rt.getState().getSettings([...Wy])},[]),j.useEffect(()=>{g()},[t]);const{showThinking:x,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:v,showWorkflowBars:S}=Ds(),_=j.useMemo(()=>rA(a),[a]);return d?s.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:s.jsx(na,{})}):p?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:p}),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(ht,{className:"flex-1 print:overflow-visible",children:[s.jsx("div",{className:"pt-4",children:s.jsx(WT,{displayItems:_,showThinking:x,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:v,showWorkflowBars:S})}),s.jsx("div",{className:"h-8"})]})]})}function Ak({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[a,o]=j.useState(""),c=j.useRef(null);j.useEffect(()=>{e&&(o(""),setTimeout(()=>{var d;Ft()&&((d=c.current)==null||d.focus())},100))},[e]);const u=d=>{d.preventDefault(),a.trim()&&n(a)};return s.jsx(wt,{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(Ns,{ref:c,type:"password",value:a,onChange:d=>o(d.target.value),placeholder:"Enter password",autoFocus:Ft()}),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 FG({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 UG({onNext:e}){const[t,n]=j.useState([]),[r,a]=j.useState([]),[o,c]=j.useState(!1),[u,d]=j.useState(null),[h,p]=j.useState(null),[m,g]=j.useState(null);j.useEffect(()=>{x()},[]);async function x(){try{const E=await xe("/api/providers");if(E.ok){const D=(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(D),a(D)}}catch{}}async function w(E){const T=E.id.startsWith("temp-"),D=r.some(M=>M.id===E.id),A=r.length===0&&u===null,R=tA(E);try{let M;if(T){const $=await xe("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});if(!$.ok)throw new Error("Failed to create provider");const G=await $.json();M={...E,id:G.provider.id,model:null}}else{if(!(await xe(`/api/providers/${E.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)})).ok)throw new Error("Failed to update provider");M={...E,model:null}}const W=$=>$.some(G=>G.id===M.id)?$.map(G=>G.id===M.id?M:G):[...$,M];a(W),n(W),A&&!D&&e({providers:[M]})}catch{if(T){const M={...E,model:null};a(W=>[...W,M])}}}function C(){d(null),c(!0)}function v(E){d(E),c(!0)}function S(){c(!1),d(null)}function _(E){p(E),t.some(D=>D.id===E)?xe(`/api/providers/${E}`,{method:"DELETE"}).then(()=>{a(r.filter(D=>D.id!==E)),n(t.filter(D=>D.id!==E)),p(null)}).catch(()=>p(null)):(a(r.filter(D=>D.id!==E)),p(null))}function b(){const E=r.filter(T=>!T.id.startsWith("temp-"));e({providers:E})}const k=r.length>0;return 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:Rj(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:m===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(fi,{})})]})})]},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(es,{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(nA,{isOpen:o,onClose:S,onSave:w,initialStep:1,editProvider:u??void 0})]})}function VG({onNext:e}){const[t,n]=j.useState(""),[r,a]=j.useState(!1);return j.useEffect(()=>{xe("/api/config").then(o=>o.json()).then(o=>{o.workdir?n(o.workdir):fetch(ms("/api/directories?path=")+encodeURIComponent("/home")).then(c=>c.json()).then(c=>{c.current&&n(c.current)}).catch(()=>{})}).catch(()=>{fetch(ms("/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(Lf,{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 GG(e){var t;return((t=e.split("/").pop())==null?void 0:t.replace(/-/g," "))??e}function WG(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??GG(r.id)});return t},[e])}function qG({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 KG({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 YG(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 XG(e,t,n){return r=>{e(r),r&&(t(""),n(""))}}function JG({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(qG,{value:n,options:r,onChange:a})]}):s.jsx("p",{className:"text-sm text-text-muted italic",children:o}),s.jsx(KG,{...u}),c]}):null}function QG({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,p]=j.useState("ollama"),[m,g]=j.useState([]),[x,w]=j.useState(""),{copied:C,copy:v}=zN();j.useEffect(()=>{xe("/api/config").then(D=>D.json()).then(D=>{D.visionFallback&&(n(D.visionFallback.enabled),D.visionFallback.providerModelRef?w(D.visionFallback.providerModelRef):(a(D.visionFallback.url??"http://localhost:11434"),c(D.visionFallback.model??"qwen3.5:0.8b"),d(D.visionFallback.apiKey??""),D.visionFallback.backend&&p(D.visionFallback.backend))),D.providers&&g(D.providers)}).catch(()=>{})},[]);const S=WG(m),_=XG(w,a,c),b=YG(p,w,a,c);function k(D){if(D){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(Rs,{className:"w-4 h-4 text-accent-primary"}):s.jsx(J5,{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:D=>n(D.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(JG,{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 ZG({onComplete:e}){const[t,n]=j.useState(1),[r,a]=j.useState(!1),[o,c]=j.useState({});async function u(m){c(g=>({...g,providers:m.providers})),n(2)}async function d(m){c(g=>({...g,...m})),n(3)}async function h(m){a(!0);try{if(!(await xe("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:o.workdir,visionFallback:m.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(g){console.error("Failed to save onboarding data:",g),a(!1)}}const p=m=>{n(m)};return s.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[s.jsx(Cu,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),s.jsx(FG,{currentStep:t,totalSteps:3,labels:["LLM Providers","Projects Folder","Vision"],onStepClick:p}),s.jsx("div",{className:"max-w-xl mx-auto",children:r?s.jsxs("div",{className:"text-center",children:[s.jsx(es,{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(UG,{onNext:u}),t===2&&s.jsx(VG,{onNext:d}),t===3&&s.jsx(QG,{onNext:h})]})})]})}function eW({projectId:e}){var p;const[,t]=Pn(),n=Re(m=>m.sessionsWithPendingConfirmations),r=Re(m=>{var g;return(g=m.currentSession)==null?void 0:g.id}),a=Re(m=>m.crossSessionConfirmations),o=Re(m=>m.sessions),c=n.find(m=>m!==r);if(!c)return null;const u=o.find(m=>m.id===c),d=(u==null?void 0:u.title)??c.slice(0,6),h=((p=a[c])==null?void 0:p.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:m=>{(m.key==="Enter"||m.key===" ")&&t(e?`/p/${e}/s/${c}`:`/s/${c}`)},children:[s.jsx(kf,{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 Cx="openfox_updated_to",kx="update_pending";function tW(){const[e,t]=j.useState(!1),n=localStorage.getItem(Cx),r=localStorage.getItem(kx);j.useEffect(()=>{if(!n||!r)return;const o=setTimeout(()=>{localStorage.removeItem(Cx),localStorage.removeItem(kx),t(!0)},8e3);return()=>clearTimeout(o)},[n,r]);const a=()=>{localStorage.removeItem(Cx),localStorage.removeItem(kx),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(Rs,{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(eb,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Kt.getState().loadUserPresets(),Kt.getState().applySavedTheme());function rv(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function sA(){return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(na,{})})}function nW({sidebarOpen:e,onSidebarToggle:t}){const[,n]=vl("/p/:projectId"),r=n==null?void 0:n.projectId,a=Re(d=>d.connectionStatus),o=Yt(d=>d.currentProject),c=rv();return q5({canLoad:a==="connected"||c,projectId:r,currentProjectId:o==null?void 0:o.id}),!o||o.id!==r?s.jsx(sA,{}):s.jsxs(s.Fragment,{children:[s.jsx(pT,{projectId:r,isOpen:e,onClose:t}),s.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:s.jsx(mU,{})})]})}function rW({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,a]=vl("/p/:projectId/s/:sessionId"),o=a==null?void 0:a.projectId,c=a==null?void 0:a.sessionId,[,u]=Pn(),d=Re(C=>C.connectionStatus),h=Re(C=>C.currentSession),p=Re(C=>C.error),m=Re(C=>C.clearError),g=Yt(C=>C.currentProject),x=rv();return K5({canLoad:d==="connected"||x,projectId:o,sessionId:c,currentProjectId:g==null?void 0:g.id,currentSessionId:h==null?void 0:h.id}),j.useEffect(()=>{(p==null?void 0:p.code)==="NOT_FOUND"&&o&&(m(),u(`/p/${o}`))},[p,o,m,u]),!g||g.id!==o?s.jsx(sA,{}):s.jsxs(s.Fragment,{children:[s.jsx(pT,{projectId:o,isOpen:e,onClose:t}),s.jsxs("div",{className:"flex-1 min-w-0 bg-primary flex flex-col",children:[s.jsx(eW,{projectId:o}),s.jsx(zG,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})]})]})}function sW(){const e=en(r=>r.fetchConfig),[,t]=Pn();async function n(){await e(),t("/")}return s.jsx(ht,{className:"flex-1",children:s.jsx(ZG,{onComplete:n})})}function iW(){const{connectionStatus:e}=H5(),t=en(I=>I.fetchConfig),n=en(I=>I.refreshProviderModels),r=en(I=>I.providers),a=en(I=>I.activeProviderId),[,o]=Pn(),c=rv(),[u,d]=j.useState(!1);j.useEffect(()=>{(e==="connected"||c)&&t().then(()=>{d(!0),Rt.getState().getSettings([...Wy,Ne.DISPLAY_THEME,Ne.DISPLAY_USER_PRESETS,Ne.DISPLAY_CUSTOM_CSS,Ne.KEYBINDINGS,Ne.FEATURES_PER_SESSION_MCP]),tu.getState().fetchServers()})},[e,c,t]),j.useEffect(()=>{u&&a&&n(a).then(()=>{const I=en.getState().defaultModelSelection;(I?I.split("/")[0]:null)!==a&&t()})},[u,a,n,t]);const h=Rt(I=>I.settings);j.useEffect(()=>{u&&r.length===0&&o("/onboarding")},[u,r.length]),j.useEffect(()=>{const{applyPreset:I,applyTokens:O,setFollowSystemTheme:V,initSystemThemeListener:z}=Kt.getState(),Y=h[Ne.DISPLAY_THEME],X=h[Ne.DISPLAY_USER_PRESETS],Z=h[Ne.DISPLAY_FOLLOW_SYSTEM_THEME];if(X&&localStorage.setItem("openfox:userPresets",X),Y){localStorage.setItem("openfox:theme",Y);try{const P=JSON.parse(Y);P.preset&&P.tokens?(I(P.preset),Kt.setState({basePreset:P.preset}),O(P.tokens)):P.preset?I(P.preset):P.tokens&&O(P.tokens)}catch{I("dark")}}else I("system");Z!==void 0&&Kt.getState().followSystemTheme!==(Z==="true")&&V(Z==="true");const F=z();return()=>F()},[h[Ne.DISPLAY_THEME],h[Ne.DISPLAY_USER_PRESETS]]),j.useEffect(()=>{const I=h[Ne.DISPLAY_CUSTOM_CSS]??"";let O=document.getElementById("custom-css");O||(O=document.createElement("style"),O.id="custom-css",document.head.appendChild(O)),O.textContent=I},[h[Ne.DISPLAY_CUSTOM_CSS]]);const[p,m]=j.useState(!1);j.useEffect(()=>{const I=Rt.getState().settings[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE];if(I===void 0||I==="false")return;let O=!1;if(localStorage.getItem("update_pending")==="true"&&(O=!0,localStorage.removeItem("update_pending")),u){const z=en.getState().version,Y=localStorage.getItem("openfox_last_version");z&&Y&&z!==Y&&(O=!0),localStorage.setItem("openfox_last_version",z??"")}O&&m(!0)},[h[Ne.DISPLAY_SHOW_CHANGELOG_ON_UPDATE],u]);const g=()=>{const I=localStorage.getItem("openfox:leftSidebar");return I!==null?I==="true":!0},x=()=>{const I=localStorage.getItem("openfox:rightSidebar");return I!==null?I==="true":!0},[w,C]=j.useState(g),[v,S]=j.useState(x),[_,b]=j.useState(!1),[k,E]=j.useState(!1),[T,D]=j.useState(!1),A=h5();j.useEffect(()=>{const I=()=>{D(window.innerWidth<768)};return I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]);const[R]=Pn(),M=/^\/p\/[^/]+$/.test(R),W=T?_:M?!0:w,$=T?k:v,G=()=>{T?b(!_):C(!w)},B=()=>{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 H=Re(I=>I.showPasswordModal),q=Re(I=>I.passwordModalRetry),Q=Re(I=>I.submitPassword),J=Re(I=>I.cancelPassword),[U]=vl("/p/:projectId/s/:sessionId/readonly");return!U&&e!=="connected"&&!H&&!c?s.jsxs(s.Fragment,{children:[s.jsx(Ak,{isOpen:!0,isRetry:q,onSubmit:Q,onCancel:J}),s.jsx("div",{className:"h-screen flex items-center justify-center",children:s.jsx(v3,{text:"Connecting to server..."})})]}):U?s.jsx(HG,{}):s.jsxs(s.Fragment,{children:[s.jsx(Ak,{isOpen:H,isRetry:q,onSubmit:Q,onCancel:J}),s.jsxs("div",{className:"flex flex-col",style:{height:T?`calc(${A.offsetTop}px + ${A.height}px)`:"100vh"},children:[s.jsx(lU,{}),s.jsx(tU,{onMenuClick:G,onCriteriaToggle:B}),s.jsx("div",{className:"flex-1 flex overflow-hidden",children:s.jsxs(XD,{children:[s.jsx(_c,{path:"/onboarding",children:s.jsx(sW,{})}),s.jsx(_c,{path:"/p/:projectId/s/:sessionId",children:s.jsx(rW,{sidebarOpen:W,onSidebarToggle:G,rightSidebarOpen:$,onRightSidebarToggle:B})}),s.jsx(_c,{path:"/p/:projectId/new",children:s.jsx(fU,{})}),s.jsx(_c,{path:"/p/:projectId",children:s.jsx(nW,{sidebarOpen:W,onSidebarToggle:G})}),s.jsx(_c,{path:"/",children:s.jsx(hU,{})})]})})]}),s.jsx(tW,{}),s.jsx(UN,{isOpen:p,onClose:()=>m(!1)})]})}const gh=window.location.pathname.match(/\/p\/[^/]+\/s\/([0-9a-fA-F-]+)/);gh!=null&&gh[1]&&m5(gh[1]);TD.createRoot(document.getElementById("root")).render(s.jsx(cs.StrictMode,{children:s.jsx($k,{base:Lj,children:s.jsx(iW,{})})}));
|