openfox 2.0.0-beta.11 → 2.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ask-5SSOA6SZ.js → ask-BRLFZKEW.js} +2 -1
- package/dist/{auth-56SIRACI.js → auth-OGGBJFJQ.js} +2 -1
- package/dist/{branch.api-PWFW26KC.js → branch.api-TCWNJXYA.js} +2 -1
- package/dist/{chat-handler-NMJCOCCB.js → chat-handler-ZFQIJIJT.js} +9 -8
- package/dist/chunk-7D4SUZUM.js +38 -0
- package/dist/{chunk-EZUR7OEP.js → chunk-BURBTNDG.js} +15 -9
- package/dist/{chunk-DMH6JVPF.js → chunk-BZJAO4VY.js} +47 -19
- package/dist/{chunk-NSBYORD5.js → chunk-DHAKJSE7.js} +4 -2
- package/dist/{chunk-4RLDN2LL.js → chunk-EYE2JMLA.js} +189 -61
- package/dist/{chunk-EQQDA4D3.js → chunk-IONKVOSF.js} +17 -19
- package/dist/{chunk-VIIRNJDT.js → chunk-LXX2CPM5.js} +203 -236
- package/dist/{chunk-EXYMWI7A.js → chunk-OKLV3ZNN.js} +9 -5
- package/dist/chunk-QD6U3BDD.js +25277 -0
- package/dist/{chunk-BU56QFHW.js → chunk-RUWSVV7U.js} +8 -9
- package/dist/{chunk-LCRJWUW7.js → chunk-YWYYRA2P.js} +11 -11
- package/dist/cli/dev.js +2 -1
- package/dist/cli/index.js +2 -1
- package/dist/{compactor-TDNRM3A7.js → compactor-WL33VHUF.js} +2 -1
- package/dist/{config-TDVA7MQN.js → config-MFKBDOOT.js} +6 -5
- package/dist/{events-UGTGGFG3.js → events-6UJR2NH4.js} +3 -2
- package/dist/{folding-YOCGTZYH.js → folding-GMO644G3.js} +2 -1
- package/dist/{inspect-proxy-42ZXL2R5.js → inspect-proxy-JZ54RBUN.js} +2 -1
- package/dist/{manager-W7N3XQ4Q.js → manager-NTL3MLGN.js} +2 -1
- package/dist/{orchestrator-75L5UGDU.js → orchestrator-HHF4UC3K.js} +8 -7
- package/dist/package.json +1 -1
- package/dist/{paths-X46PPOI2.js → paths-D7BBTOO5.js} +2 -1
- package/dist/{permissions-Z2IIV2V7.js → permissions-YGAJ47F5.js} +3 -1
- package/dist/{processor-GHESQ2YV.js → processor-EJJTSLRL.js} +11 -5
- package/dist/{project-creator-6DU7E75S.js → project-creator-GMS5YKEF.js} +2 -1
- package/dist/{projects-2HYIZC4Y.js → projects-QHGMUKWH.js} +2 -1
- package/dist/{protocol-CN24IKQN.js → protocol-QQNATDFM.js} +2 -1
- package/dist/{protocol-B9R1CUvt.d.ts → protocol-zn90yuIr.d.ts} +11 -2
- package/dist/{provider-BGH4MBLH.js → provider-APFZV234.js} +10 -9
- package/dist/provider-manager-2NFFVCX5.js +17 -0
- package/dist/{pwa-76XP2DY2.js → pwa-WYVG3NLS.js} +2 -1
- package/dist/{serve-I6T7V62Z.js → serve-GTH76EDG.js} +14 -13
- package/dist/server/index.d.ts +21 -15
- package/dist/server/index.js +10 -9
- package/dist/{service-GB7AIOG5.js → service-W43DAQ5K.js} +3 -1
- package/dist/{settings-6XX56F3F.js → settings-OAISIQVV.js} +2 -1
- package/dist/shared/index.d.ts +2 -2
- package/dist/shared/index.js +1 -0
- package/dist/{store-OQ45KONN.js → store-JZW6VPEK.js} +2 -1
- package/dist/{tools-D3WWIOQD.js → tools-2X2FC6W7.js} +7 -6
- package/dist/web/assets/index-DCu8wsRj.js +299 -0
- package/dist/web/assets/{index-CSOB8dwI.css → index-Sdax8ayU.css} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-UKTPL5ZG.js +0 -469
- package/dist/web/assets/index-tJDr1ODC.js +0 -299
|
@@ -0,0 +1,299 @@
|
|
|
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 QE=Object.defineProperty;var JE=Object.getPrototypeOf;var ZE=Reflect.get;var Yy=e=>{throw TypeError(e)};var e2=(e,t,n)=>t in e?QE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var pe=(e,t,n)=>e2(e,typeof t!="symbol"?t+"":t,n),yf=(e,t,n)=>t.has(e)||Yy("Cannot "+n);var wn=(e,t,n)=>(yf(e,t,"read from private field"),n?n.call(e):t.get(e)),fi=(e,t,n)=>t.has(e)?Yy("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),pr=(e,t,n,s)=>(yf(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),vf=(e,t,n)=>(yf(e,t,"access private method"),n);var Xy=(e,t,n)=>ZE(JE(e),n,t);function t2(e,t){for(var n=0;n<t.length;n++){const s=t[n];if(typeof s!="string"&&!Array.isArray(s)){for(const a in s)if(a!=="default"&&!(a in e)){const l=Object.getOwnPropertyDescriptor(s,a);l&&Object.defineProperty(e,a,l.get?l:{enumerable:!0,get:()=>s[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"]'))s(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&s(u)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();function Du(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var bf={exports:{}},Bo={};/**
|
|
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 Qy;function n2(){if(Qy)return Bo;Qy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,a,l){var u=null;if(l!==void 0&&(u=""+l),a.key!==void 0&&(u=""+a.key),"key"in a){l={};for(var c in a)c!=="key"&&(l[c]=a[c])}else l=a;return a=l.ref,{$$typeof:e,type:s,key:u,ref:a!==void 0?a:null,props:l}}return Bo.Fragment=t,Bo.jsx=n,Bo.jsxs=n,Bo}var Jy;function r2(){return Jy||(Jy=1,bf.exports=n2()),bf.exports}var o=r2(),Sf={exports:{}},We={};/**
|
|
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 Zy;function s2(){if(Zy)return We;Zy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),_=Symbol.iterator;function x($){return $===null||typeof $!="object"?null:($=_&&$[_]||$["@@iterator"],typeof $=="function"?$:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,y={};function S($,P,U){this.props=$,this.context=P,this.refs=y,this.updater=U||w}S.prototype.isReactComponent={},S.prototype.setState=function($,P){if(typeof $!="object"&&typeof $!="function"&&$!=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,$,P,"setState")},S.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function v(){}v.prototype=S.prototype;function b($,P,U){this.props=$,this.context=P,this.refs=y,this.updater=U||w}var E=b.prototype=new v;E.constructor=b,k(E,S.prototype),E.isPureReactComponent=!0;var T=Array.isArray;function N(){}var L={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function D($,P,U){var J=U.ref;return{$$typeof:e,type:$,key:P,ref:J!==void 0?J:null,props:U}}function B($,P){return D($.type,P,$.props)}function q($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function W($){var P={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(U){return P[U]})}var O=/\/+/g;function V($,P){return typeof $=="object"&&$!==null&&$.key!=null?W(""+$.key):P.toString(36)}function G($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(N,N):($.status="pending",$.then(function(P){$.status==="pending"&&($.status="fulfilled",$.value=P)},function(P){$.status==="pending"&&($.status="rejected",$.reason=P)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function z($,P,U,J,Q){var se=typeof $;(se==="undefined"||se==="boolean")&&($=null);var Y=!1;if($===null)Y=!0;else switch(se){case"bigint":case"string":case"number":Y=!0;break;case"object":switch($.$$typeof){case e:case t:Y=!0;break;case p:return Y=$._init,z(Y($._payload),P,U,J,Q)}}if(Y)return Q=Q($),Y=J===""?"."+V($,0):J,T(Q)?(U="",Y!=null&&(U=Y.replace(O,"$&/")+"/"),z(Q,P,U,"",function(te){return te})):Q!=null&&(q(Q)&&(Q=B(Q,U+(Q.key==null||$&&$.key===Q.key?"":(""+Q.key).replace(O,"$&/")+"/")+Y)),P.push(Q)),1;Y=0;var H=J===""?".":J+":";if(T($))for(var ee=0;ee<$.length;ee++)J=$[ee],se=H+V(J,ee),Y+=z(J,P,U,se,Q);else if(ee=x($),typeof ee=="function")for($=ee.call($),ee=0;!(J=$.next()).done;)J=J.value,se=H+V(J,ee++),Y+=z(J,P,U,se,Q);else if(se==="object"){if(typeof $.then=="function")return z(G($),P,U,J,Q);throw P=String($),Error("Objects are not valid as a React child (found: "+(P==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":P)+"). If you meant to render a collection of children, use an array instead.")}return Y}function X($,P,U){if($==null)return $;var J=[],Q=0;return z($,J,"","",function(se){return P.call(U,se,Q++)}),J}function ne($){if($._status===-1){var P=$._result;P=P(),P.then(function(U){($._status===0||$._status===-1)&&($._status=1,$._result=U)},function(U){($._status===0||$._status===-1)&&($._status=2,$._result=U)}),$._status===-1&&($._status=0,$._result=P)}if($._status===1)return $._result.default;throw $._result}var F=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var P=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(P))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},M={map:X,forEach:function($,P,U){X($,function(){P.apply(this,arguments)},U)},count:function($){var P=0;return X($,function(){P++}),P},toArray:function($){return X($,function(P){return P})||[]},only:function($){if(!q($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return We.Activity=m,We.Children=M,We.Component=S,We.Fragment=n,We.Profiler=a,We.PureComponent=b,We.StrictMode=s,We.Suspense=h,We.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,We.__COMPILER_RUNTIME={__proto__:null,c:function($){return L.H.useMemoCache($)}},We.cache=function($){return function(){return $.apply(null,arguments)}},We.cacheSignal=function(){return null},We.cloneElement=function($,P,U){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var J=k({},$.props),Q=$.key;if(P!=null)for(se in P.key!==void 0&&(Q=""+P.key),P)!A.call(P,se)||se==="key"||se==="__self"||se==="__source"||se==="ref"&&P.ref===void 0||(J[se]=P[se]);var se=arguments.length-2;if(se===1)J.children=U;else if(1<se){for(var Y=Array(se),H=0;H<se;H++)Y[H]=arguments[H+2];J.children=Y}return D($.type,Q,J)},We.createContext=function($){return $={$$typeof:u,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:l,_context:$},$},We.createElement=function($,P,U){var J,Q={},se=null;if(P!=null)for(J in P.key!==void 0&&(se=""+P.key),P)A.call(P,J)&&J!=="key"&&J!=="__self"&&J!=="__source"&&(Q[J]=P[J]);var Y=arguments.length-2;if(Y===1)Q.children=U;else if(1<Y){for(var H=Array(Y),ee=0;ee<Y;ee++)H[ee]=arguments[ee+2];Q.children=H}if($&&$.defaultProps)for(J in Y=$.defaultProps,Y)Q[J]===void 0&&(Q[J]=Y[J]);return D($,se,Q)},We.createRef=function(){return{current:null}},We.forwardRef=function($){return{$$typeof:c,render:$}},We.isValidElement=q,We.lazy=function($){return{$$typeof:p,_payload:{_status:-1,_result:$},_init:ne}},We.memo=function($,P){return{$$typeof:f,type:$,compare:P===void 0?null:P}},We.startTransition=function($){var P=L.T,U={};L.T=U;try{var J=$(),Q=L.S;Q!==null&&Q(U,J),typeof J=="object"&&J!==null&&typeof J.then=="function"&&J.then(N,F)}catch(se){F(se)}finally{P!==null&&U.types!==null&&(P.types=U.types),L.T=P}},We.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},We.use=function($){return L.H.use($)},We.useActionState=function($,P,U){return L.H.useActionState($,P,U)},We.useCallback=function($,P){return L.H.useCallback($,P)},We.useContext=function($){return L.H.useContext($)},We.useDebugValue=function(){},We.useDeferredValue=function($,P){return L.H.useDeferredValue($,P)},We.useEffect=function($,P){return L.H.useEffect($,P)},We.useEffectEvent=function($){return L.H.useEffectEvent($)},We.useId=function(){return L.H.useId()},We.useImperativeHandle=function($,P,U){return L.H.useImperativeHandle($,P,U)},We.useInsertionEffect=function($,P){return L.H.useInsertionEffect($,P)},We.useLayoutEffect=function($,P){return L.H.useLayoutEffect($,P)},We.useMemo=function($,P){return L.H.useMemo($,P)},We.useOptimistic=function($,P){return L.H.useOptimistic($,P)},We.useReducer=function($,P,U){return L.H.useReducer($,P,U)},We.useRef=function($){return L.H.useRef($)},We.useState=function($){return L.H.useState($)},We.useSyncExternalStore=function($,P,U){return L.H.useSyncExternalStore($,P,U)},We.useTransition=function(){return L.H.useTransition()},We.version="19.2.4",We}var ev;function Ru(){return ev||(ev=1,Sf.exports=s2()),Sf.exports}var R=Ru();const $s=Du(R),i2=t2({__proto__:null,default:$s},[R]);var wf={exports:{}},zo={},Cf={exports:{}},kf={};/**
|
|
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 tv;function a2(){return tv||(tv=1,(function(e){function t(z,X){var ne=z.length;z.push(X);e:for(;0<ne;){var F=ne-1>>>1,M=z[F];if(0<a(M,X))z[F]=X,z[ne]=M,ne=F;else break e}}function n(z){return z.length===0?null:z[0]}function s(z){if(z.length===0)return null;var X=z[0],ne=z.pop();if(ne!==X){z[0]=ne;e:for(var F=0,M=z.length,$=M>>>1;F<$;){var P=2*(F+1)-1,U=z[P],J=P+1,Q=z[J];if(0>a(U,ne))J<M&&0>a(Q,U)?(z[F]=Q,z[J]=ne,F=J):(z[F]=U,z[P]=ne,F=P);else if(J<M&&0>a(Q,ne))z[F]=Q,z[J]=ne,F=J;else break e}}return X}function a(z,X){var ne=z.sortIndex-X.sortIndex;return ne!==0?ne:z.id-X.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var h=[],f=[],p=1,m=null,_=3,x=!1,w=!1,k=!1,y=!1,S=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;function E(z){for(var X=n(f);X!==null;){if(X.callback===null)s(f);else if(X.startTime<=z)s(f),X.sortIndex=X.expirationTime,t(h,X);else break;X=n(f)}}function T(z){if(k=!1,E(z),!w)if(n(h)!==null)w=!0,N||(N=!0,W());else{var X=n(f);X!==null&&G(T,X.startTime-z)}}var N=!1,L=-1,A=5,D=-1;function B(){return y?!0:!(e.unstable_now()-D<A)}function q(){if(y=!1,N){var z=e.unstable_now();D=z;var X=!0;try{e:{w=!1,k&&(k=!1,v(L),L=-1),x=!0;var ne=_;try{t:{for(E(z),m=n(h);m!==null&&!(m.expirationTime>z&&B());){var F=m.callback;if(typeof F=="function"){m.callback=null,_=m.priorityLevel;var M=F(m.expirationTime<=z);if(z=e.unstable_now(),typeof M=="function"){m.callback=M,E(z),X=!0;break t}m===n(h)&&s(h),E(z)}else s(h);m=n(h)}if(m!==null)X=!0;else{var $=n(f);$!==null&&G(T,$.startTime-z),X=!1}}break e}finally{m=null,_=ne,x=!1}X=void 0}}finally{X?W():N=!1}}}var W;if(typeof b=="function")W=function(){b(q)};else if(typeof MessageChannel<"u"){var O=new MessageChannel,V=O.port2;O.port1.onmessage=q,W=function(){V.postMessage(null)}}else W=function(){S(q,0)};function G(z,X){L=S(function(){z(e.unstable_now())},X)}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(z){z.callback=null},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return _},e.unstable_next=function(z){switch(_){case 1:case 2:case 3:var X=3;break;default:X=_}var ne=_;_=X;try{return z()}finally{_=ne}},e.unstable_requestPaint=function(){y=!0},e.unstable_runWithPriority=function(z,X){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var ne=_;_=z;try{return X()}finally{_=ne}},e.unstable_scheduleCallback=function(z,X,ne){var F=e.unstable_now();switch(typeof ne=="object"&&ne!==null?(ne=ne.delay,ne=typeof ne=="number"&&0<ne?F+ne:F):ne=F,z){case 1:var M=-1;break;case 2:M=250;break;case 5:M=1073741823;break;case 4:M=1e4;break;default:M=5e3}return M=ne+M,z={id:p++,callback:X,priorityLevel:z,startTime:ne,expirationTime:M,sortIndex:-1},ne>F?(z.sortIndex=ne,t(f,z),n(h)===null&&z===n(f)&&(k?(v(L),L=-1):k=!0,G(T,ne-F))):(z.sortIndex=M,t(h,z),w||x||(w=!0,N||(N=!0,W()))),z},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(z){var X=_;return function(){var ne=_;_=X;try{return z.apply(this,arguments)}finally{_=ne}}}})(kf)),kf}var nv;function o2(){return nv||(nv=1,Cf.exports=a2()),Cf.exports}var Ef={exports:{}},xn={};/**
|
|
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 rv;function l2(){if(rv)return xn;rv=1;var e=Ru();function t(h){var f="https://react.dev/errors/"+h;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)f+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+h+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");function l(h,f,p){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:m==null?null:""+m,children:h,containerInfo:f,implementation:p}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(h,f){if(h==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return xn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,xn.createPortal=function(h,f){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return l(h,f,null,p)},xn.flushSync=function(h){var f=u.T,p=s.p;try{if(u.T=null,s.p=2,h)return h()}finally{u.T=f,s.p=p,s.d.f()}},xn.preconnect=function(h,f){typeof h=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,s.d.C(h,f))},xn.prefetchDNS=function(h){typeof h=="string"&&s.d.D(h)},xn.preinit=function(h,f){if(typeof h=="string"&&f&&typeof f.as=="string"){var p=f.as,m=c(p,f.crossOrigin),_=typeof f.integrity=="string"?f.integrity:void 0,x=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;p==="style"?s.d.S(h,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:m,integrity:_,fetchPriority:x}):p==="script"&&s.d.X(h,{crossOrigin:m,integrity:_,fetchPriority:x,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},xn.preinitModule=function(h,f){if(typeof h=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var p=c(f.as,f.crossOrigin);s.d.M(h,{crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&s.d.M(h)},xn.preload=function(h,f){if(typeof h=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var p=f.as,m=c(p,f.crossOrigin);s.d.L(h,p,{crossOrigin:m,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},xn.preloadModule=function(h,f){if(typeof h=="string")if(f){var p=c(f.as,f.crossOrigin);s.d.m(h,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(h)},xn.requestFormReset=function(h){s.d.r(h)},xn.unstable_batchedUpdates=function(h,f){return h(f)},xn.useFormState=function(h,f,p){return u.H.useFormState(h,f,p)},xn.useFormStatus=function(){return u.H.useHostTransitionStatus()},xn.version="19.2.4",xn}var sv;function Q0(){if(sv)return Ef.exports;sv=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(),Ef.exports=l2(),Ef.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 iv;function c2(){if(iv)return zo;iv=1;var e=o2(),t=Ru(),n=Q0();function s(r){var i="https://react.dev/errors/"+r;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)i+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+r+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function l(r){var i=r,d=r;if(r.alternate)for(;i.return;)i=i.return;else{r=i;do i=r,(i.flags&4098)!==0&&(d=i.return),r=i.return;while(r)}return i.tag===3?d:null}function u(r){if(r.tag===13){var i=r.memoizedState;if(i===null&&(r=r.alternate,r!==null&&(i=r.memoizedState)),i!==null)return i.dehydrated}return null}function c(r){if(r.tag===31){var i=r.memoizedState;if(i===null&&(r=r.alternate,r!==null&&(i=r.memoizedState)),i!==null)return i.dehydrated}return null}function h(r){if(l(r)!==r)throw Error(s(188))}function f(r){var i=r.alternate;if(!i){if(i=l(r),i===null)throw Error(s(188));return i!==r?null:r}for(var d=r,g=i;;){var C=d.return;if(C===null)break;var j=C.alternate;if(j===null){if(g=C.return,g!==null){d=g;continue}break}if(C.child===j.child){for(j=C.child;j;){if(j===d)return h(C),r;if(j===g)return h(C),i;j=j.sibling}throw Error(s(188))}if(d.return!==g.return)d=C,g=j;else{for(var I=!1,K=C.child;K;){if(K===d){I=!0,d=C,g=j;break}if(K===g){I=!0,g=C,d=j;break}K=K.sibling}if(!I){for(K=j.child;K;){if(K===d){I=!0,d=j,g=C;break}if(K===g){I=!0,g=j,d=C;break}K=K.sibling}if(!I)throw Error(s(189))}}if(d.alternate!==g)throw Error(s(190))}if(d.tag!==3)throw Error(s(188));return d.stateNode.current===d?r:i}function p(r){var i=r.tag;if(i===5||i===26||i===27||i===6)return r;for(r=r.child;r!==null;){if(i=p(r),i!==null)return i;r=r.sibling}return null}var m=Object.assign,_=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),v=Symbol.for("react.consumer"),b=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),D=Symbol.for("react.activity"),B=Symbol.for("react.memo_cache_sentinel"),q=Symbol.iterator;function W(r){return r===null||typeof r!="object"?null:(r=q&&r[q]||r["@@iterator"],typeof r=="function"?r:null)}var O=Symbol.for("react.client.reference");function V(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===O?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case k:return"Fragment";case S:return"Profiler";case y:return"StrictMode";case T:return"Suspense";case N:return"SuspenseList";case D:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case w:return"Portal";case b:return r.displayName||"Context";case v:return(r._context.displayName||"Context")+".Consumer";case E:var i=r.render;return r=r.displayName,r||(r=i.displayName||i.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case L:return i=r.displayName||null,i!==null?i:V(r.type)||"Memo";case A:i=r._payload,r=r._init;try{return V(r(i))}catch{}}return null}var G=Array.isArray,z=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},F=[],M=-1;function $(r){return{current:r}}function P(r){0>M||(r.current=F[M],F[M]=null,M--)}function U(r,i){M++,F[M]=r.current,r.current=i}var J=$(null),Q=$(null),se=$(null),Y=$(null);function H(r,i){switch(U(se,i),U(Q,r),U(J,null),i.nodeType){case 9:case 11:r=(r=i.documentElement)&&(r=r.namespaceURI)?_y(r):0;break;default:if(r=i.tagName,i=i.namespaceURI)i=_y(i),r=yy(i,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}P(J),U(J,r)}function ee(){P(J),P(Q),P(se)}function te(r){r.memoizedState!==null&&U(Y,r);var i=J.current,d=yy(i,r.type);i!==d&&(U(Q,r),U(J,d))}function ce(r){Q.current===r&&(P(J),P(Q)),Y.current===r&&(P(Y),Oo._currentValue=ne)}var he,Te;function Ae(r){if(he===void 0)try{throw Error()}catch(d){var i=d.stack.trim().match(/\n( *(at )?)/);he=i&&i[1]||"",Te=-1<d.stack.indexOf(`
|
|
43
|
+
at`)?" (<anonymous>)":-1<d.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
+
`+he+r+Te}var Le=!1;function Pe(r,i){if(!r||Le)return"";Le=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(i){var be=function(){throw Error()};if(Object.defineProperty(be.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(be,[])}catch(fe){var ue=fe}Reflect.construct(r,[],be)}else{try{be.call()}catch(fe){ue=fe}r.call(be.prototype)}}else{try{throw Error()}catch(fe){ue=fe}(be=r())&&typeof be.catch=="function"&&be.catch(function(){})}}catch(fe){if(fe&&ue&&typeof fe.stack=="string")return[fe.stack,ue.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var C=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");C&&C.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var j=g.DetermineComponentFrameRoot(),I=j[0],K=j[1];if(I&&K){var re=I.split(`
|
|
45
|
+
`),le=K.split(`
|
|
46
|
+
`);for(C=g=0;g<re.length&&!re[g].includes("DetermineComponentFrameRoot");)g++;for(;C<le.length&&!le[C].includes("DetermineComponentFrameRoot");)C++;if(g===re.length||C===le.length)for(g=re.length-1,C=le.length-1;1<=g&&0<=C&&re[g]!==le[C];)C--;for(;1<=g&&0<=C;g--,C--)if(re[g]!==le[C]){if(g!==1||C!==1)do if(g--,C--,0>C||re[g]!==le[C]){var xe=`
|
|
47
|
+
`+re[g].replace(" at new "," at ");return r.displayName&&xe.includes("<anonymous>")&&(xe=xe.replace("<anonymous>",r.displayName)),xe}while(1<=g&&0<=C);break}}}finally{Le=!1,Error.prepareStackTrace=d}return(d=r?r.displayName||r.name:"")?Ae(d):""}function de(r,i){switch(r.tag){case 26:case 27:case 5:return Ae(r.type);case 16:return Ae("Lazy");case 13:return r.child!==i&&i!==null?Ae("Suspense Fallback"):Ae("Suspense");case 19:return Ae("SuspenseList");case 0:case 15:return Pe(r.type,!1);case 11:return Pe(r.type.render,!1);case 1:return Pe(r.type,!0);case 31:return Ae("Activity");default:return""}}function Ie(r){try{var i="",d=null;do i+=de(r,d),d=r,r=r.return;while(r);return i}catch(g){return`
|
|
48
|
+
Error generating stack: `+g.message+`
|
|
49
|
+
`+g.stack}}var Se=Object.prototype.hasOwnProperty,me=e.unstable_scheduleCallback,je=e.unstable_cancelCallback,nt=e.unstable_shouldYield,Mt=e.unstable_requestPaint,gt=e.unstable_now,Zt=e.unstable_getCurrentPriorityLevel,ge=e.unstable_ImmediatePriority,Ce=e.unstable_UserBlockingPriority,Oe=e.unstable_NormalPriority,Ve=e.unstable_LowPriority,Ge=e.unstable_IdlePriority,vt=e.log,Xe=e.unstable_setDisableYieldValue,bt=null,ct=null;function en(r){if(typeof vt=="function"&&Xe(r),ct&&typeof ct.setStrictMode=="function")try{ct.setStrictMode(bt,r)}catch{}}var He=Math.clz32?Math.clz32:Ri,ur=Math.log,Mn=Math.LN2;function Ri(r){return r>>>=0,r===0?32:31-(ur(r)/Mn|0)|0}var dr=256,Oi=262144,Mi=4194304;function wr(r){var i=r&42;if(i!==0)return i;switch(r&-r){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 r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function Ii(r,i,d){var g=r.pendingLanes;if(g===0)return 0;var C=0,j=r.suspendedLanes,I=r.pingedLanes;r=r.warmLanes;var K=g&134217727;return K!==0?(g=K&~j,g!==0?C=wr(g):(I&=K,I!==0?C=wr(I):d||(d=K&~r,d!==0&&(C=wr(d))))):(K=g&~j,K!==0?C=wr(K):I!==0?C=wr(I):d||(d=g&~r,d!==0&&(C=wr(d)))),C===0?0:i!==0&&i!==C&&(i&j)===0&&(j=C&-C,d=i&-i,j>=d||j===32&&(d&4194048)!==0)?i:C}function Ys(r,i){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&i)===0}function qa(r,i){switch(r){case 1:case 2:case 4:case 8:case 64:return i+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 i+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 El(){var r=Mi;return Mi<<=1,(Mi&62914560)===0&&(Mi=4194304),r}function Pi(r){for(var i=[],d=0;31>d;d++)i.push(r);return i}function hs(r,i){r.pendingLanes|=i,i!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function ye(r,i,d,g,C,j){var I=r.pendingLanes;r.pendingLanes=d,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=d,r.entangledLanes&=d,r.errorRecoveryDisabledLanes&=d,r.shellSuspendCounter=0;var K=r.entanglements,re=r.expirationTimes,le=r.hiddenUpdates;for(d=I&~d;0<d;){var xe=31-He(d),be=1<<xe;K[xe]=0,re[xe]=-1;var ue=le[xe];if(ue!==null)for(le[xe]=null,xe=0;xe<ue.length;xe++){var fe=ue[xe];fe!==null&&(fe.lane&=-536870913)}d&=~be}g!==0&&_e(r,g,0),j!==0&&C===0&&r.tag!==0&&(r.suspendedLanes|=j&~(I&~i))}function _e(r,i,d){r.pendingLanes|=i,r.suspendedLanes&=~i;var g=31-He(i);r.entangledLanes|=i,r.entanglements[g]=r.entanglements[g]|1073741824|d&261930}function De(r,i){var d=r.entangledLanes|=i;for(r=r.entanglements;d;){var g=31-He(d),C=1<<g;C&i|r[g]&i&&(r[g]|=i),d&=~C}}function $e(r,i){var d=i&-i;return d=(d&42)!==0?1:et(d),(d&(r.suspendedLanes|i))!==0?0:d}function et(r){switch(r){case 2:r=1;break;case 8:r=4;break;case 32:r=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:r=128;break;case 268435456:r=134217728;break;default:r=0}return r}function qe(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function dt(){var r=X.p;return r!==0?r:(r=window.event,r===void 0?32:Uy(r.type))}function hn(r,i){var d=X.p;try{return X.p=r,i()}finally{X.p=d}}var It=Math.random().toString(36).slice(2),xt="__reactFiber$"+It,kn="__reactProps$"+It,Bi="__reactContainer$"+It,cd="__reactEvents$"+It,HC="__reactListeners$"+It,$C="__reactHandles$"+It,ig="__reactResources$"+It,Ka="__reactMarker$"+It;function ud(r){delete r[xt],delete r[kn],delete r[cd],delete r[HC],delete r[$C]}function zi(r){var i=r[xt];if(i)return i;for(var d=r.parentNode;d;){if(i=d[Bi]||d[xt]){if(d=i.alternate,i.child!==null||d!==null&&d.child!==null)for(r=Ey(r);r!==null;){if(d=r[xt])return d;r=Ey(r)}return i}r=d,d=r.parentNode}return null}function Hi(r){if(r=r[xt]||r[Bi]){var i=r.tag;if(i===5||i===6||i===13||i===31||i===26||i===27||i===3)return r}return null}function Ya(r){var i=r.tag;if(i===5||i===26||i===27||i===6)return r.stateNode;throw Error(s(33))}function $i(r){var i=r[ig];return i||(i=r[ig]={hoistableStyles:new Map,hoistableScripts:new Map}),i}function ln(r){r[Ka]=!0}var ag=new Set,og={};function Xs(r,i){Ui(r,i),Ui(r+"Capture",i)}function Ui(r,i){for(og[r]=i,r=0;r<i.length;r++)ag.add(i[r])}var UC=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]*$"),lg={},cg={};function FC(r){return Se.call(cg,r)?!0:Se.call(lg,r)?!1:UC.test(r)?cg[r]=!0:(lg[r]=!0,!1)}function jl(r,i,d){if(FC(i))if(d===null)r.removeAttribute(i);else{switch(typeof d){case"undefined":case"function":case"symbol":r.removeAttribute(i);return;case"boolean":var g=i.toLowerCase().slice(0,5);if(g!=="data-"&&g!=="aria-"){r.removeAttribute(i);return}}r.setAttribute(i,""+d)}}function Nl(r,i,d){if(d===null)r.removeAttribute(i);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(i);return}r.setAttribute(i,""+d)}}function Pr(r,i,d,g){if(g===null)r.removeAttribute(d);else{switch(typeof g){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(d);return}r.setAttributeNS(i,d,""+g)}}function Kn(r){switch(typeof r){case"bigint":case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function ug(r){var i=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function VC(r,i,d){var g=Object.getOwnPropertyDescriptor(r.constructor.prototype,i);if(!r.hasOwnProperty(i)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var C=g.get,j=g.set;return Object.defineProperty(r,i,{configurable:!0,get:function(){return C.call(this)},set:function(I){d=""+I,j.call(this,I)}}),Object.defineProperty(r,i,{enumerable:g.enumerable}),{getValue:function(){return d},setValue:function(I){d=""+I},stopTracking:function(){r._valueTracker=null,delete r[i]}}}}function dd(r){if(!r._valueTracker){var i=ug(r)?"checked":"value";r._valueTracker=VC(r,i,""+r[i])}}function dg(r){if(!r)return!1;var i=r._valueTracker;if(!i)return!0;var d=i.getValue(),g="";return r&&(g=ug(r)?r.checked?"true":"false":r.value),r=g,r!==d?(i.setValue(r),!0):!1}function Tl(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}var GC=/[\n"\\]/g;function Yn(r){return r.replace(GC,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function hd(r,i,d,g,C,j,I,K){r.name="",I!=null&&typeof I!="function"&&typeof I!="symbol"&&typeof I!="boolean"?r.type=I:r.removeAttribute("type"),i!=null?I==="number"?(i===0&&r.value===""||r.value!=i)&&(r.value=""+Kn(i)):r.value!==""+Kn(i)&&(r.value=""+Kn(i)):I!=="submit"&&I!=="reset"||r.removeAttribute("value"),i!=null?fd(r,I,Kn(i)):d!=null?fd(r,I,Kn(d)):g!=null&&r.removeAttribute("value"),C==null&&j!=null&&(r.defaultChecked=!!j),C!=null&&(r.checked=C&&typeof C!="function"&&typeof C!="symbol"),K!=null&&typeof K!="function"&&typeof K!="symbol"&&typeof K!="boolean"?r.name=""+Kn(K):r.removeAttribute("name")}function hg(r,i,d,g,C,j,I,K){if(j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(r.type=j),i!=null||d!=null){if(!(j!=="submit"&&j!=="reset"||i!=null)){dd(r);return}d=d!=null?""+Kn(d):"",i=i!=null?""+Kn(i):d,K||i===r.value||(r.value=i),r.defaultValue=i}g=g??C,g=typeof g!="function"&&typeof g!="symbol"&&!!g,r.checked=K?r.checked:!!g,r.defaultChecked=!!g,I!=null&&typeof I!="function"&&typeof I!="symbol"&&typeof I!="boolean"&&(r.name=I),dd(r)}function fd(r,i,d){i==="number"&&Tl(r.ownerDocument)===r||r.defaultValue===""+d||(r.defaultValue=""+d)}function Fi(r,i,d,g){if(r=r.options,i){i={};for(var C=0;C<d.length;C++)i["$"+d[C]]=!0;for(d=0;d<r.length;d++)C=i.hasOwnProperty("$"+r[d].value),r[d].selected!==C&&(r[d].selected=C),C&&g&&(r[d].defaultSelected=!0)}else{for(d=""+Kn(d),i=null,C=0;C<r.length;C++){if(r[C].value===d){r[C].selected=!0,g&&(r[C].defaultSelected=!0);return}i!==null||r[C].disabled||(i=r[C])}i!==null&&(i.selected=!0)}}function fg(r,i,d){if(i!=null&&(i=""+Kn(i),i!==r.value&&(r.value=i),d==null)){r.defaultValue!==i&&(r.defaultValue=i);return}r.defaultValue=d!=null?""+Kn(d):""}function mg(r,i,d,g){if(i==null){if(g!=null){if(d!=null)throw Error(s(92));if(G(g)){if(1<g.length)throw Error(s(93));g=g[0]}d=g}d==null&&(d=""),i=d}d=Kn(i),r.defaultValue=d,g=r.textContent,g===d&&g!==""&&g!==null&&(r.value=g),dd(r)}function Vi(r,i){if(i){var d=r.firstChild;if(d&&d===r.lastChild&&d.nodeType===3){d.nodeValue=i;return}}r.textContent=i}var WC=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 pg(r,i,d){var g=i.indexOf("--")===0;d==null||typeof d=="boolean"||d===""?g?r.setProperty(i,""):i==="float"?r.cssFloat="":r[i]="":g?r.setProperty(i,d):typeof d!="number"||d===0||WC.has(i)?i==="float"?r.cssFloat=d:r[i]=(""+d).trim():r[i]=d+"px"}function gg(r,i,d){if(i!=null&&typeof i!="object")throw Error(s(62));if(r=r.style,d!=null){for(var g in d)!d.hasOwnProperty(g)||i!=null&&i.hasOwnProperty(g)||(g.indexOf("--")===0?r.setProperty(g,""):g==="float"?r.cssFloat="":r[g]="");for(var C in i)g=i[C],i.hasOwnProperty(C)&&d[C]!==g&&pg(r,C,g)}else for(var j in i)i.hasOwnProperty(j)&&pg(r,j,i[j])}function md(r){if(r.indexOf("-")===-1)return!1;switch(r){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 qC=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"]]),KC=/^[\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 Al(r){return KC.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function Br(){}var pd=null;function gd(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Gi=null,Wi=null;function xg(r){var i=Hi(r);if(i&&(r=i.stateNode)){var d=r[kn]||null;e:switch(r=i.stateNode,i.type){case"input":if(hd(r,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name),i=d.name,d.type==="radio"&&i!=null){for(d=r;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll('input[name="'+Yn(""+i)+'"][type="radio"]'),i=0;i<d.length;i++){var g=d[i];if(g!==r&&g.form===r.form){var C=g[kn]||null;if(!C)throw Error(s(90));hd(g,C.value,C.defaultValue,C.defaultValue,C.checked,C.defaultChecked,C.type,C.name)}}for(i=0;i<d.length;i++)g=d[i],g.form===r.form&&dg(g)}break e;case"textarea":fg(r,d.value,d.defaultValue);break e;case"select":i=d.value,i!=null&&Fi(r,!!d.multiple,i,!1)}}}var xd=!1;function _g(r,i,d){if(xd)return r(i,d);xd=!0;try{var g=r(i);return g}finally{if(xd=!1,(Gi!==null||Wi!==null)&&(xc(),Gi&&(i=Gi,r=Wi,Wi=Gi=null,xg(i),r)))for(i=0;i<r.length;i++)xg(r[i])}}function Xa(r,i){var d=r.stateNode;if(d===null)return null;var g=d[kn]||null;if(g===null)return null;d=g[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(r=r.type,g=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!g;break e;default:r=!1}if(r)return null;if(d&&typeof d!="function")throw Error(s(231,i,typeof d));return d}var zr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_d=!1;if(zr)try{var Qa={};Object.defineProperty(Qa,"passive",{get:function(){_d=!0}}),window.addEventListener("test",Qa,Qa),window.removeEventListener("test",Qa,Qa)}catch{_d=!1}var fs=null,yd=null,Ll=null;function yg(){if(Ll)return Ll;var r,i=yd,d=i.length,g,C="value"in fs?fs.value:fs.textContent,j=C.length;for(r=0;r<d&&i[r]===C[r];r++);var I=d-r;for(g=1;g<=I&&i[d-g]===C[j-g];g++);return Ll=C.slice(r,1<g?1-g:void 0)}function Dl(r){var i=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&i===13&&(r=13)):r=i,r===10&&(r=13),32<=r||r===13?r:0}function Rl(){return!0}function vg(){return!1}function En(r){function i(d,g,C,j,I){this._reactName=d,this._targetInst=C,this.type=g,this.nativeEvent=j,this.target=I,this.currentTarget=null;for(var K in r)r.hasOwnProperty(K)&&(d=r[K],this[K]=d?d(j):j[K]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?Rl:vg,this.isPropagationStopped=vg,this}return m(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=Rl)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=Rl)},persist:function(){},isPersistent:Rl}),i}var Qs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ol=En(Qs),Ja=m({},Qs,{view:0,detail:0}),YC=En(Ja),vd,bd,Za,Ml=m({},Ja,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wd,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==Za&&(Za&&r.type==="mousemove"?(vd=r.screenX-Za.screenX,bd=r.screenY-Za.screenY):bd=vd=0,Za=r),vd)},movementY:function(r){return"movementY"in r?r.movementY:bd}}),bg=En(Ml),XC=m({},Ml,{dataTransfer:0}),QC=En(XC),JC=m({},Ja,{relatedTarget:0}),Sd=En(JC),ZC=m({},Qs,{animationName:0,elapsedTime:0,pseudoElement:0}),ek=En(ZC),tk=m({},Qs,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),nk=En(tk),rk=m({},Qs,{data:0}),Sg=En(rk),sk={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ik={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"},ak={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ok(r){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(r):(r=ak[r])?!!i[r]:!1}function wd(){return ok}var lk=m({},Ja,{key:function(r){if(r.key){var i=sk[r.key]||r.key;if(i!=="Unidentified")return i}return r.type==="keypress"?(r=Dl(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?ik[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wd,charCode:function(r){return r.type==="keypress"?Dl(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Dl(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),ck=En(lk),uk=m({},Ml,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),wg=En(uk),dk=m({},Ja,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wd}),hk=En(dk),fk=m({},Qs,{propertyName:0,elapsedTime:0,pseudoElement:0}),mk=En(fk),pk=m({},Ml,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),gk=En(pk),xk=m({},Qs,{newState:0,oldState:0}),_k=En(xk),yk=[9,13,27,32],Cd=zr&&"CompositionEvent"in window,eo=null;zr&&"documentMode"in document&&(eo=document.documentMode);var vk=zr&&"TextEvent"in window&&!eo,Cg=zr&&(!Cd||eo&&8<eo&&11>=eo),kg=" ",Eg=!1;function jg(r,i){switch(r){case"keyup":return yk.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ng(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var qi=!1;function bk(r,i){switch(r){case"compositionend":return Ng(i);case"keypress":return i.which!==32?null:(Eg=!0,kg);case"textInput":return r=i.data,r===kg&&Eg?null:r;default:return null}}function Sk(r,i){if(qi)return r==="compositionend"||!Cd&&jg(r,i)?(r=yg(),Ll=yd=fs=null,qi=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return Cg&&i.locale!=="ko"?null:i.data;default:return null}}var wk={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 Tg(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i==="input"?!!wk[r.type]:i==="textarea"}function Ag(r,i,d,g){Gi?Wi?Wi.push(g):Wi=[g]:Gi=g,i=Cc(i,"onChange"),0<i.length&&(d=new Ol("onChange","change",null,d,g),r.push({event:d,listeners:i}))}var to=null,no=null;function Ck(r){hy(r,0)}function Il(r){var i=Ya(r);if(dg(i))return r}function Lg(r,i){if(r==="change")return i}var Dg=!1;if(zr){var kd;if(zr){var Ed="oninput"in document;if(!Ed){var Rg=document.createElement("div");Rg.setAttribute("oninput","return;"),Ed=typeof Rg.oninput=="function"}kd=Ed}else kd=!1;Dg=kd&&(!document.documentMode||9<document.documentMode)}function Og(){to&&(to.detachEvent("onpropertychange",Mg),no=to=null)}function Mg(r){if(r.propertyName==="value"&&Il(no)){var i=[];Ag(i,no,r,gd(r)),_g(Ck,i)}}function kk(r,i,d){r==="focusin"?(Og(),to=i,no=d,to.attachEvent("onpropertychange",Mg)):r==="focusout"&&Og()}function Ek(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Il(no)}function jk(r,i){if(r==="click")return Il(i)}function Nk(r,i){if(r==="input"||r==="change")return Il(i)}function Tk(r,i){return r===i&&(r!==0||1/r===1/i)||r!==r&&i!==i}var In=typeof Object.is=="function"?Object.is:Tk;function ro(r,i){if(In(r,i))return!0;if(typeof r!="object"||r===null||typeof i!="object"||i===null)return!1;var d=Object.keys(r),g=Object.keys(i);if(d.length!==g.length)return!1;for(g=0;g<d.length;g++){var C=d[g];if(!Se.call(i,C)||!In(r[C],i[C]))return!1}return!0}function Ig(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Pg(r,i){var d=Ig(r);r=0;for(var g;d;){if(d.nodeType===3){if(g=r+d.textContent.length,r<=i&&g>=i)return{node:d,offset:i-r};r=g}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=Ig(d)}}function Bg(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?Bg(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function zg(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var i=Tl(r.document);i instanceof r.HTMLIFrameElement;){try{var d=typeof i.contentWindow.location.href=="string"}catch{d=!1}if(d)r=i.contentWindow;else break;i=Tl(r.document)}return i}function jd(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i&&(i==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||i==="textarea"||r.contentEditable==="true")}var Ak=zr&&"documentMode"in document&&11>=document.documentMode,Ki=null,Nd=null,so=null,Td=!1;function Hg(r,i,d){var g=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Td||Ki==null||Ki!==Tl(g)||(g=Ki,"selectionStart"in g&&jd(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),so&&ro(so,g)||(so=g,g=Cc(Nd,"onSelect"),0<g.length&&(i=new Ol("onSelect","select",null,i,d),r.push({event:i,listeners:g}),i.target=Ki)))}function Js(r,i){var d={};return d[r.toLowerCase()]=i.toLowerCase(),d["Webkit"+r]="webkit"+i,d["Moz"+r]="moz"+i,d}var Yi={animationend:Js("Animation","AnimationEnd"),animationiteration:Js("Animation","AnimationIteration"),animationstart:Js("Animation","AnimationStart"),transitionrun:Js("Transition","TransitionRun"),transitionstart:Js("Transition","TransitionStart"),transitioncancel:Js("Transition","TransitionCancel"),transitionend:Js("Transition","TransitionEnd")},Ad={},$g={};zr&&($g=document.createElement("div").style,"AnimationEvent"in window||(delete Yi.animationend.animation,delete Yi.animationiteration.animation,delete Yi.animationstart.animation),"TransitionEvent"in window||delete Yi.transitionend.transition);function Zs(r){if(Ad[r])return Ad[r];if(!Yi[r])return r;var i=Yi[r],d;for(d in i)if(i.hasOwnProperty(d)&&d in $g)return Ad[r]=i[d];return r}var Ug=Zs("animationend"),Fg=Zs("animationiteration"),Vg=Zs("animationstart"),Lk=Zs("transitionrun"),Dk=Zs("transitionstart"),Rk=Zs("transitioncancel"),Gg=Zs("transitionend"),Wg=new Map,Ld="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Ld.push("scrollEnd");function hr(r,i){Wg.set(r,i),Xs(i,[r])}var Pl=typeof reportError=="function"?reportError:function(r){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var i=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof r=="object"&&r!==null&&typeof r.message=="string"?String(r.message):String(r),error:r});if(!window.dispatchEvent(i))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",r);return}console.error(r)},Xn=[],Xi=0,Dd=0;function Bl(){for(var r=Xi,i=Dd=Xi=0;i<r;){var d=Xn[i];Xn[i++]=null;var g=Xn[i];Xn[i++]=null;var C=Xn[i];Xn[i++]=null;var j=Xn[i];if(Xn[i++]=null,g!==null&&C!==null){var I=g.pending;I===null?C.next=C:(C.next=I.next,I.next=C),g.pending=C}j!==0&&qg(d,C,j)}}function zl(r,i,d,g){Xn[Xi++]=r,Xn[Xi++]=i,Xn[Xi++]=d,Xn[Xi++]=g,Dd|=g,r.lanes|=g,r=r.alternate,r!==null&&(r.lanes|=g)}function Rd(r,i,d,g){return zl(r,i,d,g),Hl(r)}function ei(r,i){return zl(r,null,null,i),Hl(r)}function qg(r,i,d){r.lanes|=d;var g=r.alternate;g!==null&&(g.lanes|=d);for(var C=!1,j=r.return;j!==null;)j.childLanes|=d,g=j.alternate,g!==null&&(g.childLanes|=d),j.tag===22&&(r=j.stateNode,r===null||r._visibility&1||(C=!0)),r=j,j=j.return;return r.tag===3?(j=r.stateNode,C&&i!==null&&(C=31-He(d),r=j.hiddenUpdates,g=r[C],g===null?r[C]=[i]:g.push(i),i.lane=d|536870912),j):null}function Hl(r){if(50<jo)throw jo=0,Uh=null,Error(s(185));for(var i=r.return;i!==null;)r=i,i=r.return;return r.tag===3?r.stateNode:null}var Qi={};function Ok(r,i,d,g){this.tag=r,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pn(r,i,d,g){return new Ok(r,i,d,g)}function Od(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Hr(r,i){var d=r.alternate;return d===null?(d=Pn(r.tag,i,r.key,r.mode),d.elementType=r.elementType,d.type=r.type,d.stateNode=r.stateNode,d.alternate=r,r.alternate=d):(d.pendingProps=i,d.type=r.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=r.flags&65011712,d.childLanes=r.childLanes,d.lanes=r.lanes,d.child=r.child,d.memoizedProps=r.memoizedProps,d.memoizedState=r.memoizedState,d.updateQueue=r.updateQueue,i=r.dependencies,d.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},d.sibling=r.sibling,d.index=r.index,d.ref=r.ref,d.refCleanup=r.refCleanup,d}function Kg(r,i){r.flags&=65011714;var d=r.alternate;return d===null?(r.childLanes=0,r.lanes=i,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=d.childLanes,r.lanes=d.lanes,r.child=d.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=d.memoizedProps,r.memoizedState=d.memoizedState,r.updateQueue=d.updateQueue,r.type=d.type,i=d.dependencies,r.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),r}function $l(r,i,d,g,C,j){var I=0;if(g=r,typeof r=="function")Od(r)&&(I=1);else if(typeof r=="string")I=zE(r,d,J.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case D:return r=Pn(31,d,i,C),r.elementType=D,r.lanes=j,r;case k:return ti(d.children,C,j,i);case y:I=8,C|=24;break;case S:return r=Pn(12,d,i,C|2),r.elementType=S,r.lanes=j,r;case T:return r=Pn(13,d,i,C),r.elementType=T,r.lanes=j,r;case N:return r=Pn(19,d,i,C),r.elementType=N,r.lanes=j,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case b:I=10;break e;case v:I=9;break e;case E:I=11;break e;case L:I=14;break e;case A:I=16,g=null;break e}I=29,d=Error(s(130,r===null?"null":typeof r,"")),g=null}return i=Pn(I,d,i,C),i.elementType=r,i.type=g,i.lanes=j,i}function ti(r,i,d,g){return r=Pn(7,r,g,i),r.lanes=d,r}function Md(r,i,d){return r=Pn(6,r,null,i),r.lanes=d,r}function Yg(r){var i=Pn(18,null,null,0);return i.stateNode=r,i}function Id(r,i,d){return i=Pn(4,r.children!==null?r.children:[],r.key,i),i.lanes=d,i.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},i}var Xg=new WeakMap;function Qn(r,i){if(typeof r=="object"&&r!==null){var d=Xg.get(r);return d!==void 0?d:(i={value:r,source:i,stack:Ie(i)},Xg.set(r,i),i)}return{value:r,source:i,stack:Ie(i)}}var Ji=[],Zi=0,Ul=null,io=0,Jn=[],Zn=0,ms=null,Cr=1,kr="";function $r(r,i){Ji[Zi++]=io,Ji[Zi++]=Ul,Ul=r,io=i}function Qg(r,i,d){Jn[Zn++]=Cr,Jn[Zn++]=kr,Jn[Zn++]=ms,ms=r;var g=Cr;r=kr;var C=32-He(g)-1;g&=~(1<<C),d+=1;var j=32-He(i)+C;if(30<j){var I=C-C%5;j=(g&(1<<I)-1).toString(32),g>>=I,C-=I,Cr=1<<32-He(i)+C|d<<C|g,kr=j+r}else Cr=1<<j|d<<C|g,kr=r}function Pd(r){r.return!==null&&($r(r,1),Qg(r,1,0))}function Bd(r){for(;r===Ul;)Ul=Ji[--Zi],Ji[Zi]=null,io=Ji[--Zi],Ji[Zi]=null;for(;r===ms;)ms=Jn[--Zn],Jn[Zn]=null,kr=Jn[--Zn],Jn[Zn]=null,Cr=Jn[--Zn],Jn[Zn]=null}function Jg(r,i){Jn[Zn++]=Cr,Jn[Zn++]=kr,Jn[Zn++]=ms,Cr=i.id,kr=i.overflow,ms=r}var fn=null,Rt=null,lt=!1,ps=null,er=!1,zd=Error(s(519));function gs(r){var i=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ao(Qn(i,r)),zd}function Zg(r){var i=r.stateNode,d=r.type,g=r.memoizedProps;switch(i[xt]=r,i[kn]=g,d){case"dialog":st("cancel",i),st("close",i);break;case"iframe":case"object":case"embed":st("load",i);break;case"video":case"audio":for(d=0;d<To.length;d++)st(To[d],i);break;case"source":st("error",i);break;case"img":case"image":case"link":st("error",i),st("load",i);break;case"details":st("toggle",i);break;case"input":st("invalid",i),hg(i,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0);break;case"select":st("invalid",i);break;case"textarea":st("invalid",i),mg(i,g.value,g.defaultValue,g.children)}d=g.children,typeof d!="string"&&typeof d!="number"&&typeof d!="bigint"||i.textContent===""+d||g.suppressHydrationWarning===!0||gy(i.textContent,d)?(g.popover!=null&&(st("beforetoggle",i),st("toggle",i)),g.onScroll!=null&&st("scroll",i),g.onScrollEnd!=null&&st("scrollend",i),g.onClick!=null&&(i.onclick=Br),i=!0):i=!1,i||gs(r,!0)}function ex(r){for(fn=r.return;fn;)switch(fn.tag){case 5:case 31:case 13:er=!1;return;case 27:case 3:er=!0;return;default:fn=fn.return}}function ea(r){if(r!==fn)return!1;if(!lt)return ex(r),lt=!0,!1;var i=r.tag,d;if((d=i!==3&&i!==27)&&((d=i===5)&&(d=r.type,d=!(d!=="form"&&d!=="button")||rf(r.type,r.memoizedProps)),d=!d),d&&Rt&&gs(r),ex(r),i===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));Rt=ky(r)}else if(i===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));Rt=ky(r)}else i===27?(i=Rt,As(r.type)?(r=cf,cf=null,Rt=r):Rt=i):Rt=fn?nr(r.stateNode.nextSibling):null;return!0}function ni(){Rt=fn=null,lt=!1}function Hd(){var r=ps;return r!==null&&(An===null?An=r:An.push.apply(An,r),ps=null),r}function ao(r){ps===null?ps=[r]:ps.push(r)}var $d=$(null),ri=null,Ur=null;function xs(r,i,d){U($d,i._currentValue),i._currentValue=d}function Fr(r){r._currentValue=$d.current,P($d)}function Ud(r,i,d){for(;r!==null;){var g=r.alternate;if((r.childLanes&i)!==i?(r.childLanes|=i,g!==null&&(g.childLanes|=i)):g!==null&&(g.childLanes&i)!==i&&(g.childLanes|=i),r===d)break;r=r.return}}function Fd(r,i,d,g){var C=r.child;for(C!==null&&(C.return=r);C!==null;){var j=C.dependencies;if(j!==null){var I=C.child;j=j.firstContext;e:for(;j!==null;){var K=j;j=C;for(var re=0;re<i.length;re++)if(K.context===i[re]){j.lanes|=d,K=j.alternate,K!==null&&(K.lanes|=d),Ud(j.return,d,r),g||(I=null);break e}j=K.next}}else if(C.tag===18){if(I=C.return,I===null)throw Error(s(341));I.lanes|=d,j=I.alternate,j!==null&&(j.lanes|=d),Ud(I,d,r),I=null}else I=C.child;if(I!==null)I.return=C;else for(I=C;I!==null;){if(I===r){I=null;break}if(C=I.sibling,C!==null){C.return=I.return,I=C;break}I=I.return}C=I}}function ta(r,i,d,g){r=null;for(var C=i,j=!1;C!==null;){if(!j){if((C.flags&524288)!==0)j=!0;else if((C.flags&262144)!==0)break}if(C.tag===10){var I=C.alternate;if(I===null)throw Error(s(387));if(I=I.memoizedProps,I!==null){var K=C.type;In(C.pendingProps.value,I.value)||(r!==null?r.push(K):r=[K])}}else if(C===Y.current){if(I=C.alternate,I===null)throw Error(s(387));I.memoizedState.memoizedState!==C.memoizedState.memoizedState&&(r!==null?r.push(Oo):r=[Oo])}C=C.return}r!==null&&Fd(i,r,d,g),i.flags|=262144}function Fl(r){for(r=r.firstContext;r!==null;){if(!In(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function si(r){ri=r,Ur=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function mn(r){return tx(ri,r)}function Vl(r,i){return ri===null&&si(r),tx(r,i)}function tx(r,i){var d=i._currentValue;if(i={context:i,memoizedValue:d,next:null},Ur===null){if(r===null)throw Error(s(308));Ur=i,r.dependencies={lanes:0,firstContext:i},r.flags|=524288}else Ur=Ur.next=i;return d}var Mk=typeof AbortController<"u"?AbortController:function(){var r=[],i=this.signal={aborted:!1,addEventListener:function(d,g){r.push(g)}};this.abort=function(){i.aborted=!0,r.forEach(function(d){return d()})}},Ik=e.unstable_scheduleCallback,Pk=e.unstable_NormalPriority,qt={$$typeof:b,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Vd(){return{controller:new Mk,data:new Map,refCount:0}}function oo(r){r.refCount--,r.refCount===0&&Ik(Pk,function(){r.controller.abort()})}var lo=null,Gd=0,na=0,ra=null;function Bk(r,i){if(lo===null){var d=lo=[];Gd=0,na=Kh(),ra={status:"pending",value:void 0,then:function(g){d.push(g)}}}return Gd++,i.then(nx,nx),i}function nx(){if(--Gd===0&&lo!==null){ra!==null&&(ra.status="fulfilled");var r=lo;lo=null,na=0,ra=null;for(var i=0;i<r.length;i++)(0,r[i])()}}function zk(r,i){var d=[],g={status:"pending",value:null,reason:null,then:function(C){d.push(C)}};return r.then(function(){g.status="fulfilled",g.value=i;for(var C=0;C<d.length;C++)(0,d[C])(i)},function(C){for(g.status="rejected",g.reason=C,C=0;C<d.length;C++)(0,d[C])(void 0)}),g}var rx=z.S;z.S=function(r,i){H_=gt(),typeof i=="object"&&i!==null&&typeof i.then=="function"&&Bk(r,i),rx!==null&&rx(r,i)};var ii=$(null);function Wd(){var r=ii.current;return r!==null?r:kt.pooledCache}function Gl(r,i){i===null?U(ii,ii.current):U(ii,i.pool)}function sx(){var r=Wd();return r===null?null:{parent:qt._currentValue,pool:r}}var sa=Error(s(460)),qd=Error(s(474)),Wl=Error(s(542)),ql={then:function(){}};function ix(r){return r=r.status,r==="fulfilled"||r==="rejected"}function ax(r,i,d){switch(d=r[d],d===void 0?r.push(i):d!==i&&(i.then(Br,Br),i=d),i.status){case"fulfilled":return i.value;case"rejected":throw r=i.reason,lx(r),r;default:if(typeof i.status=="string")i.then(Br,Br);else{if(r=kt,r!==null&&100<r.shellSuspendCounter)throw Error(s(482));r=i,r.status="pending",r.then(function(g){if(i.status==="pending"){var C=i;C.status="fulfilled",C.value=g}},function(g){if(i.status==="pending"){var C=i;C.status="rejected",C.reason=g}})}switch(i.status){case"fulfilled":return i.value;case"rejected":throw r=i.reason,lx(r),r}throw oi=i,sa}}function ai(r){try{var i=r._init;return i(r._payload)}catch(d){throw d!==null&&typeof d=="object"&&typeof d.then=="function"?(oi=d,sa):d}}var oi=null;function ox(){if(oi===null)throw Error(s(459));var r=oi;return oi=null,r}function lx(r){if(r===sa||r===Wl)throw Error(s(483))}var ia=null,co=0;function Kl(r){var i=co;return co+=1,ia===null&&(ia=[]),ax(ia,r,i)}function uo(r,i){i=i.props.ref,r.ref=i!==void 0?i:null}function Yl(r,i){throw i.$$typeof===_?Error(s(525)):(r=Object.prototype.toString.call(i),Error(s(31,r==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":r)))}function cx(r){function i(ae,ie){if(r){var oe=ae.deletions;oe===null?(ae.deletions=[ie],ae.flags|=16):oe.push(ie)}}function d(ae,ie){if(!r)return null;for(;ie!==null;)i(ae,ie),ie=ie.sibling;return null}function g(ae){for(var ie=new Map;ae!==null;)ae.key!==null?ie.set(ae.key,ae):ie.set(ae.index,ae),ae=ae.sibling;return ie}function C(ae,ie){return ae=Hr(ae,ie),ae.index=0,ae.sibling=null,ae}function j(ae,ie,oe){return ae.index=oe,r?(oe=ae.alternate,oe!==null?(oe=oe.index,oe<ie?(ae.flags|=67108866,ie):oe):(ae.flags|=67108866,ie)):(ae.flags|=1048576,ie)}function I(ae){return r&&ae.alternate===null&&(ae.flags|=67108866),ae}function K(ae,ie,oe,ve){return ie===null||ie.tag!==6?(ie=Md(oe,ae.mode,ve),ie.return=ae,ie):(ie=C(ie,oe),ie.return=ae,ie)}function re(ae,ie,oe,ve){var Be=oe.type;return Be===k?xe(ae,ie,oe.props.children,ve,oe.key):ie!==null&&(ie.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===A&&ai(Be)===ie.type)?(ie=C(ie,oe.props),uo(ie,oe),ie.return=ae,ie):(ie=$l(oe.type,oe.key,oe.props,null,ae.mode,ve),uo(ie,oe),ie.return=ae,ie)}function le(ae,ie,oe,ve){return ie===null||ie.tag!==4||ie.stateNode.containerInfo!==oe.containerInfo||ie.stateNode.implementation!==oe.implementation?(ie=Id(oe,ae.mode,ve),ie.return=ae,ie):(ie=C(ie,oe.children||[]),ie.return=ae,ie)}function xe(ae,ie,oe,ve,Be){return ie===null||ie.tag!==7?(ie=ti(oe,ae.mode,ve,Be),ie.return=ae,ie):(ie=C(ie,oe),ie.return=ae,ie)}function be(ae,ie,oe){if(typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint")return ie=Md(""+ie,ae.mode,oe),ie.return=ae,ie;if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case x:return oe=$l(ie.type,ie.key,ie.props,null,ae.mode,oe),uo(oe,ie),oe.return=ae,oe;case w:return ie=Id(ie,ae.mode,oe),ie.return=ae,ie;case A:return ie=ai(ie),be(ae,ie,oe)}if(G(ie)||W(ie))return ie=ti(ie,ae.mode,oe,null),ie.return=ae,ie;if(typeof ie.then=="function")return be(ae,Kl(ie),oe);if(ie.$$typeof===b)return be(ae,Vl(ae,ie),oe);Yl(ae,ie)}return null}function ue(ae,ie,oe,ve){var Be=ie!==null?ie.key:null;if(typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint")return Be!==null?null:K(ae,ie,""+oe,ve);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case x:return oe.key===Be?re(ae,ie,oe,ve):null;case w:return oe.key===Be?le(ae,ie,oe,ve):null;case A:return oe=ai(oe),ue(ae,ie,oe,ve)}if(G(oe)||W(oe))return Be!==null?null:xe(ae,ie,oe,ve,null);if(typeof oe.then=="function")return ue(ae,ie,Kl(oe),ve);if(oe.$$typeof===b)return ue(ae,ie,Vl(ae,oe),ve);Yl(ae,oe)}return null}function fe(ae,ie,oe,ve,Be){if(typeof ve=="string"&&ve!==""||typeof ve=="number"||typeof ve=="bigint")return ae=ae.get(oe)||null,K(ie,ae,""+ve,Be);if(typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case x:return ae=ae.get(ve.key===null?oe:ve.key)||null,re(ie,ae,ve,Be);case w:return ae=ae.get(ve.key===null?oe:ve.key)||null,le(ie,ae,ve,Be);case A:return ve=ai(ve),fe(ae,ie,oe,ve,Be)}if(G(ve)||W(ve))return ae=ae.get(oe)||null,xe(ie,ae,ve,Be,null);if(typeof ve.then=="function")return fe(ae,ie,oe,Kl(ve),Be);if(ve.$$typeof===b)return fe(ae,ie,oe,Vl(ie,ve),Be);Yl(ie,ve)}return null}function Re(ae,ie,oe,ve){for(var Be=null,ht=null,Me=ie,Qe=ie=0,ot=null;Me!==null&&Qe<oe.length;Qe++){Me.index>Qe?(ot=Me,Me=null):ot=Me.sibling;var ft=ue(ae,Me,oe[Qe],ve);if(ft===null){Me===null&&(Me=ot);break}r&&Me&&ft.alternate===null&&i(ae,Me),ie=j(ft,ie,Qe),ht===null?Be=ft:ht.sibling=ft,ht=ft,Me=ot}if(Qe===oe.length)return d(ae,Me),lt&&$r(ae,Qe),Be;if(Me===null){for(;Qe<oe.length;Qe++)Me=be(ae,oe[Qe],ve),Me!==null&&(ie=j(Me,ie,Qe),ht===null?Be=Me:ht.sibling=Me,ht=Me);return lt&&$r(ae,Qe),Be}for(Me=g(Me);Qe<oe.length;Qe++)ot=fe(Me,ae,Qe,oe[Qe],ve),ot!==null&&(r&&ot.alternate!==null&&Me.delete(ot.key===null?Qe:ot.key),ie=j(ot,ie,Qe),ht===null?Be=ot:ht.sibling=ot,ht=ot);return r&&Me.forEach(function(Ms){return i(ae,Ms)}),lt&&$r(ae,Qe),Be}function Fe(ae,ie,oe,ve){if(oe==null)throw Error(s(151));for(var Be=null,ht=null,Me=ie,Qe=ie=0,ot=null,ft=oe.next();Me!==null&&!ft.done;Qe++,ft=oe.next()){Me.index>Qe?(ot=Me,Me=null):ot=Me.sibling;var Ms=ue(ae,Me,ft.value,ve);if(Ms===null){Me===null&&(Me=ot);break}r&&Me&&Ms.alternate===null&&i(ae,Me),ie=j(Ms,ie,Qe),ht===null?Be=Ms:ht.sibling=Ms,ht=Ms,Me=ot}if(ft.done)return d(ae,Me),lt&&$r(ae,Qe),Be;if(Me===null){for(;!ft.done;Qe++,ft=oe.next())ft=be(ae,ft.value,ve),ft!==null&&(ie=j(ft,ie,Qe),ht===null?Be=ft:ht.sibling=ft,ht=ft);return lt&&$r(ae,Qe),Be}for(Me=g(Me);!ft.done;Qe++,ft=oe.next())ft=fe(Me,ae,Qe,ft.value,ve),ft!==null&&(r&&ft.alternate!==null&&Me.delete(ft.key===null?Qe:ft.key),ie=j(ft,ie,Qe),ht===null?Be=ft:ht.sibling=ft,ht=ft);return r&&Me.forEach(function(XE){return i(ae,XE)}),lt&&$r(ae,Qe),Be}function Ct(ae,ie,oe,ve){if(typeof oe=="object"&&oe!==null&&oe.type===k&&oe.key===null&&(oe=oe.props.children),typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case x:e:{for(var Be=oe.key;ie!==null;){if(ie.key===Be){if(Be=oe.type,Be===k){if(ie.tag===7){d(ae,ie.sibling),ve=C(ie,oe.props.children),ve.return=ae,ae=ve;break e}}else if(ie.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===A&&ai(Be)===ie.type){d(ae,ie.sibling),ve=C(ie,oe.props),uo(ve,oe),ve.return=ae,ae=ve;break e}d(ae,ie);break}else i(ae,ie);ie=ie.sibling}oe.type===k?(ve=ti(oe.props.children,ae.mode,ve,oe.key),ve.return=ae,ae=ve):(ve=$l(oe.type,oe.key,oe.props,null,ae.mode,ve),uo(ve,oe),ve.return=ae,ae=ve)}return I(ae);case w:e:{for(Be=oe.key;ie!==null;){if(ie.key===Be)if(ie.tag===4&&ie.stateNode.containerInfo===oe.containerInfo&&ie.stateNode.implementation===oe.implementation){d(ae,ie.sibling),ve=C(ie,oe.children||[]),ve.return=ae,ae=ve;break e}else{d(ae,ie);break}else i(ae,ie);ie=ie.sibling}ve=Id(oe,ae.mode,ve),ve.return=ae,ae=ve}return I(ae);case A:return oe=ai(oe),Ct(ae,ie,oe,ve)}if(G(oe))return Re(ae,ie,oe,ve);if(W(oe)){if(Be=W(oe),typeof Be!="function")throw Error(s(150));return oe=Be.call(oe),Fe(ae,ie,oe,ve)}if(typeof oe.then=="function")return Ct(ae,ie,Kl(oe),ve);if(oe.$$typeof===b)return Ct(ae,ie,Vl(ae,oe),ve);Yl(ae,oe)}return typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint"?(oe=""+oe,ie!==null&&ie.tag===6?(d(ae,ie.sibling),ve=C(ie,oe),ve.return=ae,ae=ve):(d(ae,ie),ve=Md(oe,ae.mode,ve),ve.return=ae,ae=ve),I(ae)):d(ae,ie)}return function(ae,ie,oe,ve){try{co=0;var Be=Ct(ae,ie,oe,ve);return ia=null,Be}catch(Me){if(Me===sa||Me===Wl)throw Me;var ht=Pn(29,Me,null,ae.mode);return ht.lanes=ve,ht.return=ae,ht}finally{}}}var li=cx(!0),ux=cx(!1),_s=!1;function Kd(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Yd(r,i){r=r.updateQueue,i.updateQueue===r&&(i.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function ys(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function vs(r,i,d){var g=r.updateQueue;if(g===null)return null;if(g=g.shared,(pt&2)!==0){var C=g.pending;return C===null?i.next=i:(i.next=C.next,C.next=i),g.pending=i,i=Hl(r),qg(r,null,d),i}return zl(r,g,i,d),Hl(r)}function ho(r,i,d){if(i=i.updateQueue,i!==null&&(i=i.shared,(d&4194048)!==0)){var g=i.lanes;g&=r.pendingLanes,d|=g,i.lanes=d,De(r,d)}}function Xd(r,i){var d=r.updateQueue,g=r.alternate;if(g!==null&&(g=g.updateQueue,d===g)){var C=null,j=null;if(d=d.firstBaseUpdate,d!==null){do{var I={lane:d.lane,tag:d.tag,payload:d.payload,callback:null,next:null};j===null?C=j=I:j=j.next=I,d=d.next}while(d!==null);j===null?C=j=i:j=j.next=i}else C=j=i;d={baseState:g.baseState,firstBaseUpdate:C,lastBaseUpdate:j,shared:g.shared,callbacks:g.callbacks},r.updateQueue=d;return}r=d.lastBaseUpdate,r===null?d.firstBaseUpdate=i:r.next=i,d.lastBaseUpdate=i}var Qd=!1;function fo(){if(Qd){var r=ra;if(r!==null)throw r}}function mo(r,i,d,g){Qd=!1;var C=r.updateQueue;_s=!1;var j=C.firstBaseUpdate,I=C.lastBaseUpdate,K=C.shared.pending;if(K!==null){C.shared.pending=null;var re=K,le=re.next;re.next=null,I===null?j=le:I.next=le,I=re;var xe=r.alternate;xe!==null&&(xe=xe.updateQueue,K=xe.lastBaseUpdate,K!==I&&(K===null?xe.firstBaseUpdate=le:K.next=le,xe.lastBaseUpdate=re))}if(j!==null){var be=C.baseState;I=0,xe=le=re=null,K=j;do{var ue=K.lane&-536870913,fe=ue!==K.lane;if(fe?(at&ue)===ue:(g&ue)===ue){ue!==0&&ue===na&&(Qd=!0),xe!==null&&(xe=xe.next={lane:0,tag:K.tag,payload:K.payload,callback:null,next:null});e:{var Re=r,Fe=K;ue=i;var Ct=d;switch(Fe.tag){case 1:if(Re=Fe.payload,typeof Re=="function"){be=Re.call(Ct,be,ue);break e}be=Re;break e;case 3:Re.flags=Re.flags&-65537|128;case 0:if(Re=Fe.payload,ue=typeof Re=="function"?Re.call(Ct,be,ue):Re,ue==null)break e;be=m({},be,ue);break e;case 2:_s=!0}}ue=K.callback,ue!==null&&(r.flags|=64,fe&&(r.flags|=8192),fe=C.callbacks,fe===null?C.callbacks=[ue]:fe.push(ue))}else fe={lane:ue,tag:K.tag,payload:K.payload,callback:K.callback,next:null},xe===null?(le=xe=fe,re=be):xe=xe.next=fe,I|=ue;if(K=K.next,K===null){if(K=C.shared.pending,K===null)break;fe=K,K=fe.next,fe.next=null,C.lastBaseUpdate=fe,C.shared.pending=null}}while(!0);xe===null&&(re=be),C.baseState=re,C.firstBaseUpdate=le,C.lastBaseUpdate=xe,j===null&&(C.shared.lanes=0),ks|=I,r.lanes=I,r.memoizedState=be}}function dx(r,i){if(typeof r!="function")throw Error(s(191,r));r.call(i)}function hx(r,i){var d=r.callbacks;if(d!==null)for(r.callbacks=null,r=0;r<d.length;r++)dx(d[r],i)}var aa=$(null),Xl=$(0);function fx(r,i){r=Jr,U(Xl,r),U(aa,i),Jr=r|i.baseLanes}function Jd(){U(Xl,Jr),U(aa,aa.current)}function Zd(){Jr=Xl.current,P(aa),P(Xl)}var Bn=$(null),tr=null;function bs(r){var i=r.alternate;U(Ft,Ft.current&1),U(Bn,r),tr===null&&(i===null||aa.current!==null||i.memoizedState!==null)&&(tr=r)}function eh(r){U(Ft,Ft.current),U(Bn,r),tr===null&&(tr=r)}function mx(r){r.tag===22?(U(Ft,Ft.current),U(Bn,r),tr===null&&(tr=r)):Ss()}function Ss(){U(Ft,Ft.current),U(Bn,Bn.current)}function zn(r){P(Bn),tr===r&&(tr=null),P(Ft)}var Ft=$(0);function Ql(r){for(var i=r;i!==null;){if(i.tag===13){var d=i.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||of(d)||lf(d)))return i}else if(i.tag===19&&(i.memoizedProps.revealOrder==="forwards"||i.memoizedProps.revealOrder==="backwards"||i.memoizedProps.revealOrder==="unstable_legacy-backwards"||i.memoizedProps.revealOrder==="together")){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var Vr=0,Ye=null,St=null,Kt=null,Jl=!1,oa=!1,ci=!1,Zl=0,po=0,la=null,Hk=0;function Ht(){throw Error(s(321))}function th(r,i){if(i===null)return!1;for(var d=0;d<i.length&&d<r.length;d++)if(!In(r[d],i[d]))return!1;return!0}function nh(r,i,d,g,C,j){return Vr=j,Ye=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,z.H=r===null||r.memoizedState===null?Qx:xh,ci=!1,j=d(g,C),ci=!1,oa&&(j=gx(i,d,g,C)),px(r),j}function px(r){z.H=_o;var i=St!==null&&St.next!==null;if(Vr=0,Kt=St=Ye=null,Jl=!1,po=0,la=null,i)throw Error(s(300));r===null||Yt||(r=r.dependencies,r!==null&&Fl(r)&&(Yt=!0))}function gx(r,i,d,g){Ye=r;var C=0;do{if(oa&&(la=null),po=0,oa=!1,25<=C)throw Error(s(301));if(C+=1,Kt=St=null,r.updateQueue!=null){var j=r.updateQueue;j.lastEffect=null,j.events=null,j.stores=null,j.memoCache!=null&&(j.memoCache.index=0)}z.H=Jx,j=i(d,g)}while(oa);return j}function $k(){var r=z.H,i=r.useState()[0];return i=typeof i.then=="function"?go(i):i,r=r.useState()[0],(St!==null?St.memoizedState:null)!==r&&(Ye.flags|=1024),i}function rh(){var r=Zl!==0;return Zl=0,r}function sh(r,i,d){i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~d}function ih(r){if(Jl){for(r=r.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}Jl=!1}Vr=0,Kt=St=Ye=null,oa=!1,po=Zl=0,la=null}function Sn(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Kt===null?Ye.memoizedState=Kt=r:Kt=Kt.next=r,Kt}function Vt(){if(St===null){var r=Ye.alternate;r=r!==null?r.memoizedState:null}else r=St.next;var i=Kt===null?Ye.memoizedState:Kt.next;if(i!==null)Kt=i,St=r;else{if(r===null)throw Ye.alternate===null?Error(s(467)):Error(s(310));St=r,r={memoizedState:St.memoizedState,baseState:St.baseState,baseQueue:St.baseQueue,queue:St.queue,next:null},Kt===null?Ye.memoizedState=Kt=r:Kt=Kt.next=r}return Kt}function ec(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function go(r){var i=po;return po+=1,la===null&&(la=[]),r=ax(la,r,i),i=Ye,(Kt===null?i.memoizedState:Kt.next)===null&&(i=i.alternate,z.H=i===null||i.memoizedState===null?Qx:xh),r}function tc(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return go(r);if(r.$$typeof===b)return mn(r)}throw Error(s(438,String(r)))}function ah(r){var i=null,d=Ye.updateQueue;if(d!==null&&(i=d.memoCache),i==null){var g=Ye.alternate;g!==null&&(g=g.updateQueue,g!==null&&(g=g.memoCache,g!=null&&(i={data:g.data.map(function(C){return C.slice()}),index:0})))}if(i==null&&(i={data:[],index:0}),d===null&&(d=ec(),Ye.updateQueue=d),d.memoCache=i,d=i.data[i.index],d===void 0)for(d=i.data[i.index]=Array(r),g=0;g<r;g++)d[g]=B;return i.index++,d}function Gr(r,i){return typeof i=="function"?i(r):i}function nc(r){var i=Vt();return oh(i,St,r)}function oh(r,i,d){var g=r.queue;if(g===null)throw Error(s(311));g.lastRenderedReducer=d;var C=r.baseQueue,j=g.pending;if(j!==null){if(C!==null){var I=C.next;C.next=j.next,j.next=I}i.baseQueue=C=j,g.pending=null}if(j=r.baseState,C===null)r.memoizedState=j;else{i=C.next;var K=I=null,re=null,le=i,xe=!1;do{var be=le.lane&-536870913;if(be!==le.lane?(at&be)===be:(Vr&be)===be){var ue=le.revertLane;if(ue===0)re!==null&&(re=re.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),be===na&&(xe=!0);else if((Vr&ue)===ue){le=le.next,ue===na&&(xe=!0);continue}else be={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},re===null?(K=re=be,I=j):re=re.next=be,Ye.lanes|=ue,ks|=ue;be=le.action,ci&&d(j,be),j=le.hasEagerState?le.eagerState:d(j,be)}else ue={lane:be,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},re===null?(K=re=ue,I=j):re=re.next=ue,Ye.lanes|=be,ks|=be;le=le.next}while(le!==null&&le!==i);if(re===null?I=j:re.next=K,!In(j,r.memoizedState)&&(Yt=!0,xe&&(d=ra,d!==null)))throw d;r.memoizedState=j,r.baseState=I,r.baseQueue=re,g.lastRenderedState=j}return C===null&&(g.lanes=0),[r.memoizedState,g.dispatch]}function lh(r){var i=Vt(),d=i.queue;if(d===null)throw Error(s(311));d.lastRenderedReducer=r;var g=d.dispatch,C=d.pending,j=i.memoizedState;if(C!==null){d.pending=null;var I=C=C.next;do j=r(j,I.action),I=I.next;while(I!==C);In(j,i.memoizedState)||(Yt=!0),i.memoizedState=j,i.baseQueue===null&&(i.baseState=j),d.lastRenderedState=j}return[j,g]}function xx(r,i,d){var g=Ye,C=Vt(),j=lt;if(j){if(d===void 0)throw Error(s(407));d=d()}else d=i();var I=!In((St||C).memoizedState,d);if(I&&(C.memoizedState=d,Yt=!0),C=C.queue,dh(vx.bind(null,g,C,r),[r]),C.getSnapshot!==i||I||Kt!==null&&Kt.memoizedState.tag&1){if(g.flags|=2048,ca(9,{destroy:void 0},yx.bind(null,g,C,d,i),null),kt===null)throw Error(s(349));j||(Vr&127)!==0||_x(g,i,d)}return d}function _x(r,i,d){r.flags|=16384,r={getSnapshot:i,value:d},i=Ye.updateQueue,i===null?(i=ec(),Ye.updateQueue=i,i.stores=[r]):(d=i.stores,d===null?i.stores=[r]:d.push(r))}function yx(r,i,d,g){i.value=d,i.getSnapshot=g,bx(i)&&Sx(r)}function vx(r,i,d){return d(function(){bx(i)&&Sx(r)})}function bx(r){var i=r.getSnapshot;r=r.value;try{var d=i();return!In(r,d)}catch{return!0}}function Sx(r){var i=ei(r,2);i!==null&&Ln(i,r,2)}function ch(r){var i=Sn();if(typeof r=="function"){var d=r;if(r=d(),ci){en(!0);try{d()}finally{en(!1)}}}return i.memoizedState=i.baseState=r,i.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gr,lastRenderedState:r},i}function wx(r,i,d,g){return r.baseState=d,oh(r,St,typeof g=="function"?g:Gr)}function Uk(r,i,d,g,C){if(ic(r))throw Error(s(485));if(r=i.action,r!==null){var j={payload:C,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(I){j.listeners.push(I)}};z.T!==null?d(!0):j.isTransition=!1,g(j),d=i.pending,d===null?(j.next=i.pending=j,Cx(i,j)):(j.next=d.next,i.pending=d.next=j)}}function Cx(r,i){var d=i.action,g=i.payload,C=r.state;if(i.isTransition){var j=z.T,I={};z.T=I;try{var K=d(C,g),re=z.S;re!==null&&re(I,K),kx(r,i,K)}catch(le){uh(r,i,le)}finally{j!==null&&I.types!==null&&(j.types=I.types),z.T=j}}else try{j=d(C,g),kx(r,i,j)}catch(le){uh(r,i,le)}}function kx(r,i,d){d!==null&&typeof d=="object"&&typeof d.then=="function"?d.then(function(g){Ex(r,i,g)},function(g){return uh(r,i,g)}):Ex(r,i,d)}function Ex(r,i,d){i.status="fulfilled",i.value=d,jx(i),r.state=d,i=r.pending,i!==null&&(d=i.next,d===i?r.pending=null:(d=d.next,i.next=d,Cx(r,d)))}function uh(r,i,d){var g=r.pending;if(r.pending=null,g!==null){g=g.next;do i.status="rejected",i.reason=d,jx(i),i=i.next;while(i!==g)}r.action=null}function jx(r){r=r.listeners;for(var i=0;i<r.length;i++)(0,r[i])()}function Nx(r,i){return i}function Tx(r,i){if(lt){var d=kt.formState;if(d!==null){e:{var g=Ye;if(lt){if(Rt){t:{for(var C=Rt,j=er;C.nodeType!==8;){if(!j){C=null;break t}if(C=nr(C.nextSibling),C===null){C=null;break t}}j=C.data,C=j==="F!"||j==="F"?C:null}if(C){Rt=nr(C.nextSibling),g=C.data==="F!";break e}}gs(g)}g=!1}g&&(i=d[0])}}return d=Sn(),d.memoizedState=d.baseState=i,g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Nx,lastRenderedState:i},d.queue=g,d=Kx.bind(null,Ye,g),g.dispatch=d,g=ch(!1),j=gh.bind(null,Ye,!1,g.queue),g=Sn(),C={state:i,dispatch:null,action:r,pending:null},g.queue=C,d=Uk.bind(null,Ye,C,j,d),C.dispatch=d,g.memoizedState=r,[i,d,!1]}function Ax(r){var i=Vt();return Lx(i,St,r)}function Lx(r,i,d){if(i=oh(r,i,Nx)[0],r=nc(Gr)[0],typeof i=="object"&&i!==null&&typeof i.then=="function")try{var g=go(i)}catch(I){throw I===sa?Wl:I}else g=i;i=Vt();var C=i.queue,j=C.dispatch;return d!==i.memoizedState&&(Ye.flags|=2048,ca(9,{destroy:void 0},Fk.bind(null,C,d),null)),[g,j,r]}function Fk(r,i){r.action=i}function Dx(r){var i=Vt(),d=St;if(d!==null)return Lx(i,d,r);Vt(),i=i.memoizedState,d=Vt();var g=d.queue.dispatch;return d.memoizedState=r,[i,g,!1]}function ca(r,i,d,g){return r={tag:r,create:d,deps:g,inst:i,next:null},i=Ye.updateQueue,i===null&&(i=ec(),Ye.updateQueue=i),d=i.lastEffect,d===null?i.lastEffect=r.next=r:(g=d.next,d.next=r,r.next=g,i.lastEffect=r),r}function Rx(){return Vt().memoizedState}function rc(r,i,d,g){var C=Sn();Ye.flags|=r,C.memoizedState=ca(1|i,{destroy:void 0},d,g===void 0?null:g)}function sc(r,i,d,g){var C=Vt();g=g===void 0?null:g;var j=C.memoizedState.inst;St!==null&&g!==null&&th(g,St.memoizedState.deps)?C.memoizedState=ca(i,j,d,g):(Ye.flags|=r,C.memoizedState=ca(1|i,j,d,g))}function Ox(r,i){rc(8390656,8,r,i)}function dh(r,i){sc(2048,8,r,i)}function Vk(r){Ye.flags|=4;var i=Ye.updateQueue;if(i===null)i=ec(),Ye.updateQueue=i,i.events=[r];else{var d=i.events;d===null?i.events=[r]:d.push(r)}}function Mx(r){var i=Vt().memoizedState;return Vk({ref:i,nextImpl:r}),function(){if((pt&2)!==0)throw Error(s(440));return i.impl.apply(void 0,arguments)}}function Ix(r,i){return sc(4,2,r,i)}function Px(r,i){return sc(4,4,r,i)}function Bx(r,i){if(typeof i=="function"){r=r();var d=i(r);return function(){typeof d=="function"?d():i(null)}}if(i!=null)return r=r(),i.current=r,function(){i.current=null}}function zx(r,i,d){d=d!=null?d.concat([r]):null,sc(4,4,Bx.bind(null,i,r),d)}function hh(){}function Hx(r,i){var d=Vt();i=i===void 0?null:i;var g=d.memoizedState;return i!==null&&th(i,g[1])?g[0]:(d.memoizedState=[r,i],r)}function $x(r,i){var d=Vt();i=i===void 0?null:i;var g=d.memoizedState;if(i!==null&&th(i,g[1]))return g[0];if(g=r(),ci){en(!0);try{r()}finally{en(!1)}}return d.memoizedState=[g,i],g}function fh(r,i,d){return d===void 0||(Vr&1073741824)!==0&&(at&261930)===0?r.memoizedState=i:(r.memoizedState=d,r=U_(),Ye.lanes|=r,ks|=r,d)}function Ux(r,i,d,g){return In(d,i)?d:aa.current!==null?(r=fh(r,d,g),In(r,i)||(Yt=!0),r):(Vr&42)===0||(Vr&1073741824)!==0&&(at&261930)===0?(Yt=!0,r.memoizedState=d):(r=U_(),Ye.lanes|=r,ks|=r,i)}function Fx(r,i,d,g,C){var j=X.p;X.p=j!==0&&8>j?j:8;var I=z.T,K={};z.T=K,gh(r,!1,i,d);try{var re=C(),le=z.S;if(le!==null&&le(K,re),re!==null&&typeof re=="object"&&typeof re.then=="function"){var xe=zk(re,g);xo(r,i,xe,Un(r))}else xo(r,i,g,Un(r))}catch(be){xo(r,i,{then:function(){},status:"rejected",reason:be},Un())}finally{X.p=j,I!==null&&K.types!==null&&(I.types=K.types),z.T=I}}function Gk(){}function mh(r,i,d,g){if(r.tag!==5)throw Error(s(476));var C=Vx(r).queue;Fx(r,C,i,ne,d===null?Gk:function(){return Gx(r),d(g)})}function Vx(r){var i=r.memoizedState;if(i!==null)return i;i={memoizedState:ne,baseState:ne,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gr,lastRenderedState:ne},next:null};var d={};return i.next={memoizedState:d,baseState:d,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gr,lastRenderedState:d},next:null},r.memoizedState=i,r=r.alternate,r!==null&&(r.memoizedState=i),i}function Gx(r){var i=Vx(r);i.next===null&&(i=r.alternate.memoizedState),xo(r,i.next.queue,{},Un())}function ph(){return mn(Oo)}function Wx(){return Vt().memoizedState}function qx(){return Vt().memoizedState}function Wk(r){for(var i=r.return;i!==null;){switch(i.tag){case 24:case 3:var d=Un();r=ys(d);var g=vs(i,r,d);g!==null&&(Ln(g,i,d),ho(g,i,d)),i={cache:Vd()},r.payload=i;return}i=i.return}}function qk(r,i,d){var g=Un();d={lane:g,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},ic(r)?Yx(i,d):(d=Rd(r,i,d,g),d!==null&&(Ln(d,r,g),Xx(d,i,g)))}function Kx(r,i,d){var g=Un();xo(r,i,d,g)}function xo(r,i,d,g){var C={lane:g,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null};if(ic(r))Yx(i,C);else{var j=r.alternate;if(r.lanes===0&&(j===null||j.lanes===0)&&(j=i.lastRenderedReducer,j!==null))try{var I=i.lastRenderedState,K=j(I,d);if(C.hasEagerState=!0,C.eagerState=K,In(K,I))return zl(r,i,C,0),kt===null&&Bl(),!1}catch{}finally{}if(d=Rd(r,i,C,g),d!==null)return Ln(d,r,g),Xx(d,i,g),!0}return!1}function gh(r,i,d,g){if(g={lane:2,revertLane:Kh(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},ic(r)){if(i)throw Error(s(479))}else i=Rd(r,d,g,2),i!==null&&Ln(i,r,2)}function ic(r){var i=r.alternate;return r===Ye||i!==null&&i===Ye}function Yx(r,i){oa=Jl=!0;var d=r.pending;d===null?i.next=i:(i.next=d.next,d.next=i),r.pending=i}function Xx(r,i,d){if((d&4194048)!==0){var g=i.lanes;g&=r.pendingLanes,d|=g,i.lanes=d,De(r,d)}}var _o={readContext:mn,use:tc,useCallback:Ht,useContext:Ht,useEffect:Ht,useImperativeHandle:Ht,useLayoutEffect:Ht,useInsertionEffect:Ht,useMemo:Ht,useReducer:Ht,useRef:Ht,useState:Ht,useDebugValue:Ht,useDeferredValue:Ht,useTransition:Ht,useSyncExternalStore:Ht,useId:Ht,useHostTransitionStatus:Ht,useFormState:Ht,useActionState:Ht,useOptimistic:Ht,useMemoCache:Ht,useCacheRefresh:Ht};_o.useEffectEvent=Ht;var Qx={readContext:mn,use:tc,useCallback:function(r,i){return Sn().memoizedState=[r,i===void 0?null:i],r},useContext:mn,useEffect:Ox,useImperativeHandle:function(r,i,d){d=d!=null?d.concat([r]):null,rc(4194308,4,Bx.bind(null,i,r),d)},useLayoutEffect:function(r,i){return rc(4194308,4,r,i)},useInsertionEffect:function(r,i){rc(4,2,r,i)},useMemo:function(r,i){var d=Sn();i=i===void 0?null:i;var g=r();if(ci){en(!0);try{r()}finally{en(!1)}}return d.memoizedState=[g,i],g},useReducer:function(r,i,d){var g=Sn();if(d!==void 0){var C=d(i);if(ci){en(!0);try{d(i)}finally{en(!1)}}}else C=i;return g.memoizedState=g.baseState=C,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:C},g.queue=r,r=r.dispatch=qk.bind(null,Ye,r),[g.memoizedState,r]},useRef:function(r){var i=Sn();return r={current:r},i.memoizedState=r},useState:function(r){r=ch(r);var i=r.queue,d=Kx.bind(null,Ye,i);return i.dispatch=d,[r.memoizedState,d]},useDebugValue:hh,useDeferredValue:function(r,i){var d=Sn();return fh(d,r,i)},useTransition:function(){var r=ch(!1);return r=Fx.bind(null,Ye,r.queue,!0,!1),Sn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,i,d){var g=Ye,C=Sn();if(lt){if(d===void 0)throw Error(s(407));d=d()}else{if(d=i(),kt===null)throw Error(s(349));(at&127)!==0||_x(g,i,d)}C.memoizedState=d;var j={value:d,getSnapshot:i};return C.queue=j,Ox(vx.bind(null,g,j,r),[r]),g.flags|=2048,ca(9,{destroy:void 0},yx.bind(null,g,j,d,i),null),d},useId:function(){var r=Sn(),i=kt.identifierPrefix;if(lt){var d=kr,g=Cr;d=(g&~(1<<32-He(g)-1)).toString(32)+d,i="_"+i+"R_"+d,d=Zl++,0<d&&(i+="H"+d.toString(32)),i+="_"}else d=Hk++,i="_"+i+"r_"+d.toString(32)+"_";return r.memoizedState=i},useHostTransitionStatus:ph,useFormState:Tx,useActionState:Tx,useOptimistic:function(r){var i=Sn();i.memoizedState=i.baseState=r;var d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return i.queue=d,i=gh.bind(null,Ye,!0,d),d.dispatch=i,[r,i]},useMemoCache:ah,useCacheRefresh:function(){return Sn().memoizedState=Wk.bind(null,Ye)},useEffectEvent:function(r){var i=Sn(),d={impl:r};return i.memoizedState=d,function(){if((pt&2)!==0)throw Error(s(440));return d.impl.apply(void 0,arguments)}}},xh={readContext:mn,use:tc,useCallback:Hx,useContext:mn,useEffect:dh,useImperativeHandle:zx,useInsertionEffect:Ix,useLayoutEffect:Px,useMemo:$x,useReducer:nc,useRef:Rx,useState:function(){return nc(Gr)},useDebugValue:hh,useDeferredValue:function(r,i){var d=Vt();return Ux(d,St.memoizedState,r,i)},useTransition:function(){var r=nc(Gr)[0],i=Vt().memoizedState;return[typeof r=="boolean"?r:go(r),i]},useSyncExternalStore:xx,useId:Wx,useHostTransitionStatus:ph,useFormState:Ax,useActionState:Ax,useOptimistic:function(r,i){var d=Vt();return wx(d,St,r,i)},useMemoCache:ah,useCacheRefresh:qx};xh.useEffectEvent=Mx;var Jx={readContext:mn,use:tc,useCallback:Hx,useContext:mn,useEffect:dh,useImperativeHandle:zx,useInsertionEffect:Ix,useLayoutEffect:Px,useMemo:$x,useReducer:lh,useRef:Rx,useState:function(){return lh(Gr)},useDebugValue:hh,useDeferredValue:function(r,i){var d=Vt();return St===null?fh(d,r,i):Ux(d,St.memoizedState,r,i)},useTransition:function(){var r=lh(Gr)[0],i=Vt().memoizedState;return[typeof r=="boolean"?r:go(r),i]},useSyncExternalStore:xx,useId:Wx,useHostTransitionStatus:ph,useFormState:Dx,useActionState:Dx,useOptimistic:function(r,i){var d=Vt();return St!==null?wx(d,St,r,i):(d.baseState=r,[r,d.queue.dispatch])},useMemoCache:ah,useCacheRefresh:qx};Jx.useEffectEvent=Mx;function _h(r,i,d,g){i=r.memoizedState,d=d(g,i),d=d==null?i:m({},i,d),r.memoizedState=d,r.lanes===0&&(r.updateQueue.baseState=d)}var yh={enqueueSetState:function(r,i,d){r=r._reactInternals;var g=Un(),C=ys(g);C.payload=i,d!=null&&(C.callback=d),i=vs(r,C,g),i!==null&&(Ln(i,r,g),ho(i,r,g))},enqueueReplaceState:function(r,i,d){r=r._reactInternals;var g=Un(),C=ys(g);C.tag=1,C.payload=i,d!=null&&(C.callback=d),i=vs(r,C,g),i!==null&&(Ln(i,r,g),ho(i,r,g))},enqueueForceUpdate:function(r,i){r=r._reactInternals;var d=Un(),g=ys(d);g.tag=2,i!=null&&(g.callback=i),i=vs(r,g,d),i!==null&&(Ln(i,r,d),ho(i,r,d))}};function Zx(r,i,d,g,C,j,I){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(g,j,I):i.prototype&&i.prototype.isPureReactComponent?!ro(d,g)||!ro(C,j):!0}function e_(r,i,d,g){r=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(d,g),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(d,g),i.state!==r&&yh.enqueueReplaceState(i,i.state,null)}function ui(r,i){var d=i;if("ref"in i){d={};for(var g in i)g!=="ref"&&(d[g]=i[g])}if(r=r.defaultProps){d===i&&(d=m({},d));for(var C in r)d[C]===void 0&&(d[C]=r[C])}return d}function t_(r){Pl(r)}function n_(r){console.error(r)}function r_(r){Pl(r)}function ac(r,i){try{var d=r.onUncaughtError;d(i.value,{componentStack:i.stack})}catch(g){setTimeout(function(){throw g})}}function s_(r,i,d){try{var g=r.onCaughtError;g(d.value,{componentStack:d.stack,errorBoundary:i.tag===1?i.stateNode:null})}catch(C){setTimeout(function(){throw C})}}function vh(r,i,d){return d=ys(d),d.tag=3,d.payload={element:null},d.callback=function(){ac(r,i)},d}function i_(r){return r=ys(r),r.tag=3,r}function a_(r,i,d,g){var C=d.type.getDerivedStateFromError;if(typeof C=="function"){var j=g.value;r.payload=function(){return C(j)},r.callback=function(){s_(i,d,g)}}var I=d.stateNode;I!==null&&typeof I.componentDidCatch=="function"&&(r.callback=function(){s_(i,d,g),typeof C!="function"&&(Es===null?Es=new Set([this]):Es.add(this));var K=g.stack;this.componentDidCatch(g.value,{componentStack:K!==null?K:""})})}function Kk(r,i,d,g,C){if(d.flags|=32768,g!==null&&typeof g=="object"&&typeof g.then=="function"){if(i=d.alternate,i!==null&&ta(i,d,C,!0),d=Bn.current,d!==null){switch(d.tag){case 31:case 13:return tr===null?_c():d.alternate===null&&$t===0&&($t=3),d.flags&=-257,d.flags|=65536,d.lanes=C,g===ql?d.flags|=16384:(i=d.updateQueue,i===null?d.updateQueue=new Set([g]):i.add(g),Gh(r,g,C)),!1;case 22:return d.flags|=65536,g===ql?d.flags|=16384:(i=d.updateQueue,i===null?(i={transitions:null,markerInstances:null,retryQueue:new Set([g])},d.updateQueue=i):(d=i.retryQueue,d===null?i.retryQueue=new Set([g]):d.add(g)),Gh(r,g,C)),!1}throw Error(s(435,d.tag))}return Gh(r,g,C),_c(),!1}if(lt)return i=Bn.current,i!==null?((i.flags&65536)===0&&(i.flags|=256),i.flags|=65536,i.lanes=C,g!==zd&&(r=Error(s(422),{cause:g}),ao(Qn(r,d)))):(g!==zd&&(i=Error(s(423),{cause:g}),ao(Qn(i,d))),r=r.current.alternate,r.flags|=65536,C&=-C,r.lanes|=C,g=Qn(g,d),C=vh(r.stateNode,g,C),Xd(r,C),$t!==4&&($t=2)),!1;var j=Error(s(520),{cause:g});if(j=Qn(j,d),Eo===null?Eo=[j]:Eo.push(j),$t!==4&&($t=2),i===null)return!0;g=Qn(g,d),d=i;do{switch(d.tag){case 3:return d.flags|=65536,r=C&-C,d.lanes|=r,r=vh(d.stateNode,g,r),Xd(d,r),!1;case 1:if(i=d.type,j=d.stateNode,(d.flags&128)===0&&(typeof i.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(Es===null||!Es.has(j))))return d.flags|=65536,C&=-C,d.lanes|=C,C=i_(C),a_(C,r,d,g),Xd(d,C),!1}d=d.return}while(d!==null);return!1}var bh=Error(s(461)),Yt=!1;function pn(r,i,d,g){i.child=r===null?ux(i,null,d,g):li(i,r.child,d,g)}function o_(r,i,d,g,C){d=d.render;var j=i.ref;if("ref"in g){var I={};for(var K in g)K!=="ref"&&(I[K]=g[K])}else I=g;return si(i),g=nh(r,i,d,I,j,C),K=rh(),r!==null&&!Yt?(sh(r,i,C),Wr(r,i,C)):(lt&&K&&Pd(i),i.flags|=1,pn(r,i,g,C),i.child)}function l_(r,i,d,g,C){if(r===null){var j=d.type;return typeof j=="function"&&!Od(j)&&j.defaultProps===void 0&&d.compare===null?(i.tag=15,i.type=j,c_(r,i,j,g,C)):(r=$l(d.type,null,g,i,i.mode,C),r.ref=i.ref,r.return=i,i.child=r)}if(j=r.child,!Th(r,C)){var I=j.memoizedProps;if(d=d.compare,d=d!==null?d:ro,d(I,g)&&r.ref===i.ref)return Wr(r,i,C)}return i.flags|=1,r=Hr(j,g),r.ref=i.ref,r.return=i,i.child=r}function c_(r,i,d,g,C){if(r!==null){var j=r.memoizedProps;if(ro(j,g)&&r.ref===i.ref)if(Yt=!1,i.pendingProps=g=j,Th(r,C))(r.flags&131072)!==0&&(Yt=!0);else return i.lanes=r.lanes,Wr(r,i,C)}return Sh(r,i,d,g,C)}function u_(r,i,d,g){var C=g.children,j=r!==null?r.memoizedState:null;if(r===null&&i.stateNode===null&&(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.mode==="hidden"){if((i.flags&128)!==0){if(j=j!==null?j.baseLanes|d:d,r!==null){for(g=i.child=r.child,C=0;g!==null;)C=C|g.lanes|g.childLanes,g=g.sibling;g=C&~j}else g=0,i.child=null;return d_(r,i,j,d,g)}if((d&536870912)!==0)i.memoizedState={baseLanes:0,cachePool:null},r!==null&&Gl(i,j!==null?j.cachePool:null),j!==null?fx(i,j):Jd(),mx(i);else return g=i.lanes=536870912,d_(r,i,j!==null?j.baseLanes|d:d,d,g)}else j!==null?(Gl(i,j.cachePool),fx(i,j),Ss(),i.memoizedState=null):(r!==null&&Gl(i,null),Jd(),Ss());return pn(r,i,C,d),i.child}function yo(r,i){return r!==null&&r.tag===22||i.stateNode!==null||(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.sibling}function d_(r,i,d,g,C){var j=Wd();return j=j===null?null:{parent:qt._currentValue,pool:j},i.memoizedState={baseLanes:d,cachePool:j},r!==null&&Gl(i,null),Jd(),mx(i),r!==null&&ta(r,i,g,!0),i.childLanes=C,null}function oc(r,i){return i=cc({mode:i.mode,children:i.children},r.mode),i.ref=r.ref,r.child=i,i.return=r,i}function h_(r,i,d){return li(i,r.child,null,d),r=oc(i,i.pendingProps),r.flags|=2,zn(i),i.memoizedState=null,r}function Yk(r,i,d){var g=i.pendingProps,C=(i.flags&128)!==0;if(i.flags&=-129,r===null){if(lt){if(g.mode==="hidden")return r=oc(i,g),i.lanes=536870912,yo(null,r);if(eh(i),(r=Rt)?(r=Cy(r,er),r=r!==null&&r.data==="&"?r:null,r!==null&&(i.memoizedState={dehydrated:r,treeContext:ms!==null?{id:Cr,overflow:kr}:null,retryLane:536870912,hydrationErrors:null},d=Yg(r),d.return=i,i.child=d,fn=i,Rt=null)):r=null,r===null)throw gs(i);return i.lanes=536870912,null}return oc(i,g)}var j=r.memoizedState;if(j!==null){var I=j.dehydrated;if(eh(i),C)if(i.flags&256)i.flags&=-257,i=h_(r,i,d);else if(i.memoizedState!==null)i.child=r.child,i.flags|=128,i=null;else throw Error(s(558));else if(Yt||ta(r,i,d,!1),C=(d&r.childLanes)!==0,Yt||C){if(g=kt,g!==null&&(I=$e(g,d),I!==0&&I!==j.retryLane))throw j.retryLane=I,ei(r,I),Ln(g,r,I),bh;_c(),i=h_(r,i,d)}else r=j.treeContext,Rt=nr(I.nextSibling),fn=i,lt=!0,ps=null,er=!1,r!==null&&Jg(i,r),i=oc(i,g),i.flags|=4096;return i}return r=Hr(r.child,{mode:g.mode,children:g.children}),r.ref=i.ref,i.child=r,r.return=i,r}function lc(r,i){var d=i.ref;if(d===null)r!==null&&r.ref!==null&&(i.flags|=4194816);else{if(typeof d!="function"&&typeof d!="object")throw Error(s(284));(r===null||r.ref!==d)&&(i.flags|=4194816)}}function Sh(r,i,d,g,C){return si(i),d=nh(r,i,d,g,void 0,C),g=rh(),r!==null&&!Yt?(sh(r,i,C),Wr(r,i,C)):(lt&&g&&Pd(i),i.flags|=1,pn(r,i,d,C),i.child)}function f_(r,i,d,g,C,j){return si(i),i.updateQueue=null,d=gx(i,g,d,C),px(r),g=rh(),r!==null&&!Yt?(sh(r,i,j),Wr(r,i,j)):(lt&&g&&Pd(i),i.flags|=1,pn(r,i,d,j),i.child)}function m_(r,i,d,g,C){if(si(i),i.stateNode===null){var j=Qi,I=d.contextType;typeof I=="object"&&I!==null&&(j=mn(I)),j=new d(g,j),i.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=yh,i.stateNode=j,j._reactInternals=i,j=i.stateNode,j.props=g,j.state=i.memoizedState,j.refs={},Kd(i),I=d.contextType,j.context=typeof I=="object"&&I!==null?mn(I):Qi,j.state=i.memoizedState,I=d.getDerivedStateFromProps,typeof I=="function"&&(_h(i,d,I,g),j.state=i.memoizedState),typeof d.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(I=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),I!==j.state&&yh.enqueueReplaceState(j,j.state,null),mo(i,g,j,C),fo(),j.state=i.memoizedState),typeof j.componentDidMount=="function"&&(i.flags|=4194308),g=!0}else if(r===null){j=i.stateNode;var K=i.memoizedProps,re=ui(d,K);j.props=re;var le=j.context,xe=d.contextType;I=Qi,typeof xe=="object"&&xe!==null&&(I=mn(xe));var be=d.getDerivedStateFromProps;xe=typeof be=="function"||typeof j.getSnapshotBeforeUpdate=="function",K=i.pendingProps!==K,xe||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(K||le!==I)&&e_(i,j,g,I),_s=!1;var ue=i.memoizedState;j.state=ue,mo(i,g,j,C),fo(),le=i.memoizedState,K||ue!==le||_s?(typeof be=="function"&&(_h(i,d,be,g),le=i.memoizedState),(re=_s||Zx(i,d,re,g,ue,le,I))?(xe||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(i.flags|=4194308)):(typeof j.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=g,i.memoizedState=le),j.props=g,j.state=le,j.context=I,g=re):(typeof j.componentDidMount=="function"&&(i.flags|=4194308),g=!1)}else{j=i.stateNode,Yd(r,i),I=i.memoizedProps,xe=ui(d,I),j.props=xe,be=i.pendingProps,ue=j.context,le=d.contextType,re=Qi,typeof le=="object"&&le!==null&&(re=mn(le)),K=d.getDerivedStateFromProps,(le=typeof K=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(I!==be||ue!==re)&&e_(i,j,g,re),_s=!1,ue=i.memoizedState,j.state=ue,mo(i,g,j,C),fo();var fe=i.memoizedState;I!==be||ue!==fe||_s||r!==null&&r.dependencies!==null&&Fl(r.dependencies)?(typeof K=="function"&&(_h(i,d,K,g),fe=i.memoizedState),(xe=_s||Zx(i,d,xe,g,ue,fe,re)||r!==null&&r.dependencies!==null&&Fl(r.dependencies))?(le||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(g,fe,re),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(g,fe,re)),typeof j.componentDidUpdate=="function"&&(i.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof j.componentDidUpdate!="function"||I===r.memoizedProps&&ue===r.memoizedState||(i.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||I===r.memoizedProps&&ue===r.memoizedState||(i.flags|=1024),i.memoizedProps=g,i.memoizedState=fe),j.props=g,j.state=fe,j.context=re,g=xe):(typeof j.componentDidUpdate!="function"||I===r.memoizedProps&&ue===r.memoizedState||(i.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||I===r.memoizedProps&&ue===r.memoizedState||(i.flags|=1024),g=!1)}return j=g,lc(r,i),g=(i.flags&128)!==0,j||g?(j=i.stateNode,d=g&&typeof d.getDerivedStateFromError!="function"?null:j.render(),i.flags|=1,r!==null&&g?(i.child=li(i,r.child,null,C),i.child=li(i,null,d,C)):pn(r,i,d,C),i.memoizedState=j.state,r=i.child):r=Wr(r,i,C),r}function p_(r,i,d,g){return ni(),i.flags|=256,pn(r,i,d,g),i.child}var wh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ch(r){return{baseLanes:r,cachePool:sx()}}function kh(r,i,d){return r=r!==null?r.childLanes&~d:0,i&&(r|=$n),r}function g_(r,i,d){var g=i.pendingProps,C=!1,j=(i.flags&128)!==0,I;if((I=j)||(I=r!==null&&r.memoizedState===null?!1:(Ft.current&2)!==0),I&&(C=!0,i.flags&=-129),I=(i.flags&32)!==0,i.flags&=-33,r===null){if(lt){if(C?bs(i):Ss(),(r=Rt)?(r=Cy(r,er),r=r!==null&&r.data!=="&"?r:null,r!==null&&(i.memoizedState={dehydrated:r,treeContext:ms!==null?{id:Cr,overflow:kr}:null,retryLane:536870912,hydrationErrors:null},d=Yg(r),d.return=i,i.child=d,fn=i,Rt=null)):r=null,r===null)throw gs(i);return lf(r)?i.lanes=32:i.lanes=536870912,null}var K=g.children;return g=g.fallback,C?(Ss(),C=i.mode,K=cc({mode:"hidden",children:K},C),g=ti(g,C,d,null),K.return=i,g.return=i,K.sibling=g,i.child=K,g=i.child,g.memoizedState=Ch(d),g.childLanes=kh(r,I,d),i.memoizedState=wh,yo(null,g)):(bs(i),Eh(i,K))}var re=r.memoizedState;if(re!==null&&(K=re.dehydrated,K!==null)){if(j)i.flags&256?(bs(i),i.flags&=-257,i=jh(r,i,d)):i.memoizedState!==null?(Ss(),i.child=r.child,i.flags|=128,i=null):(Ss(),K=g.fallback,C=i.mode,g=cc({mode:"visible",children:g.children},C),K=ti(K,C,d,null),K.flags|=2,g.return=i,K.return=i,g.sibling=K,i.child=g,li(i,r.child,null,d),g=i.child,g.memoizedState=Ch(d),g.childLanes=kh(r,I,d),i.memoizedState=wh,i=yo(null,g));else if(bs(i),lf(K)){if(I=K.nextSibling&&K.nextSibling.dataset,I)var le=I.dgst;I=le,g=Error(s(419)),g.stack="",g.digest=I,ao({value:g,source:null,stack:null}),i=jh(r,i,d)}else if(Yt||ta(r,i,d,!1),I=(d&r.childLanes)!==0,Yt||I){if(I=kt,I!==null&&(g=$e(I,d),g!==0&&g!==re.retryLane))throw re.retryLane=g,ei(r,g),Ln(I,r,g),bh;of(K)||_c(),i=jh(r,i,d)}else of(K)?(i.flags|=192,i.child=r.child,i=null):(r=re.treeContext,Rt=nr(K.nextSibling),fn=i,lt=!0,ps=null,er=!1,r!==null&&Jg(i,r),i=Eh(i,g.children),i.flags|=4096);return i}return C?(Ss(),K=g.fallback,C=i.mode,re=r.child,le=re.sibling,g=Hr(re,{mode:"hidden",children:g.children}),g.subtreeFlags=re.subtreeFlags&65011712,le!==null?K=Hr(le,K):(K=ti(K,C,d,null),K.flags|=2),K.return=i,g.return=i,g.sibling=K,i.child=g,yo(null,g),g=i.child,K=r.child.memoizedState,K===null?K=Ch(d):(C=K.cachePool,C!==null?(re=qt._currentValue,C=C.parent!==re?{parent:re,pool:re}:C):C=sx(),K={baseLanes:K.baseLanes|d,cachePool:C}),g.memoizedState=K,g.childLanes=kh(r,I,d),i.memoizedState=wh,yo(r.child,g)):(bs(i),d=r.child,r=d.sibling,d=Hr(d,{mode:"visible",children:g.children}),d.return=i,d.sibling=null,r!==null&&(I=i.deletions,I===null?(i.deletions=[r],i.flags|=16):I.push(r)),i.child=d,i.memoizedState=null,d)}function Eh(r,i){return i=cc({mode:"visible",children:i},r.mode),i.return=r,r.child=i}function cc(r,i){return r=Pn(22,r,null,i),r.lanes=0,r}function jh(r,i,d){return li(i,r.child,null,d),r=Eh(i,i.pendingProps.children),r.flags|=2,i.memoizedState=null,r}function x_(r,i,d){r.lanes|=i;var g=r.alternate;g!==null&&(g.lanes|=i),Ud(r.return,i,d)}function Nh(r,i,d,g,C,j){var I=r.memoizedState;I===null?r.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:g,tail:d,tailMode:C,treeForkCount:j}:(I.isBackwards=i,I.rendering=null,I.renderingStartTime=0,I.last=g,I.tail=d,I.tailMode=C,I.treeForkCount=j)}function __(r,i,d){var g=i.pendingProps,C=g.revealOrder,j=g.tail;g=g.children;var I=Ft.current,K=(I&2)!==0;if(K?(I=I&1|2,i.flags|=128):I&=1,U(Ft,I),pn(r,i,g,d),g=lt?io:0,!K&&r!==null&&(r.flags&128)!==0)e:for(r=i.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&x_(r,d,i);else if(r.tag===19)x_(r,d,i);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}switch(C){case"forwards":for(d=i.child,C=null;d!==null;)r=d.alternate,r!==null&&Ql(r)===null&&(C=d),d=d.sibling;d=C,d===null?(C=i.child,i.child=null):(C=d.sibling,d.sibling=null),Nh(i,!1,C,d,j,g);break;case"backwards":case"unstable_legacy-backwards":for(d=null,C=i.child,i.child=null;C!==null;){if(r=C.alternate,r!==null&&Ql(r)===null){i.child=C;break}r=C.sibling,C.sibling=d,d=C,C=r}Nh(i,!0,d,null,j,g);break;case"together":Nh(i,!1,null,null,void 0,g);break;default:i.memoizedState=null}return i.child}function Wr(r,i,d){if(r!==null&&(i.dependencies=r.dependencies),ks|=i.lanes,(d&i.childLanes)===0)if(r!==null){if(ta(r,i,d,!1),(d&i.childLanes)===0)return null}else return null;if(r!==null&&i.child!==r.child)throw Error(s(153));if(i.child!==null){for(r=i.child,d=Hr(r,r.pendingProps),i.child=d,d.return=i;r.sibling!==null;)r=r.sibling,d=d.sibling=Hr(r,r.pendingProps),d.return=i;d.sibling=null}return i.child}function Th(r,i){return(r.lanes&i)!==0?!0:(r=r.dependencies,!!(r!==null&&Fl(r)))}function Xk(r,i,d){switch(i.tag){case 3:H(i,i.stateNode.containerInfo),xs(i,qt,r.memoizedState.cache),ni();break;case 27:case 5:te(i);break;case 4:H(i,i.stateNode.containerInfo);break;case 10:xs(i,i.type,i.memoizedProps.value);break;case 31:if(i.memoizedState!==null)return i.flags|=128,eh(i),null;break;case 13:var g=i.memoizedState;if(g!==null)return g.dehydrated!==null?(bs(i),i.flags|=128,null):(d&i.child.childLanes)!==0?g_(r,i,d):(bs(i),r=Wr(r,i,d),r!==null?r.sibling:null);bs(i);break;case 19:var C=(r.flags&128)!==0;if(g=(d&i.childLanes)!==0,g||(ta(r,i,d,!1),g=(d&i.childLanes)!==0),C){if(g)return __(r,i,d);i.flags|=128}if(C=i.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),U(Ft,Ft.current),g)break;return null;case 22:return i.lanes=0,u_(r,i,d,i.pendingProps);case 24:xs(i,qt,r.memoizedState.cache)}return Wr(r,i,d)}function y_(r,i,d){if(r!==null)if(r.memoizedProps!==i.pendingProps)Yt=!0;else{if(!Th(r,d)&&(i.flags&128)===0)return Yt=!1,Xk(r,i,d);Yt=(r.flags&131072)!==0}else Yt=!1,lt&&(i.flags&1048576)!==0&&Qg(i,io,i.index);switch(i.lanes=0,i.tag){case 16:e:{var g=i.pendingProps;if(r=ai(i.elementType),i.type=r,typeof r=="function")Od(r)?(g=ui(r,g),i.tag=1,i=m_(null,i,r,g,d)):(i.tag=0,i=Sh(null,i,r,g,d));else{if(r!=null){var C=r.$$typeof;if(C===E){i.tag=11,i=o_(null,i,r,g,d);break e}else if(C===L){i.tag=14,i=l_(null,i,r,g,d);break e}}throw i=V(r)||r,Error(s(306,i,""))}}return i;case 0:return Sh(r,i,i.type,i.pendingProps,d);case 1:return g=i.type,C=ui(g,i.pendingProps),m_(r,i,g,C,d);case 3:e:{if(H(i,i.stateNode.containerInfo),r===null)throw Error(s(387));g=i.pendingProps;var j=i.memoizedState;C=j.element,Yd(r,i),mo(i,g,null,d);var I=i.memoizedState;if(g=I.cache,xs(i,qt,g),g!==j.cache&&Fd(i,[qt],d,!0),fo(),g=I.element,j.isDehydrated)if(j={element:g,isDehydrated:!1,cache:I.cache},i.updateQueue.baseState=j,i.memoizedState=j,i.flags&256){i=p_(r,i,g,d);break e}else if(g!==C){C=Qn(Error(s(424)),i),ao(C),i=p_(r,i,g,d);break e}else{switch(r=i.stateNode.containerInfo,r.nodeType){case 9:r=r.body;break;default:r=r.nodeName==="HTML"?r.ownerDocument.body:r}for(Rt=nr(r.firstChild),fn=i,lt=!0,ps=null,er=!0,d=ux(i,null,g,d),i.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling}else{if(ni(),g===C){i=Wr(r,i,d);break e}pn(r,i,g,d)}i=i.child}return i;case 26:return lc(r,i),r===null?(d=Ay(i.type,null,i.pendingProps,null))?i.memoizedState=d:lt||(d=i.type,r=i.pendingProps,g=kc(se.current).createElement(d),g[xt]=i,g[kn]=r,gn(g,d,r),ln(g),i.stateNode=g):i.memoizedState=Ay(i.type,r.memoizedProps,i.pendingProps,r.memoizedState),null;case 27:return te(i),r===null&<&&(g=i.stateNode=jy(i.type,i.pendingProps,se.current),fn=i,er=!0,C=Rt,As(i.type)?(cf=C,Rt=nr(g.firstChild)):Rt=C),pn(r,i,i.pendingProps.children,d),lc(r,i),r===null&&(i.flags|=4194304),i.child;case 5:return r===null&<&&((C=g=Rt)&&(g=EE(g,i.type,i.pendingProps,er),g!==null?(i.stateNode=g,fn=i,Rt=nr(g.firstChild),er=!1,C=!0):C=!1),C||gs(i)),te(i),C=i.type,j=i.pendingProps,I=r!==null?r.memoizedProps:null,g=j.children,rf(C,j)?g=null:I!==null&&rf(C,I)&&(i.flags|=32),i.memoizedState!==null&&(C=nh(r,i,$k,null,null,d),Oo._currentValue=C),lc(r,i),pn(r,i,g,d),i.child;case 6:return r===null&<&&((r=d=Rt)&&(d=jE(d,i.pendingProps,er),d!==null?(i.stateNode=d,fn=i,Rt=null,r=!0):r=!1),r||gs(i)),null;case 13:return g_(r,i,d);case 4:return H(i,i.stateNode.containerInfo),g=i.pendingProps,r===null?i.child=li(i,null,g,d):pn(r,i,g,d),i.child;case 11:return o_(r,i,i.type,i.pendingProps,d);case 7:return pn(r,i,i.pendingProps,d),i.child;case 8:return pn(r,i,i.pendingProps.children,d),i.child;case 12:return pn(r,i,i.pendingProps.children,d),i.child;case 10:return g=i.pendingProps,xs(i,i.type,g.value),pn(r,i,g.children,d),i.child;case 9:return C=i.type._context,g=i.pendingProps.children,si(i),C=mn(C),g=g(C),i.flags|=1,pn(r,i,g,d),i.child;case 14:return l_(r,i,i.type,i.pendingProps,d);case 15:return c_(r,i,i.type,i.pendingProps,d);case 19:return __(r,i,d);case 31:return Yk(r,i,d);case 22:return u_(r,i,d,i.pendingProps);case 24:return si(i),g=mn(qt),r===null?(C=Wd(),C===null&&(C=kt,j=Vd(),C.pooledCache=j,j.refCount++,j!==null&&(C.pooledCacheLanes|=d),C=j),i.memoizedState={parent:g,cache:C},Kd(i),xs(i,qt,C)):((r.lanes&d)!==0&&(Yd(r,i),mo(i,null,null,d),fo()),C=r.memoizedState,j=i.memoizedState,C.parent!==g?(C={parent:g,cache:g},i.memoizedState=C,i.lanes===0&&(i.memoizedState=i.updateQueue.baseState=C),xs(i,qt,g)):(g=j.cache,xs(i,qt,g),g!==C.cache&&Fd(i,[qt],d,!0))),pn(r,i,i.pendingProps.children,d),i.child;case 29:throw i.pendingProps}throw Error(s(156,i.tag))}function qr(r){r.flags|=4}function Ah(r,i,d,g,C){if((i=(r.mode&32)!==0)&&(i=!1),i){if(r.flags|=16777216,(C&335544128)===C)if(r.stateNode.complete)r.flags|=8192;else if(W_())r.flags|=8192;else throw oi=ql,qd}else r.flags&=-16777217}function v_(r,i){if(i.type!=="stylesheet"||(i.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!My(i))if(W_())r.flags|=8192;else throw oi=ql,qd}function uc(r,i){i!==null&&(r.flags|=4),r.flags&16384&&(i=r.tag!==22?El():536870912,r.lanes|=i,fa|=i)}function vo(r,i){if(!lt)switch(r.tailMode){case"hidden":i=r.tail;for(var d=null;i!==null;)i.alternate!==null&&(d=i),i=i.sibling;d===null?r.tail=null:d.sibling=null;break;case"collapsed":d=r.tail;for(var g=null;d!==null;)d.alternate!==null&&(g=d),d=d.sibling;g===null?i||r.tail===null?r.tail=null:r.tail.sibling=null:g.sibling=null}}function Ot(r){var i=r.alternate!==null&&r.alternate.child===r.child,d=0,g=0;if(i)for(var C=r.child;C!==null;)d|=C.lanes|C.childLanes,g|=C.subtreeFlags&65011712,g|=C.flags&65011712,C.return=r,C=C.sibling;else for(C=r.child;C!==null;)d|=C.lanes|C.childLanes,g|=C.subtreeFlags,g|=C.flags,C.return=r,C=C.sibling;return r.subtreeFlags|=g,r.childLanes=d,i}function Qk(r,i,d){var g=i.pendingProps;switch(Bd(i),i.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ot(i),null;case 1:return Ot(i),null;case 3:return d=i.stateNode,g=null,r!==null&&(g=r.memoizedState.cache),i.memoizedState.cache!==g&&(i.flags|=2048),Fr(qt),ee(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(r===null||r.child===null)&&(ea(i)?qr(i):r===null||r.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Hd())),Ot(i),null;case 26:var C=i.type,j=i.memoizedState;return r===null?(qr(i),j!==null?(Ot(i),v_(i,j)):(Ot(i),Ah(i,C,null,g,d))):j?j!==r.memoizedState?(qr(i),Ot(i),v_(i,j)):(Ot(i),i.flags&=-16777217):(r=r.memoizedProps,r!==g&&qr(i),Ot(i),Ah(i,C,r,g,d)),null;case 27:if(ce(i),d=se.current,C=i.type,r!==null&&i.stateNode!=null)r.memoizedProps!==g&&qr(i);else{if(!g){if(i.stateNode===null)throw Error(s(166));return Ot(i),null}r=J.current,ea(i)?Zg(i):(r=jy(C,g,d),i.stateNode=r,qr(i))}return Ot(i),null;case 5:if(ce(i),C=i.type,r!==null&&i.stateNode!=null)r.memoizedProps!==g&&qr(i);else{if(!g){if(i.stateNode===null)throw Error(s(166));return Ot(i),null}if(j=J.current,ea(i))Zg(i);else{var I=kc(se.current);switch(j){case 1:j=I.createElementNS("http://www.w3.org/2000/svg",C);break;case 2:j=I.createElementNS("http://www.w3.org/1998/Math/MathML",C);break;default:switch(C){case"svg":j=I.createElementNS("http://www.w3.org/2000/svg",C);break;case"math":j=I.createElementNS("http://www.w3.org/1998/Math/MathML",C);break;case"script":j=I.createElement("div"),j.innerHTML="<script><\/script>",j=j.removeChild(j.firstChild);break;case"select":j=typeof g.is=="string"?I.createElement("select",{is:g.is}):I.createElement("select"),g.multiple?j.multiple=!0:g.size&&(j.size=g.size);break;default:j=typeof g.is=="string"?I.createElement(C,{is:g.is}):I.createElement(C)}}j[xt]=i,j[kn]=g;e:for(I=i.child;I!==null;){if(I.tag===5||I.tag===6)j.appendChild(I.stateNode);else if(I.tag!==4&&I.tag!==27&&I.child!==null){I.child.return=I,I=I.child;continue}if(I===i)break e;for(;I.sibling===null;){if(I.return===null||I.return===i)break e;I=I.return}I.sibling.return=I.return,I=I.sibling}i.stateNode=j;e:switch(gn(j,C,g),C){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&qr(i)}}return Ot(i),Ah(i,i.type,r===null?null:r.memoizedProps,i.pendingProps,d),null;case 6:if(r&&i.stateNode!=null)r.memoizedProps!==g&&qr(i);else{if(typeof g!="string"&&i.stateNode===null)throw Error(s(166));if(r=se.current,ea(i)){if(r=i.stateNode,d=i.memoizedProps,g=null,C=fn,C!==null)switch(C.tag){case 27:case 5:g=C.memoizedProps}r[xt]=i,r=!!(r.nodeValue===d||g!==null&&g.suppressHydrationWarning===!0||gy(r.nodeValue,d)),r||gs(i,!0)}else r=kc(r).createTextNode(g),r[xt]=i,i.stateNode=r}return Ot(i),null;case 31:if(d=i.memoizedState,r===null||r.memoizedState!==null){if(g=ea(i),d!==null){if(r===null){if(!g)throw Error(s(318));if(r=i.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(557));r[xt]=i}else ni(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Ot(i),r=!1}else d=Hd(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=d),r=!0;if(!r)return i.flags&256?(zn(i),i):(zn(i),null);if((i.flags&128)!==0)throw Error(s(558))}return Ot(i),null;case 13:if(g=i.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(C=ea(i),g!==null&&g.dehydrated!==null){if(r===null){if(!C)throw Error(s(318));if(C=i.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(s(317));C[xt]=i}else ni(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Ot(i),C=!1}else C=Hd(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=C),C=!0;if(!C)return i.flags&256?(zn(i),i):(zn(i),null)}return zn(i),(i.flags&128)!==0?(i.lanes=d,i):(d=g!==null,r=r!==null&&r.memoizedState!==null,d&&(g=i.child,C=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(C=g.alternate.memoizedState.cachePool.pool),j=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(j=g.memoizedState.cachePool.pool),j!==C&&(g.flags|=2048)),d!==r&&d&&(i.child.flags|=8192),uc(i,i.updateQueue),Ot(i),null);case 4:return ee(),r===null&&Jh(i.stateNode.containerInfo),Ot(i),null;case 10:return Fr(i.type),Ot(i),null;case 19:if(P(Ft),g=i.memoizedState,g===null)return Ot(i),null;if(C=(i.flags&128)!==0,j=g.rendering,j===null)if(C)vo(g,!1);else{if($t!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(j=Ql(r),j!==null){for(i.flags|=128,vo(g,!1),r=j.updateQueue,i.updateQueue=r,uc(i,r),i.subtreeFlags=0,r=d,d=i.child;d!==null;)Kg(d,r),d=d.sibling;return U(Ft,Ft.current&1|2),lt&&$r(i,g.treeForkCount),i.child}r=r.sibling}g.tail!==null&>()>pc&&(i.flags|=128,C=!0,vo(g,!1),i.lanes=4194304)}else{if(!C)if(r=Ql(j),r!==null){if(i.flags|=128,C=!0,r=r.updateQueue,i.updateQueue=r,uc(i,r),vo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!j.alternate&&!lt)return Ot(i),null}else 2*gt()-g.renderingStartTime>pc&&d!==536870912&&(i.flags|=128,C=!0,vo(g,!1),i.lanes=4194304);g.isBackwards?(j.sibling=i.child,i.child=j):(r=g.last,r!==null?r.sibling=j:i.child=j,g.last=j)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=gt(),r.sibling=null,d=Ft.current,U(Ft,C?d&1|2:d&1),lt&&$r(i,g.treeForkCount),r):(Ot(i),null);case 22:case 23:return zn(i),Zd(),g=i.memoizedState!==null,r!==null?r.memoizedState!==null!==g&&(i.flags|=8192):g&&(i.flags|=8192),g?(d&536870912)!==0&&(i.flags&128)===0&&(Ot(i),i.subtreeFlags&6&&(i.flags|=8192)):Ot(i),d=i.updateQueue,d!==null&&uc(i,d.retryQueue),d=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(d=r.memoizedState.cachePool.pool),g=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(g=i.memoizedState.cachePool.pool),g!==d&&(i.flags|=2048),r!==null&&P(ii),null;case 24:return d=null,r!==null&&(d=r.memoizedState.cache),i.memoizedState.cache!==d&&(i.flags|=2048),Fr(qt),Ot(i),null;case 25:return null;case 30:return null}throw Error(s(156,i.tag))}function Jk(r,i){switch(Bd(i),i.tag){case 1:return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return Fr(qt),ee(),r=i.flags,(r&65536)!==0&&(r&128)===0?(i.flags=r&-65537|128,i):null;case 26:case 27:case 5:return ce(i),null;case 31:if(i.memoizedState!==null){if(zn(i),i.alternate===null)throw Error(s(340));ni()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 13:if(zn(i),r=i.memoizedState,r!==null&&r.dehydrated!==null){if(i.alternate===null)throw Error(s(340));ni()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return P(Ft),null;case 4:return ee(),null;case 10:return Fr(i.type),null;case 22:case 23:return zn(i),Zd(),r!==null&&P(ii),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 24:return Fr(qt),null;case 25:return null;default:return null}}function b_(r,i){switch(Bd(i),i.tag){case 3:Fr(qt),ee();break;case 26:case 27:case 5:ce(i);break;case 4:ee();break;case 31:i.memoizedState!==null&&zn(i);break;case 13:zn(i);break;case 19:P(Ft);break;case 10:Fr(i.type);break;case 22:case 23:zn(i),Zd(),r!==null&&P(ii);break;case 24:Fr(qt)}}function bo(r,i){try{var d=i.updateQueue,g=d!==null?d.lastEffect:null;if(g!==null){var C=g.next;d=C;do{if((d.tag&r)===r){g=void 0;var j=d.create,I=d.inst;g=j(),I.destroy=g}d=d.next}while(d!==C)}}catch(K){yt(i,i.return,K)}}function ws(r,i,d){try{var g=i.updateQueue,C=g!==null?g.lastEffect:null;if(C!==null){var j=C.next;g=j;do{if((g.tag&r)===r){var I=g.inst,K=I.destroy;if(K!==void 0){I.destroy=void 0,C=i;var re=d,le=K;try{le()}catch(xe){yt(C,re,xe)}}}g=g.next}while(g!==j)}}catch(xe){yt(i,i.return,xe)}}function S_(r){var i=r.updateQueue;if(i!==null){var d=r.stateNode;try{hx(i,d)}catch(g){yt(r,r.return,g)}}}function w_(r,i,d){d.props=ui(r.type,r.memoizedProps),d.state=r.memoizedState;try{d.componentWillUnmount()}catch(g){yt(r,i,g)}}function So(r,i){try{var d=r.ref;if(d!==null){switch(r.tag){case 26:case 27:case 5:var g=r.stateNode;break;case 30:g=r.stateNode;break;default:g=r.stateNode}typeof d=="function"?r.refCleanup=d(g):d.current=g}}catch(C){yt(r,i,C)}}function Er(r,i){var d=r.ref,g=r.refCleanup;if(d!==null)if(typeof g=="function")try{g()}catch(C){yt(r,i,C)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof d=="function")try{d(null)}catch(C){yt(r,i,C)}else d.current=null}function C_(r){var i=r.type,d=r.memoizedProps,g=r.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":d.autoFocus&&g.focus();break e;case"img":d.src?g.src=d.src:d.srcSet&&(g.srcset=d.srcSet)}}catch(C){yt(r,r.return,C)}}function Lh(r,i,d){try{var g=r.stateNode;vE(g,r.type,d,i),g[kn]=i}catch(C){yt(r,r.return,C)}}function k_(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&As(r.type)||r.tag===4}function Dh(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||k_(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.tag===27&&As(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Rh(r,i,d){var g=r.tag;if(g===5||g===6)r=r.stateNode,i?(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d).insertBefore(r,i):(i=d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,i.appendChild(r),d=d._reactRootContainer,d!=null||i.onclick!==null||(i.onclick=Br));else if(g!==4&&(g===27&&As(r.type)&&(d=r.stateNode,i=null),r=r.child,r!==null))for(Rh(r,i,d),r=r.sibling;r!==null;)Rh(r,i,d),r=r.sibling}function dc(r,i,d){var g=r.tag;if(g===5||g===6)r=r.stateNode,i?d.insertBefore(r,i):d.appendChild(r);else if(g!==4&&(g===27&&As(r.type)&&(d=r.stateNode),r=r.child,r!==null))for(dc(r,i,d),r=r.sibling;r!==null;)dc(r,i,d),r=r.sibling}function E_(r){var i=r.stateNode,d=r.memoizedProps;try{for(var g=r.type,C=i.attributes;C.length;)i.removeAttributeNode(C[0]);gn(i,g,d),i[xt]=r,i[kn]=d}catch(j){yt(r,r.return,j)}}var Kr=!1,Xt=!1,Oh=!1,j_=typeof WeakSet=="function"?WeakSet:Set,cn=null;function Zk(r,i){if(r=r.containerInfo,tf=Dc,r=zg(r),jd(r)){if("selectionStart"in r)var d={start:r.selectionStart,end:r.selectionEnd};else e:{d=(d=r.ownerDocument)&&d.defaultView||window;var g=d.getSelection&&d.getSelection();if(g&&g.rangeCount!==0){d=g.anchorNode;var C=g.anchorOffset,j=g.focusNode;g=g.focusOffset;try{d.nodeType,j.nodeType}catch{d=null;break e}var I=0,K=-1,re=-1,le=0,xe=0,be=r,ue=null;t:for(;;){for(var fe;be!==d||C!==0&&be.nodeType!==3||(K=I+C),be!==j||g!==0&&be.nodeType!==3||(re=I+g),be.nodeType===3&&(I+=be.nodeValue.length),(fe=be.firstChild)!==null;)ue=be,be=fe;for(;;){if(be===r)break t;if(ue===d&&++le===C&&(K=I),ue===j&&++xe===g&&(re=I),(fe=be.nextSibling)!==null)break;be=ue,ue=be.parentNode}be=fe}d=K===-1||re===-1?null:{start:K,end:re}}else d=null}d=d||{start:0,end:0}}else d=null;for(nf={focusedElem:r,selectionRange:d},Dc=!1,cn=i;cn!==null;)if(i=cn,r=i.child,(i.subtreeFlags&1028)!==0&&r!==null)r.return=i,cn=r;else for(;cn!==null;){switch(i=cn,j=i.alternate,r=i.flags,i.tag){case 0:if((r&4)!==0&&(r=i.updateQueue,r=r!==null?r.events:null,r!==null))for(d=0;d<r.length;d++)C=r[d],C.ref.impl=C.nextImpl;break;case 11:case 15:break;case 1:if((r&1024)!==0&&j!==null){r=void 0,d=i,C=j.memoizedProps,j=j.memoizedState,g=d.stateNode;try{var Re=ui(d.type,C);r=g.getSnapshotBeforeUpdate(Re,j),g.__reactInternalSnapshotBeforeUpdate=r}catch(Fe){yt(d,d.return,Fe)}}break;case 3:if((r&1024)!==0){if(r=i.stateNode.containerInfo,d=r.nodeType,d===9)af(r);else if(d===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":af(r);break;default:r.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((r&1024)!==0)throw Error(s(163))}if(r=i.sibling,r!==null){r.return=i.return,cn=r;break}cn=i.return}}function N_(r,i,d){var g=d.flags;switch(d.tag){case 0:case 11:case 15:Xr(r,d),g&4&&bo(5,d);break;case 1:if(Xr(r,d),g&4)if(r=d.stateNode,i===null)try{r.componentDidMount()}catch(I){yt(d,d.return,I)}else{var C=ui(d.type,i.memoizedProps);i=i.memoizedState;try{r.componentDidUpdate(C,i,r.__reactInternalSnapshotBeforeUpdate)}catch(I){yt(d,d.return,I)}}g&64&&S_(d),g&512&&So(d,d.return);break;case 3:if(Xr(r,d),g&64&&(r=d.updateQueue,r!==null)){if(i=null,d.child!==null)switch(d.child.tag){case 27:case 5:i=d.child.stateNode;break;case 1:i=d.child.stateNode}try{hx(r,i)}catch(I){yt(d,d.return,I)}}break;case 27:i===null&&g&4&&E_(d);case 26:case 5:Xr(r,d),i===null&&g&4&&C_(d),g&512&&So(d,d.return);break;case 12:Xr(r,d);break;case 31:Xr(r,d),g&4&&L_(r,d);break;case 13:Xr(r,d),g&4&&D_(r,d),g&64&&(r=d.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(d=lE.bind(null,d),NE(r,d))));break;case 22:if(g=d.memoizedState!==null||Kr,!g){i=i!==null&&i.memoizedState!==null||Xt,C=Kr;var j=Xt;Kr=g,(Xt=i)&&!j?Qr(r,d,(d.subtreeFlags&8772)!==0):Xr(r,d),Kr=C,Xt=j}break;case 30:break;default:Xr(r,d)}}function T_(r){var i=r.alternate;i!==null&&(r.alternate=null,T_(i)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(i=r.stateNode,i!==null&&ud(i)),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}var Pt=null,jn=!1;function Yr(r,i,d){for(d=d.child;d!==null;)A_(r,i,d),d=d.sibling}function A_(r,i,d){if(ct&&typeof ct.onCommitFiberUnmount=="function")try{ct.onCommitFiberUnmount(bt,d)}catch{}switch(d.tag){case 26:Xt||Er(d,i),Yr(r,i,d),d.memoizedState?d.memoizedState.count--:d.stateNode&&(d=d.stateNode,d.parentNode.removeChild(d));break;case 27:Xt||Er(d,i);var g=Pt,C=jn;As(d.type)&&(Pt=d.stateNode,jn=!1),Yr(r,i,d),Lo(d.stateNode),Pt=g,jn=C;break;case 5:Xt||Er(d,i);case 6:if(g=Pt,C=jn,Pt=null,Yr(r,i,d),Pt=g,jn=C,Pt!==null)if(jn)try{(Pt.nodeType===9?Pt.body:Pt.nodeName==="HTML"?Pt.ownerDocument.body:Pt).removeChild(d.stateNode)}catch(j){yt(d,i,j)}else try{Pt.removeChild(d.stateNode)}catch(j){yt(d,i,j)}break;case 18:Pt!==null&&(jn?(r=Pt,Sy(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,d.stateNode),ba(r)):Sy(Pt,d.stateNode));break;case 4:g=Pt,C=jn,Pt=d.stateNode.containerInfo,jn=!0,Yr(r,i,d),Pt=g,jn=C;break;case 0:case 11:case 14:case 15:ws(2,d,i),Xt||ws(4,d,i),Yr(r,i,d);break;case 1:Xt||(Er(d,i),g=d.stateNode,typeof g.componentWillUnmount=="function"&&w_(d,i,g)),Yr(r,i,d);break;case 21:Yr(r,i,d);break;case 22:Xt=(g=Xt)||d.memoizedState!==null,Yr(r,i,d),Xt=g;break;default:Yr(r,i,d)}}function L_(r,i){if(i.memoizedState===null&&(r=i.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{ba(r)}catch(d){yt(i,i.return,d)}}}function D_(r,i){if(i.memoizedState===null&&(r=i.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{ba(r)}catch(d){yt(i,i.return,d)}}function eE(r){switch(r.tag){case 31:case 13:case 19:var i=r.stateNode;return i===null&&(i=r.stateNode=new j_),i;case 22:return r=r.stateNode,i=r._retryCache,i===null&&(i=r._retryCache=new j_),i;default:throw Error(s(435,r.tag))}}function hc(r,i){var d=eE(r);i.forEach(function(g){if(!d.has(g)){d.add(g);var C=cE.bind(null,r,g);g.then(C,C)}})}function Nn(r,i){var d=i.deletions;if(d!==null)for(var g=0;g<d.length;g++){var C=d[g],j=r,I=i,K=I;e:for(;K!==null;){switch(K.tag){case 27:if(As(K.type)){Pt=K.stateNode,jn=!1;break e}break;case 5:Pt=K.stateNode,jn=!1;break e;case 3:case 4:Pt=K.stateNode.containerInfo,jn=!0;break e}K=K.return}if(Pt===null)throw Error(s(160));A_(j,I,C),Pt=null,jn=!1,j=C.alternate,j!==null&&(j.return=null),C.return=null}if(i.subtreeFlags&13886)for(i=i.child;i!==null;)R_(i,r),i=i.sibling}var fr=null;function R_(r,i){var d=r.alternate,g=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:Nn(i,r),Tn(r),g&4&&(ws(3,r,r.return),bo(3,r),ws(5,r,r.return));break;case 1:Nn(i,r),Tn(r),g&512&&(Xt||d===null||Er(d,d.return)),g&64&&Kr&&(r=r.updateQueue,r!==null&&(g=r.callbacks,g!==null&&(d=r.shared.hiddenCallbacks,r.shared.hiddenCallbacks=d===null?g:d.concat(g))));break;case 26:var C=fr;if(Nn(i,r),Tn(r),g&512&&(Xt||d===null||Er(d,d.return)),g&4){var j=d!==null?d.memoizedState:null;if(g=r.memoizedState,d===null)if(g===null)if(r.stateNode===null){e:{g=r.type,d=r.memoizedProps,C=C.ownerDocument||C;t:switch(g){case"title":j=C.getElementsByTagName("title")[0],(!j||j[Ka]||j[xt]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=C.createElement(g),C.head.insertBefore(j,C.querySelector("head > title"))),gn(j,g,d),j[xt]=r,ln(j),g=j;break e;case"link":var I=Ry("link","href",C).get(g+(d.href||""));if(I){for(var K=0;K<I.length;K++)if(j=I[K],j.getAttribute("href")===(d.href==null||d.href===""?null:d.href)&&j.getAttribute("rel")===(d.rel==null?null:d.rel)&&j.getAttribute("title")===(d.title==null?null:d.title)&&j.getAttribute("crossorigin")===(d.crossOrigin==null?null:d.crossOrigin)){I.splice(K,1);break t}}j=C.createElement(g),gn(j,g,d),C.head.appendChild(j);break;case"meta":if(I=Ry("meta","content",C).get(g+(d.content||""))){for(K=0;K<I.length;K++)if(j=I[K],j.getAttribute("content")===(d.content==null?null:""+d.content)&&j.getAttribute("name")===(d.name==null?null:d.name)&&j.getAttribute("property")===(d.property==null?null:d.property)&&j.getAttribute("http-equiv")===(d.httpEquiv==null?null:d.httpEquiv)&&j.getAttribute("charset")===(d.charSet==null?null:d.charSet)){I.splice(K,1);break t}}j=C.createElement(g),gn(j,g,d),C.head.appendChild(j);break;default:throw Error(s(468,g))}j[xt]=r,ln(j),g=j}r.stateNode=g}else Oy(C,r.type,r.stateNode);else r.stateNode=Dy(C,g,r.memoizedProps);else j!==g?(j===null?d.stateNode!==null&&(d=d.stateNode,d.parentNode.removeChild(d)):j.count--,g===null?Oy(C,r.type,r.stateNode):Dy(C,g,r.memoizedProps)):g===null&&r.stateNode!==null&&Lh(r,r.memoizedProps,d.memoizedProps)}break;case 27:Nn(i,r),Tn(r),g&512&&(Xt||d===null||Er(d,d.return)),d!==null&&g&4&&Lh(r,r.memoizedProps,d.memoizedProps);break;case 5:if(Nn(i,r),Tn(r),g&512&&(Xt||d===null||Er(d,d.return)),r.flags&32){C=r.stateNode;try{Vi(C,"")}catch(Re){yt(r,r.return,Re)}}g&4&&r.stateNode!=null&&(C=r.memoizedProps,Lh(r,C,d!==null?d.memoizedProps:C)),g&1024&&(Oh=!0);break;case 6:if(Nn(i,r),Tn(r),g&4){if(r.stateNode===null)throw Error(s(162));g=r.memoizedProps,d=r.stateNode;try{d.nodeValue=g}catch(Re){yt(r,r.return,Re)}}break;case 3:if(Nc=null,C=fr,fr=Ec(i.containerInfo),Nn(i,r),fr=C,Tn(r),g&4&&d!==null&&d.memoizedState.isDehydrated)try{ba(i.containerInfo)}catch(Re){yt(r,r.return,Re)}Oh&&(Oh=!1,O_(r));break;case 4:g=fr,fr=Ec(r.stateNode.containerInfo),Nn(i,r),Tn(r),fr=g;break;case 12:Nn(i,r),Tn(r);break;case 31:Nn(i,r),Tn(r),g&4&&(g=r.updateQueue,g!==null&&(r.updateQueue=null,hc(r,g)));break;case 13:Nn(i,r),Tn(r),r.child.flags&8192&&r.memoizedState!==null!=(d!==null&&d.memoizedState!==null)&&(mc=gt()),g&4&&(g=r.updateQueue,g!==null&&(r.updateQueue=null,hc(r,g)));break;case 22:C=r.memoizedState!==null;var re=d!==null&&d.memoizedState!==null,le=Kr,xe=Xt;if(Kr=le||C,Xt=xe||re,Nn(i,r),Xt=xe,Kr=le,Tn(r),g&8192)e:for(i=r.stateNode,i._visibility=C?i._visibility&-2:i._visibility|1,C&&(d===null||re||Kr||Xt||di(r)),d=null,i=r;;){if(i.tag===5||i.tag===26){if(d===null){re=d=i;try{if(j=re.stateNode,C)I=j.style,typeof I.setProperty=="function"?I.setProperty("display","none","important"):I.display="none";else{K=re.stateNode;var be=re.memoizedProps.style,ue=be!=null&&be.hasOwnProperty("display")?be.display:null;K.style.display=ue==null||typeof ue=="boolean"?"":(""+ue).trim()}}catch(Re){yt(re,re.return,Re)}}}else if(i.tag===6){if(d===null){re=i;try{re.stateNode.nodeValue=C?"":re.memoizedProps}catch(Re){yt(re,re.return,Re)}}}else if(i.tag===18){if(d===null){re=i;try{var fe=re.stateNode;C?wy(fe,!0):wy(re.stateNode,!1)}catch(Re){yt(re,re.return,Re)}}}else if((i.tag!==22&&i.tag!==23||i.memoizedState===null||i===r)&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;d===i&&(d=null),i=i.return}d===i&&(d=null),i.sibling.return=i.return,i=i.sibling}g&4&&(g=r.updateQueue,g!==null&&(d=g.retryQueue,d!==null&&(g.retryQueue=null,hc(r,d))));break;case 19:Nn(i,r),Tn(r),g&4&&(g=r.updateQueue,g!==null&&(r.updateQueue=null,hc(r,g)));break;case 30:break;case 21:break;default:Nn(i,r),Tn(r)}}function Tn(r){var i=r.flags;if(i&2){try{for(var d,g=r.return;g!==null;){if(k_(g)){d=g;break}g=g.return}if(d==null)throw Error(s(160));switch(d.tag){case 27:var C=d.stateNode,j=Dh(r);dc(r,j,C);break;case 5:var I=d.stateNode;d.flags&32&&(Vi(I,""),d.flags&=-33);var K=Dh(r);dc(r,K,I);break;case 3:case 4:var re=d.stateNode.containerInfo,le=Dh(r);Rh(r,le,re);break;default:throw Error(s(161))}}catch(xe){yt(r,r.return,xe)}r.flags&=-3}i&4096&&(r.flags&=-4097)}function O_(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var i=r;O_(i),i.tag===5&&i.flags&1024&&i.stateNode.reset(),r=r.sibling}}function Xr(r,i){if(i.subtreeFlags&8772)for(i=i.child;i!==null;)N_(r,i.alternate,i),i=i.sibling}function di(r){for(r=r.child;r!==null;){var i=r;switch(i.tag){case 0:case 11:case 14:case 15:ws(4,i,i.return),di(i);break;case 1:Er(i,i.return);var d=i.stateNode;typeof d.componentWillUnmount=="function"&&w_(i,i.return,d),di(i);break;case 27:Lo(i.stateNode);case 26:case 5:Er(i,i.return),di(i);break;case 22:i.memoizedState===null&&di(i);break;case 30:di(i);break;default:di(i)}r=r.sibling}}function Qr(r,i,d){for(d=d&&(i.subtreeFlags&8772)!==0,i=i.child;i!==null;){var g=i.alternate,C=r,j=i,I=j.flags;switch(j.tag){case 0:case 11:case 15:Qr(C,j,d),bo(4,j);break;case 1:if(Qr(C,j,d),g=j,C=g.stateNode,typeof C.componentDidMount=="function")try{C.componentDidMount()}catch(le){yt(g,g.return,le)}if(g=j,C=g.updateQueue,C!==null){var K=g.stateNode;try{var re=C.shared.hiddenCallbacks;if(re!==null)for(C.shared.hiddenCallbacks=null,C=0;C<re.length;C++)dx(re[C],K)}catch(le){yt(g,g.return,le)}}d&&I&64&&S_(j),So(j,j.return);break;case 27:E_(j);case 26:case 5:Qr(C,j,d),d&&g===null&&I&4&&C_(j),So(j,j.return);break;case 12:Qr(C,j,d);break;case 31:Qr(C,j,d),d&&I&4&&L_(C,j);break;case 13:Qr(C,j,d),d&&I&4&&D_(C,j);break;case 22:j.memoizedState===null&&Qr(C,j,d),So(j,j.return);break;case 30:break;default:Qr(C,j,d)}i=i.sibling}}function Mh(r,i){var d=null;r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(d=r.memoizedState.cachePool.pool),r=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(r=i.memoizedState.cachePool.pool),r!==d&&(r!=null&&r.refCount++,d!=null&&oo(d))}function Ih(r,i){r=null,i.alternate!==null&&(r=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==r&&(i.refCount++,r!=null&&oo(r))}function mr(r,i,d,g){if(i.subtreeFlags&10256)for(i=i.child;i!==null;)M_(r,i,d,g),i=i.sibling}function M_(r,i,d,g){var C=i.flags;switch(i.tag){case 0:case 11:case 15:mr(r,i,d,g),C&2048&&bo(9,i);break;case 1:mr(r,i,d,g);break;case 3:mr(r,i,d,g),C&2048&&(r=null,i.alternate!==null&&(r=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==r&&(i.refCount++,r!=null&&oo(r)));break;case 12:if(C&2048){mr(r,i,d,g),r=i.stateNode;try{var j=i.memoizedProps,I=j.id,K=j.onPostCommit;typeof K=="function"&&K(I,i.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(re){yt(i,i.return,re)}}else mr(r,i,d,g);break;case 31:mr(r,i,d,g);break;case 13:mr(r,i,d,g);break;case 23:break;case 22:j=i.stateNode,I=i.alternate,i.memoizedState!==null?j._visibility&2?mr(r,i,d,g):wo(r,i):j._visibility&2?mr(r,i,d,g):(j._visibility|=2,ua(r,i,d,g,(i.subtreeFlags&10256)!==0||!1)),C&2048&&Mh(I,i);break;case 24:mr(r,i,d,g),C&2048&&Ih(i.alternate,i);break;default:mr(r,i,d,g)}}function ua(r,i,d,g,C){for(C=C&&((i.subtreeFlags&10256)!==0||!1),i=i.child;i!==null;){var j=r,I=i,K=d,re=g,le=I.flags;switch(I.tag){case 0:case 11:case 15:ua(j,I,K,re,C),bo(8,I);break;case 23:break;case 22:var xe=I.stateNode;I.memoizedState!==null?xe._visibility&2?ua(j,I,K,re,C):wo(j,I):(xe._visibility|=2,ua(j,I,K,re,C)),C&&le&2048&&Mh(I.alternate,I);break;case 24:ua(j,I,K,re,C),C&&le&2048&&Ih(I.alternate,I);break;default:ua(j,I,K,re,C)}i=i.sibling}}function wo(r,i){if(i.subtreeFlags&10256)for(i=i.child;i!==null;){var d=r,g=i,C=g.flags;switch(g.tag){case 22:wo(d,g),C&2048&&Mh(g.alternate,g);break;case 24:wo(d,g),C&2048&&Ih(g.alternate,g);break;default:wo(d,g)}i=i.sibling}}var Co=8192;function da(r,i,d){if(r.subtreeFlags&Co)for(r=r.child;r!==null;)I_(r,i,d),r=r.sibling}function I_(r,i,d){switch(r.tag){case 26:da(r,i,d),r.flags&Co&&r.memoizedState!==null&&HE(d,fr,r.memoizedState,r.memoizedProps);break;case 5:da(r,i,d);break;case 3:case 4:var g=fr;fr=Ec(r.stateNode.containerInfo),da(r,i,d),fr=g;break;case 22:r.memoizedState===null&&(g=r.alternate,g!==null&&g.memoizedState!==null?(g=Co,Co=16777216,da(r,i,d),Co=g):da(r,i,d));break;default:da(r,i,d)}}function P_(r){var i=r.alternate;if(i!==null&&(r=i.child,r!==null)){i.child=null;do i=r.sibling,r.sibling=null,r=i;while(r!==null)}}function ko(r){var i=r.deletions;if((r.flags&16)!==0){if(i!==null)for(var d=0;d<i.length;d++){var g=i[d];cn=g,z_(g,r)}P_(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)B_(r),r=r.sibling}function B_(r){switch(r.tag){case 0:case 11:case 15:ko(r),r.flags&2048&&ws(9,r,r.return);break;case 3:ko(r);break;case 12:ko(r);break;case 22:var i=r.stateNode;r.memoizedState!==null&&i._visibility&2&&(r.return===null||r.return.tag!==13)?(i._visibility&=-3,fc(r)):ko(r);break;default:ko(r)}}function fc(r){var i=r.deletions;if((r.flags&16)!==0){if(i!==null)for(var d=0;d<i.length;d++){var g=i[d];cn=g,z_(g,r)}P_(r)}for(r=r.child;r!==null;){switch(i=r,i.tag){case 0:case 11:case 15:ws(8,i,i.return),fc(i);break;case 22:d=i.stateNode,d._visibility&2&&(d._visibility&=-3,fc(i));break;default:fc(i)}r=r.sibling}}function z_(r,i){for(;cn!==null;){var d=cn;switch(d.tag){case 0:case 11:case 15:ws(8,d,i);break;case 23:case 22:if(d.memoizedState!==null&&d.memoizedState.cachePool!==null){var g=d.memoizedState.cachePool.pool;g!=null&&g.refCount++}break;case 24:oo(d.memoizedState.cache)}if(g=d.child,g!==null)g.return=d,cn=g;else e:for(d=r;cn!==null;){g=cn;var C=g.sibling,j=g.return;if(T_(g),g===d){cn=null;break e}if(C!==null){C.return=j,cn=C;break e}cn=j}}}var tE={getCacheForType:function(r){var i=mn(qt),d=i.data.get(r);return d===void 0&&(d=r(),i.data.set(r,d)),d},cacheSignal:function(){return mn(qt).controller.signal}},nE=typeof WeakMap=="function"?WeakMap:Map,pt=0,kt=null,rt=null,at=0,_t=0,Hn=null,Cs=!1,ha=!1,Ph=!1,Jr=0,$t=0,ks=0,hi=0,Bh=0,$n=0,fa=0,Eo=null,An=null,zh=!1,mc=0,H_=0,pc=1/0,gc=null,Es=null,tn=0,js=null,ma=null,Zr=0,Hh=0,$h=null,$_=null,jo=0,Uh=null;function Un(){return(pt&2)!==0&&at!==0?at&-at:z.T!==null?Kh():dt()}function U_(){if($n===0)if((at&536870912)===0||lt){var r=Oi;Oi<<=1,(Oi&3932160)===0&&(Oi=262144),$n=r}else $n=536870912;return r=Bn.current,r!==null&&(r.flags|=32),$n}function Ln(r,i,d){(r===kt&&(_t===2||_t===9)||r.cancelPendingCommit!==null)&&(pa(r,0),Ns(r,at,$n,!1)),hs(r,d),((pt&2)===0||r!==kt)&&(r===kt&&((pt&2)===0&&(hi|=d),$t===4&&Ns(r,at,$n,!1)),jr(r))}function F_(r,i,d){if((pt&6)!==0)throw Error(s(327));var g=!d&&(i&127)===0&&(i&r.expiredLanes)===0||Ys(r,i),C=g?iE(r,i):Vh(r,i,!0),j=g;do{if(C===0){ha&&!g&&Ns(r,i,0,!1);break}else{if(d=r.current.alternate,j&&!rE(d)){C=Vh(r,i,!1),j=!1;continue}if(C===2){if(j=i,r.errorRecoveryDisabledLanes&j)var I=0;else I=r.pendingLanes&-536870913,I=I!==0?I:I&536870912?536870912:0;if(I!==0){i=I;e:{var K=r;C=Eo;var re=K.current.memoizedState.isDehydrated;if(re&&(pa(K,I).flags|=256),I=Vh(K,I,!1),I!==2){if(Ph&&!re){K.errorRecoveryDisabledLanes|=j,hi|=j,C=4;break e}j=An,An=C,j!==null&&(An===null?An=j:An.push.apply(An,j))}C=I}if(j=!1,C!==2)continue}}if(C===1){pa(r,0),Ns(r,i,0,!0);break}e:{switch(g=r,j=C,j){case 0:case 1:throw Error(s(345));case 4:if((i&4194048)!==i)break;case 6:Ns(g,i,$n,!Cs);break e;case 2:An=null;break;case 3:case 5:break;default:throw Error(s(329))}if((i&62914560)===i&&(C=mc+300-gt(),10<C)){if(Ns(g,i,$n,!Cs),Ii(g,0,!0)!==0)break e;Zr=i,g.timeoutHandle=vy(V_.bind(null,g,d,An,gc,zh,i,$n,hi,fa,Cs,j,"Throttled",-0,0),C);break e}V_(g,d,An,gc,zh,i,$n,hi,fa,Cs,j,null,-0,0)}}break}while(!0);jr(r)}function V_(r,i,d,g,C,j,I,K,re,le,xe,be,ue,fe){if(r.timeoutHandle=-1,be=i.subtreeFlags,be&8192||(be&16785408)===16785408){be={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Br},I_(i,j,be);var Re=(j&62914560)===j?mc-gt():(j&4194048)===j?H_-gt():0;if(Re=$E(be,Re),Re!==null){Zr=j,r.cancelPendingCommit=Re(J_.bind(null,r,i,j,d,g,C,I,K,re,xe,be,null,ue,fe)),Ns(r,j,I,!le);return}}J_(r,i,j,d,g,C,I,K,re)}function rE(r){for(var i=r;;){var d=i.tag;if((d===0||d===11||d===15)&&i.flags&16384&&(d=i.updateQueue,d!==null&&(d=d.stores,d!==null)))for(var g=0;g<d.length;g++){var C=d[g],j=C.getSnapshot;C=C.value;try{if(!In(j(),C))return!1}catch{return!1}}if(d=i.child,i.subtreeFlags&16384&&d!==null)d.return=i,i=d;else{if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function Ns(r,i,d,g){i&=~Bh,i&=~hi,r.suspendedLanes|=i,r.pingedLanes&=~i,g&&(r.warmLanes|=i),g=r.expirationTimes;for(var C=i;0<C;){var j=31-He(C),I=1<<j;g[j]=-1,C&=~I}d!==0&&_e(r,d,i)}function xc(){return(pt&6)===0?(No(0),!1):!0}function Fh(){if(rt!==null){if(_t===0)var r=rt.return;else r=rt,Ur=ri=null,ih(r),ia=null,co=0,r=rt;for(;r!==null;)b_(r.alternate,r),r=r.return;rt=null}}function pa(r,i){var d=r.timeoutHandle;d!==-1&&(r.timeoutHandle=-1,wE(d)),d=r.cancelPendingCommit,d!==null&&(r.cancelPendingCommit=null,d()),Zr=0,Fh(),kt=r,rt=d=Hr(r.current,null),at=i,_t=0,Hn=null,Cs=!1,ha=Ys(r,i),Ph=!1,fa=$n=Bh=hi=ks=$t=0,An=Eo=null,zh=!1,(i&8)!==0&&(i|=i&32);var g=r.entangledLanes;if(g!==0)for(r=r.entanglements,g&=i;0<g;){var C=31-He(g),j=1<<C;i|=r[C],g&=~j}return Jr=i,Bl(),d}function G_(r,i){Ye=null,z.H=_o,i===sa||i===Wl?(i=ox(),_t=3):i===qd?(i=ox(),_t=4):_t=i===bh?8:i!==null&&typeof i=="object"&&typeof i.then=="function"?6:1,Hn=i,rt===null&&($t=1,ac(r,Qn(i,r.current)))}function W_(){var r=Bn.current;return r===null?!0:(at&4194048)===at?tr===null:(at&62914560)===at||(at&536870912)!==0?r===tr:!1}function q_(){var r=z.H;return z.H=_o,r===null?_o:r}function K_(){var r=z.A;return z.A=tE,r}function _c(){$t=4,Cs||(at&4194048)!==at&&Bn.current!==null||(ha=!0),(ks&134217727)===0&&(hi&134217727)===0||kt===null||Ns(kt,at,$n,!1)}function Vh(r,i,d){var g=pt;pt|=2;var C=q_(),j=K_();(kt!==r||at!==i)&&(gc=null,pa(r,i)),i=!1;var I=$t;e:do try{if(_t!==0&&rt!==null){var K=rt,re=Hn;switch(_t){case 8:Fh(),I=6;break e;case 3:case 2:case 9:case 6:Bn.current===null&&(i=!0);var le=_t;if(_t=0,Hn=null,ga(r,K,re,le),d&&ha){I=0;break e}break;default:le=_t,_t=0,Hn=null,ga(r,K,re,le)}}sE(),I=$t;break}catch(xe){G_(r,xe)}while(!0);return i&&r.shellSuspendCounter++,Ur=ri=null,pt=g,z.H=C,z.A=j,rt===null&&(kt=null,at=0,Bl()),I}function sE(){for(;rt!==null;)Y_(rt)}function iE(r,i){var d=pt;pt|=2;var g=q_(),C=K_();kt!==r||at!==i?(gc=null,pc=gt()+500,pa(r,i)):ha=Ys(r,i);e:do try{if(_t!==0&&rt!==null){i=rt;var j=Hn;t:switch(_t){case 1:_t=0,Hn=null,ga(r,i,j,1);break;case 2:case 9:if(ix(j)){_t=0,Hn=null,X_(i);break}i=function(){_t!==2&&_t!==9||kt!==r||(_t=7),jr(r)},j.then(i,i);break e;case 3:_t=7;break e;case 4:_t=5;break e;case 7:ix(j)?(_t=0,Hn=null,X_(i)):(_t=0,Hn=null,ga(r,i,j,7));break;case 5:var I=null;switch(rt.tag){case 26:I=rt.memoizedState;case 5:case 27:var K=rt;if(I?My(I):K.stateNode.complete){_t=0,Hn=null;var re=K.sibling;if(re!==null)rt=re;else{var le=K.return;le!==null?(rt=le,yc(le)):rt=null}break t}}_t=0,Hn=null,ga(r,i,j,5);break;case 6:_t=0,Hn=null,ga(r,i,j,6);break;case 8:Fh(),$t=6;break e;default:throw Error(s(462))}}aE();break}catch(xe){G_(r,xe)}while(!0);return Ur=ri=null,z.H=g,z.A=C,pt=d,rt!==null?0:(kt=null,at=0,Bl(),$t)}function aE(){for(;rt!==null&&!nt();)Y_(rt)}function Y_(r){var i=y_(r.alternate,r,Jr);r.memoizedProps=r.pendingProps,i===null?yc(r):rt=i}function X_(r){var i=r,d=i.alternate;switch(i.tag){case 15:case 0:i=f_(d,i,i.pendingProps,i.type,void 0,at);break;case 11:i=f_(d,i,i.pendingProps,i.type.render,i.ref,at);break;case 5:ih(i);default:b_(d,i),i=rt=Kg(i,Jr),i=y_(d,i,Jr)}r.memoizedProps=r.pendingProps,i===null?yc(r):rt=i}function ga(r,i,d,g){Ur=ri=null,ih(i),ia=null,co=0;var C=i.return;try{if(Kk(r,C,i,d,at)){$t=1,ac(r,Qn(d,r.current)),rt=null;return}}catch(j){if(C!==null)throw rt=C,j;$t=1,ac(r,Qn(d,r.current)),rt=null;return}i.flags&32768?(lt||g===1?r=!0:ha||(at&536870912)!==0?r=!1:(Cs=r=!0,(g===2||g===9||g===3||g===6)&&(g=Bn.current,g!==null&&g.tag===13&&(g.flags|=16384))),Q_(i,r)):yc(i)}function yc(r){var i=r;do{if((i.flags&32768)!==0){Q_(i,Cs);return}r=i.return;var d=Qk(i.alternate,i,Jr);if(d!==null){rt=d;return}if(i=i.sibling,i!==null){rt=i;return}rt=i=r}while(i!==null);$t===0&&($t=5)}function Q_(r,i){do{var d=Jk(r.alternate,r);if(d!==null){d.flags&=32767,rt=d;return}if(d=r.return,d!==null&&(d.flags|=32768,d.subtreeFlags=0,d.deletions=null),!i&&(r=r.sibling,r!==null)){rt=r;return}rt=r=d}while(r!==null);$t=6,rt=null}function J_(r,i,d,g,C,j,I,K,re){r.cancelPendingCommit=null;do vc();while(tn!==0);if((pt&6)!==0)throw Error(s(327));if(i!==null){if(i===r.current)throw Error(s(177));if(j=i.lanes|i.childLanes,j|=Dd,ye(r,d,j,I,K,re),r===kt&&(rt=kt=null,at=0),ma=i,js=r,Zr=d,Hh=j,$h=C,$_=g,(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,uE(Oe,function(){return ry(),null})):(r.callbackNode=null,r.callbackPriority=0),g=(i.flags&13878)!==0,(i.subtreeFlags&13878)!==0||g){g=z.T,z.T=null,C=X.p,X.p=2,I=pt,pt|=4;try{Zk(r,i,d)}finally{pt=I,X.p=C,z.T=g}}tn=1,Z_(),ey(),ty()}}function Z_(){if(tn===1){tn=0;var r=js,i=ma,d=(i.flags&13878)!==0;if((i.subtreeFlags&13878)!==0||d){d=z.T,z.T=null;var g=X.p;X.p=2;var C=pt;pt|=4;try{R_(i,r);var j=nf,I=zg(r.containerInfo),K=j.focusedElem,re=j.selectionRange;if(I!==K&&K&&K.ownerDocument&&Bg(K.ownerDocument.documentElement,K)){if(re!==null&&jd(K)){var le=re.start,xe=re.end;if(xe===void 0&&(xe=le),"selectionStart"in K)K.selectionStart=le,K.selectionEnd=Math.min(xe,K.value.length);else{var be=K.ownerDocument||document,ue=be&&be.defaultView||window;if(ue.getSelection){var fe=ue.getSelection(),Re=K.textContent.length,Fe=Math.min(re.start,Re),Ct=re.end===void 0?Fe:Math.min(re.end,Re);!fe.extend&&Fe>Ct&&(I=Ct,Ct=Fe,Fe=I);var ae=Pg(K,Fe),ie=Pg(K,Ct);if(ae&&ie&&(fe.rangeCount!==1||fe.anchorNode!==ae.node||fe.anchorOffset!==ae.offset||fe.focusNode!==ie.node||fe.focusOffset!==ie.offset)){var oe=be.createRange();oe.setStart(ae.node,ae.offset),fe.removeAllRanges(),Fe>Ct?(fe.addRange(oe),fe.extend(ie.node,ie.offset)):(oe.setEnd(ie.node,ie.offset),fe.addRange(oe))}}}}for(be=[],fe=K;fe=fe.parentNode;)fe.nodeType===1&&be.push({element:fe,left:fe.scrollLeft,top:fe.scrollTop});for(typeof K.focus=="function"&&K.focus(),K=0;K<be.length;K++){var ve=be[K];ve.element.scrollLeft=ve.left,ve.element.scrollTop=ve.top}}Dc=!!tf,nf=tf=null}finally{pt=C,X.p=g,z.T=d}}r.current=i,tn=2}}function ey(){if(tn===2){tn=0;var r=js,i=ma,d=(i.flags&8772)!==0;if((i.subtreeFlags&8772)!==0||d){d=z.T,z.T=null;var g=X.p;X.p=2;var C=pt;pt|=4;try{N_(r,i.alternate,i)}finally{pt=C,X.p=g,z.T=d}}tn=3}}function ty(){if(tn===4||tn===3){tn=0,Mt();var r=js,i=ma,d=Zr,g=$_;(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?tn=5:(tn=0,ma=js=null,ny(r,r.pendingLanes));var C=r.pendingLanes;if(C===0&&(Es=null),qe(d),i=i.stateNode,ct&&typeof ct.onCommitFiberRoot=="function")try{ct.onCommitFiberRoot(bt,i,void 0,(i.current.flags&128)===128)}catch{}if(g!==null){i=z.T,C=X.p,X.p=2,z.T=null;try{for(var j=r.onRecoverableError,I=0;I<g.length;I++){var K=g[I];j(K.value,{componentStack:K.stack})}}finally{z.T=i,X.p=C}}(Zr&3)!==0&&vc(),jr(r),C=r.pendingLanes,(d&261930)!==0&&(C&42)!==0?r===Uh?jo++:(jo=0,Uh=r):jo=0,No(0)}}function ny(r,i){(r.pooledCacheLanes&=i)===0&&(i=r.pooledCache,i!=null&&(r.pooledCache=null,oo(i)))}function vc(){return Z_(),ey(),ty(),ry()}function ry(){if(tn!==5)return!1;var r=js,i=Hh;Hh=0;var d=qe(Zr),g=z.T,C=X.p;try{X.p=32>d?32:d,z.T=null,d=$h,$h=null;var j=js,I=Zr;if(tn=0,ma=js=null,Zr=0,(pt&6)!==0)throw Error(s(331));var K=pt;if(pt|=4,B_(j.current),M_(j,j.current,I,d),pt=K,No(0,!1),ct&&typeof ct.onPostCommitFiberRoot=="function")try{ct.onPostCommitFiberRoot(bt,j)}catch{}return!0}finally{X.p=C,z.T=g,ny(r,i)}}function sy(r,i,d){i=Qn(d,i),i=vh(r.stateNode,i,2),r=vs(r,i,2),r!==null&&(hs(r,2),jr(r))}function yt(r,i,d){if(r.tag===3)sy(r,r,d);else for(;i!==null;){if(i.tag===3){sy(i,r,d);break}else if(i.tag===1){var g=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Es===null||!Es.has(g))){r=Qn(d,r),d=i_(2),g=vs(i,d,2),g!==null&&(a_(d,g,i,r),hs(g,2),jr(g));break}}i=i.return}}function Gh(r,i,d){var g=r.pingCache;if(g===null){g=r.pingCache=new nE;var C=new Set;g.set(i,C)}else C=g.get(i),C===void 0&&(C=new Set,g.set(i,C));C.has(d)||(Ph=!0,C.add(d),r=oE.bind(null,r,i,d),i.then(r,r))}function oE(r,i,d){var g=r.pingCache;g!==null&&g.delete(i),r.pingedLanes|=r.suspendedLanes&d,r.warmLanes&=~d,kt===r&&(at&d)===d&&($t===4||$t===3&&(at&62914560)===at&&300>gt()-mc?(pt&2)===0&&pa(r,0):Bh|=d,fa===at&&(fa=0)),jr(r)}function iy(r,i){i===0&&(i=El()),r=ei(r,i),r!==null&&(hs(r,i),jr(r))}function lE(r){var i=r.memoizedState,d=0;i!==null&&(d=i.retryLane),iy(r,d)}function cE(r,i){var d=0;switch(r.tag){case 31:case 13:var g=r.stateNode,C=r.memoizedState;C!==null&&(d=C.retryLane);break;case 19:g=r.stateNode;break;case 22:g=r.stateNode._retryCache;break;default:throw Error(s(314))}g!==null&&g.delete(i),iy(r,d)}function uE(r,i){return me(r,i)}var bc=null,xa=null,Wh=!1,Sc=!1,qh=!1,Ts=0;function jr(r){r!==xa&&r.next===null&&(xa===null?bc=xa=r:xa=xa.next=r),Sc=!0,Wh||(Wh=!0,hE())}function No(r,i){if(!qh&&Sc){qh=!0;do for(var d=!1,g=bc;g!==null;){if(r!==0){var C=g.pendingLanes;if(C===0)var j=0;else{var I=g.suspendedLanes,K=g.pingedLanes;j=(1<<31-He(42|r)+1)-1,j&=C&~(I&~K),j=j&201326741?j&201326741|1:j?j|2:0}j!==0&&(d=!0,cy(g,j))}else j=at,j=Ii(g,g===kt?j:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(j&3)===0||Ys(g,j)||(d=!0,cy(g,j));g=g.next}while(d);qh=!1}}function dE(){ay()}function ay(){Sc=Wh=!1;var r=0;Ts!==0&&SE()&&(r=Ts);for(var i=gt(),d=null,g=bc;g!==null;){var C=g.next,j=oy(g,i);j===0?(g.next=null,d===null?bc=C:d.next=C,C===null&&(xa=d)):(d=g,(r!==0||(j&3)!==0)&&(Sc=!0)),g=C}tn!==0&&tn!==5||No(r),Ts!==0&&(Ts=0)}function oy(r,i){for(var d=r.suspendedLanes,g=r.pingedLanes,C=r.expirationTimes,j=r.pendingLanes&-62914561;0<j;){var I=31-He(j),K=1<<I,re=C[I];re===-1?((K&d)===0||(K&g)!==0)&&(C[I]=qa(K,i)):re<=i&&(r.expiredLanes|=K),j&=~K}if(i=kt,d=at,d=Ii(r,r===i?d:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),g=r.callbackNode,d===0||r===i&&(_t===2||_t===9)||r.cancelPendingCommit!==null)return g!==null&&g!==null&&je(g),r.callbackNode=null,r.callbackPriority=0;if((d&3)===0||Ys(r,d)){if(i=d&-d,i===r.callbackPriority)return i;switch(g!==null&&je(g),qe(d)){case 2:case 8:d=Ce;break;case 32:d=Oe;break;case 268435456:d=Ge;break;default:d=Oe}return g=ly.bind(null,r),d=me(d,g),r.callbackPriority=i,r.callbackNode=d,i}return g!==null&&g!==null&&je(g),r.callbackPriority=2,r.callbackNode=null,2}function ly(r,i){if(tn!==0&&tn!==5)return r.callbackNode=null,r.callbackPriority=0,null;var d=r.callbackNode;if(vc()&&r.callbackNode!==d)return null;var g=at;return g=Ii(r,r===kt?g:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),g===0?null:(F_(r,g,i),oy(r,gt()),r.callbackNode!=null&&r.callbackNode===d?ly.bind(null,r):null)}function cy(r,i){if(vc())return null;F_(r,i,!0)}function hE(){CE(function(){(pt&6)!==0?me(ge,dE):ay()})}function Kh(){if(Ts===0){var r=na;r===0&&(r=dr,dr<<=1,(dr&261888)===0&&(dr=256)),Ts=r}return Ts}function uy(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:Al(""+r)}function dy(r,i){var d=i.ownerDocument.createElement("input");return d.name=i.name,d.value=i.value,r.id&&d.setAttribute("form",r.id),i.parentNode.insertBefore(d,i),r=new FormData(r),d.parentNode.removeChild(d),r}function fE(r,i,d,g,C){if(i==="submit"&&d&&d.stateNode===C){var j=uy((C[kn]||null).action),I=g.submitter;I&&(i=(i=I[kn]||null)?uy(i.formAction):I.getAttribute("formAction"),i!==null&&(j=i,I=null));var K=new Ol("action","action",null,g,C);r.push({event:K,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(Ts!==0){var re=I?dy(C,I):new FormData(C);mh(d,{pending:!0,data:re,method:C.method,action:j},null,re)}}else typeof j=="function"&&(K.preventDefault(),re=I?dy(C,I):new FormData(C),mh(d,{pending:!0,data:re,method:C.method,action:j},j,re))},currentTarget:C}]})}}for(var Yh=0;Yh<Ld.length;Yh++){var Xh=Ld[Yh],mE=Xh.toLowerCase(),pE=Xh[0].toUpperCase()+Xh.slice(1);hr(mE,"on"+pE)}hr(Ug,"onAnimationEnd"),hr(Fg,"onAnimationIteration"),hr(Vg,"onAnimationStart"),hr("dblclick","onDoubleClick"),hr("focusin","onFocus"),hr("focusout","onBlur"),hr(Lk,"onTransitionRun"),hr(Dk,"onTransitionStart"),hr(Rk,"onTransitionCancel"),hr(Gg,"onTransitionEnd"),Ui("onMouseEnter",["mouseout","mouseover"]),Ui("onMouseLeave",["mouseout","mouseover"]),Ui("onPointerEnter",["pointerout","pointerover"]),Ui("onPointerLeave",["pointerout","pointerover"]),Xs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Xs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Xs("onBeforeInput",["compositionend","keypress","textInput","paste"]),Xs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Xs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Xs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var To="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(" "),gE=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(To));function hy(r,i){i=(i&4)!==0;for(var d=0;d<r.length;d++){var g=r[d],C=g.event;g=g.listeners;e:{var j=void 0;if(i)for(var I=g.length-1;0<=I;I--){var K=g[I],re=K.instance,le=K.currentTarget;if(K=K.listener,re!==j&&C.isPropagationStopped())break e;j=K,C.currentTarget=le;try{j(C)}catch(xe){Pl(xe)}C.currentTarget=null,j=re}else for(I=0;I<g.length;I++){if(K=g[I],re=K.instance,le=K.currentTarget,K=K.listener,re!==j&&C.isPropagationStopped())break e;j=K,C.currentTarget=le;try{j(C)}catch(xe){Pl(xe)}C.currentTarget=null,j=re}}}}function st(r,i){var d=i[cd];d===void 0&&(d=i[cd]=new Set);var g=r+"__bubble";d.has(g)||(fy(i,r,2,!1),d.add(g))}function Qh(r,i,d){var g=0;i&&(g|=4),fy(d,r,g,i)}var wc="_reactListening"+Math.random().toString(36).slice(2);function Jh(r){if(!r[wc]){r[wc]=!0,ag.forEach(function(d){d!=="selectionchange"&&(gE.has(d)||Qh(d,!1,r),Qh(d,!0,r))});var i=r.nodeType===9?r:r.ownerDocument;i===null||i[wc]||(i[wc]=!0,Qh("selectionchange",!1,i))}}function fy(r,i,d,g){switch(Uy(i)){case 2:var C=VE;break;case 8:C=GE;break;default:C=mf}d=C.bind(null,i,d,r),C=void 0,!_d||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(C=!0),g?C!==void 0?r.addEventListener(i,d,{capture:!0,passive:C}):r.addEventListener(i,d,!0):C!==void 0?r.addEventListener(i,d,{passive:C}):r.addEventListener(i,d,!1)}function Zh(r,i,d,g,C){var j=g;if((i&1)===0&&(i&2)===0&&g!==null)e:for(;;){if(g===null)return;var I=g.tag;if(I===3||I===4){var K=g.stateNode.containerInfo;if(K===C)break;if(I===4)for(I=g.return;I!==null;){var re=I.tag;if((re===3||re===4)&&I.stateNode.containerInfo===C)return;I=I.return}for(;K!==null;){if(I=zi(K),I===null)return;if(re=I.tag,re===5||re===6||re===26||re===27){g=j=I;continue e}K=K.parentNode}}g=g.return}_g(function(){var le=j,xe=gd(d),be=[];e:{var ue=Wg.get(r);if(ue!==void 0){var fe=Ol,Re=r;switch(r){case"keypress":if(Dl(d)===0)break e;case"keydown":case"keyup":fe=ck;break;case"focusin":Re="focus",fe=Sd;break;case"focusout":Re="blur",fe=Sd;break;case"beforeblur":case"afterblur":fe=Sd;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=bg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=QC;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=hk;break;case Ug:case Fg:case Vg:fe=ek;break;case Gg:fe=mk;break;case"scroll":case"scrollend":fe=YC;break;case"wheel":fe=gk;break;case"copy":case"cut":case"paste":fe=nk;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=wg;break;case"toggle":case"beforetoggle":fe=_k}var Fe=(i&4)!==0,Ct=!Fe&&(r==="scroll"||r==="scrollend"),ae=Fe?ue!==null?ue+"Capture":null:ue;Fe=[];for(var ie=le,oe;ie!==null;){var ve=ie;if(oe=ve.stateNode,ve=ve.tag,ve!==5&&ve!==26&&ve!==27||oe===null||ae===null||(ve=Xa(ie,ae),ve!=null&&Fe.push(Ao(ie,ve,oe))),Ct)break;ie=ie.return}0<Fe.length&&(ue=new fe(ue,Re,null,d,xe),be.push({event:ue,listeners:Fe}))}}if((i&7)===0){e:{if(ue=r==="mouseover"||r==="pointerover",fe=r==="mouseout"||r==="pointerout",ue&&d!==pd&&(Re=d.relatedTarget||d.fromElement)&&(zi(Re)||Re[Bi]))break e;if((fe||ue)&&(ue=xe.window===xe?xe:(ue=xe.ownerDocument)?ue.defaultView||ue.parentWindow:window,fe?(Re=d.relatedTarget||d.toElement,fe=le,Re=Re?zi(Re):null,Re!==null&&(Ct=l(Re),Fe=Re.tag,Re!==Ct||Fe!==5&&Fe!==27&&Fe!==6)&&(Re=null)):(fe=null,Re=le),fe!==Re)){if(Fe=bg,ve="onMouseLeave",ae="onMouseEnter",ie="mouse",(r==="pointerout"||r==="pointerover")&&(Fe=wg,ve="onPointerLeave",ae="onPointerEnter",ie="pointer"),Ct=fe==null?ue:Ya(fe),oe=Re==null?ue:Ya(Re),ue=new Fe(ve,ie+"leave",fe,d,xe),ue.target=Ct,ue.relatedTarget=oe,ve=null,zi(xe)===le&&(Fe=new Fe(ae,ie+"enter",Re,d,xe),Fe.target=oe,Fe.relatedTarget=Ct,ve=Fe),Ct=ve,fe&&Re)t:{for(Fe=xE,ae=fe,ie=Re,oe=0,ve=ae;ve;ve=Fe(ve))oe++;ve=0;for(var Be=ie;Be;Be=Fe(Be))ve++;for(;0<oe-ve;)ae=Fe(ae),oe--;for(;0<ve-oe;)ie=Fe(ie),ve--;for(;oe--;){if(ae===ie||ie!==null&&ae===ie.alternate){Fe=ae;break t}ae=Fe(ae),ie=Fe(ie)}Fe=null}else Fe=null;fe!==null&&my(be,ue,fe,Fe,!1),Re!==null&&Ct!==null&&my(be,Ct,Re,Fe,!0)}}e:{if(ue=le?Ya(le):window,fe=ue.nodeName&&ue.nodeName.toLowerCase(),fe==="select"||fe==="input"&&ue.type==="file")var ht=Lg;else if(Tg(ue))if(Dg)ht=Nk;else{ht=Ek;var Me=kk}else fe=ue.nodeName,!fe||fe.toLowerCase()!=="input"||ue.type!=="checkbox"&&ue.type!=="radio"?le&&md(le.elementType)&&(ht=Lg):ht=jk;if(ht&&(ht=ht(r,le))){Ag(be,ht,d,xe);break e}Me&&Me(r,ue,le),r==="focusout"&&le&&ue.type==="number"&&le.memoizedProps.value!=null&&fd(ue,"number",ue.value)}switch(Me=le?Ya(le):window,r){case"focusin":(Tg(Me)||Me.contentEditable==="true")&&(Ki=Me,Nd=le,so=null);break;case"focusout":so=Nd=Ki=null;break;case"mousedown":Td=!0;break;case"contextmenu":case"mouseup":case"dragend":Td=!1,Hg(be,d,xe);break;case"selectionchange":if(Ak)break;case"keydown":case"keyup":Hg(be,d,xe)}var Qe;if(Cd)e:{switch(r){case"compositionstart":var ot="onCompositionStart";break e;case"compositionend":ot="onCompositionEnd";break e;case"compositionupdate":ot="onCompositionUpdate";break e}ot=void 0}else qi?jg(r,d)&&(ot="onCompositionEnd"):r==="keydown"&&d.keyCode===229&&(ot="onCompositionStart");ot&&(Cg&&d.locale!=="ko"&&(qi||ot!=="onCompositionStart"?ot==="onCompositionEnd"&&qi&&(Qe=yg()):(fs=xe,yd="value"in fs?fs.value:fs.textContent,qi=!0)),Me=Cc(le,ot),0<Me.length&&(ot=new Sg(ot,r,null,d,xe),be.push({event:ot,listeners:Me}),Qe?ot.data=Qe:(Qe=Ng(d),Qe!==null&&(ot.data=Qe)))),(Qe=vk?bk(r,d):Sk(r,d))&&(ot=Cc(le,"onBeforeInput"),0<ot.length&&(Me=new Sg("onBeforeInput","beforeinput",null,d,xe),be.push({event:Me,listeners:ot}),Me.data=Qe)),fE(be,r,le,d,xe)}hy(be,i)})}function Ao(r,i,d){return{instance:r,listener:i,currentTarget:d}}function Cc(r,i){for(var d=i+"Capture",g=[];r!==null;){var C=r,j=C.stateNode;if(C=C.tag,C!==5&&C!==26&&C!==27||j===null||(C=Xa(r,d),C!=null&&g.unshift(Ao(r,C,j)),C=Xa(r,i),C!=null&&g.push(Ao(r,C,j))),r.tag===3)return g;r=r.return}return[]}function xE(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function my(r,i,d,g,C){for(var j=i._reactName,I=[];d!==null&&d!==g;){var K=d,re=K.alternate,le=K.stateNode;if(K=K.tag,re!==null&&re===g)break;K!==5&&K!==26&&K!==27||le===null||(re=le,C?(le=Xa(d,j),le!=null&&I.unshift(Ao(d,le,re))):C||(le=Xa(d,j),le!=null&&I.push(Ao(d,le,re)))),d=d.return}I.length!==0&&r.push({event:i,listeners:I})}var _E=/\r\n?/g,yE=/\u0000|\uFFFD/g;function py(r){return(typeof r=="string"?r:""+r).replace(_E,`
|
|
50
|
+
`).replace(yE,"")}function gy(r,i){return i=py(i),py(r)===i}function wt(r,i,d,g,C,j){switch(d){case"children":typeof g=="string"?i==="body"||i==="textarea"&&g===""||Vi(r,g):(typeof g=="number"||typeof g=="bigint")&&i!=="body"&&Vi(r,""+g);break;case"className":Nl(r,"class",g);break;case"tabIndex":Nl(r,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":Nl(r,d,g);break;case"style":gg(r,g,j);break;case"data":if(i!=="object"){Nl(r,"data",g);break}case"src":case"href":if(g===""&&(i!=="a"||d!=="href")){r.removeAttribute(d);break}if(g==null||typeof g=="function"||typeof g=="symbol"||typeof g=="boolean"){r.removeAttribute(d);break}g=Al(""+g),r.setAttribute(d,g);break;case"action":case"formAction":if(typeof g=="function"){r.setAttribute(d,"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 j=="function"&&(d==="formAction"?(i!=="input"&&wt(r,i,"name",C.name,C,null),wt(r,i,"formEncType",C.formEncType,C,null),wt(r,i,"formMethod",C.formMethod,C,null),wt(r,i,"formTarget",C.formTarget,C,null)):(wt(r,i,"encType",C.encType,C,null),wt(r,i,"method",C.method,C,null),wt(r,i,"target",C.target,C,null)));if(g==null||typeof g=="symbol"||typeof g=="boolean"){r.removeAttribute(d);break}g=Al(""+g),r.setAttribute(d,g);break;case"onClick":g!=null&&(r.onclick=Br);break;case"onScroll":g!=null&&st("scroll",r);break;case"onScrollEnd":g!=null&&st("scrollend",r);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(s(61));if(d=g.__html,d!=null){if(C.children!=null)throw Error(s(60));r.innerHTML=d}}break;case"multiple":r.multiple=g&&typeof g!="function"&&typeof g!="symbol";break;case"muted":r.muted=g&&typeof g!="function"&&typeof g!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(g==null||typeof g=="function"||typeof g=="boolean"||typeof g=="symbol"){r.removeAttribute("xlink:href");break}d=Al(""+g),r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",d);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":g!=null&&typeof g!="function"&&typeof g!="symbol"?r.setAttribute(d,""+g):r.removeAttribute(d);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":g&&typeof g!="function"&&typeof g!="symbol"?r.setAttribute(d,""):r.removeAttribute(d);break;case"capture":case"download":g===!0?r.setAttribute(d,""):g!==!1&&g!=null&&typeof g!="function"&&typeof g!="symbol"?r.setAttribute(d,g):r.removeAttribute(d);break;case"cols":case"rows":case"size":case"span":g!=null&&typeof g!="function"&&typeof g!="symbol"&&!isNaN(g)&&1<=g?r.setAttribute(d,g):r.removeAttribute(d);break;case"rowSpan":case"start":g==null||typeof g=="function"||typeof g=="symbol"||isNaN(g)?r.removeAttribute(d):r.setAttribute(d,g);break;case"popover":st("beforetoggle",r),st("toggle",r),jl(r,"popover",g);break;case"xlinkActuate":Pr(r,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":Pr(r,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":Pr(r,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":Pr(r,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":Pr(r,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":Pr(r,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":Pr(r,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":Pr(r,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":Pr(r,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":jl(r,"is",g);break;case"innerText":case"textContent":break;default:(!(2<d.length)||d[0]!=="o"&&d[0]!=="O"||d[1]!=="n"&&d[1]!=="N")&&(d=qC.get(d)||d,jl(r,d,g))}}function ef(r,i,d,g,C,j){switch(d){case"style":gg(r,g,j);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(s(61));if(d=g.__html,d!=null){if(C.children!=null)throw Error(s(60));r.innerHTML=d}}break;case"children":typeof g=="string"?Vi(r,g):(typeof g=="number"||typeof g=="bigint")&&Vi(r,""+g);break;case"onScroll":g!=null&&st("scroll",r);break;case"onScrollEnd":g!=null&&st("scrollend",r);break;case"onClick":g!=null&&(r.onclick=Br);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!og.hasOwnProperty(d))e:{if(d[0]==="o"&&d[1]==="n"&&(C=d.endsWith("Capture"),i=d.slice(2,C?d.length-7:void 0),j=r[kn]||null,j=j!=null?j[d]:null,typeof j=="function"&&r.removeEventListener(i,j,C),typeof g=="function")){typeof j!="function"&&j!==null&&(d in r?r[d]=null:r.hasAttribute(d)&&r.removeAttribute(d)),r.addEventListener(i,g,C);break e}d in r?r[d]=g:g===!0?r.setAttribute(d,""):jl(r,d,g)}}}function gn(r,i,d){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":st("error",r),st("load",r);var g=!1,C=!1,j;for(j in d)if(d.hasOwnProperty(j)){var I=d[j];if(I!=null)switch(j){case"src":g=!0;break;case"srcSet":C=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:wt(r,i,j,I,d,null)}}C&&wt(r,i,"srcSet",d.srcSet,d,null),g&&wt(r,i,"src",d.src,d,null);return;case"input":st("invalid",r);var K=j=I=C=null,re=null,le=null;for(g in d)if(d.hasOwnProperty(g)){var xe=d[g];if(xe!=null)switch(g){case"name":C=xe;break;case"type":I=xe;break;case"checked":re=xe;break;case"defaultChecked":le=xe;break;case"value":j=xe;break;case"defaultValue":K=xe;break;case"children":case"dangerouslySetInnerHTML":if(xe!=null)throw Error(s(137,i));break;default:wt(r,i,g,xe,d,null)}}hg(r,j,K,re,le,I,C,!1);return;case"select":st("invalid",r),g=I=j=null;for(C in d)if(d.hasOwnProperty(C)&&(K=d[C],K!=null))switch(C){case"value":j=K;break;case"defaultValue":I=K;break;case"multiple":g=K;default:wt(r,i,C,K,d,null)}i=j,d=I,r.multiple=!!g,i!=null?Fi(r,!!g,i,!1):d!=null&&Fi(r,!!g,d,!0);return;case"textarea":st("invalid",r),j=C=g=null;for(I in d)if(d.hasOwnProperty(I)&&(K=d[I],K!=null))switch(I){case"value":g=K;break;case"defaultValue":C=K;break;case"children":j=K;break;case"dangerouslySetInnerHTML":if(K!=null)throw Error(s(91));break;default:wt(r,i,I,K,d,null)}mg(r,g,C,j);return;case"option":for(re in d)if(d.hasOwnProperty(re)&&(g=d[re],g!=null))switch(re){case"selected":r.selected=g&&typeof g!="function"&&typeof g!="symbol";break;default:wt(r,i,re,g,d,null)}return;case"dialog":st("beforetoggle",r),st("toggle",r),st("cancel",r),st("close",r);break;case"iframe":case"object":st("load",r);break;case"video":case"audio":for(g=0;g<To.length;g++)st(To[g],r);break;case"image":st("error",r),st("load",r);break;case"details":st("toggle",r);break;case"embed":case"source":case"link":st("error",r),st("load",r);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(le in d)if(d.hasOwnProperty(le)&&(g=d[le],g!=null))switch(le){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:wt(r,i,le,g,d,null)}return;default:if(md(i)){for(xe in d)d.hasOwnProperty(xe)&&(g=d[xe],g!==void 0&&ef(r,i,xe,g,d,void 0));return}}for(K in d)d.hasOwnProperty(K)&&(g=d[K],g!=null&&wt(r,i,K,g,d,null))}function vE(r,i,d,g){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var C=null,j=null,I=null,K=null,re=null,le=null,xe=null;for(fe in d){var be=d[fe];if(d.hasOwnProperty(fe)&&be!=null)switch(fe){case"checked":break;case"value":break;case"defaultValue":re=be;default:g.hasOwnProperty(fe)||wt(r,i,fe,null,g,be)}}for(var ue in g){var fe=g[ue];if(be=d[ue],g.hasOwnProperty(ue)&&(fe!=null||be!=null))switch(ue){case"type":j=fe;break;case"name":C=fe;break;case"checked":le=fe;break;case"defaultChecked":xe=fe;break;case"value":I=fe;break;case"defaultValue":K=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(s(137,i));break;default:fe!==be&&wt(r,i,ue,fe,g,be)}}hd(r,I,K,re,le,xe,j,C);return;case"select":fe=I=K=ue=null;for(j in d)if(re=d[j],d.hasOwnProperty(j)&&re!=null)switch(j){case"value":break;case"multiple":fe=re;default:g.hasOwnProperty(j)||wt(r,i,j,null,g,re)}for(C in g)if(j=g[C],re=d[C],g.hasOwnProperty(C)&&(j!=null||re!=null))switch(C){case"value":ue=j;break;case"defaultValue":K=j;break;case"multiple":I=j;default:j!==re&&wt(r,i,C,j,g,re)}i=K,d=I,g=fe,ue!=null?Fi(r,!!d,ue,!1):!!g!=!!d&&(i!=null?Fi(r,!!d,i,!0):Fi(r,!!d,d?[]:"",!1));return;case"textarea":fe=ue=null;for(K in d)if(C=d[K],d.hasOwnProperty(K)&&C!=null&&!g.hasOwnProperty(K))switch(K){case"value":break;case"children":break;default:wt(r,i,K,null,g,C)}for(I in g)if(C=g[I],j=d[I],g.hasOwnProperty(I)&&(C!=null||j!=null))switch(I){case"value":ue=C;break;case"defaultValue":fe=C;break;case"children":break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(s(91));break;default:C!==j&&wt(r,i,I,C,g,j)}fg(r,ue,fe);return;case"option":for(var Re in d)if(ue=d[Re],d.hasOwnProperty(Re)&&ue!=null&&!g.hasOwnProperty(Re))switch(Re){case"selected":r.selected=!1;break;default:wt(r,i,Re,null,g,ue)}for(re in g)if(ue=g[re],fe=d[re],g.hasOwnProperty(re)&&ue!==fe&&(ue!=null||fe!=null))switch(re){case"selected":r.selected=ue&&typeof ue!="function"&&typeof ue!="symbol";break;default:wt(r,i,re,ue,g,fe)}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 Fe in d)ue=d[Fe],d.hasOwnProperty(Fe)&&ue!=null&&!g.hasOwnProperty(Fe)&&wt(r,i,Fe,null,g,ue);for(le in g)if(ue=g[le],fe=d[le],g.hasOwnProperty(le)&&ue!==fe&&(ue!=null||fe!=null))switch(le){case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(s(137,i));break;default:wt(r,i,le,ue,g,fe)}return;default:if(md(i)){for(var Ct in d)ue=d[Ct],d.hasOwnProperty(Ct)&&ue!==void 0&&!g.hasOwnProperty(Ct)&&ef(r,i,Ct,void 0,g,ue);for(xe in g)ue=g[xe],fe=d[xe],!g.hasOwnProperty(xe)||ue===fe||ue===void 0&&fe===void 0||ef(r,i,xe,ue,g,fe);return}}for(var ae in d)ue=d[ae],d.hasOwnProperty(ae)&&ue!=null&&!g.hasOwnProperty(ae)&&wt(r,i,ae,null,g,ue);for(be in g)ue=g[be],fe=d[be],!g.hasOwnProperty(be)||ue===fe||ue==null&&fe==null||wt(r,i,be,ue,g,fe)}function xy(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function bE(){if(typeof performance.getEntriesByType=="function"){for(var r=0,i=0,d=performance.getEntriesByType("resource"),g=0;g<d.length;g++){var C=d[g],j=C.transferSize,I=C.initiatorType,K=C.duration;if(j&&K&&xy(I)){for(I=0,K=C.responseEnd,g+=1;g<d.length;g++){var re=d[g],le=re.startTime;if(le>K)break;var xe=re.transferSize,be=re.initiatorType;xe&&xy(be)&&(re=re.responseEnd,I+=xe*(re<K?1:(K-le)/(re-le)))}if(--g,i+=8*(j+I)/(C.duration/1e3),r++,10<r)break}}if(0<r)return i/r/1e6}return navigator.connection&&(r=navigator.connection.downlink,typeof r=="number")?r:5}var tf=null,nf=null;function kc(r){return r.nodeType===9?r:r.ownerDocument}function _y(r){switch(r){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function yy(r,i){if(r===0)switch(i){case"svg":return 1;case"math":return 2;default:return 0}return r===1&&i==="foreignObject"?0:r}function rf(r,i){return r==="textarea"||r==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.children=="bigint"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var sf=null;function SE(){var r=window.event;return r&&r.type==="popstate"?r===sf?!1:(sf=r,!0):(sf=null,!1)}var vy=typeof setTimeout=="function"?setTimeout:void 0,wE=typeof clearTimeout=="function"?clearTimeout:void 0,by=typeof Promise=="function"?Promise:void 0,CE=typeof queueMicrotask=="function"?queueMicrotask:typeof by<"u"?function(r){return by.resolve(null).then(r).catch(kE)}:vy;function kE(r){setTimeout(function(){throw r})}function As(r){return r==="head"}function Sy(r,i){var d=i,g=0;do{var C=d.nextSibling;if(r.removeChild(d),C&&C.nodeType===8)if(d=C.data,d==="/$"||d==="/&"){if(g===0){r.removeChild(C),ba(i);return}g--}else if(d==="$"||d==="$?"||d==="$~"||d==="$!"||d==="&")g++;else if(d==="html")Lo(r.ownerDocument.documentElement);else if(d==="head"){d=r.ownerDocument.head,Lo(d);for(var j=d.firstChild;j;){var I=j.nextSibling,K=j.nodeName;j[Ka]||K==="SCRIPT"||K==="STYLE"||K==="LINK"&&j.rel.toLowerCase()==="stylesheet"||d.removeChild(j),j=I}}else d==="body"&&Lo(r.ownerDocument.body);d=C}while(d);ba(i)}function wy(r,i){var d=r;r=0;do{var g=d.nextSibling;if(d.nodeType===1?i?(d._stashedDisplay=d.style.display,d.style.display="none"):(d.style.display=d._stashedDisplay||"",d.getAttribute("style")===""&&d.removeAttribute("style")):d.nodeType===3&&(i?(d._stashedText=d.nodeValue,d.nodeValue=""):d.nodeValue=d._stashedText||""),g&&g.nodeType===8)if(d=g.data,d==="/$"){if(r===0)break;r--}else d!=="$"&&d!=="$?"&&d!=="$~"&&d!=="$!"||r++;d=g}while(d)}function af(r){var i=r.firstChild;for(i&&i.nodeType===10&&(i=i.nextSibling);i;){var d=i;switch(i=i.nextSibling,d.nodeName){case"HTML":case"HEAD":case"BODY":af(d),ud(d);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(d.rel.toLowerCase()==="stylesheet")continue}r.removeChild(d)}}function EE(r,i,d,g){for(;r.nodeType===1;){var C=d;if(r.nodeName.toLowerCase()!==i.toLowerCase()){if(!g&&(r.nodeName!=="INPUT"||r.type!=="hidden"))break}else if(g){if(!r[Ka])switch(i){case"meta":if(!r.hasAttribute("itemprop"))break;return r;case"link":if(j=r.getAttribute("rel"),j==="stylesheet"&&r.hasAttribute("data-precedence"))break;if(j!==C.rel||r.getAttribute("href")!==(C.href==null||C.href===""?null:C.href)||r.getAttribute("crossorigin")!==(C.crossOrigin==null?null:C.crossOrigin)||r.getAttribute("title")!==(C.title==null?null:C.title))break;return r;case"style":if(r.hasAttribute("data-precedence"))break;return r;case"script":if(j=r.getAttribute("src"),(j!==(C.src==null?null:C.src)||r.getAttribute("type")!==(C.type==null?null:C.type)||r.getAttribute("crossorigin")!==(C.crossOrigin==null?null:C.crossOrigin))&&j&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(i==="input"&&r.type==="hidden"){var j=C.name==null?null:""+C.name;if(C.type==="hidden"&&r.getAttribute("name")===j)return r}else return r;if(r=nr(r.nextSibling),r===null)break}return null}function jE(r,i,d){if(i==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!d||(r=nr(r.nextSibling),r===null))return null;return r}function Cy(r,i){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!i||(r=nr(r.nextSibling),r===null))return null;return r}function of(r){return r.data==="$?"||r.data==="$~"}function lf(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function NE(r,i){var d=r.ownerDocument;if(r.data==="$~")r._reactRetry=i;else if(r.data!=="$?"||d.readyState!=="loading")i();else{var g=function(){i(),d.removeEventListener("DOMContentLoaded",g)};d.addEventListener("DOMContentLoaded",g),r._reactRetry=g}}function nr(r){for(;r!=null;r=r.nextSibling){var i=r.nodeType;if(i===1||i===3)break;if(i===8){if(i=r.data,i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"||i==="F!"||i==="F")break;if(i==="/$"||i==="/&")return null}}return r}var cf=null;function ky(r){r=r.nextSibling;for(var i=0;r;){if(r.nodeType===8){var d=r.data;if(d==="/$"||d==="/&"){if(i===0)return nr(r.nextSibling);i--}else d!=="$"&&d!=="$!"&&d!=="$?"&&d!=="$~"&&d!=="&"||i++}r=r.nextSibling}return null}function Ey(r){r=r.previousSibling;for(var i=0;r;){if(r.nodeType===8){var d=r.data;if(d==="$"||d==="$!"||d==="$?"||d==="$~"||d==="&"){if(i===0)return r;i--}else d!=="/$"&&d!=="/&"||i++}r=r.previousSibling}return null}function jy(r,i,d){switch(i=kc(d),r){case"html":if(r=i.documentElement,!r)throw Error(s(452));return r;case"head":if(r=i.head,!r)throw Error(s(453));return r;case"body":if(r=i.body,!r)throw Error(s(454));return r;default:throw Error(s(451))}}function Lo(r){for(var i=r.attributes;i.length;)r.removeAttributeNode(i[0]);ud(r)}var rr=new Map,Ny=new Set;function Ec(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var es=X.d;X.d={f:TE,r:AE,D:LE,C:DE,L:RE,m:OE,X:IE,S:ME,M:PE};function TE(){var r=es.f(),i=xc();return r||i}function AE(r){var i=Hi(r);i!==null&&i.tag===5&&i.type==="form"?Gx(i):es.r(r)}var _a=typeof document>"u"?null:document;function Ty(r,i,d){var g=_a;if(g&&typeof i=="string"&&i){var C=Yn(i);C='link[rel="'+r+'"][href="'+C+'"]',typeof d=="string"&&(C+='[crossorigin="'+d+'"]'),Ny.has(C)||(Ny.add(C),r={rel:r,crossOrigin:d,href:i},g.querySelector(C)===null&&(i=g.createElement("link"),gn(i,"link",r),ln(i),g.head.appendChild(i)))}}function LE(r){es.D(r),Ty("dns-prefetch",r,null)}function DE(r,i){es.C(r,i),Ty("preconnect",r,i)}function RE(r,i,d){es.L(r,i,d);var g=_a;if(g&&r&&i){var C='link[rel="preload"][as="'+Yn(i)+'"]';i==="image"&&d&&d.imageSrcSet?(C+='[imagesrcset="'+Yn(d.imageSrcSet)+'"]',typeof d.imageSizes=="string"&&(C+='[imagesizes="'+Yn(d.imageSizes)+'"]')):C+='[href="'+Yn(r)+'"]';var j=C;switch(i){case"style":j=ya(r);break;case"script":j=va(r)}rr.has(j)||(r=m({rel:"preload",href:i==="image"&&d&&d.imageSrcSet?void 0:r,as:i},d),rr.set(j,r),g.querySelector(C)!==null||i==="style"&&g.querySelector(Do(j))||i==="script"&&g.querySelector(Ro(j))||(i=g.createElement("link"),gn(i,"link",r),ln(i),g.head.appendChild(i)))}}function OE(r,i){es.m(r,i);var d=_a;if(d&&r){var g=i&&typeof i.as=="string"?i.as:"script",C='link[rel="modulepreload"][as="'+Yn(g)+'"][href="'+Yn(r)+'"]',j=C;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=va(r)}if(!rr.has(j)&&(r=m({rel:"modulepreload",href:r},i),rr.set(j,r),d.querySelector(C)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(d.querySelector(Ro(j)))return}g=d.createElement("link"),gn(g,"link",r),ln(g),d.head.appendChild(g)}}}function ME(r,i,d){es.S(r,i,d);var g=_a;if(g&&r){var C=$i(g).hoistableStyles,j=ya(r);i=i||"default";var I=C.get(j);if(!I){var K={loading:0,preload:null};if(I=g.querySelector(Do(j)))K.loading=5;else{r=m({rel:"stylesheet",href:r,"data-precedence":i},d),(d=rr.get(j))&&uf(r,d);var re=I=g.createElement("link");ln(re),gn(re,"link",r),re._p=new Promise(function(le,xe){re.onload=le,re.onerror=xe}),re.addEventListener("load",function(){K.loading|=1}),re.addEventListener("error",function(){K.loading|=2}),K.loading|=4,jc(I,i,g)}I={type:"stylesheet",instance:I,count:1,state:K},C.set(j,I)}}}function IE(r,i){es.X(r,i);var d=_a;if(d&&r){var g=$i(d).hoistableScripts,C=va(r),j=g.get(C);j||(j=d.querySelector(Ro(C)),j||(r=m({src:r,async:!0},i),(i=rr.get(C))&&df(r,i),j=d.createElement("script"),ln(j),gn(j,"link",r),d.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},g.set(C,j))}}function PE(r,i){es.M(r,i);var d=_a;if(d&&r){var g=$i(d).hoistableScripts,C=va(r),j=g.get(C);j||(j=d.querySelector(Ro(C)),j||(r=m({src:r,async:!0,type:"module"},i),(i=rr.get(C))&&df(r,i),j=d.createElement("script"),ln(j),gn(j,"link",r),d.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},g.set(C,j))}}function Ay(r,i,d,g){var C=(C=se.current)?Ec(C):null;if(!C)throw Error(s(446));switch(r){case"meta":case"title":return null;case"style":return typeof d.precedence=="string"&&typeof d.href=="string"?(i=ya(d.href),d=$i(C).hoistableStyles,g=d.get(i),g||(g={type:"style",instance:null,count:0,state:null},d.set(i,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(d.rel==="stylesheet"&&typeof d.href=="string"&&typeof d.precedence=="string"){r=ya(d.href);var j=$i(C).hoistableStyles,I=j.get(r);if(I||(C=C.ownerDocument||C,I={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(r,I),(j=C.querySelector(Do(r)))&&!j._p&&(I.instance=j,I.state.loading=5),rr.has(r)||(d={rel:"preload",as:"style",href:d.href,crossOrigin:d.crossOrigin,integrity:d.integrity,media:d.media,hrefLang:d.hrefLang,referrerPolicy:d.referrerPolicy},rr.set(r,d),j||BE(C,r,d,I.state))),i&&g===null)throw Error(s(528,""));return I}if(i&&g!==null)throw Error(s(529,""));return null;case"script":return i=d.async,d=d.src,typeof d=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=va(d),d=$i(C).hoistableScripts,g=d.get(i),g||(g={type:"script",instance:null,count:0,state:null},d.set(i,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,r))}}function ya(r){return'href="'+Yn(r)+'"'}function Do(r){return'link[rel="stylesheet"]['+r+"]"}function Ly(r){return m({},r,{"data-precedence":r.precedence,precedence:null})}function BE(r,i,d,g){r.querySelector('link[rel="preload"][as="style"]['+i+"]")?g.loading=1:(i=r.createElement("link"),g.preload=i,i.addEventListener("load",function(){return g.loading|=1}),i.addEventListener("error",function(){return g.loading|=2}),gn(i,"link",d),ln(i),r.head.appendChild(i))}function va(r){return'[src="'+Yn(r)+'"]'}function Ro(r){return"script[async]"+r}function Dy(r,i,d){if(i.count++,i.instance===null)switch(i.type){case"style":var g=r.querySelector('style[data-href~="'+Yn(d.href)+'"]');if(g)return i.instance=g,ln(g),g;var C=m({},d,{"data-href":d.href,"data-precedence":d.precedence,href:null,precedence:null});return g=(r.ownerDocument||r).createElement("style"),ln(g),gn(g,"style",C),jc(g,d.precedence,r),i.instance=g;case"stylesheet":C=ya(d.href);var j=r.querySelector(Do(C));if(j)return i.state.loading|=4,i.instance=j,ln(j),j;g=Ly(d),(C=rr.get(C))&&uf(g,C),j=(r.ownerDocument||r).createElement("link"),ln(j);var I=j;return I._p=new Promise(function(K,re){I.onload=K,I.onerror=re}),gn(j,"link",g),i.state.loading|=4,jc(j,d.precedence,r),i.instance=j;case"script":return j=va(d.src),(C=r.querySelector(Ro(j)))?(i.instance=C,ln(C),C):(g=d,(C=rr.get(j))&&(g=m({},d),df(g,C)),r=r.ownerDocument||r,C=r.createElement("script"),ln(C),gn(C,"link",g),r.head.appendChild(C),i.instance=C);case"void":return null;default:throw Error(s(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(g=i.instance,i.state.loading|=4,jc(g,d.precedence,r));return i.instance}function jc(r,i,d){for(var g=d.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),C=g.length?g[g.length-1]:null,j=C,I=0;I<g.length;I++){var K=g[I];if(K.dataset.precedence===i)j=K;else if(j!==C)break}j?j.parentNode.insertBefore(r,j.nextSibling):(i=d.nodeType===9?d.head:d,i.insertBefore(r,i.firstChild))}function uf(r,i){r.crossOrigin==null&&(r.crossOrigin=i.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=i.referrerPolicy),r.title==null&&(r.title=i.title)}function df(r,i){r.crossOrigin==null&&(r.crossOrigin=i.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=i.referrerPolicy),r.integrity==null&&(r.integrity=i.integrity)}var Nc=null;function Ry(r,i,d){if(Nc===null){var g=new Map,C=Nc=new Map;C.set(d,g)}else C=Nc,g=C.get(d),g||(g=new Map,C.set(d,g));if(g.has(r))return g;for(g.set(r,null),d=d.getElementsByTagName(r),C=0;C<d.length;C++){var j=d[C];if(!(j[Ka]||j[xt]||r==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var I=j.getAttribute(i)||"";I=r+I;var K=g.get(I);K?K.push(j):g.set(I,[j])}}return g}function Oy(r,i,d){r=r.ownerDocument||r,r.head.insertBefore(d,i==="title"?r.querySelector("head > title"):null)}function zE(r,i,d){if(d===1||i.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;switch(i.rel){case"stylesheet":return r=i.disabled,typeof i.precedence=="string"&&r==null;default:return!0}case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function My(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function HE(r,i,d,g){if(d.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(d.state.loading&4)===0){if(d.instance===null){var C=ya(g.href),j=i.querySelector(Do(C));if(j){i=j._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(r.count++,r=Tc.bind(r),i.then(r,r)),d.state.loading|=4,d.instance=j,ln(j);return}j=i.ownerDocument||i,g=Ly(g),(C=rr.get(C))&&uf(g,C),j=j.createElement("link"),ln(j);var I=j;I._p=new Promise(function(K,re){I.onload=K,I.onerror=re}),gn(j,"link",g),d.instance=j}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(d,i),(i=d.state.preload)&&(d.state.loading&3)===0&&(r.count++,d=Tc.bind(r),i.addEventListener("load",d),i.addEventListener("error",d))}}var hf=0;function $E(r,i){return r.stylesheets&&r.count===0&&Lc(r,r.stylesheets),0<r.count||0<r.imgCount?function(d){var g=setTimeout(function(){if(r.stylesheets&&Lc(r,r.stylesheets),r.unsuspend){var j=r.unsuspend;r.unsuspend=null,j()}},6e4+i);0<r.imgBytes&&hf===0&&(hf=62500*bE());var C=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&Lc(r,r.stylesheets),r.unsuspend)){var j=r.unsuspend;r.unsuspend=null,j()}},(r.imgBytes>hf?50:800)+i);return r.unsuspend=d,function(){r.unsuspend=null,clearTimeout(g),clearTimeout(C)}}:null}function Tc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Lc(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var Ac=null;function Lc(r,i){r.stylesheets=null,r.unsuspend!==null&&(r.count++,Ac=new Map,i.forEach(UE,r),Ac=null,Tc.call(r))}function UE(r,i){if(!(i.state.loading&4)){var d=Ac.get(r);if(d)var g=d.get(null);else{d=new Map,Ac.set(r,d);for(var C=r.querySelectorAll("link[data-precedence],style[data-precedence]"),j=0;j<C.length;j++){var I=C[j];(I.nodeName==="LINK"||I.getAttribute("media")!=="not all")&&(d.set(I.dataset.precedence,I),g=I)}g&&d.set(null,g)}C=i.instance,I=C.getAttribute("data-precedence"),j=d.get(I)||g,j===g&&d.set(null,C),d.set(I,C),this.count++,g=Tc.bind(this),C.addEventListener("load",g),C.addEventListener("error",g),j?j.parentNode.insertBefore(C,j.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(C,r.firstChild)),i.state.loading|=4}}var Oo={$$typeof:b,Provider:null,Consumer:null,_currentValue:ne,_currentValue2:ne,_threadCount:0};function FE(r,i,d,g,C,j,I,K,re){this.tag=1,this.containerInfo=r,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=Pi(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pi(0),this.hiddenUpdates=Pi(null),this.identifierPrefix=g,this.onUncaughtError=C,this.onCaughtError=j,this.onRecoverableError=I,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=re,this.incompleteTransitions=new Map}function Iy(r,i,d,g,C,j,I,K,re,le,xe,be){return r=new FE(r,i,d,I,re,le,xe,be,K),i=1,j===!0&&(i|=24),j=Pn(3,null,null,i),r.current=j,j.stateNode=r,i=Vd(),i.refCount++,r.pooledCache=i,i.refCount++,j.memoizedState={element:g,isDehydrated:d,cache:i},Kd(j),r}function Py(r){return r?(r=Qi,r):Qi}function By(r,i,d,g,C,j){C=Py(C),g.context===null?g.context=C:g.pendingContext=C,g=ys(i),g.payload={element:d},j=j===void 0?null:j,j!==null&&(g.callback=j),d=vs(r,g,i),d!==null&&(Ln(d,r,i),ho(d,r,i))}function zy(r,i){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var d=r.retryLane;r.retryLane=d!==0&&d<i?d:i}}function ff(r,i){zy(r,i),(r=r.alternate)&&zy(r,i)}function Hy(r){if(r.tag===13||r.tag===31){var i=ei(r,67108864);i!==null&&Ln(i,r,67108864),ff(r,67108864)}}function $y(r){if(r.tag===13||r.tag===31){var i=Un();i=et(i);var d=ei(r,i);d!==null&&Ln(d,r,i),ff(r,i)}}var Dc=!0;function VE(r,i,d,g){var C=z.T;z.T=null;var j=X.p;try{X.p=2,mf(r,i,d,g)}finally{X.p=j,z.T=C}}function GE(r,i,d,g){var C=z.T;z.T=null;var j=X.p;try{X.p=8,mf(r,i,d,g)}finally{X.p=j,z.T=C}}function mf(r,i,d,g){if(Dc){var C=pf(g);if(C===null)Zh(r,i,g,Rc,d),Fy(r,g);else if(qE(C,r,i,d,g))g.stopPropagation();else if(Fy(r,g),i&4&&-1<WE.indexOf(r)){for(;C!==null;){var j=Hi(C);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var I=wr(j.pendingLanes);if(I!==0){var K=j;for(K.pendingLanes|=2,K.entangledLanes|=2;I;){var re=1<<31-He(I);K.entanglements[1]|=re,I&=~re}jr(j),(pt&6)===0&&(pc=gt()+500,No(0))}}break;case 31:case 13:K=ei(j,2),K!==null&&Ln(K,j,2),xc(),ff(j,2)}if(j=pf(g),j===null&&Zh(r,i,g,Rc,d),j===C)break;C=j}C!==null&&g.stopPropagation()}else Zh(r,i,g,null,d)}}function pf(r){return r=gd(r),gf(r)}var Rc=null;function gf(r){if(Rc=null,r=zi(r),r!==null){var i=l(r);if(i===null)r=null;else{var d=i.tag;if(d===13){if(r=u(i),r!==null)return r;r=null}else if(d===31){if(r=c(i),r!==null)return r;r=null}else if(d===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;r=null}else i!==r&&(r=null)}}return Rc=r,null}function Uy(r){switch(r){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(Zt()){case ge:return 2;case Ce:return 8;case Oe:case Ve:return 32;case Ge:return 268435456;default:return 32}default:return 32}}var xf=!1,Ls=null,Ds=null,Rs=null,Mo=new Map,Io=new Map,Os=[],WE="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 Fy(r,i){switch(r){case"focusin":case"focusout":Ls=null;break;case"dragenter":case"dragleave":Ds=null;break;case"mouseover":case"mouseout":Rs=null;break;case"pointerover":case"pointerout":Mo.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Io.delete(i.pointerId)}}function Po(r,i,d,g,C,j){return r===null||r.nativeEvent!==j?(r={blockedOn:i,domEventName:d,eventSystemFlags:g,nativeEvent:j,targetContainers:[C]},i!==null&&(i=Hi(i),i!==null&&Hy(i)),r):(r.eventSystemFlags|=g,i=r.targetContainers,C!==null&&i.indexOf(C)===-1&&i.push(C),r)}function qE(r,i,d,g,C){switch(i){case"focusin":return Ls=Po(Ls,r,i,d,g,C),!0;case"dragenter":return Ds=Po(Ds,r,i,d,g,C),!0;case"mouseover":return Rs=Po(Rs,r,i,d,g,C),!0;case"pointerover":var j=C.pointerId;return Mo.set(j,Po(Mo.get(j)||null,r,i,d,g,C)),!0;case"gotpointercapture":return j=C.pointerId,Io.set(j,Po(Io.get(j)||null,r,i,d,g,C)),!0}return!1}function Vy(r){var i=zi(r.target);if(i!==null){var d=l(i);if(d!==null){if(i=d.tag,i===13){if(i=u(d),i!==null){r.blockedOn=i,hn(r.priority,function(){$y(d)});return}}else if(i===31){if(i=c(d),i!==null){r.blockedOn=i,hn(r.priority,function(){$y(d)});return}}else if(i===3&&d.stateNode.current.memoizedState.isDehydrated){r.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Oc(r){if(r.blockedOn!==null)return!1;for(var i=r.targetContainers;0<i.length;){var d=pf(r.nativeEvent);if(d===null){d=r.nativeEvent;var g=new d.constructor(d.type,d);pd=g,d.target.dispatchEvent(g),pd=null}else return i=Hi(d),i!==null&&Hy(i),r.blockedOn=d,!1;i.shift()}return!0}function Gy(r,i,d){Oc(r)&&d.delete(i)}function KE(){xf=!1,Ls!==null&&Oc(Ls)&&(Ls=null),Ds!==null&&Oc(Ds)&&(Ds=null),Rs!==null&&Oc(Rs)&&(Rs=null),Mo.forEach(Gy),Io.forEach(Gy)}function Mc(r,i){r.blockedOn===i&&(r.blockedOn=null,xf||(xf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,KE)))}var Ic=null;function Wy(r){Ic!==r&&(Ic=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Ic===r&&(Ic=null);for(var i=0;i<r.length;i+=3){var d=r[i],g=r[i+1],C=r[i+2];if(typeof g!="function"){if(gf(g||d)===null)continue;break}var j=Hi(d);j!==null&&(r.splice(i,3),i-=3,mh(j,{pending:!0,data:C,method:d.method,action:g},g,C))}}))}function ba(r){function i(re){return Mc(re,r)}Ls!==null&&Mc(Ls,r),Ds!==null&&Mc(Ds,r),Rs!==null&&Mc(Rs,r),Mo.forEach(i),Io.forEach(i);for(var d=0;d<Os.length;d++){var g=Os[d];g.blockedOn===r&&(g.blockedOn=null)}for(;0<Os.length&&(d=Os[0],d.blockedOn===null);)Vy(d),d.blockedOn===null&&Os.shift();if(d=(r.ownerDocument||r).$$reactFormReplay,d!=null)for(g=0;g<d.length;g+=3){var C=d[g],j=d[g+1],I=C[kn]||null;if(typeof j=="function")I||Wy(d);else if(I){var K=null;if(j&&j.hasAttribute("formAction")){if(C=j,I=j[kn]||null)K=I.formAction;else if(gf(C)!==null)continue}else K=I.action;typeof K=="function"?d[g+1]=K:(d.splice(g,3),g-=3),Wy(d)}}}function qy(){function r(j){j.canIntercept&&j.info==="react-transition"&&j.intercept({handler:function(){return new Promise(function(I){return C=I})},focusReset:"manual",scroll:"manual"})}function i(){C!==null&&(C(),C=null),g||setTimeout(d,20)}function d(){if(!g&&!navigation.transition){var j=navigation.currentEntry;j&&j.url!=null&&navigation.navigate(j.url,{state:j.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var g=!1,C=null;return navigation.addEventListener("navigate",r),navigation.addEventListener("navigatesuccess",i),navigation.addEventListener("navigateerror",i),setTimeout(d,100),function(){g=!0,navigation.removeEventListener("navigate",r),navigation.removeEventListener("navigatesuccess",i),navigation.removeEventListener("navigateerror",i),C!==null&&(C(),C=null)}}}function _f(r){this._internalRoot=r}Pc.prototype.render=_f.prototype.render=function(r){var i=this._internalRoot;if(i===null)throw Error(s(409));var d=i.current,g=Un();By(d,g,r,i,null,null)},Pc.prototype.unmount=_f.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var i=r.containerInfo;By(r.current,2,null,r,null,null),xc(),i[Bi]=null}};function Pc(r){this._internalRoot=r}Pc.prototype.unstable_scheduleHydration=function(r){if(r){var i=dt();r={blockedOn:null,target:r,priority:i};for(var d=0;d<Os.length&&i!==0&&i<Os[d].priority;d++);Os.splice(d,0,r),d===0&&Vy(r)}};var Ky=t.version;if(Ky!=="19.2.4")throw Error(s(527,Ky,"19.2.4"));X.findDOMNode=function(r){var i=r._reactInternals;if(i===void 0)throw typeof r.render=="function"?Error(s(188)):(r=Object.keys(r).join(","),Error(s(268,r)));return r=f(i),r=r!==null?p(r):null,r=r===null?null:r.stateNode,r};var YE={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Bc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bc.isDisabled&&Bc.supportsFiber)try{bt=Bc.inject(YE),ct=Bc}catch{}}return zo.createRoot=function(r,i){if(!a(r))throw Error(s(299));var d=!1,g="",C=t_,j=n_,I=r_;return i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(g=i.identifierPrefix),i.onUncaughtError!==void 0&&(C=i.onUncaughtError),i.onCaughtError!==void 0&&(j=i.onCaughtError),i.onRecoverableError!==void 0&&(I=i.onRecoverableError)),i=Iy(r,1,!1,null,null,d,g,null,C,j,I,qy),r[Bi]=i.current,Jh(r),new _f(i)},zo.hydrateRoot=function(r,i,d){if(!a(r))throw Error(s(299));var g=!1,C="",j=t_,I=n_,K=r_,re=null;return d!=null&&(d.unstable_strictMode===!0&&(g=!0),d.identifierPrefix!==void 0&&(C=d.identifierPrefix),d.onUncaughtError!==void 0&&(j=d.onUncaughtError),d.onCaughtError!==void 0&&(I=d.onCaughtError),d.onRecoverableError!==void 0&&(K=d.onRecoverableError),d.formState!==void 0&&(re=d.formState)),i=Iy(r,1,!0,i,d??null,g,C,re,j,I,K,qy),i.context=Py(null),d=i.current,g=Un(),g=et(g),C=ys(g),C.callback=null,vs(d,C,g),d=g,i.current.lanes=d,hs(i,d),jr(i),r[Bi]=i.current,Jh(r),new Pc(i)},zo.version="19.2.4",zo}var av;function u2(){if(av)return wf.exports;av=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(),wf.exports=c2(),wf.exports}var d2=u2();const h2=Du(d2),ov=e=>{let t;const n=new Set,s=(f,p)=>{const m=typeof f=="function"?f(t):f;if(!Object.is(m,t)){const _=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(x=>x(t,_))}},a=()=>t,c={setState:s,getState:a,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f))},h=t=e(s,a,c);return c},f2=(e=>e?ov(e):ov),m2=e=>e;function p2(e,t=m2){const n=$s.useSyncExternalStore(e.subscribe,$s.useCallback(()=>t(e.getState()),[e,t]),$s.useCallback(()=>t(e.getInitialState()),[e,t]));return $s.useDebugValue(n),n}const lv=e=>{const t=f2(e),n=s=>p2(t,s);return Object.assign(n,t),n},qn=(e=>e?lv(e):lv);async function Ne(e,t={}){const n=localStorage.getItem("openfox_token"),s={...t.headers instanceof Headers?Object.fromEntries(t.headers.entries()):t.headers,...n?{"x-session-token":n}:{}};return fetch(e,{...t,headers:s})}async function g2(e,t){try{return(await Ne(`/api/sessions/${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageIndex:t})})).ok}catch{return!1}}const ze={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_SHOW_OPEN_IN_EDITOR:"display.showOpenInEditorLinks",LLM_DYNAMIC_SYSTEM_PROMPT:"llm.dynamicSystemPrompt",KEYBINDINGS:"keybindings",RETRY_PATTERNS:"agent.retryPatterns"};function zc(e,t){return n=>({loading:{...n.loading,[e]:t}})}function cv(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const J0=[ze.DISPLAY_SHOW_THINKING,ze.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,ze.DISPLAY_SHOW_STATS,ze.DISPLAY_SHOW_AGENT_DEFINITIONS,ze.DISPLAY_SHOW_WORKFLOW_BARS,ze.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,ze.DISPLAY_FOLLOW_SYSTEM_THEME,ze.DISPLAY_SHOW_OPEN_IN_EDITOR];function Ou(){return{showThinking:an(e=>e.settings[ze.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:an(e=>e.settings[ze.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:an(e=>e.settings[ze.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:an(e=>e.settings[ze.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:an(e=>e.settings[ze.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:an(e=>e.settings[ze.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true"}}const an=qn(e=>({settings:{},loading:{},getSetting:async t=>{e(zc(t,!0));try{const s=await(await Ne(`/api/settings/${t}`)).json();return e(cv(t,s.value??"")),s.value}catch{return e(zc(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const s=await(await Ne(`/api/settings?keys=${encodeURIComponent(t.join(","))}`)).json();e({settings:s,loading:Object.fromEntries(t.map(a=>[a,!1]))})}catch{e({loading:Object.fromEntries(t.map(n=>[n,!1]))})}},setSetting:async(t,n)=>{e(zc(t,!0));try{const a=await(await Ne(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(cv(t,a.value??""))}catch{e(zc(t,!1))}}})),jf=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:J0,SETTINGS_KEYS:ze,useDisplaySettings:Ou,useSettingsStore:an},Symbol.toStringTag,{value:"Module"}));function x2(){const[e,t]=R.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=R.useRef(window.innerHeight);return R.useEffect(()=>{const s=window.visualViewport;if(!s)return;const a=()=>{const l=s.offsetTop,u=s.height,c=n.current-u>100;t({offsetTop:l,height:u,keyboardVisible:c})};return a(),s.addEventListener("resize",a),s.addEventListener("scroll",a),()=>{s.removeEventListener("resize",a),s.removeEventListener("scroll",a)}},[]),e}function _2(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,s,a,l,u=[],c="",h=e.split("/");for(h[0]||h.shift();a=h.shift();)n=a[0],n==="*"?(u.push(n),c+=a[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(s=a.indexOf("?",1),l=a.indexOf(".",1),u.push(a.substring(1,~s?s:~l?l:a.length)),c+=~s&&!~l?"(?:/([^/]+?))?":"/([^/]+?)",~l&&(c+=(~s?"?":"")+"\\"+a.substring(l))):c+="/"+a;return{keys:u,pattern:new RegExp("^"+c+(t?"(?=$|/)":"/?$"),"i")}}var Nf={exports:{}},Tf={};/**
|
|
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 uv;function y2(){if(uv)return Tf;uv=1;var e=Ru();function t(m,_){return m===_&&(m!==0||1/m===1/_)||m!==m&&_!==_}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,a=e.useEffect,l=e.useLayoutEffect,u=e.useDebugValue;function c(m,_){var x=_(),w=s({inst:{value:x,getSnapshot:_}}),k=w[0].inst,y=w[1];return l(function(){k.value=x,k.getSnapshot=_,h(k)&&y({inst:k})},[m,x,_]),a(function(){return h(k)&&y({inst:k}),m(function(){h(k)&&y({inst:k})})},[m]),u(x),x}function h(m){var _=m.getSnapshot;m=m.value;try{var x=_();return!n(m,x)}catch{return!0}}function f(m,_){return _()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Tf.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,Tf}var dv;function v2(){return dv||(dv=1,Nf.exports=y2()),Nf.exports}var b2=v2();const S2=i2.useInsertionEffect,w2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",C2=w2?R.useLayoutEffect:R.useEffect,k2=S2||C2,Z0=e=>{const t=R.useRef([e,(...n)=>t[0](...n)]).current;return k2(()=>{t[0]=e}),t[1]},E2="popstate",tp="pushState",np="replaceState",j2="hashchange",hv=[E2,tp,np,j2],N2=e=>{for(const t of hv)addEventListener(t,e);return()=>{for(const t of hv)removeEventListener(t,e)}},eS=(e,t)=>b2.useSyncExternalStore(N2,e,t),fv=()=>location.search,T2=({ssrSearch:e}={})=>eS(fv,e!=null?()=>e:fv),mv=()=>location.pathname,A2=({ssrPath:e}={})=>eS(mv,e!=null?()=>e:mv),L2=(e,{replace:t=!1,state:n=null}={})=>history[t?np:tp](n,"",e),D2=(e={})=>[A2(e),L2],pv=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[pv]>"u"){for(const e of[tp,np]){const t=history[e];history[e]=function(){const n=t.apply(this,arguments),s=new Event(e);return s.arguments=arguments,dispatchEvent(s),n}}Object.defineProperty(window,pv,{value:!0})}const R2=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",tS=(e="")=>e==="/"?"":e,O2=(e,t)=>e[0]==="~"?e.slice(1):tS(t)+e,M2=(e="",t)=>R2(gv(tS(e)),gv(t)),gv=e=>{try{return decodeURI(e)}catch{return e}},nS={hook:D2,searchHook:T2,parser:_2,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},rS=R.createContext(nS),Ha=()=>R.useContext(rS),sS={},iS=R.createContext(sS),I2=()=>R.useContext(iS),Mu=e=>{const[t,n]=e.hook(e);return[M2(e.base,t),Z0((s,a)=>e.aroundNav(n,O2(s,e.base),a))]},cr=()=>Mu(Ha()),rp=(e,t,n,s)=>{const{pattern:a,keys:l}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",s),u=a.exec(n)||[],[c,...h]=u;return c!==void 0?[!0,(()=>{const f=l!==!1?Object.fromEntries(l.map((m,_)=>[m,h[_]])):u.groups;let p={...h};return f&&Object.assign(p,f),p})(),...s?[c]:[]]:[!1,null]},sp=e=>rp(Ha().parser,e,cr()[0]),P2=({children:e,...t})=>{var p,m,_;const n=Ha(),s=t.hook?nS:n;let a=s;const[l,u=t.ssrSearch??""]=((p=t.ssrPath)==null?void 0:p.split("?"))??[];l&&(t.ssrSearch=u,t.ssrPath=l),t.hrefs=t.hrefs??((m=t.hook)==null?void 0:m.hrefs),t.searchHook=t.searchHook??((_=t.hook)==null?void 0:_.searchHook);let c=R.useRef({}),h=c.current,f=h;for(let x in s){const w=x==="base"?s[x]+(t[x]??""):t[x]??s[x];h===f&&w!==f[x]&&(c.current=f={...f}),f[x]=w,(w!==s[x]||w!==a[x])&&(a=f)}return R.createElement(rS.Provider,{value:a,children:e})},xv=({children:e,component:t},n)=>t?R.createElement(t,{params:n}):typeof e=="function"?e(n):e,B2=e=>{let t=R.useRef(sS);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([s,a])=>a!==n[s])?e:n},Ho=({path:e,nest:t,match:n,...s})=>{const a=Ha(),[l]=Mu(a),[u,c,h]=n??rp(a.parser,e,l,t),f=B2({...I2(),...c});if(!u)return null;const p=h?R.createElement(P2,{base:h},xv(s,f)):xv(s,f);return R.createElement(iS.Provider,{value:f,children:p})},Gn=R.forwardRef((e,t)=>{const n=Ha(),[s,a]=Mu(n),{to:l="",href:u=l,onClick:c,asChild:h,children:f,className:p,replace:m,state:_,transition:x,...w}=e,k=Z0(S=>{S.ctrlKey||S.metaKey||S.altKey||S.shiftKey||S.button!==0||(c==null||c(S),S.defaultPrevented||(S.preventDefault(),a(u,e)))}),y=n.hrefs(u[0]==="~"?u.slice(1):n.base+u,n);return h&&R.isValidElement(f)?R.cloneElement(f,{onClick:k,href:y}):R.createElement("a",{...w,onClick:k,href:y,className:p!=null&&p.call?p(s===u):p,children:f,ref:t})}),aS=e=>Array.isArray(e)?e.flatMap(t=>aS(t&&t.type===R.Fragment?t.props.children:t)):[e],z2=({children:e,location:t})=>{const n=Ha(),[s]=Mu(n);for(const a of aS(e)){let l=0;if(R.isValidElement(a)&&(l=rp(n.parser,a.props.path,t||s,a.props.nest))[0])return R.cloneElement(a,{match:l})}return null};function H2(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function oS(){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 $2{constructor(t){pe(this,"ws",null);pe(this,"handlers",new Set);pe(this,"statusHandler",null);pe(this,"baseUrl");pe(this,"isReconnecting",!1);pe(this,"connectingPromise",null);pe(this,"lastCloseCode",0);pe(this,"reconnectAttempts",0);pe(this,"manualReconnectScheduled",!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,s;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&&((s=this.ws)==null?void 0:s.readyState)===WebSocket.CONNECTING?(console.warn("[WS CLIENT] Connection already in progress, returning existing promise"),this.connectingPromise):(this.connectingPromise=new Promise((a,l)=>{try{const u=this.getUrl();this.ws=new WebSocket(u);const c=setTimeout(()=>{var h;((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING&&(this.ws.close(),l(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var h;clearTimeout(c),this.isReconnecting=!1,this.connectingPromise=null,(h=this.statusHandler)==null||h.call(this,"connected"),a()},this.ws.onclose=h=>{var f,p,m;clearTimeout(c),this.lastCloseCode=h.code,((f=this.ws)==null?void 0:f.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(p=this.statusHandler)==null||p.call(this,"disconnected"),l(new Error(`Connection closed: ${h.code}`))):(this.connectingPromise=null,(m=this.statusHandler)==null||m.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=h=>{clearTimeout(c),console.error("WebSocket error:",h),this.connectingPromise=null,l(h)},this.ws.onmessage=h=>{try{const f=JSON.parse(h.data);H2(f)&&this.handlers.forEach(p=>p(f))}catch(f){console.error("Failed to parse WebSocket message:",f)}}}catch(u){this.connectingPromise=null,l(u)}}),this.connectingPromise)))}attemptReconnect(){var a;if(([1e3,1005,1006,4e3].includes(this.lastCloseCode)||this.lastCloseCode===0)&&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,(a=this.statusHandler)==null||a.call(this,"reconnecting");const s=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(()=>{})},s)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{})}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 s=oS(),a={id:s,type:t,payload:n};return this.ws.send(JSON.stringify(a)),s}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 U2=window.location.protocol==="https:"?"wss:":"ws:";let ym=window.location.port;ym||(ym=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const F2=`${U2}//${window.location.hostname}:${ym}/ws`,zt=new $2(F2);function V2(e){return{...e.temperature!=null&&{temperature:e.temperature},...e.topP!=null&&{topP:e.topP},...e.topK!=null&&{topK:e.topK},...e.maxTokens!=null&&{maxTokens:e.maxTokens}}}function _v(e){e&&we.getState().updateContextState({...e,dynamicContextChanged:e.dynamicContextChanged??!1})}async function yv(e,t,n){const s=await Ne(`/api/providers/${e}/models/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok){const a=await s.json();throw new Error(a.error??"Failed to update model")}return s.json()}function vv(e,t,n,s){return e.map(a=>a.id===t?{...a,models:a.models.map(l=>l.id===n?{...l,...s,source:"user"}:l)}:a)}const G2=3e4;function ip(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"auto":return"Auto";case"unknown":return""}}const Bt=qn((e,t)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>{e({loading:!0,error:null});try{const n=await Ne("/api/config");if(!n.ok)throw new Error("Failed to fetch config");const s=await n.json();e({version:s.version,model:s.model,maxContext:s.maxContext,llmUrl:s.llmUrl,llmStatus:s.llmStatus,backend:s.backend,providers:s.providers??[],activeProviderId:s.activeProviderId??null,defaultModelSelection:s.defaultModelSelection??null,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const n=await Ne("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const s=await n.json(),l=we.getState().currentSession;if(l!=null&&l.providerId&&l.providerModel){e({llmStatus:s.llmStatus,backend:s.backend});return}e({model:s.model,llmStatus:s.llmStatus,backend:s.backend})}catch(n){console.error("Failed to refresh model:",n)}},activateProvider:async n=>{const{activeProviderId:s,providers:a}=t();if(n===s)return!0;e({activating:!0,error:null});try{const l=await Ne(`/api/providers/${n}/activate`,{method:"POST"});if(!l.ok){const c=await l.json();throw new Error(c.error??"Failed to activate provider")}const u=await l.json();return e({activeProviderId:u.activeProviderId,model:u.model,backend:u.backend,providers:a.map(c=>({...c,isActive:c.id===u.activeProviderId})),activating:!1}),!0}catch(l){return e({error:l instanceof Error?l.message:"Failed to switch provider",activating:!1}),!1}},syncFromSession:(n,s)=>{var c;const{providers:a,defaultModelSelection:l}=t();let u=s;if(!u){const h=l?l.split("/"):[],f=h[0],p=h.slice(1).join("/")??"";if(f===n&&p)u=p;else{const m=a.find(_=>_.id===n);u=((c=m==null?void 0:m.models[0])==null?void 0:c.id)??""}}e({activeProviderId:n,model:u,defaultModelSelection:`${n}/${u}`,providers:a.map(h=>({...h,isActive:h.id===n}))})},updateModelContext:async(n,s,a)=>{e({activating:!0,error:null});try{const l=await yv(n,s,{contextWindow:a}),{providers:u}=t();return e({providers:vv(u,n,s,{contextWindow:a}),activating:!1}),_v(l.contextState),!0}catch(l){return e({error:l instanceof Error?l.message:"Failed to update model context",activating:!1}),!1}},updateModelSettings:async(n,s,a)=>{e({activating:!0,error:null});try{const l=await yv(n,s,a),{providers:u}=t(),c={...a.contextWindow!==void 0&&{contextWindow:a.contextWindow},...V2({temperature:a.temperature??void 0,topP:a.topP??void 0,topK:a.topK??void 0,maxTokens:a.maxTokens??void 0}),...a.supportsVision!==void 0&&{supportsVision:a.supportsVision},...a.thinkingEnabled!==void 0&&{thinkingEnabled:a.thinkingEnabled},...a.thinkingLevel!==void 0&&{thinkingLevel:a.thinkingLevel},...a.nonThinkingEnabled!==void 0&&{nonThinkingEnabled:a.nonThinkingEnabled},...a.thinkingExtraKwargs!==void 0&&{thinkingExtraKwargs:a.thinkingExtraKwargs},...a.nonThinkingExtraKwargs!==void 0&&{nonThinkingExtraKwargs:a.nonThinkingExtraKwargs}};return e({providers:vv(u,n,s,c),activating:!1}),_v(l.contextState),!0}catch(l){return e({error:l instanceof Error?l.message:"Failed to update model settings",activating:!1}),!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const s=await Ne(`/api/providers/${n}/refresh`,{method:"POST"});if(!s.ok){const u=await s.json();throw new Error(u.error??"Failed to refresh models")}const a=await s.json(),{providers:l}=t();return e({providers:l.map(u=>u.id===n?{...u,models:a.models,status:a.status}:u),activating:!1}),!0}catch(s){return e({error:s instanceof Error?s.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:n,refreshModel:s}=t();if(n)return;const a=setInterval(()=>{s()},G2);e({autoRefreshInterval:a})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:s}=t();return n.find(a=>a.id===s)},getModelContext:n=>{const{providers:s,activeProviderId:a}=t(),l=s.find(c=>c.id===a);if(!l)return 2e5;const u=l.models.find(c=>c.id===n);return(u==null?void 0:u.contextWindow)??2e5}})),Lt=qn((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const s=await(await Ne("/api/projects")).json();e({projects:s.projects??[],loading:!1})}catch(n){console.error("Failed to load projects:",n),e({loading:!1})}},createProject:async(n,s)=>{try{const a=await Ne("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:s})});if(!a.ok){const u=await a.json().catch(()=>({}));return{error:{code:u.code||"UNKNOWN",path:u.path,message:u.error}}}const l=await a.json();return await t().listProjects(),l.project}catch{return null}},loadProject:async n=>{try{const s=await Ne(`/api/projects/${n}`);if(!s.ok)return null;const a=await s.json();return e({currentProject:a.project}),t().projects.length===0&&await t().listProjects(),a.project}catch{return null}},updateProject:async(n,s)=>{var a;try{const l=await Ne(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!l.ok)return null;const u=await l.json();return((a=t().currentProject)==null?void 0:a.id)===n&&e({currentProject:u.project}),await t().listProjects(),u.project}catch{return null}},deleteProject:async n=>{var s;try{return(await Ne(`/api/projects/${n}`,{method:"DELETE"})).ok?(await t().listProjects(),((s=t().currentProject)==null?void 0:s.id)===n&&e({currentProject:null}),!0):!1}catch{return!1}},toggleStar:async(n,s)=>{var a;try{const l=await Ne(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:s})});if(!l.ok)return!1;if(((a=t().currentProject)==null?void 0:a.id)===n){const u=await l.json();e({currentProject:u.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}})),Ws=async(e,t,n)=>{try{const s=await Ne(t,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return s.ok?{success:!0}:{success:!1,error:(await s.json()).error}}catch{return{success:!1,error:"Network error"}}},Iu=async(e,t,n)=>{try{const s=await Ne(e,{method:"POST",body:n?JSON.stringify({destination:n}):void 0,headers:n?{"Content-Type":"application/json"}:void 0}),a=await s.json();return s.ok?(await t(),{success:!0}):{success:!1,error:a.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}};function lS(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let Hc=[];const Zo=qn()((e,t)=>{function n(){if(Hc.length===0)return;const a=Hc;Hc=[],e(l=>{const u={...l.logs};for(const c of a){const h=u[c.processId]??[];u[c.processId]=[...h,{offset:h.length,content:c.content,timestamp:Date.now(),stream:c.stream}]}return{logs:u}})}const s=lS(n);return{processes:[],logs:{},loading:!1,setProcesses:a=>e({processes:a}),addProcess:a=>e(l=>({processes:[...l.processes,a]})),updateProcess:(a,l)=>e(u=>({processes:u.processes.map(c=>c.id===a?{...c,...l}:c)})),removeProcess:a=>e(l=>({processes:l.processes.filter(u=>u.id!==a),logs:Object.fromEntries(Object.entries(l.logs).filter(([u])=>u!==a))})),stopProcess:async(a,l)=>{try{(await Ne(`/api/sessions/${l}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,l,u)=>{Hc.push({processId:a,stream:l,content:u}),s()},setLogs:(a,l)=>e(u=>({logs:{...u.logs,[a]:l}})),clearLogs:a=>e(l=>({logs:{...l.logs,[a]:[]}})),handleMessage:(a,l)=>{switch(a){case"backgroundProcess.started":{const{processId:u,name:c,pid:h,status:f}=l;e(p=>({processes:[...p.processes,{id:u,sessionId:"",name:c,command:"",cwd:"",pid:h,status:f,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const u=l.processId,c=l.stream,h=l.content;t().appendLog(u,c,h);break}case"backgroundProcess.exited":{const u=l.processId,c=l.exitCode;e(h=>({processes:h.processes.map(f=>f.id===u?{...f,status:"exited",exitCode:c}:f)}));break}case"backgroundProcess.removed":{const u=l.processId;t().removeProcess(u);break}}}}}),W2={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let iu=null;function q2(e){iu=e}function yi(){return W2}function Af(){iu==null||iu()}let $c=[];const Rr=qn()((e,t)=>{function n(){if($c.length===0)return;const a=$c;$c=[],e(l=>({logs:[...l.logs,...a]}))}const s=lS(n);return{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:a=>{t().workdir!==a&&(e({workdir:a,status:null,logs:[],config:null,loading:!0}),a&&(t().fetchStatus(),t().fetchConfig()))},fetchStatus:async()=>{const a=t().workdir;if(a)try{const u=await(await Ne(`/api/dev-server?workdir=${encodeURIComponent(a)}`)).json();e({status:u,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const a=t().workdir;if(a)try{const u=await(await Ne(`/api/dev-server/config?workdir=${encodeURIComponent(a)}`)).json();e({config:u.config??null})}catch{}},fetchLogs:async()=>{const a=t().workdir;if(a)try{const c=(await(await Ne(`/api/dev-server/logs?workdir=${encodeURIComponent(a)}`)).json()).logs.map(h=>({stream:h.stream,content:h.content}));e({logs:c})}catch{}},start:async()=>{const a=t().workdir;if(a)try{const u=await(await Ne(`/api/dev-server/start?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u,logs:[]})}catch{}},stop:async()=>{const a=t().workdir;if(a)try{const u=await(await Ne(`/api/dev-server/stop?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u})}catch{}},restart:async()=>{const a=t().workdir;if(a)try{const u=await(await Ne(`/api/dev-server/restart?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u,logs:[]})}catch{}},saveConfig:async a=>{const l=t().workdir;if(l)try{const c=await(await Ne(`/api/dev-server/config?workdir=${encodeURIComponent(l)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();e({config:c.config??a}),t().fetchStatus()}catch{}},handleMessage:a=>{const l=t().workdir;if(l)switch(a.type){case"devServer.output":{const u=a.payload;if(u.workdir!==l)return;$c.push({stream:u.stream,content:u.content}),s();break}case"devServer.state":{const u=a.payload;if(u.workdir!==l)return;e(c=>({status:c.status?{...c.status,state:u.state,errorMessage:u.errorMessage}:c.status}));break}}}}}),K2=[{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"}],Y2=[{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"}],cS={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"},Us={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},uS={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},vm={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...Us},waiting_for_user:{...Us},phase_done:{...Us},phase_blocked:{...Us},new_message:{...uS}},agentOverrides:{}};function dS(e,t,n){var l;const s=e.events[t];if(!n)return s;const a=(l=e.agentOverrides[n])==null?void 0:l[t];return a?{soundEnabled:a.soundEnabled??s.soundEnabled,browserNotification:a.browserNotification??s.browserNotification,customSoundUrl:a.customSoundUrl!==void 0?a.customSoundUrl:s.customSoundUrl}:s}const bi=qn((e,t)=>({settings:vm,loaded:!1,load:()=>{an.getState().getSetting(ze.NOTIFICATION_SETTINGS);const s=an.subscribe(l=>{const u=l.settings[ze.NOTIFICATION_SETTINGS];if(u!==void 0)try{const c=JSON.parse(u);e({settings:bv(c),loaded:!0})}catch{e({loaded:!0})}}),a=an.getState().settings[ze.NOTIFICATION_SETTINGS];if(a)try{const l=JSON.parse(a);e({settings:bv(l),loaded:!0})}catch{e({loaded:!0})}return s},update:n=>{e({settings:n}),Lf(n)},updateEvent:(n,s)=>{const a=t().settings,l={...a,events:{...a.events,[n]:{...a.events[n],...s}}};e({settings:l}),Lf(l)},updateAgentOverride:(n,s,a)=>{var h;const l=t().settings,u={...l.agentOverrides};if(a===null){if(u[n]){const f={...u[n]};delete f[s],Object.keys(f).length===0?delete u[n]:u[n]=f}}else u[n]={...u[n],[s]:{...((h=u[n])==null?void 0:h[s])??{},...a}};const c={...l,agentOverrides:u};e({settings:c}),Lf(c)}}));function Lf(e){an.getState().setSetting(ze.NOTIFICATION_SETTINGS,JSON.stringify(e))}function bv(e){var t,n,s,a,l;return{soundEnabled:e.soundEnabled??vm.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??vm.browserNotificationEnabled,events:{complete:{...Us,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...Us,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...Us,...(s=e.events)==null?void 0:s.phase_done},phase_blocked:{...Us,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...uS,...(l=e.events)==null?void 0:l.new_message}},agentOverrides:e.agentOverrides??{}}}const Sv=new Map;function X2(e){let t=Sv.get(e);return t||(t=new Audio(e),t.volume=.5,Sv.set(e,t)),t}let hS=typeof Notification<"u"?Notification.permission:"denied";function Q2(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(hS=e,e))}const J2={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},Z2={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 ej(e){typeof Notification>"u"||hS==="granted"&&(document.hasFocus()||new Notification(J2[e],{body:Z2[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function ml(e,t){const{settings:n}=bi.getState(),s=dS(n,e,t);if(n.soundEnabled&&s.soundEnabled){const a=s.customSoundUrl??cS[e],l=X2(a);l.currentTime=0,l.play().catch(()=>{})}n.browserNotificationEnabled&&s.browserNotification&&ej(e)}const tj=e=>ml("complete",e),nj=e=>ml("phase_done",e),rj=e=>ml("phase_blocked",e),wv=e=>ml("waiting_for_user",e),sj=e=>ml("new_message",e),Cv=new Map;function Xo(e,t){var l;const n=t===((l=e.currentSession)==null?void 0:l.id)?e.currentSession:null,s=e.sessions.find(u=>u.id===t),a=(n==null?void 0:n.mode)??(s==null?void 0:s.mode);return a==="planner"?"planner":a==="builder"?"build":"planner"}function ij(e,t){if(e.type==="chat.done"){const n=e.payload,s=Xo(t,e.sessionId),a=n.agentType??s;n.reason==="complete"&&tj(a),n.reason==="waiting_for_user"&&wv(a);return}if(e.type==="chat.path_confirmation"){const n=Xo(t,e.sessionId);wv(n);return}if(e.type==="task.completed"){const n=Xo(t,e.sessionId);nj(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,s=Cv.get(e.sessionId)??null;if(Cv.set(e.sessionId,n.phase),s===n.phase)return;const a=Xo(t,e.sessionId);n.phase==="blocked"&&rj(a)}}const Df=new Set;function Gt(e,t){return t!==null&&e.sessionId===t}function aj(e,t,n){return e.id!==void 0||Gt(e,t)||n===!0&&e.sessionId!==void 0}function oj(e,t){return e.includes(t)?e:[...e,t]}function kv(e,t){return e.filter(n=>n!==t)}function lj(e,t){const n=e.find(l=>l.id===t.id),s=t.messageCount??t.messages.length,a=n?{...n,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:s,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(l=>l.status.type==="passed").length}:{id:t.id,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(l=>l.status.type==="passed").length,messageCount:s};return n?e.map(l=>l.id===t.id?a:l):[a,...e]}function cj(e,t,n){return e.map(s=>{const a=(n==null?void 0:n.id)===s.id?n:null,l=t.find(u=>u.id===s.id);return{...s,title:s.title??(l==null?void 0:l.title),mode:(a==null?void 0:a.mode)??(l==null?void 0:l.mode)??s.mode,phase:(a==null?void 0:a.phase)??(l==null?void 0:l.phase)??s.phase,isRunning:s.isRunning&&(l==null?void 0:l.isRunning)!==!1,messageCount:s.messageCount,recentUserPrompts:s.recentUserPrompts}})}function Ev(e,t,n,s){var c;const a=e.sessionId,l=(c=n().currentSession)==null?void 0:c.id,u=a&&a!==l;if(t(h=>({sessions:h.sessions.map(f=>f.id===a?s(f):f)})),!u){const h=n().currentSession;if(h){const f=s(h);t(()=>({currentSession:f}))}}}function jv(e,t,n){var u,c,h,f,p,m,_,x,w,k,y,S,v,b,E,T,N,L,A,D,B,q,W;const s=n();ij(e,s);const a=((u=s.currentSession)==null?void 0:u.id)??null,l=()=>{const O=e.sessionId;!O||O===a||t(V=>({unreadSessionIds:oj(V.unreadSessionIds,O)}))};switch(e.type){case"session.state":{const O=e.payload;if(!aj(e,a,s.pendingSessionCreate))break;const V=O.messages.find(z=>z.isStreaming)??null,G=n().pendingSessionCreate===!0;if(t({currentSession:O.session,sessions:lj(n().sessions,O.session),unreadSessionIds:kv(n().unreadSessionIds,O.session.id),messages:O.messages,streamingMessageId:(V==null?void 0:V.id)??null,streamingMessage:V,currentTodos:[],pendingPathConfirmations:O.pendingConfirmations??[],error:null,...G?{pendingSessionCreate:O.session.id}:{}}),O.session.providerId){const z=Bt.getState();z.providers.find(ne=>ne.id===O.session.providerId)&&z.syncFromSession(O.session.providerId,O.session.providerModel??"")}break}case"session.list":{const O=e.payload;t(V=>({sessions:cj(O.sessions,V.sessions,V.currentSession)}));break}case"session.deleted":{const O=e.payload;t(V=>({unreadSessionIds:kv(V.unreadSessionIds,O.sessionId)})),n().listSessions();break}case"session.deletedAll":{n().listSessions();break}case"session.running":{const O=e.payload;Ev(e,t,n,V=>({...V,isRunning:O.isRunning})),O.isRunning||t({abortInProgress:!1,queuedMessages:[]});break}case"chat.message":{if(!Gt(e,((c=n().currentSession)==null?void 0:c.id)??null)){l();break}const O=e.payload;t(V=>{if(V.messages.some(z=>z.id===O.message.id))return V;const G=O.message.role==="user";return{messages:[...V.messages,O.message],sessions:V.sessions.map(z=>z.id===e.sessionId&&G?{...z,messageCount:z.messageCount+1}:z),streamingMessageId:O.message.isStreaming?O.message.id:V.streamingMessageId,streamingMessage:O.message.isStreaming?O.message:V.streamingMessage}});break}case"chat.message_updated":{if(!Gt(e,((h=n().currentSession)==null?void 0:h.id)??null)){l();break}const O=e.payload,V=O.updates.isStreaming===!1&&n().streamingMessageId===O.messageId;t(G=>{const z=G.streamingMessage;if(z&&z.id===O.messageId){const X={...z,...O.updates};return{messages:G.messages.map(ne=>ne.id===O.messageId?X:ne),streamingMessageId:V?null:G.streamingMessageId,streamingMessage:V?null:{...z,...O.updates}}}return{messages:G.messages.map(X=>X.id===O.messageId?{...X,...O.updates}:X),streamingMessageId:V?null:G.streamingMessageId}});break}case"chat.delta":{if(!Gt(e,((f=n().currentSession)==null?void 0:f.id)??null)){l();break}const O=e.payload;if(!Df.has(O.messageId)){Df.add(O.messageId);const G=O.subAgentType?"sub-agent":Xo(n(),e.sessionId);sj(G)}const V=yi();V.messageId=O.messageId,V.deltaContent+=O.content,Af();break}case"chat.thinking":{if(!Gt(e,((p=n().currentSession)==null?void 0:p.id)??null)){l();break}const O=e.payload,V=yi();V.messageId=O.messageId,V.thinkingContent+=O.content,Af();break}case"chat.tool_preparing":{if(!Gt(e,((m=n().currentSession)==null?void 0:m.id)??null)){l();break}const O=e.payload,V=n().streamingMessage;if(!V||V.id!==O.messageId||((_=V.toolCalls)==null?void 0:_.find((z,X)=>X===O.index)))return;t(z=>{const X=z.streamingMessage.preparingToolCalls??[],ne=X.findIndex(M=>M.index===O.index);let F;return ne>=0?F=X.map((M,$)=>$===ne?{...M,arguments:O.arguments}:M):F=[...X,{index:O.index,name:O.name,...O.arguments?{arguments:O.arguments}:{}}],{streamingMessage:{...z.streamingMessage,preparingToolCalls:F}}});break}case"chat.tool_call":{if(!Gt(e,((x=n().currentSession)==null?void 0:x.id)??null)){l();break}const O=e.payload,V=G=>{var F;const z=(F=G.preparingToolCalls)==null?void 0:F.filter((M,$)=>{var P;return M.name===O.tool?(P=G.preparingToolCalls)==null?void 0:P.slice(0,$).some(J=>J.name===O.tool):!0}),X=yi(),ne=X.toolOutput.filter(M=>M.callId===O.callId);return ne.length>0&&(X.toolOutput=X.toolOutput.filter(M=>M.callId!==O.callId)),{...G,toolCalls:[...G.toolCalls??[],{id:O.callId,name:O.tool,arguments:O.args,startedAt:Date.now(),...ne.length>0?{streamingOutput:ne.map(M=>({stream:M.stream,content:M.content,timestamp:Date.now()}))}:{}}],...z&&z.length>0?{preparingToolCalls:z}:{preparingToolCalls:void 0}}};t(G=>{const z=G.streamingMessage;return z&&z.id===O.messageId?{streamingMessage:V(z)}:{messages:G.messages.map(X=>X.id===O.messageId?V(X):X)}});break}case"chat.tool_output":{if(!Gt(e,((w=n().currentSession)==null?void 0:w.id)??null)){l();break}const O=e.payload,V=yi();V.messageId=O.messageId,V.toolOutput.push({messageId:O.messageId,callId:O.callId,stream:O.stream,content:O.output}),Af();break}case"chat.tool_result":{if(!Gt(e,((k=n().currentSession)==null?void 0:k.id)??null)){l();break}const O=e.payload,V=G=>{var X;const z=(X=G.toolCalls)==null?void 0:X.map(ne=>ne.id===O.callId?{...ne,result:O.result}:ne);return{...G,toolCalls:z}};t(G=>{const z=G.streamingMessage;return z&&z.id===O.messageId?{streamingMessage:V(z)}:{messages:G.messages.map(X=>X.id===O.messageId?V(X):X)}});break}case"chat.vision_fallback":{if(!Gt(e,((y=n().currentSession)==null?void 0:y.id)??null)){l();break}const O=e.payload;t(V=>{const G=`${O.messageId}-${O.attachmentId}`,z={...V.visionFallbackByMessage};return z[G]={type:O.type,attachmentId:O.attachmentId,filename:O.filename,description:O.description},{visionFallbackByMessage:z}});break}case"chat.todo":{if(!Gt(e,((S=n().currentSession)==null?void 0:S.id)??null)){l();break}const O=e.payload;t({currentTodos:O.todos});break}case"chat.progress":{if(!Gt(e,((v=n().currentSession)==null?void 0:v.id)??null)){l();break}const O=e.payload;console.warn("Progress:",O.message,O.phase);break}case"chat.format_retry":{if(!Gt(e,((b=n().currentSession)==null?void 0:b.id)??null)){l();break}const O=e.payload;console.warn("Format retry:",O.attempt,"/",O.maxAttempts);break}case"chat.done":{if(!Gt(e,((E=n().currentSession)==null?void 0:E.id)??null)){l();break}const O=yi();O.messageId=null,O.deltaContent="",O.thinkingContent="",O.toolOutput=[],Df.delete(e.payload.messageId);const V=e.payload,G=V.stats;t(z=>{const X=z.streamingMessage,ne=X&&X.id===V.messageId?{...X,isStreaming:!1,stats:G??X.stats}:null;return{messages:z.messages.map(F=>F.id===V.messageId?ne??{...F,isStreaming:!1,stats:G??F.stats,completeReason:V.reason}:F),streamingMessageId:null,streamingMessage:null,visionFallbackByMessage:{}}});break}case"chat.error":{if(!Gt(e,((T=n().currentSession)==null?void 0:T.id)??null)){l();break}const O=yi(),V=e.payload;console.error("Chat error:",V.error,"recoverable:",V.recoverable),V.recoverable||(O.messageId=null,O.deltaContent="",O.thinkingContent="",O.toolOutput=[]),t(G=>({error:{code:"CHAT_ERROR",message:V.error},streamingMessageId:V.recoverable?G.streamingMessageId:null,...V.recoverable?{}:{messages:G.streamingMessage?G.messages.map(z=>z.id===G.streamingMessage.id?G.streamingMessage:z):G.messages,streamingMessage:null}}));break}case"chat.path_confirmation":{if(!Gt(e,((N=n().currentSession)==null?void 0:N.id)??null)){l();break}const O=e.payload,V={callId:O.callId,tool:O.tool,paths:O.paths,workdir:O.workdir,reason:O.reason};t(G=>({pendingPathConfirmations:[...G.pendingPathConfirmations,V]}));break}case"chat.ask_user":{if(!Gt(e,((L=n().currentSession)==null?void 0:L.id)??null)){l();return}const O=e.payload;t({pendingQuestion:{callId:O.callId,question:O.question}});break}case"mode.changed":{if(!Gt(e,((A=n().currentSession)==null?void 0:A.id)??null)){l();break}const O=e.payload;t(V=>({currentSession:V.currentSession?{...V.currentSession,mode:O.mode}:null}));break}case"phase.changed":{const O=e.payload;Ev(e,t,n,V=>({...V,phase:O.phase}));break}case"criteria.updated":{if(!Gt(e,((D=n().currentSession)==null?void 0:D.id)??null)){l();break}const O=e.payload;t(V=>({currentSession:V.currentSession?{...V.currentSession,criteria:O.criteria}:null}));break}case"metadata.updated":{if(!Gt(e,((B=n().currentSession)==null?void 0:B.id)??null)){l();break}const O=e.payload;t(V=>({currentSession:V.currentSession?{...V.currentSession,metadataEntries:{...V.currentSession.metadataEntries,[O.key]:O.entries}}:null}));break}case"context.state":{const O=e.payload,V=Gt(e,((q=n().currentSession)==null?void 0:q.id)??null);O.subAgentId?V&&n().updateSubAgentContextState(O.subAgentId,O.context):V?t({contextState:O.context}):l();break}case"session.name_generated":{const O=e.payload,V=e.sessionId,G=(W=n().currentSession)==null?void 0:W.id;t(z=>{const X=z.sessions.map(F=>F.id===V?{...F,title:O.name,updatedAt:new Date().toISOString()}:F),ne=G===V?z.currentSession?{...z.currentSession,title:O.name,updatedAt:new Date().toISOString()}:null:z.currentSession;return{sessions:X,currentSession:ne}});break}case"queue.state":{const O=e.payload;t({queuedMessages:O.messages??[]});break}case"git.status":{const O=e.payload;t({gitStatus:{branch:O.branch,diff:O.diff}});break}case"devServer.output":case"devServer.state":{Rr.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{Zo.getState().handleMessage(e.type,e.payload);break}case"error":{const O=e.payload;console.error("Server error:",O),t({error:{code:O.code,message:O.message},streamingMessageId:null});break}}}let $o=!1,Nr=null;const Rf=new Set,Uc=new Map;function Nv(e,t,n){return e==null?void 0:e.map(s=>{const a=t.filter(l=>l.callId===s.id);return a.length===0?s:(n.add(s.id),{...s,streamingOutput:[...s.streamingOutput??[],...a.map(l=>({stream:l.stream,content:l.content,timestamp:Date.now()}))]})})}async function Tv(e,t,n,s,a){try{const u=await(await Ne(`/api/sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,messageKind:s})})).json();u.queueState&&a({queuedMessages:u.queueState})}catch(l){console.error("Error queueing message:",l)}}const we=qn((e,t)=>(q2(()=>{const n=yi();if(!n.messageId)return;const s=n.deltaContent.length>0,a=n.thinkingContent.length>0,l=n.toolOutput.length>0;if(!s&&!a&&!l)return;const u=n.deltaContent,c=n.thinkingContent,h=n.toolOutput;n.deltaContent="",n.thinkingContent="",n.toolOutput=[],e(f=>{const p=f.streamingMessage;if(p&&p.id===n.messageId){const m={...p};if(s&&(m.content=m.content+u),a&&(m.thinkingContent=(m.thinkingContent??"")+c),l){const _=new Set;m.toolCalls=Nv(m.toolCalls,h,_);const x=h.filter(w=>!_.has(w.callId));x.length>0&&n.toolOutput.push(...x)}return{streamingMessage:m}}if(l){const m=new Set,_=f.messages.map(w=>w.id!==n.messageId?w:{...w,toolCalls:Nv(w.toolCalls,h,m)}),x=h.filter(w=>!m.has(w.callId));return x.length>0&&n.toolOutput.push(...x),{messages:_}}return f})}),{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],pendingQuestion:null,visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,error:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let s=!1;try{s=(await(await Ne("/api/auth")).json()).requiresAuth}catch{}if(s&&!zt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}zt.onStatusChange(a=>{var l;if(e({connectionStatus:a}),a==="connected"){t().listSessions(void 0),Lt.getState().listProjects();const u=(l=t().currentSession)==null?void 0:l.id;u&&t().loadSession(u)}});try{await zt.connect(),$o||($o=!0,Nr=zt.subscribe(a=>{jv(a,e,t)}))}catch(a){console.error("Failed to connect:",a);const l=zt.getLastCloseCode();if(!zt.hasToken()&&(l===1006||l===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}Nr&&(Nr(),Nr=null),$o=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{zt.disconnect(),Nr&&(Nr(),Nr=null),$o=!1,e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{zt.disconnect(),Nr&&(Nr(),Nr=null),$o=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async n=>{try{const s=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:n})});if(!s.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:a}=await s.json();zt.setToken(a),e({showPasswordModal:!1}),t().connect();const{listProjects:l}=Lt.getState(),{fetchConfig:u}=Bt.getState();l(),u(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{zt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(n,s)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const l=await Ne("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:n,title:s})});if(!l.ok)return e({pendingSessionCreate:!1}),null;const u=await l.json();try{zt.send("session.load",{sessionId:u.session.id})}catch{}return u.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async n=>{if(!Rf.has(n)){Rf.add(n);try{const s=t().currentSession;!s||s.id!==n?e({currentSession:null,unreadSessionIds:t().unreadSessionIds.filter(u=>u!==n),subAgentContextStates:{},messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingPathConfirmations:[],queuedMessages:[],abortInProgress:!1,error:null,pendingSessionCreate:!1}):e({unreadSessionIds:t().unreadSessionIds.filter(u=>u!==n)});const a=await Ne(`/api/sessions/${n}`);if(!a.ok)return;const l=await a.json();e({currentSession:l.session,messages:l.messages??[],contextState:l.contextState,queuedMessages:l.queueState??[]}),zt.send("session.load",{sessionId:n});try{const u=await Ne(`/api/sessions/${n}/background-processes`);if(u.ok){const c=await u.json();Zo.getState().setProcesses(c.processes??[])}}catch{}}catch{}finally{Rf.delete(n)}}},listSessions:async(n,s=20)=>{const a=n??"global";if(Uc.has(a))return Uc.get(a);const l=(async()=>{try{const u=new URLSearchParams;u.set("limit",String(s)),n&&u.set("projectId",n);const h=await(await Ne(`/api/sessions?${u.toString()}`)).json(),f=h.sessions??[];e(p=>({sessions:f.map(m=>{var x,w;const _=p.sessions.find(k=>k.id===m.id);return{...m,title:m.title??(_==null?void 0:_.title),mode:((x=p.currentSession)==null?void 0:x.id)===m.id?p.currentSession.mode:(_==null?void 0:_.mode)??m.mode,phase:((w=p.currentSession)==null?void 0:w.id)===m.id?p.currentSession.phase:(_==null?void 0:_.phase)??m.phase,isRunning:m.isRunning&&(_==null?void 0:_.isRunning)!==!1,messageCount:m.messageCount,recentUserPrompts:m.recentUserPrompts}}),sessionsHasMore:n?h.hasMore??!1:!0}))}catch{}finally{Uc.delete(a)}})();return Uc.set(a,l),l},loadMoreSessions:async n=>{const s=t();if(!(s.sessionsPaginationLoading||!s.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const a=new URLSearchParams;a.set("limit","20"),a.set("offset",String(s.sessions.length)),a.set("projectId",n);const u=await(await Ne(`/api/sessions?${a.toString()}`)).json(),c=u.sessions??[];e(h=>({sessions:[...h.sessions,...c.map(f=>{const p=h.sessions.find(m=>m.id===f.id);return(p==null?void 0:p.isRunning)===!1?{...f,isRunning:!1}:f})],sessionsHasMore:u.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async n=>{var s;try{return(await Ne(`/api/sessions/${n}`,{method:"DELETE"})).ok?(await t().listSessions(),((s=t().currentSession)==null?void 0:s.id)===n&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(n,s)=>{var a;try{const l=await Ne(`/api/sessions/${n}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:s})});if(!l.ok)return!1;if(await t().listSessions(),((a=t().currentSession)==null?void 0:a.id)===n){const c=await l.json();c.session&&e({currentSession:c.session})}return!0}catch{return!1}},deleteAllSessions:async n=>{try{return(await Ne(`/api/projects/${n}/sessions`,{method:"DELETE"})).ok?(await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{e(n=>({currentSession:null,messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingSessionCreate:!1,unreadSessionIds:n.currentSession?n.unreadSessionIds.filter(s=>s!==n.currentSession.id):n.unreadSessionIds}))},sendMessage:async(n,s,a)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;if(l){e({streamingMessageId:null});try{const h=await(await Ne(`/api/sessions/${l}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,attachments:s,messageKind:a==null?void 0:a.messageKind})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(c){console.error("Error sending message:",c)}}},stopGeneration:async()=>{var s;const n=(s=t().currentSession)==null?void 0:s.id;if(n&&!t().abortInProgress){e({abortInProgress:!0});try{await Ne(`/api/sessions/${n}/stop`,{method:"POST"})}catch(a){console.error("Error stopping generation:",a)}}},continueGeneration:async()=>{var s;const n=(s=t().currentSession)==null?void 0:s.id;if(n){e({streamingMessageId:null});try{await Ne(`/api/sessions/${n}/continue`,{method:"POST"})}catch(a){console.error("Error continuing generation:",a)}}},launchRunner:(n,s,a,l)=>{e({streamingMessageId:null});const u={};n!=null&&n.trim()&&(u.content=n),s&&s.length>0&&(u.attachments=s),a&&(u.workflowId=a),l&&(u.subGroup=l),zt.send("runner.launch",u)},switchMode:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const l=await Ne(`/api/sessions/${s}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:n})});if(!l.ok){console.error("Failed to switch mode:",await l.json());return}const u=await l.json();u.session&&e({currentSession:u.session})}catch(l){console.error("Error switching mode:",l)}},switchDangerLevel:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const l=await Ne(`/api/sessions/${s}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:n})});if(!l.ok){console.error("Failed to switch danger level:",await l.json());return}const u=await l.json();u.session&&e({currentSession:u.session})}catch(l){console.error("Error switching danger level:",l)}},acceptAndBuild:(n,s,a,l)=>{var h;e({streamingMessageId:null});const u={};n&&(u.workflowId=n),s!=null&&s.trim()&&(u.content=s),a&&a.length>0&&(u.attachments=a),l&&(u.subGroup=l);const c=(h=t().currentSession)==null?void 0:h.id;c&&Ne(`/api/sessions/${c}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"builder"})}).then(()=>{zt.send("runner.launch",u)})},editCriteria:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const l=await Ne(`/api/sessions/${s}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:n})});l.ok||console.error("Failed to update criteria:",await l.json())}catch(l){console.error("Error updating criteria:",l)}},compactContext:()=>{zt.send("context.compact",{})},setSessionProvider:async(n,s)=>{var a,l;try{const u=(a=t().currentSession)==null?void 0:a.id;if(!u)return null;const c=await Ne(`/api/sessions/${u}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,...s?{model:s}:{}})});if(!c.ok)return null;const h=await c.json();if(e({currentSession:h.session,messages:h.messages??[],contextState:h.contextState}),(l=h.session)!=null&&l.providerId){const f=Bt.getState();f.providers.find(m=>m.id===h.session.providerId)&&f.syncFromSession(h.session.providerId,h.session.providerModel??"")}return h.session}catch{return null}},updateContextState:n=>{e({contextState:n})},updateSubAgentContextState:(n,s)=>{e(a=>({subAgentContextStates:{...a.subAgentContextStates,[n]:s}}))},clearSubAgentContextState:n=>{e(s=>{const a={...s.subAgentContextStates};return delete a[n],{subAgentContextStates:a}})},confirmPath:async(n,s,a=!1)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;if(l)try{await Ne(`/api/sessions/${l}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,approved:s,alwaysAllow:a})})}catch(c){console.error("Error confirming path:",c)}},answerQuestion:async(n,s)=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a){try{await Ne(`/api/sessions/${a}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,answer:s})})}catch(u){console.error("Error answering question:",u)}e({pendingQuestion:null})}},queueAsap:async(n,s,a)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;l&&await Tv(l,n,s,a,e)},queueCompletion:async(n,s,a)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;l&&await Tv(l,n,s,a,e)},cancelQueued:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const u=await(await Ne(`/api/sessions/${s}/queue/${n}`,{method:"DELETE"})).json();u.queueState&&e({queuedMessages:u.queueState})}catch(l){console.error("Error canceling queued message:",l)}},clearError:()=>{e({error:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:n=>{jv(n,e,t)}}));function Pu(){return we(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function uj(){return we(e=>e.abortInProgress)}function dj(){const e=we(s=>s.connect),t=we(s=>s.connectionStatus),n=bi(s=>s.load);return R.useEffect(()=>{e()},[e]),R.useEffect(()=>{t==="connected"&&n()},[t,n]),{connectionStatus:t}}const hj="modulepreload",fj=function(e){return"/"+e},Av={},Z=function(t,n,s){let a=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),h=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=u(n.map(f=>{if(f=fj(f),f in Av)return;Av[f]=!0;const p=f.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const _=document.createElement("link");if(_.rel=p?"stylesheet":hj,p||(_.as="script"),_.crossOrigin="",_.href=f,h&&_.setAttribute("nonce",h),document.head.appendChild(_),p)return new Promise((x,w)=>{_.addEventListener("load",x),_.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function l(u){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=u,window.dispatchEvent(c),!c.defaultPrevented)throw u}return a.then(u=>{for(const c of u||[])c.status==="rejected"&&l(c.reason);return t().catch(l)})},fS=[{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"}],Or=[{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"}},{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"}},{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"}},{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"}},{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":"76 86 106","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":"76 86 106"}}];function Lv(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}const Ut=qn((e,t)=>({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:Lv(),followSystemTheme:!0,isSystem:!1,applySavedTheme:()=>{const{getSavedTheme:n,applyPreset:s,applyTokens:a}=t(),l=n();if(l)try{const u=JSON.parse(l);u.preset&&u.tokens?(s(u.preset),e({basePreset:u.preset}),a(u.tokens)):u.preset?s(u.preset):u.tokens&&a(u.tokens)}catch{s("dark")}else s("dark")},applyPreset:n=>{if(Or.find(a=>a.id===n))if(n==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";e({basePreset:"system",currentPreset:l,customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!0}),t().applyTheme()}else e({currentPreset:n,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!1}),t().applyTheme()},startCustomizing:()=>{var a;const{currentPreset:n}=t(),s=((a=Or.find(l=>l.id===n))==null?void 0:a.tokens)??{};e({basePreset:n,customTokens:{...s},isCustom:!0,isCustomizing:!0})},setCustomToken:(n,s)=>{e(a=>({customTokens:{...a.customTokens,[n]:s}})),t().applyTheme()},cancelCustomizing:()=>{t().applyPreset(t().basePreset||t().currentPreset)},saveCustomTheme:()=>{const{customTokens:n}=t();t().saveTheme(JSON.stringify({tokens:n})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:n=>{e({customTokens:n,isCustom:!0,isCustomizing:!1}),t().applyTheme()},getActiveTheme:()=>{var u,c;const{basePreset:n,customTokens:s,isCustom:a}=t();if(a&&n)return{...((u=Or.find(f=>f.id===n))==null?void 0:u.tokens)??{},...s};if(a)return{...fS.reduce((h,f)=>({...h,[f.key]:f.defaultValue}),{}),...s};const l=Or.find(h=>h.id===t().currentPreset);return(l==null?void 0:l.tokens)??((c=Or[0])==null?void 0:c.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const n=t().getActiveTheme(),s=document.documentElement;Object.entries(n).forEach(([a,l])=>{s.style.setProperty(`--${a}`,l)})},getSavedTheme:()=>{try{const n=localStorage.getItem("openfox:theme");if(!n)return null;if(n[0]!=="{")return JSON.stringify({preset:n});const s=JSON.parse(n);if(s.preset)return JSON.stringify({preset:s.preset});if(s.tokens)return JSON.stringify({tokens:s.tokens})}catch{return null}return null},saveTheme:async n=>{localStorage.setItem("openfox:theme",n);const{useSettingsStore:s}=await Z(async()=>{const{useSettingsStore:a}=await Promise.resolve().then(()=>jf);return{useSettingsStore:a}},void 0);await s.getState().setSetting(ze.DISPLAY_THEME,n)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:n=>{e({followSystemTheme:n}),Z(async()=>{const{useSettingsStore:s,SETTINGS_KEYS:a}=await Promise.resolve().then(()=>jf);return{useSettingsStore:s,SETTINGS_KEYS:a}},void 0).then(({useSettingsStore:s,SETTINGS_KEYS:a})=>{s.getState().setSetting(a.DISPLAY_FOLLOW_SYSTEM_THEME,String(n))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const n=window.matchMedia("(prefers-color-scheme: dark)"),s=l=>{const{followSystemTheme:u}=t();u&&(t().applyPreset(l?"dark":"light"),t().saveTheme(JSON.stringify({preset:l?"dark":"light"})))},a=l=>s(l.matches);return n.addEventListener("change",a),()=>n.removeEventListener("change",a)},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[],followSystemTheme:!0})},addUserPreset:n=>{const{basePreset:s,customTokens:a,currentPreset:l}=t(),u={id:"custom-"+Date.now(),name:n,basePreset:s||l,tokens:{...a}},c=[...t().userPresets,u];e({userPresets:c}),t().saveUserPresets()},applyUserPreset:n=>{const s=t().userPresets[n];s&&(e({currentPreset:s.basePreset,basePreset:s.basePreset,customTokens:{...s.tokens},isCustom:!0,isCustomizing:!1}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:s.basePreset,tokens:s.tokens})).catch(()=>{}))},deleteUserPreset:n=>{const s=t().userPresets.filter((a,l)=>l!==n);e({userPresets:s}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:Lv()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),Z(async()=>{const{useSettingsStore:n}=await Promise.resolve().then(()=>jf);return{useSettingsStore:n}},void 0).then(({useSettingsStore:n})=>{n.getState().setSetting(ze.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})}}));function mj({canLoad:e,projectId:t,currentProjectId:n}){const s=Lt(u=>u.loadProject),a=we(u=>u.listSessions),l=we(u=>u.clearSession);R.useEffect(()=>{e&&t&&(n!==t&&s(t),a(t),l())},[e,t,n,s,a,l])}function pj({canLoad:e,projectId:t,sessionId:n,currentProjectId:s,currentSessionId:a}){const l=we(f=>f.loadSession),u=Lt(f=>f.loadProject),c=we(f=>f.listSessions),h=we(f=>f.pendingSessionCreate);R.useEffect(()=>{e&&t&&s!==t&&u(t)},[e,t,s,u]),R.useEffect(()=>{e&&n&&a!==n&&l(n),e&&t&&c(t)},[e,n,a,l,c,h,t])}function gj({className:e="w-5 h-5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function mS({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function xj({className:e="w-5 h-5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 _j({className:e="w-3 h-3 text-text-muted"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 yj({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.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 Mr({className:e="w-3.5 h-3.5 text-text-muted"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function Sr({className:e="w-3 h-3 text-text-muted",rotate:t}){return o.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:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function vj({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function ap({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 bj({className:e="w-3 h-3"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 op({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("circle",{cx:"12",cy:"5",r:"2"}),o.jsx("circle",{cx:"12",cy:"12",r:"2"}),o.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function uu({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 Bu({className:e="w-5 h-5 text-accent-primary"}){return o.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:o.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 Sj({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 wj({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 Cj({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.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 pS({className:e="w-3 h-3"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 kj({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 Dv({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function gS({className:e="w-[18px] h-[18px]"}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function Ej({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[o.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"}),o.jsx("path",{d:"M9.5 2h4.5v4.5"}),o.jsx("path",{d:"M14 2L7.5 8.5"})]})}function jj({className:e="w-3 h-3",color:t}){return o.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M8 5v14l11-7z"})})}function qs({className:e="w-3 h-3 text-accent-primary"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function Nj({className:e="w-5 h-5"}){return o.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:o.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 lp({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 Tj({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.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"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function Aj({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return o.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[o.jsx("title",{children:"Running"}),o.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),o.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function Lj({className:e="w-3.5 h-3.5 text-text-muted"}){return o.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:o.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 Dj({className:e="w-3.5 h-3.5 text-text-muted"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 xS({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function Rj({className:e="w-3.5 h-3.5 shrink-0",color:t}){return o.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:o.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 Oj({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("polyline",{points:"4 17 10 11 4 5"}),o.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function pl({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 cp(){return o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 Mj({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 bm({className:e="w-2.5 h-2.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 gl({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:o.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 _S({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.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 Ij({className:e="w-3.5 h-3.5 text-text-muted"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 Pj({className:e="w-3.5 h-3.5 text-text-muted"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 Rv({className:e="w-3.5 h-3.5 text-text-muted"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 Sm(){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 Ov(e,t){const n=zt.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:Sm(),type:e,payload:t}))}const _r=qn((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 s=await Ne(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(s.ok){const a=await s.json();e({sessions:a});const l=zt.ws;if(l&&l.readyState===WebSocket.OPEN)for(const u of a)l.send(JSON.stringify({id:Sm(),type:"terminal.subscribe",payload:{sessionId:u.id}}))}}catch(s){console.error("Failed to fetch terminals:",s)}},createSession:async(n,s)=>{try{const a=await Ne("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:s})});if(a.ok){const l=await a.json();e(c=>({sessions:[...c.sessions,l]}));const u=zt.ws;u&&u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({id:Sm(),type:"terminal.subscribe",payload:{sessionId:l.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,s)=>{Ov("terminal.write",{sessionId:n,data:s})},resizeSession:(n,s,a)=>{Ov("terminal.resize",{sessionId:n,cols:s,rows:a})},killSession:async n=>{try{(await Ne(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(a=>({sessions:a.sessions.filter(l=>l.id!==n)}))}catch(s){console.error("Failed to kill terminal:",s)}},handleMessage:n=>{switch(n.type){case"terminal.exit":{const{sessionId:s}=n.payload||{};s&&e(a=>{const l=a.sessions.filter(u=>u.id!==s);return l.length===0&&a.isOpen?{sessions:[],isOpen:!1}:{sessions:l}});break}}}}));zt.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&_r.getState().handleMessage(e)});const Aa={terminalToggle:{type:"double-press",key:"Control",threshold:300},quickAction:{type:"double-press",key:"Shift",threshold:300},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 wm(e){if(!e)return structuredClone(Aa);try{const t=JSON.parse(e);return{terminalToggle:t.terminalToggle??structuredClone(Aa.terminalToggle),quickAction:t.quickAction??structuredClone(Aa.quickAction),agentSwitching:t.agentSwitching??structuredClone(Aa.agentSwitching)}}catch{return structuredClone(Aa)}}function Mv(e){return e.code.startsWith("Digit")?e.code.slice(-1):e.code.startsWith("Key")?e.code.slice(3).toLowerCase():e.key}function yS(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(s=>{switch(s){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 Bj(e){return e.type==="double-press"}function vS(e){return e.type==="chord"}function zj(e,t){return t.length===1&&/^[a-z]$/i.test(t)?e.code===`Key${t.toUpperCase()}`:t.length===1&&/^[0-9]$/.test(t)?e.code===`Digit${t}`:e.key.toLowerCase()===t.toLowerCase()}function bS(e,t){const n=t.modifiers.includes("ctrl"),s=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),l=t.modifiers.includes("shift");return zj(e,t.key)&&e.ctrlKey===n&&e.metaKey===s&&e.altKey===a&&e.shiftKey===l}function up(){const e=an(t=>t.settings[ze.KEYBINDINGS]);return wm(e)}function Hj(e,t,n){const s=R.useRef(0),a=R.useRef(t);a.current=t,R.useEffect(()=>{if(!e)return;const l=e.threshold??300,u=c=>{if(c.key!==e.key)return;const h=e.key==="Control",f=e.key==="Shift",p=e.key==="Alt",m=e.key==="Meta";if(!h&&c.ctrlKey||!f&&c.shiftKey||!p&&c.altKey||!m&&c.metaKey)return;const _=Date.now();_-s.current<l?(c.preventDefault(),c.stopPropagation(),a.current(),s.current=0):s.current=_};return window.addEventListener("keydown",u,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",u,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function $j(e,t){const n=R.useRef(t);n.current=t,R.useEffect(()=>{if(!e)return;const s=a=>{bS(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e])}function SS(e,t,n){Hj(e&&Bj(e)?e:void 0,t,n),$j(e&&vS(e)?e:void 0,t)}function Uj(e,t,n){const s=R.useRef(n);s.current=n,R.useEffect(()=>{const a=l=>{for(let u=0;u<e.length;u++){const c=e[u];if(!c)continue;const h=t[u];if(h&&vS(c)&&bS(l,c)){l.preventDefault(),s.current(h.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var $a=Q0();const zu=R.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...s},a)=>o.jsx("button",{ref:a,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...s,children:o.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));zu.displayName="IconButton";const Fj="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",Fs=R.forwardRef((e,t)=>o.jsx(zu,{ref:t,icon:Fj,title:"Edit",...e}));Fs.displayName="EditButton";const Vj="M6 18L18 6M6 6l12 12",dp=R.forwardRef((e,t)=>o.jsx(zu,{ref:t,icon:Vj,...e}));dp.displayName="CloseButton";const Gj={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 Dt({label:e,title:t,size:n="md",minHeight:s,children:a,footer:l,className:u,onClose:c,isOpen:h,closeOnBackdropClick:f=!0,closeOnEscape:p=!0,showCloseButton:m=!0}){const[_,x]=R.useState(!1),w=h!==void 0,k=w?h:_,y=R.useCallback(()=>{w||x(!0)},[w]),S=R.useCallback(()=>{w||x(!1),c==null||c()},[w,c]);R.useEffect(()=>{if(!k||!p)return;const b=E=>{E.key==="Escape"&&(E.stopPropagation(),S())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[k,S,p]);const v=e&&(typeof e=="string"?o.jsx("button",{type:"button",onClick:y,className:u,children:e}):o.jsx("span",{onClick:y,className:u,style:{cursor:"pointer"},children:e}));return o.jsxs(o.Fragment,{children:[v,k&&(typeof document<"u"?$a.createPortal(o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[o.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:f?S:void 0}),o.jsxs("div",{className:`relative w-full ${Gj[n]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||m)&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t&&o.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),m&&o.jsx(dp,{onClick:S,className:"ml-auto","aria-label":"Close"})]}),o.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",style:s?{minHeight:s}:void 0,children:a}),l&&o.jsx("div",{className:"px-4 py-3 border-t border-border",children:l})]})]}),document.body):null)]})}function Wj({value:e,defaultUrl:t,disabled:n,onChange:s}){const a=e??t;return o.jsxs("div",{className:"relative",children:[o.jsx("select",{value:a,disabled:n,onChange:l=>{const u=l.target.value;s(u===t?null:u)},className:"appearance-none bg-bg-tertiary border border-border rounded px-1.5 pr-5 text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary disabled:opacity-40 cursor-pointer",style:{width:"60px"},children:Y2.map(({url:l,label:u})=>o.jsx("option",{value:l,title:u,children:u.split(" ")[0]},l))}),o.jsx(Sr,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const Iv=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function qj(){const e=bi(h=>h.settings),t=bi(h=>h.update),n=bi(h=>h.updateEvent),s=bi(h=>h.updateAgentOverride),a=bi(h=>h.load);R.useEffect(()=>{a()},[a]);const l=async()=>{await Q2()==="granted"&&t({...e,browserNotificationEnabled:!0})},u=(h,f,p,m)=>{h==="general"?n(f,{[p]:m}):s(h,f,{[p]:m})},c=(h,f,p)=>{h==="general"?n(f,{customSoundUrl:p}):s(h,f,{customSoundUrl:p})};return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),o.jsx(Pv,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:h=>t({...e,soundEnabled:h})}),o.jsx(Pv,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:h=>{h&&typeof Notification<"u"&&Notification.permission!=="granted"?l():t({...e,browserNotificationEnabled:h})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&o.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),o.jsx("div",{className:"border border-border rounded overflow-hidden",children:o.jsxs("table",{className:"w-full text-sm",children:[o.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:o.jsxs("tr",{className:"border-b border-border",children:[o.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),Iv.map(h=>o.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:h.label},h.key))]})}),o.jsx("tbody",{children:K2.map(h=>o.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[o.jsx("td",{className:"px-3 py-2",children:o.jsx("div",{className:"text-text-primary text-xs",children:h.label})}),Iv.map(f=>{const p=dS(e,h.key,f.key==="general"?void 0:f.key),m=cS[h.key];return o.jsx("td",{className:"px-2 py-2 align-top",children:o.jsxs("div",{className:"flex flex-col items-center gap-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:o.jsx("input",{type:"checkbox",checked:p.soundEnabled,onChange:_=>u(f.key,h.key,"soundEnabled",_.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),o.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:o.jsx("input",{type:"checkbox",checked:p.browserNotification,onChange:_=>u(f.key,h.key,"browserNotification",_.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&o.jsx(Wj,{value:p.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:_=>c(f.key,h.key,_)})]})},f.key)})]},h.key))})]})})]})]})}function Pv({label:e,description:t,checked:n,onChange:s}){return o.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer group",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),o.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:t})]}),o.jsx("div",{className:"flex-shrink-0 pt-0.5",children:o.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(),s(!n)},children:o.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 tt=R.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:s,...a},l)=>{const u="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",c={primary:"bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40",secondary:"bg-bg-tertiary text-text-primary hover:bg-border",danger:"bg-accent-error text-white hover:bg-accent-error/80"},h={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return o.jsx("button",{ref:l,className:`${u} ${c[e]} ${h[t]} ${n}`,...a,children:s})});tt.displayName="Button";async function hp(e,t,n){t({loading:!0});try{const a=await(await Ne(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const Tr=qn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchSkills:async()=>{await hp("/api/skills",e,!0)},toggleSkill:async n=>{try{const a=await(await Ne(`/api/skills/${n}/toggle`,{method:"POST"})).json();e(l=>({defaults:l.defaults.map(u=>u.id===n?{...u,enabled:a.enabled}:u),userItems:l.userItems.map(u=>u.id===n?{...u,enabled:a.enabled}:u)}))}catch{}},fetchSkill:async n=>{try{const s=await Ne(`/api/skills/${n}`);return s.ok?await s.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const s=await Ne(`/api/skills/defaults/${n}`);return s.ok?await s.json():null}catch{return null}},createSkill:async(n,s)=>{const a=await Ws("POST","/api/skills",{...n,destination:s});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,s)=>{const a=await Ws("PUT",`/api/skills/${n}`,s);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const s=await Ne(`/api/skills/${n}`,{method:"DELETE"}),a=await s.json();return s.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,s)=>Iu(`/api/skills/${n}/duplicate`,()=>t().fetchSkills(),s)}));function fp(){const[e,t]=R.useState({id:null,type:null}),n=R.useCallback(l=>t({id:l,type:"delete"}),[]),s=R.useCallback(()=>t({id:null,type:null}),[]),a=R.useCallback((l,u)=>e.id===l&&e.type===u,[e.id,e.type]);return{requestDelete:n,clearConfirm:s,isConfirming:a}}function mp({onConfirm:e,onCancel:t}){return o.jsxs("div",{className:"flex items-center gap-1",children:[o.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"}),o.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 pp({onClick:e}){return o.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:o.jsx(pl,{})})}function du({onClick:e}){return o.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:o.jsx(ap,{})})}function ji({label:e,value:t,onChange:n,placeholder:s,readOnly:a,hint:l,mono:u}){return o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,l&&o.jsx("span",{className:"text-text-muted ml-1",children:l})]}),o.jsx("input",{value:t,onChange:c=>n(c.target.value),readOnly:a,placeholder:s,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${u?"font-mono":""} ${a?"opacity-60":""}`})]})}function Kj({onCancel:e,onSave:t,saving:n,saveDisabled:s}){return o.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[o.jsx(tt,{variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(tt,{variant:"primary",onClick:t,disabled:n||s,children:n?"Saving...":"Save"})]})}function gp({message:e}){return o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function wS({description:e,onNew:t,loading:n,hasItems:s,children:a}){return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("p",{className:"text-text-secondary text-sm",children:e}),o.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:o.jsx(tt,{variant:"primary",size:"sm",onClick:t,children:"+ New"})})]}),n&&!s?o.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."}):s?a:o.jsx("div",{className:"text-text-muted text-sm",children:"No items defined."})]})}function CS({label:e="Custom",children:t}){return o.jsxs("div",{children:[o.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),o.jsx("div",{className:"space-y-2",children:t})]})}function kS({description:e,onNew:t,newLabel:n="+ New"}){return o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("p",{className:"text-text-secondary text-sm",children:e}),o.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:o.jsx(tt,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function ES({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:s,onDuplicate:a,onDelete:l,children:u}){return o.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[o.jsx("div",{className:"min-w-0 flex-1 mr-3",children:u}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&n&&o.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:o.jsx(uu,{})}),o.jsx(du,{onClick:a}),!e&&s&&o.jsx(Fs,{onClick:s}),!e&&(t?o.jsx(mp,{onConfirm:()=>{l==null||l()},onCancel:()=>{}}):o.jsx(pp,{onClick:()=>l==null?void 0:l()}))]})]})}function Yj({id:e,name:t,description:n,isBuiltIn:s,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:h}){return o.jsxs(ES,{isBuiltIn:s,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:h,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),o.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&o.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function jS({loading:e,hasItems:t,loadingLabel:n,emptyLabel:s,children:a}){return e&&!t?o.jsx("div",{className:"text-text-muted text-sm",children:n}):t?o.jsx("div",{className:"space-y-4",children:a}):s?o.jsx("div",{className:"text-text-muted text-sm",children:s}):null}function NS({name:e,id:t,nameLabel:n="Name",idLabel:s="ID",namePlaceholder:a="My Item",idPlaceholder:l="my-item",nameHint:u,readOnlyId:c=!1,readOnlyHint:h="(read-only)",onNameChange:f,onIdChange:p}){return o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(ji,{label:n,value:e,onChange:f,placeholder:a,hint:u}),o.jsx(ji,{label:s,value:t,onChange:p,readOnly:c,placeholder:l,hint:c?h:void 0,mono:!0})]})}function TS(e={}){const{initialData:t={}}=e,[n,s]=R.useState("list"),[a,l]=R.useState(null),[u,c]=R.useState(""),[h,f]=R.useState(!1),[p,m]=R.useState(t),_=R.useCallback(()=>{m(t),c(""),l(null)},[t]),x=R.useCallback(S=>{s(S),S==="list"&&_()},[_]),w=R.useCallback(S=>{m(v=>typeof S=="function"?S(v):S)},[]),k=R.useCallback((S,v={})=>{l(S),s("edit"),m({...v}),c("")},[]),y=R.useCallback(()=>{l(null),s("edit"),m(t),c("")},[t]);return{view:n,editingId:a,formError:u,saving:h,formData:p,setView:x,setEditingId:l,setFormError:c,setFormData:w,setSaving:f,resetForm:_,startEditing:k,startNew:y}}function Bv({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:s,onEdit:a,onDuplicate:l,onDelete:u}){return o.jsx(Yj,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:s,onEdit:a,onDuplicate:l,onDelete:u})}function Xj({isOpen:e}){const t=Tr(z=>z.defaults),n=Tr(z=>z.userItems),s=Tr(z=>z.projectItems),a=Tr(z=>z.loading),l=Tr(z=>z.fetchSkills),u=Tr(z=>z.fetchSkill),c=Tr(z=>z.fetchDefaultContent),h=Tr(z=>z.createSkill),f=Tr(z=>z.updateSkill),p=Tr(z=>z.deleteSkill),{view:m,editingId:_,formError:x,saving:w,formData:k,setView:y,setEditingId:S,setFormError:v,setFormData:b,setSaving:E}=TS(),{clearConfirm:T}=fp();R.useEffect(()=>{e&&(l(),y("list"),S(null),T())},[e,l,T]);const N=(z,X,ne,F)=>{b({name:F??z.metadata.name,id:ne??z.metadata.id,description:z.metadata.description??"",version:z.metadata.version??"1.0.0",prompt:z.prompt,isReadOnly:X,destination:"user"})},L=async z=>{if(t.some(ne=>ne.id===z)){const ne=await c(z);if(!ne)return;N(ne,!0),S(z),v(""),y("edit")}else{const ne=await u(z);if(!ne)return;N(ne,!0),S(z),v(""),y("edit")}},A=async z=>{const ne=t.some(M=>M.id===z)?await c(z):await u(z);if(!ne)return;const F=`${z}-copy-${Date.now()}`;N(ne,!1,F,`${ne.metadata.name} (copy)`),S(null),v(""),y("edit")},D=()=>{b({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),y("edit")},B=async z=>{const X=await u(z);X&&(N(X,!1),S(z),v(""),y("edit"))},q=async z=>{await p(z),T()},W=async()=>{const z=_??k.id;if(!z||!k.name||!k.prompt){v("Name, ID, and prompt are required.");return}E(!0),v("");const X={metadata:{id:z,name:k.name,description:k.description,version:k.version},prompt:k.prompt},ne=_?await f(_,X):await h(X,k.destination);if(E(!1),!ne.success){v(ne.error??"Failed to save skill.");return}y("list")},O=z=>{b(X=>({...X,name:z})),_||b(X=>({...X,id:z.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},V=k.isReadOnly;if(m==="edit")return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex justify-between items-center mb-3",children:[o.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:V?k.name:_?"Edit Skill":"New Skill"}),o.jsx("button",{onClick:()=>y("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),x&&o.jsx(gp,{message:x}),o.jsxs("div",{className:"space-y-3 mb-3",children:[o.jsx(NS,{name:k.name,id:k.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:O,onIdChange:()=>{}}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(ji,{label:"Description",value:k.description,onChange:z=>b(X=>({...X,description:z})),placeholder:"What this skill does...",readOnly:V}),o.jsx(ji,{label:"Version",value:k.version,onChange:z=>b(X=>({...X,version:z})),placeholder:"1.0.0",readOnly:V})]})]}),o.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),o.jsx("textarea",{value:k.prompt,onChange:z=>b(X=>({...X,prompt:z.target.value})),readOnly:V,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"})]}),!_&&o.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[o.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),o.jsxs("select",{value:k.destination,onChange:z=>b(X=>({...X,destination:z.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:[o.jsx("option",{value:"user",children:"Global config"}),o.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[o.jsx(tt,{variant:"secondary",onClick:()=>y("list"),children:"Cancel"}),V?o.jsx(tt,{variant:"primary",onClick:()=>{b(z=>({...z,name:z.name+" (copy)",id:`${_}-copy-${Date.now()}`,isReadOnly:!1})),S(null)},children:"Duplicate & Customize"}):o.jsx(tt,{variant:"primary",onClick:W,disabled:w||!k.name||!k.id||!k.prompt,children:w?"Saving...":"Save"})]})]});function G({items:z}){return z.map(X=>o.jsx(Bv,{skill:X,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>L(X.id),onEdit:()=>B(X.id),onDuplicate:()=>A(X.id),onDelete:()=>q(X.id)},X.id))}return o.jsxs("div",{children:[o.jsx(kS,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:D}),o.jsxs(jS,{loading:a,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),o.jsx("div",{className:"space-y-2",children:t.map(z=>o.jsx(Bv,{skill:z,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>L(z.id),onDuplicate:()=>A(z.id)},z.id))})]}),n.length>0&&o.jsx(CS,{children:o.jsx(G,{items:n})}),s.length>0&&o.jsxs("div",{className:"mt-4",children:[o.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),o.jsx("div",{className:"space-y-2",children:o.jsx(G,{items:s})})]})]})]})}function Hu(){const e=an(a=>a.settings),t=an(a=>a.loading),n=an(a=>a.getSetting),s=an(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:s}}function Qj({isOpen:e}){const{settings:t,loading:n,getSetting:s,setSetting:a}=Hu(),l=t[ze.GLOBAL_INSTRUCTIONS]??"",u=n[ze.GLOBAL_INSTRUCTIONS]??!1,[c,h]=R.useState(l),[f,p]=R.useState(!1),[m,_]=R.useState(!1);R.useEffect(()=>{e&&s(ze.GLOBAL_INSTRUCTIONS)},[e,s]),R.useEffect(()=>{h(l),p(!1)},[l]);const x=async()=>{_(!0),await a(ze.GLOBAL_INSTRUCTIONS,c),_(!1),p(!1)},w=()=>{h(l),p(!1)},k=u||m;return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),o.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),o.jsx("textarea",{value:c,onChange:y=>{h(y.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:k})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(tt,{variant:"secondary",onClick:w,disabled:!f,children:"Discard"}),o.jsx(tt,{variant:"primary",onClick:x,disabled:!f||k,children:m?"Saving...":"Save"})]})]})}function Jj(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),s=parseInt(t[2]??"0",16),a=parseInt(t[3]??"0",16);return`${n} ${s} ${a}`}return e}function vi(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 Zj({isOpen:e,isNew:t,basePresetId:n,presetName:s,initialTokens:a,onClose:l,onSave:u}){const[c,h]=R.useState(a),[f,p]=R.useState(s);R.useEffect(()=>{h(a),p(s)},[a,s]);const m=(y,S)=>{const v=S.startsWith("#")?Jj(S):S;h(b=>({...b,[y]:v}))},_=()=>{u(f.trim()||"Untitled",{...c})},x=fS.reduce((y,S)=>{const v=S.category;return y[v]||(y[v]=[]),y[v].push(S),y},{}),w={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},k=Or.find(y=>y.id===n);return o.jsx(Dt,{isOpen:e,onClose:l,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:o.jsxs("div",{className:"flex gap-2 justify-end",children:[o.jsx("button",{type:"button",onClick:l,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),o.jsx("button",{type:"button",onClick:_,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),o.jsx("input",{type:"text",value:f,onChange:y=>p(y.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"})]}),!t&&o.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",o.jsx("span",{className:"text-text-primary",children:k==null?void 0:k.name})]}),Object.entries(x).map(([y,S])=>o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:w[y]??y}),o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:S.map(v=>o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("label",{htmlFor:v.key,className:"text-xs text-text-muted",children:v.label}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"color",id:v.key,value:vi(c[v.key]??v.defaultValue),onChange:b=>m(v.key,b.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent flex-shrink-0"}),o.jsx("input",{type:"text",value:c[v.key]??v.defaultValue,onChange:b=>m(v.key,b.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"})]})]},v.key))})]},y))]})})}function eN(){const[e,t]=R.useState(null),n=Ut(b=>b.currentPreset),s=Ut(b=>b.isCustom),a=Ut(b=>b.basePreset),l=Ut(b=>b.isSystem),u=Ut(b=>b.applyPreset),c=Ut(b=>b.applyUserPreset),h=Ut(b=>b.deleteUserPreset),f=Ut(b=>b.saveTheme),p=Ut(b=>b.userPresets),m=b=>{b==="system"?(u(b),f(JSON.stringify({preset:"system"})).catch(()=>{})):(u(b),f(JSON.stringify({preset:b})).catch(()=>{}))},_=b=>{c(b)},x=b=>{const E=Or.find(T=>T.id===b);E&&t({type:"new",presetIndex:p.length,basePresetId:b,presetName:E.name+" Copy",tokens:{...E.tokens}})},w=b=>{const E=p[b];if(!E)return;const T=Or.find(L=>L.id===E.basePreset),N=T?{...T.tokens,...E.tokens}:E.tokens;t({type:"edit",presetIndex:b,basePresetId:E.basePreset,presetName:E.name,tokens:N})},k=(b,E)=>{if(!e)return;const T=[...p];if(e.type==="new"){const N={id:"custom-"+Date.now(),name:b,basePreset:e.basePresetId,tokens:E};T.push(N);const L=T.length-1;Ut.setState({userPresets:T}),Ut.getState().saveUserPresets(),Ut.getState().applyUserPreset(L)}else{const N=T[e.presetIndex];N&&(T[e.presetIndex]={...N,name:b,tokens:E}),Ut.setState({userPresets:T}),Ut.getState().saveUserPresets(),Ut.getState().applyUserPreset(e.presetIndex)}t(null)},y=()=>{t(null)},S=(b,E)=>{b.stopPropagation(),h(E)},v=l?"system":s?a:n;return o.jsxs("div",{className:"space-y-4",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),o.jsx("div",{className:"flex flex-wrap gap-2 pb-2",children:Or.map(b=>{const E=b.id===v&&!s;return o.jsxs("div",{className:"relative group",children:[o.jsxs("button",{type:"button",onClick:()=>m(b.id),className:`flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors min-w-[80px] ${E?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[o.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:b.id==="system"?"transparent":vi(b.tokens["color-bg-primary"]??"#000"),borderColor:vi(b.tokens["color-border"]??"#000")},children:b.id==="system"?o.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:"linear-gradient(135deg, #000 50%, #fff 50%)"}}):o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:vi(b.tokens["color-text-primary"]??"#fff")}})}),o.jsx("span",{className:"text-xs",children:b.name})]}),b.id!=="system"&&o.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),x(b.id)},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:o.jsx("span",{className:"text-xs",children:"✎"})})]},b.id)})}),p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:"My Themes"}),o.jsx("div",{className:"grid grid-cols-5 gap-2",children:p.map((b,E)=>{const T=Or.find(L=>L.id===b.basePreset),N=T?{...T.tokens,...b.tokens}:b.tokens;return o.jsxs("div",{className:"relative group",children:[o.jsxs("button",{type:"button",onClick:()=>_(E),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${s&&a===b.basePreset&&v===b.basePreset?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[o.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:vi(N["color-bg-primary"]??"#000"),borderColor:vi(N["color-border"]??"#000")},children:o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:vi(N["color-text-primary"]??"#fff")}})}),o.jsx("span",{className:"text-xs truncate w-full text-center",children:b.name})]}),o.jsx("button",{type:"button",onClick:L=>{L.stopPropagation(),w(E)},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:o.jsx("span",{className:"text-xs",children:"✎"})}),o.jsx("button",{type:"button",onClick:L=>S(L,E),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:o.jsx(gl,{className:"w-3 h-3"})})]},b.id)})})]}),e&&o.jsx(Zj,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,initialTokens:e.tokens,onClose:y,onSave:k})]})}function tN(){return o.jsx(eN,{})}function nN(){const{settings:e,loading:t,getSetting:n,setSetting:s}=Hu(),a=t[ze.DISPLAY_SHOW_THINKING]??!1,l=[{key:ze.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:ze.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:ze.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:ze.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:ze.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"},{key:ze.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but very slow - does not affect red/green diff coloring"}],u=Object.fromEntries(l.map(p=>[p.key,e[p.key]??"true"])),[c,h]=R.useState(()=>Object.fromEntries(l.map(p=>[p.key,u[p.key]==="true"])));R.useEffect(()=>{l.forEach(p=>n(p.key))},[n]),R.useEffect(()=>{h(Object.fromEntries(l.map(p=>[p.key,u[p.key]==="true"])))},[JSON.stringify(u)]);const f=async p=>{const m=String(!c[p]);h(_=>({..._,[p]:!_[p]})),await s(p,m)};return a?o.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):o.jsxs("div",{className:"space-y-6",children:[o.jsx(tN,{}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),o.jsx("div",{className:"space-y-4",children:l.map(({key:p,label:m,description:_})=>o.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-text-primary font-medium",children:m}),o.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:_})]}),o.jsx("button",{type:"button",onClick:()=>f(p),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${c[p]?"bg-accent-primary":"bg-bg-tertiary"}`,children:o.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${c[p]?"translate-x-6":"translate-x-1"}`})})]},p))})]})]})}function rN({enabled:e,onClick:t}){return o.jsx("button",{type:"button",onClick:t,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-accent-primary":"bg-bg-tertiary"}`,children:o.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function sN(e){try{return new RegExp(e),!0}catch{return!1}}function iN({value:e,onChange:t}){const[n,s]=R.useState({}),a=(h,f)=>{const p=e.patterns.map((m,_)=>_===h?{...m,...f}:m);t({...e,patterns:p})},l=h=>{const f=e.patterns.filter((p,m)=>m!==h);t({...e,patterns:f})},u=()=>{const h={field:"content",pattern:"",action:"retry",active:!0};t({...e,patterns:[...e.patterns,h]})},c=(h,f)=>{s(p=>({...p,[h]:f.length>0&&!sN(f)})),a(h,{pattern:f})};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-sm font-medium text-text-primary",children:"Max Retries Per Turn"}),o.jsx("input",{type:"number",min:1,max:100,value:e.maxRetriesPerTurn,onChange:h=>{const f=parseInt(h.target.value,10),p=isNaN(f)?10:Math.max(1,Math.min(100,f));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?o.jsx("p",{className:"text-sm text-text-muted",children:"No retry patterns configured."}):o.jsxs("table",{className:"w-full text-sm",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"text-left text-text-muted border-b border-border",children:[o.jsx("th",{className:"pb-2 pr-2 w-12",children:"Active"}),o.jsx("th",{className:"pb-2 pr-2",children:"Field"}),o.jsx("th",{className:"pb-2 pr-2",children:"Pattern"}),o.jsx("th",{className:"pb-2 pr-2",children:"Action"}),o.jsx("th",{className:"pb-2 w-8"})]})}),o.jsx("tbody",{children:e.patterns.map((h,f)=>o.jsxs("tr",{className:"border-b border-border",children:[o.jsx("td",{className:"py-2 pr-2",children:o.jsx("input",{type:"checkbox",checked:h.active,onChange:()=>a(f,{active:!h.active}),className:"accent-accent-primary","aria-label":`Toggle pattern ${f+1}`})}),o.jsx("td",{className:"py-2 pr-2",children:o.jsxs("select",{value:h.field,onChange:p=>a(f,{field:p.target.value}),className:"px-2 py-1 bg-bg-secondary border border-border rounded text-sm",children:[o.jsx("option",{value:"content",children:"content"}),o.jsx("option",{value:"thinking",children:"thinking"}),o.jsx("option",{value:"both",children:"both"})]})}),o.jsx("td",{className:"py-2 pr-2",children:o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("input",{type:"text",value:h.pattern,onChange:p=>c(f,p.target.value),placeholder:"regex pattern",className:"flex-1 px-2 py-1 bg-bg-secondary border border-border rounded text-sm font-mono"}),h.pattern.length>0&&o.jsx("span",{className:`text-sm ${n[f]?"text-red-500":"text-green-500"}`,children:n[f]?"✗":"✓"})]})}),o.jsx("td",{className:"py-2 pr-2 text-text-muted",children:"retry"}),o.jsx("td",{className:"py-2",children:o.jsx("button",{onClick:()=>l(f),title:"Remove pattern",className:"text-text-muted hover:text-red-500 transition-colors",children:"×"})})]},f))})]}),o.jsx(tt,{variant:"secondary",onClick:u,children:"Add Pattern"})]})}function aN({onClose:e}){const[,t]=cr(),{settings:n,getSetting:s,setSetting:a}=Hu(),l=n[ze.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",u=n[ze.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",[c,h]=R.useState({openInEditor:l,dynamicPrompt:u}),[f,p]=R.useState({patterns:[],maxRetriesPerTurn:10});R.useEffect(()=>{h({openInEditor:l,dynamicPrompt:u})},[l,u]),R.useEffect(()=>{s(ze.DISPLAY_SHOW_OPEN_IN_EDITOR),s(ze.LLM_DYNAMIC_SYSTEM_PROMPT),s(ze.RETRY_PATTERNS)},[s]),R.useEffect(()=>{const k=n[ze.RETRY_PATTERNS];if(k)try{p(JSON.parse(k))}catch{}},[n]);const m=R.useCallback(k=>{p(k),a(ze.RETRY_PATTERNS,JSON.stringify(k))},[a]),_=()=>{const k=!c.openInEditor;h(y=>({...y,openInEditor:k})),a(ze.DISPLAY_SHOW_OPEN_IN_EDITOR,String(k))},x=()=>{const k=!c.dynamicPrompt;h(y=>({...y,dynamicPrompt:k})),a(ze.LLM_DYNAMIC_SYSTEM_PROMPT,String(k))};function w(){e(),t("/onboarding")}return o.jsxs("div",{className:"space-y-6",children:[o.jsx(zv,{title:"Dynamic System Prompt",description:"Rebuild the system prompt on every turn. When disabled, changes are applied on demand via the context header for better cache performance.",enabled:c.dynamicPrompt,onToggle:x,boldTitle:!0}),o.jsx("hr",{className:"border-border"}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Auto-Retry Patterns"}),o.jsx("p",{className:"text-xs 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.'}),o.jsx(iN,{value:f,onChange:m})]}),o.jsx("hr",{className:"border-border"}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Integrations"}),o.jsx(zv,{title:'Show "Open in VSCode" links',description:"Display a link on file reads to open the file directly in VS Code.",enabled:c.openInEditor,onToggle:_})]}),o.jsx("hr",{className:"border-border"}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),o.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Reset your OpenFox setup and go through the initial configuration again."}),o.jsx(tt,{variant:"secondary",onClick:w,children:"Launch Onboarding"})]})]})}function zv({title:e,description:t,enabled:n,onToggle:s,boldTitle:a}){return o.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:`text-sm ${a?"font-medium":""} text-text-primary`,children:e}),o.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:t})]}),o.jsx("div",{className:"flex-shrink-0",children:o.jsx(rN,{enabled:n,onClick:s})})]})}function oN({label:e,binding:t,isRecording:n,onStartRecording:s,onBindingRecorded:a,onCancelRecording:l}){const u=R.useRef(null),c=R.useRef(0),h=R.useRef("");return R.useEffect(()=>{if(!n)return;const f=new Set(["Control","Shift","Alt","Meta"]);let p=[];const m=x=>{if(x.preventDefault(),x.stopPropagation(),x.key==="Escape"){l();return}if(f.has(x.key)){x.ctrlKey&&!p.includes("ctrl")&&p.push("ctrl"),x.metaKey&&!p.includes("meta")&&p.push("meta"),x.altKey&&!p.includes("alt")&&p.push("alt"),x.shiftKey&&!p.includes("shift")&&p.push("shift");return}if(p.length>0||x.ctrlKey||x.metaKey||x.altKey||x.shiftKey){const y=[...p];x.ctrlKey&&!y.includes("ctrl")&&y.push("ctrl"),x.metaKey&&!y.includes("meta")&&y.push("meta"),x.altKey&&!y.includes("alt")&&y.push("alt"),x.shiftKey&&!y.includes("shift")&&y.push("shift"),a({type:"chord",key:Mv(x),modifiers:y});return}const w=Date.now(),k=Mv(x);if(k===h.current&&w-c.current<400){a({type:"double-press",key:k,threshold:300});return}c.current=w,h.current=k},_=x=>{x.key==="Control"&&(p=p.filter(w=>w!=="ctrl")),x.key==="Shift"&&(p=p.filter(w=>w!=="shift")),x.key==="Alt"&&(p=p.filter(w=>w!=="alt")),x.key==="Meta"&&(p=p.filter(w=>w!=="meta"))};return window.addEventListener("keydown",m,!0),window.addEventListener("keyup",_,!0),()=>{window.removeEventListener("keydown",m,!0),window.removeEventListener("keyup",_,!0)}},[n,a,l]),o.jsxs("div",{ref:u,className:`flex items-center justify-between px-3 py-2 rounded transition-colors ${n?"bg-accent-primary/10 ring-1 ring-accent-primary":"hover:bg-bg-tertiary"}`,children:[o.jsx("span",{className:"text-sm text-text-primary",children:e}),o.jsx("div",{className:"flex items-center gap-2",children:n?o.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):o.jsx("button",{type:"button",onClick:s,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:yS(t)})})]})}function lN(){const{settings:e,loading:t,setSetting:n}=Hu(),s=e[ze.KEYBINDINGS],a=t[ze.KEYBINDINGS]??!1,l=wm(s),[u,c]=R.useState(null),h=[{id:"terminalToggle",label:"Toggle Terminal",binding:l.terminalToggle},{id:"quickAction",label:"Quick Action",binding:l.quickAction},...l.agentSwitching.map((_,x)=>({id:`agentSwitching.${x}`,label:`Switch to Agent ${x+1}`,binding:_}))],f=_=>{c(_)},p=R.useCallback(_=>{if(!u)return;const x=wm(s),w=structuredClone(x);if(u.startsWith("agentSwitching.")){const k=parseInt(u.split(".")[1],10);w.agentSwitching[k]=_}else u==="terminalToggle"?w.terminalToggle=_:u==="quickAction"&&(w.quickAction=_);c(null),n(ze.KEYBINDINGS,JSON.stringify(w))},[u,s,n]),m=()=>{n(ze.KEYBINDINGS,JSON.stringify(Aa))};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),o.jsx("button",{type:"button",onClick:m,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?o.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):o.jsx("div",{className:"space-y-1",children:h.map(_=>o.jsx(oN,{label:_.label,binding:_.binding,isRecording:u===_.id,onStartRecording:()=>f(_.id),onBindingRecorded:p,onCancelRecording:()=>c(null)},_.id))})]})}function cN({isOpen:e,onClose:t}){const[n,s]=R.useState("instructions"),a=()=>{try{zt.send("context.checkDynamic",{})}catch{}t()};return o.jsx(Dt,{isOpen:e,onClose:a,title:"Settings",size:"xl",minHeight:"500px",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex border-b border-border mb-4 -mt-1 overflow-x-auto scrollbar-hide",children:[o.jsx(Sa,{label:"Instructions",active:n==="instructions",onClick:()=>s("instructions")}),o.jsx(Sa,{label:"Skills",active:n==="skills",onClick:()=>s("skills")}),o.jsx(Sa,{label:"Notifications",active:n==="notifications",onClick:()=>s("notifications")}),o.jsx(Sa,{label:"Display",active:n==="display",onClick:()=>s("display")}),o.jsx(Sa,{label:"Keybindings",active:n==="keybindings",onClick:()=>s("keybindings")}),o.jsx(Sa,{label:"Advanced",active:n==="advanced",onClick:()=>s("advanced")})]}),n==="instructions"&&o.jsx(Qj,{isOpen:e}),n==="skills"&&o.jsx(Xj,{isOpen:e}),n==="notifications"&&o.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:o.jsx(qj,{})}),n==="display"&&o.jsx(nN,{}),n==="keybindings"&&o.jsx(lN,{}),n==="advanced"&&o.jsx(aN,{onClose:t})]})})}function Sa({label:e,active:t,onClick:n}){return o.jsx("button",{onClick:n,className:`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})}var Of={exports:{}},Hv;function uN(){return Hv||(Hv=1,(function(e,t){(function(n,s){e.exports=s()})(globalThis,(()=>(()=>{var n={4567:function(u,c,h){var f=this&&this.__decorate||function(v,b,E,T){var N,L=arguments.length,A=L<3?b:T===null?T=Object.getOwnPropertyDescriptor(b,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,b,E,T);else for(var D=v.length-1;D>=0;D--)(N=v[D])&&(A=(L<3?N(A):L>3?N(b,E,A):N(b,E))||A);return L>3&&A&&Object.defineProperty(b,E,A),A},p=this&&this.__param||function(v,b){return function(E,T){b(E,T,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.AccessibilityManager=void 0;const m=h(9042),_=h(9924),x=h(844),w=h(4725),k=h(2585),y=h(3656);let S=c.AccessibilityManager=class extends x.Disposable{constructor(v,b,E,T){super(),this._terminal=v,this._coreBrowserService=E,this._renderService=T,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 N=0;N<this._terminal.rows;N++)this._rowElements[N]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[N]);if(this._topBoundaryFocusListener=N=>this._handleBoundaryFocus(N,0),this._bottomBoundaryFocusListener=N=>this._handleBoundaryFocus(N,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 _.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((N=>this._handleResize(N.rows)))),this.register(this._terminal.onRender((N=>this._refreshRows(N.start,N.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((N=>this._handleChar(N)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
59
|
+
`)))),this.register(this._terminal.onA11yTab((N=>this._handleTab(N)))),this.register(this._terminal.onKey((N=>this._handleKey(N.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,y.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(v){for(let b=0;b<v;b++)this._handleChar(" ")}_handleChar(v){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==v&&(this._charsToAnnounce+=v):this._charsToAnnounce+=v,v===`
|
|
60
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=m.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(v){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(v)||this._charsToConsume.push(v)}_refreshRows(v,b){this._liveRegionDebouncer.refresh(v,b,this._terminal.rows)}_renderRows(v,b){const E=this._terminal.buffer,T=E.lines.length.toString();for(let N=v;N<=b;N++){const L=E.lines.get(E.ydisp+N),A=[],D=(L==null?void 0:L.translateToString(!0,void 0,void 0,A))||"",B=(E.ydisp+N+1).toString(),q=this._rowElements[N];q&&(D.length===0?(q.innerText=" ",this._rowColumns.set(q,[0,1])):(q.textContent=D,this._rowColumns.set(q,A)),q.setAttribute("aria-posinset",B),q.setAttribute("aria-setsize",T))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(v,b){const E=v.target,T=this._rowElements[b===0?1:this._rowElements.length-2];if(E.getAttribute("aria-posinset")===(b===0?"1":`${this._terminal.buffer.lines.length}`)||v.relatedTarget!==T)return;let N,L;if(b===0?(N=E,L=this._rowElements.pop(),this._rowContainer.removeChild(L)):(N=this._rowElements.shift(),L=E,this._rowContainer.removeChild(N)),N.removeEventListener("focus",this._topBoundaryFocusListener),L.removeEventListener("focus",this._bottomBoundaryFocusListener),b===0){const A=this._createAccessibilityTreeNode();this._rowElements.unshift(A),this._rowContainer.insertAdjacentElement("afterbegin",A)}else{const A=this._createAccessibilityTreeNode();this._rowElements.push(A),this._rowContainer.appendChild(A)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(b===0?-1:1),this._rowElements[b===0?1:this._rowElements.length-2].focus(),v.preventDefault(),v.stopImmediatePropagation()}_handleSelectionChange(){var D;if(this._rowElements.length===0)return;const v=document.getSelection();if(!v)return;if(v.isCollapsed)return void(this._rowContainer.contains(v.anchorNode)&&this._terminal.clearSelection());if(!v.anchorNode||!v.focusNode)return void console.error("anchorNode and/or focusNode are null");let b={node:v.anchorNode,offset:v.anchorOffset},E={node:v.focusNode,offset:v.focusOffset};if((b.node.compareDocumentPosition(E.node)&Node.DOCUMENT_POSITION_PRECEDING||b.node===E.node&&b.offset>E.offset)&&([b,E]=[E,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 T=this._rowElements.slice(-1)[0];if(E.node.compareDocumentPosition(T)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(E={node:T,offset:((D=T.textContent)==null?void 0:D.length)??0}),!this._rowContainer.contains(E.node))return;const N=({node:B,offset:q})=>{const W=B instanceof Text?B.parentNode:B;let O=parseInt(W==null?void 0:W.getAttribute("aria-posinset"),10)-1;if(isNaN(O))return console.warn("row is invalid. Race condition?"),null;const V=this._rowColumns.get(W);if(!V)return console.warn("columns is null. Race condition?"),null;let G=q<V.length?V[q]:V.slice(-1)[0]+1;return G>=this._terminal.cols&&(++O,G=0),{row:O,column:G}},L=N(b),A=N(E);if(L&&A){if(L.row>A.row||L.row===A.row&&L.column>=A.column)throw new Error("invalid range");this._terminal.select(L.column,L.row,(A.row-L.row)*this._terminal.cols-L.column+A.column)}}_handleResize(v){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>v;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const v=this._coreBrowserService.mainDocument.createElement("div");return v.setAttribute("role","listitem"),v.tabIndex=-1,this._refreshRowDimensions(v),v}_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 v=0;v<this._terminal.rows;v++)this._refreshRowDimensions(this._rowElements[v])}}_refreshRowDimensions(v){v.style.height=`${this._renderService.dimensions.css.cell.height}px`}};c.AccessibilityManager=S=f([p(1,k.IInstantiationService),p(2,w.ICoreBrowserService),p(3,w.IRenderService)],S)},3614:(u,c)=>{function h(_){return _.replace(/\r?\n/g,"\r")}function f(_,x){return x?"\x1B[200~"+_+"\x1B[201~":_}function p(_,x,w,k){_=f(_=h(_),w.decPrivateModes.bracketedPasteMode&&k.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(_,!0),x.value=""}function m(_,x,w){const k=w.getBoundingClientRect(),y=_.clientX-k.left-10,S=_.clientY-k.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${y}px`,x.style.top=`${S}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(c,"__esModule",{value:!0}),c.rightClickHandler=c.moveTextAreaUnderMouseCursor=c.paste=c.handlePasteEvent=c.copyHandler=c.bracketTextForPaste=c.prepareTextForTerminal=void 0,c.prepareTextForTerminal=h,c.bracketTextForPaste=f,c.copyHandler=function(_,x){_.clipboardData&&_.clipboardData.setData("text/plain",x.selectionText),_.preventDefault()},c.handlePasteEvent=function(_,x,w,k){_.stopPropagation(),_.clipboardData&&p(_.clipboardData.getData("text/plain"),x,w,k)},c.paste=p,c.moveTextAreaUnderMouseCursor=m,c.rightClickHandler=function(_,x,w,k,y){m(_,x,w),y&&k.rightClickSelect(_),x.value=k.selectionText,x.select()}},7239:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorContrastCache=void 0;const f=h(1505);c.ColorContrastCache=class{constructor(){this._color=new f.TwoKeyMap,this._css=new f.TwoKeyMap}setCss(p,m,_){this._css.set(p,m,_)}getCss(p,m){return this._css.get(p,m)}setColor(p,m,_){this._color.set(p,m,_)}getColor(p,m){return this._color.get(p,m)}clear(){this._color.clear(),this._css.clear()}}},3656:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.addDisposableDomListener=void 0,c.addDisposableDomListener=function(h,f,p,m){h.addEventListener(f,p,m);let _=!1;return{dispose:()=>{_||(_=!0,h.removeEventListener(f,p,m))}}}},3551:function(u,c,h){var f=this&&this.__decorate||function(S,v,b,E){var T,N=arguments.length,L=N<3?v:E===null?E=Object.getOwnPropertyDescriptor(v,b):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(S,v,b,E);else for(var A=S.length-1;A>=0;A--)(T=S[A])&&(L=(N<3?T(L):N>3?T(v,b,L):T(v,b))||L);return N>3&&L&&Object.defineProperty(v,b,L),L},p=this&&this.__param||function(S,v){return function(b,E){v(b,E,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Linkifier=void 0;const m=h(3656),_=h(8460),x=h(844),w=h(2585),k=h(4725);let y=c.Linkifier=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(S,v,b,E,T){super(),this._element=S,this._mouseService=v,this._renderService=b,this._bufferService=E,this._linkProviderService=T,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new _.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new _.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{var N;this._lastMouseEvent=void 0,(N=this._activeProviderReplies)==null||N.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 v=this._positionFromMouseEvent(S,this._element,this._mouseService);if(!v)return;this._isMouseOut=!1;const b=S.composedPath();for(let E=0;E<b.length;E++){const T=b[E];if(T.classList.contains("xterm"))break;if(T.classList.contains("xterm-hover"))return}this._lastBufferCell&&v.x===this._lastBufferCell.x&&v.y===this._lastBufferCell.y||(this._handleHover(v),this._lastBufferCell=v)}_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,v){var E,T;this._activeProviderReplies&&v||((E=this._activeProviderReplies)==null||E.forEach((N=>{N==null||N.forEach((L=>{L.link.dispose&&L.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=S.y);let b=!1;for(const[N,L]of this._linkProviderService.linkProviders.entries())v?(T=this._activeProviderReplies)!=null&&T.get(N)&&(b=this._checkLinkProviderResult(N,S,b)):L.provideLinks(S.y,(A=>{var B,q;if(this._isMouseOut)return;const D=A==null?void 0:A.map((W=>({link:W})));(B=this._activeProviderReplies)==null||B.set(N,D),b=this._checkLinkProviderResult(N,S,b),((q=this._activeProviderReplies)==null?void 0:q.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(S.y,this._activeProviderReplies)}))}_removeIntersectingLinks(S,v){const b=new Set;for(let E=0;E<v.size;E++){const T=v.get(E);if(T)for(let N=0;N<T.length;N++){const L=T[N],A=L.link.range.start.y<S?0:L.link.range.start.x,D=L.link.range.end.y>S?this._bufferService.cols:L.link.range.end.x;for(let B=A;B<=D;B++){if(b.has(B)){T.splice(N--,1);break}b.add(B)}}}}_checkLinkProviderResult(S,v,b){var N;if(!this._activeProviderReplies)return b;const E=this._activeProviderReplies.get(S);let T=!1;for(let L=0;L<S;L++)this._activeProviderReplies.has(L)&&!this._activeProviderReplies.get(L)||(T=!0);if(!T&&E){const L=E.find((A=>this._linkAtPosition(A.link,v)));L&&(b=!0,this._handleNewLink(L))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!b)for(let L=0;L<this._activeProviderReplies.size;L++){const A=(N=this._activeProviderReplies.get(L))==null?void 0:N.find((D=>this._linkAtPosition(D.link,v)));if(A){b=!0,this._handleNewLink(A);break}}return b}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(S){if(!this._currentLink)return;const v=this._positionFromMouseEvent(S,this._element,this._mouseService);v&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,v)&&this._currentLink.link.activate(S,this._currentLink.link.text)}_clearCurrentLink(S,v){this._currentLink&&this._lastMouseEvent&&(!S||!v||this._currentLink.link.range.start.y>=S&&this._currentLink.link.range.end.y<=v)&&(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 v=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);v&&this._linkAtPosition(S.link,v)&&(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,E;return(E=(b=this._currentLink)==null?void 0:b.state)==null?void 0:E.decorations.pointerCursor},set:b=>{var E;(E=this._currentLink)!=null&&E.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,E;return(E=(b=this._currentLink)==null?void 0:b.state)==null?void 0:E.decorations.underline},set:b=>{var E,T,N;(E=this._currentLink)!=null&&E.state&&((N=(T=this._currentLink)==null?void 0:T.state)==null?void 0:N.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 E=b.start===0?0:b.start+1+this._bufferService.buffer.ydisp,T=this._bufferService.buffer.ydisp+1+b.end;if(this._currentLink.link.range.start.y>=E&&this._currentLink.link.range.end.y<=T&&(this._clearCurrentLink(E,T),this._lastMouseEvent)){const N=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);N&&this._askForLink(N,!1)}}))))}_linkHover(S,v,b){var E;(E=this._currentLink)!=null&&E.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!0),this._currentLink.state.decorations.pointerCursor&&S.classList.add("xterm-cursor-pointer")),v.hover&&v.hover(b,v.text)}_fireUnderlineEvent(S,v){const b=S.range,E=this._bufferService.buffer.ydisp,T=this._createLinkUnderlineEvent(b.start.x-1,b.start.y-E-1,b.end.x,b.end.y-E-1,void 0);(v?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(T)}_linkLeave(S,v,b){var E;(E=this._currentLink)!=null&&E.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!1),this._currentLink.state.decorations.pointerCursor&&S.classList.remove("xterm-cursor-pointer")),v.leave&&v.leave(b,v.text)}_linkAtPosition(S,v){const b=S.range.start.y*this._bufferService.cols+S.range.start.x,E=S.range.end.y*this._bufferService.cols+S.range.end.x,T=v.y*this._bufferService.cols+v.x;return b<=T&&T<=E}_positionFromMouseEvent(S,v,b){const E=b.getCoords(S,v,this._bufferService.cols,this._bufferService.rows);if(E)return{x:E[0],y:E[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(S,v,b,E,T){return{x1:S,y1:v,x2:b,y2:E,cols:this._bufferService.cols,fg:T}}};c.Linkifier=y=f([p(1,k.IMouseService),p(2,k.IRenderService),p(3,w.IBufferService),p(4,k.ILinkProviderService)],y)},9042:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.tooMuchOutput=c.promptLabel=void 0,c.promptLabel="Terminal input",c.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(u,c,h){var f=this&&this.__decorate||function(k,y,S,v){var b,E=arguments.length,T=E<3?y:v===null?v=Object.getOwnPropertyDescriptor(y,S):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,y,S,v);else for(var N=k.length-1;N>=0;N--)(b=k[N])&&(T=(E<3?b(T):E>3?b(y,S,T):b(y,S))||T);return E>3&&T&&Object.defineProperty(y,S,T),T},p=this&&this.__param||function(k,y){return function(S,v){y(S,v,k)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkProvider=void 0;const m=h(511),_=h(2585);let x=c.OscLinkProvider=class{constructor(k,y,S){this._bufferService=k,this._optionsService=y,this._oscLinkService=S}provideLinks(k,y){var D;const S=this._bufferService.buffer.lines.get(k-1);if(!S)return void y(void 0);const v=[],b=this._optionsService.rawOptions.linkHandler,E=new m.CellData,T=S.getTrimmedLength();let N=-1,L=-1,A=!1;for(let B=0;B<T;B++)if(L!==-1||S.hasContent(B)){if(S.loadCell(B,E),E.hasExtendedAttrs()&&E.extended.urlId){if(L===-1){L=B,N=E.extended.urlId;continue}A=E.extended.urlId!==N}else L!==-1&&(A=!0);if(A||L!==-1&&B===T-1){const q=(D=this._oscLinkService.getLinkData(N))==null?void 0:D.uri;if(q){const W={start:{x:L+1,y:k},end:{x:B+(A||B!==T-1?0:1),y:k}};let O=!1;if(!(b!=null&&b.allowNonHttpProtocols))try{const V=new URL(q);["http:","https:"].includes(V.protocol)||(O=!0)}catch{O=!0}O||v.push({text:q,range:W,activate:(V,G)=>b?b.activate(V,G,W):w(0,G),hover:(V,G)=>{var z;return(z=b==null?void 0:b.hover)==null?void 0:z.call(b,V,G,W)},leave:(V,G)=>{var z;return(z=b==null?void 0:b.leave)==null?void 0:z.call(b,V,G,W)}})}A=!1,E.hasExtendedAttrs()&&E.extended.urlId?(L=B,N=E.extended.urlId):(L=-1,N=-1)}}y(v)}};function w(k,y){if(confirm(`Do you want to navigate to ${y}?
|
|
61
|
+
|
|
62
|
+
WARNING: This link could potentially be dangerous`)){const S=window.open();if(S){try{S.opener=null}catch{}S.location.href=y}else console.warn("Opening link blocked as opener could not be cleared")}}c.OscLinkProvider=x=f([p(0,_.IBufferService),p(1,_.IOptionsService),p(2,_.IOscLinkService)],x)},6193:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.RenderDebouncer=void 0,c.RenderDebouncer=class{constructor(h,f){this._renderCallback=h,this._coreBrowserService=f,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(h){return this._refreshCallbacks.push(h),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(h,f,p){this._rowCount=p,h=h!==void 0?h:0,f=f!==void 0?f:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,h):h,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,f):f,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 h=Math.max(this._rowStart,0),f=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(h,f),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const h of this._refreshCallbacks)h(0);this._refreshCallbacks=[]}}},3236:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Terminal=void 0;const f=h(3614),p=h(3656),m=h(3551),_=h(9042),x=h(3730),w=h(1680),k=h(3107),y=h(5744),S=h(2950),v=h(1296),b=h(428),E=h(4269),T=h(5114),N=h(8934),L=h(3230),A=h(9312),D=h(4725),B=h(6731),q=h(8055),W=h(8969),O=h(8460),V=h(844),G=h(6114),z=h(8437),X=h(2584),ne=h(7399),F=h(5941),M=h(9074),$=h(2585),P=h(5435),U=h(4567),J=h(779);class Q extends W.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(Y={}){super(Y),this.browser=G,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new V.MutableDisposable),this._onCursorMove=this.register(new O.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new O.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new O.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new O.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new O.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new O.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new O.EventEmitter),this._onBlur=this.register(new O.EventEmitter),this._onA11yCharEmitter=this.register(new O.EventEmitter),this._onA11yTabEmitter=this.register(new O.EventEmitter),this._onWillOpen=this.register(new O.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(M.DecorationService),this._instantiationService.setService($.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(J.LinkProviderService),this._instantiationService.setService(D.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((H,ee)=>this.refresh(H,ee)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((H=>this._reportWindowsOptions(H)))),this.register(this._inputHandler.onColor((H=>this._handleColorEvent(H)))),this.register((0,O.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,O.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,O.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,O.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((H=>this._afterResize(H.cols,H.rows)))),this.register((0,V.toDisposable)((()=>{var H,ee;this._customKeyEventHandler=void 0,(ee=(H=this.element)==null?void 0:H.parentNode)==null||ee.removeChild(this.element)})))}_handleColorEvent(Y){if(this._themeService)for(const H of Y){let ee,te="";switch(H.index){case 256:ee="foreground",te="10";break;case 257:ee="background",te="11";break;case 258:ee="cursor",te="12";break;default:ee="ansi",te="4;"+H.index}switch(H.type){case 0:const ce=q.color.toColorRGB(ee==="ansi"?this._themeService.colors.ansi[H.index]:this._themeService.colors[ee]);this.coreService.triggerDataEvent(`${X.C0.ESC}]${te};${(0,F.toRgbString)(ce)}${X.C1_ESCAPED.ST}`);break;case 1:if(ee==="ansi")this._themeService.modifyColors((he=>he.ansi[H.index]=q.channels.toColor(...H.color)));else{const he=ee;this._themeService.modifyColors((Te=>Te[he]=q.channels.toColor(...H.color)))}break;case 2:this._themeService.restoreColor(H.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(Y){Y?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(U.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(Y){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(X.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var Y;return(Y=this.textarea)==null?void 0:Y.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(X.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const Y=this.buffer.ybase+this.buffer.y,H=this.buffer.lines.get(Y);if(!H)return;const ee=Math.min(this.buffer.x,this.cols-1),te=this._renderService.dimensions.css.cell.height,ce=H.getWidth(ee),he=this._renderService.dimensions.css.cell.width*ce,Te=this.buffer.y*this._renderService.dimensions.css.cell.height,Ae=ee*this._renderService.dimensions.css.cell.width;this.textarea.style.left=Ae+"px",this.textarea.style.top=Te+"px",this.textarea.style.width=he+"px",this.textarea.style.height=te+"px",this.textarea.style.lineHeight=te+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,p.addDisposableDomListener)(this.element,"copy",(H=>{this.hasSelection()&&(0,f.copyHandler)(H,this._selectionService)})));const Y=H=>(0,f.handlePasteEvent)(H,this.textarea,this.coreService,this.optionsService);this.register((0,p.addDisposableDomListener)(this.textarea,"paste",Y)),this.register((0,p.addDisposableDomListener)(this.element,"paste",Y)),G.isFirefox?this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(H=>{H.button===2&&(0,f.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,p.addDisposableDomListener)(this.element,"contextmenu",(H=>{(0,f.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),G.isLinux&&this.register((0,p.addDisposableDomListener)(this.element,"auxclick",(H=>{H.button===1&&(0,f.moveTextAreaUnderMouseCursor)(H,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,p.addDisposableDomListener)(this.textarea,"keyup",(Y=>this._keyUp(Y)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keydown",(Y=>this._keyDown(Y)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keypress",(Y=>this._keyPress(Y)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionupdate",(Y=>this._compositionHelper.compositionupdate(Y)))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,p.addDisposableDomListener)(this.textarea,"input",(Y=>this._inputEvent(Y)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(Y){var ee;if(!Y)throw new Error("Terminal requires a parent element.");if(Y.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((ee=this.element)==null?void 0:ee.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=Y.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),Y.appendChild(this.element);const H=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),H.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",(te=>this.updateCursorStyle(te)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),H.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",_.promptLabel),G.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(T.CoreBrowserService,this.textarea,Y.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(D.ICoreBrowserService,this._coreBrowserService),this.register((0,p.addDisposableDomListener)(this.textarea,"focus",(te=>this._handleTextAreaFocus(te)))),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(D.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(B.ThemeService),this._instantiationService.setService(D.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(E.CharacterJoinerService),this._instantiationService.setService(D.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(L.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(D.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((te=>this._onRender.fire(te)))),this.onResize((te=>this._renderService.resize(te.cols,te.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(N.MouseService),this._instantiationService.setService(D.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(m.Linkifier,this.screenElement)),this.element.appendChild(H);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((te=>this.scrollLines(te.amount,te.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(D.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((te=>this.scrollLines(te.amount,te.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((te=>this._renderService.handleSelectionChanged(te.start,te.end,te.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((te=>{this.textarea.value=te,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((te=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,p.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(k.BufferDecorationRenderer,this.screenElement)),this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(te=>this._selectionService.handleMouseDown(te)))),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(U.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(te=>this._handleScreenReaderModeOptionChange(te)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(y.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(te=>{!this._overviewRulerRenderer&&te&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(y.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(v.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const Y=this,H=this.element;function ee(he){const Te=Y._mouseService.getMouseReportCoords(he,Y.screenElement);if(!Te)return!1;let Ae,Le;switch(he.overrideType||he.type){case"mousemove":Le=32,he.buttons===void 0?(Ae=3,he.button!==void 0&&(Ae=he.button<3?he.button:3)):Ae=1&he.buttons?0:4&he.buttons?1:2&he.buttons?2:3;break;case"mouseup":Le=0,Ae=he.button<3?he.button:3;break;case"mousedown":Le=1,Ae=he.button<3?he.button:3;break;case"wheel":if(Y._customWheelEventHandler&&Y._customWheelEventHandler(he)===!1||Y.viewport.getLinesScrolled(he)===0)return!1;Le=he.deltaY<0?0:1,Ae=4;break;default:return!1}return!(Le===void 0||Ae===void 0||Ae>4)&&Y.coreMouseService.triggerMouseEvent({col:Te.col,row:Te.row,x:Te.x,y:Te.y,button:Ae,action:Le,ctrl:he.ctrlKey,alt:he.altKey,shift:he.shiftKey})}const te={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ce={mouseup:he=>(ee(he),he.buttons||(this._document.removeEventListener("mouseup",te.mouseup),te.mousedrag&&this._document.removeEventListener("mousemove",te.mousedrag)),this.cancel(he)),wheel:he=>(ee(he),this.cancel(he,!0)),mousedrag:he=>{he.buttons&&ee(he)},mousemove:he=>{he.buttons||ee(he)}};this.register(this.coreMouseService.onProtocolChange((he=>{he?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(he)),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&he?te.mousemove||(H.addEventListener("mousemove",ce.mousemove),te.mousemove=ce.mousemove):(H.removeEventListener("mousemove",te.mousemove),te.mousemove=null),16&he?te.wheel||(H.addEventListener("wheel",ce.wheel,{passive:!1}),te.wheel=ce.wheel):(H.removeEventListener("wheel",te.wheel),te.wheel=null),2&he?te.mouseup||(te.mouseup=ce.mouseup):(this._document.removeEventListener("mouseup",te.mouseup),te.mouseup=null),4&he?te.mousedrag||(te.mousedrag=ce.mousedrag):(this._document.removeEventListener("mousemove",te.mousedrag),te.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,p.addDisposableDomListener)(H,"mousedown",(he=>{if(he.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(he))return ee(he),te.mouseup&&this._document.addEventListener("mouseup",te.mouseup),te.mousedrag&&this._document.addEventListener("mousemove",te.mousedrag),this.cancel(he)}))),this.register((0,p.addDisposableDomListener)(H,"wheel",(he=>{if(!te.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(he)===!1)return!1;if(!this.buffer.hasScrollback){const Te=this.viewport.getLinesScrolled(he);if(Te===0)return;const Ae=X.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(he.deltaY<0?"A":"B");let Le="";for(let Pe=0;Pe<Math.abs(Te);Pe++)Le+=Ae;return this.coreService.triggerDataEvent(Le,!0),this.cancel(he,!0)}return this.viewport.handleWheel(he)?this.cancel(he):void 0}}),{passive:!1})),this.register((0,p.addDisposableDomListener)(H,"touchstart",(he=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(he),this.cancel(he)}),{passive:!0})),this.register((0,p.addDisposableDomListener)(H,"touchmove",(he=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(he)?void 0:this.cancel(he)}),{passive:!1}))}refresh(Y,H){var ee;(ee=this._renderService)==null||ee.refreshRows(Y,H)}updateCursorStyle(Y){var H;(H=this._selectionService)!=null&&H.shouldColumnSelect(Y)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(Y,H,ee=0){var te;ee===1?(super.scrollLines(Y,H,ee),this.refresh(0,this.rows-1)):(te=this.viewport)==null||te.scrollLines(Y)}paste(Y){(0,f.paste)(Y,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(Y){this._customKeyEventHandler=Y}attachCustomWheelEventHandler(Y){this._customWheelEventHandler=Y}registerLinkProvider(Y){return this._linkProviderService.registerLinkProvider(Y)}registerCharacterJoiner(Y){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const H=this._characterJoinerService.register(Y);return this.refresh(0,this.rows-1),H}deregisterCharacterJoiner(Y){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(Y)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(Y){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+Y)}registerDecoration(Y){return this._decorationService.registerDecoration(Y)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(Y,H,ee){this._selectionService.setSelection(Y,H,ee)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var Y;(Y=this._selectionService)==null||Y.clearSelection()}selectAll(){var Y;(Y=this._selectionService)==null||Y.selectAll()}selectLines(Y,H){var ee;(ee=this._selectionService)==null||ee.selectLines(Y,H)}_keyDown(Y){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(Y)===!1)return!1;const H=this.browser.isMac&&this.options.macOptionIsMeta&&Y.altKey;if(!H&&!this._compositionHelper.keydown(Y))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;H||Y.key!=="Dead"&&Y.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const ee=(0,ne.evaluateKeyboardEvent)(Y,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(Y),ee.type===3||ee.type===2){const te=this.rows-1;return this.scrollLines(ee.type===2?-te:te),this.cancel(Y,!0)}return ee.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,Y)||(ee.cancel&&this.cancel(Y,!0),!ee.key||!!(Y.key&&!Y.ctrlKey&&!Y.altKey&&!Y.metaKey&&Y.key.length===1&&Y.key.charCodeAt(0)>=65&&Y.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(ee.key!==X.C0.ETX&&ee.key!==X.C0.CR||(this.textarea.value=""),this._onKey.fire({key:ee.key,domEvent:Y}),this._showCursor(),this.coreService.triggerDataEvent(ee.key,!0),!this.optionsService.rawOptions.screenReaderMode||Y.altKey||Y.ctrlKey?this.cancel(Y,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(Y,H){const ee=Y.isMac&&!this.options.macOptionIsMeta&&H.altKey&&!H.ctrlKey&&!H.metaKey||Y.isWindows&&H.altKey&&H.ctrlKey&&!H.metaKey||Y.isWindows&&H.getModifierState("AltGraph");return H.type==="keypress"?ee:ee&&(!H.keyCode||H.keyCode>47)}_keyUp(Y){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(Y)===!1||((function(H){return H.keyCode===16||H.keyCode===17||H.keyCode===18})(Y)||this.focus(),this.updateCursorStyle(Y),this._keyPressHandled=!1)}_keyPress(Y){let H;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(Y)===!1)return!1;if(this.cancel(Y),Y.charCode)H=Y.charCode;else if(Y.which===null||Y.which===void 0)H=Y.keyCode;else{if(Y.which===0||Y.charCode===0)return!1;H=Y.which}return!(!H||(Y.altKey||Y.ctrlKey||Y.metaKey)&&!this._isThirdLevelShift(this.browser,Y)||(H=String.fromCharCode(H),this._onKey.fire({key:H,domEvent:Y}),this._showCursor(),this.coreService.triggerDataEvent(H,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(Y){if(Y.data&&Y.inputType==="insertText"&&(!Y.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const H=Y.data;return this.coreService.triggerDataEvent(H,!0),this.cancel(Y),!0}return!1}resize(Y,H){Y!==this.cols||H!==this.rows?super.resize(Y,H):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(Y,H){var ee,te;(ee=this._charSizeService)==null||ee.measure(),(te=this.viewport)==null||te.syncScrollArea(!0)}clear(){var Y;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let H=1;H<this.rows;H++)this.buffer.lines.push(this.buffer.getBlankLine(z.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(Y=this.viewport)==null||Y.reset(),this.refresh(0,this.rows-1)}}reset(){var H,ee;this.options.rows=this.rows,this.options.cols=this.cols;const Y=this._customKeyEventHandler;this._setup(),super.reset(),(H=this._selectionService)==null||H.reset(),this._decorationService.reset(),(ee=this.viewport)==null||ee.reset(),this._customKeyEventHandler=Y,this.refresh(0,this.rows-1)}clearTextureAtlas(){var Y;(Y=this._renderService)==null||Y.clearTextureAtlas()}_reportFocus(){var Y;(Y=this.element)!=null&&Y.classList.contains("focus")?this.coreService.triggerDataEvent(X.C0.ESC+"[I"):this.coreService.triggerDataEvent(X.C0.ESC+"[O")}_reportWindowsOptions(Y){if(this._renderService)switch(Y){case P.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const H=this._renderService.dimensions.css.canvas.width.toFixed(0),ee=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${X.C0.ESC}[4;${ee};${H}t`);break;case P.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const te=this._renderService.dimensions.css.cell.width.toFixed(0),ce=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${X.C0.ESC}[6;${ce};${te}t`)}}cancel(Y,H){if(this.options.cancelEvents||H)return Y.preventDefault(),Y.stopPropagation(),!1}}c.Terminal=Q},9924:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TimeBasedDebouncer=void 0,c.TimeBasedDebouncer=class{constructor(h,f=1e3){this._renderCallback=h,this._debounceThresholdMS=f,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(h,f,p){this._rowCount=p,h=h!==void 0?h:0,f=f!==void 0?f:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,h):h,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,f):f;const m=Date.now();if(m-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=m,this._innerRefresh();else if(!this._additionalRefreshRequested){const _=m-this._lastRefreshMs,x=this._debounceThresholdMS-_;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 h=Math.max(this._rowStart,0),f=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(h,f)}}},1680:function(u,c,h){var f=this&&this.__decorate||function(S,v,b,E){var T,N=arguments.length,L=N<3?v:E===null?E=Object.getOwnPropertyDescriptor(v,b):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(S,v,b,E);else for(var A=S.length-1;A>=0;A--)(T=S[A])&&(L=(N<3?T(L):N>3?T(v,b,L):T(v,b))||L);return N>3&&L&&Object.defineProperty(v,b,L),L},p=this&&this.__param||function(S,v){return function(b,E){v(b,E,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Viewport=void 0;const m=h(3656),_=h(4725),x=h(8460),w=h(844),k=h(2585);let y=c.Viewport=class extends w.Disposable{constructor(S,v,b,E,T,N,L,A){super(),this._viewportElement=S,this._scrollArea=v,this._bufferService=b,this._optionsService=E,this._charSizeService=T,this._renderService=N,this._coreBrowserService=L,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,m.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((D=>this._activeBuffer=D.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((D=>this._renderDimensions=D))),this._handleThemeChange(A.colors),this.register(A.onChangeColors((D=>this._handleThemeChange(D)))),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 v=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==v&&(this._lastRecordedBufferHeight=v,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 v=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:v,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,v){const b=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(v<0&&this._viewportElement.scrollTop!==0||v>0&&b<this._lastRecordedBufferHeight)||(S.cancelable&&S.preventDefault(),!1)}handleWheel(S){const v=this._getPixelsScrolled(S);return v!==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+v:this._smoothScrollState.target+=v,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=v,this._bubbleScroll(S,v))}scrollLines(S){if(S!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const v=S*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+v,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 v=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_LINE?v*=this._currentRowHeight:S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(v*=this._currentRowHeight*this._bufferService.rows),v}getBufferElements(S,v){var A;let b,E="";const T=[],N=v??this._bufferService.buffer.lines.length,L=this._bufferService.buffer.lines;for(let D=S;D<N;D++){const B=L.get(D);if(!B)continue;const q=(A=L.get(D+1))==null?void 0:A.isWrapped;if(E+=B.translateToString(!q),!q||D===L.length-1){const W=document.createElement("div");W.textContent=E,T.push(W),E.length>0&&(b=W),E=""}}return{bufferElements:T,cursorElement:b}}getLinesScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let v=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(v/=this._currentRowHeight+0,this._wheelPartialScroll+=v,v=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(v*=this._bufferService.rows),v}_applyScrollModifier(S,v){const b=this._optionsService.rawOptions.fastScrollModifier;return b==="alt"&&v.altKey||b==="ctrl"&&v.ctrlKey||b==="shift"&&v.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 v=this._lastTouchY-S.touches[0].pageY;return this._lastTouchY=S.touches[0].pageY,v!==0&&(this._viewportElement.scrollTop+=v,this._bubbleScroll(S,v))}};c.Viewport=y=f([p(2,k.IBufferService),p(3,k.IOptionsService),p(4,_.ICharSizeService),p(5,_.IRenderService),p(6,_.ICoreBrowserService),p(7,_.IThemeService)],y)},3107:function(u,c,h){var f=this&&this.__decorate||function(k,y,S,v){var b,E=arguments.length,T=E<3?y:v===null?v=Object.getOwnPropertyDescriptor(y,S):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,y,S,v);else for(var N=k.length-1;N>=0;N--)(b=k[N])&&(T=(E<3?b(T):E>3?b(y,S,T):b(y,S))||T);return E>3&&T&&Object.defineProperty(y,S,T),T},p=this&&this.__param||function(k,y){return function(S,v){y(S,v,k)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferDecorationRenderer=void 0;const m=h(4725),_=h(844),x=h(2585);let w=c.BufferDecorationRenderer=class extends _.Disposable{constructor(k,y,S,v,b){super(),this._screenElement=k,this._bufferService=y,this._coreBrowserService=S,this._decorationService=v,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((E=>this._removeDecoration(E)))),this.register((0,_.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 k of this._decorationService.decorations)this._renderDecoration(k);this._dimensionsChanged=!1}_renderDecoration(k){this._refreshStyle(k),this._dimensionsChanged&&this._refreshXPosition(k)}_createElement(k){var v;const y=this._coreBrowserService.mainDocument.createElement("div");y.classList.add("xterm-decoration"),y.classList.toggle("xterm-decoration-top-layer",((v=k==null?void 0:k.options)==null?void 0:v.layer)==="top"),y.style.width=`${Math.round((k.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,y.style.height=(k.options.height||1)*this._renderService.dimensions.css.cell.height+"px",y.style.top=(k.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",y.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const S=k.options.x??0;return S&&S>this._bufferService.cols&&(y.style.display="none"),this._refreshXPosition(k,y),y}_refreshStyle(k){const y=k.marker.line-this._bufferService.buffers.active.ydisp;if(y<0||y>=this._bufferService.rows)k.element&&(k.element.style.display="none",k.onRenderEmitter.fire(k.element));else{let S=this._decorationElements.get(k);S||(S=this._createElement(k),k.element=S,this._decorationElements.set(k,S),this._container.appendChild(S),k.onDispose((()=>{this._decorationElements.delete(k),S.remove()}))),S.style.top=y*this._renderService.dimensions.css.cell.height+"px",S.style.display=this._altBufferIsActive?"none":"block",k.onRenderEmitter.fire(S)}}_refreshXPosition(k,y=k.element){if(!y)return;const S=k.options.x??0;(k.options.anchor||"left")==="right"?y.style.right=S?S*this._renderService.dimensions.css.cell.width+"px":"":y.style.left=S?S*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(k){var y;(y=this._decorationElements.get(k))==null||y.remove(),this._decorationElements.delete(k),k.dispose()}};c.BufferDecorationRenderer=w=f([p(1,x.IBufferService),p(2,m.ICoreBrowserService),p(3,x.IDecorationService),p(4,m.IRenderService)],w)},5871:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorZoneStore=void 0,c.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(h){if(h.options.overviewRulerOptions){for(const f of this._zones)if(f.color===h.options.overviewRulerOptions.color&&f.position===h.options.overviewRulerOptions.position){if(this._lineIntersectsZone(f,h.marker.line))return;if(this._lineAdjacentToZone(f,h.marker.line,h.options.overviewRulerOptions.position))return void this._addLineToZone(f,h.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=h.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=h.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=h.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=h.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:h.options.overviewRulerOptions.color,position:h.options.overviewRulerOptions.position,startBufferLine:h.marker.line,endBufferLine:h.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(h){this._linePadding=h}_lineIntersectsZone(h,f){return f>=h.startBufferLine&&f<=h.endBufferLine}_lineAdjacentToZone(h,f,p){return f>=h.startBufferLine-this._linePadding[p||"full"]&&f<=h.endBufferLine+this._linePadding[p||"full"]}_addLineToZone(h,f){h.startBufferLine=Math.min(h.startBufferLine,f),h.endBufferLine=Math.max(h.endBufferLine,f)}}},5744:function(u,c,h){var f=this&&this.__decorate||function(b,E,T,N){var L,A=arguments.length,D=A<3?E:N===null?N=Object.getOwnPropertyDescriptor(E,T):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(b,E,T,N);else for(var B=b.length-1;B>=0;B--)(L=b[B])&&(D=(A<3?L(D):A>3?L(E,T,D):L(E,T))||D);return A>3&&D&&Object.defineProperty(E,T,D),D},p=this&&this.__param||function(b,E){return function(T,N){E(T,N,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OverviewRulerRenderer=void 0;const m=h(5871),_=h(4725),x=h(844),w=h(2585),k={full:0,left:0,center:0,right:0},y={full:0,left:0,center:0,right:0},S={full:0,left:0,center:0,right:0};let v=c.OverviewRulerRenderer=class extends x.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(b,E,T,N,L,A,D){var q;super(),this._viewportElement=b,this._screenElement=E,this._bufferService=T,this._decorationService=N,this._renderService=L,this._optionsService=A,this._coreBrowserService=D,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(),(q=this._viewportElement.parentElement)==null||q.insertBefore(this._canvas,this._viewportElement);const B=this._canvas.getContext("2d");if(!B)throw new Error("Ctx cannot be null");this._ctx=B,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,x.toDisposable)((()=>{var W;(W=this._canvas)==null||W.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),E=Math.ceil(this._canvas.width/3);y.full=this._canvas.width,y.left=b,y.center=E,y.right=b,this._refreshDrawHeightConstants(),S.full=0,S.left=0,S.center=y.left,S.right=y.left+y.center}_refreshDrawHeightConstants(){k.full=Math.round(2*this._coreBrowserService.dpr);const b=this._canvas.height/this._bufferService.buffer.lines.length,E=Math.round(Math.max(Math.min(b,12),6)*this._coreBrowserService.dpr);k.left=E,k.center=E,k.right=E}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*k.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*k.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*k.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*k.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 E of this._decorationService.decorations)this._colorZoneStore.addDecoration(E);this._ctx.lineWidth=1;const b=this._colorZoneStore.zones;for(const E of b)E.position!=="full"&&this._renderColorZone(E);for(const E of b)E.position==="full"&&this._renderColorZone(E);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)-k[b.position||"full"]/2),y[b.position||"full"],Math.round((this._canvas.height-1)*((b.endBufferLine-b.startBufferLine)/this._bufferService.buffers.active.lines.length)+k[b.position||"full"]))}_queueRefresh(b,E){this._shouldUpdateDimensions=b||this._shouldUpdateDimensions,this._shouldUpdateAnchor=E||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};c.OverviewRulerRenderer=v=f([p(2,w.IBufferService),p(3,w.IDecorationService),p(4,_.IRenderService),p(5,w.IOptionsService),p(6,_.ICoreBrowserService)],v)},2950:function(u,c,h){var f=this&&this.__decorate||function(k,y,S,v){var b,E=arguments.length,T=E<3?y:v===null?v=Object.getOwnPropertyDescriptor(y,S):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(k,y,S,v);else for(var N=k.length-1;N>=0;N--)(b=k[N])&&(T=(E<3?b(T):E>3?b(y,S,T):b(y,S))||T);return E>3&&T&&Object.defineProperty(y,S,T),T},p=this&&this.__param||function(k,y){return function(S,v){y(S,v,k)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CompositionHelper=void 0;const m=h(4725),_=h(2585),x=h(2584);let w=c.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(k,y,S,v,b,E){this._textarea=k,this._compositionView=y,this._bufferService=S,this._optionsService=v,this._coreService=b,this._renderService=E,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(k){this._compositionView.textContent=k.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(k){if(this._isComposing||this._isSendingComposition){if(k.keyCode===229||k.keyCode===16||k.keyCode===17||k.keyCode===18)return!1;this._finalizeComposition(!1)}return k.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(k){if(this._compositionView.classList.remove("active"),this._isComposing=!1,k){const y={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let S;this._isSendingComposition=!1,y.start+=this._dataAlreadySent.length,S=this._isComposing?this._textarea.value.substring(y.start,y.end):this._textarea.value.substring(y.start),S.length>0&&this._coreService.triggerDataEvent(S,!0)}}),0)}else{this._isSendingComposition=!1;const y=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(y,!0)}}_handleAnyTextareaChanges(){const k=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const y=this._textarea.value,S=y.replace(k,"");this._dataAlreadySent=S,y.length>k.length?this._coreService.triggerDataEvent(S,!0):y.length<k.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):y.length===k.length&&y!==k&&this._coreService.triggerDataEvent(y,!0)}}),0)}updateCompositionElements(k){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const y=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),S=this._renderService.dimensions.css.cell.height,v=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,b=y*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=b+"px",this._compositionView.style.top=v+"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 E=this._compositionView.getBoundingClientRect();this._textarea.style.left=b+"px",this._textarea.style.top=v+"px",this._textarea.style.width=Math.max(E.width,1)+"px",this._textarea.style.height=Math.max(E.height,1)+"px",this._textarea.style.lineHeight=E.height+"px"}k||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};c.CompositionHelper=w=f([p(2,_.IBufferService),p(3,_.IOptionsService),p(4,_.ICoreService),p(5,m.IRenderService)],w)},9806:(u,c)=>{function h(f,p,m){const _=m.getBoundingClientRect(),x=f.getComputedStyle(m),w=parseInt(x.getPropertyValue("padding-left")),k=parseInt(x.getPropertyValue("padding-top"));return[p.clientX-_.left-w,p.clientY-_.top-k]}Object.defineProperty(c,"__esModule",{value:!0}),c.getCoords=c.getCoordsRelativeToElement=void 0,c.getCoordsRelativeToElement=h,c.getCoords=function(f,p,m,_,x,w,k,y,S){if(!w)return;const v=h(f,p,m);return v?(v[0]=Math.ceil((v[0]+(S?k/2:0))/k),v[1]=Math.ceil(v[1]/y),v[0]=Math.min(Math.max(v[0],1),_+(S?1:0)),v[1]=Math.min(Math.max(v[1],1),x),v):void 0}},9504:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.moveToCellSequence=void 0;const f=h(2584);function p(y,S,v,b){const E=y-m(y,v),T=S-m(S,v),N=Math.abs(E-T)-(function(L,A,D){let B=0;const q=L-m(L,D),W=A-m(A,D);for(let O=0;O<Math.abs(q-W);O++){const V=_(L,A)==="A"?-1:1,G=D.buffer.lines.get(q+V*O);G!=null&&G.isWrapped&&B++}return B})(y,S,v);return k(N,w(_(y,S),b))}function m(y,S){let v=0,b=S.buffer.lines.get(y),E=b==null?void 0:b.isWrapped;for(;E&&y>=0&&y<S.rows;)v++,b=S.buffer.lines.get(--y),E=b==null?void 0:b.isWrapped;return v}function _(y,S){return y>S?"A":"B"}function x(y,S,v,b,E,T){let N=y,L=S,A="";for(;N!==v||L!==b;)N+=E?1:-1,E&&N>T.cols-1?(A+=T.buffer.translateBufferLineToString(L,!1,y,N),N=0,y=0,L++):!E&&N<0&&(A+=T.buffer.translateBufferLineToString(L,!1,0,y+1),N=T.cols-1,y=N,L--);return A+T.buffer.translateBufferLineToString(L,!1,y,N)}function w(y,S){const v=S?"O":"[";return f.C0.ESC+v+y}function k(y,S){y=Math.floor(y);let v="";for(let b=0;b<y;b++)v+=S;return v}c.moveToCellSequence=function(y,S,v,b){const E=v.buffer.x,T=v.buffer.y;if(!v.buffer.hasScrollback)return(function(A,D,B,q,W,O){return p(D,q,W,O).length===0?"":k(x(A,D,A,D-m(D,W),!1,W).length,w("D",O))})(E,T,0,S,v,b)+p(T,S,v,b)+(function(A,D,B,q,W,O){let V;V=p(D,q,W,O).length>0?q-m(q,W):D;const G=q,z=(function(X,ne,F,M,$,P){let U;return U=p(F,M,$,P).length>0?M-m(M,$):ne,X<F&&U<=M||X>=F&&U<M?"C":"D"})(A,D,B,q,W,O);return k(x(A,V,B,G,z==="C",W).length,w(z,O))})(E,T,y,S,v,b);let N;if(T===S)return N=E>y?"D":"C",k(Math.abs(E-y),w(N,b));N=T>S?"D":"C";const L=Math.abs(T-S);return k((function(A,D){return D.cols-A})(T>S?y:E,v)+(L-1)*v.cols+1+((T>S?E:y)-1),w(N,b))}},1296:function(u,c,h){var f=this&&this.__decorate||function(O,V,G,z){var X,ne=arguments.length,F=ne<3?V:z===null?z=Object.getOwnPropertyDescriptor(V,G):z;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(O,V,G,z);else for(var M=O.length-1;M>=0;M--)(X=O[M])&&(F=(ne<3?X(F):ne>3?X(V,G,F):X(V,G))||F);return ne>3&&F&&Object.defineProperty(V,G,F),F},p=this&&this.__param||function(O,V){return function(G,z){V(G,z,O)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRenderer=void 0;const m=h(3787),_=h(2550),x=h(2223),w=h(6171),k=h(6052),y=h(4725),S=h(8055),v=h(8460),b=h(844),E=h(2585),T="xterm-dom-renderer-owner-",N="xterm-rows",L="xterm-fg-",A="xterm-bg-",D="xterm-focus",B="xterm-selection";let q=1,W=c.DomRenderer=class extends b.Disposable{constructor(O,V,G,z,X,ne,F,M,$,P,U,J,Q){super(),this._terminal=O,this._document=V,this._element=G,this._screenElement=z,this._viewportElement=X,this._helperContainer=ne,this._linkifier2=F,this._charSizeService=$,this._optionsService=P,this._bufferService=U,this._coreBrowserService=J,this._themeService=Q,this._terminalClass=q++,this._rowElements=[],this._selectionRenderModel=(0,k.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new v.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(N),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(B),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((se=>this._injectCss(se)))),this._injectCss(this._themeService.colors),this._rowFactory=M.createInstance(m.DomRendererRowFactory,document),this._element.classList.add(T+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((se=>this._handleLinkHover(se)))),this.register(this._linkifier2.onHideLinkUnderline((se=>this._handleLinkLeave(se)))),this.register((0,b.toDisposable)((()=>{this._element.classList.remove(T+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new _.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 O=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*O,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*O),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/O),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/O),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const G of this._rowElements)G.style.width=`${this.dimensions.css.canvas.width}px`,G.style.height=`${this.dimensions.css.cell.height}px`,G.style.lineHeight=`${this.dimensions.css.cell.height}px`,G.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const V=`${this._terminalSelector} .${N} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=V,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(O){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let V=`${this._terminalSelector} .${N} { color: ${O.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;V+=`${this._terminalSelector} .${N} .xterm-dim { color: ${S.color.multiplyOpacity(O.foreground,.5).css};}`,V+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;const G=`blink_underline_${this._terminalClass}`,z=`blink_bar_${this._terminalClass}`,X=`blink_block_${this._terminalClass}`;V+=`@keyframes ${G} { 50% { border-bottom-style: hidden; }}`,V+=`@keyframes ${z} { 50% { box-shadow: none; }}`,V+=`@keyframes ${X} { 0% { background-color: ${O.cursor.css}; color: ${O.cursorAccent.css}; } 50% { background-color: inherit; color: ${O.cursor.css}; }}`,V+=`${this._terminalSelector} .${N}.${D} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${G} 1s step-end infinite;}${this._terminalSelector} .${N}.${D} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${z} 1s step-end infinite;}${this._terminalSelector} .${N}.${D} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${X} 1s step-end infinite;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-block { background-color: ${O.cursor.css}; color: ${O.cursorAccent.css};}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${O.cursor.css} !important; color: ${O.cursorAccent.css} !important;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${O.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${O.cursor.css} inset;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${O.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,V+=`${this._terminalSelector} .${B} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${B} div { position: absolute; background-color: ${O.selectionBackgroundOpaque.css};}${this._terminalSelector} .${B} div { position: absolute; background-color: ${O.selectionInactiveBackgroundOpaque.css};}`;for(const[ne,F]of O.ansi.entries())V+=`${this._terminalSelector} .${L}${ne} { color: ${F.css}; }${this._terminalSelector} .${L}${ne}.xterm-dim { color: ${S.color.multiplyOpacity(F,.5).css}; }${this._terminalSelector} .${A}${ne} { background-color: ${F.css}; }`;V+=`${this._terminalSelector} .${L}${x.INVERTED_DEFAULT_COLOR} { color: ${S.color.opaque(O.background).css}; }${this._terminalSelector} .${L}${x.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${S.color.multiplyOpacity(S.color.opaque(O.background),.5).css}; }${this._terminalSelector} .${A}${x.INVERTED_DEFAULT_COLOR} { background-color: ${O.foreground.css}; }`,this._themeStyleElement.textContent=V}_setDefaultSpacing(){const O=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${O}px`,this._rowFactory.defaultSpacing=O}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(O,V){for(let G=this._rowElements.length;G<=V;G++){const z=this._document.createElement("div");this._rowContainer.appendChild(z),this._rowElements.push(z)}for(;this._rowElements.length>V;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(O,V){this._refreshRowElements(O,V),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(D),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(D),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(O,V,G){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(O,V,G),this.renderRows(0,this._bufferService.rows-1),!O||!V)return;this._selectionRenderModel.update(this._terminal,O,V,G);const z=this._selectionRenderModel.viewportStartRow,X=this._selectionRenderModel.viewportEndRow,ne=this._selectionRenderModel.viewportCappedStartRow,F=this._selectionRenderModel.viewportCappedEndRow;if(ne>=this._bufferService.rows||F<0)return;const M=this._document.createDocumentFragment();if(G){const $=O[0]>V[0];M.appendChild(this._createSelectionElement(ne,$?V[0]:O[0],$?O[0]:V[0],F-ne+1))}else{const $=z===ne?O[0]:0,P=ne===X?V[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(ne,$,P));const U=F-ne-1;if(M.appendChild(this._createSelectionElement(ne+1,0,this._bufferService.cols,U)),ne!==F){const J=X===F?V[0]:this._bufferService.cols;M.appendChild(this._createSelectionElement(F,0,J))}}this._selectionContainer.appendChild(M)}_createSelectionElement(O,V,G,z=1){const X=this._document.createElement("div"),ne=V*this.dimensions.css.cell.width;let F=this.dimensions.css.cell.width*(G-V);return ne+F>this.dimensions.css.canvas.width&&(F=this.dimensions.css.canvas.width-ne),X.style.height=z*this.dimensions.css.cell.height+"px",X.style.top=O*this.dimensions.css.cell.height+"px",X.style.left=`${ne}px`,X.style.width=`${F}px`,X}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 O of this._rowElements)O.replaceChildren()}renderRows(O,V){const G=this._bufferService.buffer,z=G.ybase+G.y,X=Math.min(G.x,this._bufferService.cols-1),ne=this._optionsService.rawOptions.cursorBlink,F=this._optionsService.rawOptions.cursorStyle,M=this._optionsService.rawOptions.cursorInactiveStyle;for(let $=O;$<=V;$++){const P=$+G.ydisp,U=this._rowElements[$],J=G.lines.get(P);if(!U||!J)break;U.replaceChildren(...this._rowFactory.createRow(J,P,P===z,F,M,X,ne,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${T}${this._terminalClass}`}_handleLinkHover(O){this._setCellUnderline(O.x1,O.x2,O.y1,O.y2,O.cols,!0)}_handleLinkLeave(O){this._setCellUnderline(O.x1,O.x2,O.y1,O.y2,O.cols,!1)}_setCellUnderline(O,V,G,z,X,ne){G<0&&(O=0),z<0&&(V=0);const F=this._bufferService.rows-1;G=Math.max(Math.min(G,F),0),z=Math.max(Math.min(z,F),0),X=Math.min(X,this._bufferService.cols);const M=this._bufferService.buffer,$=M.ybase+M.y,P=Math.min(M.x,X-1),U=this._optionsService.rawOptions.cursorBlink,J=this._optionsService.rawOptions.cursorStyle,Q=this._optionsService.rawOptions.cursorInactiveStyle;for(let se=G;se<=z;++se){const Y=se+M.ydisp,H=this._rowElements[se],ee=M.lines.get(Y);if(!H||!ee)break;H.replaceChildren(...this._rowFactory.createRow(ee,Y,Y===$,J,Q,P,U,this.dimensions.css.cell.width,this._widthCache,ne?se===G?O:0:-1,ne?(se===z?V:X)-1:-1))}}};c.DomRenderer=W=f([p(7,E.IInstantiationService),p(8,y.ICharSizeService),p(9,E.IOptionsService),p(10,E.IBufferService),p(11,y.ICoreBrowserService),p(12,y.IThemeService)],W)},3787:function(u,c,h){var f=this&&this.__decorate||function(N,L,A,D){var B,q=arguments.length,W=q<3?L:D===null?D=Object.getOwnPropertyDescriptor(L,A):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")W=Reflect.decorate(N,L,A,D);else for(var O=N.length-1;O>=0;O--)(B=N[O])&&(W=(q<3?B(W):q>3?B(L,A,W):B(L,A))||W);return q>3&&W&&Object.defineProperty(L,A,W),W},p=this&&this.__param||function(N,L){return function(A,D){L(A,D,N)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRendererRowFactory=void 0;const m=h(2223),_=h(643),x=h(511),w=h(2585),k=h(8055),y=h(4725),S=h(4269),v=h(6171),b=h(3734);let E=c.DomRendererRowFactory=class{constructor(N,L,A,D,B,q,W){this._document=N,this._characterJoinerService=L,this._optionsService=A,this._coreBrowserService=D,this._coreService=B,this._decorationService=q,this._themeService=W,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(N,L,A){this._selectionStart=N,this._selectionEnd=L,this._columnSelectMode=A}createRow(N,L,A,D,B,q,W,O,V,G,z){const X=[],ne=this._characterJoinerService.getJoinedCharacters(L),F=this._themeService.colors;let M,$=N.getNoBgTrimmedLength();A&&$<q+1&&($=q+1);let P=0,U="",J=0,Q=0,se=0,Y=!1,H=0,ee=!1,te=0;const ce=[],he=G!==-1&&z!==-1;for(let Te=0;Te<$;Te++){N.loadCell(Te,this._workCell);let Ae=this._workCell.getWidth();if(Ae===0)continue;let Le=!1,Pe=Te,de=this._workCell;if(ne.length>0&&Te===ne[0][0]){Le=!0;const Xe=ne.shift();de=new S.JoinedCellData(this._workCell,N.translateToString(!0,Xe[0],Xe[1]),Xe[1]-Xe[0]),Pe=Xe[1]-1,Ae=de.getWidth()}const Ie=this._isCellInSelection(Te,L),Se=A&&Te===q,me=he&&Te>=G&&Te<=z;let je=!1;this._decorationService.forEachDecorationAtCell(Te,L,void 0,(Xe=>{je=!0}));let nt=de.getChars()||_.WHITESPACE_CELL_CHAR;if(nt===" "&&(de.isUnderline()||de.isOverline())&&(nt=" "),te=Ae*O-V.get(nt,de.isBold(),de.isItalic()),M){if(P&&(Ie&&ee||!Ie&&!ee&&de.bg===J)&&(Ie&&ee&&F.selectionForeground||de.fg===Q)&&de.extended.ext===se&&me===Y&&te===H&&!Se&&!Le&&!je){de.isInvisible()?U+=_.WHITESPACE_CELL_CHAR:U+=nt,P++;continue}P&&(M.textContent=U),M=this._document.createElement("span"),P=0,U=""}else M=this._document.createElement("span");if(J=de.bg,Q=de.fg,se=de.extended.ext,Y=me,H=te,ee=Ie,Le&&q>=Te&&q<=Pe&&(q=Te),!this._coreService.isCursorHidden&&Se&&this._coreService.isCursorInitialized){if(ce.push("xterm-cursor"),this._coreBrowserService.isFocused)W&&ce.push("xterm-cursor-blink"),ce.push(D==="bar"?"xterm-cursor-bar":D==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(B)switch(B){case"outline":ce.push("xterm-cursor-outline");break;case"block":ce.push("xterm-cursor-block");break;case"bar":ce.push("xterm-cursor-bar");break;case"underline":ce.push("xterm-cursor-underline")}}if(de.isBold()&&ce.push("xterm-bold"),de.isItalic()&&ce.push("xterm-italic"),de.isDim()&&ce.push("xterm-dim"),U=de.isInvisible()?_.WHITESPACE_CELL_CHAR:de.getChars()||_.WHITESPACE_CELL_CHAR,de.isUnderline()&&(ce.push(`xterm-underline-${de.extended.underlineStyle}`),U===" "&&(U=" "),!de.isUnderlineColorDefault()))if(de.isUnderlineColorRGB())M.style.textDecorationColor=`rgb(${b.AttributeData.toColorRGB(de.getUnderlineColor()).join(",")})`;else{let Xe=de.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&de.isBold()&&Xe<8&&(Xe+=8),M.style.textDecorationColor=F.ansi[Xe].css}de.isOverline()&&(ce.push("xterm-overline"),U===" "&&(U=" ")),de.isStrikethrough()&&ce.push("xterm-strikethrough"),me&&(M.style.textDecoration="underline");let Mt=de.getFgColor(),gt=de.getFgColorMode(),Zt=de.getBgColor(),ge=de.getBgColorMode();const Ce=!!de.isInverse();if(Ce){const Xe=Mt;Mt=Zt,Zt=Xe;const bt=gt;gt=ge,ge=bt}let Oe,Ve,Ge,vt=!1;switch(this._decorationService.forEachDecorationAtCell(Te,L,void 0,(Xe=>{Xe.options.layer!=="top"&&vt||(Xe.backgroundColorRGB&&(ge=50331648,Zt=Xe.backgroundColorRGB.rgba>>8&16777215,Oe=Xe.backgroundColorRGB),Xe.foregroundColorRGB&&(gt=50331648,Mt=Xe.foregroundColorRGB.rgba>>8&16777215,Ve=Xe.foregroundColorRGB),vt=Xe.options.layer==="top")})),!vt&&Ie&&(Oe=this._coreBrowserService.isFocused?F.selectionBackgroundOpaque:F.selectionInactiveBackgroundOpaque,Zt=Oe.rgba>>8&16777215,ge=50331648,vt=!0,F.selectionForeground&&(gt=50331648,Mt=F.selectionForeground.rgba>>8&16777215,Ve=F.selectionForeground)),vt&&ce.push("xterm-decoration-top"),ge){case 16777216:case 33554432:Ge=F.ansi[Zt],ce.push(`xterm-bg-${Zt}`);break;case 50331648:Ge=k.channels.toColor(Zt>>16,Zt>>8&255,255&Zt),this._addStyle(M,`background-color:#${T((Zt>>>0).toString(16),"0",6)}`);break;default:Ce?(Ge=F.foreground,ce.push(`xterm-bg-${m.INVERTED_DEFAULT_COLOR}`)):Ge=F.background}switch(Oe||de.isDim()&&(Oe=k.color.multiplyOpacity(Ge,.5)),gt){case 16777216:case 33554432:de.isBold()&&Mt<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Mt+=8),this._applyMinimumContrast(M,Ge,F.ansi[Mt],de,Oe,void 0)||ce.push(`xterm-fg-${Mt}`);break;case 50331648:const Xe=k.channels.toColor(Mt>>16&255,Mt>>8&255,255&Mt);this._applyMinimumContrast(M,Ge,Xe,de,Oe,Ve)||this._addStyle(M,`color:#${T(Mt.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(M,Ge,F.foreground,de,Oe,Ve)||Ce&&ce.push(`xterm-fg-${m.INVERTED_DEFAULT_COLOR}`)}ce.length&&(M.className=ce.join(" "),ce.length=0),Se||Le||je?M.textContent=U:P++,te!==this.defaultSpacing&&(M.style.letterSpacing=`${te}px`),X.push(M),Te=Pe}return M&&P&&(M.textContent=U),X}_applyMinimumContrast(N,L,A,D,B,q){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,v.treatGlyphAsBackgroundColor)(D.getCode()))return!1;const W=this._getContrastCache(D);let O;if(B||q||(O=W.getColor(L.rgba,A.rgba)),O===void 0){const V=this._optionsService.rawOptions.minimumContrastRatio/(D.isDim()?2:1);O=k.color.ensureContrastRatio(B||L,q||A,V),W.setColor((B||L).rgba,(q||A).rgba,O??null)}return!!O&&(this._addStyle(N,`color:${O.css}`),!0)}_getContrastCache(N){return N.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(N,L){N.setAttribute("style",`${N.getAttribute("style")||""}${L};`)}_isCellInSelection(N,L){const A=this._selectionStart,D=this._selectionEnd;return!(!A||!D)&&(this._columnSelectMode?A[0]<=D[0]?N>=A[0]&&L>=A[1]&&N<D[0]&&L<=D[1]:N<A[0]&&L>=A[1]&&N>=D[0]&&L<=D[1]:L>A[1]&&L<D[1]||A[1]===D[1]&&L===A[1]&&N>=A[0]&&N<D[0]||A[1]<D[1]&&L===D[1]&&N<D[0]||A[1]<D[1]&&L===A[1]&&N>=A[0])}};function T(N,L,A){for(;N.length<A;)N=L+N;return N}c.DomRendererRowFactory=E=f([p(1,y.ICharacterJoinerService),p(2,w.IOptionsService),p(3,y.ICoreBrowserService),p(4,w.ICoreService),p(5,w.IDecorationService),p(6,y.IThemeService)],E)},2550:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WidthCache=void 0,c.WidthCache=class{constructor(h,f){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=h.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=h.createElement("span");p.classList.add("xterm-char-measure-element");const m=h.createElement("span");m.classList.add("xterm-char-measure-element"),m.style.fontWeight="bold";const _=h.createElement("span");_.classList.add("xterm-char-measure-element"),_.style.fontStyle="italic";const x=h.createElement("span");x.classList.add("xterm-char-measure-element"),x.style.fontWeight="bold",x.style.fontStyle="italic",this._measureElements=[p,m,_,x],this._container.appendChild(p),this._container.appendChild(m),this._container.appendChild(_),this._container.appendChild(x),f.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(h,f,p,m){h===this._font&&f===this._fontSize&&p===this._weight&&m===this._weightBold||(this._font=h,this._fontSize=f,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(h,f,p){let m=0;if(!f&&!p&&h.length===1&&(m=h.charCodeAt(0))<256){if(this._flat[m]!==-9999)return this._flat[m];const w=this._measure(h,0);return w>0&&(this._flat[m]=w),w}let _=h;f&&(_+="B"),p&&(_+="I");let x=this._holey.get(_);if(x===void 0){let w=0;f&&(w|=1),p&&(w|=2),x=this._measure(h,w),x>0&&this._holey.set(_,x)}return x}_measure(h,f){const p=this._measureElements[f];return p.textContent=h.repeat(32),p.offsetWidth/32}}},2223:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TEXT_BASELINE=c.DIM_OPACITY=c.INVERTED_DEFAULT_COLOR=void 0;const f=h(6114);c.INVERTED_DEFAULT_COLOR=257,c.DIM_OPACITY=.5,c.TEXT_BASELINE=f.isFirefox||f.isLegacyEdge?"bottom":"ideographic"},6171:(u,c)=>{function h(p){return 57508<=p&&p<=57558}function f(p){return p>=128512&&p<=128591||p>=127744&&p<=128511||p>=128640&&p<=128767||p>=9728&&p<=9983||p>=9984&&p<=10175||p>=65024&&p<=65039||p>=129280&&p<=129535||p>=127462&&p<=127487}Object.defineProperty(c,"__esModule",{value:!0}),c.computeNextVariantOffset=c.createRenderDimensions=c.treatGlyphAsBackgroundColor=c.allowRescaling=c.isEmoji=c.isRestrictedPowerlineGlyph=c.isPowerlineGlyph=c.throwIfFalsy=void 0,c.throwIfFalsy=function(p){if(!p)throw new Error("value must not be falsy");return p},c.isPowerlineGlyph=h,c.isRestrictedPowerlineGlyph=function(p){return 57520<=p&&p<=57527},c.isEmoji=f,c.allowRescaling=function(p,m,_,x){return m===1&&_>Math.ceil(1.5*x)&&p!==void 0&&p>255&&!f(p)&&!h(p)&&!(function(w){return 57344<=w&&w<=63743})(p)},c.treatGlyphAsBackgroundColor=function(p){return h(p)||(function(m){return 9472<=m&&m<=9631})(p)},c.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},c.computeNextVariantOffset=function(p,m,_=0){return(p-(2*Math.round(m)-_))%(2*Math.round(m))}},6052:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createSelectionRenderModel=void 0;class h{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(p,m,_,x=!1){if(this.selectionStart=m,this.selectionEnd=_,!m||!_||m[0]===_[0]&&m[1]===_[1])return void this.clear();const w=p.buffers.active.ydisp,k=m[1]-w,y=_[1]-w,S=Math.max(k,0),v=Math.min(y,p.rows-1);S>=p.rows||v<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=x,this.viewportStartRow=k,this.viewportEndRow=y,this.viewportCappedStartRow=S,this.viewportCappedEndRow=v,this.startCol=m[0],this.endCol=_[0])}isCellSelected(p,m,_){return!!this.hasSelection&&(_-=p.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?m>=this.startCol&&_>=this.viewportCappedStartRow&&m<this.endCol&&_<=this.viewportCappedEndRow:m<this.startCol&&_>=this.viewportCappedStartRow&&m>=this.endCol&&_<=this.viewportCappedEndRow:_>this.viewportStartRow&&_<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&_===this.viewportStartRow&&m>=this.startCol&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&_===this.viewportEndRow&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&_===this.viewportStartRow&&m>=this.startCol)}}c.createSelectionRenderModel=function(){return new h}},456:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionModel=void 0,c.SelectionModel=class{constructor(h){this._bufferService=h,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 h=this.selectionStart[0]+this.selectionStartLength;return h>this._bufferService.cols?h%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(h/this._bufferService.cols)-1]:[h%this._bufferService.cols,this.selectionStart[1]+Math.floor(h/this._bufferService.cols)]:[h,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const h=this.selectionStart[0]+this.selectionStartLength;return h>this._bufferService.cols?[h%this._bufferService.cols,this.selectionStart[1]+Math.floor(h/this._bufferService.cols)]:[Math.max(h,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const h=this.selectionStart,f=this.selectionEnd;return!(!h||!f)&&(h[1]>f[1]||h[1]===f[1]&&h[0]>f[0])}handleTrim(h){return this.selectionStart&&(this.selectionStart[1]-=h),this.selectionEnd&&(this.selectionEnd[1]-=h),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(u,c,h){var f=this&&this.__decorate||function(v,b,E,T){var N,L=arguments.length,A=L<3?b:T===null?T=Object.getOwnPropertyDescriptor(b,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,b,E,T);else for(var D=v.length-1;D>=0;D--)(N=v[D])&&(A=(L<3?N(A):L>3?N(b,E,A):N(b,E))||A);return L>3&&A&&Object.defineProperty(b,E,A),A},p=this&&this.__param||function(v,b){return function(E,T){b(E,T,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharSizeService=void 0;const m=h(2585),_=h(8460),x=h(844);let w=c.CharSizeService=class extends x.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(v,b,E){super(),this._optionsService=E,this.width=0,this.height=0,this._onCharSizeChange=this.register(new _.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new S(this._optionsService))}catch{this._measureStrategy=this.register(new y(v,b,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const v=this._measureStrategy.measure();v.width===this.width&&v.height===this.height||(this.width=v.width,this.height=v.height,this._onCharSizeChange.fire())}};c.CharSizeService=w=f([p(2,m.IOptionsService)],w);class k extends x.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(b,E){b!==void 0&&b>0&&E!==void 0&&E>0&&(this._result.width=b,this._result.height=E)}}class y extends k{constructor(b,E,T){super(),this._document=b,this._parentElement=E,this._optionsService=T,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 k{constructor(b){super(),this._optionsService=b,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");const E=this._ctx.measureText("W");if(!("width"in E&&"fontBoundingBoxAscent"in E&&"fontBoundingBoxDescent"in E))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;const b=this._ctx.measureText("W");return this._validateAndSet(b.width,b.fontBoundingBoxAscent+b.fontBoundingBoxDescent),this._result}}},4269:function(u,c,h){var f=this&&this.__decorate||function(S,v,b,E){var T,N=arguments.length,L=N<3?v:E===null?E=Object.getOwnPropertyDescriptor(v,b):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(S,v,b,E);else for(var A=S.length-1;A>=0;A--)(T=S[A])&&(L=(N<3?T(L):N>3?T(v,b,L):T(v,b))||L);return N>3&&L&&Object.defineProperty(v,b,L),L},p=this&&this.__param||function(S,v){return function(b,E){v(b,E,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharacterJoinerService=c.JoinedCellData=void 0;const m=h(3734),_=h(643),x=h(511),w=h(2585);class k extends m.AttributeData{constructor(v,b,E){super(),this.content=0,this.combinedData="",this.fg=v.fg,this.bg=v.bg,this.combinedData=b,this._width=E}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(v){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.JoinedCellData=k;let y=c.CharacterJoinerService=class AS{constructor(v){this._bufferService=v,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(v){const b={id:this._nextCharacterJoinerId++,handler:v};return this._characterJoiners.push(b),b.id}deregister(v){for(let b=0;b<this._characterJoiners.length;b++)if(this._characterJoiners[b].id===v)return this._characterJoiners.splice(b,1),!0;return!1}getJoinedCharacters(v){if(this._characterJoiners.length===0)return[];const b=this._bufferService.buffer.lines.get(v);if(!b||b.length===0)return[];const E=[],T=b.translateToString(!0);let N=0,L=0,A=0,D=b.getFg(0),B=b.getBg(0);for(let q=0;q<b.getTrimmedLength();q++)if(b.loadCell(q,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==D||this._workCell.bg!==B){if(q-N>1){const W=this._getJoinedRanges(T,A,L,b,N);for(let O=0;O<W.length;O++)E.push(W[O])}N=q,A=L,D=this._workCell.fg,B=this._workCell.bg}L+=this._workCell.getChars().length||_.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-N>1){const q=this._getJoinedRanges(T,A,L,b,N);for(let W=0;W<q.length;W++)E.push(q[W])}return E}_getJoinedRanges(v,b,E,T,N){const L=v.substring(b,E);let A=[];try{A=this._characterJoiners[0].handler(L)}catch(D){console.error(D)}for(let D=1;D<this._characterJoiners.length;D++)try{const B=this._characterJoiners[D].handler(L);for(let q=0;q<B.length;q++)AS._mergeRanges(A,B[q])}catch(B){console.error(B)}return this._stringRangesToCellRanges(A,T,N),A}_stringRangesToCellRanges(v,b,E){let T=0,N=!1,L=0,A=v[T];if(A){for(let D=E;D<this._bufferService.cols;D++){const B=b.getWidth(D),q=b.getString(D).length||_.WHITESPACE_CELL_CHAR.length;if(B!==0){if(!N&&A[0]<=L&&(A[0]=D,N=!0),A[1]<=L){if(A[1]=D,A=v[++T],!A)break;A[0]<=L?(A[0]=D,N=!0):N=!1}L+=q}}A&&(A[1]=this._bufferService.cols)}}static _mergeRanges(v,b){let E=!1;for(let T=0;T<v.length;T++){const N=v[T];if(E){if(b[1]<=N[0])return v[T-1][1]=b[1],v;if(b[1]<=N[1])return v[T-1][1]=Math.max(b[1],N[1]),v.splice(T,1),v;v.splice(T,1),T--}else{if(b[1]<=N[0])return v.splice(T,0,b),v;if(b[1]<=N[1])return N[0]=Math.min(b[0],N[0]),v;b[0]<N[1]&&(N[0]=Math.min(b[0],N[0]),E=!0)}}return E?v[v.length-1][1]=b[1]:v.push(b),v}};c.CharacterJoinerService=y=f([p(0,w.IBufferService)],y)},5114:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreBrowserService=void 0;const f=h(844),p=h(8460),m=h(3656);class _ extends f.Disposable{constructor(k,y,S){super(),this._textarea=k,this._window=y,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((v=>this._screenDprMonitor.setWindow(v)))),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(k){this._window!==k&&(this._window=k,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}c.CoreBrowserService=_;class x extends f.Disposable{constructor(k){super(),this._parentWindow=k,this._windowResizeListener=this.register(new f.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,f.toDisposable)((()=>this.clearListener())))}setWindow(k){this._parentWindow=k,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 k;this._outerListener&&((k=this._resolutionMediaMatchList)==null||k.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.LinkProviderService=void 0;const f=h(844);class p extends f.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,f.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(_){return this.linkProviders.push(_),{dispose:()=>{const x=this.linkProviders.indexOf(_);x!==-1&&this.linkProviders.splice(x,1)}}}}c.LinkProviderService=p},8934:function(u,c,h){var f=this&&this.__decorate||function(w,k,y,S){var v,b=arguments.length,E=b<3?k:S===null?S=Object.getOwnPropertyDescriptor(k,y):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(w,k,y,S);else for(var T=w.length-1;T>=0;T--)(v=w[T])&&(E=(b<3?v(E):b>3?v(k,y,E):v(k,y))||E);return b>3&&E&&Object.defineProperty(k,y,E),E},p=this&&this.__param||function(w,k){return function(y,S){k(y,S,w)}};Object.defineProperty(c,"__esModule",{value:!0}),c.MouseService=void 0;const m=h(4725),_=h(9806);let x=c.MouseService=class{constructor(w,k){this._renderService=w,this._charSizeService=k}getCoords(w,k,y,S,v){return(0,_.getCoords)(window,w,k,y,S,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,v)}getMouseReportCoords(w,k){const y=(0,_.getCoordsRelativeToElement)(window,w,k);if(this._charSizeService.hasValidSize)return y[0]=Math.min(Math.max(y[0],0),this._renderService.dimensions.css.canvas.width-1),y[1]=Math.min(Math.max(y[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(y[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(y[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(y[0]),y:Math.floor(y[1])}}};c.MouseService=x=f([p(0,m.IRenderService),p(1,m.ICharSizeService)],x)},3230:function(u,c,h){var f=this&&this.__decorate||function(v,b,E,T){var N,L=arguments.length,A=L<3?b:T===null?T=Object.getOwnPropertyDescriptor(b,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,b,E,T);else for(var D=v.length-1;D>=0;D--)(N=v[D])&&(A=(L<3?N(A):L>3?N(b,E,A):N(b,E))||A);return L>3&&A&&Object.defineProperty(b,E,A),A},p=this&&this.__param||function(v,b){return function(E,T){b(E,T,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.RenderService=void 0;const m=h(6193),_=h(4725),x=h(8460),w=h(844),k=h(7226),y=h(2585);let S=c.RenderService=class extends w.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(v,b,E,T,N,L,A,D){super(),this._rowCount=v,this._charSizeService=T,this._renderer=this.register(new w.MutableDisposable),this._pausedResizeTask=new k.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(((B,q)=>this._renderRows(B,q)),A),this.register(this._renderDebouncer),this.register(A.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(L.onResize((()=>this._fullRefresh()))),this.register(L.buffers.onBufferActivate((()=>{var B;return(B=this._renderer.value)==null?void 0:B.clear()}))),this.register(E.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(N.onDecorationRegistered((()=>this._fullRefresh()))),this.register(N.onDecorationRemoved((()=>this._fullRefresh()))),this.register(E.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(L.cols,L.rows),this._fullRefresh()}))),this.register(E.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(L.buffer.y,L.buffer.y,!0)))),this.register(D.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(A.window,b),this.register(A.onWindowChange((B=>this._registerIntersectionObserver(B,b))))}_registerIntersectionObserver(v,b){if("IntersectionObserver"in v){const E=new v.IntersectionObserver((T=>this._handleIntersectionChange(T[T.length-1])),{threshold:0});E.observe(b),this._observerDisposable.value=(0,w.toDisposable)((()=>E.disconnect()))}}_handleIntersectionChange(v){this._isPaused=v.isIntersecting===void 0?v.intersectionRatio===0:!v.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(v,b,E=!1){this._isPaused?this._needsFullRefresh=!0:(E||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(v,b,this._rowCount))}_renderRows(v,b){this._renderer.value&&(v=Math.min(v,this._rowCount-1),b=Math.min(b,this._rowCount-1),this._renderer.value.renderRows(v,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:v,end:b}),this._onRender.fire({start:v,end:b}),this._isNextRenderRedrawOnly=!0)}resize(v,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(v){this._renderer.value=v,this._renderer.value&&(this._renderer.value.onRequestRedraw((b=>this.refreshRows(b.start,b.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(v){return this._renderDebouncer.addRefreshCallback(v)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var v,b;this._renderer.value&&((b=(v=this._renderer.value).clearTextureAtlas)==null||b.call(v),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(v,b){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>{var E;return(E=this._renderer.value)==null?void 0:E.handleResize(v,b)})):this._renderer.value.handleResize(v,b),this._fullRefresh())}handleCharSizeChanged(){var v;(v=this._renderer.value)==null||v.handleCharSizeChanged()}handleBlur(){var v;(v=this._renderer.value)==null||v.handleBlur()}handleFocus(){var v;(v=this._renderer.value)==null||v.handleFocus()}handleSelectionChanged(v,b,E){var T;this._selectionState.start=v,this._selectionState.end=b,this._selectionState.columnSelectMode=E,(T=this._renderer.value)==null||T.handleSelectionChanged(v,b,E)}handleCursorMove(){var v;(v=this._renderer.value)==null||v.handleCursorMove()}clear(){var v;(v=this._renderer.value)==null||v.clear()}};c.RenderService=S=f([p(2,y.IOptionsService),p(3,_.ICharSizeService),p(4,y.IDecorationService),p(5,y.IBufferService),p(6,_.ICoreBrowserService),p(7,_.IThemeService)],S)},9312:function(u,c,h){var f=this&&this.__decorate||function(A,D,B,q){var W,O=arguments.length,V=O<3?D:q===null?q=Object.getOwnPropertyDescriptor(D,B):q;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")V=Reflect.decorate(A,D,B,q);else for(var G=A.length-1;G>=0;G--)(W=A[G])&&(V=(O<3?W(V):O>3?W(D,B,V):W(D,B))||V);return O>3&&V&&Object.defineProperty(D,B,V),V},p=this&&this.__param||function(A,D){return function(B,q){D(B,q,A)}};Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionService=void 0;const m=h(9806),_=h(9504),x=h(456),w=h(4725),k=h(8460),y=h(844),S=h(6114),v=h(4841),b=h(511),E=h(2585),T=" ",N=new RegExp(T,"g");let L=c.SelectionService=class extends y.Disposable{constructor(A,D,B,q,W,O,V,G,z){super(),this._element=A,this._screenElement=D,this._linkifier=B,this._bufferService=q,this._coreService=W,this._mouseService=O,this._optionsService=V,this._renderService=G,this._coreBrowserService=z,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 k.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new k.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new k.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new k.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=X=>this._handleMouseMove(X),this._mouseUpListener=X=>this._handleMouseUp(X),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((X=>this._handleTrim(X))),this.register(this._bufferService.buffers.onBufferActivate((X=>this._handleBufferActivate(X)))),this.enable(),this._model=new x.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,y.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,D=this._model.finalSelectionEnd;return!(!A||!D||A[0]===D[0]&&A[1]===D[1])}get selectionText(){const A=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;if(!A||!D)return"";const B=this._bufferService.buffer,q=[];if(this._activeSelectionMode===3){if(A[0]===D[0])return"";const W=A[0]<D[0]?A[0]:D[0],O=A[0]<D[0]?D[0]:A[0];for(let V=A[1];V<=D[1];V++){const G=B.translateBufferLineToString(V,!0,W,O);q.push(G)}}else{const W=A[1]===D[1]?D[0]:void 0;q.push(B.translateBufferLineToString(A[1],!0,A[0],W));for(let O=A[1]+1;O<=D[1]-1;O++){const V=B.lines.get(O),G=B.translateBufferLineToString(O,!0);V!=null&&V.isWrapped?q[q.length-1]+=G:q.push(G)}if(A[1]!==D[1]){const O=B.lines.get(D[1]),V=B.translateBufferLineToString(D[1],!0,0,D[0]);O&&O.isWrapped?q[q.length-1]+=V:q.push(V)}}return q.map((W=>W.replace(N," "))).join(S.isWindows?`\r
|
|
63
|
+
`:`
|
|
64
|
+
`)}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 D=this._getMouseBufferCoords(A),B=this._model.finalSelectionStart,q=this._model.finalSelectionEnd;return!!(B&&q&&D)&&this._areCoordsInSelection(D,B,q)}isCellInSelection(A,D){const B=this._model.finalSelectionStart,q=this._model.finalSelectionEnd;return!(!B||!q)&&this._areCoordsInSelection([A,D],B,q)}_areCoordsInSelection(A,D,B){return A[1]>D[1]&&A[1]<B[1]||D[1]===B[1]&&A[1]===D[1]&&A[0]>=D[0]&&A[0]<B[0]||D[1]<B[1]&&A[1]===B[1]&&A[0]<B[0]||D[1]<B[1]&&A[1]===D[1]&&A[0]>=D[0]}_selectWordAtCursor(A,D){var W,O;const B=(O=(W=this._linkifier.currentLink)==null?void 0:W.link)==null?void 0:O.range;if(B)return this._model.selectionStart=[B.start.x-1,B.start.y-1],this._model.selectionStartLength=(0,v.getRangeLength)(B,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const q=this._getMouseBufferCoords(A);return!!q&&(this._selectWordAt(q,D),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(A,D){this._model.clearSelection(),A=Math.max(A,0),D=Math.min(D,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,A],this._model.selectionEnd=[this._bufferService.cols,D],this.refresh(),this._onSelectionChange.fire()}_handleTrim(A){this._model.handleTrim(A)&&this.refresh()}_getMouseBufferCoords(A){const D=this._mouseService.getCoords(A,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(D)return D[0]--,D[1]--,D[1]+=this._bufferService.buffer.ydisp,D}_getMouseEventScrollAmount(A){let D=(0,m.getCoordsRelativeToElement)(this._coreBrowserService.window,A,this._screenElement)[1];const B=this._renderService.dimensions.css.canvas.height;return D>=0&&D<=B?0:(D>B&&(D-=B),D=Math.min(Math.max(D,-50),50),D/=50,D/Math.abs(D)+Math.round(14*D))}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 D=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);D&&D.length!==this._model.selectionStart[0]&&D.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(A){this._selectWordAtCursor(A,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(A){const D=this._getMouseBufferCoords(A);D&&(this._activeSelectionMode=2,this._selectLineAt(D[1]))}shouldColumnSelect(A){return A.altKey&&!(S.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(A){if(A.stopImmediatePropagation(),!this._model.selectionStart)return;const D=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 B=this._bufferService.buffer;if(this._model.selectionEnd[1]<B.lines.length){const q=B.lines.get(this._model.selectionEnd[1]);q&&q.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}D&&D[0]===this._model.selectionEnd[0]&&D[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 D=A.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&D<500&&A.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const B=this._mouseService.getCoords(A,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(B&&B[0]!==void 0&&B[1]!==void 0){const q=(0,_.moveToCellSequence)(B[0]-1,B[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(q,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const A=this._model.finalSelectionStart,D=this._model.finalSelectionEnd,B=!(!A||!D||A[0]===D[0]&&A[1]===D[1]);B?A&&D&&(this._oldSelectionStart&&this._oldSelectionEnd&&A[0]===this._oldSelectionStart[0]&&A[1]===this._oldSelectionStart[1]&&D[0]===this._oldSelectionEnd[0]&&D[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(A,D,B)):this._oldHasSelection&&this._fireOnSelectionChange(A,D,B)}_fireOnSelectionChange(A,D,B){this._oldSelectionStart=A,this._oldSelectionEnd=D,this._oldHasSelection=B,this._onSelectionChange.fire()}_handleBufferActivate(A){this.clearSelection(),this._trimListener.dispose(),this._trimListener=A.activeBuffer.lines.onTrim((D=>this._handleTrim(D)))}_convertViewportColToCharacterIndex(A,D){let B=D;for(let q=0;D>=q;q++){const W=A.loadCell(q,this._workCell).getChars().length;this._workCell.getWidth()===0?B--:W>1&&D!==q&&(B+=W-1)}return B}setSelection(A,D,B){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[A,D],this._model.selectionStartLength=B,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(A){this._isClickInSelection(A)||(this._selectWordAtCursor(A,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(A,D,B=!0,q=!0){if(A[0]>=this._bufferService.cols)return;const W=this._bufferService.buffer,O=W.lines.get(A[1]);if(!O)return;const V=W.translateBufferLineToString(A[1],!1);let G=this._convertViewportColToCharacterIndex(O,A[0]),z=G;const X=A[0]-G;let ne=0,F=0,M=0,$=0;if(V.charAt(G)===" "){for(;G>0&&V.charAt(G-1)===" ";)G--;for(;z<V.length&&V.charAt(z+1)===" ";)z++}else{let J=A[0],Q=A[0];O.getWidth(J)===0&&(ne++,J--),O.getWidth(Q)===2&&(F++,Q++);const se=O.getString(Q).length;for(se>1&&($+=se-1,z+=se-1);J>0&&G>0&&!this._isCharWordSeparator(O.loadCell(J-1,this._workCell));){O.loadCell(J-1,this._workCell);const Y=this._workCell.getChars().length;this._workCell.getWidth()===0?(ne++,J--):Y>1&&(M+=Y-1,G-=Y-1),G--,J--}for(;Q<O.length&&z+1<V.length&&!this._isCharWordSeparator(O.loadCell(Q+1,this._workCell));){O.loadCell(Q+1,this._workCell);const Y=this._workCell.getChars().length;this._workCell.getWidth()===2?(F++,Q++):Y>1&&($+=Y-1,z+=Y-1),z++,Q++}}z++;let P=G+X-ne+M,U=Math.min(this._bufferService.cols,z-G+ne+F-M-$);if(D||V.slice(G,z).trim()!==""){if(B&&P===0&&O.getCodePoint(0)!==32){const J=W.lines.get(A[1]-1);if(J&&O.isWrapped&&J.getCodePoint(this._bufferService.cols-1)!==32){const Q=this._getWordAt([this._bufferService.cols-1,A[1]-1],!1,!0,!1);if(Q){const se=this._bufferService.cols-Q.start;P-=se,U+=se}}}if(q&&P+U===this._bufferService.cols&&O.getCodePoint(this._bufferService.cols-1)!==32){const J=W.lines.get(A[1]+1);if(J!=null&&J.isWrapped&&J.getCodePoint(0)!==32){const Q=this._getWordAt([0,A[1]+1],!1,!1,!0);Q&&(U+=Q.length)}}return{start:P,length:U}}}_selectWordAt(A,D){const B=this._getWordAt(A,D);if(B){for(;B.start<0;)B.start+=this._bufferService.cols,A[1]--;this._model.selectionStart=[B.start,A[1]],this._model.selectionStartLength=B.length}}_selectToWordAt(A){const D=this._getWordAt(A,!0);if(D){let B=A[1];for(;D.start<0;)D.start+=this._bufferService.cols,B--;if(!this._model.areSelectionValuesReversed())for(;D.start+D.length>this._bufferService.cols;)D.length-=this._bufferService.cols,B++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?D.start:D.start+D.length,B]}}_isCharWordSeparator(A){return A.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(A.getChars())>=0}_selectLineAt(A){const D=this._bufferService.buffer.getWrappedRangeForLine(A),B={start:{x:0,y:D.first},end:{x:this._bufferService.cols-1,y:D.last}};this._model.selectionStart=[0,D.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,v.getRangeLength)(B,this._bufferService.cols)}};c.SelectionService=L=f([p(3,E.IBufferService),p(4,E.ICoreService),p(5,w.IMouseService),p(6,E.IOptionsService),p(7,w.IRenderService),p(8,w.ICoreBrowserService)],L)},4725:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ILinkProviderService=c.IThemeService=c.ICharacterJoinerService=c.ISelectionService=c.IRenderService=c.IMouseService=c.ICoreBrowserService=c.ICharSizeService=void 0;const f=h(8343);c.ICharSizeService=(0,f.createDecorator)("CharSizeService"),c.ICoreBrowserService=(0,f.createDecorator)("CoreBrowserService"),c.IMouseService=(0,f.createDecorator)("MouseService"),c.IRenderService=(0,f.createDecorator)("RenderService"),c.ISelectionService=(0,f.createDecorator)("SelectionService"),c.ICharacterJoinerService=(0,f.createDecorator)("CharacterJoinerService"),c.IThemeService=(0,f.createDecorator)("ThemeService"),c.ILinkProviderService=(0,f.createDecorator)("LinkProviderService")},6731:function(u,c,h){var f=this&&this.__decorate||function(L,A,D,B){var q,W=arguments.length,O=W<3?A:B===null?B=Object.getOwnPropertyDescriptor(A,D):B;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(L,A,D,B);else for(var V=L.length-1;V>=0;V--)(q=L[V])&&(O=(W<3?q(O):W>3?q(A,D,O):q(A,D))||O);return W>3&&O&&Object.defineProperty(A,D,O),O},p=this&&this.__param||function(L,A){return function(D,B){A(D,B,L)}};Object.defineProperty(c,"__esModule",{value:!0}),c.ThemeService=c.DEFAULT_ANSI_COLORS=void 0;const m=h(7239),_=h(8055),x=h(8460),w=h(844),k=h(2585),y=_.css.toColor("#ffffff"),S=_.css.toColor("#000000"),v=_.css.toColor("#ffffff"),b=_.css.toColor("#000000"),E={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};c.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const L=[_.css.toColor("#2e3436"),_.css.toColor("#cc0000"),_.css.toColor("#4e9a06"),_.css.toColor("#c4a000"),_.css.toColor("#3465a4"),_.css.toColor("#75507b"),_.css.toColor("#06989a"),_.css.toColor("#d3d7cf"),_.css.toColor("#555753"),_.css.toColor("#ef2929"),_.css.toColor("#8ae234"),_.css.toColor("#fce94f"),_.css.toColor("#729fcf"),_.css.toColor("#ad7fa8"),_.css.toColor("#34e2e2"),_.css.toColor("#eeeeec")],A=[0,95,135,175,215,255];for(let D=0;D<216;D++){const B=A[D/36%6|0],q=A[D/6%6|0],W=A[D%6];L.push({css:_.channels.toCss(B,q,W),rgba:_.channels.toRgba(B,q,W)})}for(let D=0;D<24;D++){const B=8+10*D;L.push({css:_.channels.toCss(B,B,B),rgba:_.channels.toRgba(B,B,B)})}return L})());let T=c.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(L){super(),this._optionsService=L,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:y,background:S,cursor:v,cursorAccent:b,selectionForeground:void 0,selectionBackgroundTransparent:E,selectionBackgroundOpaque:_.color.blend(S,E),selectionInactiveBackgroundTransparent:E,selectionInactiveBackgroundOpaque:_.color.blend(S,E),ansi:c.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(L={}){const A=this._colors;if(A.foreground=N(L.foreground,y),A.background=N(L.background,S),A.cursor=N(L.cursor,v),A.cursorAccent=N(L.cursorAccent,b),A.selectionBackgroundTransparent=N(L.selectionBackground,E),A.selectionBackgroundOpaque=_.color.blend(A.background,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundTransparent=N(L.selectionInactiveBackground,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundOpaque=_.color.blend(A.background,A.selectionInactiveBackgroundTransparent),A.selectionForeground=L.selectionForeground?N(L.selectionForeground,_.NULL_COLOR):void 0,A.selectionForeground===_.NULL_COLOR&&(A.selectionForeground=void 0),_.color.isOpaque(A.selectionBackgroundTransparent)&&(A.selectionBackgroundTransparent=_.color.opacity(A.selectionBackgroundTransparent,.3)),_.color.isOpaque(A.selectionInactiveBackgroundTransparent)&&(A.selectionInactiveBackgroundTransparent=_.color.opacity(A.selectionInactiveBackgroundTransparent,.3)),A.ansi=c.DEFAULT_ANSI_COLORS.slice(),A.ansi[0]=N(L.black,c.DEFAULT_ANSI_COLORS[0]),A.ansi[1]=N(L.red,c.DEFAULT_ANSI_COLORS[1]),A.ansi[2]=N(L.green,c.DEFAULT_ANSI_COLORS[2]),A.ansi[3]=N(L.yellow,c.DEFAULT_ANSI_COLORS[3]),A.ansi[4]=N(L.blue,c.DEFAULT_ANSI_COLORS[4]),A.ansi[5]=N(L.magenta,c.DEFAULT_ANSI_COLORS[5]),A.ansi[6]=N(L.cyan,c.DEFAULT_ANSI_COLORS[6]),A.ansi[7]=N(L.white,c.DEFAULT_ANSI_COLORS[7]),A.ansi[8]=N(L.brightBlack,c.DEFAULT_ANSI_COLORS[8]),A.ansi[9]=N(L.brightRed,c.DEFAULT_ANSI_COLORS[9]),A.ansi[10]=N(L.brightGreen,c.DEFAULT_ANSI_COLORS[10]),A.ansi[11]=N(L.brightYellow,c.DEFAULT_ANSI_COLORS[11]),A.ansi[12]=N(L.brightBlue,c.DEFAULT_ANSI_COLORS[12]),A.ansi[13]=N(L.brightMagenta,c.DEFAULT_ANSI_COLORS[13]),A.ansi[14]=N(L.brightCyan,c.DEFAULT_ANSI_COLORS[14]),A.ansi[15]=N(L.brightWhite,c.DEFAULT_ANSI_COLORS[15]),L.extendedAnsi){const D=Math.min(A.ansi.length-16,L.extendedAnsi.length);for(let B=0;B<D;B++)A.ansi[B+16]=N(L.extendedAnsi[B],c.DEFAULT_ANSI_COLORS[B+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(L){this._restoreColor(L),this._onChangeColors.fire(this.colors)}_restoreColor(L){if(L!==void 0)switch(L){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[L]=this._restoreColors.ansi[L]}else for(let A=0;A<this._restoreColors.ansi.length;++A)this._colors.ansi[A]=this._restoreColors.ansi[A]}modifyColors(L){L(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function N(L,A){if(L!==void 0)try{return _.css.toColor(L)}catch{}return A}c.ThemeService=T=f([p(0,k.IOptionsService)],T)},6349:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CircularList=void 0;const f=h(8460),p=h(844);class m extends p.Disposable{constructor(x){super(),this._maxLength=x,this.onDeleteEmitter=this.register(new f.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new f.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new f.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 k=0;k<Math.min(x,this.length);k++)w[k]=this._array[this._getCyclicIndex(k)];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,...k){if(w){for(let y=x;y<this._length-w;y++)this._array[this._getCyclicIndex(y)]=this._array[this._getCyclicIndex(y+w)];this._length-=w,this.onDeleteEmitter.fire({index:x,amount:w})}for(let y=this._length-1;y>=x;y--)this._array[this._getCyclicIndex(y+k.length)]=this._array[this._getCyclicIndex(y)];for(let y=0;y<k.length;y++)this._array[this._getCyclicIndex(x+y)]=k[y];if(k.length&&this.onInsertEmitter.fire({index:x,amount:k.length}),this._length+k.length>this._maxLength){const y=this._length+k.length-this._maxLength;this._startIndex+=y,this._length=this._maxLength,this.onTrimEmitter.fire(y)}else this._length+=k.length}trimStart(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,w,k){if(!(w<=0)){if(x<0||x>=this._length)throw new Error("start argument out of range");if(x+k<0)throw new Error("Cannot shift elements in list beyond index 0");if(k>0){for(let S=w-1;S>=0;S--)this.set(x+S+k,this.get(x+S));const y=x+w+k-this._length;if(y>0)for(this._length+=y;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let y=0;y<w;y++)this.set(x+y+k,this.get(x+y))}}_getCyclicIndex(x){return(this._startIndex+x)%this._maxLength}}c.CircularList=m},1439:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.clone=void 0,c.clone=function h(f,p=5){if(typeof f!="object")return f;const m=Array.isArray(f)?[]:{};for(const _ in f)m[_]=p<=1?f[_]:f[_]&&h(f[_],p-1);return m}},8055:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.contrastRatio=c.toPaddedHex=c.rgba=c.rgb=c.css=c.color=c.channels=c.NULL_COLOR=void 0;let h=0,f=0,p=0,m=0;var _,x,w,k,y;function S(b){const E=b.toString(16);return E.length<2?"0"+E:E}function v(b,E){return b<E?(E+.05)/(b+.05):(b+.05)/(E+.05)}c.NULL_COLOR={css:"#00000000",rgba:0},(function(b){b.toCss=function(E,T,N,L){return L!==void 0?`#${S(E)}${S(T)}${S(N)}${S(L)}`:`#${S(E)}${S(T)}${S(N)}`},b.toRgba=function(E,T,N,L=255){return(E<<24|T<<16|N<<8|L)>>>0},b.toColor=function(E,T,N,L){return{css:b.toCss(E,T,N,L),rgba:b.toRgba(E,T,N,L)}}})(_||(c.channels=_={})),(function(b){function E(T,N){return m=Math.round(255*N),[h,f,p]=y.toChannels(T.rgba),{css:_.toCss(h,f,p,m),rgba:_.toRgba(h,f,p,m)}}b.blend=function(T,N){if(m=(255&N.rgba)/255,m===1)return{css:N.css,rgba:N.rgba};const L=N.rgba>>24&255,A=N.rgba>>16&255,D=N.rgba>>8&255,B=T.rgba>>24&255,q=T.rgba>>16&255,W=T.rgba>>8&255;return h=B+Math.round((L-B)*m),f=q+Math.round((A-q)*m),p=W+Math.round((D-W)*m),{css:_.toCss(h,f,p),rgba:_.toRgba(h,f,p)}},b.isOpaque=function(T){return(255&T.rgba)==255},b.ensureContrastRatio=function(T,N,L){const A=y.ensureContrastRatio(T.rgba,N.rgba,L);if(A)return _.toColor(A>>24&255,A>>16&255,A>>8&255)},b.opaque=function(T){const N=(255|T.rgba)>>>0;return[h,f,p]=y.toChannels(N),{css:_.toCss(h,f,p),rgba:N}},b.opacity=E,b.multiplyOpacity=function(T,N){return m=255&T.rgba,E(T,m*N/255)},b.toColorRGB=function(T){return[T.rgba>>24&255,T.rgba>>16&255,T.rgba>>8&255]}})(x||(c.color=x={})),(function(b){let E,T;try{const N=document.createElement("canvas");N.width=1,N.height=1;const L=N.getContext("2d",{willReadFrequently:!0});L&&(E=L,E.globalCompositeOperation="copy",T=E.createLinearGradient(0,0,1,1))}catch{}b.toColor=function(N){if(N.match(/#[\da-f]{3,8}/i))switch(N.length){case 4:return h=parseInt(N.slice(1,2).repeat(2),16),f=parseInt(N.slice(2,3).repeat(2),16),p=parseInt(N.slice(3,4).repeat(2),16),_.toColor(h,f,p);case 5:return h=parseInt(N.slice(1,2).repeat(2),16),f=parseInt(N.slice(2,3).repeat(2),16),p=parseInt(N.slice(3,4).repeat(2),16),m=parseInt(N.slice(4,5).repeat(2),16),_.toColor(h,f,p,m);case 7:return{css:N,rgba:(parseInt(N.slice(1),16)<<8|255)>>>0};case 9:return{css:N,rgba:parseInt(N.slice(1),16)>>>0}}const L=N.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(L)return h=parseInt(L[1]),f=parseInt(L[2]),p=parseInt(L[3]),m=Math.round(255*(L[5]===void 0?1:parseFloat(L[5]))),_.toColor(h,f,p,m);if(!E||!T)throw new Error("css.toColor: Unsupported css format");if(E.fillStyle=T,E.fillStyle=N,typeof E.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(E.fillRect(0,0,1,1),[h,f,p,m]=E.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:_.toRgba(h,f,p,m),css:N}}})(w||(c.css=w={})),(function(b){function E(T,N,L){const A=T/255,D=N/255,B=L/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))+.0722*(B<=.03928?B/12.92:Math.pow((B+.055)/1.055,2.4))}b.relativeLuminance=function(T){return E(T>>16&255,T>>8&255,255&T)},b.relativeLuminance2=E})(k||(c.rgb=k={})),(function(b){function E(N,L,A){const D=N>>24&255,B=N>>16&255,q=N>>8&255;let W=L>>24&255,O=L>>16&255,V=L>>8&255,G=v(k.relativeLuminance2(W,O,V),k.relativeLuminance2(D,B,q));for(;G<A&&(W>0||O>0||V>0);)W-=Math.max(0,Math.ceil(.1*W)),O-=Math.max(0,Math.ceil(.1*O)),V-=Math.max(0,Math.ceil(.1*V)),G=v(k.relativeLuminance2(W,O,V),k.relativeLuminance2(D,B,q));return(W<<24|O<<16|V<<8|255)>>>0}function T(N,L,A){const D=N>>24&255,B=N>>16&255,q=N>>8&255;let W=L>>24&255,O=L>>16&255,V=L>>8&255,G=v(k.relativeLuminance2(W,O,V),k.relativeLuminance2(D,B,q));for(;G<A&&(W<255||O<255||V<255);)W=Math.min(255,W+Math.ceil(.1*(255-W))),O=Math.min(255,O+Math.ceil(.1*(255-O))),V=Math.min(255,V+Math.ceil(.1*(255-V))),G=v(k.relativeLuminance2(W,O,V),k.relativeLuminance2(D,B,q));return(W<<24|O<<16|V<<8|255)>>>0}b.blend=function(N,L){if(m=(255&L)/255,m===1)return L;const A=L>>24&255,D=L>>16&255,B=L>>8&255,q=N>>24&255,W=N>>16&255,O=N>>8&255;return h=q+Math.round((A-q)*m),f=W+Math.round((D-W)*m),p=O+Math.round((B-O)*m),_.toRgba(h,f,p)},b.ensureContrastRatio=function(N,L,A){const D=k.relativeLuminance(N>>8),B=k.relativeLuminance(L>>8);if(v(D,B)<A){if(B<D){const O=E(N,L,A),V=v(D,k.relativeLuminance(O>>8));if(V<A){const G=T(N,L,A);return V>v(D,k.relativeLuminance(G>>8))?O:G}return O}const q=T(N,L,A),W=v(D,k.relativeLuminance(q>>8));if(W<A){const O=E(N,L,A);return W>v(D,k.relativeLuminance(O>>8))?q:O}return q}},b.reduceLuminance=E,b.increaseLuminance=T,b.toChannels=function(N){return[N>>24&255,N>>16&255,N>>8&255,255&N]}})(y||(c.rgba=y={})),c.toPaddedHex=S,c.contrastRatio=v},8969:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreTerminal=void 0;const f=h(844),p=h(2585),m=h(4348),_=h(7866),x=h(744),w=h(7302),k=h(6975),y=h(8460),S=h(1753),v=h(1480),b=h(7994),E=h(9282),T=h(5435),N=h(5981),L=h(2660);let A=!1;class D extends f.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new y.EventEmitter),this._onScroll.event((q=>{var W;(W=this._onScrollApi)==null||W.fire(q.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(q){for(const W in q)this.optionsService.options[W]=q[W]}constructor(q){super(),this._windowsWrappingHeuristics=this.register(new f.MutableDisposable),this._onBinary=this.register(new y.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new y.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new y.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new y.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new y.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new y.EventEmitter),this._instantiationService=new m.InstantiationService,this.optionsService=this.register(new w.OptionsService(q)),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(_.LogService)),this._instantiationService.setService(p.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(k.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(v.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(L.OscLinkService),this._instantiationService.setService(p.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new T.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,y.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,y.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,y.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,y.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((W=>{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((W=>{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 N.WriteBuffer(((W,O)=>this._inputHandler.parse(W,O)))),this.register((0,y.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(q,W){this._writeBuffer.write(q,W)}writeSync(q,W){this._logService.logLevel<=p.LogLevelEnum.WARN&&!A&&(this._logService.warn("writeSync is unreliable and will be removed soon."),A=!0),this._writeBuffer.writeSync(q,W)}input(q,W=!0){this.coreService.triggerDataEvent(q,W)}resize(q,W){isNaN(q)||isNaN(W)||(q=Math.max(q,x.MINIMUM_COLS),W=Math.max(W,x.MINIMUM_ROWS),this._bufferService.resize(q,W))}scroll(q,W=!1){this._bufferService.scroll(q,W)}scrollLines(q,W,O){this._bufferService.scrollLines(q,W,O)}scrollPages(q){this.scrollLines(q*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(q){const W=q-this._bufferService.buffer.ydisp;W!==0&&this.scrollLines(W)}registerEscHandler(q,W){return this._inputHandler.registerEscHandler(q,W)}registerDcsHandler(q,W){return this._inputHandler.registerDcsHandler(q,W)}registerCsiHandler(q,W){return this._inputHandler.registerCsiHandler(q,W)}registerOscHandler(q,W){return this._inputHandler.registerOscHandler(q,W)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let q=!1;const W=this.optionsService.rawOptions.windowsPty;W&&W.buildNumber!==void 0&&W.buildNumber!==void 0?q=W.backend==="conpty"&&W.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(q=!0),q?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const q=[];q.push(this.onLineFeed(E.updateWindowsModeWrappedState.bind(null,this._bufferService))),q.push(this.registerCsiHandler({final:"H"},(()=>((0,E.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,f.toDisposable)((()=>{for(const W of q)W.dispose()}))}}}c.CoreTerminal=D},8460:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.runAndSubscribe=c.forwardEvent=c.EventEmitter=void 0,c.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=h=>(this._listeners.push(h),{dispose:()=>{if(!this._disposed){for(let f=0;f<this._listeners.length;f++)if(this._listeners[f]===h)return void this._listeners.splice(f,1)}}})),this._event}fire(h,f){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,h,f)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},c.forwardEvent=function(h,f){return h((p=>f.fire(p)))},c.runAndSubscribe=function(h,f){return f(void 0),h((p=>f(p)))}},5435:function(u,c,h){var f=this&&this.__decorate||function(ne,F,M,$){var P,U=arguments.length,J=U<3?F:$===null?$=Object.getOwnPropertyDescriptor(F,M):$;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")J=Reflect.decorate(ne,F,M,$);else for(var Q=ne.length-1;Q>=0;Q--)(P=ne[Q])&&(J=(U<3?P(J):U>3?P(F,M,J):P(F,M))||J);return U>3&&J&&Object.defineProperty(F,M,J),J},p=this&&this.__param||function(ne,F){return function(M,$){F(M,$,ne)}};Object.defineProperty(c,"__esModule",{value:!0}),c.InputHandler=c.WindowsOptionsReportType=void 0;const m=h(2584),_=h(7116),x=h(2015),w=h(844),k=h(482),y=h(8437),S=h(8460),v=h(643),b=h(511),E=h(3734),T=h(2585),N=h(1480),L=h(6242),A=h(6351),D=h(5941),B={"(":0,")":1,"*":2,"+":3,"-":1,".":2},q=131072;function W(ne,F){if(ne>24)return F.setWinLines||!1;switch(ne){case 1:return!!F.restoreWin;case 2:return!!F.minimizeWin;case 3:return!!F.setWinPosition;case 4:return!!F.setWinSizePixels;case 5:return!!F.raiseWin;case 6:return!!F.lowerWin;case 7:return!!F.refreshWin;case 8:return!!F.setWinSizeChars;case 9:return!!F.maximizeWin;case 10:return!!F.fullscreenWin;case 11:return!!F.getWinState;case 13:return!!F.getWinPosition;case 14:return!!F.getWinSizePixels;case 15:return!!F.getScreenSizePixels;case 16:return!!F.getCellSizePixels;case 18:return!!F.getWinSizeChars;case 19:return!!F.getScreenSizeChars;case 20:return!!F.getIconTitle;case 21:return!!F.getWinTitle;case 22:return!!F.pushTitle;case 23:return!!F.popTitle;case 24:return!!F.setWinLines}return!1}var O;(function(ne){ne[ne.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",ne[ne.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(O||(c.WindowsOptionsReportType=O={}));let V=0;class G extends w.Disposable{getAttrData(){return this._curAttrData}constructor(F,M,$,P,U,J,Q,se,Y=new x.EscapeSequenceParser){super(),this._bufferService=F,this._charsetService=M,this._coreService=$,this._logService=P,this._optionsService=U,this._oscLinkService=J,this._coreMouseService=Q,this._unicodeService=se,this._parser=Y,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new k.StringToUtf32,this._utf8Decoder=new k.Utf8ToUtf32,this._workCell=new b.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=y.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=y.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 z(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((H=>this._activeBuffer=H.activeBuffer))),this._parser.setCsiHandlerFallback(((H,ee)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(H),params:ee.toArray()})})),this._parser.setEscHandlerFallback((H=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(H)})})),this._parser.setExecuteHandlerFallback((H=>{this._logService.debug("Unknown EXECUTE code: ",{code:H})})),this._parser.setOscHandlerFallback(((H,ee,te)=>{this._logService.debug("Unknown OSC code: ",{identifier:H,action:ee,data:te})})),this._parser.setDcsHandlerFallback(((H,ee,te)=>{ee==="HOOK"&&(te=te.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(H),action:ee,payload:te})})),this._parser.setPrintHandler(((H,ee,te)=>this.print(H,ee,te))),this._parser.registerCsiHandler({final:"@"},(H=>this.insertChars(H))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(H=>this.scrollLeft(H))),this._parser.registerCsiHandler({final:"A"},(H=>this.cursorUp(H))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(H=>this.scrollRight(H))),this._parser.registerCsiHandler({final:"B"},(H=>this.cursorDown(H))),this._parser.registerCsiHandler({final:"C"},(H=>this.cursorForward(H))),this._parser.registerCsiHandler({final:"D"},(H=>this.cursorBackward(H))),this._parser.registerCsiHandler({final:"E"},(H=>this.cursorNextLine(H))),this._parser.registerCsiHandler({final:"F"},(H=>this.cursorPrecedingLine(H))),this._parser.registerCsiHandler({final:"G"},(H=>this.cursorCharAbsolute(H))),this._parser.registerCsiHandler({final:"H"},(H=>this.cursorPosition(H))),this._parser.registerCsiHandler({final:"I"},(H=>this.cursorForwardTab(H))),this._parser.registerCsiHandler({final:"J"},(H=>this.eraseInDisplay(H,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(H=>this.eraseInDisplay(H,!0))),this._parser.registerCsiHandler({final:"K"},(H=>this.eraseInLine(H,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(H=>this.eraseInLine(H,!0))),this._parser.registerCsiHandler({final:"L"},(H=>this.insertLines(H))),this._parser.registerCsiHandler({final:"M"},(H=>this.deleteLines(H))),this._parser.registerCsiHandler({final:"P"},(H=>this.deleteChars(H))),this._parser.registerCsiHandler({final:"S"},(H=>this.scrollUp(H))),this._parser.registerCsiHandler({final:"T"},(H=>this.scrollDown(H))),this._parser.registerCsiHandler({final:"X"},(H=>this.eraseChars(H))),this._parser.registerCsiHandler({final:"Z"},(H=>this.cursorBackwardTab(H))),this._parser.registerCsiHandler({final:"`"},(H=>this.charPosAbsolute(H))),this._parser.registerCsiHandler({final:"a"},(H=>this.hPositionRelative(H))),this._parser.registerCsiHandler({final:"b"},(H=>this.repeatPrecedingCharacter(H))),this._parser.registerCsiHandler({final:"c"},(H=>this.sendDeviceAttributesPrimary(H))),this._parser.registerCsiHandler({prefix:">",final:"c"},(H=>this.sendDeviceAttributesSecondary(H))),this._parser.registerCsiHandler({final:"d"},(H=>this.linePosAbsolute(H))),this._parser.registerCsiHandler({final:"e"},(H=>this.vPositionRelative(H))),this._parser.registerCsiHandler({final:"f"},(H=>this.hVPosition(H))),this._parser.registerCsiHandler({final:"g"},(H=>this.tabClear(H))),this._parser.registerCsiHandler({final:"h"},(H=>this.setMode(H))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(H=>this.setModePrivate(H))),this._parser.registerCsiHandler({final:"l"},(H=>this.resetMode(H))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(H=>this.resetModePrivate(H))),this._parser.registerCsiHandler({final:"m"},(H=>this.charAttributes(H))),this._parser.registerCsiHandler({final:"n"},(H=>this.deviceStatus(H))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(H=>this.deviceStatusPrivate(H))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(H=>this.softReset(H))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(H=>this.setCursorStyle(H))),this._parser.registerCsiHandler({final:"r"},(H=>this.setScrollRegion(H))),this._parser.registerCsiHandler({final:"s"},(H=>this.saveCursor(H))),this._parser.registerCsiHandler({final:"t"},(H=>this.windowOptions(H))),this._parser.registerCsiHandler({final:"u"},(H=>this.restoreCursor(H))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(H=>this.insertColumns(H))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(H=>this.deleteColumns(H))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(H=>this.selectProtected(H))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(H=>this.requestMode(H,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(H=>this.requestMode(H,!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 L.OscHandler((H=>(this.setTitle(H),this.setIconName(H),!0)))),this._parser.registerOscHandler(1,new L.OscHandler((H=>this.setIconName(H)))),this._parser.registerOscHandler(2,new L.OscHandler((H=>this.setTitle(H)))),this._parser.registerOscHandler(4,new L.OscHandler((H=>this.setOrReportIndexedColor(H)))),this._parser.registerOscHandler(8,new L.OscHandler((H=>this.setHyperlink(H)))),this._parser.registerOscHandler(10,new L.OscHandler((H=>this.setOrReportFgColor(H)))),this._parser.registerOscHandler(11,new L.OscHandler((H=>this.setOrReportBgColor(H)))),this._parser.registerOscHandler(12,new L.OscHandler((H=>this.setOrReportCursorColor(H)))),this._parser.registerOscHandler(104,new L.OscHandler((H=>this.restoreIndexedColor(H)))),this._parser.registerOscHandler(110,new L.OscHandler((H=>this.restoreFgColor(H)))),this._parser.registerOscHandler(111,new L.OscHandler((H=>this.restoreBgColor(H)))),this._parser.registerOscHandler(112,new L.OscHandler((H=>this.restoreCursorColor(H)))),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 H in _.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:H},(()=>this.selectCharset("("+H))),this._parser.registerEscHandler({intermediates:")",final:H},(()=>this.selectCharset(")"+H))),this._parser.registerEscHandler({intermediates:"*",final:H},(()=>this.selectCharset("*"+H))),this._parser.registerEscHandler({intermediates:"+",final:H},(()=>this.selectCharset("+"+H))),this._parser.registerEscHandler({intermediates:"-",final:H},(()=>this.selectCharset("-"+H))),this._parser.registerEscHandler({intermediates:".",final:H},(()=>this.selectCharset("."+H))),this._parser.registerEscHandler({intermediates:"/",final:H},(()=>this.selectCharset("/"+H)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((H=>(this._logService.error("Parsing error: ",H),H))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new A.DcsHandler(((H,ee)=>this.requestStatusString(H,ee))))}_preserveStack(F,M,$,P){this._parseStack.paused=!0,this._parseStack.cursorStartX=F,this._parseStack.cursorStartY=M,this._parseStack.decodedLength=$,this._parseStack.position=P}_logSlowResolvingAsync(F){this._logService.logLevel<=T.LogLevelEnum.WARN&&Promise.race([F,new Promise(((M,$)=>setTimeout((()=>$("#SLOW_TIMEOUT")),5e3)))]).catch((M=>{if(M!=="#SLOW_TIMEOUT")throw M;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(F,M){let $,P=this._activeBuffer.x,U=this._activeBuffer.y,J=0;const Q=this._parseStack.paused;if(Q){if($=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,M))return this._logSlowResolvingAsync($),$;P=this._parseStack.cursorStartX,U=this._parseStack.cursorStartY,this._parseStack.paused=!1,F.length>q&&(J=this._parseStack.position+q)}if(this._logService.logLevel<=T.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof F=="string"?` "${F}"`:` "${Array.prototype.map.call(F,(H=>String.fromCharCode(H))).join("")}"`),typeof F=="string"?F.split("").map((H=>H.charCodeAt(0))):F),this._parseBuffer.length<F.length&&this._parseBuffer.length<q&&(this._parseBuffer=new Uint32Array(Math.min(F.length,q))),Q||this._dirtyRowTracker.clearRange(),F.length>q)for(let H=J;H<F.length;H+=q){const ee=H+q<F.length?H+q:F.length,te=typeof F=="string"?this._stringDecoder.decode(F.substring(H,ee),this._parseBuffer):this._utf8Decoder.decode(F.subarray(H,ee),this._parseBuffer);if($=this._parser.parse(this._parseBuffer,te))return this._preserveStack(P,U,te,H),this._logSlowResolvingAsync($),$}else if(!Q){const H=typeof F=="string"?this._stringDecoder.decode(F,this._parseBuffer):this._utf8Decoder.decode(F,this._parseBuffer);if($=this._parser.parse(this._parseBuffer,H))return this._preserveStack(P,U,H,0),this._logSlowResolvingAsync($),$}this._activeBuffer.x===P&&this._activeBuffer.y===U||this._onCursorMove.fire();const se=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),Y=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);Y<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(Y,this._bufferService.rows-1),Math.min(se,this._bufferService.rows-1))}print(F,M,$){let P,U;const J=this._charsetService.charset,Q=this._optionsService.rawOptions.screenReaderMode,se=this._bufferService.cols,Y=this._coreService.decPrivateModes.wraparound,H=this._coreService.modes.insertMode,ee=this._curAttrData;let te=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&$-M>0&&te.getWidth(this._activeBuffer.x-1)===2&&te.setCellFromCodepoint(this._activeBuffer.x-1,0,1,ee);let ce=this._parser.precedingJoinState;for(let he=M;he<$;++he){if(P=F[he],P<127&&J){const Pe=J[String.fromCharCode(P)];Pe&&(P=Pe.charCodeAt(0))}const Te=this._unicodeService.charProperties(P,ce);U=N.UnicodeService.extractWidth(Te);const Ae=N.UnicodeService.extractShouldJoin(Te),Le=Ae?N.UnicodeService.extractWidth(ce):0;if(ce=Te,Q&&this._onA11yChar.fire((0,k.stringFromCodePoint)(P)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+U-Le>se){if(Y){const Pe=te;let de=this._activeBuffer.x-Le;for(this._activeBuffer.x=Le,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),te=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),Le>0&&te instanceof y.BufferLine&&te.copyCellsFrom(Pe,de,0,Le,!1);de<se;)Pe.setCellFromCodepoint(de++,0,1,ee)}else if(this._activeBuffer.x=se-1,U===2)continue}if(Ae&&this._activeBuffer.x){const Pe=te.getWidth(this._activeBuffer.x-1)?1:2;te.addCodepointToCell(this._activeBuffer.x-Pe,P,U);for(let de=U-Le;--de>=0;)te.setCellFromCodepoint(this._activeBuffer.x++,0,0,ee)}else if(H&&(te.insertCells(this._activeBuffer.x,U-Le,this._activeBuffer.getNullCell(ee)),te.getWidth(se-1)===2&&te.setCellFromCodepoint(se-1,v.NULL_CELL_CODE,v.NULL_CELL_WIDTH,ee)),te.setCellFromCodepoint(this._activeBuffer.x++,P,U,ee),U>0)for(;--U;)te.setCellFromCodepoint(this._activeBuffer.x++,0,0,ee)}this._parser.precedingJoinState=ce,this._activeBuffer.x<se&&$-M>0&&te.getWidth(this._activeBuffer.x)===0&&!te.hasContent(this._activeBuffer.x)&&te.setCellFromCodepoint(this._activeBuffer.x,0,1,ee),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(F,M){return F.final!=="t"||F.prefix||F.intermediates?this._parser.registerCsiHandler(F,M):this._parser.registerCsiHandler(F,($=>!W($.params[0],this._optionsService.rawOptions.windowOptions)||M($)))}registerDcsHandler(F,M){return this._parser.registerDcsHandler(F,new A.DcsHandler(M))}registerEscHandler(F,M){return this._parser.registerEscHandler(F,M)}registerOscHandler(F,M){return this._parser.registerOscHandler(F,new L.OscHandler(M))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var F;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((F=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&F.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);M.hasWidth(this._activeBuffer.x)&&!M.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const F=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-F),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(F=this._bufferService.cols-1){this._activeBuffer.x=Math.min(F,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(F,M){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=F,this._activeBuffer.y=this._activeBuffer.scrollTop+M):(this._activeBuffer.x=F,this._activeBuffer.y=M),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(F,M){this._restrictCursor(),this._setCursor(this._activeBuffer.x+F,this._activeBuffer.y+M)}cursorUp(F){const M=this._activeBuffer.y-this._activeBuffer.scrollTop;return M>=0?this._moveCursor(0,-Math.min(M,F.params[0]||1)):this._moveCursor(0,-(F.params[0]||1)),!0}cursorDown(F){const M=this._activeBuffer.scrollBottom-this._activeBuffer.y;return M>=0?this._moveCursor(0,Math.min(M,F.params[0]||1)):this._moveCursor(0,F.params[0]||1),!0}cursorForward(F){return this._moveCursor(F.params[0]||1,0),!0}cursorBackward(F){return this._moveCursor(-(F.params[0]||1),0),!0}cursorNextLine(F){return this.cursorDown(F),this._activeBuffer.x=0,!0}cursorPrecedingLine(F){return this.cursorUp(F),this._activeBuffer.x=0,!0}cursorCharAbsolute(F){return this._setCursor((F.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(F){return this._setCursor(F.length>=2?(F.params[1]||1)-1:0,(F.params[0]||1)-1),!0}charPosAbsolute(F){return this._setCursor((F.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(F){return this._moveCursor(F.params[0]||1,0),!0}linePosAbsolute(F){return this._setCursor(this._activeBuffer.x,(F.params[0]||1)-1),!0}vPositionRelative(F){return this._moveCursor(0,F.params[0]||1),!0}hVPosition(F){return this.cursorPosition(F),!0}tabClear(F){const M=F.params[0];return M===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:M===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(F){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=F.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(F){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=F.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(F){const M=F.params[0];return M===1&&(this._curAttrData.bg|=536870912),M!==2&&M!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(F,M,$,P=!1,U=!1){const J=this._activeBuffer.lines.get(this._activeBuffer.ybase+F);J.replaceCells(M,$,this._activeBuffer.getNullCell(this._eraseAttrData()),U),P&&(J.isWrapped=!1)}_resetBufferLine(F,M=!1){const $=this._activeBuffer.lines.get(this._activeBuffer.ybase+F);$&&($.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),M),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+F),$.isWrapped=!1)}eraseInDisplay(F,M=!1){let $;switch(this._restrictCursor(this._bufferService.cols),F.params[0]){case 0:for($=this._activeBuffer.y,this._dirtyRowTracker.markDirty($),this._eraseInBufferLine($++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);$<this._bufferService.rows;$++)this._resetBufferLine($,M);this._dirtyRowTracker.markDirty($);break;case 1:for($=this._activeBuffer.y,this._dirtyRowTracker.markDirty($),this._eraseInBufferLine($,0,this._activeBuffer.x+1,!0,M),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get($+1).isWrapped=!1);$--;)this._resetBufferLine($,M);this._dirtyRowTracker.markDirty(0);break;case 2:for($=this._bufferService.rows,this._dirtyRowTracker.markDirty($-1);$--;)this._resetBufferLine($,M);this._dirtyRowTracker.markDirty(0);break;case 3:const P=this._activeBuffer.lines.length-this._bufferService.rows;P>0&&(this._activeBuffer.lines.trimStart(P),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-P,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-P,0),this._onScroll.fire(0))}return!0}eraseInLine(F,M=!1){switch(this._restrictCursor(this._bufferService.cols),F.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,M);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,M)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(F){this._restrictCursor();let M=F.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const $=this._activeBuffer.ybase+this._activeBuffer.y,P=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-P+1;for(;M--;)this._activeBuffer.lines.splice(U-1,1),this._activeBuffer.lines.splice($,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(F){this._restrictCursor();let M=F.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const $=this._activeBuffer.ybase+this._activeBuffer.y;let P;for(P=this._bufferService.rows-1-this._activeBuffer.scrollBottom,P=this._bufferService.rows-1+this._activeBuffer.ybase-P;M--;)this._activeBuffer.lines.splice($,1),this._activeBuffer.lines.splice(P,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(F){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.insertCells(this._activeBuffer.x,F.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(F){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.deleteCells(this._activeBuffer.x,F.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(F){let M=F.params[0]||1;for(;M--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(F){let M=F.params[0]||1;for(;M--;)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(y.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(F){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=F.params[0]||1;for(let $=this._activeBuffer.scrollTop;$<=this._activeBuffer.scrollBottom;++$){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);P.deleteCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData())),P.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(F){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=F.params[0]||1;for(let $=this._activeBuffer.scrollTop;$<=this._activeBuffer.scrollBottom;++$){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);P.insertCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData())),P.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(F){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=F.params[0]||1;for(let $=this._activeBuffer.scrollTop;$<=this._activeBuffer.scrollBottom;++$){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);P.insertCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData())),P.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(F){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=F.params[0]||1;for(let $=this._activeBuffer.scrollTop;$<=this._activeBuffer.scrollBottom;++$){const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);P.deleteCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData())),P.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(F){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(F.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(F){const M=this._parser.precedingJoinState;if(!M)return!0;const $=F.params[0]||1,P=N.UnicodeService.extractWidth(M),U=this._activeBuffer.x-P,J=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(U),Q=new Uint32Array(J.length*$);let se=0;for(let H=0;H<J.length;){const ee=J.codePointAt(H)||0;Q[se++]=ee,H+=ee>65535?2:1}let Y=se;for(let H=1;H<$;++H)Q.copyWithin(Y,0,se),Y+=se;return this.print(Q,0,Y),!0}sendDeviceAttributesPrimary(F){return F.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(m.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(m.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(F){return F.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(m.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(m.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(F.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(m.C0.ESC+"[>83;40003;0c")),!0}_is(F){return(this._optionsService.rawOptions.termName+"").indexOf(F)===0}setMode(F){for(let M=0;M<F.length;M++)switch(F.params[M]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(F){for(let M=0;M<F.length;M++)switch(F.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,_.DEFAULT_CHARSET),this._charsetService.setgCharset(1,_.DEFAULT_CHARSET),this._charsetService.setgCharset(2,_.DEFAULT_CHARSET),this._charsetService.setgCharset(3,_.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(F){for(let M=0;M<F.length;M++)switch(F.params[M]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(F){for(let M=0;M<F.length;M++)switch(F.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),F.params[M]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(F,M){const $=this._coreService.decPrivateModes,{activeProtocol:P,activeEncoding:U}=this._coreMouseService,J=this._coreService,{buffers:Q,cols:se}=this._bufferService,{active:Y,alt:H}=Q,ee=this._optionsService.rawOptions,te=Ae=>Ae?1:2,ce=F.params[0];return he=ce,Te=M?ce===2?4:ce===4?te(J.modes.insertMode):ce===12?3:ce===20?te(ee.convertEol):0:ce===1?te($.applicationCursorKeys):ce===3?ee.windowOptions.setWinLines?se===80?2:se===132?1:0:0:ce===6?te($.origin):ce===7?te($.wraparound):ce===8?3:ce===9?te(P==="X10"):ce===12?te(ee.cursorBlink):ce===25?te(!J.isCursorHidden):ce===45?te($.reverseWraparound):ce===66?te($.applicationKeypad):ce===67?4:ce===1e3?te(P==="VT200"):ce===1002?te(P==="DRAG"):ce===1003?te(P==="ANY"):ce===1004?te($.sendFocus):ce===1005?4:ce===1006?te(U==="SGR"):ce===1015?4:ce===1016?te(U==="SGR_PIXELS"):ce===1048?1:ce===47||ce===1047||ce===1049?te(Y===H):ce===2004?te($.bracketedPasteMode):0,J.triggerDataEvent(`${m.C0.ESC}[${M?"":"?"}${he};${Te}$y`),!0;var he,Te}_updateAttrColor(F,M,$,P,U){return M===2?(F|=50331648,F&=-16777216,F|=E.AttributeData.fromColorRGB([$,P,U])):M===5&&(F&=-50331904,F|=33554432|255&$),F}_extractColor(F,M,$){const P=[0,0,-1,0,0,0];let U=0,J=0;do{if(P[J+U]=F.params[M+J],F.hasSubParams(M+J)){const Q=F.getSubParams(M+J);let se=0;do P[1]===5&&(U=1),P[J+se+1+U]=Q[se];while(++se<Q.length&&se+J+1+U<P.length);break}if(P[1]===5&&J+U>=2||P[1]===2&&J+U>=5)break;P[1]&&(U=1)}while(++J+M<F.length&&J+U<P.length);for(let Q=2;Q<P.length;++Q)P[Q]===-1&&(P[Q]=0);switch(P[0]){case 38:$.fg=this._updateAttrColor($.fg,P[1],P[3],P[4],P[5]);break;case 48:$.bg=this._updateAttrColor($.bg,P[1],P[3],P[4],P[5]);break;case 58:$.extended=$.extended.clone(),$.extended.underlineColor=this._updateAttrColor($.extended.underlineColor,P[1],P[3],P[4],P[5])}return J}_processUnderline(F,M){M.extended=M.extended.clone(),(!~F||F>5)&&(F=1),M.extended.underlineStyle=F,M.fg|=268435456,F===0&&(M.fg&=-268435457),M.updateExtended()}_processSGR0(F){F.fg=y.DEFAULT_ATTR_DATA.fg,F.bg=y.DEFAULT_ATTR_DATA.bg,F.extended=F.extended.clone(),F.extended.underlineStyle=0,F.extended.underlineColor&=-67108864,F.updateExtended()}charAttributes(F){if(F.length===1&&F.params[0]===0)return this._processSGR0(this._curAttrData),!0;const M=F.length;let $;const P=this._curAttrData;for(let U=0;U<M;U++)$=F.params[U],$>=30&&$<=37?(P.fg&=-50331904,P.fg|=16777216|$-30):$>=40&&$<=47?(P.bg&=-50331904,P.bg|=16777216|$-40):$>=90&&$<=97?(P.fg&=-50331904,P.fg|=16777224|$-90):$>=100&&$<=107?(P.bg&=-50331904,P.bg|=16777224|$-100):$===0?this._processSGR0(P):$===1?P.fg|=134217728:$===3?P.bg|=67108864:$===4?(P.fg|=268435456,this._processUnderline(F.hasSubParams(U)?F.getSubParams(U)[0]:1,P)):$===5?P.fg|=536870912:$===7?P.fg|=67108864:$===8?P.fg|=1073741824:$===9?P.fg|=2147483648:$===2?P.bg|=134217728:$===21?this._processUnderline(2,P):$===22?(P.fg&=-134217729,P.bg&=-134217729):$===23?P.bg&=-67108865:$===24?(P.fg&=-268435457,this._processUnderline(0,P)):$===25?P.fg&=-536870913:$===27?P.fg&=-67108865:$===28?P.fg&=-1073741825:$===29?P.fg&=2147483647:$===39?(P.fg&=-67108864,P.fg|=16777215&y.DEFAULT_ATTR_DATA.fg):$===49?(P.bg&=-67108864,P.bg|=16777215&y.DEFAULT_ATTR_DATA.bg):$===38||$===48||$===58?U+=this._extractColor(F,U,P):$===53?P.bg|=1073741824:$===55?P.bg&=-1073741825:$===59?(P.extended=P.extended.clone(),P.extended.underlineColor=-1,P.updateExtended()):$===100?(P.fg&=-67108864,P.fg|=16777215&y.DEFAULT_ATTR_DATA.fg,P.bg&=-67108864,P.bg|=16777215&y.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",$);return!0}deviceStatus(F){switch(F.params[0]){case 5:this._coreService.triggerDataEvent(`${m.C0.ESC}[0n`);break;case 6:const M=this._activeBuffer.y+1,$=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[${M};${$}R`)}return!0}deviceStatusPrivate(F){if(F.params[0]===6){const M=this._activeBuffer.y+1,$=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[?${M};${$}R`)}return!0}softReset(F){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=y.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(F){const M=F.params[0]||1;switch(M){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 $=M%2==1;return this._optionsService.options.cursorBlink=$,!0}setScrollRegion(F){const M=F.params[0]||1;let $;return(F.length<2||($=F.params[1])>this._bufferService.rows||$===0)&&($=this._bufferService.rows),$>M&&(this._activeBuffer.scrollTop=M-1,this._activeBuffer.scrollBottom=$-1,this._setCursor(0,0)),!0}windowOptions(F){if(!W(F.params[0],this._optionsService.rawOptions.windowOptions))return!0;const M=F.length>1?F.params[1]:0;switch(F.params[0]){case 14:M!==2&&this._onRequestWindowsOptionsReport.fire(O.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(O.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:M!==0&&M!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),M!==0&&M!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:M!==0&&M!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),M!==0&&M!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(F){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(F){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(F){return this._windowTitle=F,this._onTitleChange.fire(F),!0}setIconName(F){return this._iconName=F,!0}setOrReportIndexedColor(F){const M=[],$=F.split(";");for(;$.length>1;){const P=$.shift(),U=$.shift();if(/^\d+$/.exec(P)){const J=parseInt(P);if(X(J))if(U==="?")M.push({type:0,index:J});else{const Q=(0,D.parseColor)(U);Q&&M.push({type:1,index:J,color:Q})}}}return M.length&&this._onColor.fire(M),!0}setHyperlink(F){const M=F.split(";");return!(M.length<2)&&(M[1]?this._createHyperlink(M[0],M[1]):!M[0]&&this._finishHyperlink())}_createHyperlink(F,M){this._getCurrentLinkId()&&this._finishHyperlink();const $=F.split(":");let P;const U=$.findIndex((J=>J.startsWith("id=")));return U!==-1&&(P=$[U].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:P,uri:M}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(F,M){const $=F.split(";");for(let P=0;P<$.length&&!(M>=this._specialColors.length);++P,++M)if($[P]==="?")this._onColor.fire([{type:0,index:this._specialColors[M]}]);else{const U=(0,D.parseColor)($[P]);U&&this._onColor.fire([{type:1,index:this._specialColors[M],color:U}])}return!0}setOrReportFgColor(F){return this._setOrReportSpecialColor(F,0)}setOrReportBgColor(F){return this._setOrReportSpecialColor(F,1)}setOrReportCursorColor(F){return this._setOrReportSpecialColor(F,2)}restoreIndexedColor(F){if(!F)return this._onColor.fire([{type:2}]),!0;const M=[],$=F.split(";");for(let P=0;P<$.length;++P)if(/^\d+$/.exec($[P])){const U=parseInt($[P]);X(U)&&M.push({type:2,index:U})}return M.length&&this._onColor.fire(M),!0}restoreFgColor(F){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(F){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(F){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,_.DEFAULT_CHARSET),!0}selectCharset(F){return F.length!==2?(this.selectDefaultCharset(),!0):(F[0]==="/"||this._charsetService.setgCharset(B[F[0]],_.CHARSETS[F[1]]||_.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const F=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,F,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=y.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=y.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(F){return this._charsetService.setgLevel(F),!0}screenAlignmentPattern(){const F=new b.CellData;F.content=4194373,F.fg=this._curAttrData.fg,F.bg=this._curAttrData.bg,this._setCursor(0,0);for(let M=0;M<this._bufferService.rows;++M){const $=this._activeBuffer.ybase+this._activeBuffer.y+M,P=this._activeBuffer.lines.get($);P&&(P.fill(F),P.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(F,M){const $=this._bufferService.buffer,P=this._optionsService.rawOptions;return(U=>(this._coreService.triggerDataEvent(`${m.C0.ESC}${U}${m.C0.ESC}\\`),!0))(F==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:F==='"p'?'P1$r61;1"p':F==="r"?`P1$r${$.scrollTop+1};${$.scrollBottom+1}r`:F==="m"?"P1$r0m":F===" q"?`P1$r${{block:2,underline:4,bar:6}[P.cursorStyle]-(P.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(F,M){this._dirtyRowTracker.markRangeDirty(F,M)}}c.InputHandler=G;let z=class{constructor(ne){this._bufferService=ne,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(ne){ne<this.start?this.start=ne:ne>this.end&&(this.end=ne)}markRangeDirty(ne,F){ne>F&&(V=ne,ne=F,F=V),ne<this.start&&(this.start=ne),F>this.end&&(this.end=F)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function X(ne){return 0<=ne&&ne<256}z=f([p(0,T.IBufferService)],z)},844:(u,c)=>{function h(f){for(const p of f)p.dispose();f.length=0}Object.defineProperty(c,"__esModule",{value:!0}),c.getDisposeArrayDisposable=c.disposeArray=c.toDisposable=c.MutableDisposable=c.Disposable=void 0,c.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const f of this._disposables)f.dispose();this._disposables.length=0}register(f){return this._disposables.push(f),f}unregister(f){const p=this._disposables.indexOf(f);p!==-1&&this._disposables.splice(p,1)}},c.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(f){var p;this._isDisposed||f===this._value||((p=this._value)==null||p.dispose(),this._value=f)}clear(){this.value=void 0}dispose(){var f;this._isDisposed=!0,(f=this._value)==null||f.dispose(),this._value=void 0}},c.toDisposable=function(f){return{dispose:f}},c.disposeArray=h,c.getDisposeArrayDisposable=function(f){return{dispose:()=>h(f)}}},1505:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.FourKeyMap=c.TwoKeyMap=void 0;class h{constructor(){this._data={}}set(p,m,_){this._data[p]||(this._data[p]={}),this._data[p][m]=_}get(p,m){return this._data[p]?this._data[p][m]:void 0}clear(){this._data={}}}c.TwoKeyMap=h,c.FourKeyMap=class{constructor(){this._data=new h}set(f,p,m,_,x){this._data.get(f,p)||this._data.set(f,p,new h),this._data.get(f,p).set(m,_,x)}get(f,p,m,_){var x;return(x=this._data.get(f,p))==null?void 0:x.get(m,_)}clear(){this._data.clear()}}},6114:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.isChromeOS=c.isLinux=c.isWindows=c.isIphone=c.isIpad=c.isMac=c.getSafariVersion=c.isSafari=c.isLegacyEdge=c.isFirefox=c.isNode=void 0,c.isNode=typeof process<"u"&&"title"in process;const h=c.isNode?"node":navigator.userAgent,f=c.isNode?"node":navigator.platform;c.isFirefox=h.includes("Firefox"),c.isLegacyEdge=h.includes("Edge"),c.isSafari=/^((?!chrome|android).)*safari/i.test(h),c.getSafariVersion=function(){if(!c.isSafari)return 0;const p=h.match(/Version\/(\d+)/);return p===null||p.length<2?0:parseInt(p[1])},c.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(f),c.isIpad=f==="iPad",c.isIphone=f==="iPhone",c.isWindows=["Windows","Win16","Win32","WinCE"].includes(f),c.isLinux=f.indexOf("Linux")>=0,c.isChromeOS=/\bCrOS\b/.test(h)},6106:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.SortedList=void 0;let h=0;c.SortedList=class{constructor(f){this._getKey=f,this._array=[]}clear(){this._array.length=0}insert(f){this._array.length!==0?(h=this._search(this._getKey(f)),this._array.splice(h,0,f)):this._array.push(f)}delete(f){if(this._array.length===0)return!1;const p=this._getKey(f);if(p===void 0||(h=this._search(p),h===-1)||this._getKey(this._array[h])!==p)return!1;do if(this._array[h]===f)return this._array.splice(h,1),!0;while(++h<this._array.length&&this._getKey(this._array[h])===p);return!1}*getKeyIterator(f){if(this._array.length!==0&&(h=this._search(f),!(h<0||h>=this._array.length)&&this._getKey(this._array[h])===f))do yield this._array[h];while(++h<this._array.length&&this._getKey(this._array[h])===f)}forEachByKey(f,p){if(this._array.length!==0&&(h=this._search(f),!(h<0||h>=this._array.length)&&this._getKey(this._array[h])===f))do p(this._array[h]);while(++h<this._array.length&&this._getKey(this._array[h])===f)}values(){return[...this._array].values()}_search(f){let p=0,m=this._array.length-1;for(;m>=p;){let _=p+m>>1;const x=this._getKey(this._array[_]);if(x>f)m=_-1;else{if(!(x<f)){for(;_>0&&this._getKey(this._array[_-1])===f;)_--;return _}p=_+1}}return p}}},7226:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DebouncedIdleTask=c.IdleTaskQueue=c.PriorityTaskQueue=void 0;const f=h(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,k=0,y=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),k=Math.max(w,k),S=x.timeRemaining(),1.5*k>S)return y-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(y-w))}ms`),void this._start();y=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())}}}c.PriorityTaskQueue=m,c.IdleTaskQueue=!f.isNode&&"requestIdleCallback"in window?class extends p{_requestCallback(_){return requestIdleCallback(_)}_cancelCallback(_){cancelIdleCallback(_)}}:m,c.DebouncedIdleTask=class{constructor(){this._queue=new c.IdleTaskQueue}set(_){this._queue.clear(),this._queue.enqueue(_)}flush(){this._queue.flush()}}},9282:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.updateWindowsModeWrappedState=void 0;const f=h(643);c.updateWindowsModeWrappedState=function(p){const m=p.buffer.lines.get(p.buffer.ybase+p.buffer.y-1),_=m==null?void 0:m.get(p.cols-1),x=p.buffer.lines.get(p.buffer.ybase+p.buffer.y);x&&_&&(x.isWrapped=_[f.CHAR_DATA_CODE_INDEX]!==f.NULL_CELL_CODE&&_[f.CHAR_DATA_CODE_INDEX]!==f.WHITESPACE_CELL_CODE)}},3734:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ExtendedAttrs=c.AttributeData=void 0;class h{constructor(){this.fg=0,this.bg=0,this.extended=new f}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 h;return m.fg=this.fg,m.bg=this.bg,m.extended=this.extended.clone(),m}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}c.AttributeData=h;class f{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,_=0){this._ext=0,this._urlId=0,this._ext=m,this._urlId=_}clone(){return new f(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}c.ExtendedAttrs=f},9092:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Buffer=c.MAX_BUFFER_SIZE=void 0;const f=h(6349),p=h(7226),m=h(3734),_=h(8437),x=h(4634),w=h(511),k=h(643),y=h(4863),S=h(7116);c.MAX_BUFFER_SIZE=4294967295,c.Buffer=class{constructor(v,b,E){this._hasScrollback=v,this._optionsService=b,this._bufferService=E,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=_.DEFAULT_ATTR_DATA.clone(),this.savedCharset=S.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,k.NULL_CELL_CHAR,k.NULL_CELL_WIDTH,k.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,k.WHITESPACE_CELL_CHAR,k.WHITESPACE_CELL_WIDTH,k.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 f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(v){return v?(this._nullCell.fg=v.fg,this._nullCell.bg=v.bg,this._nullCell.extended=v.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new m.ExtendedAttrs),this._nullCell}getWhitespaceCell(v){return v?(this._whitespaceCell.fg=v.fg,this._whitespaceCell.bg=v.bg,this._whitespaceCell.extended=v.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new m.ExtendedAttrs),this._whitespaceCell}getBlankLine(v,b){return new _.BufferLine(this._bufferService.cols,this.getNullCell(v),b)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const v=this.ybase+this.y-this.ydisp;return v>=0&&v<this._rows}_getCorrectBufferLength(v){if(!this._hasScrollback)return v;const b=v+this._optionsService.rawOptions.scrollback;return b>c.MAX_BUFFER_SIZE?c.MAX_BUFFER_SIZE:b}fillViewportRows(v){if(this.lines.length===0){v===void 0&&(v=_.DEFAULT_ATTR_DATA);let b=this._rows;for(;b--;)this.lines.push(this.getBlankLine(v))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(v,b){const E=this.getNullCell(_.DEFAULT_ATTR_DATA);let T=0;const N=this._getCorrectBufferLength(b);if(N>this.lines.maxLength&&(this.lines.maxLength=N),this.lines.length>0){if(this._cols<v)for(let A=0;A<this.lines.length;A++)T+=+this.lines.get(A).resize(v,E);let L=0;if(this._rows<b)for(let A=this._rows;A<b;A++)this.lines.length<b+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new _.BufferLine(v,E)):this.ybase>0&&this.lines.length<=this.ybase+this.y+L+1?(this.ybase--,L++,this.ydisp>0&&this.ydisp--):this.lines.push(new _.BufferLine(v,E)));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(N<this.lines.maxLength){const A=this.lines.length-N;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=N}this.x=Math.min(this.x,v-1),this.y=Math.min(this.y,b-1),L&&(this.y+=L),this.savedX=Math.min(this.savedX,v-1),this.scrollTop=0}if(this.scrollBottom=b-1,this._isReflowEnabled&&(this._reflow(v,b),this._cols>v))for(let L=0;L<this.lines.length;L++)T+=+this.lines.get(L).resize(v,E);this._cols=v,this._rows=b,this._memoryCleanupQueue.clear(),T>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let v=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,v=!1);let b=0;for(;this._memoryCleanupPosition<this.lines.length;)if(b+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),b>100)return!0;return v}get _isReflowEnabled(){const v=this._optionsService.rawOptions.windowsPty;return v&&v.buildNumber?this._hasScrollback&&v.backend==="conpty"&&v.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(v,b){this._cols!==v&&(v>this._cols?this._reflowLarger(v,b):this._reflowSmaller(v,b))}_reflowLarger(v,b){const E=(0,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,v,this.ybase+this.y,this.getNullCell(_.DEFAULT_ATTR_DATA));if(E.length>0){const T=(0,x.reflowLargerCreateNewLayout)(this.lines,E);(0,x.reflowLargerApplyNewLayout)(this.lines,T.layout),this._reflowLargerAdjustViewport(v,b,T.countRemoved)}}_reflowLargerAdjustViewport(v,b,E){const T=this.getNullCell(_.DEFAULT_ATTR_DATA);let N=E;for(;N-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<b&&this.lines.push(new _.BufferLine(v,T))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-E,0)}_reflowSmaller(v,b){const E=this.getNullCell(_.DEFAULT_ATTR_DATA),T=[];let N=0;for(let L=this.lines.length-1;L>=0;L--){let A=this.lines.get(L);if(!A||!A.isWrapped&&A.getTrimmedLength()<=v)continue;const D=[A];for(;A.isWrapped&&L>0;)A=this.lines.get(--L),D.unshift(A);const B=this.ybase+this.y;if(B>=L&&B<L+D.length)continue;const q=D[D.length-1].getTrimmedLength(),W=(0,x.reflowSmallerGetNewLineLengths)(D,this._cols,v),O=W.length-D.length;let V;V=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+O):Math.max(0,this.lines.length-this.lines.maxLength+O);const G=[];for(let $=0;$<O;$++){const P=this.getBlankLine(_.DEFAULT_ATTR_DATA,!0);G.push(P)}G.length>0&&(T.push({start:L+D.length+N,newLines:G}),N+=G.length),D.push(...G);let z=W.length-1,X=W[z];X===0&&(z--,X=W[z]);let ne=D.length-O-1,F=q;for(;ne>=0;){const $=Math.min(F,X);if(D[z]===void 0)break;if(D[z].copyCellsFrom(D[ne],F-$,X-$,$,!0),X-=$,X===0&&(z--,X=W[z]),F-=$,F===0){ne--;const P=Math.max(ne,0);F=(0,x.getWrappedLineTrimmedLength)(D,P,this._cols)}}for(let $=0;$<D.length;$++)W[$]<v&&D[$].setCell(W[$],E);let M=O-V;for(;M-- >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+N)-b&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+O,this.ybase+b-1)}if(T.length>0){const L=[],A=[];for(let z=0;z<this.lines.length;z++)A.push(this.lines.get(z));const D=this.lines.length;let B=D-1,q=0,W=T[q];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+N);let O=0;for(let z=Math.min(this.lines.maxLength-1,D+N-1);z>=0;z--)if(W&&W.start>B+O){for(let X=W.newLines.length-1;X>=0;X--)this.lines.set(z--,W.newLines[X]);z++,L.push({index:B+1,amount:W.newLines.length}),O+=W.newLines.length,W=T[++q]}else this.lines.set(z,A[B--]);let V=0;for(let z=L.length-1;z>=0;z--)L[z].index+=V,this.lines.onInsertEmitter.fire(L[z]),V+=L[z].amount;const G=Math.max(0,D+N-this.lines.maxLength);G>0&&this.lines.onTrimEmitter.fire(G)}}translateBufferLineToString(v,b,E=0,T){const N=this.lines.get(v);return N?N.translateToString(b,E,T):""}getWrappedRangeForLine(v){let b=v,E=v;for(;b>0&&this.lines.get(b).isWrapped;)b--;for(;E+1<this.lines.length&&this.lines.get(E+1).isWrapped;)E++;return{first:b,last:E}}setupTabStops(v){for(v!=null?this.tabs[v]||(v=this.prevStop(v)):(this.tabs={},v=0);v<this._cols;v+=this._optionsService.rawOptions.tabStopWidth)this.tabs[v]=!0}prevStop(v){for(v==null&&(v=this.x);!this.tabs[--v]&&v>0;);return v>=this._cols?this._cols-1:v<0?0:v}nextStop(v){for(v==null&&(v=this.x);!this.tabs[++v]&&v<this._cols;);return v>=this._cols?this._cols-1:v<0?0:v}clearMarkers(v){this._isClearing=!0;for(let b=0;b<this.markers.length;b++)this.markers[b].line===v&&(this.markers[b].dispose(),this.markers.splice(b--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let v=0;v<this.markers.length;v++)this.markers[v].dispose(),this.markers.splice(v--,1);this._isClearing=!1}addMarker(v){const b=new y.Marker(v);return this.markers.push(b),b.register(this.lines.onTrim((E=>{b.line-=E,b.line<0&&b.dispose()}))),b.register(this.lines.onInsert((E=>{b.line>=E.index&&(b.line+=E.amount)}))),b.register(this.lines.onDelete((E=>{b.line>=E.index&&b.line<E.index+E.amount&&b.dispose(),b.line>E.index&&(b.line-=E.amount)}))),b.register(b.onDispose((()=>this._removeMarker(b)))),b}_removeMarker(v){this._isClearing||this.markers.splice(this.markers.indexOf(v),1)}}},8437:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLine=c.DEFAULT_ATTR_DATA=void 0;const f=h(3734),p=h(511),m=h(643),_=h(482);c.DEFAULT_ATTR_DATA=Object.freeze(new f.AttributeData);let x=0;class w{constructor(y,S,v=!1){this.isWrapped=v,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*y);const b=S||p.CellData.fromCharData([0,m.NULL_CELL_CHAR,m.NULL_CELL_WIDTH,m.NULL_CELL_CODE]);for(let E=0;E<y;++E)this.setCell(E,b);this.length=y}get(y){const S=this._data[3*y+0],v=2097151&S;return[this._data[3*y+1],2097152&S?this._combined[y]:v?(0,_.stringFromCodePoint)(v):"",S>>22,2097152&S?this._combined[y].charCodeAt(this._combined[y].length-1):v]}set(y,S){this._data[3*y+1]=S[m.CHAR_DATA_ATTR_INDEX],S[m.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[y]=S[1],this._data[3*y+0]=2097152|y|S[m.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*y+0]=S[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[m.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(y){return this._data[3*y+0]>>22}hasWidth(y){return 12582912&this._data[3*y+0]}getFg(y){return this._data[3*y+1]}getBg(y){return this._data[3*y+2]}hasContent(y){return 4194303&this._data[3*y+0]}getCodePoint(y){const S=this._data[3*y+0];return 2097152&S?this._combined[y].charCodeAt(this._combined[y].length-1):2097151&S}isCombined(y){return 2097152&this._data[3*y+0]}getString(y){const S=this._data[3*y+0];return 2097152&S?this._combined[y]:2097151&S?(0,_.stringFromCodePoint)(2097151&S):""}isProtected(y){return 536870912&this._data[3*y+2]}loadCell(y,S){return x=3*y,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[y]),268435456&S.bg&&(S.extended=this._extendedAttrs[y]),S}setCell(y,S){2097152&S.content&&(this._combined[y]=S.combinedData),268435456&S.bg&&(this._extendedAttrs[y]=S.extended),this._data[3*y+0]=S.content,this._data[3*y+1]=S.fg,this._data[3*y+2]=S.bg}setCellFromCodepoint(y,S,v,b){268435456&b.bg&&(this._extendedAttrs[y]=b.extended),this._data[3*y+0]=S|v<<22,this._data[3*y+1]=b.fg,this._data[3*y+2]=b.bg}addCodepointToCell(y,S,v){let b=this._data[3*y+0];2097152&b?this._combined[y]+=(0,_.stringFromCodePoint)(S):2097151&b?(this._combined[y]=(0,_.stringFromCodePoint)(2097151&b)+(0,_.stringFromCodePoint)(S),b&=-2097152,b|=2097152):b=S|4194304,v&&(b&=-12582913,b|=v<<22),this._data[3*y+0]=b}insertCells(y,S,v){if((y%=this.length)&&this.getWidth(y-1)===2&&this.setCellFromCodepoint(y-1,0,1,v),S<this.length-y){const b=new p.CellData;for(let E=this.length-y-S-1;E>=0;--E)this.setCell(y+S+E,this.loadCell(y+E,b));for(let E=0;E<S;++E)this.setCell(y+E,v)}else for(let b=y;b<this.length;++b)this.setCell(b,v);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,v)}deleteCells(y,S,v){if(y%=this.length,S<this.length-y){const b=new p.CellData;for(let E=0;E<this.length-y-S;++E)this.setCell(y+E,this.loadCell(y+S+E,b));for(let E=this.length-S;E<this.length;++E)this.setCell(E,v)}else for(let b=y;b<this.length;++b)this.setCell(b,v);y&&this.getWidth(y-1)===2&&this.setCellFromCodepoint(y-1,0,1,v),this.getWidth(y)!==0||this.hasContent(y)||this.setCellFromCodepoint(y,0,1,v)}replaceCells(y,S,v,b=!1){if(b)for(y&&this.getWidth(y-1)===2&&!this.isProtected(y-1)&&this.setCellFromCodepoint(y-1,0,1,v),S<this.length&&this.getWidth(S-1)===2&&!this.isProtected(S)&&this.setCellFromCodepoint(S,0,1,v);y<S&&y<this.length;)this.isProtected(y)||this.setCell(y,v),y++;else for(y&&this.getWidth(y-1)===2&&this.setCellFromCodepoint(y-1,0,1,v),S<this.length&&this.getWidth(S-1)===2&&this.setCellFromCodepoint(S,0,1,v);y<S&&y<this.length;)this.setCell(y++,v)}resize(y,S){if(y===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const v=3*y;if(y>this.length){if(this._data.buffer.byteLength>=4*v)this._data=new Uint32Array(this._data.buffer,0,v);else{const b=new Uint32Array(v);b.set(this._data),this._data=b}for(let b=this.length;b<y;++b)this.setCell(b,S)}else{this._data=this._data.subarray(0,v);const b=Object.keys(this._combined);for(let T=0;T<b.length;T++){const N=parseInt(b[T],10);N>=y&&delete this._combined[N]}const E=Object.keys(this._extendedAttrs);for(let T=0;T<E.length;T++){const N=parseInt(E[T],10);N>=y&&delete this._extendedAttrs[N]}}return this.length=y,4*v*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const y=new Uint32Array(this._data.length);return y.set(this._data),this._data=y,1}return 0}fill(y,S=!1){if(S)for(let v=0;v<this.length;++v)this.isProtected(v)||this.setCell(v,y);else{this._combined={},this._extendedAttrs={};for(let v=0;v<this.length;++v)this.setCell(v,y)}}copyFrom(y){this.length!==y.length?this._data=new Uint32Array(y._data):this._data.set(y._data),this.length=y.length,this._combined={};for(const S in y._combined)this._combined[S]=y._combined[S];this._extendedAttrs={};for(const S in y._extendedAttrs)this._extendedAttrs[S]=y._extendedAttrs[S];this.isWrapped=y.isWrapped}clone(){const y=new w(0);y._data=new Uint32Array(this._data),y.length=this.length;for(const S in this._combined)y._combined[S]=this._combined[S];for(const S in this._extendedAttrs)y._extendedAttrs[S]=this._extendedAttrs[S];return y.isWrapped=this.isWrapped,y}getTrimmedLength(){for(let y=this.length-1;y>=0;--y)if(4194303&this._data[3*y+0])return y+(this._data[3*y+0]>>22);return 0}getNoBgTrimmedLength(){for(let y=this.length-1;y>=0;--y)if(4194303&this._data[3*y+0]||50331648&this._data[3*y+2])return y+(this._data[3*y+0]>>22);return 0}copyCellsFrom(y,S,v,b,E){const T=y._data;if(E)for(let L=b-1;L>=0;L--){for(let A=0;A<3;A++)this._data[3*(v+L)+A]=T[3*(S+L)+A];268435456&T[3*(S+L)+2]&&(this._extendedAttrs[v+L]=y._extendedAttrs[S+L])}else for(let L=0;L<b;L++){for(let A=0;A<3;A++)this._data[3*(v+L)+A]=T[3*(S+L)+A];268435456&T[3*(S+L)+2]&&(this._extendedAttrs[v+L]=y._extendedAttrs[S+L])}const N=Object.keys(y._combined);for(let L=0;L<N.length;L++){const A=parseInt(N[L],10);A>=S&&(this._combined[A-S+v]=y._combined[A])}}translateToString(y,S,v,b){S=S??0,v=v??this.length,y&&(v=Math.min(v,this.getTrimmedLength())),b&&(b.length=0);let E="";for(;S<v;){const T=this._data[3*S+0],N=2097151&T,L=2097152&T?this._combined[S]:N?(0,_.stringFromCodePoint)(N):m.WHITESPACE_CELL_CHAR;if(E+=L,b)for(let A=0;A<L.length;++A)b.push(S);S+=T>>22||1}return b&&b.push(S),E}}c.BufferLine=w},4841:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.getRangeLength=void 0,c.getRangeLength=function(h,f){if(h.start.y>h.end.y)throw new Error(`Buffer range end (${h.end.x}, ${h.end.y}) cannot be before start (${h.start.x}, ${h.start.y})`);return f*(h.end.y-h.start.y)+(h.end.x-h.start.x+1)}},4634:(u,c)=>{function h(f,p,m){if(p===f.length-1)return f[p].getTrimmedLength();const _=!f[p].hasContent(m-1)&&f[p].getWidth(m-1)===1,x=f[p+1].getWidth(0)===2;return _&&x?m-1:m}Object.defineProperty(c,"__esModule",{value:!0}),c.getWrappedLineTrimmedLength=c.reflowSmallerGetNewLineLengths=c.reflowLargerApplyNewLayout=c.reflowLargerCreateNewLayout=c.reflowLargerGetLinesToRemove=void 0,c.reflowLargerGetLinesToRemove=function(f,p,m,_,x){const w=[];for(let k=0;k<f.length-1;k++){let y=k,S=f.get(++y);if(!S.isWrapped)continue;const v=[f.get(k)];for(;y<f.length&&S.isWrapped;)v.push(S),S=f.get(++y);if(_>=k&&_<y){k+=v.length-1;continue}let b=0,E=h(v,b,p),T=1,N=0;for(;T<v.length;){const A=h(v,T,p),D=A-N,B=m-E,q=Math.min(D,B);v[b].copyCellsFrom(v[T],N,E,q,!1),E+=q,E===m&&(b++,E=0),N+=q,N===A&&(T++,N=0),E===0&&b!==0&&v[b-1].getWidth(m-1)===2&&(v[b].copyCellsFrom(v[b-1],m-1,E++,1,!1),v[b-1].setCell(m-1,x))}v[b].replaceCells(E,m,x);let L=0;for(let A=v.length-1;A>0&&(A>b||v[A].getTrimmedLength()===0);A--)L++;L>0&&(w.push(k+v.length-L),w.push(L)),k+=v.length-1}return w},c.reflowLargerCreateNewLayout=function(f,p){const m=[];let _=0,x=p[_],w=0;for(let k=0;k<f.length;k++)if(x===k){const y=p[++_];f.onDeleteEmitter.fire({index:k-w,amount:y}),k+=y-1,w+=y,x=p[++_]}else m.push(k);return{layout:m,countRemoved:w}},c.reflowLargerApplyNewLayout=function(f,p){const m=[];for(let _=0;_<p.length;_++)m.push(f.get(p[_]));for(let _=0;_<m.length;_++)f.set(_,m[_]);f.length=p.length},c.reflowSmallerGetNewLineLengths=function(f,p,m){const _=[],x=f.map(((S,v)=>h(f,v,p))).reduce(((S,v)=>S+v));let w=0,k=0,y=0;for(;y<x;){if(x-y<m){_.push(x-y);break}w+=m;const S=h(f,k,p);w>S&&(w-=S,k++);const v=f[k].getWidth(w-1)===2;v&&w--;const b=v?m-1:m;_.push(b),y+=b}return _},c.getWrappedLineTrimmedLength=h},5295:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferSet=void 0;const f=h(8460),p=h(844),m=h(9092);class _ extends p.Disposable{constructor(w,k){super(),this._optionsService=w,this._bufferService=k,this._onBufferActivate=this.register(new f.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,k){this._normal.resize(w,k),this._alt.resize(w,k),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}c.BufferSet=_},511:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CellData=void 0;const f=h(482),p=h(643),m=h(3734);class _ 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 k=new _;return k.setFromCharData(w),k}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,f.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 k=!1;if(w[p.CHAR_DATA_CHAR_INDEX].length>2)k=!0;else if(w[p.CHAR_DATA_CHAR_INDEX].length===2){const y=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=y&&y<=56319){const S=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=S&&S<=57343?this.content=1024*(y-55296)+S-56320+65536|w[p.CHAR_DATA_WIDTH_INDEX]<<22:k=!0}else k=!0}else this.content=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[p.CHAR_DATA_WIDTH_INDEX]<<22;k&&(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()]}}c.CellData=_},643:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WHITESPACE_CELL_CODE=c.WHITESPACE_CELL_WIDTH=c.WHITESPACE_CELL_CHAR=c.NULL_CELL_CODE=c.NULL_CELL_WIDTH=c.NULL_CELL_CHAR=c.CHAR_DATA_CODE_INDEX=c.CHAR_DATA_WIDTH_INDEX=c.CHAR_DATA_CHAR_INDEX=c.CHAR_DATA_ATTR_INDEX=c.DEFAULT_EXT=c.DEFAULT_ATTR=c.DEFAULT_COLOR=void 0,c.DEFAULT_COLOR=0,c.DEFAULT_ATTR=256|c.DEFAULT_COLOR<<9,c.DEFAULT_EXT=0,c.CHAR_DATA_ATTR_INDEX=0,c.CHAR_DATA_CHAR_INDEX=1,c.CHAR_DATA_WIDTH_INDEX=2,c.CHAR_DATA_CODE_INDEX=3,c.NULL_CELL_CHAR="",c.NULL_CELL_WIDTH=1,c.NULL_CELL_CODE=0,c.WHITESPACE_CELL_CHAR=" ",c.WHITESPACE_CELL_WIDTH=1,c.WHITESPACE_CELL_CODE=32},4863:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Marker=void 0;const f=h(8460),p=h(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 f.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}}c.Marker=m,m._nextId=1},7116:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DEFAULT_CHARSET=c.CHARSETS=void 0,c.CHARSETS={},c.DEFAULT_CHARSET=c.CHARSETS.B,c.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},c.CHARSETS.A={"#":"£"},c.CHARSETS.B=void 0,c.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},c.CHARSETS.C=c.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},c.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},c.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},c.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},c.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},c.CHARSETS.E=c.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},c.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},c.CHARSETS.H=c.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},c.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(u,c)=>{var h,f,p;Object.defineProperty(c,"__esModule",{value:!0}),c.C1_ESCAPED=c.C1=c.C0=void 0,(function(m){m.NUL="\0",m.SOH="",m.STX="",m.ETX="",m.EOT="",m.ENQ="",m.ACK="",m.BEL="\x07",m.BS="\b",m.HT=" ",m.LF=`
|
|
65
|
+
`,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=""})(h||(c.C0=h={})),(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=""})(f||(c.C1=f={})),(function(m){m.ST=`${h.ESC}\\`})(p||(c.C1_ESCAPED=p={}))},7399:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.evaluateKeyboardEvent=void 0;const f=h(2584),p={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};c.evaluateKeyboardEvent=function(m,_,x,w){const k={type:0,cancel:!1,key:void 0},y=(m.shiftKey?1:0)|(m.altKey?2:0)|(m.ctrlKey?4:0)|(m.metaKey?8:0);switch(m.keyCode){case 0:m.key==="UIKeyInputUpArrow"?k.key=_?f.C0.ESC+"OA":f.C0.ESC+"[A":m.key==="UIKeyInputLeftArrow"?k.key=_?f.C0.ESC+"OD":f.C0.ESC+"[D":m.key==="UIKeyInputRightArrow"?k.key=_?f.C0.ESC+"OC":f.C0.ESC+"[C":m.key==="UIKeyInputDownArrow"&&(k.key=_?f.C0.ESC+"OB":f.C0.ESC+"[B");break;case 8:k.key=m.ctrlKey?"\b":f.C0.DEL,m.altKey&&(k.key=f.C0.ESC+k.key);break;case 9:if(m.shiftKey){k.key=f.C0.ESC+"[Z";break}k.key=f.C0.HT,k.cancel=!0;break;case 13:k.key=m.altKey?f.C0.ESC+f.C0.CR:f.C0.CR,k.cancel=!0;break;case 27:k.key=f.C0.ESC,m.altKey&&(k.key=f.C0.ESC+f.C0.ESC),k.cancel=!0;break;case 37:if(m.metaKey)break;y?(k.key=f.C0.ESC+"[1;"+(y+1)+"D",k.key===f.C0.ESC+"[1;3D"&&(k.key=f.C0.ESC+(x?"b":"[1;5D"))):k.key=_?f.C0.ESC+"OD":f.C0.ESC+"[D";break;case 39:if(m.metaKey)break;y?(k.key=f.C0.ESC+"[1;"+(y+1)+"C",k.key===f.C0.ESC+"[1;3C"&&(k.key=f.C0.ESC+(x?"f":"[1;5C"))):k.key=_?f.C0.ESC+"OC":f.C0.ESC+"[C";break;case 38:if(m.metaKey)break;y?(k.key=f.C0.ESC+"[1;"+(y+1)+"A",x||k.key!==f.C0.ESC+"[1;3A"||(k.key=f.C0.ESC+"[1;5A")):k.key=_?f.C0.ESC+"OA":f.C0.ESC+"[A";break;case 40:if(m.metaKey)break;y?(k.key=f.C0.ESC+"[1;"+(y+1)+"B",x||k.key!==f.C0.ESC+"[1;3B"||(k.key=f.C0.ESC+"[1;5B")):k.key=_?f.C0.ESC+"OB":f.C0.ESC+"[B";break;case 45:m.shiftKey||m.ctrlKey||(k.key=f.C0.ESC+"[2~");break;case 46:k.key=y?f.C0.ESC+"[3;"+(y+1)+"~":f.C0.ESC+"[3~";break;case 36:k.key=y?f.C0.ESC+"[1;"+(y+1)+"H":_?f.C0.ESC+"OH":f.C0.ESC+"[H";break;case 35:k.key=y?f.C0.ESC+"[1;"+(y+1)+"F":_?f.C0.ESC+"OF":f.C0.ESC+"[F";break;case 33:m.shiftKey?k.type=2:m.ctrlKey?k.key=f.C0.ESC+"[5;"+(y+1)+"~":k.key=f.C0.ESC+"[5~";break;case 34:m.shiftKey?k.type=3:m.ctrlKey?k.key=f.C0.ESC+"[6;"+(y+1)+"~":k.key=f.C0.ESC+"[6~";break;case 112:k.key=y?f.C0.ESC+"[1;"+(y+1)+"P":f.C0.ESC+"OP";break;case 113:k.key=y?f.C0.ESC+"[1;"+(y+1)+"Q":f.C0.ESC+"OQ";break;case 114:k.key=y?f.C0.ESC+"[1;"+(y+1)+"R":f.C0.ESC+"OR";break;case 115:k.key=y?f.C0.ESC+"[1;"+(y+1)+"S":f.C0.ESC+"OS";break;case 116:k.key=y?f.C0.ESC+"[15;"+(y+1)+"~":f.C0.ESC+"[15~";break;case 117:k.key=y?f.C0.ESC+"[17;"+(y+1)+"~":f.C0.ESC+"[17~";break;case 118:k.key=y?f.C0.ESC+"[18;"+(y+1)+"~":f.C0.ESC+"[18~";break;case 119:k.key=y?f.C0.ESC+"[19;"+(y+1)+"~":f.C0.ESC+"[19~";break;case 120:k.key=y?f.C0.ESC+"[20;"+(y+1)+"~":f.C0.ESC+"[20~";break;case 121:k.key=y?f.C0.ESC+"[21;"+(y+1)+"~":f.C0.ESC+"[21~";break;case 122:k.key=y?f.C0.ESC+"[23;"+(y+1)+"~":f.C0.ESC+"[23~";break;case 123:k.key=y?f.C0.ESC+"[24;"+(y+1)+"~":f.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?k.key=m.key:m.key&&m.ctrlKey&&(m.key==="_"&&(k.key=f.C0.US),m.key==="@"&&(k.key=f.C0.NUL)):m.keyCode===65&&(k.type=1);else{const S=p[m.keyCode],v=S==null?void 0:S[m.shiftKey?1:0];if(v)k.key=f.C0.ESC+v;else if(m.keyCode>=65&&m.keyCode<=90){const b=m.ctrlKey?m.keyCode-64:m.keyCode+32;let E=String.fromCharCode(b);m.shiftKey&&(E=E.toUpperCase()),k.key=f.C0.ESC+E}else if(m.keyCode===32)k.key=f.C0.ESC+(m.ctrlKey?f.C0.NUL:" ");else if(m.key==="Dead"&&m.code.startsWith("Key")){let b=m.code.slice(3,4);m.shiftKey||(b=b.toLowerCase()),k.key=f.C0.ESC+b,k.cancel=!0}}else m.keyCode>=65&&m.keyCode<=90?k.key=String.fromCharCode(m.keyCode-64):m.keyCode===32?k.key=f.C0.NUL:m.keyCode>=51&&m.keyCode<=55?k.key=String.fromCharCode(m.keyCode-51+27):m.keyCode===56?k.key=f.C0.DEL:m.keyCode===219?k.key=f.C0.ESC:m.keyCode===220?k.key=f.C0.FS:m.keyCode===221&&(k.key=f.C0.GS)}return k}},482:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Utf8ToUtf32=c.StringToUtf32=c.utf32ToString=c.stringFromCodePoint=void 0,c.stringFromCodePoint=function(h){return h>65535?(h-=65536,String.fromCharCode(55296+(h>>10))+String.fromCharCode(h%1024+56320)):String.fromCharCode(h)},c.utf32ToString=function(h,f=0,p=h.length){let m="";for(let _=f;_<p;++_){let x=h[_];x>65535?(x-=65536,m+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):m+=String.fromCharCode(x)}return m},c.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(h,f){const p=h.length;if(!p)return 0;let m=0,_=0;if(this._interim){const x=h.charCodeAt(_++);56320<=x&&x<=57343?f[m++]=1024*(this._interim-55296)+x-56320+65536:(f[m++]=this._interim,f[m++]=x),this._interim=0}for(let x=_;x<p;++x){const w=h.charCodeAt(x);if(55296<=w&&w<=56319){if(++x>=p)return this._interim=w,m;const k=h.charCodeAt(x);56320<=k&&k<=57343?f[m++]=1024*(w-55296)+k-56320+65536:(f[m++]=w,f[m++]=k)}else w!==65279&&(f[m++]=w)}return m}},c.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(h,f){const p=h.length;if(!p)return 0;let m,_,x,w,k=0,y=0,S=0;if(this.interim[0]){let E=!1,T=this.interim[0];T&=(224&T)==192?31:(240&T)==224?15:7;let N,L=0;for(;(N=63&this.interim[++L])&&L<4;)T<<=6,T|=N;const A=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,D=A-L;for(;S<D;){if(S>=p)return 0;if(N=h[S++],(192&N)!=128){S--,E=!0;break}this.interim[L++]=N,T<<=6,T|=63&N}E||(A===2?T<128?S--:f[k++]=T:A===3?T<2048||T>=55296&&T<=57343||T===65279||(f[k++]=T):T<65536||T>1114111||(f[k++]=T)),this.interim.fill(0)}const v=p-4;let b=S;for(;b<p;){for(;!(!(b<v)||128&(m=h[b])||128&(_=h[b+1])||128&(x=h[b+2])||128&(w=h[b+3]));)f[k++]=m,f[k++]=_,f[k++]=x,f[k++]=w,b+=4;if(m=h[b++],m<128)f[k++]=m;else if((224&m)==192){if(b>=p)return this.interim[0]=m,k;if(_=h[b++],(192&_)!=128){b--;continue}if(y=(31&m)<<6|63&_,y<128){b--;continue}f[k++]=y}else if((240&m)==224){if(b>=p)return this.interim[0]=m,k;if(_=h[b++],(192&_)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=_,k;if(x=h[b++],(192&x)!=128){b--;continue}if(y=(15&m)<<12|(63&_)<<6|63&x,y<2048||y>=55296&&y<=57343||y===65279)continue;f[k++]=y}else if((248&m)==240){if(b>=p)return this.interim[0]=m,k;if(_=h[b++],(192&_)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=_,k;if(x=h[b++],(192&x)!=128){b--;continue}if(b>=p)return this.interim[0]=m,this.interim[1]=_,this.interim[2]=x,k;if(w=h[b++],(192&w)!=128){b--;continue}if(y=(7&m)<<18|(63&_)<<12|(63&x)<<6|63&w,y<65536||y>1114111)continue;f[k++]=y}}return k}}},225:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeV6=void 0;const f=h(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 _;c.UnicodeV6=class{constructor(){if(this.version="6",!_){_=new Uint8Array(65536),_.fill(1),_[0]=0,_.fill(0,1,32),_.fill(0,127,160),_.fill(2,4352,4448),_[9001]=2,_[9002]=2,_.fill(2,11904,42192),_[12351]=1,_.fill(2,44032,55204),_.fill(2,63744,64256),_.fill(2,65040,65050),_.fill(2,65072,65136),_.fill(2,65280,65377),_.fill(2,65504,65511);for(let x=0;x<p.length;++x)_.fill(0,p[x][0],p[x][1]+1)}}wcwidth(x){return x<32?0:x<127?1:x<65536?_[x]:(function(w,k){let y,S=0,v=k.length-1;if(w<k[0][0]||w>k[v][1])return!1;for(;v>=S;)if(y=S+v>>1,w>k[y][1])S=y+1;else{if(!(w<k[y][0]))return!0;v=y-1}return!1})(x,m)?0:x>=131072&&x<=196605||x>=196608&&x<=262141?2:1}charProperties(x,w){let k=this.wcwidth(x),y=k===0&&w!==0;if(y){const S=f.UnicodeService.extractWidth(w);S===0?y=!1:S>k&&(k=S)}return f.UnicodeService.createPropertyValue(0,k,y)}}},5981:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WriteBuffer=void 0;const f=h(8460),p=h(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 f.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 k;for(this._isSyncWriting=!0;k=this._writeBuffer.shift();){this._action(k);const y=this._callbacks.shift();y&&y()}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 k=x||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const y=this._writeBuffer[this._bufferOffset],S=this._action(y,w);if(S){const b=E=>Date.now()-k>=12?setTimeout((()=>this._innerWrite(0,E))):this._innerWrite(k,E);return void S.catch((E=>(queueMicrotask((()=>{throw E})),Promise.resolve(!1)))).then(b)}const v=this._callbacks[this._bufferOffset];if(v&&v(),this._bufferOffset++,this._pendingData-=y.length,Date.now()-k>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}c.WriteBuffer=m},5941:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.toRgbString=c.parseColor=void 0;const h=/^([\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})$/,f=/^[\da-f]+$/;function p(m,_){const x=m.toString(16),w=x.length<2?"0"+x:x;switch(_){case 4:return x[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}c.parseColor=function(m){if(!m)return;let _=m.toLowerCase();if(_.indexOf("rgb:")===0){_=_.slice(4);const x=h.exec(_);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(_.indexOf("#")===0&&(_=_.slice(1),f.exec(_)&&[3,6,9,12].includes(_.length))){const x=_.length/3,w=[0,0,0];for(let k=0;k<3;++k){const y=parseInt(_.slice(x*k,x*k+x),16);w[k]=x===1?y<<4:x===2?y:x===3?y>>4:y>>8}return w}},c.toRgbString=function(m,_=16){const[x,w,k]=m;return`rgb:${p(x,_)}/${p(w,_)}/${p(k,_)}`}},5770:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.PAYLOAD_LIMIT=void 0,c.PAYLOAD_LIMIT=1e7},6351:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DcsHandler=c.DcsParser=void 0;const f=h(482),p=h(8742),m=h(5770),_=[];c.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=_,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=_}registerHandler(w,k){this._handlers[w]===void 0&&(this._handlers[w]=[]);const y=this._handlers[w];return y.push(k),{dispose:()=>{const S=y.indexOf(k);S!==-1&&y.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=_,this._ident=0}hook(w,k){if(this.reset(),this._ident=w,this._active=this._handlers[w]||_,this._active.length)for(let y=this._active.length-1;y>=0;y--)this._active[y].hook(k);else this._handlerFb(this._ident,"HOOK",k)}put(w,k,y){if(this._active.length)for(let S=this._active.length-1;S>=0;S--)this._active[S].put(w,k,y);else this._handlerFb(this._ident,"PUT",(0,f.utf32ToString)(w,k,y))}unhook(w,k=!0){if(this._active.length){let y=!1,S=this._active.length-1,v=!1;if(this._stack.paused&&(S=this._stack.loopPosition-1,y=k,v=this._stack.fallThrough,this._stack.paused=!1),!v&&y===!1){for(;S>=0&&(y=this._active[S].unhook(w),y!==!0);S--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!1,y;S--}for(;S>=0;S--)if(y=this._active[S].unhook(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!0,y}else this._handlerFb(this._ident,"UNHOOK",w);this._active=_,this._ident=0}};const x=new p.Params;x.addParam(0),c.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,k,y){this._hitLimit||(this._data+=(0,f.utf32ToString)(w,k,y),this._data.length>m.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let k=!1;if(this._hitLimit)k=!1;else if(w&&(k=this._handler(this._data,this._params),k instanceof Promise))return k.then((y=>(this._params=x,this._data="",this._hitLimit=!1,y)));return this._params=x,this._data="",this._hitLimit=!1,k}}},2015:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.EscapeSequenceParser=c.VT500_TRANSITION_TABLE=c.TransitionTable=void 0;const f=h(844),p=h(8742),m=h(6242),_=h(6351);class x{constructor(S){this.table=new Uint8Array(S)}setDefault(S,v){this.table.fill(S<<4|v)}add(S,v,b,E){this.table[v<<8|S]=b<<4|E}addMany(S,v,b,E){for(let T=0;T<S.length;T++)this.table[v<<8|S[T]]=b<<4|E}}c.TransitionTable=x;const w=160;c.VT500_TRANSITION_TABLE=(function(){const y=new x(4095),S=Array.apply(null,Array(256)).map(((L,A)=>A)),v=(L,A)=>S.slice(L,A),b=v(32,127),E=v(0,24);E.push(25),E.push.apply(E,v(28,32));const T=v(0,14);let N;for(N in y.setDefault(1,0),y.addMany(b,0,2,0),T)y.addMany([24,26,153,154],N,3,0),y.addMany(v(128,144),N,3,0),y.addMany(v(144,152),N,3,0),y.add(156,N,0,0),y.add(27,N,11,1),y.add(157,N,4,8),y.addMany([152,158,159],N,0,7),y.add(155,N,11,3),y.add(144,N,11,9);return y.addMany(E,0,3,0),y.addMany(E,1,3,1),y.add(127,1,0,1),y.addMany(E,8,0,8),y.addMany(E,3,3,3),y.add(127,3,0,3),y.addMany(E,4,3,4),y.add(127,4,0,4),y.addMany(E,6,3,6),y.addMany(E,5,3,5),y.add(127,5,0,5),y.addMany(E,2,3,2),y.add(127,2,0,2),y.add(93,1,4,8),y.addMany(b,8,5,8),y.add(127,8,5,8),y.addMany([156,27,24,26,7],8,6,0),y.addMany(v(28,32),8,0,8),y.addMany([88,94,95],1,0,7),y.addMany(b,7,0,7),y.addMany(E,7,0,7),y.add(156,7,0,0),y.add(127,7,0,7),y.add(91,1,11,3),y.addMany(v(64,127),3,7,0),y.addMany(v(48,60),3,8,4),y.addMany([60,61,62,63],3,9,4),y.addMany(v(48,60),4,8,4),y.addMany(v(64,127),4,7,0),y.addMany([60,61,62,63],4,0,6),y.addMany(v(32,64),6,0,6),y.add(127,6,0,6),y.addMany(v(64,127),6,0,0),y.addMany(v(32,48),3,9,5),y.addMany(v(32,48),5,9,5),y.addMany(v(48,64),5,0,6),y.addMany(v(64,127),5,7,0),y.addMany(v(32,48),4,9,5),y.addMany(v(32,48),1,9,2),y.addMany(v(32,48),2,9,2),y.addMany(v(48,127),2,10,0),y.addMany(v(48,80),1,10,0),y.addMany(v(81,88),1,10,0),y.addMany([89,90,92],1,10,0),y.addMany(v(96,127),1,10,0),y.add(80,1,11,9),y.addMany(E,9,0,9),y.add(127,9,0,9),y.addMany(v(28,32),9,0,9),y.addMany(v(32,48),9,9,12),y.addMany(v(48,60),9,8,10),y.addMany([60,61,62,63],9,9,10),y.addMany(E,11,0,11),y.addMany(v(32,128),11,0,11),y.addMany(v(28,32),11,0,11),y.addMany(E,10,0,10),y.add(127,10,0,10),y.addMany(v(28,32),10,0,10),y.addMany(v(48,60),10,8,10),y.addMany([60,61,62,63],10,0,11),y.addMany(v(32,48),10,9,12),y.addMany(E,12,0,12),y.add(127,12,0,12),y.addMany(v(28,32),12,0,12),y.addMany(v(32,48),12,9,12),y.addMany(v(48,64),12,0,11),y.addMany(v(64,127),12,12,13),y.addMany(v(64,127),10,12,13),y.addMany(v(64,127),9,12,13),y.addMany(E,13,13,13),y.addMany(b,13,13,13),y.add(127,13,0,13),y.addMany([27,156,24,26],13,14,0),y.add(w,0,2,0),y.add(w,8,5,8),y.add(w,6,0,6),y.add(w,11,0,11),y.add(w,13,13,13),y})();class k extends f.Disposable{constructor(S=c.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=(v,b,E)=>{},this._executeHandlerFb=v=>{},this._csiHandlerFb=(v,b)=>{},this._escHandlerFb=v=>{},this._errorHandlerFb=v=>v,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,f.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 _.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(S,v=[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 T=0;T<S.intermediates.length;++T){const N=S.intermediates.charCodeAt(T);if(32>N||N>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");b<<=8,b|=N}}if(S.final.length!==1)throw new Error("final must be a single byte");const E=S.final.charCodeAt(0);if(v[0]>E||E>v[1])throw new Error(`final must be in range ${v[0]} .. ${v[1]}`);return b<<=8,b|=E,b}identToString(S){const v=[];for(;S;)v.push(String.fromCharCode(255&S)),S>>=8;return v.reverse().join("")}setPrintHandler(S){this._printHandler=S}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(S,v){const b=this._identifier(S,[48,126]);this._escHandlers[b]===void 0&&(this._escHandlers[b]=[]);const E=this._escHandlers[b];return E.push(v),{dispose:()=>{const T=E.indexOf(v);T!==-1&&E.splice(T,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,v){this._executeHandlers[S.charCodeAt(0)]=v}clearExecuteHandler(S){this._executeHandlers[S.charCodeAt(0)]&&delete this._executeHandlers[S.charCodeAt(0)]}setExecuteHandlerFallback(S){this._executeHandlerFb=S}registerCsiHandler(S,v){const b=this._identifier(S);this._csiHandlers[b]===void 0&&(this._csiHandlers[b]=[]);const E=this._csiHandlers[b];return E.push(v),{dispose:()=>{const T=E.indexOf(v);T!==-1&&E.splice(T,1)}}}clearCsiHandler(S){this._csiHandlers[this._identifier(S)]&&delete this._csiHandlers[this._identifier(S)]}setCsiHandlerFallback(S){this._csiHandlerFb=S}registerDcsHandler(S,v){return this._dcsParser.registerHandler(this._identifier(S),v)}clearDcsHandler(S){this._dcsParser.clearHandler(this._identifier(S))}setDcsHandlerFallback(S){this._dcsParser.setHandlerFallback(S)}registerOscHandler(S,v){return this._oscParser.registerHandler(S,v)}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,v,b,E,T){this._parseStack.state=S,this._parseStack.handlers=v,this._parseStack.handlerPos=b,this._parseStack.transition=E,this._parseStack.chunkPos=T}parse(S,v,b){let E,T=0,N=0,L=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,L=this._parseStack.chunkPos+1;else{if(b===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const A=this._parseStack.handlers;let D=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(b===!1&&D>-1){for(;D>=0&&(E=A[D](this._params),E!==!0);D--)if(E instanceof Promise)return this._parseStack.handlerPos=D,E}this._parseStack.handlers=[];break;case 4:if(b===!1&&D>-1){for(;D>=0&&(E=A[D](),E!==!0);D--)if(E instanceof Promise)return this._parseStack.handlerPos=D,E}this._parseStack.handlers=[];break;case 6:if(T=S[this._parseStack.chunkPos],E=this._dcsParser.unhook(T!==24&&T!==26,b),E)return E;T===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(T=S[this._parseStack.chunkPos],E=this._oscParser.end(T!==24&&T!==26,b),E)return E;T===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,L=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let A=L;A<v;++A){switch(T=S[A],N=this._transitions.table[this.currentState<<8|(T<160?T:w)],N>>4){case 2:for(let O=A+1;;++O){if(O>=v||(T=S[O])<32||T>126&&T<w){this._printHandler(S,A,O),A=O-1;break}if(++O>=v||(T=S[O])<32||T>126&&T<w){this._printHandler(S,A,O),A=O-1;break}if(++O>=v||(T=S[O])<32||T>126&&T<w){this._printHandler(S,A,O),A=O-1;break}if(++O>=v||(T=S[O])<32||T>126&&T<w){this._printHandler(S,A,O),A=O-1;break}}break;case 3:this._executeHandlers[T]?this._executeHandlers[T]():this._executeHandlerFb(T),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:A,code:T,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const D=this._csiHandlers[this._collect<<8|T];let B=D?D.length-1:-1;for(;B>=0&&(E=D[B](this._params),E!==!0);B--)if(E instanceof Promise)return this._preserveStack(3,D,B,N,A),E;B<0&&this._csiHandlerFb(this._collect<<8|T,this._params),this.precedingJoinState=0;break;case 8:do switch(T){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(T-48)}while(++A<v&&(T=S[A])>47&&T<60);A--;break;case 9:this._collect<<=8,this._collect|=T;break;case 10:const q=this._escHandlers[this._collect<<8|T];let W=q?q.length-1:-1;for(;W>=0&&(E=q[W](),E!==!0);W--)if(E instanceof Promise)return this._preserveStack(4,q,W,N,A),E;W<0&&this._escHandlerFb(this._collect<<8|T),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|T,this._params);break;case 13:for(let O=A+1;;++O)if(O>=v||(T=S[O])===24||T===26||T===27||T>127&&T<w){this._dcsParser.put(S,A,O),A=O-1;break}break;case 14:if(E=this._dcsParser.unhook(T!==24&&T!==26),E)return this._preserveStack(6,[],0,N,A),E;T===27&&(N|=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 O=A+1;;O++)if(O>=v||(T=S[O])<32||T>127&&T<w){this._oscParser.put(S,A,O),A=O-1;break}break;case 6:if(E=this._oscParser.end(T!==24&&T!==26),E)return this._preserveStack(5,[],0,N,A),E;T===27&&(N|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&N}}}c.EscapeSequenceParser=k},6242:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OscHandler=c.OscParser=void 0;const f=h(5770),p=h(482),m=[];c.OscParser=class{constructor(){this._state=0,this._active=m,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(_,x){this._handlers[_]===void 0&&(this._handlers[_]=[]);const w=this._handlers[_];return w.push(x),{dispose:()=>{const k=w.indexOf(x);k!==-1&&w.splice(k,1)}}}clearHandler(_){this._handlers[_]&&delete this._handlers[_]}setHandlerFallback(_){this._handlerFb=_}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}reset(){if(this._state===2)for(let _=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;_>=0;--_)this._active[_].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 _=this._active.length-1;_>=0;_--)this._active[_].start();else this._handlerFb(this._id,"START")}_put(_,x,w){if(this._active.length)for(let k=this._active.length-1;k>=0;k--)this._active[k].put(_,x,w);else this._handlerFb(this._id,"PUT",(0,p.utf32ToString)(_,x,w))}start(){this.reset(),this._state=1}put(_,x,w){if(this._state!==3){if(this._state===1)for(;x<w;){const k=_[x++];if(k===59){this._state=2,this._start();break}if(k<48||57<k)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+k-48}this._state===2&&w-x>0&&this._put(_,x,w)}}end(_,x=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,k=this._active.length-1,y=!1;if(this._stack.paused&&(k=this._stack.loopPosition-1,w=x,y=this._stack.fallThrough,this._stack.paused=!1),!y&&w===!1){for(;k>=0&&(w=this._active[k].end(_),w!==!0);k--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=k,this._stack.fallThrough=!1,w;k--}for(;k>=0;k--)if(w=this._active[k].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=k,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",_);this._active=m,this._id=-1,this._state=0}}},c.OscHandler=class{constructor(_){this._handler=_,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(_,x,w){this._hitLimit||(this._data+=(0,p.utf32ToString)(_,x,w),this._data.length>f.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(_){let x=!1;if(this._hitLimit)x=!1;else if(_&&(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:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Params=void 0;const h=2147483647;class f{static fromArray(m){const _=new f;if(!m.length)return _;for(let x=Array.isArray(m[0])?1:0;x<m.length;++x){const w=m[x];if(Array.isArray(w))for(let k=0;k<w.length;++k)_.addSubParam(w[k]);else _.addParam(w)}return _}constructor(m=32,_=32){if(this.maxLength=m,this.maxSubParamsLength=_,_>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(m),this.length=0,this._subParams=new Int32Array(_),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(m),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const m=new f(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 _=0;_<this.length;++_){m.push(this.params[_]);const x=this._subParamsIdx[_]>>8,w=255&this._subParamsIdx[_];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>h?h: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>h?h:m,this._subParamsIdx[this.length-1]++}}hasSubParams(m){return(255&this._subParamsIdx[m])-(this._subParamsIdx[m]>>8)>0}getSubParams(m){const _=this._subParamsIdx[m]>>8,x=255&this._subParamsIdx[m];return x-_>0?this._subParams.subarray(_,x):null}getSubParamsAll(){const m={};for(let _=0;_<this.length;++_){const x=this._subParamsIdx[_]>>8,w=255&this._subParamsIdx[_];w-x>0&&(m[_]=this._subParams.slice(x,w))}return m}addDigit(m){let _;if(this._rejectDigits||!(_=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const x=this._digitIsSub?this._subParams:this.params,w=x[_-1];x[_-1]=~w?Math.min(10*w+m,h):m}}c.Params=f},5741:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.AddonManager=void 0,c.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let h=this._addons.length-1;h>=0;h--)this._addons[h].instance.dispose()}loadAddon(h,f){const p={instance:f,dispose:f.dispose,isDisposed:!1};this._addons.push(p),f.dispose=()=>this._wrappedAddonDispose(p),f.activate(h)}_wrappedAddonDispose(h){if(h.isDisposed)return;let f=-1;for(let p=0;p<this._addons.length;p++)if(this._addons[p]===h){f=p;break}if(f===-1)throw new Error("Could not dispose an addon that has not been loaded");h.isDisposed=!0,h.dispose.apply(h.instance),this._addons.splice(f,1)}}},8771:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferApiView=void 0;const f=h(3785),p=h(511);c.BufferApiView=class{constructor(m,_){this._buffer=m,this.type=_}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 _=this._buffer.lines.get(m);if(_)return new f.BufferLineApiView(_)}getNullCell(){return new p.CellData}}},3785:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLineApiView=void 0;const f=h(511);c.BufferLineApiView=class{constructor(p){this._line=p}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(p,m){if(!(p<0||p>=this._line.length))return m?(this._line.loadCell(p,m),m):this._line.loadCell(p,new f.CellData)}translateToString(p,m,_){return this._line.translateToString(p,m,_)}}},8285:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferNamespaceApi=void 0;const f=h(8771),p=h(8460),m=h(844);class _ extends m.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new p.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new f.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new f.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}c.BufferNamespaceApi=_},7975:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ParserApi=void 0,c.ParserApi=class{constructor(h){this._core=h}registerCsiHandler(h,f){return this._core.registerCsiHandler(h,(p=>f(p.toArray())))}addCsiHandler(h,f){return this.registerCsiHandler(h,f)}registerDcsHandler(h,f){return this._core.registerDcsHandler(h,((p,m)=>f(p,m.toArray())))}addDcsHandler(h,f){return this.registerDcsHandler(h,f)}registerEscHandler(h,f){return this._core.registerEscHandler(h,f)}addEscHandler(h,f){return this.registerEscHandler(h,f)}registerOscHandler(h,f){return this._core.registerOscHandler(h,f)}addOscHandler(h,f){return this.registerOscHandler(h,f)}}},7090:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeApi=void 0,c.UnicodeApi=class{constructor(h){this._core=h}register(h){this._core.unicodeService.register(h)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(h){this._core.unicodeService.activeVersion=h}}},744:function(u,c,h){var f=this&&this.__decorate||function(y,S,v,b){var E,T=arguments.length,N=T<3?S:b===null?b=Object.getOwnPropertyDescriptor(S,v):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(y,S,v,b);else for(var L=y.length-1;L>=0;L--)(E=y[L])&&(N=(T<3?E(N):T>3?E(S,v,N):E(S,v))||N);return T>3&&N&&Object.defineProperty(S,v,N),N},p=this&&this.__param||function(y,S){return function(v,b){S(v,b,y)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferService=c.MINIMUM_ROWS=c.MINIMUM_COLS=void 0;const m=h(8460),_=h(844),x=h(5295),w=h(2585);c.MINIMUM_COLS=2,c.MINIMUM_ROWS=1;let k=c.BufferService=class extends _.Disposable{get buffer(){return this.buffers.active}constructor(y){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(y.rawOptions.cols||0,c.MINIMUM_COLS),this.rows=Math.max(y.rawOptions.rows||0,c.MINIMUM_ROWS),this.buffers=this.register(new x.BufferSet(y,this))}resize(y,S){this.cols=y,this.rows=S,this.buffers.resize(y,S),this._onResize.fire({cols:y,rows:S})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(y,S=!1){const v=this.buffer;let b;b=this._cachedBlankLine,b&&b.length===this.cols&&b.getFg(0)===y.fg&&b.getBg(0)===y.bg||(b=v.getBlankLine(y,S),this._cachedBlankLine=b),b.isWrapped=S;const E=v.ybase+v.scrollTop,T=v.ybase+v.scrollBottom;if(v.scrollTop===0){const N=v.lines.isFull;T===v.lines.length-1?N?v.lines.recycle().copyFrom(b):v.lines.push(b.clone()):v.lines.splice(T+1,0,b.clone()),N?this.isUserScrolling&&(v.ydisp=Math.max(v.ydisp-1,0)):(v.ybase++,this.isUserScrolling||v.ydisp++)}else{const N=T-E+1;v.lines.shiftElements(E+1,N-1,-1),v.lines.set(T,b.clone())}this.isUserScrolling||(v.ydisp=v.ybase),this._onScroll.fire(v.ydisp)}scrollLines(y,S,v){const b=this.buffer;if(y<0){if(b.ydisp===0)return;this.isUserScrolling=!0}else y+b.ydisp>=b.ybase&&(this.isUserScrolling=!1);const E=b.ydisp;b.ydisp=Math.max(Math.min(b.ydisp+y,b.ybase),0),E!==b.ydisp&&(S||this._onScroll.fire(b.ydisp))}};c.BufferService=k=f([p(0,w.IOptionsService)],k)},7994:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CharsetService=void 0,c.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(h){this.glevel=h,this.charset=this._charsets[h]}setgCharset(h,f){this._charsets[h]=f,this.glevel===h&&(this.charset=f)}}},1753:function(u,c,h){var f=this&&this.__decorate||function(b,E,T,N){var L,A=arguments.length,D=A<3?E:N===null?N=Object.getOwnPropertyDescriptor(E,T):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(b,E,T,N);else for(var B=b.length-1;B>=0;B--)(L=b[B])&&(D=(A<3?L(D):A>3?L(E,T,D):L(E,T))||D);return A>3&&D&&Object.defineProperty(E,T,D),D},p=this&&this.__param||function(b,E){return function(T,N){E(T,N,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreMouseService=void 0;const m=h(2585),_=h(8460),x=h(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 k(b,E){let T=(b.ctrl?16:0)|(b.shift?4:0)|(b.alt?8:0);return b.button===4?(T|=64,T|=b.action):(T|=3&b.button,4&b.button&&(T|=64),8&b.button&&(T|=128),b.action===32?T|=32:b.action!==0||E||(T|=3)),T}const y=String.fromCharCode,S={DEFAULT:b=>{const E=[k(b,!1)+32,b.col+32,b.row+32];return E[0]>255||E[1]>255||E[2]>255?"":`\x1B[M${y(E[0])}${y(E[1])}${y(E[2])}`},SGR:b=>{const E=b.action===0&&b.button!==4?"m":"M";return`\x1B[<${k(b,!0)};${b.col};${b.row}${E}`},SGR_PIXELS:b=>{const E=b.action===0&&b.button!==4?"m":"M";return`\x1B[<${k(b,!0)};${b.x};${b.y}${E}`}};let v=c.CoreMouseService=class extends x.Disposable{constructor(b,E){super(),this._bufferService=b,this._coreService=E,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new _.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const T of Object.keys(w))this.addProtocol(T,w[T]);for(const T of Object.keys(S))this.addEncoding(T,S[T]);this.reset()}addProtocol(b,E){this._protocols[b]=E}addEncoding(b,E){this._encodings[b]=E}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 E=this._encodings[this._activeEncoding](b);return E&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(E):this._coreService.triggerDataEvent(E,!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,E,T){if(T){if(b.x!==E.x||b.y!==E.y)return!1}else if(b.col!==E.col||b.row!==E.row)return!1;return b.button===E.button&&b.action===E.action&&b.ctrl===E.ctrl&&b.alt===E.alt&&b.shift===E.shift}};c.CoreMouseService=v=f([p(0,m.IBufferService),p(1,m.ICoreService)],v)},6975:function(u,c,h){var f=this&&this.__decorate||function(v,b,E,T){var N,L=arguments.length,A=L<3?b:T===null?T=Object.getOwnPropertyDescriptor(b,E):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,b,E,T);else for(var D=v.length-1;D>=0;D--)(N=v[D])&&(A=(L<3?N(A):L>3?N(b,E,A):N(b,E))||A);return L>3&&A&&Object.defineProperty(b,E,A),A},p=this&&this.__param||function(v,b){return function(E,T){b(E,T,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreService=void 0;const m=h(1439),_=h(8460),x=h(844),w=h(2585),k=Object.freeze({insertMode:!1}),y=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let S=c.CoreService=class extends x.Disposable{constructor(v,b,E){super(),this._bufferService=v,this._logService=b,this._optionsService=E,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new _.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new _.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new _.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new _.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,m.clone)(k),this.decPrivateModes=(0,m.clone)(y)}reset(){this.modes=(0,m.clone)(k),this.decPrivateModes=(0,m.clone)(y)}triggerDataEvent(v,b=!1){if(this._optionsService.rawOptions.disableStdin)return;const E=this._bufferService.buffer;b&&this._optionsService.rawOptions.scrollOnUserInput&&E.ybase!==E.ydisp&&this._onRequestScrollToBottom.fire(),b&&this._onUserInput.fire(),this._logService.debug(`sending data "${v}"`,(()=>v.split("").map((T=>T.charCodeAt(0))))),this._onData.fire(v)}triggerBinaryEvent(v){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${v}"`,(()=>v.split("").map((b=>b.charCodeAt(0))))),this._onBinary.fire(v))}};c.CoreService=S=f([p(0,w.IBufferService),p(1,w.ILogService),p(2,w.IOptionsService)],S)},9074:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DecorationService=void 0;const f=h(8055),p=h(8460),m=h(844),_=h(6106);let x=0,w=0;class k extends m.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new _.SortedList((v=>v==null?void 0:v.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(v){if(v.marker.isDisposed)return;const b=new y(v);if(b){const E=b.marker.onDispose((()=>b.dispose()));b.onDispose((()=>{b&&(this._decorations.delete(b)&&this._onDecorationRemoved.fire(b),E.dispose())})),this._decorations.insert(b),this._onDecorationRegistered.fire(b)}return b}reset(){for(const v of this._decorations.values())v.dispose();this._decorations.clear()}*getDecorationsAtCell(v,b,E){let T=0,N=0;for(const L of this._decorations.getKeyIterator(b))T=L.options.x??0,N=T+(L.options.width??1),v>=T&&v<N&&(!E||(L.options.layer??"bottom")===E)&&(yield L)}forEachDecorationAtCell(v,b,E,T){this._decorations.forEachByKey(b,(N=>{x=N.options.x??0,w=x+(N.options.width??1),v>=x&&v<w&&(!E||(N.options.layer??"bottom")===E)&&T(N)}))}}c.DecorationService=k;class y extends m.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=f.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=f.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(v){super(),this.options=v,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=v.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.InstantiationService=c.ServiceCollection=void 0;const f=h(2585),p=h(8343);class m{constructor(...x){this._entries=new Map;for(const[w,k]of x)this.set(w,k)}set(x,w){const k=this._entries.get(x);return this._entries.set(x,w),k}forEach(x){for(const[w,k]of this._entries.entries())x(w,k)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}c.ServiceCollection=m,c.InstantiationService=class{constructor(){this._services=new m,this._services.set(f.IInstantiationService,this)}setService(_,x){this._services.set(_,x)}getService(_){return this._services.get(_)}createInstance(_,...x){const w=(0,p.getServiceDependencies)(_).sort(((S,v)=>S.index-v.index)),k=[];for(const S of w){const v=this._services.get(S.id);if(!v)throw new Error(`[createInstance] ${_.name} depends on UNKNOWN service ${S.id}.`);k.push(v)}const y=w.length>0?w[0].index:x.length;if(x.length!==y)throw new Error(`[createInstance] First service dependency of ${_.name} at position ${y+1} conflicts with ${x.length} static arguments`);return new _(...x,...k)}}},7866:function(u,c,h){var f=this&&this.__decorate||function(y,S,v,b){var E,T=arguments.length,N=T<3?S:b===null?b=Object.getOwnPropertyDescriptor(S,v):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(y,S,v,b);else for(var L=y.length-1;L>=0;L--)(E=y[L])&&(N=(T<3?E(N):T>3?E(S,v,N):E(S,v))||N);return T>3&&N&&Object.defineProperty(S,v,N),N},p=this&&this.__param||function(y,S){return function(v,b){S(v,b,y)}};Object.defineProperty(c,"__esModule",{value:!0}),c.traceCall=c.setTraceLogger=c.LogService=void 0;const m=h(844),_=h(2585),x={trace:_.LogLevelEnum.TRACE,debug:_.LogLevelEnum.DEBUG,info:_.LogLevelEnum.INFO,warn:_.LogLevelEnum.WARN,error:_.LogLevelEnum.ERROR,off:_.LogLevelEnum.OFF};let w,k=c.LogService=class extends m.Disposable{get logLevel(){return this._logLevel}constructor(y){super(),this._optionsService=y,this._logLevel=_.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=x[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(y){for(let S=0;S<y.length;S++)typeof y[S]=="function"&&(y[S]=y[S]())}_log(y,S,v){this._evalLazyOptionalParams(v),y.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+S,...v)}trace(y,...S){var v;this._logLevel<=_.LogLevelEnum.TRACE&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.trace.bind(this._optionsService.options.logger))??console.log,y,S)}debug(y,...S){var v;this._logLevel<=_.LogLevelEnum.DEBUG&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.debug.bind(this._optionsService.options.logger))??console.log,y,S)}info(y,...S){var v;this._logLevel<=_.LogLevelEnum.INFO&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.info.bind(this._optionsService.options.logger))??console.info,y,S)}warn(y,...S){var v;this._logLevel<=_.LogLevelEnum.WARN&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.warn.bind(this._optionsService.options.logger))??console.warn,y,S)}error(y,...S){var v;this._logLevel<=_.LogLevelEnum.ERROR&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.error.bind(this._optionsService.options.logger))??console.error,y,S)}};c.LogService=k=f([p(0,_.IOptionsService)],k),c.setTraceLogger=function(y){w=y},c.traceCall=function(y,S,v){if(typeof v.value!="function")throw new Error("not supported");const b=v.value;v.value=function(...E){if(w.logLevel!==_.LogLevelEnum.TRACE)return b.apply(this,E);w.trace(`GlyphRenderer#${b.name}(${E.map((N=>JSON.stringify(N))).join(", ")})`);const T=b.apply(this,E);return w.trace(`GlyphRenderer#${b.name} return`,T),T}}},7302:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OptionsService=c.DEFAULT_OPTIONS=void 0;const f=h(8460),p=h(844),m=h(6114);c.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:m.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const _=["normal","bold","100","200","300","400","500","600","700","800","900"];class x extends p.Disposable{constructor(k){super(),this._onOptionChange=this.register(new f.EventEmitter),this.onOptionChange=this._onOptionChange.event;const y={...c.DEFAULT_OPTIONS};for(const S in k)if(S in y)try{const v=k[S];y[S]=this._sanitizeAndValidateOption(S,v)}catch(v){console.error(v)}this.rawOptions=y,this.options={...y},this._setupOptions(),this.register((0,p.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(k,y){return this.onOptionChange((S=>{S===k&&y(this.rawOptions[k])}))}onMultipleOptionChange(k,y){return this.onOptionChange((S=>{k.indexOf(S)!==-1&&y()}))}_setupOptions(){const k=S=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);return this.rawOptions[S]},y=(S,v)=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);v=this._sanitizeAndValidateOption(S,v),this.rawOptions[S]!==v&&(this.rawOptions[S]=v,this._onOptionChange.fire(S))};for(const S in this.rawOptions){const v={get:k.bind(this,S),set:y.bind(this,S)};Object.defineProperty(this.options,S,v)}}_sanitizeAndValidateOption(k,y){switch(k){case"cursorStyle":if(y||(y=c.DEFAULT_OPTIONS[k]),!(function(S){return S==="block"||S==="underline"||S==="bar"})(y))throw new Error(`"${y}" is not a valid value for ${k}`);break;case"wordSeparator":y||(y=c.DEFAULT_OPTIONS[k]);break;case"fontWeight":case"fontWeightBold":if(typeof y=="number"&&1<=y&&y<=1e3)break;y=_.includes(y)?y:c.DEFAULT_OPTIONS[k];break;case"cursorWidth":y=Math.floor(y);case"lineHeight":case"tabStopWidth":if(y<1)throw new Error(`${k} cannot be less than 1, value: ${y}`);break;case"minimumContrastRatio":y=Math.max(1,Math.min(21,Math.round(10*y)/10));break;case"scrollback":if((y=Math.min(y,4294967295))<0)throw new Error(`${k} cannot be less than 0, value: ${y}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(y<=0)throw new Error(`${k} cannot be less than or equal to 0, value: ${y}`);break;case"rows":case"cols":if(!y&&y!==0)throw new Error(`${k} must be numeric, value: ${y}`);break;case"windowsPty":y=y??{}}return y}}c.OptionsService=x},2660:function(u,c,h){var f=this&&this.__decorate||function(x,w,k,y){var S,v=arguments.length,b=v<3?w:y===null?y=Object.getOwnPropertyDescriptor(w,k):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(x,w,k,y);else for(var E=x.length-1;E>=0;E--)(S=x[E])&&(b=(v<3?S(b):v>3?S(w,k,b):S(w,k))||b);return v>3&&b&&Object.defineProperty(w,k,b),b},p=this&&this.__param||function(x,w){return function(k,y){w(k,y,x)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkService=void 0;const m=h(2585);let _=c.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 E=w.addMarker(w.ybase+w.y),T={data:x,id:this._nextId++,lines:[E]};return E.onDispose((()=>this._removeMarkerFromLink(T,E))),this._dataByLinkId.set(T.id,T),T.id}const k=x,y=this._getEntryIdKey(k),S=this._entriesWithId.get(y);if(S)return this.addLineToLink(S.id,w.ybase+w.y),S.id;const v=w.addMarker(w.ybase+w.y),b={id:this._nextId++,key:this._getEntryIdKey(k),data:k,lines:[v]};return v.onDispose((()=>this._removeMarkerFromLink(b,v))),this._entriesWithId.set(b.key,b),this._dataByLinkId.set(b.id,b),b.id}addLineToLink(x,w){const k=this._dataByLinkId.get(x);if(k&&k.lines.every((y=>y.line!==w))){const y=this._bufferService.buffer.addMarker(w);k.lines.push(y),y.onDispose((()=>this._removeMarkerFromLink(k,y)))}}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 k=x.lines.indexOf(w);k!==-1&&(x.lines.splice(k,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.id)))}};c.OscLinkService=_=f([p(0,m.IBufferService)],_)},8343:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createDecorator=c.getServiceDependencies=c.serviceRegistry=void 0;const h="di$target",f="di$dependencies";c.serviceRegistry=new Map,c.getServiceDependencies=function(p){return p[f]||[]},c.createDecorator=function(p){if(c.serviceRegistry.has(p))return c.serviceRegistry.get(p);const m=function(_,x,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(k,y,S){y[h]===y?y[f].push({id:k,index:S}):(y[f]=[{id:k,index:S}],y[h]=y)})(m,_,w)};return m.toString=()=>p,c.serviceRegistry.set(p,m),m}},2585:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.IDecorationService=c.IUnicodeService=c.IOscLinkService=c.IOptionsService=c.ILogService=c.LogLevelEnum=c.IInstantiationService=c.ICharsetService=c.ICoreService=c.ICoreMouseService=c.IBufferService=void 0;const f=h(8343);var p;c.IBufferService=(0,f.createDecorator)("BufferService"),c.ICoreMouseService=(0,f.createDecorator)("CoreMouseService"),c.ICoreService=(0,f.createDecorator)("CoreService"),c.ICharsetService=(0,f.createDecorator)("CharsetService"),c.IInstantiationService=(0,f.createDecorator)("InstantiationService"),(function(m){m[m.TRACE=0]="TRACE",m[m.DEBUG=1]="DEBUG",m[m.INFO=2]="INFO",m[m.WARN=3]="WARN",m[m.ERROR=4]="ERROR",m[m.OFF=5]="OFF"})(p||(c.LogLevelEnum=p={})),c.ILogService=(0,f.createDecorator)("LogService"),c.IOptionsService=(0,f.createDecorator)("OptionsService"),c.IOscLinkService=(0,f.createDecorator)("OscLinkService"),c.IUnicodeService=(0,f.createDecorator)("UnicodeService"),c.IDecorationService=(0,f.createDecorator)("DecorationService")},1480:(u,c,h)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeService=void 0;const f=h(8460),p=h(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,k=!1){return(16777215&x)<<3|(3&w)<<1|(k?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new f.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,k=0;const y=x.length;for(let S=0;S<y;++S){let v=x.charCodeAt(S);if(55296<=v&&v<=56319){if(++S>=y)return w+this.wcwidth(v);const T=x.charCodeAt(S);56320<=T&&T<=57343?v=1024*(v-55296)+T-56320+65536:w+=this.wcwidth(T)}const b=this.charProperties(v,k);let E=m.extractWidth(b);m.extractShouldJoin(b)&&(E-=m.extractWidth(k)),w+=E,k=b}return w}charProperties(x,w){return this._activeProvider.charProperties(x,w)}}c.UnicodeService=m}},s={};function a(u){var c=s[u];if(c!==void 0)return c.exports;var h=s[u]={exports:{}};return n[u].call(h.exports,h,h.exports,a),h.exports}var l={};return(()=>{var u=l;Object.defineProperty(u,"__esModule",{value:!0}),u.Terminal=void 0;const c=a(9042),h=a(3236),f=a(844),p=a(5741),m=a(8285),_=a(7975),x=a(7090),w=["cols","rows"];class k extends f.Disposable{constructor(S){super(),this._core=this.register(new h.Terminal(S)),this._addonManager=this.register(new p.AddonManager),this._publicOptions={...this._core.options};const v=E=>this._core.options[E],b=(E,T)=>{this._checkReadonlyOptions(E),this._core.options[E]=T};for(const E in this._core.options){const T={get:v.bind(this,E),set:b.bind(this,E)};Object.defineProperty(this._publicOptions,E,T)}}_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 _.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 v="none";switch(this._core.coreMouseService.activeProtocol){case"X10":v="x10";break;case"VT200":v="vt200";break;case"DRAG":v="drag";break;case"ANY":v="any"}return{applicationCursorKeysMode:S.applicationCursorKeys,applicationKeypadMode:S.applicationKeypad,bracketedPasteMode:S.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:v,originMode:S.origin,reverseWraparoundMode:S.reverseWraparound,sendFocusMode:S.sendFocus,wraparoundMode:S.wraparound}}get options(){return this._publicOptions}set options(S){for(const v in S)this._publicOptions[v]=S[v]}blur(){this._core.blur()}focus(){this._core.focus()}input(S,v=!0){this._core.input(S,v)}resize(S,v){this._verifyIntegers(S,v),this._core.resize(S,v)}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,v,b){this._verifyIntegers(S,v,b),this._core.select(S,v,b)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(S,v){this._verifyIntegers(S,v),this._core.selectLines(S,v)}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,v){this._core.write(S,v)}writeln(S,v){this._core.write(S),this._core.write(`\r
|
|
66
|
+
`,v)}paste(S){this._core.paste(S)}refresh(S,v){this._verifyIntegers(S,v),this._core.refresh(S,v)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(S){this._addonManager.loadAddon(this,S)}static get strings(){return c}_verifyIntegers(...S){for(const v of S)if(v===1/0||isNaN(v)||v%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...S){for(const v of S)if(v&&(v===1/0||isNaN(v)||v%1!=0||v<0))throw new Error("This API only accepts positive integers")}}u.Terminal=k})(),l})()))})(Of)),Of.exports}var dN=uN();/**
|
|
67
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
68
|
+
* @license MIT
|
|
69
|
+
*
|
|
70
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
71
|
+
* @license MIT
|
|
72
|
+
*
|
|
73
|
+
* Originally forked from (with the author's permission):
|
|
74
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
75
|
+
* http://bellard.org/jslinux/
|
|
76
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
77
|
+
*/var hN=2,fN=1,mN=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let n=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(n._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){var _;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let n=this._terminal.options.scrollback===0?0:((_=this._terminal.options.overviewRuler)==null?void 0:_.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),a=parseInt(s.getPropertyValue("height")),l=Math.max(0,parseInt(s.getPropertyValue("width"))),u=window.getComputedStyle(this._terminal.element),c={top:parseInt(u.getPropertyValue("padding-top")),bottom:parseInt(u.getPropertyValue("padding-bottom")),right:parseInt(u.getPropertyValue("padding-right")),left:parseInt(u.getPropertyValue("padding-left"))},h=c.top+c.bottom,f=c.right+c.left,p=a-h,m=l-f-n;return{cols:Math.max(hN,Math.floor(m/t.css.cell.width)),rows:Math.max(fN,Math.floor(p/t.css.cell.height))}}};function pN({sessionId:e,onClose:t,onEscape:n,autoFocus:s}){const a=R.useRef(null),l=R.useRef(e),u=R.useRef(null),c=R.useRef(null),h=_r(p=>p.writeSession),f=_r(p=>p.resizeSession);return R.useEffect(()=>{l.current=e},[e]),R.useEffect(()=>{if(!n)return;const p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),n())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]),R.useEffect(()=>{if(!a.current)return;const p=new dN.Terminal({fontFamily:'"JetBrains Mono", monospace',fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),m=new mN;p.loadAddon(m),u.current={term:p,fitAddon:m},a.current.addEventListener("keydown",k=>{k.key==="Escape"&&n&&(k.preventDefault(),k.stopPropagation(),n())}),p.open(a.current);const _=a.current.querySelector(".xterm");_&&(_.style.padding="8px"),m.fit(),s&&setTimeout(()=>{p.focus()},150);const x=new ResizeObserver(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{requestAnimationFrame(()=>{var y;m.fit&&m.fit();const k=(y=u.current)==null?void 0:y.term;k&&k.cols>0&&k.rows>0&&f(l.current,k.cols,k.rows)})},100)});x.observe(a.current),p.onData(k=>{if(k==="\x1B"&&n){n();return}h(l.current,k)}),p.onKey(k=>{k.key==="\x1B"&&n&&(k.domEvent.stopPropagation(),n())});const w=zt.subscribe(k=>{const y=k.payload;if(k.type==="terminal.output"&&(y==null?void 0:y.sessionId)===l.current){const S=y==null?void 0:y.data;S&&p.write(S)}});return()=>{w(),x.disconnect(),c.current&&clearTimeout(c.current),p.dispose(),u.current=null}},[e,h,f]),o.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[o.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[o.jsx("div",{}),o.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:o.jsx(_S,{})})]}),o.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:p=>{p.key==="Escape"&&n&&(p.preventDefault(),p.stopPropagation(),n())}})]})}const LS="openfox-chat-textarea";function DS(){const e=document.getElementById(LS);e&&e.focus()}function gN(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 xN({isOpen:e,onClose:t}){const n=_r(w=>w.createSession),s=_r(w=>w.killSession),a=_r(w=>w.sessions),l=_r(w=>w.setWorkdir),u=_r(w=>w.fetchSessions),c=Lt(w=>w.currentProject),[h,f]=R.useState(!0),p=R.useRef(null),m=R.useRef(!1),_=R.useRef(!1),x=R.useCallback(()=>{t()},[t]);return R.useEffect(()=>{c!=null&&c.workdir&&l(c.workdir)},[c==null?void 0:c.workdir,l]),R.useEffect(()=>{e?(f(!0),u(c==null?void 0:c.id).finally(()=>f(!1))):DS()},[e,u,c==null?void 0:c.id]),R.useEffect(()=>{e&&a.length===0&&!h&&!_.current&&(_.current=!0,n(void 0,c==null?void 0:c.id))},[e,a.length,h,n,c==null?void 0:c.id]),R.useEffect(()=>{e?(m.current=!0,setTimeout(()=>{var w;(w=p.current)==null||w.focus(),setTimeout(()=>{m.current=!1},200)},100)):_.current=!1},[e]),R.useEffect(()=>{if(!e)return;const w=k=>{m.current||k.key==="Escape"&&(k.preventDefault(),t())};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e,t]),e?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:x}),o.jsxs("div",{ref:p,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:w=>w.stopPropagation(),onKeyDown:w=>{w.key==="Escape"&&(w.preventDefault(),x())},children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:()=>n(void 0,c==null?void 0:c.id),className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New terminal",children:o.jsx(Nj,{})}),o.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:o.jsx(gl,{})})]})]}),o.jsx("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:h?o.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):a.length===0?o.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:o.jsxs("div",{className:"text-center",children:[o.jsx("p",{className:"mb-4",children:"No terminal sessions"}),o.jsx("button",{onClick:()=>n(void 0,c==null?void 0:c.id),className:"px-4 py-2 bg-accent-primary/25 text-text-primary rounded hover:bg-accent-primary/40 transition-colors",children:"Create Terminal"})]})}):o.jsx("div",{className:`grid ${gN(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(w=>o.jsx(pN,{sessionId:w.id,onClose:()=>s(w.id),onEscape:x,autoFocus:a.length===1},w.id))})})]})]}):null}function xl({items:e,footerItems:t=[],trigger:n,minWidth:s="120px",isOpen:a,onOpenChange:l}){const[u,c]=R.useState(!1),h=a!==void 0,f=h?a:u,p=O=>{if(h){const V=typeof O=="function"?O(u):O;l==null||l(V)}else c(O)},[m,_]=R.useState(null),x=R.useRef(null),w=R.useRef(null),[k,y]=R.useState(0),S=R.useRef(0),v=R.useMemo(()=>[...e,...t],[e,t]),b=R.useRef(v),E=R.useCallback(()=>{if(!x.current)return;const O=x.current.getBoundingClientRect(),V=200,z=window.innerHeight-O.bottom<V;_({top:z?O.top-V-4:O.bottom+4,left:O.left,alignToTop:z})},[]);R.useEffect(()=>{b.current=v},[v]),R.useEffect(()=>{function O(V){if(w.current){const G=V.target;w.current.contains(G)||p(!1)}}return f&&document.addEventListener("mousedown",O),()=>{document.removeEventListener("mousedown",O)}},[f]),R.useEffect(()=>{f&&E()},[f,E]),R.useEffect(()=>{if(!f)return;setTimeout(()=>{var V;(V=w.current)==null||V.focus()},0);function O(V){const G=b.current,z=G.filter(ne=>!T(ne)),X=N(S.current,G);switch(V.key){case"ArrowDown":if(V.preventDefault(),V.stopPropagation(),X<z.length-1){const ne=L(S.current+1,G);S.current=ne,y(ne)}break;case"ArrowUp":if(V.preventDefault(),V.stopPropagation(),X>0){const ne=A(S.current-1,G);S.current=ne,y(ne)}break;case"Enter":V.preventDefault(),V.stopPropagation(),D(S.current,G);break;case"Escape":V.preventDefault(),V.stopPropagation(),p(!1);break}}return window.addEventListener("keydown",O,!0),()=>window.removeEventListener("keydown",O,!0)},[f,v]);function T(O){var z;const V=O.label;return V?String(((z=V.props)==null?void 0:z.className)??"").includes("cursor-default"):!1}function N(O,V){let G=0;for(let z=0;z<O;z++){const X=V[z];X&&!T(X)&&G++}return G}function L(O,V){for(let G=O;G<V.length;G++){const z=V[G];if(z&&!T(z))return G}return O}function A(O,V){for(let G=O;G>=0;G--){const z=V[G];if(z&&!T(z))return G}return O}function D(O,V){var z;const G=V[O];!G||T(G)||((z=G.onClick)==null||z.call(G),G.href&&(window.history.pushState(null,"",G.href),window.dispatchEvent(new PopStateEvent("popstate"))),p(!1))}R.useEffect(()=>{f&&(y(v.findIndex(O=>!T(O))),S.current=v.findIndex(O=>!T(O)))},[f,v]);const B=O=>{O.stopPropagation(),f||E(),p(!f)};function q(O,V,G,z){const ne=!T(O)&&z===k,F=o.jsxs(o.Fragment,{children:[O.icon&&o.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:O.icon}),O.label]}),M=V!==G-1;return O.href?o.jsx(Gn,{href:O.href,onClick:$=>{var P;(P=O.onClick)==null||P.call(O,$),p(!1)},onAuxClick:()=>p(!1),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${O.danger?"text-accent-error hover:bg-accent-error/10":ne?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${M?"border-b border-border":""}`,children:F},z):o.jsx("button",{onClick:$=>{var P;(P=O.onClick)==null||P.call(O,$),O.closeOnClick!==!1&&p(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${O.danger?"text-accent-error hover:bg-accent-error/10":ne?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${M?"border-b border-border":""}`,children:F},z)}const W=m&&o.jsxs("div",{ref:w,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${m.alignToTop?"mb-1":"mt-1"}`,style:{top:m.top,left:m.left,minWidth:s},tabIndex:-1,children:[o.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:e.map((O,V)=>q(O,V,e.length,V))}),t.length>0&&o.jsx("div",{className:"border-t border-border",children:t.map((O,V)=>q(O,V,t.length,e.length+V))})]});return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"relative",children:o.jsx("div",{ref:x,onClick:B,children:n})}),f&&$a.createPortal(W,document.body)]})}const $u=R.forwardRef(({className:e="",...t},n)=>o.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}));$u.displayName="Input";function _N(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 RS({isOpen:e,onClose:t,path:n,onRetry:s}){const[a,l]=R.useState(!1),[u,c]=R.useState(null),[h,f]=R.useState(null);R.useEffect(()=>{e&&p()},[e]);const p=async()=>{try{const E=await(await Ne("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();f({sudoAvailable:E.sudoAvailable,userInGroup:E.userInGroup,groupHasWrite:E.groupHasWrite,groupName:E.groupName||null})}catch{f({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},m=R.useCallback(async b=>{l(!0),c(null);try{const T=await(await Ne("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:b})})).json();T.success?(s(),t()):T.sudoAvailable?c("Failed to fix permissions: "+(T.error||"Unknown error")):c(`Passwordless sudo is not available. Please fix permissions manually:
|
|
78
|
+
|
|
79
|
+
`+(b==="group"?`sudo chmod g+w "${n}"`:"sudo usermod -aG <group> $USER"))}catch(E){c("Failed to fix permissions: "+(E instanceof Error?E.message:"Unknown error"))}finally{l(!1)}},[n,s,t]),_=(h==null?void 0:h.userInGroup)??!1,x=(h==null?void 0:h.groupHasWrite)??!1,w=(h==null?void 0:h.sudoAvailable)??!1,k=(h==null?void 0:h.groupName)??"",y=_&&!x,S=!_&&x,v=!_&&!x;return o.jsx(Dt,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"text-sm text-text-secondary",children:[o.jsx("p",{children:y?o.jsxs(o.Fragment,{children:["The group ",o.jsx("strong",{children:k})," doesn't have write access:"]}):S?o.jsxs(o.Fragment,{children:["You're not a member of group ",o.jsx("strong",{children:k}),":"]}):o.jsxs(o.Fragment,{children:["You're not a member of group ",o.jsx("strong",{children:k})," and it doesn't have write access:"]})}),o.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),u?o.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:u}):h?o.jsxs("div",{className:"flex flex-col gap-2",children:[y&&o.jsxs(o.Fragment,{children:[o.jsx(tt,{type:"button",variant:"primary",onClick:()=>m("group"),disabled:a||!w,className:"w-full",children:a?"Granting access...":"Extend group permissions"}),o.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),o.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),S&&o.jsxs(o.Fragment,{children:[o.jsx(tt,{type:"button",variant:"primary",onClick:()=>m("join_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group"}),o.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),o.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",k," $USER"]})]}),v&&o.jsxs(o.Fragment,{children:[o.jsx(tt,{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"}),o.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),o.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",k," $USER",o.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!w&&!u&&o.jsxs("div",{className:"text-xs text-text-secondary",children:[o.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),o.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),o.jsx("div",{className:"flex justify-end",children:o.jsx(tt,{type:"button",variant:"secondary",onClick:t,disabled:a,children:"Cancel"})})]}):null]})})}function OS({isOpen:e,onClose:t}){const[,n]=cr(),s=Lt(T=>T.listProjects),[a,l]=R.useState(""),[u,c]=R.useState(null),[h,f]=R.useState(!1),[p,m]=R.useState(""),[_,x]=R.useState(null),w=R.useRef(null);R.useEffect(()=>{e&&(Ne("/api/config").then(T=>T.json()).then(T=>{T.workdir&&m(T.workdir)}),l(""),c(null),f(!1),x(null),setTimeout(()=>{var T;(T=w.current)==null||T.focus()},100))},[e]);const k=R.useCallback(async T=>{T.preventDefault();const N=_N(a);if(!N.valid){c(N.error);return}const L=`${p}/${a}`;await v(L)},[a,n,t,p]),y=R.useCallback(()=>{x(null)},[]),S=R.useCallback(async()=>{const T=`${p}/${a}`;await v(T)},[p,a,n,t,x,c,f]);async function v(T){f(!0),c(null),x(null);try{const N=await Ne("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,workdir:T})});if(!N.ok){const D=await N.json().catch(()=>({}));if(D.code==="EACCES"){x(T),f(!1);return}throw new Error(D.error||"Failed to create project")}const A=(await N.json()).project;t(),await s(),n(`/p/${A.id}`)}catch(N){c(N instanceof Error?N.message:"Failed to create project"),f(!1)}}const b=R.useCallback(()=>{l(""),c(null),t()},[t]),E=a?`${p}/${a}`:"";return o.jsxs(o.Fragment,{children:[o.jsx(Dt,{isOpen:e,onClose:b,title:"Create New Project",size:"sm",children:o.jsxs("form",{onSubmit:k,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),o.jsx($u,{ref:w,id:"project-name",value:a,onChange:T=>{l(T.target.value),c(null)},placeholder:"my-project",disabled:h,"data-testid":"create-project-name-input",className:"w-full"}),a&&o.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",o.jsx("span",{className:"font-mono",children:E})]}),u&&o.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:u})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(tt,{type:"button",variant:"secondary",onClick:b,disabled:h,children:"Cancel"}),o.jsx(tt,{type:"submit",variant:"primary",disabled:h||!a.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:h?o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(qs,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),_&&o.jsx(RS,{isOpen:!!_,onClose:y,path:_,onRetry:S})]})}const yN={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function _l({size:e="md",className:t=""}){return o.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${yN[e]} ${t}`})}function vN({text:e,...t}){return o.jsxs("div",{className:"text-center",children:[o.jsx(_l,{...t,className:"mx-auto mb-4"}),e&&o.jsx("div",{className:"text-text-secondary",children:e})]})}function xp({onSelect:e,onClose:t,initialPath:n}){const[s,a]=R.useState(null),[l,u]=R.useState(!0),[c,h]=R.useState(""),[f,p]=R.useState(-1),m=R.useRef(null),_=R.useRef([]),x=R.useCallback(async v=>{u(!0),h(""),p(-1);try{const b=v?`/api/directories?path=${encodeURIComponent(v)}`:"/api/directories",T=await(await Ne(b)).json();a(T)}catch(b){console.error("Failed to load directories:",b)}finally{u(!1)}},[]);R.useEffect(()=>{x(n)},[n,x]);const w=((s==null?void 0:s.current)??"").split("/").filter(Boolean).map((v,b,E)=>({name:v,path:"/"+E.slice(0,b+1).join("/")})),k=(s==null?void 0:s.directories.filter(v=>c===""||v.name.toLowerCase().includes(c.toLowerCase())))??[],y=[...s!=null&&s.parent?[{type:"parent",path:s.parent,name:".."}]:[],...k.map(v=>({type:"dir",path:v.path,name:v.name}))];R.useEffect(()=>{p(c?0:-1)},[c,k.length]),R.useEffect(()=>{var v;f>=0&&_.current[f]&&((v=_.current[f])==null||v.scrollIntoView({block:"nearest"}))},[f]);const S=v=>{var b;if(v.key==="ArrowDown")v.preventDefault(),p(E=>Math.min(E+1,y.length-1));else if(v.key==="ArrowUp")v.preventDefault(),p(E=>Math.max(E-1,0));else if(v.key==="Enter"){if(v.preventDefault(),f>=0&&y[f]){const E=y[f];E.type,x(E.path)}}else v.key==="Escape"&&(h(""),(b=m.current)==null||b.focus())};return o.jsxs(Dt,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",children:[s&&o.jsx("div",{className:"px-3 py-2 bg-bg-tertiary/30 -mx-4 -mt-4 mb-4 border-b border-border",children:o.jsxs("div",{className:"flex items-center text-xs overflow-x-auto",children:[w.map((v,b)=>o.jsxs("span",{className:"flex items-center shrink-0",children:[o.jsx("span",{className:"text-text-muted",children:"/"}),o.jsx("button",{onClick:()=>x(v.path),className:`px-1 ${b===w.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:v.name})]},v.path)),w.length===0&&o.jsx("button",{onClick:()=>x("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]})}),o.jsx("div",{className:"px-4 mb-3",children:o.jsxs("div",{className:"relative",children:[o.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:o.jsx(cp,{})}),o.jsx($u,{autoFocus:!0,ref:m,value:c,onChange:v=>h(v.target.value),onKeyDown:S,placeholder:"Filter directories...",className:"w-full pl-9"})]})}),o.jsx("div",{className:"flex-1 overflow-y-auto -mx-4",children:l?o.jsx("div",{className:"p-8 text-center",children:o.jsx(_l,{size:"sm"})}):y.length===0?o.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:c?"No matching directories":"No subdirectories"}):o.jsx("div",{className:"divide-y divide-border",children:y.map((v,b)=>o.jsxs("button",{ref:E=>{_.current[b]=E},onClick:()=>x(v.path),onDoubleClick:()=>e(v.path),className:`w-full p-3 flex items-center gap-3 text-left transition-colors ${b===f?"bg-accent-primary/20 text-accent-primary":"hover:bg-bg-tertiary/50"}`,children:[v.type==="parent"?o.jsx(gj,{className:"w-5 h-5 text-text-muted"}):o.jsx(Bu,{className:"w-5 h-5"}),o.jsx("span",{className:"flex-1",children:v.name}),b===f&&o.jsx("span",{className:"text-xs text-text-muted",children:"⏎ navigate · dbl-click select"})]},v.path))})}),o.jsxs("div",{className:"flex flex-col gap-2 pt-4 border-t border-border mt-4 -mx-4 -mb-4 p-4",children:[(s==null?void 0:s.current)&&o.jsx("button",{onClick:()=>e(s.current),className:"w-full px-4 py-2 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Select this folder"}),o.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})]})]})}function MS(){const[e,t]=R.useState(null);return R.useEffect(()=>{Ne("/api/config").then(n=>n.json()).then(n=>{n.workdir&&t(n.workdir)})},[]),e}function bN({projects:e,currentProject:t}){const[,n]=cr(),s=Lt(y=>y.loadProject),a=Lt(y=>y.toggleStar),l=Lt(y=>y.createProject),u=Lt(y=>y.listProjects),[c,h]=R.useState(!1),[f,p]=R.useState(!1),m=MS(),_=R.useCallback(async y=>{const S=y.split("/").filter(Boolean).pop()??"",v=await l(S,y);return v&&"id"in v?(await u(),p(!1),n(`/p/${v.id}`),!0):!1},[l,u,n]),w=R.useMemo(()=>{const y=e.filter(v=>v.isStarred).sort((v,b)=>v.name.localeCompare(b.name)),S=e.filter(v=>!v.isStarred).sort((v,b)=>v.name.localeCompare(b.name));return[...y,...S]},[e]).map(y=>({label:o.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[o.jsx("span",{className:"truncate flex-1",children:y.name}),o.jsx("button",{onClick:S=>{S.stopPropagation(),S.preventDefault(),S.nativeEvent.stopImmediatePropagation(),a(y.id,!y.isStarred)},className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:y.isStarred?"Unstar project":"Star project",children:y.isStarred?o.jsx(Lj,{className:"w-3.5 h-3.5 text-yellow-500"}):o.jsx(Dj,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:y.id===t.id?o.jsx(Mr,{}):void 0,href:`/p/${y.id}`,closeOnClick:!0,onClick:()=>{s(y.id)}})),k=[{label:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Bu,{className:"w-4 h-4"}),o.jsx("span",{children:"Open Project"})]}),onClick:()=>p(!0)},{label:o.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[o.jsx(qs,{className:"w-4 h-4"}),o.jsx("span",{children:"New Project"})]}),onClick:()=>h(!0)}];return o.jsxs(o.Fragment,{children:[o.jsx(xl,{items:w,footerItems:k,trigger:o.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:t.name,children:[t.name,o.jsx(Sr,{})]}),minWidth:"250px"}),c&&o.jsx(OS,{isOpen:c,onClose:()=>h(!1)}),f&&o.jsx(xp,{initialPath:m??void 0,onSelect:_,onClose:()=>p(!1)})]})}function IS(e){const t=new Date(e),s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.getDay()],a=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0");return`${s} ${a}/${l}/${u}`}function Uu(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0");return`${n}:${s}`}function SN(e){const t=new Date(e),n=new Date,s=new Date(n.getFullYear(),n.getMonth(),n.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=Math.floor((s.getTime()-a.getTime())/(1e3*60*60*24)),u=Uu(e);if(l===0)return`today ${u}`;if(l===1)return`yesterday ${u}`;if(l<7)return`${l} days ago ${u}`;{const c=t.getFullYear(),h=String(t.getMonth()+1).padStart(2,"0"),f=String(t.getDate()).padStart(2,"0");return`${c}/${h}/${f} ${u}`}}function PS(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 wN(e){const{year:t,month:n,day:s}=PS(e);return`${t}-${n}-${s}`}function BS(e){const t=new Map;for(const a of e){const l=wN(a.updatedAt);t.has(l)||t.set(l,[]),t.get(l).push(a)}for(const[a,l]of t)l.sort((u,c)=>{const h=new Date(u.updatedAt).getTime();return new Date(c.updatedAt).getTime()-h});const n=Array.from(t.keys()).sort((a,l)=>l.localeCompare(a)),s=new Map;for(const a of n)s.set(a,t.get(a));return s}function CN({sessions:e,currentProject:t,currentSession:n,isOpen:s,onOpenChange:a}){var p;const l=we(m=>m.loadSession),u=e.filter(m=>m.projectId===t.id).slice(0,15),c=BS(u),h=R.useMemo(()=>{const m=[];m.push({label:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(qs,{className:"w-4 h-4 text-accent-primary"}),o.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});for(const[_,x]of c){const w=x[0];if(w){m.push({label:o.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:IS(w.updatedAt)}),onClick:()=>{}});for(const k of x)m.push({label:o.jsxs("div",{className:"min-w-[160px]",children:[o.jsx("div",{className:"truncate text-sm",children:k.title??k.id.slice(0,8)}),o.jsx("div",{className:"text-text-muted text-xs",children:Uu(k.updatedAt)})]}),icon:k.id===(n==null?void 0:n.id)?o.jsx(Mr,{}):void 0,href:`/p/${t.id}/s/${k.id}`,onClick:()=>{l(k.id)}})}}return m},[t.id,c,n==null?void 0:n.id]),f=n?((p=n.metadata)==null?void 0:p.title)??n.id.slice(0,8):"No session selected";return o.jsx(xl,{items:h,isOpen:s,onOpenChange:a,trigger:o.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:f,"data-testid":"header-session-dropdown",children:[f,o.jsx(Sr,{})]}),minWidth:"280px"})}function kN({items:e,trigger:t,isActive:n=!1}){const[s,a]=R.useState(!1),l=R.useRef(null);return R.useEffect(()=>{function u(c){l.current&&!l.current.contains(c.target)&&a(!1)}if(s)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[s]),o.jsxs("div",{className:"relative",ref:l,children:[o.jsxs("button",{type:"button",onClick:()=>a(!s),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"?o.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,o.jsx(Sr,{className:"w-3 h-3 text-text-muted flex-shrink-0 transition-transform",rotate:s?180:0})]}),s&&e.length>0&&o.jsx("div",{className:"absolute top-full left-0 mt-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:e.map((u,c)=>{const h=u.label&&typeof u.label=="object"&&u.label.type===Gn?u.label:null;if(h){const f=h.props.href||"";return o.jsxs(Gn,{href:f,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,h.props.children]},c)}return u.href?o.jsxs("a",{href:u.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,u.label]},c):o.jsxs("button",{type:"button",onClick:()=>{var f;(f=u.onClick)==null||f.call(u),a(!1)},className:"flex items-center gap-2 px-3 py-2 text-sm w-full text-left border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,u.label]},c)})})]})}function EN({currentProject:e,sessions:t,currentSession:n,projectIdFromUrl:s}){if(!(e!=null&&e.id)||e.id!==s)return null;const a=t.filter(u=>u.projectId===e.id).sort((u,c)=>new Date(c.updatedAt).getTime()-new Date(u.updatedAt).getTime()).slice(0,5),l=[{label:o.jsxs(Gn,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[o.jsx(qs,{className:"w-3 h-3 text-accent-primary"}),o.jsx("span",{className:"text-sm",children:"New Session"})]})},...a.map(u=>({label:o.jsx(Gn,{href:`/p/${e.id}/s/${u.id}`,className:"flex items-center gap-2 truncate text-sm",children:o.jsx("span",{children:u.title??u.id.slice(0,8)})}),icon:u.id===(n==null?void 0:n.id)?o.jsx(Mr,{className:"w-3 h-3"}):void 0})),{label:o.jsxs(Gn,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[o.jsx(_j,{className:"w-3 h-3"}),o.jsx("span",{className:"text-sm",children:"Projects"})]})}];return o.jsx(kN,{items:l,trigger:o.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function jN({onMenuClick:e,onCriteriaToggle:t}){const[n,s]=R.useState(!1),[a,l]=R.useState(!1),[u,c]=R.useState(!!document.fullscreenElement);R.useEffect(()=>{const E=()=>c(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",E),()=>document.removeEventListener("fullscreenchange",E)},[]);const[h]=cr(),f=h.startsWith("/p/"),p=/^\/p\/[^/]+\/s\/[^/]+$/.test(h),m=we(E=>E.currentSession),_=we(E=>E.sessions),x=Lt(E=>E.currentProject),w=Lt(E=>E.projects),k=Bt(E=>E.startAutoRefresh),y=Bt(E=>E.stopAutoRefresh),S=_r(E=>E.setOpen),v=_r(E=>E.isOpen);R.useEffect(()=>{const E=()=>l(!0);return window.addEventListener("open-session-dropdown",E),()=>window.removeEventListener("open-session-dropdown",E)},[]);const b=up();return SS(b.terminalToggle,()=>{_r.getState().toggleOpen()},{capture:!0}),R.useEffect(()=>(k(),()=>y()),[k,y]),o.jsxs("header",{className:"h-8 bg-secondary border-b border-border flex items-center justify-between px-2",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&f&&o.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:"Toggle session list",children:o.jsx(Dv,{})}),o.jsx(Gn,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),x&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),o.jsx("span",{className:"hidden md:inline",children:o.jsx(bN,{projects:w,currentProject:x})}),o.jsx("span",{className:"md:hidden",children:o.jsx(EN,{currentProject:x,sessions:_,currentSession:m,projectIdFromUrl:f&&h.split("/")[2]||null},x==null?void 0:x.id)}),o.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),o.jsx("span",{className:"hidden md:inline",children:o.jsx(CN,{sessions:_,currentProject:x,currentSession:m,isOpen:a,onOpenChange:l})})]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[p&&o.jsx("button",{onClick:()=>{var E,T,N;document.fullscreenElement?(E=document.exitFullscreen)==null||E.call(document):(N=(T=document.documentElement).requestFullscreen)==null||N.call(T)},className:"max-sm:block hidden p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:u?"Exit fullscreen":"Enter fullscreen",children:u?o.jsx(Sj,{}):o.jsx(wj,{})}),f&&o.jsx("button",{onClick:()=>S(!v),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${v?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:o.jsx(Oj,{})}),o.jsx("button",{onClick:()=>s(!0),className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Settings",children:o.jsx(Tj,{})}),o.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),window.location.reload()},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:o.jsx(kj,{})}),t&&p&&o.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Toggle sidebar",children:o.jsx(Dv,{})})]}),o.jsx(cN,{isOpen:n,onClose:()=>s(!1)}),o.jsx(xN,{isOpen:v,onClose:()=>S(!1)})]})}function NN({onCancel:e,onSave:t,saving:n,saveDisabled:s,cancelLabel:a="Cancel",saveLabel:l=n?"Saving...":"Save"}){return o.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[o.jsx(tt,{variant:"secondary",onClick:e,children:a}),o.jsx(tt,{variant:"primary",onClick:t,disabled:s??n,children:l})]})}function TN({isOpen:e,onClose:t,project:n}){const s=Lt(E=>E.updateProject),a=()=>{try{zt.send("context.checkDynamic",{})}catch{}t()},[l,u]=R.useState(n.customInstructions??""),[c,h]=R.useState(n.dangerLevel??""),[f,p]=R.useState(!1),[m,_]=R.useState(!1),[x,w]=R.useState(!1),k=f||m;R.useEffect(()=>{u(n.customInstructions??""),h(n.dangerLevel??""),p(!1),_(!1)},[n]);const y=E=>{u(E.target.value),p(!0)},S=E=>{h(E),_(!0)},v=async()=>{w(!0);const E=c===""?null:c;await s(n.id,{customInstructions:l||null,dangerLevel:E}),w(!1),p(!1),_(!1),a()},b=()=>{u(n.customInstructions??""),h(n.dangerLevel??""),p(!1),_(!1),a()};return o.jsx(Dt,{isOpen:e,onClose:b,title:`${n.name} Settings`,size:"lg",footer:o.jsx(NN,{onCancel:b,onSave:v,saving:x,saveDisabled:!k||x}),children:o.jsxs("div",{className:"flex flex-col gap-5 -mt-1",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Danger Level"}),o.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."}),o.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit",children:[o.jsx("button",{type:"button",onClick:()=>S(""),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"}),o.jsx("button",{type:"button",onClick:()=>S("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"}),o.jsx("button",{type:"button",onClick:()=>S("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"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),o.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),o.jsxs("div",{className:"flex-1 min-h-[150px] pb-4",children:[o.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),o.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."}),o.jsx("textarea",{value:l,onChange:y,placeholder:"Enter project-specific instructions...",className:"w-full h-full px-3 py-2 mb-3 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:x})]})]})})}const AN={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},LN="M6 18L18 6M6 6l12 12";function yl({onClick:e,className:t="",size:n="md",variant:s="default"}){const a=s==="overlay"?"bg-accent-error text-white rounded-full flex items-center justify-center hover:bg-accent-error/80 transition-colors":s==="sidebar"?"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors":s==="modal"?"text-text-muted hover:text-text-primary transition-colors":"hover:text-white transition-colors";return o.jsx(zu,{onClick:e,icon:LN,iconSize:AN[n],className:`${a} ${t}`,title:"Close"})}function zS({projectId:e,isOpen:t=!0,onClose:n}){const[,s]=cr(),[a,l]=R.useState(!1),u=we(T=>T.sessions),c=we(T=>T.currentSession),h=we(T=>T.unreadSessionIds),f=we(T=>T.deleteSession),p=we(T=>T.deleteAllSessions),m=we(T=>T.loadMoreSessions),_=we(T=>T.sessionsHasMore),x=we(T=>T.sessionsPaginationLoading),w=Lt(T=>T.currentProject),k=R.useRef(null),y=R.useCallback(()=>{_&&!x&&w&&m(w.id)},[_,x,w,m]);R.useEffect(()=>{if(!k.current||!_)return;const T=new IntersectionObserver(N=>{const L=N[0];L&&L.isIntersecting&&y()},{threshold:.1});return T.observe(k.current),()=>T.disconnect()},[_,y]);const S=u.filter(T=>T.projectId===(w==null?void 0:w.id)),v=(T,N)=>{N==null||N.stopPropagation(),confirm("Delete this session?")&&(f(T),(c==null?void 0:c.id)===T&&s(`/p/${e}`))},b=(T,N)=>{N==null||N.stopPropagation();const L=u.find(B=>B.id===T),A=(L==null?void 0:L.title)??T.slice(0,6),D=prompt("Rename session:",A);if(D!==null&&D.trim()!==""){const B=we.getState().renameSession;B(T,D.trim())}},E=()=>{confirm("Delete all sessions in this project? This cannot be undone.")&&(p(e),s(`/p/${e}`))};return o.jsxs(o.Fragment,{children:[t&&n&&o.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),o.jsxs("aside",{className:`
|
|
80
|
+
${t?"md:w-[300px] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden"}
|
|
81
|
+
md:relative md:h-auto md:translate-x-0
|
|
82
|
+
|
|
83
|
+
fixed z-50 h-[calc(100vh-32px)]
|
|
84
|
+
w-[300px] bg-secondary border-r border-border flex flex-col
|
|
85
|
+
transition-all duration-300 ease-in-out
|
|
86
|
+
${t?"translate-x-0":"-translate-x-full"}
|
|
87
|
+
`,children:[o.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[o.jsx(Gn,{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"}),o.jsx(xl,{items:[{label:"Edit project settings",onClick:()=>l(!0)},{label:"Delete all sessions",onClick:E,danger:!0}],trigger:o.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:o.jsx(op,{})})}),n&&o.jsx(yl,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),w&&o.jsx(TN,{isOpen:a,onClose:()=>l(!1),project:w}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:S.length===0?o.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"No sessions"}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"divide-y divide-border",children:DN(S,c,h,v,b,e)}),x&&o.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),o.jsx("div",{ref:k,className:"h-px"})]})})]})]})}function DN(e,t,n,s,a,l){const u=BS(e);return Array.from(u).map(([c,h])=>{const f=h[0];return f?o.jsxs("div",{children:[o.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:IS(f.updatedAt)}),h.map(p=>{const m=(t==null?void 0:t.id)===p.id,_=n.includes(p.id),x=p.isRunning;return o.jsx("div",{className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${m?"bg-bg-tertiary":""}`,children:o.jsxs(Gn,{href:`/p/${l}/s/${p.id}`,className:`block ${m?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[o.jsxs("div",{className:"flex justify-between items-center mb-1",children:[o.jsx("span",{className:`font-medium truncate text-sm ${m?"text-accent-primary":"text-text-primary"}`,children:p.title??p.id.slice(0,6)}),o.jsx(xl,{items:[{label:"Rename session",onClick:w=>a(p.id,w)},{label:"Delete session",onClick:w=>s(p.id,w),danger:!0}],trigger:o.jsx("button",{onClick:w=>w.preventDefault(),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:o.jsx(op,{})})})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[x?o.jsx(Aj,{}):_&&!m?o.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,o.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:Uu(p.updatedAt)}),o.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[p.messageCount," messages"]})]})]})},p.id)})]},c):null})}const $v=["⠋","⠙","⠹","⠸","⠼","⠴"];function RN(){var c;const e=Lt(h=>h.currentProject),t=we(h=>h.currentSession),n=Pu(),s=!1,a=R.useRef(0),l=R.useRef(null);R.useEffect(()=>(n?(l.current=window.setInterval(()=>{a.current=(a.current+1)%$v.length,u()},150),u()):(l.current&&(clearInterval(l.current),l.current=null),u()),()=>{l.current&&(clearInterval(l.current),l.current=null)}),[n,e,t,s]);const u=()=>{var m;const f=(m=t==null?void 0:t.metadata)==null?void 0:m.title,p=n?`${$v[a.current]} `:"";e&&f?document.title=`${p}${e.name} - ${f} | OpenFox`:e?document.title=`${p}${e.name} | OpenFox`:document.title=`${p}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 HS(e,t=28){if(e.length<=t)return e;const n=e.split("/").filter(Boolean);if(n.length<=2)return e;const s=n[0],a=n[n.length-1],l=n.slice(1,-1).join("/"),u=t-s.length-a.length-3;if(u<0)return e;const c=l.slice(0,Math.floor(u/2)),h=l.slice(-Math.ceil(u/2));return`/${s}/${c}...${h}/${a}`}function $S({isOpen:e,onClose:t,projectName:n,onConfirm:s}){const a=()=>{s(),t()};return o.jsx(Dt,{isOpen:e,onClose:t,title:"Delete Project",size:"sm",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("p",{className:"text-text-secondary",children:["This will permanently delete the project"," ",o.jsx("span",{className:"font-semibold text-text-primary",children:n})," and all its sessions from OpenFox. The project files on disk will remain untouched."]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(tt,{variant:"secondary",onClick:t,children:"Cancel"}),o.jsx(tt,{variant:"danger",onClick:a,children:"Delete"})]})]})})}function ON({isOpen:e,onClose:t}){const[,n]=cr(),[s,a]=R.useState(!1),l=MS(),[u,c]=R.useState(!1),h=Lt(D=>D.projects),f=Lt(D=>D.createProject),p=Lt(D=>D.listProjects),m=Lt(D=>D.deleteProject),[_,x]=R.useState(null),[w,k]=R.useState(null),[y,S]=R.useState(null);R.useEffect(()=>{e&&p()},[e,p]);const v=D=>{n(`/p/${D}`),t()},b=(D,B)=>{B.stopPropagation(),x(D)},E=()=>{_&&(m(_.id),x(null))},T=async D=>{const B=D.split("/").filter(Boolean).pop()??"",q=await f(B,D);return p(),k(D),N(q)?(S(q.error.path||D),!1):!0};function N(D){return D!=null&&typeof D=="object"&&"error"in D&&D.error!=null&&typeof D.error=="object"&&"code"in D.error&&D.error.code==="EACCES"}const L=R.useCallback(()=>{S(null)},[]),A=R.useCallback(async()=>{if(S(null),w){const D=w.split("/").filter(Boolean).pop()??"",B=await f(D,w);p(),k(w),N(B)&&S(B.error.path||w)}},[w,f,p,S]);return R.useEffect(()=>{if(w){const D=h.find(B=>B.workdir===w);D&&(n(`/p/${D.id}`),t(),k(null))}},[h,w,n,t]),e?o.jsxs(Dt,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:o.jsx("div",{className:"flex justify-end gap-2",children:o.jsx(tt,{variant:"secondary",onClick:t,children:"Close"})}),children:[o.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[o.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:[o.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:o.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:h.length===0?o.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[o.jsx("p",{className:"mb-2",children:"No recent projects"}),o.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):o.jsx("div",{className:"divide-y divide-border",children:h.map(D=>o.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[o.jsxs("button",{onClick:()=>v(D.id),className:"flex-1 flex items-center gap-3 text-left",children:[o.jsx(Bu,{className:"w-5 h-5 text-accent-primary"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"font-medium truncate",children:D.name}),o.jsx("div",{className:"text-xs text-text-muted truncate",children:HS(D.workdir,32)})]})]}),o.jsx("button",{onClick:B=>b(D,B),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:o.jsx(pl,{className:"w-4 h-4"})})]},D.id))})})]}),o.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:o.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[o.jsx(tt,{variant:"primary",onClick:()=>c(!0),children:"Select existing project"}),o.jsx(tt,{variant:"secondary",onClick:()=>a(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),s&&o.jsx(OS,{isOpen:s,onClose:()=>a(!1)}),_&&o.jsx($S,{isOpen:!0,onClose:()=>x(null),projectName:_.name,onConfirm:E}),u&&o.jsx(xp,{initialPath:l??void 0,onSelect:D=>{T(D).then(B=>{B&&c(!1)})},onClose:()=>c(!1)}),y&&o.jsx(RS,{isOpen:!0,onClose:L,path:y,onRetry:A})]}):null}function MN(){const[e,t]=R.useState(!1),[n,s]=R.useState(null),a=we(w=>w.sessions),l=Lt(w=>w.projects),u=Lt(w=>w.loading),c=Lt(w=>w.listProjects),h=we(w=>w.listSessions),f=Lt(w=>w.deleteProject),p=we(w=>w.connectionStatus);R.useEffect(()=>{p==="connected"&&(c(),h())},[p,c,h]);const m=[...l].sort((w,k)=>{const y=a.filter(E=>E.workdir.startsWith(w.workdir)),S=a.filter(E=>E.workdir.startsWith(k.workdir)),v=y.length>0?new Date(y.reduce((E,T)=>new Date(T.updatedAt)>new Date(E.updatedAt)?T:E).updatedAt).getTime():new Date(w.updatedAt).getTime();return(S.length>0?new Date(S.reduce((E,T)=>new Date(T.updatedAt)>new Date(E.updatedAt)?T:E).updatedAt).getTime():new Date(k.updatedAt).getTime())-v}),_=w=>{const k=l.find(y=>y.id===w);return k?a.filter(y=>y.workdir.startsWith(k.workdir)).sort((y,S)=>new Date(S.updatedAt).getTime()-new Date(y.updatedAt).getTime()).slice(0,5):[]},x=()=>{t(!0)};return o.jsxs("div",{className:"flex-1 flex flex-col overflow-y-auto bg-primary",children:[o.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[o.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),o.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),o.jsx(tt,{variant:"primary",onClick:x,children:"Open Project"})]}),m.map(w=>{const k=_(w.id);return o.jsx("div",{className:"mb-6 md:mb-8",children:o.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[o.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[o.jsxs(Gn,{href:`/p/${w.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[o.jsx(Bu,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),o.jsx("span",{className:"text-text-primary font-semibold",children:w.name})]}),o.jsx(Gn,{href:`/p/${w.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"}),o.jsx("button",{type:"button",onClick:()=>s({id:w.id,name:w.name}),className:"p-1.5 rounded text-text-muted hover:text-accent-error hover:bg-accent-error/10 transition-colors",title:"Delete project",children:o.jsx(pl,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"divide-y divide-border",children:k.length>0?k.map(y=>{const S=l.find(b=>y.workdir.startsWith(b.workdir)),v=S?`/p/${S.id}/s/${y.id}`:"#";return o.jsx(Gn,{href:v,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"text-sm text-text-muted truncate",children:y.title??y.id.slice(0,8)})})}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx("span",{className:"text-text-muted text-xs",children:SN(y.updatedAt)}),o.jsxs("span",{className:"text-text-muted text-xs",children:[y.messageCount," msgs"]})]})]})},y.id)}):o.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},w.id)}),m.length===0&&!u&&o.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),u&&o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(_l,{})})]}),e&&o.jsx(ON,{isOpen:e,onClose:()=>t(!1)}),n&&o.jsx($S,{isOpen:!0,onClose:()=>s(null),projectName:n.name,onConfirm:()=>f(n.id)})]})}function IN(){const[,e]=sp("/p/:projectId/new"),[,t]=cr(),n=e==null?void 0:e.projectId,s=we(u=>u.createSession),a=we(u=>u.resetPendingSessionCreate),l=R.useCallback(async()=>{if(!n)return;const u=await s(n);u?(t(`/p/${n}/s/${u.id}`),a()):(t(`/p/${n}`),a())},[n,s,t,a]);return R.useEffect(()=>{l()},[l]),o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(_l,{})})}function PN(){const e=Lt(t=>t.currentProject);return o.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:o.jsxs("div",{className:"max-w-md",children:[o.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),o.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),o.jsxs("div",{className:"flex flex-col gap-3",children:[e&&o.jsx(Gn,{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"}),o.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const Uo=e=>Math.round(e*10)/10;function BN(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function Cm(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function zN(e){return`${e.providerId}::${e.model}`}function HN(e){return`${e.providerName} > ${e.model}`}function Uv(e){let t=0,n=0,s=0,a=0,l=0,u=0;const c=[],h=[];let f=0;for(const[_,x]of e.entries()){const w=x.stats,k=Cm(w);t+=w.totalTime,n+=w.toolTime,s+=w.prefillTokens,a+=w.generationTokens;const y=w.prefillSpeed>0?w.prefillTokens/w.prefillSpeed:0,S=w.generationSpeed>0?w.generationTokens/w.generationSpeed:0;l+=y,u+=S,c.push({messageId:x.id,timestamp:x.timestamp,...k,mode:w.mode,responseIndex:_+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 v=w.llmCalls??[];for(const b of v)f+=1,h.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:_+1,sessionCallIndex:f,callIndex:b.callIndex,promptTokens:b.promptTokens,completionTokens:b.completionTokens,ttft:b.ttft,completionTime:b.completionTime,prefillSpeed:b.prefillSpeed,generationSpeed:b.generationSpeed,totalTime:b.totalTime,...b.temperature!==void 0&&{temperature:b.temperature},...b.topP!==void 0&&{topP:b.topP},...b.topK!==void 0&&{topK:b.topK},...b.maxTokens!==void 0&&{maxTokens:b.maxTokens}})}const p=l>0?Uo(s/l):0,m=u>0?Uo(a/u):0;return{totalTime:Uo(t),aiTime:Uo(t-n),toolTime:Uo(n),prefillTokens:s,generationTokens:a,avgPrefillSpeed:p,avgGenerationSpeed:m,responseCount:e.length,llmCallCount:h.length,dataPoints:c,callDataPoints:h}}function $N(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null&&BN(a.stats)).sort((a,l)=>new Date(a.timestamp).getTime()-new Date(l.timestamp).getTime());if(t.length===0)return null;const n=new Map;for(const a of t){const l=zN(Cm(a.stats)),u=n.get(l)??[];n.set(l,[...u,a])}const s=Array.from(n.entries()).map(([a,l])=>{const u=Cm(l[0].stats),c=Uv(l);return{...u,key:a,label:HN(u),...c}});return{...Uv(t),modelGroups:s}}function UN(e){return R.useMemo(()=>$N(e),[e])}function US(){var a;const e=we(l=>l.gitStatus),t=we(l=>l.currentSession),[n,s]=R.useState(!0);return R.useEffect(()=>{t!=null&&t.workdir&&s(!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 hu(e){return e.toLocaleString("en-US").replace(/,/g," ")}function Fv(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function FN(e){if(!Number.isFinite(e))return"0s";if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=Math.round(e%60);return`${t}m${n}s`}const Vv=["▁","▂","▃","▄","▅","▆","▇","█"];function VN(e,t,n){if(n===t)return 4;const s=(e-t)/(n-t);return Math.min(7,Math.max(0,Math.round(s*7)))}function GN(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,s=Math.max(n*.1,.1);return{minY:e-s,maxY:t+s}}function WN(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((m,_)=>m.x-_.x),s=n[0].x,a=n[n.length-1].x,l=Math.min(...n.map(m=>m.y)),u=Math.max(...n.map(m=>m.y)),{minY:c,maxY:h}=GN(l,u),f=Array.from({length:t},()=>" "),p=new Map;for(const m of n){const _=a===s?0:Math.round((m.x-s)/(a-s)*(t-1)),x=p.get(_)??[];p.set(_,[...x,m.y])}for(const[m,_]of p){const x=Math.max(..._);f[m]=Vv[VN(x,c,h)]??Vv[0]}return{blocks:f.join(""),minX:s,maxX:a,minY:c,maxY:h}}function Gv(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function Wv({data:e,width:t=60,height:n=78,label:s,xLabel:a,yLabel:l,showAxes:u=!0,formatY:c=Gv,formatX:h=Gv}){const f=R.useMemo(()=>{const p=WN(e,t),m=Math.max(t*6,240),_=10,x=8,k=[...e].sort((b,E)=>b.x-E.x).map(b=>{const E=p.maxX===p.minX?m/2:_+(b.x-p.minX)/(p.maxX-p.minX)*(m-_*2),T=p.maxY===p.minY?n/2:x+(p.maxY-b.y)/(p.maxY-p.minY)*(n-x*2);return{...b,cx:E,cy:T,leftPercent:E/m*100,topPercent:T/n*100}}),y=k.map((b,E)=>`${E===0?"M":"L"} ${b.cx.toFixed(1)} ${b.cy.toFixed(1)}`).join(" "),v=[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:k,path:y,gridLines:v}},[e,n,t]);return e.length===0?o.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[s&&o.jsx("div",{className:"mb-1",children:s}),o.jsx("div",{children:"No data"})]}):o.jsxs("div",{className:"font-mono text-xs",children:[s&&o.jsx("div",{className:"text-text-secondary mb-2",children:s}),o.jsxs("div",{className:"flex gap-3",children:[u&&o.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:f.gridLines.map(p=>o.jsx("span",{children:c(p.value)},`${p.value}-${p.y}`))}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsxs("div",{className:"relative h-[78px]",children:[o.jsxs("svg",{viewBox:`0 0 ${f.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[f.gridLines.map(p=>o.jsx("line",{x1:"0",x2:f.chartWidth,y1:p.y,y2:p.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${p.y}`)),f.points.map(p=>o.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}`)),f.points.length>1&&o.jsx("path",{d:f.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),f.points.map(p=>o.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${p.leftPercent}%`,top:`${p.topPercent}%`},title:`${h(p.x)} -> ${c(p.y)}`,children:o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${p.x}-${p.y}`))]})})]}),u&&o.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[o.jsx("span",{className:"w-12"}),o.jsxs("span",{className:"flex-1 flex justify-between",children:[o.jsx("span",{children:h(f.minX)}),o.jsx("span",{children:a}),o.jsx("span",{children:h(f.maxX)})]})]}),l&&u&&o.jsx("div",{className:"text-text-muted mt-1 text-center",children:l})]})}function qN({data:e,prefillLabel:t="Prefill Speed (tok/s) by Response",generationLabel:n="Generation Speed (tok/s) by Response",xLabel:s="response",width:a=60}){const l=e.map(c=>({x:c.x,y:c.ppSpeed})),u=e.map(c=>({x:c.x,y:c.tgSpeed}));return o.jsxs("div",{className:"space-y-5",children:[o.jsx(Wv,{data:l,width:a,label:t,xLabel:s}),o.jsx(Wv,{data:u,width:a,label:n,xLabel:s})]})}function KN(e){const t=new Map;for(const n of e.callDataPoints){const s=t.get(n.messageId)??[];t.set(n.messageId,[...s,n])}return e.dataPoints.map(n=>{const s=[...t.get(n.messageId)??[]].sort((a,l)=>a.callIndex-l.callIndex);return{...n,callCount:s.length,calls:s,isExpandable:s.length>1}})}function YN(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 XN(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 QN(e){return e.callDataPoints.length>0?XN(e):YN(e)}function Mf(e){if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=e%60;return`${t}m ${n.toFixed(0)}s`}function Ni(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function Qo(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function JN(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${Ni(t)} ctx`:`${Ni(t)}-${Ni(n)} ctx`}function fu(e){return`${Qo(e)} t/s`}function FS(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function ZN(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 eT({isOpen:e,onClose:t,stats:n}){const s=R.useRef(null),[a,l]=R.useState({}),[u,c]=R.useState(()=>{var w;return((w=n.modelGroups[0])==null?void 0:w.key)??""});R.useEffect(()=>{var w;n.modelGroups.some(k=>k.key===u)||c(((w=n.modelGroups[0])==null?void 0:w.key)??"")},[u,n.modelGroups]);const h=R.useMemo(()=>n.modelGroups.find(w=>w.key===u)??n.modelGroups[0],[u,n.modelGroups]),f=R.useMemo(()=>h?KN(h):[],[h]),p=R.useMemo(()=>h?QN(h):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[h]),m=R.useCallback(w=>{l(k=>({...k,[w]:!k[w]}))},[]),_=R.useCallback(()=>{if(!h)return;const w=ZN(h);navigator.clipboard.writeText(JSON.stringify(w,null,2)).catch(k=>console.error("Failed to copy:",k))},[h]),x=R.useCallback(async()=>{if(s.current)try{const w=(await Z(async()=>{const{default:S}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:S}},[])).default,k=await w(s.current,{backgroundColor:"#1a1a1a",scale:2}),y=document.createElement("a");y.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,y.href=k.toDataURL("image/png"),y.click()}catch(w){console.error("Failed to export PNG:",w),_()}},[_]);return o.jsx(Dt,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:o.jsxs("div",{ref:s,className:"space-y-6",children:[o.jsx("section",{children:o.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(w=>o.jsx("button",{onClick:()=>c(w.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${w.key===(h==null?void 0:h.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))})}),h&&o.jsxs("section",{children:[o.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[o.jsx(ts,{label:"AI Time",value:Mf(h.aiTime)}),o.jsx(ts,{label:"Total Time",value:Mf(h.totalTime)}),o.jsx(ts,{label:"Tool Time",value:Mf(h.toolTime)}),o.jsx(ts,{label:"Responses",value:h.responseCount.toString()}),o.jsx(ts,{label:"LLM Calls",value:h.llmCallCount.toString()})]}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[o.jsx(ts,{label:"Prefill Tokens",value:Ni(h.prefillTokens),subValue:`@ ${Qo(h.avgPrefillSpeed)} tok/s`}),o.jsx(ts,{label:"Gen Tokens",value:Ni(h.generationTokens),subValue:`@ ${Qo(h.avgGenerationSpeed)} tok/s`}),o.jsx(ts,{label:"Avg PP Speed",value:`${Qo(h.avgPrefillSpeed)}`,subValue:"tok/s"}),o.jsx(ts,{label:"Avg TG Speed",value:`${Qo(h.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),h&&p.points.length>1&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:_,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),o.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"})]})]}),o.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:o.jsx(qN,{data:p.points,width:50,prefillLabel:p.prefillLabel,generationLabel:p.generationLabel,xLabel:p.xLabel})})]}),h&&o.jsxs("section",{children:[o.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",h.responseCount," responses)"]}),o.jsx("div",{className:"overflow-y-auto bg-bg-tertiary/30 rounded",children:o.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[o.jsxs("colgroup",{children:[o.jsx("col",{className:"w-[7%]"}),o.jsx("col",{className:"w-[14%]"}),o.jsx("col",{className:"w-[10%]"}),o.jsx("col",{className:"w-[14%]"}),o.jsx("col",{className:"w-[14%]"}),o.jsx("col",{className:"w-[14%]"}),o.jsx("col",{className:"w-[11%]"}),o.jsx("col",{className:"w-[2%]"})]}),o.jsx("thead",{children:o.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[o.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),o.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),o.jsx("th",{className:"px-2 py-2"})]})}),o.jsx("tbody",{children:f.map((w,k)=>o.jsxs(R.Fragment,{children:[o.jsx(tT,{row:w,index:k,isExpanded:a[w.messageId]??!1,onToggle:w.isExpandable?()=>m(w.messageId):void 0}),(a[w.messageId]??!1)&&w.calls.map((y,S)=>o.jsx(nT,{dataPoint:y,index:S},`${y.messageId}-${y.callIndex}`))]},w.messageId))})]})})]})]})})}function ts({label:e,value:t,subValue:n}){return o.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[o.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),o.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&o.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function tT({row:e,index:t,isExpanded:n,onToggle:s}){const a=e.calls.length>0?JN(e.calls.map(l=>l.promptTokens)):`${Ni(e.prefillTokens)} ctx`;return o.jsxs("tr",{onClick:s,className:`${t%2===0?"bg-bg-tertiary/20":""} ${s?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[o.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:FS(e.timestamp)}),o.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:a.replace(/ ctx$/,"")}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:fu(e.prefillSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:fu(e.generationSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function nT({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return o.jsxs(o.Fragment,{children:[o.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[o.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]}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:FS(e.timestamp)}),o.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Ni(e.promptTokens)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:fu(e.prefillSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:fu(e.generationSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),o.jsx("td",{className:"px-2 py-2"})]}),n&&o.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:o.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&o.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&o.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&o.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&o.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const rT={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"}},sT=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function iT(e){return rT[e]??{icon:"○",color:"text-text-muted"}}function VS(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const Fu=R.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:s,color:a}=iT(t);return o.jsx("span",{className:`${a} ${n}`,children:s})});function qv({entries:e,title:t}){const n=R.useMemo(()=>e.reduce((s,a)=>(s[a.status]=(s[a.status]??0)+1,s),{}),[e]);return o.jsxs("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center justify-between",children:[o.jsx("span",{children:t}),Object.keys(n).length>0&&o.jsx("span",{className:"font-normal text-xs flex items-center gap-1.5",children:sT.map(s=>{const a=n[s];return a?o.jsxs("span",{className:"flex items-center gap-0.5",children:[o.jsx(Fu,{status:s}),o.jsx("span",{children:a})]},s):null})})]})}const aT=R.memo(function({entries:t,title:n}){return t.length===0?null:o.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[n&&o.jsx("div",{className:"px-1.5 py-1 border-b border-border bg-secondary",children:o.jsx("span",{className:"text-xs font-medium text-text-muted",children:n})}),o.jsx("div",{className:"bg-primary",children:t.map((s,a)=>o.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${a>0?"border-t border-border":""}`,children:[o.jsx(Fu,{status:s.status}),o.jsxs("div",{className:"flex-1 min-w-0 text-xs truncate",children:[o.jsxs("span",{className:"text-text-muted",children:["[",s.id,"]"]})," ",VS(s.description)]})]},s.id??a))})]})}),oT="#6b7280";function il(e,t){var n;return((n=e.find(s=>s.id===t))==null?void 0:n.color)??oT}const mt=qn(e=>{const t=async()=>{await hp("/api/agents",e,!0)};return{defaults:[],userItems:[],projectItems:[],loading:!1,fetchAgents:t,fetchAgent:async n=>{try{const s=await Ne(`/api/agents/${n}`);return s.ok?await s.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const s=await Ne(`/api/agents/defaults/${n}`);return s.ok?await s.json():null}catch{return null}},createAgent:async(n,s)=>{const a=await Ws("POST","/api/agents",{...n,destination:s});return a.success&&await t(),a},updateAgent:async(n,s)=>{const a=await Ws("PUT",`/api/agents/${n}`,s);return a.success&&await t(),a},deleteAgent:async n=>{try{const s=await Ne(`/api/agents/${n}`,{method:"DELETE"}),a=await s.json();return s.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateAgent:async(n,s)=>Iu(`/api/agents/${n}/duplicate`,t,s)}}),Et=qn((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],fetchTemplateVariables:async()=>{try{const s=await(await Ne("/api/workflows/template-variables")).json();e({templateVariables:s.variables??[]})}catch{}},fetchWorkflows:async()=>{e({loading:!0});try{const s=await(await Ne("/api/workflows")).json();e({defaults:s.defaults??[],userItems:s.userItems??[],projectItems:s.projectItems??[],activeWorkflowId:s.activeWorkflowId??"default",loading:!1})}catch{e({loading:!1})}},fetchWorkflow:async n=>{try{const s=await Ne(`/api/workflows/${n}`);return s.ok?await s.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const s=await Ne(`/api/workflows/defaults/${n}`);return s.ok?await s.json():null}catch{return null}},createWorkflow:async(n,s)=>{const a=await Ws("POST","/api/workflows",{...n,destination:s});return a.success&&await t().fetchWorkflows(),a},updateWorkflow:async(n,s)=>{const a=await Ws("PUT",`/api/workflows/${n}`,s);return a.success&&await t().fetchWorkflows(),a},deleteWorkflow:async n=>{try{const s=await Ne(`/api/workflows/${n}`,{method:"DELETE"}),a=await s.json();return s.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateWorkflow:async(n,s)=>Iu(`/api/workflows/${n}/duplicate`,()=>t().fetchWorkflows(),s)})),lT={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function cT(e,t){await Ne(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function Fc({id:e,agents:t}){const n=il(t,e),s=t.find(a=>a.id===e);return o.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${n}20`,color:n},children:(s==null?void 0:s.name)??e})}function uT({id:e}){const t=Et(u=>u.defaults),n=Et(u=>u.userItems),a=R.useMemo(()=>[...t,...n],[t,n]).find(u=>u.id===e),l=(a==null?void 0:a.color)??"#3b82f6";return o.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${l}20`,color:l},children:(a==null?void 0:a.name)??e})}function dT({entries:e,sessionId:t}){const[n,s]=R.useState(e),[a,l]=R.useState(!1),[u,c]=R.useState(null),[h,f]=R.useState(""),[p,m]=R.useState(""),[_,x]=R.useState(!1),[w,k]=R.useState(!1),y=mt(z=>z.defaults),S=mt(z=>z.userItems),v=mt(z=>z.projectItems),b=R.useMemo(()=>[...y,...S,...v],[y,S,v]),E=R.useRef(null),T=R.useRef(null);R.useEffect(()=>{s(e)},[e]),R.useEffect(()=>{var z;a&&((z=E.current)==null||z.focus())},[a]),R.useEffect(()=>{var z;u&&((z=T.current)==null||z.focus())},[u]);const N=R.useCallback(z=>{s(z),cT(t,z)},[t]),L=R.useCallback(()=>{var F;const z=h.trim();if(!z)return;const X=String(n.length),ne=[...n,{id:X,description:z,status:"pending"}];N(ne),f(""),(F=E.current)==null||F.focus()},[n,h,N]),A=R.useCallback(()=>{l(!1),f("")},[]),D=R.useCallback((z,X)=>{c(z),m(X)},[]),B=R.useCallback(()=>{if(!u)return;const z=p.trim(),X=n.map(ne=>ne.id===u?{...ne,description:z||ne.description}:ne);N(X),c(null)},[u,p,n,N]),q=R.useCallback(z=>{const X=n.map(ne=>ne.id===z?{...ne,status:lT[ne.status]??"pending"}:ne);N(X)},[n,N]),W=R.useCallback(z=>{N(n.filter(X=>X.id!==z))},[n,N]),O=R.useCallback(()=>{N([]),x(!1)},[N]),V=R.useCallback(z=>{z.key==="Enter"&&(z.preventDefault(),L()),z.key==="Escape"&&A()},[L,A]),G=R.useCallback(z=>{z.key==="Enter"&&B(),z.key==="Escape"&&c(null)},[B]);return o.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[o.jsxs("div",{className:"bg-primary",children:[n.length===0&&!a&&o.jsxs("div",{className:"px-1.5 py-2 text-xs text-text-muted italic text-center",children:["No criteria yet."," ",o.jsx("button",{onClick:()=>k(!0),className:"text-accent-primary hover:underline not-italic cursor-pointer",children:"Learn more"})]}),n.map((z,X)=>{const ne=z.status,F=u===z.id;return o.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${X>0?"border-t border-border":""}`,children:[o.jsx("button",{onClick:()=>q(z.id),className:"text-xs leading-tight flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",title:`Status: ${z.status} (click to cycle)`,children:o.jsx(Fu,{status:ne})}),o.jsx("div",{className:"flex-1 min-w-0",children:F?o.jsx("input",{ref:T,value:p,onChange:M=>m(M.target.value),onBlur:B,onKeyDown:G,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"}):o.jsxs("button",{onClick:()=>D(z.id,z.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:["[",z.id,"] ",VS(z.description)]})}),o.jsx("button",{onClick:()=>W(z.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:o.jsx(gl,{className:"w-4 h-4"})})]},z.id)})]}),a&&o.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"text-text-muted text-xs leading-tight flex-shrink-0",children:"○"}),o.jsx("input",{ref:E,value:h,onChange:z=>f(z.target.value),onKeyDown:V,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"})]})}),o.jsxs("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:[a?o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:L,className:"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add criterion",children:[o.jsx(qs,{className:"w-3 h-3"}),"Add"]}),o.jsx("button",{onClick:A,className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Cancel",children:"Cancel"})]}):o.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"Add criterion",children:[o.jsx(qs,{className:"w-3 h-3"}),"Add"]}),n.length>0&&o.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:[o.jsx(pl,{className:"w-3 h-3"}),"Clear all"]}),o.jsx("button",{onClick:()=>k(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"About criteria",children:o.jsx(pS,{className:"w-3 h-3"})})]}),_&&o.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:o.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[o.jsx("span",{className:"text-xs text-accent-error",children:"Clear all criteria?"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:O,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),o.jsx("button",{onClick:()=>x(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})}),o.jsx(Dt,{isOpen:w,onClose:()=>k(!1),title:"About Acceptance Criteria",size:"md",children:o.jsxs("div",{className:"space-y-3 text-sm text-text-secondary",children:[o.jsx("p",{children:"Each criterion defines a specific requirement that needs to be met."}),o.jsxs("p",{children:["To use this feature, start in ",o.jsx(Fc,{id:"planner",agents:b})," mode and",o.jsxs("strong",{className:"text-text-primary",children:[" ","ask the agent to define acceptance criteria that matches your goal"]}),". Then launch the ",o.jsx(uT,{id:"default"})," builtin workflow to launch the automation part."]}),o.jsx("p",{children:"This workflow will automatically:"}),o.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[o.jsxs("li",{children:["Launch the ",o.jsx(Fc,{id:"builder",agents:b}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),o.jsxs("li",{children:["Then launch the ",o.jsx(Fc,{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."]}),o.jsxs("li",{children:["Launch a ",o.jsx(Fc,{id:"code_reviewer",agents:b})," subagent, that will analyze the code to provide actionable feedback to the main agent."]})]}),o.jsx("div",{className:"bg-bg-tertiary rounded p-3 space-y-1.5",children:o.jsx("p",{children:"This lets smaller models follow complex plans to completion and improves the chances that nothing from your plan is missed."})})]})})]})}function hT({isOpen:e,onClose:t}){const n=Rr(k=>k.config),s=Rr(k=>k.saveConfig),[a,l]=R.useState(""),[u,c]=R.useState(""),[h,f]=R.useState(!1),[p,m]=R.useState(!1),[_,x]=R.useState(!1);R.useEffect(()=>{e&&(l((n==null?void 0:n.command)??""),c((n==null?void 0:n.url)??""),f((n==null?void 0:n.hotReload)??!1),m((n==null?void 0:n.disableInspect)??!1))},[e,n]);const w=async()=>{!a.trim()||!u.trim()||(x(!0),await s({command:a.trim(),url:u.trim(),hotReload:h,disableInspect:p}),x(!1),t())};return o.jsx(Dt,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),o.jsx("input",{className:"input w-full",type:"text",value:a,onChange:k=>l(k.target.value),placeholder:"npm run dev"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),o.jsx("input",{className:"input w-full",type:"text",value:u,onChange:k=>c(k.target.value),placeholder:"http://localhost:3000"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"hotReload",checked:h,onChange:k=>f(k.target.checked),className:"rounded border-border bg-bg-tertiary"}),o.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"disableInspect",checked:p,onChange:k=>m(k.target.checked),className:"rounded border-border bg-bg-tertiary"}),o.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),o.jsx("button",{className:"btn btn-primary",onClick:w,disabled:_||!a.trim()||!u.trim(),children:_?"Saving...":"Save"})]})]})})}const Kv={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"},fT={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"},Yv={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},mT="text-text-primary";function pT(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let s=0,a="text-text-primary",l;try{for(;(l=n.exec(e))!==null;){if(l.index>s){const f=e.slice(s,l.index);f&&t.push({text:f,className:a})}const u=l[1];if(!u)continue;const c=u.split(";").map(Number);if(c.length===0||c[0]===0){a="text-text-primary";continue}const h=[];for(const f of c)if(f>=30&&f<=37){const p=Kv[f];p&&h.push(p)}else if(f>=40&&f<=47){const p=fT[f];p&&h.push(p)}else if(f>=90&&f<=97){const p=Kv[f];p&&h.push(p)}else if(f in Yv){const p=Yv[f];p&&h.push(p)}else f===39?h.push(mT):f===49&&(a=a.split(" ").filter(p=>!p.startsWith("bg-")).join(" "));h.length>0&&(a=h.join(" ")),s=n.lastIndex}if(s<e.length){const u=e.slice(s);u&&t.push({text:u,className:a})}return t}catch(u){return console.warn("ANSI parsing failed, stripping codes:",u),[{text:gT(e),className:"text-text-primary"}]}}function gT(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function mu(e){const t=pT(e),n=[];return t.forEach((s,a)=>{const l=s.text.split(`
|
|
88
|
+
`);l.forEach((u,c)=>{n.push($s.createElement("span",{key:`${a}-${c}`,className:s.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},u)),c<l.length-1&&n.push($s.createElement("br",{key:`${a}-${c}-br`}))})}),n.length===1?n[0]:n}function GS({logs:e,preRef:t,preClassName:n="text-sm font-mono"}){return o.jsx("pre",{ref:t,className:n,children:e.length===0?o.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((s,a)=>o.jsx("span",{className:s.stream==="stderr"?"text-accent-warning":"",children:mu(s.content)},a))})}const WS=R.memo(function({title:t,logs:n,onClose:s,preClassName:a}){const l=R.useRef(null);return R.useEffect(()=>{l.current&&(l.current.scrollTop=l.current.scrollHeight)},[n]),o.jsx(Dt,{isOpen:!0,onClose:s,title:t,size:"full",children:o.jsx(GS,{logs:n,preRef:l,preClassName:a})})}),xT=R.memo(function({logs:t,anchorRef:n,isHiding:s,onExpand:a,onClose:l}){const[u,c]=R.useState(null),h=R.useRef(null);return R.useEffect(()=>{var p;const f=(p=n.current)==null?void 0:p.getBoundingClientRect();f&&c({bottom:window.innerHeight-f.bottom,right:window.innerWidth-f.right,width:f.width,height:f.height})},[n]),R.useEffect(()=>{h.current&&(h.current.scrollTop=h.current.scrollHeight)},[t]),u?o.jsxs("div",{className:"relative",children:[o.jsx("pre",{ref:h,className:"fixed z-50 text-sm font-mono text-text-primary bg-bg-primary p-2 rounded border border-border overflow-auto transition-all duration-150 ease-out select-text",style:{bottom:u.bottom,right:u.right,width:u.width*2,maxHeight:u.height*3,transformOrigin:"bottom right",transform:s?"scale(0.01)":"scale(1)",opacity:s?0:1},children:t.map((f,p)=>o.jsx("span",{className:f.stream==="stderr"?"text-accent-warning":"",children:mu(f.content)},p))}),o.jsx("button",{onClick:()=>{l(),a()},className:"fixed z-50 px-2 py-1 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors duration-150",style:{bottom:u.bottom+8,right:u.right+8},children:"Expand"})]}):null}),_T=R.memo(function({workdir:t}){const n=Rr(W=>W.setWorkdir),s=Rr(W=>W.status),a=Rr(W=>W.config),l=Rr(W=>W.logs),u=Rr(W=>W.start),c=Rr(W=>W.stop),h=Rr(W=>W.fetchLogs),f=we(W=>W.currentSession),[p,m]=R.useState(!1),[_,x]=R.useState(!1),[w,k]=R.useState(!1),[y,S]=R.useState(!1),v=R.useRef(null),b=R.useRef(null),E=R.useRef(null),T=R.useRef(null),N=R.useRef(null),L=()=>{const W=s==null?void 0:s.inspectProxyPort;if(!W){s!=null&&s.url&&window.open(s.url,"_blank");return}const O=`${window.location.protocol}//${window.location.hostname}:${W}`,V=window.open(O,"_blank");if(V){N.current=V;const G=()=>{var X;!N.current||N.current.closed||(N.current.postMessage({type:"setFoxSessionId",sessionId:(f==null?void 0:f.id)??null},"*"),N.current.postMessage({type:"setFoxSessionTitle",sessionTitle:((X=f==null?void 0:f.metadata)==null?void 0:X.title)??null},"*"),N.current.postMessage({type:"setFoxInspectEnabled",enabled:!(a!=null&&a.disableInspect)},"*"))},z=setInterval(()=>{G(),(!N.current||N.current.closed)&&clearInterval(z)},500);setTimeout(()=>clearInterval(z),5e3)}},A=(s==null?void 0:s.state)??"off",D=a!==null,B=A==="running"||A==="warning";R.useEffect(()=>{n(t??null)},[t,n]),R.useEffect(()=>{B&&h()},[B,h]),R.useEffect(()=>{E.current&&B&&(E.current.scrollTop=E.current.scrollHeight)},[l,B]);const q=()=>{B?c():u()};return o.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${A==="running"?"bg-accent-success":A==="warning"?"bg-accent-warning":A==="error"?"bg-accent-error":"bg-text-muted"}`}),o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),o.jsx("button",{onClick:()=>m(!0),className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:o.jsx(Cj,{})})]}),D?o.jsxs(o.Fragment,{children:[A==="running"||A==="warning"?o.jsxs("div",{className:"flex gap-2",children:[o.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-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[o.jsx(xS,{}),"Stop"]}),(s==null?void 0:s.url)&&o.jsxs("button",{onClick:()=>L(),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:s.url,children:[o.jsx(Ej,{}),"Open"]})]}):o.jsx("button",{onClick:q,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"}),B&&o.jsxs("div",{ref:T,className:"relative",onMouseEnter:()=>{b.current&&clearTimeout(b.current),v.current=setTimeout(()=>{k(!0),S(!1)},500)},onMouseLeave:()=>{v.current&&clearTimeout(v.current),S(!0),b.current=setTimeout(()=>k(!1),150)},children:[o.jsx(GS,{logs:l,preRef:E,preClassName:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border"}),(w||y)&&T.current&&$a.createPortal(o.jsx(xT,{logs:l,anchorRef:T,isHiding:y,onExpand:()=>x(!0),onClose:()=>k(!1)}),document.body)]})]}):o.jsx("button",{onClick:()=>m(!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"}),o.jsx(hT,{isOpen:p,onClose:()=>m(!1)}),_&&o.jsx(WS,{title:"Dev Server Logs",logs:l,onClose:()=>x(!1)})]})}),yT=R.memo(function({sessionId:t}){var x;const n=Zo(w=>w.processes),s=Zo(w=>w.stopProcess),[a,l]=R.useState(null),[u,c]=R.useState([]),h=n.filter(w=>w.status!=="exited"),f=h.filter(w=>w.status==="running").length;if(n.length===0)return null;const p=w=>{switch(w){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=w=>{const k=Zo.getState().logs[w]??[];c(k.map(y=>({content:y.content,stream:y.stream}))),l(w)},_=w=>{t&&s(w,t)};return o.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),o.jsxs("span",{className:"text-xs text-text-muted",children:["(",f," running)"]})]})}),o.jsx("div",{className:"space-y-2",children:h.map(w=>o.jsx("div",{className:"border border-border rounded p-2",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${p(w.status)}`}),o.jsx("span",{className:"text-sm text-text-primary truncate",title:w.name,children:w.name}),o.jsxs("span",{className:"text-xs text-text-muted",children:["[",w.status,"]"]})]}),o.jsxs("div",{className:"flex gap-1 ml-2",children:[o.jsx("button",{onClick:()=>m(w.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"}),o.jsx("button",{onClick:()=>_(w.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"})]})]})},w.id))}),a&&o.jsx(WS,{title:((x=h.find(w=>w.id===a))==null?void 0:x.name)??"",logs:u,onClose:()=>{l(null),c([])}})]})});function vT({isOpen:e,onClose:t,versionInfo:n}){const[s,a]=R.useState("ready"),[l,u]=R.useState("waiting"),[c,h]=R.useState(""),[f,p]=R.useState(n),[m,_]=R.useState(!1),x=R.useRef(!1);R.useEffect(()=>{if(e){if(n){p(n);return}fetch("/api/auto-update/check").then(y=>y.json()).then(y=>{p({current:y.current,latest:y.latest}),_(y.isService??!1)}).catch(()=>{})}},[e]),R.useEffect(()=>{if(!e||s!=="updating")return;const y=setInterval(()=>{h(S=>S.length>=3?"":S+".")},400);return()=>clearInterval(y)},[e,s]);const w=R.useCallback(async()=>{a("updating"),u("waiting"),x.current=!1;const y=(f==null?void 0:f.current)==="1.0.0"&&(f==null?void 0:f.latest)==="1.1.0",S=await Ne("/api/auto-update",{method:"POST"}),{isService:v}=await S.json();if(y){setTimeout(()=>{a("reloading"),localStorage.setItem("openfox_updated_to",(f==null?void 0:f.latest)??"unknown"),localStorage.setItem("update_pending","true"),setTimeout(()=>window.location.reload(),1e3)},5e3);return}if(!v){setTimeout(()=>{a("complete")},8e3);return}let b=!1;const E=setInterval(async()=>{try{(await fetch("/api/health")).ok&&x.current&&(b=!0,clearInterval(E),a("reloading"),localStorage.setItem("openfox_updated_to",(f==null?void 0:f.latest)??"unknown"),localStorage.setItem("update_pending","true"),window.location.reload())}catch{x.current=!0}},2e3);setTimeout(()=>{b||u("takingLonger")},6e4),setTimeout(()=>{b||(clearInterval(E),a("failed"))},12e4)},[f==null?void 0:f.current,f==null?void 0:f.latest]);R.useEffect(()=>{e&&(a("ready"),u("waiting"),h(""),x.current=!1)},[e]);const k=s!=="updating";return o.jsxs(Dt,{isOpen:e,onClose:k?t:void 0,title:s==="failed"?"Update Failed":s==="complete"?"Update Complete":"New OpenFox Version Available",size:"sm",closeOnBackdropClick:k,showCloseButton:k,children:[o.jsxs("div",{className:"flex flex-col gap-4",children:[f&&o.jsxs("div",{className:"flex justify-between text-sm",children:[o.jsx("span",{className:"text-text-muted",children:"Current version"}),o.jsx("span",{className:"text-text-primary font-mono",children:f.current})]}),f&&o.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[o.jsx("span",{className:"text-text-muted",children:"Latest version"}),o.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:f.latest})]}),s==="updating"&&o.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[o.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),o.jsx("p",{className:"text-xs text-text-muted text-center",children:l==="takingLonger"?"Taking longer than expected…":`Updating${c}`})]}),s==="reloading"&&o.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[o.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),o.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Update complete, reloading",c]})]}),s==="complete"&&o.jsx("div",{className:"flex flex-col gap-3 mt-2",children:o.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",f==null?void 0:f.latest,". Please relaunch OpenFox to use the new version."]})}),s==="failed"&&o.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[o.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:[o.jsx("span",{children:"⚠️"}),o.jsx("p",{className:"text-text-secondary",children:"The update timed out. The server may need to be updated manually."})]}),o.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:"openfox update"}),o.jsxs("p",{className:"text-xs text-text-muted",children:["Run this command in your terminal to complete the update, then start the service with"," ",o.jsx("span",{className:"font-mono text-text-secondary",children:"openfox service start"}),"."]})]})]}),s==="ready"&&o.jsx("button",{onClick:w,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"}),(s==="complete"||s==="failed")&&o.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"}),s==="ready"&&m&&o.jsx("div",{className:"flex justify-center mt-2",children:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-warning/10 border border-accent-warning/30 rounded text-xs",children:[o.jsx("span",{children:"⚠️"}),o.jsx("p",{className:"text-text-secondary",children:"Server will restart to apply this update. Sessions in progress will be interrupted."})]})})]})}function bT({file:e}){const t=HS(e.path,28),n=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",s=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"";return o.jsxs("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:[o.jsx("span",{className:`truncate ${n}`,title:e.path,children:t}),s&&o.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:s})]})}function ST(){const{diff:e}=US();return e.loading?o.jsx("div",{className:"mt-3",children:o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[o.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),o.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?o.jsx("div",{className:"mt-3",children:o.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):o.jsx("div",{className:"mt-3 max-h-[150px] overflow-y-auto",children:o.jsx("div",{className:"pr-1",children:e.files.map((t,n)=>o.jsx(bT,{file:t},n))})})}function Xv({messages:e,workdir:t}){var k,y,S,v;const[n,s]=R.useState(!1),[a,l]=R.useState(!1),[u,c]=R.useState(!1),[h,f]=R.useState(!1),p=UN(e),{branch:m}=US(),_=Bt(b=>b.version),x=we(b=>b.currentSession),w=R.useCallback(async()=>{l(!0);try{const b=await fetch("/api/auto-update/check");if(b.ok){const E=await b.json();c(E.isUpdateAvailable)}}catch{}finally{l(!1)}},[]);return R.useEffect(()=>{w()},[w]),R.useEffect(()=>{if(new URLSearchParams(window.location.search).get("test-update")==="1"){c(!0),f(!0);const E=new URL(window.location.href);E.searchParams.delete("test-update"),window.history.replaceState({},"",E.toString())}},[]),o.jsxs("div",{className:"flex flex-col h-full",children:[p&&o.jsxs("div",{className:"mb-4",children:[o.jsx("button",{onClick:()=>s(!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:o.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[o.jsx("span",{className:"text-text-secondary",children:FN(p.aiTime)}),o.jsx("span",{className:"w-px h-3 bg-border"}),o.jsx("span",{className:"text-text-secondary",children:Fv(p.avgPrefillSpeed)}),o.jsx("span",{children:"pp"}),o.jsx("span",{className:"w-px h-3 bg-border"}),o.jsx("span",{className:"text-text-secondary",children:Fv(p.avgGenerationSpeed)}),o.jsx("span",{children:"tg"})]})}),o.jsx(eT,{isOpen:n,onClose:()=>s(!1),stats:p})]}),o.jsx("div",{className:"flex flex-col flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mt-4",children:[o.jsx(qv,{entries:((k=x==null?void 0:x.metadataEntries)==null?void 0:k.criteria)??[],title:"Acceptance Criteria"}),x&&o.jsx(dT,{entries:((y=x==null?void 0:x.metadataEntries)==null?void 0:y.criteria)??[],sessionId:x.id}),x&&(((v=(S=x.metadataEntries)==null?void 0:S.review_findings)==null?void 0:v.length)??0)>0&&o.jsxs("div",{className:"mt-6",children:[o.jsx(qv,{entries:x.metadataEntries.review_findings,title:"Review Findings"}),o.jsx(aT,{entries:x.metadataEntries.review_findings})]})]})}),m&&o.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm",children:[o.jsx(yj,{}),o.jsx("span",{className:"truncate text-text-secondary",title:m,children:m})]}),o.jsx(ST,{}),o.jsx(_T,{workdir:t}),o.jsx(yT,{sessionId:x==null?void 0:x.id}),_&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[o.jsxs("div",{className:"flex items-center justify-center gap-1",children:[o.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",o.jsxs("span",{className:"font-mono",children:["v",_]}),o.jsx("button",{onClick:()=>w(),disabled:a,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:o.jsx(lp,{className:`w-3 h-3 ${a?"animate-spin":""}`})})]}),u&&o.jsx("button",{onClick:()=>f(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"})]}),o.jsx(vT,{isOpen:h,onClose:()=>f(!1),versionInfo:null})]})}function wT({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:s}){const a=we(l=>l.currentSession);return o.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&o.jsx("div",{className:"fixed md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),o.jsxs("div",{className:"flex h-full",children:[o.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?o.jsx("aside",{className:"hidden md:block w-[320px] shrink-0 border-l border-border p-4 overflow-y-auto bg-secondary",children:o.jsx(Xv,{messages:s,workdir:a==null?void 0:a.workdir})}):o.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),o.jsx("aside",{className:`
|
|
89
|
+
md:hidden
|
|
90
|
+
p-4 overflow-y-auto bg-secondary
|
|
91
|
+
transition-all duration-300 ease-in-out
|
|
92
|
+
fixed right-0 top-[32px] h-[calc(100vh-32px)] z-50
|
|
93
|
+
${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
|
|
94
|
+
`,children:o.jsx(Xv,{messages:s,workdir:a==null?void 0:a.workdir})})]})]})}function CT(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function qS({percent:e,dangerZone:t=!1,size:n="md",className:s=""}){const a=n==="sm"?"w-12":"w-20",l=n==="sm"?"h-1":"h-1.5";return o.jsx("div",{className:`${l} bg-bg-tertiary rounded-full overflow-hidden ${a} ${s}`,children:o.jsx("div",{className:`h-full transition-all duration-300 ${CT(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function kT({dangerZone:e,size:t="md"}){return e?o.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function Qv(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function ET(){const e=we(v=>v.contextState),t=we(v=>v.currentSession),n=we(v=>v.compactContext),[s,a]=R.useState(!1),[l,u]=R.useState(!1),[c,h]=R.useState(!1),f=R.useRef(!1);if(R.useEffect(()=>{e!=null&&e.dynamicContextChanged&&!f.current&&u(!1),f.current=(e==null?void 0:e.dynamicContextChanged)??!1},[e==null?void 0:e.dynamicContextChanged]),!e||!t)return null;const{currentTokens:p,maxTokens:m,compactionCount:_,dangerZone:x,dynamicContextChanged:w}=e,k=Math.round(p/m*100),y=t.isRunning,S=()=>{zt.send("context.applyDynamic",{}),u(!0)};return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-secondary",children:o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx("div",{className:"flex-1"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:Qv(k,x),children:[hu(p)," / ",hu(m)]}),o.jsxs("span",{className:Qv(k,x),children:["(",k,"%)"]}),o.jsx(qS,{percent:k,dangerZone:x}),o.jsx(kT,{dangerZone:x}),_>0&&o.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[_,"x"]})]}),o.jsx("div",{className:"flex-1 flex justify-end",children:o.jsxs("div",{className:"relative",children:[o.jsx("button",{onClick:()=>a(!s),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:o.jsx(gS,{})}),s&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>a(!1)}),o.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:[o.jsx("button",{onClick:()=>{y||n(),a(!1)},disabled:y,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:y?"Cannot compact while running":"Compact context",children:o.jsx("span",{className:x?"text-accent-error":"",children:"Compact"})}),w&&o.jsx("button",{onClick:()=>{a(!1),h(!0)},disabled:y,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:y?"Cannot apply while running":"Apply dynamic context",children:o.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]})]})]})})]})}),w&&!l&&o.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent-warning/10 border-b border-accent-warning/30",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 text-sm text-text-secondary",children:[o.jsx("span",{children:"System prompt has changed —"}),o.jsx("button",{onClick:()=>h(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),o.jsx("button",{onClick:()=>u(!0),className:"flex-shrink-0 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Dismiss",children:o.jsx(gl,{})})]})}),o.jsxs(Dt,{isOpen:c,onClose:()=>h(!1),title:"Update system prompt",size:"sm",children:[o.jsx("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."}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx("button",{onClick:()=>h(!1),className:"px-3 py-1.5 text-sm rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),o.jsx("button",{onClick:()=>{S(),h(!1)},disabled:y,className:"px-3 py-1.5 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"Update"})]})]})]})}function jT({stats:e,onClose:t}){var n;return o.jsx(Dt,{isOpen:!0,onClose:t,title:"Turn Stats",size:"md",children:o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"flex items-center gap-3",children:o.jsxs("p",{className:"text-xs text-text-muted",children:[e.model," · ",e.mode]})}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[o.jsx(Vc,{label:"Total Time",value:`${e.totalTime.toFixed(1)}s`}),o.jsx(Vc,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),o.jsx(Vc,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),o.jsx(Vc,{label:"LLM Calls",value:String(((n=e.llmCalls)==null?void 0:n.length)??1)})]}),e.llmCalls&&e.llmCalls.length>0&&o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-medium text-text-secondary mb-2",children:"LLM Calls"}),e.llmCalls.map((s,a)=>o.jsxs("div",{className:"bg-bg-tertiary/30 rounded p-3 mb-2",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("span",{className:"text-xs text-text-muted",children:["Call ",a+1]}),o.jsxs("span",{className:"text-xs text-text-muted",children:[s.ttft.toFixed(2),"s TTFT · ",s.completionTime.toFixed(2),"s gen"]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-text-muted",children:"Tokens:"})," ",o.jsxs("span",{className:"text-text-primary",children:[s.promptTokens," → ",s.completionTokens]})]}),o.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[s.temperature!==void 0&&o.jsx(Gc,{label:"temp",value:s.temperature.toFixed(2)}),s.topP!==void 0&&o.jsx(Gc,{label:"topP",value:s.topP.toFixed(2)}),s.topK!==void 0&&o.jsx(Gc,{label:"topK",value:String(s.topK)}),s.maxTokens!==void 0&&o.jsx(Gc,{label:"maxTok",value:String(s.maxTokens)})]})]})]},a))]})]})})}function Vc({label:e,value:t}){return o.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[o.jsx("div",{className:"text-xs text-text-muted",children:e}),o.jsx("div",{className:"text-lg font-semibold text-text-primary",children:t})]})}function Gc({label:e,value:t}){return o.jsxs("span",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-primary",children:[o.jsxs("span",{className:"text-text-muted",children:[e,":"]})," ",t]})}function NT(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const TT=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,AT=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,LT={};function Jv(e,t){return(LT.jsx?AT:TT).test(e)}const DT=/[ \t\n\f\r]/g;function RT(e){return typeof e=="object"?e.type==="text"?Zv(e.value):!1:Zv(e)}function Zv(e){return e.replace(DT,"")===""}let vl=class{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}};vl.prototype.normal={};vl.prototype.property={};vl.prototype.space=void 0;function KS(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new vl(n,s,t)}function km(e){return e.toLowerCase()}let Rn=class{constructor(t,n){this.attribute=n,this.property=t}};Rn.prototype.attribute="";Rn.prototype.booleanish=!1;Rn.prototype.boolean=!1;Rn.prototype.commaOrSpaceSeparated=!1;Rn.prototype.commaSeparated=!1;Rn.prototype.defined=!1;Rn.prototype.mustUseProperty=!1;Rn.prototype.number=!1;Rn.prototype.overloadedBoolean=!1;Rn.prototype.property="";Rn.prototype.spaceSeparated=!1;Rn.prototype.space=void 0;let OT=0;const Je=Li(),Qt=Li(),Em=Li(),ke=Li(),Nt=Li(),Oa=Li(),Fn=Li();function Li(){return 2**++OT}const jm=Object.freeze(Object.defineProperty({__proto__:null,boolean:Je,booleanish:Qt,commaOrSpaceSeparated:Fn,commaSeparated:Oa,number:ke,overloadedBoolean:Em,spaceSeparated:Nt},Symbol.toStringTag,{value:"Module"})),If=Object.keys(jm);let _p=class extends Rn{constructor(t,n,s,a){let l=-1;if(super(t,n),eb(this,"space",a),typeof s=="number")for(;++l<If.length;){const u=If[l];eb(this,If[l],(s&jm[u])===jm[u])}}};_p.prototype.defined=!0;function eb(e,t,n){n&&(e[t]=n)}function Ua(e){const t={},n={};for(const[s,a]of Object.entries(e.properties)){const l=new _p(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(l.mustUseProperty=!0),t[s]=l,n[km(s)]=s,n[km(l.attribute)]=s}return new vl(t,n,e.space)}const YS=Ua({properties:{ariaActiveDescendant:null,ariaAtomic:Qt,ariaAutoComplete:null,ariaBusy:Qt,ariaChecked:Qt,ariaColCount:ke,ariaColIndex:ke,ariaColSpan:ke,ariaControls:Nt,ariaCurrent:null,ariaDescribedBy:Nt,ariaDetails:null,ariaDisabled:Qt,ariaDropEffect:Nt,ariaErrorMessage:null,ariaExpanded:Qt,ariaFlowTo:Nt,ariaGrabbed:Qt,ariaHasPopup:null,ariaHidden:Qt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Nt,ariaLevel:ke,ariaLive:null,ariaModal:Qt,ariaMultiLine:Qt,ariaMultiSelectable:Qt,ariaOrientation:null,ariaOwns:Nt,ariaPlaceholder:null,ariaPosInSet:ke,ariaPressed:Qt,ariaReadOnly:Qt,ariaRelevant:null,ariaRequired:Qt,ariaRoleDescription:Nt,ariaRowCount:ke,ariaRowIndex:ke,ariaRowSpan:ke,ariaSelected:Qt,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 XS(e,t){return t in e?e[t]:t}function QS(e,t){return XS(e,t.toLowerCase())}const MT=Ua({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Oa,acceptCharset:Nt,accessKey:Nt,action:null,allow:null,allowFullScreen:Je,allowPaymentRequest:Je,allowUserMedia:Je,alt:null,as:null,async:Je,autoCapitalize:null,autoComplete:Nt,autoFocus:Je,autoPlay:Je,blocking:Nt,capture:null,charSet:null,checked:Je,cite:null,className:Nt,cols:ke,colSpan:null,content:null,contentEditable:Qt,controls:Je,controlsList:Nt,coords:ke|Oa,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Je,defer:Je,dir:null,dirName:null,disabled:Je,download:Em,draggable:Qt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Je,formTarget:null,headers:Nt,height:ke,hidden:Em,high:ke,href:null,hrefLang:null,htmlFor:Nt,httpEquiv:Nt,id:null,imageSizes:null,imageSrcSet:null,inert:Je,inputMode:null,integrity:null,is:null,isMap:Je,itemId:null,itemProp:Nt,itemRef:Nt,itemScope:Je,itemType:Nt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Je,low:ke,manifest:null,max:null,maxLength:ke,media:null,method:null,min:null,minLength:ke,multiple:Je,muted:Je,name:null,nonce:null,noModule:Je,noValidate:Je,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:Je,optimum:ke,pattern:null,ping:Nt,placeholder:null,playsInline:Je,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Je,referrerPolicy:null,rel:Nt,required:Je,reversed:Je,rows:ke,rowSpan:ke,sandbox:Nt,scope:null,scoped:Je,seamless:Je,selected:Je,shadowRootClonable:Je,shadowRootDelegatesFocus:Je,shadowRootMode:null,shape:null,size:ke,sizes:null,slot:null,span:ke,spellCheck:Qt,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:Je,useMap:null,value:Qt,width:ke,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Nt,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:Je,declare:Je,event:null,face:null,frame:null,frameBorder:null,hSpace:ke,leftMargin:ke,link:null,longDesc:null,lowSrc:null,marginHeight:ke,marginWidth:ke,noResize:Je,noHref:Je,noShade:Je,noWrap:Je,object:null,profile:null,prompt:null,rev:null,rightMargin:ke,rules:null,scheme:null,scrolling:Qt,standby:null,summary:null,text:null,topMargin:ke,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ke,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Je,disableRemotePlayback:Je,prefix:null,property:null,results:ke,security:null,unselectable:null},space:"html",transform:QS}),IT=Ua({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",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:Fn,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:Nt,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:Je,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:Oa,g2:Oa,glyphName:Oa,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:Fn,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,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:Nt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ke,pointsAtY:ke,pointsAtZ:ke,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Fn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Fn,rev:Fn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Fn,requiredFeatures:Fn,requiredFonts:Fn,requiredFormats:Fn,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:Fn,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:Fn,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:Fn,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:XS}),JS=Ua({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()}}),ZS=Ua({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:QS}),e1=Ua({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),PT={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"},BT=/[A-Z]/g,tb=/-[a-z]/g,zT=/^data[-\w.:]+$/i;function HT(e,t){const n=km(t);let s=t,a=Rn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&zT.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(tb,UT);s="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!tb.test(l)){let u=l.replace(BT,$T);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=_p}return new a(s,t)}function $T(e){return"-"+e.toLowerCase()}function UT(e){return e.charAt(1).toUpperCase()}const FT=KS([YS,MT,JS,ZS,e1],"html"),yp=KS([YS,IT,JS,ZS,e1],"svg");function VT(e){return e.join(" ").trim()}var wa={},Pf,nb;function GT(){if(nb)return Pf;nb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,h=`
|
|
95
|
+
`,f="/",p="*",m="",_="comment",x="declaration";function w(y,S){if(typeof y!="string")throw new TypeError("First argument must be a string");if(!y)return[];S=S||{};var v=1,b=1;function E(V){var G=V.match(t);G&&(v+=G.length);var z=V.lastIndexOf(h);b=~z?V.length-z:b+V.length}function T(){var V={line:v,column:b};return function(G){return G.position=new N(V),D(),G}}function N(V){this.start=V,this.end={line:v,column:b},this.source=S.source}N.prototype.content=y;function L(V){var G=new Error(S.source+":"+v+":"+b+": "+V);if(G.reason=V,G.filename=S.source,G.line=v,G.column=b,G.source=y,!S.silent)throw G}function A(V){var G=V.exec(y);if(G){var z=G[0];return E(z),y=y.slice(z.length),G}}function D(){A(n)}function B(V){var G;for(V=V||[];G=q();)G!==!1&&V.push(G);return V}function q(){var V=T();if(!(f!=y.charAt(0)||p!=y.charAt(1))){for(var G=2;m!=y.charAt(G)&&(p!=y.charAt(G)||f!=y.charAt(G+1));)++G;if(G+=2,m===y.charAt(G-1))return L("End of comment missing");var z=y.slice(2,G-2);return b+=2,E(z),y=y.slice(G),b+=2,V({type:_,comment:z})}}function W(){var V=T(),G=A(s);if(G){if(q(),!A(a))return L("property missing ':'");var z=A(l),X=V({type:x,property:k(G[0].replace(e,m)),value:z?k(z[0].replace(e,m)):m});return A(u),X}}function O(){var V=[];B(V);for(var G;G=W();)G!==!1&&(V.push(G),B(V));return V}return D(),O()}function k(y){return y?y.replace(c,m):m}return Pf=w,Pf}var rb;function WT(){if(rb)return wa;rb=1;var e=wa&&wa.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(wa,"__esModule",{value:!0}),wa.default=n;const t=e(GT());function n(s,a){let l=null;if(!s||typeof s!="string")return l;const u=(0,t.default)(s),c=typeof a=="function";return u.forEach(h=>{if(h.type!=="declaration")return;const{property:f,value:p}=h;c?a(f,p,h):p&&(l=l||{},l[f]=p)}),l}return wa}var Fo={},sb;function qT(){if(sb)return Fo;sb=1,Object.defineProperty(Fo,"__esModule",{value:!0}),Fo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,l=function(f){return!f||n.test(f)||e.test(f)},u=function(f,p){return p.toUpperCase()},c=function(f,p){return"".concat(p,"-")},h=function(f,p){return p===void 0&&(p={}),l(f)?f:(f=f.toLowerCase(),p.reactCompat?f=f.replace(a,c):f=f.replace(s,c),f.replace(t,u))};return Fo.camelCase=h,Fo}var Vo,ib;function KT(){if(ib)return Vo;ib=1;var e=Vo&&Vo.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(WT()),n=qT();function s(a,l){var u={};return!a||typeof a!="string"||(0,t.default)(a,function(c,h){c&&h&&(u[(0,n.camelCase)(c,l)]=h)}),u}return s.default=s,Vo=s,Vo}var YT=KT();const XT=Du(YT),t1=n1("end"),vp=n1("start");function n1(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function QT(e){const t=vp(e),n=t1(e);if(t&&n)return{start:t,end:n}}function el(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ab(e.position):"start"in e||"end"in e?ab(e):"line"in e||"column"in e?Nm(e):""}function Nm(e){return ob(e&&e.line)+":"+ob(e&&e.column)}function ab(e){return Nm(e&&e.start)+"-"+Nm(e&&e.end)}function ob(e){return e&&typeof e=="number"?e:1}class bn extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",l={},u=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?a=t:!l.cause&&t&&(u=!0,a=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof s=="string"){const h=s.indexOf(":");h===-1?l.ruleId=s:(l.source=s.slice(0,h),l.ruleId=s.slice(h+1))}if(!l.place&&l.ancestors&&l.ancestors){const h=l.ancestors[l.ancestors.length-1];h&&(l.place=h.position)}const c=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=el(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=u&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}bn.prototype.file="";bn.prototype.name="";bn.prototype.reason="";bn.prototype.message="";bn.prototype.stack="";bn.prototype.column=void 0;bn.prototype.line=void 0;bn.prototype.ancestors=void 0;bn.prototype.cause=void 0;bn.prototype.fatal=void 0;bn.prototype.place=void 0;bn.prototype.ruleId=void 0;bn.prototype.source=void 0;const bp={}.hasOwnProperty,JT=new Map,ZT=/[A-Z]/g,eA=new Set(["table","tbody","thead","tfoot","tr"]),tA=new Set(["td","th"]),r1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function nA(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=uA(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");s=cA(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,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"?yp:FT,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=s1(a,e,void 0);return l&&typeof l!="string"?l:a.create(e,a.Fragment,{children:l||void 0},void 0)}function s1(e,t,n){if(t.type==="element")return rA(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return sA(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return aA(e,t,n);if(t.type==="mdxjsEsm")return iA(e,t);if(t.type==="root")return oA(e,t,n);if(t.type==="text")return lA(e,t)}function rA(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=yp,e.schema=a),e.ancestors.push(t);const l=a1(e,t.tagName,!1),u=dA(e,t);let c=wp(e,t);return eA.has(t.tagName)&&(c=c.filter(function(h){return typeof h=="string"?!RT(h):!0})),i1(e,u,l,t),Sp(u,c),e.ancestors.pop(),e.schema=s,e.create(t,l,u,n)}function sA(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}al(e,t.position)}function iA(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);al(e,t.position)}function aA(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=yp,e.schema=a),e.ancestors.push(t);const l=t.name===null?e.Fragment:a1(e,t.name,!0),u=hA(e,t),c=wp(e,t);return i1(e,u,l,t),Sp(u,c),e.ancestors.pop(),e.schema=s,e.create(t,l,u,n)}function oA(e,t,n){const s={};return Sp(s,wp(e,t)),e.create(t,e.Fragment,s,n)}function lA(e,t){return t.value}function i1(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function Sp(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function cA(e,t,n){return s;function s(a,l,u,c){const f=Array.isArray(u.children)?n:t;return c?f(l,u,c):f(l,u)}}function uA(e,t){return n;function n(s,a,l,u){const c=Array.isArray(l.children),h=vp(s);return t(a,l,u,c,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function dA(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&bp.call(t.properties,a)){const l=fA(e,a,t.properties[a]);if(l){const[u,c]=l;e.tableCellAlignToStyle&&u==="align"&&typeof c=="string"&&tA.has(t.tagName)?s=c:n[u]=c}}if(s){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function hA(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const l=s.data.estree.body[0];l.type;const u=l.expression;u.type;const c=u.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else al(e,t.position);else{const a=s.name;let l;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const c=s.value.data.estree.body[0];c.type,l=e.evaluater.evaluateExpression(c.expression)}else al(e,t.position);else l=s.value===null?!0:s.value;n[a]=l}return n}function wp(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:JT;for(;++s<t.children.length;){const l=t.children[s];let u;if(e.passKeys){const h=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(h){const f=a.get(h)||0;u=h+"-"+f,a.set(h,f+1)}}const c=s1(e,l,u);c!==void 0&&n.push(c)}return n}function fA(e,t,n){const s=HT(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?NT(n):VT(n)),s.property==="style"){let a=typeof n=="object"?n:mA(e,String(n));return e.stylePropertyNameCase==="css"&&(a=pA(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&s.space?PT[s.property]||s.property:s.attribute,n]}}function mA(e,t){try{return XT(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const s=n,a=new bn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=r1+"#cannot-parse-style-attribute",a}}function a1(e,t,n){let s;if(!n)s={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let l=-1,u;for(;++l<a.length;){const c=Jv(a[l])?{type:"Identifier",name:a[l]}:{type:"Literal",value:a[l]};u=u?{type:"MemberExpression",object:u,property:c,computed:!!(l&&c.type==="Literal"),optional:!1}:c}s=u}else s=Jv(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const a=s.value;return bp.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(s);al(e)}function al(e,t){const n=new bn("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=r1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function pA(e){const t={};let n;for(n in e)bp.call(e,n)&&(t[gA(n)]=e[n]);return t}function gA(e){let t=e.replace(ZT,xA);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function xA(e){return"-"+e.toLowerCase()}const Bf={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"]},_A={};function Cp(e,t){const n=_A,s=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return o1(e,s,a)}function o1(e,t,n){if(yA(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 lb(e.children,t,n)}return Array.isArray(e)?lb(e,t,n):""}function lb(e,t,n){const s=[];let a=-1;for(;++a<e.length;)s[a]=o1(e[a],t,n);return s.join("")}function yA(e){return!!(e&&typeof e=="object")}const cb=document.createElement("i");function kp(e){const t="&"+e+";";cb.innerHTML=t;const n=cb.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Wn(e,t,n,s){const a=e.length;let l=0,u;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,s.length<1e4)u=Array.from(s),u.unshift(t,n),e.splice(...u);else for(n&&e.splice(t,n);l<s.length;)u=s.slice(l,l+1e4),u.unshift(t,0),e.splice(...u),l+=1e4,t+=1e4}function ir(e,t){return e.length>0?(Wn(e,e.length,0,t),e):t}const ub={}.hasOwnProperty;function l1(e){const t={};let n=-1;for(;++n<e.length;)vA(t,e[n]);return t}function vA(e,t){let n;for(n in t){const a=(ub.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let u;if(l)for(u in l){ub.call(a,u)||(a[u]=[]);const c=l[u];bA(a[u],Array.isArray(c)?c:c?[c]:[])}}}function bA(e,t){let n=-1;const s=[];for(;++n<t.length;)(t[n].add==="after"?e:s).push(t[n]);Wn(e,0,0,s)}function c1(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 vr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Cn=Ks(/[A-Za-z]/),vn=Ks(/[\dA-Za-z]/),SA=Ks(/[#-'*+\--9=?A-Z^-~]/);function pu(e){return e!==null&&(e<32||e===127)}const Tm=Ks(/\d/),wA=Ks(/[\dA-Fa-f]/),CA=Ks(/[!-/:-@[-`{-~]/);function Ue(e){return e!==null&&e<-2}function jt(e){return e!==null&&(e<0||e===32)}function it(e){return e===-2||e===-1||e===32}const Vu=Ks(new RegExp("\\p{P}|\\p{S}","u")),Ti=Ks(/\s/);function Ks(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Fa(e){const t=[];let n=-1,s=0,a=0;for(;++n<e.length;){const l=e.charCodeAt(n);let u="";if(l===37&&vn(e.charCodeAt(n+1))&&vn(e.charCodeAt(n+2)))a=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(u=String.fromCharCode(l));else if(l>55295&&l<57344){const c=e.charCodeAt(n+1);l<56320&&c>56319&&c<57344?(u=String.fromCharCode(l,c),a=1):u="�"}else u=String.fromCharCode(l);u&&(t.push(e.slice(s,n),encodeURIComponent(u)),s=n+a+1,u=""),a&&(n+=a,a=0)}return t.join("")+e.slice(s)}function ut(e,t,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let l=0;return u;function u(h){return it(h)?(e.enter(n),c(h)):t(h)}function c(h){return it(h)&&l++<a?(e.consume(h),c):(e.exit(n),t(h))}}const kA={tokenize:EA};function EA(e){const t=e.attempt(this.parser.constructs.contentInitial,s,a);let n;return t;function s(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),ut(e,t,"linePrefix")}function a(c){return e.enter("paragraph"),l(c)}function l(c){const h=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=h),n=h,u(c)}function u(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return Ue(c)?(e.consume(c),e.exit("chunkText"),l):(e.consume(c),u)}}const jA={tokenize:NA},db={tokenize:TA};function NA(e){const t=this,n=[];let s=0,a,l,u;return c;function c(b){if(s<n.length){const E=n[s];return t.containerState=E[1],e.attempt(E[0].continuation,h,f)(b)}return f(b)}function h(b){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&v();const E=t.events.length;let T=E,N;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){N=t.events[T][1].end;break}S(s);let L=E;for(;L<t.events.length;)t.events[L][1].end={...N},L++;return Wn(t.events,T+1,0,t.events.slice(E)),t.events.length=L,f(b)}return c(b)}function f(b){if(s===n.length){if(!a)return _(b);if(a.currentConstruct&&a.currentConstruct.concrete)return w(b);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(db,p,m)(b)}function p(b){return a&&v(),S(s),_(b)}function m(b){return t.parser.lazy[t.now().line]=s!==n.length,u=t.now().offset,w(b)}function _(b){return t.containerState={},e.attempt(db,x,w)(b)}function x(b){return s++,n.push([t.currentConstruct,t.containerState]),_(b)}function w(b){if(b===null){a&&v(),S(0),e.consume(b);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:l}),k(b)}function k(b){if(b===null){y(e.exit("chunkFlow"),!0),S(0),e.consume(b);return}return Ue(b)?(e.consume(b),y(e.exit("chunkFlow")),s=0,t.interrupt=void 0,c):(e.consume(b),k)}function y(b,E){const T=t.sliceStream(b);if(E&&T.push(null),b.previous=l,l&&(l.next=b),l=b,a.defineSkip(b.start),a.write(T),t.parser.lazy[b.start.line]){let N=a.events.length;for(;N--;)if(a.events[N][1].start.offset<u&&(!a.events[N][1].end||a.events[N][1].end.offset>u))return;const L=t.events.length;let A=L,D,B;for(;A--;)if(t.events[A][0]==="exit"&&t.events[A][1].type==="chunkFlow"){if(D){B=t.events[A][1].end;break}D=!0}for(S(s),N=L;N<t.events.length;)t.events[N][1].end={...B},N++;Wn(t.events,A+1,0,t.events.slice(L)),t.events.length=N}}function S(b){let E=n.length;for(;E-- >b;){const T=n[E];t.containerState=T[1],T[0].exit.call(t,e)}n.length=b}function v(){a.write([null]),l=void 0,a=void 0,t.containerState._closeFlow=void 0}}function TA(e,t,n){return ut(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Pa(e){if(e===null||jt(e)||Ti(e))return 1;if(Vu(e))return 2}function Gu(e,t,n){const s=[];let a=-1;for(;++a<e.length;){const l=e[a].resolveAll;l&&!s.includes(l)&&(t=l(t,n),s.push(l))}return t}const Am={name:"attention",resolveAll:AA,tokenize:LA};function AA(e,t){let n=-1,s,a,l,u,c,h,f,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(s=n;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[s][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;h=e[s][1].end.offset-e[s][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const m={...e[s][1].end},_={...e[n][1].start};hb(m,-h),hb(_,h),u={type:h>1?"strongSequence":"emphasisSequence",start:m,end:{...e[s][1].end}},c={type:h>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:_},l={type:h>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},a={type:h>1?"strong":"emphasis",start:{...u.start},end:{...c.end}},e[s][1].end={...u.start},e[n][1].start={...c.end},f=[],e[s][1].end.offset-e[s][1].start.offset&&(f=ir(f,[["enter",e[s][1],t],["exit",e[s][1],t]])),f=ir(f,[["enter",a,t],["enter",u,t],["exit",u,t],["enter",l,t]]),f=ir(f,Gu(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),f=ir(f,[["exit",l,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,f=ir(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,Wn(e,s-1,n-s+3,f),n=s+f.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function LA(e,t){const n=this.parser.constructs.attentionMarkers.null,s=this.previous,a=Pa(s);let l;return u;function u(h){return l=h,e.enter("attentionSequence"),c(h)}function c(h){if(h===l)return e.consume(h),c;const f=e.exit("attentionSequence"),p=Pa(h),m=!p||p===2&&a||n.includes(h),_=!a||a===2&&p||n.includes(s);return f._open=!!(l===42?m:m&&(a||!_)),f._close=!!(l===42?_:_&&(p||!m)),t(h)}}function hb(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const DA={name:"autolink",tokenize:RA};function RA(e,t,n){let s=0;return a;function a(x){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(x){return Cn(x)?(e.consume(x),u):x===64?n(x):f(x)}function u(x){return x===43||x===45||x===46||vn(x)?(s=1,c(x)):f(x)}function c(x){return x===58?(e.consume(x),s=0,h):(x===43||x===45||x===46||vn(x))&&s++<32?(e.consume(x),c):(s=0,f(x))}function h(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||pu(x)?n(x):(e.consume(x),h)}function f(x){return x===64?(e.consume(x),p):SA(x)?(e.consume(x),f):n(x)}function p(x){return vn(x)?m(x):n(x)}function m(x){return x===46?(e.consume(x),s=0,p):x===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.exit("autolink"),t):_(x)}function _(x){if((x===45||vn(x))&&s++<63){const w=x===45?_:m;return e.consume(x),w}return n(x)}}const bl={partial:!0,tokenize:OA};function OA(e,t,n){return s;function s(l){return it(l)?ut(e,a,"linePrefix")(l):a(l)}function a(l){return l===null||Ue(l)?t(l):n(l)}}const u1={continuation:{tokenize:IA},exit:PA,name:"blockQuote",tokenize:MA};function MA(e,t,n){const s=this;return a;function a(u){if(u===62){const c=s.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),l}return n(u)}function l(u){return it(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function IA(e,t,n){const s=this;return a;function a(u){return it(u)?ut(e,l,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):l(u)}function l(u){return e.attempt(u1,t,n)(u)}}function PA(e){e.exit("blockQuote")}const d1={name:"characterEscape",tokenize:BA};function BA(e,t,n){return s;function s(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),a}function a(l){return CA(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const h1={name:"characterReference",tokenize:zA};function zA(e,t,n){const s=this;let a=0,l,u;return c;function c(m){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),h}function h(m){return m===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(m),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),l=31,u=vn,p(m))}function f(m){return m===88||m===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(m),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,u=wA,p):(e.enter("characterReferenceValue"),l=7,u=Tm,p(m))}function p(m){if(m===59&&a){const _=e.exit("characterReferenceValue");return u===vn&&!kp(s.sliceSerialize(_))?n(m):(e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(m)&&a++<l?(e.consume(m),p):n(m)}}const fb={partial:!0,tokenize:$A},mb={concrete:!0,name:"codeFenced",tokenize:HA};function HA(e,t,n){const s=this,a={partial:!0,tokenize:T};let l=0,u=0,c;return h;function h(N){return f(N)}function f(N){const L=s.events[s.events.length-1];return l=L&&L[1].type==="linePrefix"?L[2].sliceSerialize(L[1],!0).length:0,c=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(N)}function p(N){return N===c?(u++,e.consume(N),p):u<3?n(N):(e.exit("codeFencedFenceSequence"),it(N)?ut(e,m,"whitespace")(N):m(N))}function m(N){return N===null||Ue(N)?(e.exit("codeFencedFence"),s.interrupt?t(N):e.check(fb,k,E)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),_(N))}function _(N){return N===null||Ue(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),m(N)):it(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ut(e,x,"whitespace")(N)):N===96&&N===c?n(N):(e.consume(N),_)}function x(N){return N===null||Ue(N)?m(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(N))}function w(N){return N===null||Ue(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),m(N)):N===96&&N===c?n(N):(e.consume(N),w)}function k(N){return e.attempt(a,E,y)(N)}function y(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),S}function S(N){return l>0&&it(N)?ut(e,v,"linePrefix",l+1)(N):v(N)}function v(N){return N===null||Ue(N)?e.check(fb,k,E)(N):(e.enter("codeFlowValue"),b(N))}function b(N){return N===null||Ue(N)?(e.exit("codeFlowValue"),v(N)):(e.consume(N),b)}function E(N){return e.exit("codeFenced"),t(N)}function T(N,L,A){let D=0;return B;function B(G){return N.enter("lineEnding"),N.consume(G),N.exit("lineEnding"),q}function q(G){return N.enter("codeFencedFence"),it(G)?ut(N,W,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(G):W(G)}function W(G){return G===c?(N.enter("codeFencedFenceSequence"),O(G)):A(G)}function O(G){return G===c?(D++,N.consume(G),O):D>=u?(N.exit("codeFencedFenceSequence"),it(G)?ut(N,V,"whitespace")(G):V(G)):A(G)}function V(G){return G===null||Ue(G)?(N.exit("codeFencedFence"),L(G)):A(G)}}}function $A(e,t,n){const s=this;return a;function a(u){return u===null?n(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l)}function l(u){return s.parser.lazy[s.now().line]?n(u):t(u)}}const zf={name:"codeIndented",tokenize:FA},UA={partial:!0,tokenize:VA};function FA(e,t,n){const s=this;return a;function a(f){return e.enter("codeIndented"),ut(e,l,"linePrefix",5)(f)}function l(f){const p=s.events[s.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?u(f):n(f)}function u(f){return f===null?h(f):Ue(f)?e.attempt(UA,u,h)(f):(e.enter("codeFlowValue"),c(f))}function c(f){return f===null||Ue(f)?(e.exit("codeFlowValue"),u(f)):(e.consume(f),c)}function h(f){return e.exit("codeIndented"),t(f)}}function VA(e,t,n){const s=this;return a;function a(u){return s.parser.lazy[s.now().line]?n(u):Ue(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),a):ut(e,l,"linePrefix",5)(u)}function l(u){const c=s.events[s.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):Ue(u)?a(u):n(u)}}const GA={name:"codeText",previous:qA,resolve:WA,tokenize:KA};function WA(e){let t=e.length-4,n=3,s,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s<t;)if(e[s][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(s=n-1,t++;++s<=t;)a===void 0?s!==t&&e[s][1].type!=="lineEnding"&&(a=s):(s===t||e[s][1].type==="lineEnding")&&(e[a][1].type="codeTextData",s!==a+2&&(e[a][1].end=e[s-1][1].end,e.splice(a+2,s-a-2),t-=s-a-2,s=a+2),a=void 0);return e}function qA(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function KA(e,t,n){let s=0,a,l;return u;function u(m){return e.enter("codeText"),e.enter("codeTextSequence"),c(m)}function c(m){return m===96?(e.consume(m),s++,c):(e.exit("codeTextSequence"),h(m))}function h(m){return m===null?n(m):m===32?(e.enter("space"),e.consume(m),e.exit("space"),h):m===96?(l=e.enter("codeTextSequence"),a=0,p(m)):Ue(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),h):(e.enter("codeTextData"),f(m))}function f(m){return m===null||m===32||m===96||Ue(m)?(e.exit("codeTextData"),h(m)):(e.consume(m),f)}function p(m){return m===96?(e.consume(m),a++,p):a===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(m)):(l.type="codeTextData",f(m))}}class YA{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 s=n??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(t,s):t>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const a=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&Go(this.left,s),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Go(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Go(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);Go(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Go(this.left,n.reverse())}}}function Go(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 f1(e){const t={};let n=-1,s,a,l,u,c,h,f;const p=new YA(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(s=p.get(n),n&&s[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(h=s[1]._tokenizer.events,l=0,l<h.length&&h[l][1].type==="lineEndingBlank"&&(l+=2),l<h.length&&h[l][1].type==="content"))for(;++l<h.length&&h[l][1].type!=="content";)h[l][1].type==="chunkText"&&(h[l][1]._isInFirstContentOfListItem=!0,l++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,XA(p,n)),n=t[n],f=!0);else if(s[1]._container){for(l=n,a=void 0;l--;)if(u=p.get(l),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(a&&(p.get(a)[1].type="lineEndingBlank"),u[1].type="lineEnding",a=l);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;a&&(s[1].end={...p.get(a)[1].start},c=p.slice(a,n),c.unshift(s),p.splice(a,n-a+1,c))}}return Wn(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!f}function XA(e,t){const n=e.get(t)[1],s=e.get(t)[2];let a=t-1;const l=[];let u=n._tokenizer;u||(u=s.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const c=u.events,h=[],f={};let p,m,_=-1,x=n,w=0,k=0;const y=[k];for(;x;){for(;e.get(++a)[1]!==x;);l.push(a),x._tokenizer||(p=s.sliceStream(x),x.next||p.push(null),m&&u.defineSkip(x.start),x._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(p),x._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),m=x,x=x.next}for(x=n;++_<c.length;)c[_][0]==="exit"&&c[_-1][0]==="enter"&&c[_][1].type===c[_-1][1].type&&c[_][1].start.line!==c[_][1].end.line&&(k=_+1,y.push(k),x._tokenizer=void 0,x.previous=void 0,x=x.next);for(u.events=[],x?(x._tokenizer=void 0,x.previous=void 0):y.pop(),_=y.length;_--;){const S=c.slice(y[_],y[_+1]),v=l.pop();h.push([v,v+S.length-1]),e.splice(v,2,S)}for(h.reverse(),_=-1;++_<h.length;)f[w+h[_][0]]=w+h[_][1],w+=h[_][1]-h[_][0]-1;return f}const QA={resolve:ZA,tokenize:eL},JA={partial:!0,tokenize:tL};function ZA(e){return f1(e),e}function eL(e,t){let n;return s;function s(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(c)}function a(c){return c===null?l(c):Ue(c)?e.check(JA,u,l)(c):(e.consume(c),a)}function l(c){return e.exit("chunkContent"),e.exit("content"),t(c)}function u(c){return e.consume(c),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function tL(e,t,n){const s=this;return a;function a(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),ut(e,l,"linePrefix")}function l(u){if(u===null||Ue(u))return n(u);const c=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):e.interrupt(s.parser.constructs.flow,n,t)(u)}}function m1(e,t,n,s,a,l,u,c,h){const f=h||Number.POSITIVE_INFINITY;let p=0;return m;function m(S){return S===60?(e.enter(s),e.enter(a),e.enter(l),e.consume(S),e.exit(l),_):S===null||S===32||S===41||pu(S)?n(S):(e.enter(s),e.enter(u),e.enter(c),e.enter("chunkString",{contentType:"string"}),k(S))}function _(S){return S===62?(e.enter(l),e.consume(S),e.exit(l),e.exit(a),e.exit(s),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),x(S))}function x(S){return S===62?(e.exit("chunkString"),e.exit(c),_(S)):S===null||S===60||Ue(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 k(S){return!p&&(S===null||S===41||jt(S))?(e.exit("chunkString"),e.exit(c),e.exit(u),e.exit(s),t(S)):p<f&&S===40?(e.consume(S),p++,k):S===41?(e.consume(S),p--,k):S===null||S===32||S===40||pu(S)?n(S):(e.consume(S),S===92?y:k)}function y(S){return S===40||S===41||S===92?(e.consume(S),k):k(S)}}function p1(e,t,n,s,a,l){const u=this;let c=0,h;return f;function f(x){return e.enter(s),e.enter(a),e.consume(x),e.exit(a),e.enter(l),p}function p(x){return c>999||x===null||x===91||x===93&&!h||x===94&&!c&&"_hiddenFootnoteSupport"in u.parser.constructs?n(x):x===93?(e.exit(l),e.enter(a),e.consume(x),e.exit(a),e.exit(s),t):Ue(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||Ue(x)||c++>999?(e.exit("chunkString"),p(x)):(e.consume(x),h||(h=!it(x)),x===92?_:m)}function _(x){return x===91||x===92||x===93?(e.consume(x),c++,m):m(x)}}function g1(e,t,n,s,a,l){let u;return c;function c(_){return _===34||_===39||_===40?(e.enter(s),e.enter(a),e.consume(_),e.exit(a),u=_===40?41:_,h):n(_)}function h(_){return _===u?(e.enter(a),e.consume(_),e.exit(a),e.exit(s),t):(e.enter(l),f(_))}function f(_){return _===u?(e.exit(l),h(u)):_===null?n(_):Ue(_)?(e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),ut(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(_))}function p(_){return _===u||_===null||Ue(_)?(e.exit("chunkString"),f(_)):(e.consume(_),_===92?m:p)}function m(_){return _===u||_===92?(e.consume(_),p):p(_)}}function tl(e,t){let n;return s;function s(a){return Ue(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):it(a)?ut(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const nL={name:"definition",tokenize:sL},rL={partial:!0,tokenize:iL};function sL(e,t,n){const s=this;let a;return l;function l(x){return e.enter("definition"),u(x)}function u(x){return p1.call(s,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function c(x){return a=vr(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),h):n(x)}function h(x){return jt(x)?tl(e,f)(x):f(x)}function f(x){return m1(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function p(x){return e.attempt(rL,m,m)(x)}function m(x){return it(x)?ut(e,_,"whitespace")(x):_(x)}function _(x){return x===null||Ue(x)?(e.exit("definition"),s.parser.defined.push(a),t(x)):n(x)}}function iL(e,t,n){return s;function s(c){return jt(c)?tl(e,a)(c):n(c)}function a(c){return g1(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function l(c){return it(c)?ut(e,u,"whitespace")(c):u(c)}function u(c){return c===null||Ue(c)?t(c):n(c)}}const aL={name:"hardBreakEscape",tokenize:oL};function oL(e,t,n){return s;function s(l){return e.enter("hardBreakEscape"),e.consume(l),a}function a(l){return Ue(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const lL={name:"headingAtx",resolve:cL,tokenize:uL};function cL(e,t){let n=e.length-2,s=3,a,l;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},l={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},Wn(e,s,n-s+1,[["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t]])),e}function uL(e,t,n){let s=0;return a;function a(p){return e.enter("atxHeading"),l(p)}function l(p){return e.enter("atxHeadingSequence"),u(p)}function u(p){return p===35&&s++<6?(e.consume(p),u):p===null||jt(p)?(e.exit("atxHeadingSequence"),c(p)):n(p)}function c(p){return p===35?(e.enter("atxHeadingSequence"),h(p)):p===null||Ue(p)?(e.exit("atxHeading"),t(p)):it(p)?ut(e,c,"whitespace")(p):(e.enter("atxHeadingText"),f(p))}function h(p){return p===35?(e.consume(p),h):(e.exit("atxHeadingSequence"),c(p))}function f(p){return p===null||p===35||jt(p)?(e.exit("atxHeadingText"),c(p)):(e.consume(p),f)}}const dL=["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"],pb=["pre","script","style","textarea"],hL={concrete:!0,name:"htmlFlow",resolveTo:pL,tokenize:gL},fL={partial:!0,tokenize:_L},mL={partial:!0,tokenize:xL};function pL(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 gL(e,t,n){const s=this;let a,l,u,c,h;return f;function f(U){return p(U)}function p(U){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(U),m}function m(U){return U===33?(e.consume(U),_):U===47?(e.consume(U),l=!0,k):U===63?(e.consume(U),a=3,s.interrupt?t:M):Cn(U)?(e.consume(U),u=String.fromCharCode(U),y):n(U)}function _(U){return U===45?(e.consume(U),a=2,x):U===91?(e.consume(U),a=5,c=0,w):Cn(U)?(e.consume(U),a=4,s.interrupt?t:M):n(U)}function x(U){return U===45?(e.consume(U),s.interrupt?t:M):n(U)}function w(U){const J="CDATA[";return U===J.charCodeAt(c++)?(e.consume(U),c===J.length?s.interrupt?t:W:w):n(U)}function k(U){return Cn(U)?(e.consume(U),u=String.fromCharCode(U),y):n(U)}function y(U){if(U===null||U===47||U===62||jt(U)){const J=U===47,Q=u.toLowerCase();return!J&&!l&&pb.includes(Q)?(a=1,s.interrupt?t(U):W(U)):dL.includes(u.toLowerCase())?(a=6,J?(e.consume(U),S):s.interrupt?t(U):W(U)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(U):l?v(U):b(U))}return U===45||vn(U)?(e.consume(U),u+=String.fromCharCode(U),y):n(U)}function S(U){return U===62?(e.consume(U),s.interrupt?t:W):n(U)}function v(U){return it(U)?(e.consume(U),v):B(U)}function b(U){return U===47?(e.consume(U),B):U===58||U===95||Cn(U)?(e.consume(U),E):it(U)?(e.consume(U),b):B(U)}function E(U){return U===45||U===46||U===58||U===95||vn(U)?(e.consume(U),E):T(U)}function T(U){return U===61?(e.consume(U),N):it(U)?(e.consume(U),T):b(U)}function N(U){return U===null||U===60||U===61||U===62||U===96?n(U):U===34||U===39?(e.consume(U),h=U,L):it(U)?(e.consume(U),N):A(U)}function L(U){return U===h?(e.consume(U),h=null,D):U===null||Ue(U)?n(U):(e.consume(U),L)}function A(U){return U===null||U===34||U===39||U===47||U===60||U===61||U===62||U===96||jt(U)?T(U):(e.consume(U),A)}function D(U){return U===47||U===62||it(U)?b(U):n(U)}function B(U){return U===62?(e.consume(U),q):n(U)}function q(U){return U===null||Ue(U)?W(U):it(U)?(e.consume(U),q):n(U)}function W(U){return U===45&&a===2?(e.consume(U),z):U===60&&a===1?(e.consume(U),X):U===62&&a===4?(e.consume(U),$):U===63&&a===3?(e.consume(U),M):U===93&&a===5?(e.consume(U),F):Ue(U)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(fL,P,O)(U)):U===null||Ue(U)?(e.exit("htmlFlowData"),O(U)):(e.consume(U),W)}function O(U){return e.check(mL,V,P)(U)}function V(U){return e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),G}function G(U){return U===null||Ue(U)?O(U):(e.enter("htmlFlowData"),W(U))}function z(U){return U===45?(e.consume(U),M):W(U)}function X(U){return U===47?(e.consume(U),u="",ne):W(U)}function ne(U){if(U===62){const J=u.toLowerCase();return pb.includes(J)?(e.consume(U),$):W(U)}return Cn(U)&&u.length<8?(e.consume(U),u+=String.fromCharCode(U),ne):W(U)}function F(U){return U===93?(e.consume(U),M):W(U)}function M(U){return U===62?(e.consume(U),$):U===45&&a===2?(e.consume(U),M):W(U)}function $(U){return U===null||Ue(U)?(e.exit("htmlFlowData"),P(U)):(e.consume(U),$)}function P(U){return e.exit("htmlFlow"),t(U)}}function xL(e,t,n){const s=this;return a;function a(u){return Ue(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l):n(u)}function l(u){return s.parser.lazy[s.now().line]?n(u):t(u)}}function _L(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(bl,t,n)}}const yL={name:"htmlText",tokenize:vL};function vL(e,t,n){const s=this;let a,l,u;return c;function c(M){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(M),h}function h(M){return M===33?(e.consume(M),f):M===47?(e.consume(M),T):M===63?(e.consume(M),b):Cn(M)?(e.consume(M),A):n(M)}function f(M){return M===45?(e.consume(M),p):M===91?(e.consume(M),l=0,w):Cn(M)?(e.consume(M),v):n(M)}function p(M){return M===45?(e.consume(M),x):n(M)}function m(M){return M===null?n(M):M===45?(e.consume(M),_):Ue(M)?(u=m,X(M)):(e.consume(M),m)}function _(M){return M===45?(e.consume(M),x):m(M)}function x(M){return M===62?z(M):M===45?_(M):m(M)}function w(M){const $="CDATA[";return M===$.charCodeAt(l++)?(e.consume(M),l===$.length?k:w):n(M)}function k(M){return M===null?n(M):M===93?(e.consume(M),y):Ue(M)?(u=k,X(M)):(e.consume(M),k)}function y(M){return M===93?(e.consume(M),S):k(M)}function S(M){return M===62?z(M):M===93?(e.consume(M),S):k(M)}function v(M){return M===null||M===62?z(M):Ue(M)?(u=v,X(M)):(e.consume(M),v)}function b(M){return M===null?n(M):M===63?(e.consume(M),E):Ue(M)?(u=b,X(M)):(e.consume(M),b)}function E(M){return M===62?z(M):b(M)}function T(M){return Cn(M)?(e.consume(M),N):n(M)}function N(M){return M===45||vn(M)?(e.consume(M),N):L(M)}function L(M){return Ue(M)?(u=L,X(M)):it(M)?(e.consume(M),L):z(M)}function A(M){return M===45||vn(M)?(e.consume(M),A):M===47||M===62||jt(M)?D(M):n(M)}function D(M){return M===47?(e.consume(M),z):M===58||M===95||Cn(M)?(e.consume(M),B):Ue(M)?(u=D,X(M)):it(M)?(e.consume(M),D):z(M)}function B(M){return M===45||M===46||M===58||M===95||vn(M)?(e.consume(M),B):q(M)}function q(M){return M===61?(e.consume(M),W):Ue(M)?(u=q,X(M)):it(M)?(e.consume(M),q):D(M)}function W(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),a=M,O):Ue(M)?(u=W,X(M)):it(M)?(e.consume(M),W):(e.consume(M),V)}function O(M){return M===a?(e.consume(M),a=void 0,G):M===null?n(M):Ue(M)?(u=O,X(M)):(e.consume(M),O)}function V(M){return M===null||M===34||M===39||M===60||M===61||M===96?n(M):M===47||M===62||jt(M)?D(M):(e.consume(M),V)}function G(M){return M===47||M===62||jt(M)?D(M):n(M)}function z(M){return M===62?(e.consume(M),e.exit("htmlTextData"),e.exit("htmlText"),t):n(M)}function X(M){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),ne}function ne(M){return it(M)?ut(e,F,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):F(M)}function F(M){return e.enter("htmlTextData"),u(M)}}const Ep={name:"labelEnd",resolveAll:CL,resolveTo:kL,tokenize:EL},bL={tokenize:jL},SL={tokenize:NL},wL={tokenize:TL};function CL(e){let t=-1;const n=[];for(;++t<e.length;){const s=e[t][1];if(n.push(e[t]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const a=s.type==="labelImage"?4:2;s.type="data",t+=a}}return e.length!==n.length&&Wn(e,0,e.length,n),e}function kL(e,t){let n=e.length,s=0,a,l,u,c;for(;n--;)if(a=e[n][1],l){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(u){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(l=n,a.type!=="labelLink")){s=2;break}}else a.type==="labelEnd"&&(u=n);const h={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[l][1].start},end:{...e[u][1].end}},p={type:"labelText",start:{...e[l+s+2][1].end},end:{...e[u-2][1].start}};return c=[["enter",h,t],["enter",f,t]],c=ir(c,e.slice(l+1,l+s+3)),c=ir(c,[["enter",p,t]]),c=ir(c,Gu(t.parser.constructs.insideSpan.null,e.slice(l+s+4,u-3),t)),c=ir(c,[["exit",p,t],e[u-2],e[u-1],["exit",f,t]]),c=ir(c,e.slice(u+1)),c=ir(c,[["exit",h,t]]),Wn(e,l,e.length,c),e}function EL(e,t,n){const s=this;let a=s.events.length,l,u;for(;a--;)if((s.events[a][1].type==="labelImage"||s.events[a][1].type==="labelLink")&&!s.events[a][1]._balanced){l=s.events[a][1];break}return c;function c(_){return l?l._inactive?m(_):(u=s.parser.defined.includes(vr(s.sliceSerialize({start:l.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(_),e.exit("labelMarker"),e.exit("labelEnd"),h):n(_)}function h(_){return _===40?e.attempt(bL,p,u?p:m)(_):_===91?e.attempt(SL,p,u?f:m)(_):u?p(_):m(_)}function f(_){return e.attempt(wL,p,m)(_)}function p(_){return t(_)}function m(_){return l._balanced=!0,n(_)}}function jL(e,t,n){return s;function s(m){return e.enter("resource"),e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),a}function a(m){return jt(m)?tl(e,l)(m):l(m)}function l(m){return m===41?p(m):m1(e,u,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function u(m){return jt(m)?tl(e,h)(m):p(m)}function c(m){return n(m)}function h(m){return m===34||m===39||m===40?g1(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):p(m)}function f(m){return jt(m)?tl(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 NL(e,t,n){const s=this;return a;function a(c){return p1.call(s,e,l,u,"reference","referenceMarker","referenceString")(c)}function l(c){return s.parser.defined.includes(vr(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function u(c){return n(c)}}function TL(e,t,n){return s;function s(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),a}function a(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const AL={name:"labelStartImage",resolveAll:Ep.resolveAll,tokenize:LL};function LL(e,t,n){const s=this;return a;function a(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),l}function l(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),u):n(c)}function u(c){return c===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(c):t(c)}}const DL={name:"labelStartLink",resolveAll:Ep.resolveAll,tokenize:RL};function RL(e,t,n){const s=this;return a;function a(u){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelLink"),l}function l(u){return u===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(u):t(u)}}const Hf={name:"lineEnding",tokenize:OL};function OL(e,t){return n;function n(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),ut(e,t,"linePrefix")}}const au={name:"thematicBreak",tokenize:ML};function ML(e,t,n){let s=0,a;return l;function l(f){return e.enter("thematicBreak"),u(f)}function u(f){return a=f,c(f)}function c(f){return f===a?(e.enter("thematicBreakSequence"),h(f)):s>=3&&(f===null||Ue(f))?(e.exit("thematicBreak"),t(f)):n(f)}function h(f){return f===a?(e.consume(f),s++,h):(e.exit("thematicBreakSequence"),it(f)?ut(e,c,"whitespace")(f):c(f))}}const Dn={continuation:{tokenize:zL},exit:$L,name:"list",tokenize:BL},IL={partial:!0,tokenize:UL},PL={partial:!0,tokenize:HL};function BL(e,t,n){const s=this,a=s.events[s.events.length-1];let l=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,u=0;return c;function c(x){const w=s.containerState.type||(x===42||x===43||x===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!s.containerState.marker||x===s.containerState.marker:Tm(x)){if(s.containerState.type||(s.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),x===42||x===45?e.check(au,n,f)(x):f(x);if(!s.interrupt||x===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(x)}return n(x)}function h(x){return Tm(x)&&++u<10?(e.consume(x),h):(!s.interrupt||u<2)&&(s.containerState.marker?x===s.containerState.marker:x===41||x===46)?(e.exit("listItemValue"),f(x)):n(x)}function f(x){return e.enter("listItemMarker"),e.consume(x),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||x,e.check(bl,s.interrupt?n:p,e.attempt(IL,_,m))}function p(x){return s.containerState.initialBlankLine=!0,l++,_(x)}function m(x){return it(x)?(e.enter("listItemPrefixWhitespace"),e.consume(x),e.exit("listItemPrefixWhitespace"),_):n(x)}function _(x){return s.containerState.size=l+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(x)}}function zL(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(bl,a,l);function a(c){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,ut(e,t,"listItemIndent",s.containerState.size+1)(c)}function l(c){return s.containerState.furtherBlankLines||!it(c)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,u(c)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(PL,t,u)(c))}function u(c){return s.containerState._closeFlow=!0,s.interrupt=void 0,ut(e,e.attempt(Dn,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function HL(e,t,n){const s=this;return ut(e,a,"listItemIndent",s.containerState.size+1);function a(l){const u=s.events[s.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===s.containerState.size?t(l):n(l)}}function $L(e){e.exit(this.containerState.type)}function UL(e,t,n){const s=this;return ut(e,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(l){const u=s.events[s.events.length-1];return!it(l)&&u&&u[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const gb={name:"setextUnderline",resolveTo:FL,tokenize:VL};function FL(e,t){let n=e.length,s,a,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const u={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",l?(e.splice(a,0,["enter",u,t]),e.splice(l+1,0,["exit",e[s][1],t]),e[s][1].end={...e[l][1].end}):e[s][1]=u,e.push(["exit",u,t]),e}function VL(e,t,n){const s=this;let a;return l;function l(f){let p=s.events.length,m;for(;p--;)if(s.events[p][1].type!=="lineEnding"&&s.events[p][1].type!=="linePrefix"&&s.events[p][1].type!=="content"){m=s.events[p][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||m)?(e.enter("setextHeadingLine"),a=f,u(f)):n(f)}function u(f){return e.enter("setextHeadingLineSequence"),c(f)}function c(f){return f===a?(e.consume(f),c):(e.exit("setextHeadingLineSequence"),it(f)?ut(e,h,"lineSuffix")(f):h(f))}function h(f){return f===null||Ue(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const GL={tokenize:WL};function WL(e){const t=this,n=e.attempt(bl,s,e.attempt(this.parser.constructs.flowInitial,a,ut(e,e.attempt(this.parser.constructs.flow,a,e.attempt(QA,a)),"linePrefix")));return n;function s(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const qL={resolveAll:_1()},KL=x1("string"),YL=x1("text");function x1(e){return{resolveAll:_1(e==="text"?XL:void 0),tokenize:t};function t(n){const s=this,a=this.parser.constructs[e],l=n.attempt(a,u,c);return u;function u(p){return f(p)?l(p):c(p)}function c(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),h}function h(p){return f(p)?(n.exit("data"),l(p)):(n.consume(p),h)}function f(p){if(p===null)return!0;const m=a[p];let _=-1;if(m)for(;++_<m.length;){const x=m[_];if(!x.previous||x.previous.call(s,s.previous))return!0}return!1}}}function _1(e){return t;function t(n,s){let a=-1,l;for(;++a<=n.length;)l===void 0?n[a]&&n[a][1].type==="data"&&(l=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==l+2&&(n[l][1].end=n[a-1][1].end,n.splice(l+2,a-l-2),a=l+2),l=void 0);return e?e(n,s):n}}function XL(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 s=e[n-1][1],a=t.sliceStream(s);let l=a.length,u=-1,c=0,h;for(;l--;){const f=a[l];if(typeof f=="string"){for(u=f.length;f.charCodeAt(u-1)===32;)c++,u--;if(u)break;u=-1}else if(f===-2)h=!0,c++;else if(f!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const f={type:n===e.length||h||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?u:s.start._bufferIndex+u,_index:s.start._index+l,line:s.end.line,column:s.end.column-c,offset:s.end.offset-c},end:{...s.end}};s.end={...f.start},s.start.offset===s.end.offset?Object.assign(s,f):(e.splice(n,0,["enter",f,t],["exit",f,t]),n+=2)}n++}return e}const QL={42:Dn,43:Dn,45:Dn,48:Dn,49:Dn,50:Dn,51:Dn,52:Dn,53:Dn,54:Dn,55:Dn,56:Dn,57:Dn,62:u1},JL={91:nL},ZL={[-2]:zf,[-1]:zf,32:zf},eD={35:lL,42:au,45:[gb,au],60:hL,61:gb,95:au,96:mb,126:mb},tD={38:h1,92:d1},nD={[-5]:Hf,[-4]:Hf,[-3]:Hf,33:AL,38:h1,42:Am,60:[DA,yL],91:DL,92:[aL,d1],93:Ep,95:Am,96:GA},rD={null:[Am,qL]},sD={null:[42,95]},iD={null:[]},aD=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:sD,contentInitial:JL,disable:iD,document:QL,flow:eD,flowInitial:ZL,insideSpan:rD,string:tD,text:nD},Symbol.toStringTag,{value:"Module"}));function oD(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},l=[];let u=[],c=[];const h={attempt:L(T),check:L(N),consume:v,enter:b,exit:E,interrupt:L(N,{interrupt:!0})},f={code:null,containerState:{},defineSkip:k,events:[],now:w,parser:e,previous:null,sliceSerialize:_,sliceStream:x,write:m};let p=t.tokenize.call(f,h);return t.resolveAll&&l.push(t),f;function m(q){return u=ir(u,q),y(),u[u.length-1]!==null?[]:(A(t,0),f.events=Gu(l,f.events,f),f.events)}function _(q,W){return cD(x(q),W)}function x(q){return lD(u,q)}function w(){const{_bufferIndex:q,_index:W,line:O,column:V,offset:G}=s;return{_bufferIndex:q,_index:W,line:O,column:V,offset:G}}function k(q){a[q.line]=q.column,B()}function y(){let q;for(;s._index<u.length;){const W=u[s._index];if(typeof W=="string")for(q=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===q&&s._bufferIndex<W.length;)S(W.charCodeAt(s._bufferIndex));else S(W)}}function S(q){p=p(q)}function v(q){Ue(q)?(s.line++,s.column=1,s.offset+=q===-3?2:1,B()):q!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===u[s._index].length&&(s._bufferIndex=-1,s._index++)),f.previous=q}function b(q,W){const O=W||{};return O.type=q,O.start=w(),f.events.push(["enter",O,f]),c.push(O),O}function E(q){const W=c.pop();return W.end=w(),f.events.push(["exit",W,f]),W}function T(q,W){A(q,W.from)}function N(q,W){W.restore()}function L(q,W){return O;function O(V,G,z){let X,ne,F,M;return Array.isArray(V)?P(V):"tokenize"in V?P([V]):$(V);function $(se){return Y;function Y(H){const ee=H!==null&&se[H],te=H!==null&&se.null,ce=[...Array.isArray(ee)?ee:ee?[ee]:[],...Array.isArray(te)?te:te?[te]:[]];return P(ce)(H)}}function P(se){return X=se,ne=0,se.length===0?z:U(se[ne])}function U(se){return Y;function Y(H){return M=D(),F=se,se.partial||(f.currentConstruct=se),se.name&&f.parser.constructs.disable.null.includes(se.name)?Q():se.tokenize.call(W?Object.assign(Object.create(f),W):f,h,J,Q)(H)}}function J(se){return q(F,M),G}function Q(se){return M.restore(),++ne<X.length?U(X[ne]):z}}}function A(q,W){q.resolveAll&&!l.includes(q)&&l.push(q),q.resolve&&Wn(f.events,W,f.events.length-W,q.resolve(f.events.slice(W),f)),q.resolveTo&&(f.events=q.resolveTo(f.events,f))}function D(){const q=w(),W=f.previous,O=f.currentConstruct,V=f.events.length,G=Array.from(c);return{from:V,restore:z};function z(){s=q,f.previous=W,f.currentConstruct=O,f.events.length=V,c=G,B()}}function B(){s.line in a&&s.column<2&&(s.column=a[s.line],s.offset+=a[s.line]-1)}}function lD(e,t){const n=t.start._index,s=t.start._bufferIndex,a=t.end._index,l=t.end._bufferIndex;let u;if(n===a)u=[e[n].slice(s,l)];else{if(u=e.slice(n,a),s>-1){const c=u[0];typeof c=="string"?u[0]=c.slice(s):u.shift()}l>0&&u.push(e[a].slice(0,l))}return u}function cD(e,t){let n=-1;const s=[];let a;for(;++n<e.length;){const l=e[n];let u;if(typeof l=="string")u=l;else switch(l){case-5:{u="\r";break}case-4:{u=`
|
|
96
|
+
`;break}case-3:{u=`\r
|
|
97
|
+
`;break}case-2:{u=t?" ":" ";break}case-1:{if(!t&&a)continue;u=" ";break}default:u=String.fromCharCode(l)}a=l===-2,s.push(u)}return s.join("")}function uD(e){const s={constructs:l1([aD,...(e||{}).extensions||[]]),content:a(kA),defined:[],document:a(jA),flow:a(GL),lazy:{},string:a(KL),text:a(YL)};return s;function a(l){return u;function u(c){return oD(s,l,c)}}}function dD(e){for(;!f1(e););return e}const xb=/[\0\t\n\r]/g;function hD(){let e=1,t="",n=!0,s;return a;function a(l,u,c){const h=[];let f,p,m,_,x;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(u||void 0).decode(l)),m=0,t="",n&&(l.charCodeAt(0)===65279&&m++,n=void 0);m<l.length;){if(xb.lastIndex=m,f=xb.exec(l),_=f&&f.index!==void 0?f.index:l.length,x=l.charCodeAt(_),!f){t=l.slice(m);break}if(x===10&&m===_&&s)h.push(-3),s=void 0;else switch(s&&(h.push(-5),s=void 0),m<_&&(h.push(l.slice(m,_)),e+=_-m),x){case 0:{h.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,h.push(-2);e++<p;)h.push(-1);break}case 10:{h.push(-4),e=1;break}default:s=!0,e=1}m=_+1}return c&&(s&&h.push(-5),t&&h.push(t),h.push(null)),h}}const fD=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function mD(e){return e.replace(fD,pD)}function pD(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),l=a===120||a===88;return c1(n.slice(l?2:1),l?16:10)}return kp(n)||e}const y1={}.hasOwnProperty;function gD(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),xD(n)(dD(uD(n).document().write(hD()(e,t,!0))))}function xD(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Se),autolinkProtocol:D,autolinkEmail:D,atxHeading:l(Le),blockQuote:l(te),characterEscape:D,characterReference:D,codeFenced:l(ce),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:l(ce,u),codeText:l(he,u),codeTextData:D,data:D,codeFlowValue:D,definition:l(Te),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:l(Ae),hardBreakEscape:l(Pe),hardBreakTrailing:l(Pe),htmlFlow:l(de,u),htmlFlowData:D,htmlText:l(de,u),htmlTextData:D,image:l(Ie),label:u,link:l(Se),listItem:l(je),listItemValue:_,listOrdered:l(me,m),listUnordered:l(me),paragraph:l(nt),reference:U,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:l(Le),strong:l(Mt),thematicBreak:l(Zt)},exit:{atxHeading:h(),atxHeadingSequence:T,autolink:h(),autolinkEmail:ee,autolinkProtocol:H,blockQuote:h(),characterEscapeValue:B,characterReferenceMarkerHexadecimal:Q,characterReferenceMarkerNumeric:Q,characterReferenceValue:se,characterReference:Y,codeFenced:h(y),codeFencedFence:k,codeFencedFenceInfo:x,codeFencedFenceMeta:w,codeFlowValue:B,codeIndented:h(S),codeText:h(G),codeTextData:B,data:B,definition:h(),definitionDestinationString:E,definitionLabelString:v,definitionTitleString:b,emphasis:h(),hardBreakEscape:h(W),hardBreakTrailing:h(W),htmlFlow:h(O),htmlFlowData:B,htmlText:h(V),htmlTextData:B,image:h(X),label:F,labelText:ne,lineEnding:q,link:h(z),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:J,resourceDestinationString:M,resourceTitleString:$,resource:P,setextHeading:h(A),setextHeadingLineSequence:L,setextHeadingText:N,strong:h(),thematicBreak:h()}};v1(t,(e||{}).mdastExtensions||[]);const n={};return s;function s(ge){let Ce={type:"root",children:[]};const Oe={stack:[Ce],tokenStack:[],config:t,enter:c,exit:f,buffer:u,resume:p,data:n},Ve=[];let Ge=-1;for(;++Ge<ge.length;)if(ge[Ge][1].type==="listOrdered"||ge[Ge][1].type==="listUnordered")if(ge[Ge][0]==="enter")Ve.push(Ge);else{const vt=Ve.pop();Ge=a(ge,vt,Ge)}for(Ge=-1;++Ge<ge.length;){const vt=t[ge[Ge][0]];y1.call(vt,ge[Ge][1].type)&&vt[ge[Ge][1].type].call(Object.assign({sliceSerialize:ge[Ge][2].sliceSerialize},Oe),ge[Ge][1])}if(Oe.tokenStack.length>0){const vt=Oe.tokenStack[Oe.tokenStack.length-1];(vt[1]||_b).call(Oe,void 0,vt[0])}for(Ce.position={start:Is(ge.length>0?ge[0][1].start:{line:1,column:1,offset:0}),end:Is(ge.length>0?ge[ge.length-2][1].end:{line:1,column:1,offset:0})},Ge=-1;++Ge<t.transforms.length;)Ce=t.transforms[Ge](Ce)||Ce;return Ce}function a(ge,Ce,Oe){let Ve=Ce-1,Ge=-1,vt=!1,Xe,bt,ct,en;for(;++Ve<=Oe;){const He=ge[Ve];switch(He[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{He[0]==="enter"?Ge++:Ge--,en=void 0;break}case"lineEndingBlank":{He[0]==="enter"&&(Xe&&!en&&!Ge&&!ct&&(ct=Ve),en=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:en=void 0}if(!Ge&&He[0]==="enter"&&He[1].type==="listItemPrefix"||Ge===-1&&He[0]==="exit"&&(He[1].type==="listUnordered"||He[1].type==="listOrdered")){if(Xe){let ur=Ve;for(bt=void 0;ur--;){const Mn=ge[ur];if(Mn[1].type==="lineEnding"||Mn[1].type==="lineEndingBlank"){if(Mn[0]==="exit")continue;bt&&(ge[bt][1].type="lineEndingBlank",vt=!0),Mn[1].type="lineEnding",bt=ur}else if(!(Mn[1].type==="linePrefix"||Mn[1].type==="blockQuotePrefix"||Mn[1].type==="blockQuotePrefixWhitespace"||Mn[1].type==="blockQuoteMarker"||Mn[1].type==="listItemIndent"))break}ct&&(!bt||ct<bt)&&(Xe._spread=!0),Xe.end=Object.assign({},bt?ge[bt][1].start:He[1].end),ge.splice(bt||Ve,0,["exit",Xe,He[2]]),Ve++,Oe++}if(He[1].type==="listItemPrefix"){const ur={type:"listItem",_spread:!1,start:Object.assign({},He[1].start),end:void 0};Xe=ur,ge.splice(Ve,0,["enter",ur,He[2]]),Ve++,Oe++,ct=void 0,en=!0}}}return ge[Ce][1]._spread=vt,Oe}function l(ge,Ce){return Oe;function Oe(Ve){c.call(this,ge(Ve),Ve),Ce&&Ce.call(this,Ve)}}function u(){this.stack.push({type:"fragment",children:[]})}function c(ge,Ce,Oe){this.stack[this.stack.length-1].children.push(ge),this.stack.push(ge),this.tokenStack.push([Ce,Oe||void 0]),ge.position={start:Is(Ce.start),end:void 0}}function h(ge){return Ce;function Ce(Oe){ge&&ge.call(this,Oe),f.call(this,Oe)}}function f(ge,Ce){const Oe=this.stack.pop(),Ve=this.tokenStack.pop();if(Ve)Ve[0].type!==ge.type&&(Ce?Ce.call(this,ge,Ve[0]):(Ve[1]||_b).call(this,ge,Ve[0]));else throw new Error("Cannot close `"+ge.type+"` ("+el({start:ge.start,end:ge.end})+"): it’s not open");Oe.position.end=Is(ge.end)}function p(){return Cp(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function _(ge){if(this.data.expectingFirstListItemValue){const Ce=this.stack[this.stack.length-2];Ce.start=Number.parseInt(this.sliceSerialize(ge),10),this.data.expectingFirstListItemValue=void 0}}function x(){const ge=this.resume(),Ce=this.stack[this.stack.length-1];Ce.lang=ge}function w(){const ge=this.resume(),Ce=this.stack[this.stack.length-1];Ce.meta=ge}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function y(){const ge=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=ge.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const ge=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=ge.replace(/(\r?\n|\r)$/g,"")}function v(ge){const Ce=this.resume(),Oe=this.stack[this.stack.length-1];Oe.label=Ce,Oe.identifier=vr(this.sliceSerialize(ge)).toLowerCase()}function b(){const ge=this.resume(),Ce=this.stack[this.stack.length-1];Ce.title=ge}function E(){const ge=this.resume(),Ce=this.stack[this.stack.length-1];Ce.url=ge}function T(ge){const Ce=this.stack[this.stack.length-1];if(!Ce.depth){const Oe=this.sliceSerialize(ge).length;Ce.depth=Oe}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function L(ge){const Ce=this.stack[this.stack.length-1];Ce.depth=this.sliceSerialize(ge).codePointAt(0)===61?1:2}function A(){this.data.setextHeadingSlurpLineEnding=void 0}function D(ge){const Oe=this.stack[this.stack.length-1].children;let Ve=Oe[Oe.length-1];(!Ve||Ve.type!=="text")&&(Ve=gt(),Ve.position={start:Is(ge.start),end:void 0},Oe.push(Ve)),this.stack.push(Ve)}function B(ge){const Ce=this.stack.pop();Ce.value+=this.sliceSerialize(ge),Ce.position.end=Is(ge.end)}function q(ge){const Ce=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Oe=Ce.children[Ce.children.length-1];Oe.position.end=Is(ge.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Ce.type)&&(D.call(this,ge),B.call(this,ge))}function W(){this.data.atHardBreak=!0}function O(){const ge=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=ge}function V(){const ge=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=ge}function G(){const ge=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=ge}function z(){const ge=this.stack[this.stack.length-1];if(this.data.inReference){const Ce=this.data.referenceType||"shortcut";ge.type+="Reference",ge.referenceType=Ce,delete ge.url,delete ge.title}else delete ge.identifier,delete ge.label;this.data.referenceType=void 0}function X(){const ge=this.stack[this.stack.length-1];if(this.data.inReference){const Ce=this.data.referenceType||"shortcut";ge.type+="Reference",ge.referenceType=Ce,delete ge.url,delete ge.title}else delete ge.identifier,delete ge.label;this.data.referenceType=void 0}function ne(ge){const Ce=this.sliceSerialize(ge),Oe=this.stack[this.stack.length-2];Oe.label=mD(Ce),Oe.identifier=vr(Ce).toLowerCase()}function F(){const ge=this.stack[this.stack.length-1],Ce=this.resume(),Oe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Oe.type==="link"){const Ve=ge.children;Oe.children=Ve}else Oe.alt=Ce}function M(){const ge=this.resume(),Ce=this.stack[this.stack.length-1];Ce.url=ge}function $(){const ge=this.resume(),Ce=this.stack[this.stack.length-1];Ce.title=ge}function P(){this.data.inReference=void 0}function U(){this.data.referenceType="collapsed"}function J(ge){const Ce=this.resume(),Oe=this.stack[this.stack.length-1];Oe.label=Ce,Oe.identifier=vr(this.sliceSerialize(ge)).toLowerCase(),this.data.referenceType="full"}function Q(ge){this.data.characterReferenceType=ge.type}function se(ge){const Ce=this.sliceSerialize(ge),Oe=this.data.characterReferenceType;let Ve;Oe?(Ve=c1(Ce,Oe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ve=kp(Ce);const Ge=this.stack[this.stack.length-1];Ge.value+=Ve}function Y(ge){const Ce=this.stack.pop();Ce.position.end=Is(ge.end)}function H(ge){B.call(this,ge);const Ce=this.stack[this.stack.length-1];Ce.url=this.sliceSerialize(ge)}function ee(ge){B.call(this,ge);const Ce=this.stack[this.stack.length-1];Ce.url="mailto:"+this.sliceSerialize(ge)}function te(){return{type:"blockquote",children:[]}}function ce(){return{type:"code",lang:null,meta:null,value:""}}function he(){return{type:"inlineCode",value:""}}function Te(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ae(){return{type:"emphasis",children:[]}}function Le(){return{type:"heading",depth:0,children:[]}}function Pe(){return{type:"break"}}function de(){return{type:"html",value:""}}function Ie(){return{type:"image",title:null,url:"",alt:null}}function Se(){return{type:"link",title:null,url:"",children:[]}}function me(ge){return{type:"list",ordered:ge.type==="listOrdered",start:null,spread:ge._spread,children:[]}}function je(ge){return{type:"listItem",spread:ge._spread,checked:null,children:[]}}function nt(){return{type:"paragraph",children:[]}}function Mt(){return{type:"strong",children:[]}}function gt(){return{type:"text",value:""}}function Zt(){return{type:"thematicBreak"}}}function Is(e){return{line:e.line,column:e.column,offset:e.offset}}function v1(e,t){let n=-1;for(;++n<t.length;){const s=t[n];Array.isArray(s)?v1(e,s):_D(e,s)}}function _D(e,t){let n;for(n in t)if(y1.call(t,n))switch(n){case"canContainEols":{const s=t[n];s&&e[n].push(...s);break}case"transforms":{const s=t[n];s&&e[n].push(...s);break}case"enter":case"exit":{const s=t[n];s&&Object.assign(e[n],s);break}}}function _b(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+el({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+el({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+el({start:t.start,end:t.end})+") is still open")}function yD(e){const t=this;t.parser=n;function n(s){return gD(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function vD(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 bD(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
98
|
+
`}]}function SD(e,t){const n=t.value?t.value+`
|
|
99
|
+
`:"",s={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(s.className=["language-"+a[0]]);let l={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return t.meta&&(l.data={meta:t.meta}),e.patch(t,l),l=e.applyData(t,l),l={type:"element",tagName:"pre",properties:{},children:[l]},e.patch(t,l),l}function wD(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function CD(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function kD(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=Fa(s.toLowerCase()),l=e.footnoteOrder.indexOf(s);let u,c=e.footnoteCounts.get(s);c===void 0?(c=0,e.footnoteOrder.push(s),u=e.footnoteOrder.length):u=l+1,c+=1,e.footnoteCounts.set(s,c);const h={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,h);const f={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(t,f),e.applyData(t,f)}function ED(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 jD(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function b1(e,t){const n=t.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const a=e.all(t),l=a[0];l&&l.type==="text"?l.value="["+l.value:a.unshift({type:"text",value:"["});const u=a[a.length-1];return u&&u.type==="text"?u.value+=s:a.push({type:"text",value:s}),a}function ND(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return b1(e,t);const a={src:Fa(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(a.title=s.title);const l={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,l),e.applyData(t,l)}function TD(e,t){const n={src:Fa(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 s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)}function AD(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)}function LD(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return b1(e,t);const a={href:Fa(s.url||"")};s.title!==null&&s.title!==void 0&&(a.title=s.title);const l={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function DD(e,t){const n={href:Fa(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function RD(e,t,n){const s=e.all(t),a=n?OD(n):S1(t),l={},u=[];if(typeof t.checked=="boolean"){const p=s[0];let m;p&&p.type==="element"&&p.tagName==="p"?m=p:(m={type:"element",tagName:"p",properties:{},children:[]},s.unshift(m)),m.children.length>0&&m.children.unshift({type:"text",value:" "}),m.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),l.className=["task-list-item"]}let c=-1;for(;++c<s.length;){const p=s[c];(a||c!==0||p.type!=="element"||p.tagName!=="p")&&u.push({type:"text",value:`
|
|
100
|
+
`}),p.type==="element"&&p.tagName==="p"&&!a?u.push(...p.children):u.push(p)}const h=s[s.length-1];h&&(a||h.type!=="element"||h.tagName!=="p")&&u.push({type:"text",value:`
|
|
101
|
+
`});const f={type:"element",tagName:"li",properties:l,children:u};return e.patch(t,f),e.applyData(t,f)}function OD(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let s=-1;for(;!t&&++s<n.length;)t=S1(n[s])}return t}function S1(e){const t=e.spread;return t??e.children.length>1}function MD(e,t){const n={},s=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a<s.length;){const u=s[a];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const l={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(s,!0)};return e.patch(t,l),e.applyData(t,l)}function ID(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PD(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function BD(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function zD(e,t){const n=e.all(t),s=n.shift(),a=[];if(s){const u={type:"element",tagName:"thead",properties:{},children:e.wrap([s],!0)};e.patch(t.children[0],u),a.push(u)}if(n.length>0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=vp(t.children[1]),h=t1(t.children[t.children.length-1]);c&&h&&(u.position={start:c,end:h}),a.push(u)}const l={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,l),e.applyData(t,l)}function HD(e,t,n){const s=n?n.children:void 0,l=(s?s.indexOf(t):1)===0?"th":"td",u=n&&n.type==="table"?n.align:void 0,c=u?u.length:t.children.length;let h=-1;const f=[];for(;++h<c;){const m=t.children[h],_={},x=u?u[h]:void 0;x&&(_.align=x);let w={type:"element",tagName:l,properties:_,children:[]};m&&(w.children=e.all(m),e.patch(m,w),w=e.applyData(m,w)),f.push(w)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(t,p),e.applyData(t,p)}function $D(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const yb=9,vb=32;function UD(e){const t=String(e),n=/\r?\n|\r/g;let s=n.exec(t),a=0;const l=[];for(;s;)l.push(bb(t.slice(a,s.index),a>0,!0),s[0]),a=s.index+s[0].length,s=n.exec(t);return l.push(bb(t.slice(a),a>0,!1)),l.join("")}function bb(e,t,n){let s=0,a=e.length;if(t){let l=e.codePointAt(s);for(;l===yb||l===vb;)s++,l=e.codePointAt(s)}if(n){let l=e.codePointAt(a-1);for(;l===yb||l===vb;)a--,l=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function FD(e,t){const n={type:"text",value:UD(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function VD(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const GD={blockquote:vD,break:bD,code:SD,delete:wD,emphasis:CD,footnoteReference:kD,heading:ED,html:jD,imageReference:ND,image:TD,inlineCode:AD,linkReference:LD,link:DD,listItem:RD,list:MD,paragraph:ID,root:PD,strong:BD,table:zD,tableCell:$D,tableRow:HD,text:FD,thematicBreak:VD,toml:Wc,yaml:Wc,definition:Wc,footnoteDefinition:Wc};function Wc(){}const w1=-1,Wu=0,nl=1,gu=2,jp=3,Np=4,Tp=5,Ap=6,C1=7,k1=8,Sb=typeof self=="object"?self:globalThis,WD=(e,t)=>{const n=(a,l)=>(e.set(l,a),a),s=a=>{if(e.has(a))return e.get(a);const[l,u]=t[a];switch(l){case Wu:case w1:return n(u,a);case nl:{const c=n([],a);for(const h of u)c.push(s(h));return c}case gu:{const c=n({},a);for(const[h,f]of u)c[s(h)]=s(f);return c}case jp:return n(new Date(u),a);case Np:{const{source:c,flags:h}=u;return n(new RegExp(c,h),a)}case Tp:{const c=n(new Map,a);for(const[h,f]of u)c.set(s(h),s(f));return c}case Ap:{const c=n(new Set,a);for(const h of u)c.add(s(h));return c}case C1:{const{name:c,message:h}=u;return n(new Sb[c](h),a)}case k1:return n(BigInt(u),a);case"BigInt":return n(Object(BigInt(u)),a);case"ArrayBuffer":return n(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:c}=new Uint8Array(u);return n(new DataView(c),u)}}return n(new Sb[l](u),a)};return s},wb=e=>WD(new Map,e)(0),Ca="",{toString:qD}={},{keys:KD}=Object,Wo=e=>{const t=typeof e;if(t!=="object"||!e)return[Wu,t];const n=qD.call(e).slice(8,-1);switch(n){case"Array":return[nl,Ca];case"Object":return[gu,Ca];case"Date":return[jp,Ca];case"RegExp":return[Np,Ca];case"Map":return[Tp,Ca];case"Set":return[Ap,Ca];case"DataView":return[nl,n]}return n.includes("Array")?[nl,n]:n.includes("Error")?[C1,n]:[gu,n]},qc=([e,t])=>e===Wu&&(t==="function"||t==="symbol"),YD=(e,t,n,s)=>{const a=(u,c)=>{const h=s.push(u)-1;return n.set(c,h),h},l=u=>{if(n.has(u))return n.get(u);let[c,h]=Wo(u);switch(c){case Wu:{let p=u;switch(h){case"bigint":c=k1,p=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);p=null;break;case"undefined":return a([w1],u)}return a([c,p],u)}case nl:{if(h){let _=u;return h==="DataView"?_=new Uint8Array(u.buffer):h==="ArrayBuffer"&&(_=new Uint8Array(u)),a([h,[..._]],u)}const p=[],m=a([c,p],u);for(const _ of u)p.push(l(_));return m}case gu:{if(h)switch(h){case"BigInt":return a([h,u.toString()],u);case"Boolean":case"Number":case"String":return a([h,u.valueOf()],u)}if(t&&"toJSON"in u)return l(u.toJSON());const p=[],m=a([c,p],u);for(const _ of KD(u))(e||!qc(Wo(u[_])))&&p.push([l(_),l(u[_])]);return m}case jp:return a([c,u.toISOString()],u);case Np:{const{source:p,flags:m}=u;return a([c,{source:p,flags:m}],u)}case Tp:{const p=[],m=a([c,p],u);for(const[_,x]of u)(e||!(qc(Wo(_))||qc(Wo(x))))&&p.push([l(_),l(x)]);return m}case Ap:{const p=[],m=a([c,p],u);for(const _ of u)(e||!qc(Wo(_)))&&p.push(l(_));return m}}const{message:f}=u;return a([c,{name:h,message:f}],u)};return l},Cb=(e,{json:t,lossy:n}={})=>{const s=[];return YD(!(t||n),!!t,new Map,s)(e),s},xu=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?wb(Cb(e,t)):structuredClone(e):(e,t)=>wb(Cb(e,t));function XD(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 QD(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function JD(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||XD,s=e.options.footnoteBackLabel||QD,a=e.options.footnoteLabel||"Footnotes",l=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let h=-1;for(;++h<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[h]);if(!f)continue;const p=e.all(f),m=String(f.identifier).toUpperCase(),_=Fa(m.toLowerCase());let x=0;const w=[],k=e.footnoteCounts.get(m);for(;k!==void 0&&++x<=k;){w.length>0&&w.push({type:"text",value:" "});let v=typeof n=="string"?n:n(h,x);typeof v=="string"&&(v={type:"text",value:v}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+_+(x>1?"-"+x:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(h,x),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}const y=p[p.length-1];if(y&&y.type==="element"&&y.tagName==="p"){const v=y.children[y.children.length-1];v&&v.type==="text"?v.value+=" ":y.children.push({type:"text",value:" "}),y.children.push(...w)}else p.push(...w);const S={type:"element",tagName:"li",properties:{id:t+"fn-"+_},children:e.wrap(p,!0)};e.patch(f,S),c.push(S)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:l,properties:{...xu(u),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
|
|
102
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:`
|
|
103
|
+
`}]}}const qu=(function(e){if(e==null)return nR;if(typeof e=="function")return Ku(e);if(typeof e=="object")return Array.isArray(e)?ZD(e):eR(e);if(typeof e=="string")return tR(e);throw new Error("Expected function, string, or object as test")});function ZD(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=qu(e[n]);return Ku(s);function s(...a){let l=-1;for(;++l<t.length;)if(t[l].apply(this,a))return!0;return!1}}function eR(e){const t=e;return Ku(n);function n(s){const a=s;let l;for(l in e)if(a[l]!==t[l])return!1;return!0}}function tR(e){return Ku(t);function t(n){return n&&n.type===e}}function Ku(e){return t;function t(n,s,a){return!!(rR(n)&&e.call(this,n,typeof s=="number"?s:void 0,a||void 0))}}function nR(){return!0}function rR(e){return e!==null&&typeof e=="object"&&"type"in e}const E1=[],sR=!0,Lm=!1,iR="skip";function j1(e,t,n,s){let a;typeof t=="function"&&typeof n!="function"?(s=n,n=t):a=t;const l=qu(a),u=s?-1:1;c(e,void 0,[])();function c(h,f,p){const m=h&&typeof h=="object"?h:{};if(typeof m.type=="string"){const x=typeof m.tagName=="string"?m.tagName:typeof m.name=="string"?m.name:void 0;Object.defineProperty(_,"name",{value:"node ("+(h.type+(x?"<"+x+">":""))+")"})}return _;function _(){let x=E1,w,k,y;if((!t||l(h,f,p[p.length-1]||void 0))&&(x=aR(n(h,p)),x[0]===Lm))return x;if("children"in h&&h.children){const S=h;if(S.children&&x[0]!==iR)for(k=(s?S.children.length:-1)+u,y=p.concat(S);k>-1&&k<S.children.length;){const v=S.children[k];if(w=c(v,k,y)(),w[0]===Lm)return w;k=typeof w[1]=="number"?w[1]:k+u}}return x}}}function aR(e){return Array.isArray(e)?e:typeof e=="number"?[sR,e]:e==null?E1:[e]}function Lp(e,t,n,s){let a,l,u;typeof t=="function"&&typeof n!="function"?(l=void 0,u=t,a=n):(l=t,u=n,a=s),j1(e,l,c,a);function c(h,f){const p=f[f.length-1],m=p?p.children.indexOf(h):void 0;return u(h,m,p)}}const Dm={}.hasOwnProperty,oR={};function lR(e,t){const n=t||oR,s=new Map,a=new Map,l=new Map,u={...GD,...n.handlers},c={all:f,applyData:uR,definitionById:s,footnoteById:a,footnoteCounts:l,footnoteOrder:[],handlers:u,one:h,options:n,patch:cR,wrap:hR};return Lp(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const m=p.type==="definition"?s:a,_=String(p.identifier).toUpperCase();m.has(_)||m.set(_,p)}}),c;function h(p,m){const _=p.type,x=c.handlers[_];if(Dm.call(c.handlers,_)&&x)return x(c,p,m);if(c.options.passThrough&&c.options.passThrough.includes(_)){if("children"in p){const{children:k,...y}=p,S=xu(y);return S.children=c.all(p),S}return xu(p)}return(c.options.unknownHandler||dR)(c,p,m)}function f(p){const m=[];if("children"in p){const _=p.children;let x=-1;for(;++x<_.length;){const w=c.one(_[x],p);if(w){if(x&&_[x-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=kb(w.value)),!Array.isArray(w)&&w.type==="element")){const k=w.children[0];k&&k.type==="text"&&(k.value=kb(k.value))}Array.isArray(w)?m.push(...w):m.push(w)}}}return m}}function cR(e,t){e.position&&(t.position=QT(e))}function uR(e,t){let n=t;if(e&&e.data){const s=e.data.hName,a=e.data.hChildren,l=e.data.hProperties;if(typeof s=="string")if(n.type==="element")n.tagName=s;else{const u="children"in n?n.children:[n];n={type:"element",tagName:s,properties:{},children:u}}n.type==="element"&&l&&Object.assign(n.properties,xu(l)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function dR(e,t){const n=t.data||{},s="value"in t&&!(Dm.call(n,"hProperties")||Dm.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function hR(e,t){const n=[];let s=-1;for(t&&n.push({type:"text",value:`
|
|
104
|
+
`});++s<e.length;)s&&n.push({type:"text",value:`
|
|
105
|
+
`}),n.push(e[s]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
106
|
+
`}),n}function kb(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Eb(e,t){const n=lR(e,t),s=n.one(e,void 0),a=JD(n),l=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&l.children.push({type:"text",value:`
|
|
107
|
+
`},a),l}function fR(e,t){return e&&"run"in e?async function(n,s){const a=Eb(n,{file:s,...t});await e.run(a,s)}:function(n,s){return Eb(n,{file:s,...e||t})}}function jb(e){if(e)throw e}var $f,Nb;function mR(){if(Nb)return $f;Nb=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},l=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var p=e.call(f,"constructor"),m=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!p&&!m)return!1;var _;for(_ in f);return typeof _>"u"||e.call(f,_)},u=function(f,p){n&&p.name==="__proto__"?n(f,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):f[p.name]=p.newValue},c=function(f,p){if(p==="__proto__")if(e.call(f,p)){if(s)return s(f,p).value}else return;return f[p]};return $f=function h(){var f,p,m,_,x,w,k=arguments[0],y=1,S=arguments.length,v=!1;for(typeof k=="boolean"&&(v=k,k=arguments[1]||{},y=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});y<S;++y)if(f=arguments[y],f!=null)for(p in f)m=c(k,p),_=c(f,p),k!==_&&(v&&_&&(l(_)||(x=a(_)))?(x?(x=!1,w=m&&a(m)?m:[]):w=m&&l(m)?m:{},u(k,{name:p,newValue:h(v,w,_)})):typeof _<"u"&&u(k,{name:p,newValue:_}));return k},$f}var pR=mR();const Uf=Du(pR);function Rm(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 gR(){const e=[],t={run:n,use:s};return t;function n(...a){let l=-1;const u=a.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);c(null,...a);function c(h,...f){const p=e[++l];let m=-1;if(h){u(h);return}for(;++m<a.length;)(f[m]===null||f[m]===void 0)&&(f[m]=a[m]);a=f,p?xR(p,c)(...f):u(null,...f)}}function s(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function xR(e,t){let n;return s;function s(...u){const c=e.length>u.length;let h;c&&u.push(a);try{h=e.apply(this,u)}catch(f){const p=f;if(c&&n)throw p;return a(p)}c||(h&&h.then&&typeof h.then=="function"?h.then(l,a):h instanceof Error?a(h):l(h))}function a(u,...c){n||(n=!0,t(u,...c))}function l(u){a(null,u)}}const Dr={basename:_R,dirname:yR,extname:vR,join:bR,sep:"/"};function _R(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Sl(e);let n=0,s=-1,a=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else s<0&&(l=!0,s=a+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let u=-1,c=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else u<0&&(l=!0,u=a+1),c>-1&&(e.codePointAt(a)===t.codePointAt(c--)?c<0&&(s=a):(c=-1,s=u));return n===s?s=u:s<0&&(s=e.length),e.slice(n,s)}function yR(e){if(Sl(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function vR(e){Sl(e);let t=e.length,n=-1,s=0,a=-1,l=0,u;for(;t--;){const c=e.codePointAt(t);if(c===47){if(u){s=t+1;break}continue}n<0&&(u=!0,n=t+1),c===46?a<0?a=t:l!==1&&(l=1):a>-1&&(l=-1)}return a<0||n<0||l===0||l===1&&a===n-1&&a===s+1?"":e.slice(a,n)}function bR(...e){let t=-1,n;for(;++t<e.length;)Sl(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":SR(n)}function SR(e){Sl(e);const t=e.codePointAt(0)===47;let n=wR(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function wR(e,t){let n="",s=0,a=-1,l=0,u=-1,c,h;for(;++u<=e.length;){if(u<e.length)c=e.codePointAt(u);else{if(c===47)break;c=47}if(c===47){if(!(a===u-1||l===1))if(a!==u-1&&l===2){if(n.length<2||s!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(h=n.lastIndexOf("/"),h!==n.length-1){h<0?(n="",s=0):(n=n.slice(0,h),s=n.length-1-n.lastIndexOf("/")),a=u,l=0;continue}}else if(n.length>0){n="",s=0,a=u,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(a+1,u):n=e.slice(a+1,u),s=u-a-1;a=u,l=0}else c===46&&l>-1?l++:l=-1}return n}function Sl(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const CR={cwd:kR};function kR(){return"/"}function Om(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function ER(e){if(typeof e=="string")e=new URL(e);else if(!Om(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 jR(e)}function jR(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const s=t.codePointAt(n+2);if(s===70||s===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 Ff=["history","path","basename","stem","extname","dirname"];class N1{constructor(t){let n;t?Om(t)?n={path:t}:typeof t=="string"||NR(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":CR.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<Ff.length;){const l=Ff[s];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let a;for(a in n)Ff.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Dr.basename(this.path):void 0}set basename(t){Gf(t,"basename"),Vf(t,"basename"),this.path=Dr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Dr.dirname(this.path):void 0}set dirname(t){Tb(this.basename,"dirname"),this.path=Dr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Dr.extname(this.path):void 0}set extname(t){if(Vf(t,"extname"),Tb(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=Dr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Om(t)&&(t=ER(t)),Gf(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Dr.basename(this.path,this.extname):void 0}set stem(t){Gf(t,"stem"),Vf(t,"stem"),this.path=Dr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,s){const a=this.message(t,n,s);throw a.fatal=!0,a}info(t,n,s){const a=this.message(t,n,s);return a.fatal=void 0,a}message(t,n,s){const a=new bn(t,n,s);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 Vf(e,t){if(e&&e.includes(Dr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Dr.sep+"`")}function Gf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Tb(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function NR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const TR=(function(e){const s=this.constructor.prototype,a=s[e],l=function(){return a.apply(l,arguments)};return Object.setPrototypeOf(l,s),l}),AR={}.hasOwnProperty;class Dp extends TR{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=gR()}copy(){const t=new Dp;let n=-1;for(;++n<this.attachers.length;){const s=this.attachers[n];t.use(...s)}return t.data(Uf(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Kf("data",this.frozen),this.namespace[t]=n,this):AR.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Kf("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,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const a=n.call(t,...s);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Kc(t),s=this.parser||this.Parser;return Wf("parse",s),s(String(n),n)}process(t,n){const s=this;return this.freeze(),Wf("process",this.parser||this.Parser),qf("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(l,u){const c=Kc(t),h=s.parse(c);s.run(h,c,function(p,m,_){if(p||!m||!_)return f(p);const x=m,w=s.stringify(x,_);RR(w)?_.value=w:_.result=w,f(p,_)});function f(p,m){p||!m?u(p):l?l(m):n(void 0,m)}}}processSync(t){let n=!1,s;return this.freeze(),Wf("processSync",this.parser||this.Parser),qf("processSync",this.compiler||this.Compiler),this.process(t,a),Lb("processSync","process",n),s;function a(l,u){n=!0,jb(l),s=u}}run(t,n,s){Ab(t),this.freeze();const a=this.transformers;return!s&&typeof n=="function"&&(s=n,n=void 0),s?l(void 0,s):new Promise(l);function l(u,c){const h=Kc(n);a.run(t,h,f);function f(p,m,_){const x=m||t;p?c(p):u?u(x):s(void 0,x,_)}}}runSync(t,n){let s=!1,a;return this.run(t,n,l),Lb("runSync","run",s),a;function l(u,c){jb(u),a=c,s=!0}}stringify(t,n){this.freeze();const s=Kc(n),a=this.compiler||this.Compiler;return qf("stringify",a),Ab(t),a(t,s)}use(t,...n){const s=this.attachers,a=this.namespace;if(Kf("use",this.frozen),t!=null)if(typeof t=="function")h(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):u(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(f){if(typeof f=="function")h(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[p,...m]=f;h(p,m)}else u(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function u(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(f.plugins),f.settings&&(a.settings=Uf(!0,a.settings,f.settings))}function c(f){let p=-1;if(f!=null)if(Array.isArray(f))for(;++p<f.length;){const m=f[p];l(m)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function h(f,p){let m=-1,_=-1;for(;++m<s.length;)if(s[m][0]===f){_=m;break}if(_===-1)s.push([f,...p]);else if(p.length>0){let[x,...w]=p;const k=s[_][1];Rm(k)&&Rm(x)&&(x=Uf(!0,k,x)),s[_]=[f,x,...w]}}}}const LR=new Dp().freeze();function Wf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function qf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Kf(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 Ab(e){if(!Rm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Lb(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Kc(e){return DR(e)?e:new N1(e)}function DR(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function RR(e){return typeof e=="string"||OR(e)}function OR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const MR="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Db=[],Rb={allowDangerousHtml:!0},IR=/^(https?|ircs?|mailto|xmpp)$/i,PR=[{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 BR(e){const t=zR(e),n=HR(e);return $R(t.runSync(t.parse(n),n),e)}function zR(e){const t=e.rehypePlugins||Db,n=e.remarkPlugins||Db,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Rb}:Rb;return LR().use(yD).use(n).use(fR,s).use(t)}function HR(e){const t=e.children||"",n=new N1;return typeof t=="string"&&(n.value=t),n}function $R(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,l=t.disallowedElements,u=t.skipHtml,c=t.unwrapDisallowed,h=t.urlTransform||UR;for(const p of PR)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+MR+p.id,void 0);return Lp(e,f),nA(e,{Fragment:o.Fragment,components:a,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function f(p,m,_){if(p.type==="raw"&&_&&typeof m=="number")return u?_.children.splice(m,1):_.children[m]={type:"text",value:p.value},m;if(p.type==="element"){let x;for(x in Bf)if(Object.hasOwn(Bf,x)&&Object.hasOwn(p.properties,x)){const w=p.properties[x],k=Bf[x];(k===null||k.includes(p.tagName))&&(p.properties[x]=h(String(w||""),x,p))}}if(p.type==="element"){let x=n?!n.includes(p.tagName):l?l.includes(p.tagName):!1;if(!x&&s&&typeof m=="number"&&(x=!s(p,m,_)),x&&_&&typeof m=="number")return c&&p.children?_.children.splice(m,1,...p.children):_.children.splice(m,1),m}}}function UR(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||s!==-1&&t>s||IR.test(e.slice(0,t))?e:""}function Ob(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let s=0,a=n.indexOf(t);for(;a!==-1;)s++,a=n.indexOf(t,a+t.length);return s}function FR(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function VR(e,t,n){const a=qu((n||{}).ignore||[]),l=GR(t);let u=-1;for(;++u<l.length;)j1(e,"text",c);function c(f,p){let m=-1,_;for(;++m<p.length;){const x=p[m],w=_?_.children:void 0;if(a(x,w?w.indexOf(x):void 0,_))return;_=x}if(_)return h(f,p)}function h(f,p){const m=p[p.length-1],_=l[u][0],x=l[u][1];let w=0;const y=m.children.indexOf(f);let S=!1,v=[];_.lastIndex=0;let b=_.exec(f.value);for(;b;){const E=b.index,T={index:b.index,input:b.input,stack:[...p,f]};let N=x(...b,T);if(typeof N=="string"&&(N=N.length>0?{type:"text",value:N}:void 0),N===!1?_.lastIndex=E+1:(w!==E&&v.push({type:"text",value:f.value.slice(w,E)}),Array.isArray(N)?v.push(...N):N&&v.push(N),w=E+b[0].length,S=!0),!_.global)break;b=_.exec(f.value)}return S?(w<f.value.length&&v.push({type:"text",value:f.value.slice(w)}),m.children.splice(y,1,...v)):v=[f],y+v.length}}function GR(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 s=-1;for(;++s<n.length;){const a=n[s];t.push([WR(a[0]),qR(a[1])])}return t}function WR(e){return typeof e=="string"?new RegExp(FR(e),"g"):e}function qR(e){return typeof e=="function"?e:function(){return e}}const Yf="phrasing",Xf=["autolink","link","image","label"];function KR(){return{transforms:[t3],enter:{literalAutolink:XR,literalAutolinkEmail:Qf,literalAutolinkHttp:Qf,literalAutolinkWww:Qf},exit:{literalAutolink:e3,literalAutolinkEmail:ZR,literalAutolinkHttp:QR,literalAutolinkWww:JR}}}function YR(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Yf,notInConstruct:Xf},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Yf,notInConstruct:Xf},{character:":",before:"[ps]",after:"\\/",inConstruct:Yf,notInConstruct:Xf}]}}function XR(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Qf(e){this.config.enter.autolinkProtocol.call(this,e)}function QR(e){this.config.exit.autolinkProtocol.call(this,e)}function JR(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 ZR(e){this.config.exit.autolinkEmail.call(this,e)}function e3(e){this.exit(e)}function t3(e){VR(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,n3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),r3]],{ignore:["link","linkReference"]})}function n3(e,t,n,s,a){let l="";if(!T1(a)||(/^w/i.test(t)&&(n=t+n,t="",l="http://"),!s3(n)))return!1;const u=i3(n+s);if(!u[0])return!1;const c={type:"link",title:null,url:l+t+u[0],children:[{type:"text",value:t+u[0]}]};return u[1]?[c,{type:"text",value:u[1]}]:c}function r3(e,t,n,s){return!T1(s,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function s3(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 i3(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],s=n.indexOf(")");const a=Ob(e,"(");let l=Ob(e,")");for(;s!==-1&&a>l;)e+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),l++;return[e,n]}function T1(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Ti(n)||Vu(n))&&(!t||n!==47)}A1.peek=m3;function a3(){this.buffer()}function o3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function l3(){this.buffer()}function c3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function u3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=vr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function d3(e){this.exit(e)}function h3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=vr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function f3(e){this.exit(e)}function m3(){return"["}function A1(e,t,n,s){const a=n.createTracker(s);let l=a.move("[^");const u=n.enter("footnoteReference"),c=n.enter("reference");return l+=a.move(n.safe(n.associationId(e),{after:"]",before:l})),c(),u(),l+=a.move("]"),l}function p3(){return{enter:{gfmFootnoteCallString:a3,gfmFootnoteCall:o3,gfmFootnoteDefinitionLabelString:l3,gfmFootnoteDefinition:c3},exit:{gfmFootnoteCallString:u3,gfmFootnoteCall:d3,gfmFootnoteDefinitionLabelString:h3,gfmFootnoteDefinition:f3}}}function g3(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:A1},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,a,l,u){const c=l.createTracker(u);let h=c.move("[^");const f=l.enter("footnoteDefinition"),p=l.enter("label");return h+=c.move(l.safe(l.associationId(s),{before:h,after:"]"})),p(),h+=c.move("]:"),s.children&&s.children.length>0&&(c.shift(4),h+=c.move((t?`
|
|
108
|
+
`:" ")+l.indentLines(l.containerFlow(s,c.current()),t?L1:x3))),f(),h}}function x3(e,t,n){return t===0?e:L1(e,t,n)}function L1(e,t,n){return(n?"":" ")+e}const _3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];D1.peek=w3;function y3(){return{canContainEols:["delete"],enter:{strikethrough:b3},exit:{strikethrough:S3}}}function v3(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:_3}],handlers:{delete:D1}}}function b3(e){this.enter({type:"delete",children:[]},e)}function S3(e){this.exit(e)}function D1(e,t,n,s){const a=n.createTracker(s),l=n.enter("strikethrough");let u=a.move("~~");return u+=n.containerPhrasing(e,{...a.current(),before:u,after:"~"}),u+=a.move("~~"),l(),u}function w3(){return"~"}function C3(e){return e.length}function k3(e,t){const n=t||{},s=(n.align||[]).concat(),a=n.stringLength||C3,l=[],u=[],c=[],h=[];let f=0,p=-1;for(;++p<e.length;){const k=[],y=[];let S=-1;for(e[p].length>f&&(f=e[p].length);++S<e[p].length;){const v=E3(e[p][S]);if(n.alignDelimiters!==!1){const b=a(v);y[S]=b,(h[S]===void 0||b>h[S])&&(h[S]=b)}k.push(v)}u[p]=k,c[p]=y}let m=-1;if(typeof s=="object"&&"length"in s)for(;++m<f;)l[m]=Mb(s[m]);else{const k=Mb(s);for(;++m<f;)l[m]=k}m=-1;const _=[],x=[];for(;++m<f;){const k=l[m];let y="",S="";k===99?(y=":",S=":"):k===108?y=":":k===114&&(S=":");let v=n.alignDelimiters===!1?1:Math.max(1,h[m]-y.length-S.length);const b=y+"-".repeat(v)+S;n.alignDelimiters!==!1&&(v=y.length+v+S.length,v>h[m]&&(h[m]=v),x[m]=v),_[m]=b}u.splice(1,0,_),c.splice(1,0,x),p=-1;const w=[];for(;++p<u.length;){const k=u[p],y=c[p];m=-1;const S=[];for(;++m<f;){const v=k[m]||"";let b="",E="";if(n.alignDelimiters!==!1){const T=h[m]-(y[m]||0),N=l[m];N===114?b=" ".repeat(T):N===99?T%2?(b=" ".repeat(T/2+.5),E=" ".repeat(T/2-.5)):(b=" ".repeat(T/2),E=b):E=" ".repeat(T)}n.delimiterStart!==!1&&!m&&S.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&v==="")&&(n.delimiterStart!==!1||m)&&S.push(" "),n.alignDelimiters!==!1&&S.push(b),S.push(v),n.alignDelimiters!==!1&&S.push(E),n.padding!==!1&&S.push(" "),(n.delimiterEnd!==!1||m!==f-1)&&S.push("|")}w.push(n.delimiterEnd===!1?S.join("").replace(/ +$/,""):S.join(""))}return w.join(`
|
|
109
|
+
`)}function E3(e){return e==null?"":String(e)}function Mb(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 j3(e,t,n,s){const a=n.enter("blockquote"),l=n.createTracker(s);l.move("> "),l.shift(2);const u=n.indentLines(n.containerFlow(e,l.current()),N3);return a(),u}function N3(e,t,n){return">"+(n?"":" ")+e}function T3(e,t){return Ib(e,t.inConstruct,!0)&&!Ib(e,t.notInConstruct,!1)}function Ib(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let s=-1;for(;++s<t.length;)if(e.includes(t[s]))return!0;return!1}function Pb(e,t,n,s){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
|
|
110
|
+
`&&T3(n.stack,n.unsafe[a]))return/[ \t]/.test(s.before)?"":" ";return`\\
|
|
111
|
+
`}function A3(e,t){const n=String(e);let s=n.indexOf(t),a=s,l=0,u=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;s!==-1;)s===a?++l>u&&(u=l):l=1,a=s+t.length,s=n.indexOf(t,a);return u}function L3(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 D3(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 R3(e,t,n,s){const a=D3(n),l=e.value||"",u=a==="`"?"GraveAccent":"Tilde";if(L3(e,n)){const m=n.enter("codeIndented"),_=n.indentLines(l,O3);return m(),_}const c=n.createTracker(s),h=a.repeat(Math.max(A3(l,a)+1,3)),f=n.enter("codeFenced");let p=c.move(h);if(e.lang){const m=n.enter(`codeFencedLang${u}`);p+=c.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...c.current()})),m()}if(e.lang&&e.meta){const m=n.enter(`codeFencedMeta${u}`);p+=c.move(" "),p+=c.move(n.safe(e.meta,{before:p,after:`
|
|
112
|
+
`,encode:["`"],...c.current()})),m()}return p+=c.move(`
|
|
113
|
+
`),l&&(p+=c.move(l+`
|
|
114
|
+
`)),p+=c.move(h),f(),p}function O3(e,t,n){return(n?"":" ")+e}function Rp(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 M3(e,t,n,s){const a=Rp(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("definition");let c=n.enter("label");const h=n.createTracker(s);let f=h.move("[");return f+=h.move(n.safe(n.associationId(e),{before:f,after:"]",...h.current()})),f+=h.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=h.move("<"),f+=h.move(n.safe(e.url,{before:f,after:">",...h.current()})),f+=h.move(">")):(c=n.enter("destinationRaw"),f+=h.move(n.safe(e.url,{before:f,after:e.title?" ":`
|
|
115
|
+
`,...h.current()}))),c(),e.title&&(c=n.enter(`title${l}`),f+=h.move(" "+a),f+=h.move(n.safe(e.title,{before:f,after:a,...h.current()})),f+=h.move(a),c()),u(),f}function I3(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 ol(e){return"&#x"+e.toString(16).toUpperCase()+";"}function _u(e,t,n){const s=Pa(e),a=Pa(t);return s===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===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}}R1.peek=P3;function R1(e,t,n,s){const a=I3(n),l=n.enter("emphasis"),u=n.createTracker(s),c=u.move(a);let h=u.move(n.containerPhrasing(e,{after:a,before:c,...u.current()}));const f=h.charCodeAt(0),p=_u(s.before.charCodeAt(s.before.length-1),f,a);p.inside&&(h=ol(f)+h.slice(1));const m=h.charCodeAt(h.length-1),_=_u(s.after.charCodeAt(0),m,a);_.inside&&(h=h.slice(0,-1)+ol(m));const x=u.move(a);return l(),n.attentionEncodeSurroundingInfo={after:_.outside,before:p.outside},c+h+x}function P3(e,t,n){return n.options.emphasis||"*"}function B3(e,t){let n=!1;return Lp(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,Lm}),!!((!e.depth||e.depth<3)&&Cp(e)&&(t.options.setext||n))}function z3(e,t,n,s){const a=Math.max(Math.min(6,e.depth||1),1),l=n.createTracker(s);if(B3(e,n)){const p=n.enter("headingSetext"),m=n.enter("phrasing"),_=n.containerPhrasing(e,{...l.current(),before:`
|
|
116
|
+
`,after:`
|
|
117
|
+
`});return m(),p(),_+`
|
|
118
|
+
`+(a===1?"=":"-").repeat(_.length-(Math.max(_.lastIndexOf("\r"),_.lastIndexOf(`
|
|
119
|
+
`))+1))}const u="#".repeat(a),c=n.enter("headingAtx"),h=n.enter("phrasing");l.move(u+" ");let f=n.containerPhrasing(e,{before:"# ",after:`
|
|
120
|
+
`,...l.current()});return/^[\t ]/.test(f)&&(f=ol(f.charCodeAt(0))+f.slice(1)),f=f?u+" "+f:u,n.options.closeAtx&&(f+=" "+u),h(),c(),f}O1.peek=H3;function O1(e){return e.value||""}function H3(){return"<"}M1.peek=$3;function M1(e,t,n,s){const a=Rp(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("image");let c=n.enter("label");const h=n.createTracker(s);let f=h.move("![");return f+=h.move(n.safe(e.alt,{before:f,after:"]",...h.current()})),f+=h.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=h.move("<"),f+=h.move(n.safe(e.url,{before:f,after:">",...h.current()})),f+=h.move(">")):(c=n.enter("destinationRaw"),f+=h.move(n.safe(e.url,{before:f,after:e.title?" ":")",...h.current()}))),c(),e.title&&(c=n.enter(`title${l}`),f+=h.move(" "+a),f+=h.move(n.safe(e.title,{before:f,after:a,...h.current()})),f+=h.move(a),c()),f+=h.move(")"),u(),f}function $3(){return"!"}I1.peek=U3;function I1(e,t,n,s){const a=e.referenceType,l=n.enter("imageReference");let u=n.enter("label");const c=n.createTracker(s);let h=c.move("![");const f=n.safe(e.alt,{before:h,after:"]",...c.current()});h+=c.move(f+"]["),u();const p=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:h,after:"]",...c.current()});return u(),n.stack=p,l(),a==="full"||!f||f!==m?h+=c.move(m+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function U3(){return"!"}P1.peek=F3;function P1(e,t,n){let s=e.value||"",a="`",l=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(s);)a+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++l<n.unsafe.length;){const u=n.unsafe[l],c=n.compilePattern(u);let h;if(u.atBreak)for(;h=c.exec(s);){let f=h.index;s.charCodeAt(f)===10&&s.charCodeAt(f-1)===13&&f--,s=s.slice(0,f)+" "+s.slice(h.index+1)}}return a+s+a}function F3(){return"`"}function B1(e,t){const n=Cp(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))}z1.peek=V3;function z1(e,t,n,s){const a=Rp(n),l=a==='"'?"Quote":"Apostrophe",u=n.createTracker(s);let c,h;if(B1(e,n)){const p=n.stack;n.stack=[],c=n.enter("autolink");let m=u.move("<");return m+=u.move(n.containerPhrasing(e,{before:m,after:">",...u.current()})),m+=u.move(">"),c(),n.stack=p,m}c=n.enter("link"),h=n.enter("label");let f=u.move("[");return f+=u.move(n.containerPhrasing(e,{before:f,after:"](",...u.current()})),f+=u.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=n.enter("destinationLiteral"),f+=u.move("<"),f+=u.move(n.safe(e.url,{before:f,after:">",...u.current()})),f+=u.move(">")):(h=n.enter("destinationRaw"),f+=u.move(n.safe(e.url,{before:f,after:e.title?" ":")",...u.current()}))),h(),e.title&&(h=n.enter(`title${l}`),f+=u.move(" "+a),f+=u.move(n.safe(e.title,{before:f,after:a,...u.current()})),f+=u.move(a),h()),f+=u.move(")"),c(),f}function V3(e,t,n){return B1(e,n)?"<":"["}H1.peek=G3;function H1(e,t,n,s){const a=e.referenceType,l=n.enter("linkReference");let u=n.enter("label");const c=n.createTracker(s);let h=c.move("[");const f=n.containerPhrasing(e,{before:h,after:"]",...c.current()});h+=c.move(f+"]["),u();const p=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:h,after:"]",...c.current()});return u(),n.stack=p,l(),a==="full"||!f||f!==m?h+=c.move(m+"]"):a==="shortcut"?h=h.slice(0,-1):h+=c.move("]"),h}function G3(){return"["}function Op(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 W3(e){const t=Op(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 q3(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 $1(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 K3(e,t,n,s){const a=n.enter("list"),l=n.bulletCurrent;let u=e.ordered?q3(n):Op(n);const c=e.ordered?u==="."?")":".":W3(n);let h=t&&n.bulletLastUsed?u===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(h=!0),$1(n)===u&&p){let m=-1;for(;++m<e.children.length;){const _=e.children[m];if(_&&_.type==="listItem"&&_.children&&_.children[0]&&_.children[0].type==="thematicBreak"){h=!0;break}}}}h&&(u=c),n.bulletCurrent=u;const f=n.containerFlow(e,s);return n.bulletLastUsed=u,n.bulletCurrent=l,a(),f}function Y3(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 X3(e,t,n,s){const a=Y3(n);let l=n.bulletCurrent||Op(n);t&&t.type==="list"&&t.ordered&&(l=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+l);let u=l.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const c=n.createTracker(s);c.move(l+" ".repeat(u-l.length)),c.shift(u);const h=n.enter("listItem"),f=n.indentLines(n.containerFlow(e,c.current()),p);return h(),f;function p(m,_,x){return _?(x?"":" ".repeat(u))+m:(x?l:l+" ".repeat(u-l.length))+m}}function Q3(e,t,n,s){const a=n.enter("paragraph"),l=n.enter("phrasing"),u=n.containerPhrasing(e,s);return l(),a(),u}const J3=qu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Z3(e,t,n,s){return(e.children.some(function(u){return J3(u)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function e5(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}U1.peek=t5;function U1(e,t,n,s){const a=e5(n),l=n.enter("strong"),u=n.createTracker(s),c=u.move(a+a);let h=u.move(n.containerPhrasing(e,{after:a,before:c,...u.current()}));const f=h.charCodeAt(0),p=_u(s.before.charCodeAt(s.before.length-1),f,a);p.inside&&(h=ol(f)+h.slice(1));const m=h.charCodeAt(h.length-1),_=_u(s.after.charCodeAt(0),m,a);_.inside&&(h=h.slice(0,-1)+ol(m));const x=u.move(a+a);return l(),n.attentionEncodeSurroundingInfo={after:_.outside,before:p.outside},c+h+x}function t5(e,t,n){return n.options.strong||"*"}function n5(e,t,n,s){return n.safe(e.value,s)}function r5(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 s5(e,t,n){const s=($1(n)+(n.options.ruleSpaces?" ":"")).repeat(r5(n));return n.options.ruleSpaces?s.slice(0,-1):s}const F1={blockquote:j3,break:Pb,code:R3,definition:M3,emphasis:R1,hardBreak:Pb,heading:z3,html:O1,image:M1,imageReference:I1,inlineCode:P1,link:z1,linkReference:H1,list:K3,listItem:X3,paragraph:Q3,root:Z3,strong:U1,text:n5,thematicBreak:s5};function i5(){return{enter:{table:a5,tableData:Bb,tableHeader:Bb,tableRow:l5},exit:{codeText:c5,table:o5,tableData:Jf,tableHeader:Jf,tableRow:Jf}}}function a5(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 o5(e){this.exit(e),this.data.inTable=void 0}function l5(e){this.enter({type:"tableRow",children:[]},e)}function Jf(e){this.exit(e)}function Bb(e){this.enter({type:"tableCell",children:[]},e)}function c5(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,u5));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function u5(e,t){return t==="|"?t:e}function d5(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,a=t.stringLength,l=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
121
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:_,table:u,tableCell:h,tableRow:c}};function u(x,w,k,y){return f(p(x,k,y),x.align)}function c(x,w,k,y){const S=m(x,k,y),v=f([S]);return v.slice(0,v.indexOf(`
|
|
122
|
+
`))}function h(x,w,k,y){const S=k.enter("tableCell"),v=k.enter("phrasing"),b=k.containerPhrasing(x,{...y,before:l,after:l});return v(),S(),b}function f(x,w){return k3(x,{align:w,alignDelimiters:s,padding:n,stringLength:a})}function p(x,w,k){const y=x.children;let S=-1;const v=[],b=w.enter("table");for(;++S<y.length;)v[S]=m(y[S],w,k);return b(),v}function m(x,w,k){const y=x.children;let S=-1;const v=[],b=w.enter("tableRow");for(;++S<y.length;)v[S]=h(y[S],x,w,k);return b(),v}function _(x,w,k){let y=F1.inlineCode(x,w,k);return k.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function h5(){return{exit:{taskListCheckValueChecked:zb,taskListCheckValueUnchecked:zb,paragraph:m5}}}function f5(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:p5}}}function zb(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function m5(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 s=n.children[0];if(s&&s.type==="text"){const a=t.children;let l=-1,u;for(;++l<a.length;){const c=a[l];if(c.type==="paragraph"){u=c;break}}u===n&&(s.value=s.value.slice(1),s.value.length===0?n.children.shift():n.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,n.position.start=Object.assign({},s.position.start)))}}this.exit(e)}function p5(e,t,n,s){const a=e.children[0],l=typeof e.checked=="boolean"&&a&&a.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",c=n.createTracker(s);l&&c.move(u);let h=F1.listItem(e,t,n,{...s,...c.current()});return l&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),h;function f(p){return p+u}}function g5(){return[KR(),p3(),y3(),i5(),h5()]}function x5(e){return{extensions:[YR(),g3(e),v3(),d5(e),f5()]}}const _5={tokenize:C5,partial:!0},V1={tokenize:k5,partial:!0},G1={tokenize:E5,partial:!0},W1={tokenize:j5,partial:!0},y5={tokenize:N5,partial:!0},q1={name:"wwwAutolink",tokenize:S5,previous:Y1},K1={name:"protocolAutolink",tokenize:w5,previous:X1},ds={name:"emailAutolink",tokenize:b5,previous:Q1},Ir={};function v5(){return{text:Ir}}let mi=48;for(;mi<123;)Ir[mi]=ds,mi++,mi===58?mi=65:mi===91&&(mi=97);Ir[43]=ds;Ir[45]=ds;Ir[46]=ds;Ir[95]=ds;Ir[72]=[ds,K1];Ir[104]=[ds,K1];Ir[87]=[ds,q1];Ir[119]=[ds,q1];function b5(e,t,n){const s=this;let a,l;return u;function u(m){return!Mm(m)||!Q1.call(s,s.previous)||Mp(s.events)?n(m):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(m))}function c(m){return Mm(m)?(e.consume(m),c):m===64?(e.consume(m),h):n(m)}function h(m){return m===46?e.check(y5,p,f)(m):m===45||m===95||vn(m)?(l=!0,e.consume(m),h):p(m)}function f(m){return e.consume(m),a=!0,h}function p(m){return l&&a&&Cn(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function S5(e,t,n){const s=this;return a;function a(u){return u!==87&&u!==119||!Y1.call(s,s.previous)||Mp(s.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(_5,e.attempt(V1,e.attempt(G1,l),n),n)(u))}function l(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function w5(e,t,n){const s=this;let a="",l=!1;return u;function u(m){return(m===72||m===104)&&X1.call(s,s.previous)&&!Mp(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),e.consume(m),c):n(m)}function c(m){if(Cn(m)&&a.length<5)return a+=String.fromCodePoint(m),e.consume(m),c;if(m===58){const _=a.toLowerCase();if(_==="http"||_==="https")return e.consume(m),h}return n(m)}function h(m){return m===47?(e.consume(m),l?f:(l=!0,h)):n(m)}function f(m){return m===null||pu(m)||jt(m)||Ti(m)||Vu(m)?n(m):e.attempt(V1,e.attempt(G1,p),n)(m)}function p(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function C5(e,t,n){let s=0;return a;function a(u){return(u===87||u===119)&&s<3?(s++,e.consume(u),a):u===46&&s===3?(e.consume(u),l):n(u)}function l(u){return u===null?n(u):t(u)}}function k5(e,t,n){let s,a,l;return u;function u(f){return f===46||f===95?e.check(W1,h,c)(f):f===null||jt(f)||Ti(f)||f!==45&&Vu(f)?h(f):(l=!0,e.consume(f),u)}function c(f){return f===95?s=!0:(a=s,s=void 0),e.consume(f),u}function h(f){return a||s||!l?n(f):t(f)}}function E5(e,t){let n=0,s=0;return a;function a(u){return u===40?(n++,e.consume(u),a):u===41&&s<n?l(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(W1,t,l)(u):u===null||jt(u)||Ti(u)?t(u):(e.consume(u),a)}function l(u){return u===41&&s++,e.consume(u),a}}function j5(e,t,n){return s;function s(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),s):c===38?(e.consume(c),l):c===93?(e.consume(c),a):c===60||c===null||jt(c)||Ti(c)?t(c):n(c)}function a(c){return c===null||c===40||c===91||jt(c)||Ti(c)?t(c):s(c)}function l(c){return Cn(c)?u(c):n(c)}function u(c){return c===59?(e.consume(c),s):Cn(c)?(e.consume(c),u):n(c)}}function N5(e,t,n){return s;function s(l){return e.consume(l),a}function a(l){return vn(l)?n(l):t(l)}}function Y1(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||jt(e)}function X1(e){return!Cn(e)}function Q1(e){return!(e===47||Mm(e))}function Mm(e){return e===43||e===45||e===46||e===95||vn(e)}function Mp(e){let t=e.length,n=!1;for(;t--;){const s=e[t][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){n=!0;break}if(s._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const T5={tokenize:P5,partial:!0};function A5(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:O5,continuation:{tokenize:M5},exit:I5}},text:{91:{name:"gfmFootnoteCall",tokenize:R5},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:L5,resolveTo:D5}}}}function L5(e,t,n){const s=this;let a=s.events.length;const l=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let u;for(;a--;){const h=s.events[a][1];if(h.type==="labelImage"){u=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return c;function c(h){if(!u||!u._balanced)return n(h);const f=vr(s.sliceSerialize({start:u.end,end:s.now()}));return f.codePointAt(0)!==94||!l.includes(f.slice(1))?n(h):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),t(h))}}function D5(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 s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const l={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},c=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",l,t],["enter",u,t],["exit",u,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...c),e}function R5(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let l=0,u;return c;function c(m){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),h}function h(m){return m!==94?n(m):(e.enter("gfmFootnoteCallMarker"),e.consume(m),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(m){if(l>999||m===93&&!u||m===null||m===91||jt(m))return n(m);if(m===93){e.exit("chunkString");const _=e.exit("gfmFootnoteCallString");return a.includes(vr(s.sliceSerialize(_)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return jt(m)||(u=!0),l++,e.consume(m),m===92?p:f}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,f):f(m)}}function O5(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let l,u=0,c;return h;function h(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(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(u>999||w===93&&!c||w===null||w===91||jt(w))return n(w);if(w===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return l=vr(s.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),_}return jt(w)||(c=!0),u++,e.consume(w),w===92?m:p}function m(w){return w===91||w===92||w===93?(e.consume(w),u++,p):p(w)}function _(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(l)||a.push(l),ut(e,x,"gfmFootnoteDefinitionWhitespace")):n(w)}function x(w){return t(w)}}function M5(e,t,n){return e.check(bl,t,e.attempt(T5,t,n))}function I5(e){e.exit("gfmFootnoteDefinition")}function P5(e,t,n){const s=this;return ut(e,a,"gfmFootnoteDefinitionIndent",5);function a(l){const u=s.events[s.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(l):n(l)}}function B5(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:l,resolveAll:a};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(u,c){let h=-1;for(;++h<u.length;)if(u[h][0]==="enter"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._close){let f=h;for(;f--;)if(u[f][0]==="exit"&&u[f][1].type==="strikethroughSequenceTemporary"&&u[f][1]._open&&u[h][1].end.offset-u[h][1].start.offset===u[f][1].end.offset-u[f][1].start.offset){u[h][1].type="strikethroughSequence",u[f][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},u[f][1].start),end:Object.assign({},u[h][1].end)},m={type:"strikethroughText",start:Object.assign({},u[f][1].end),end:Object.assign({},u[h][1].start)},_=[["enter",p,c],["enter",u[f][1],c],["exit",u[f][1],c],["enter",m,c]],x=c.parser.constructs.insideSpan.null;x&&Wn(_,_.length,0,Gu(x,u.slice(f+1,h),c)),Wn(_,_.length,0,[["exit",m,c],["enter",u[h][1],c],["exit",u[h][1],c],["exit",p,c]]),Wn(u,f-1,h-f+3,_),h=f+_.length-2;break}}for(h=-1;++h<u.length;)u[h][1].type==="strikethroughSequenceTemporary"&&(u[h][1].type="data");return u}function l(u,c,h){const f=this.previous,p=this.events;let m=0;return _;function _(w){return f===126&&p[p.length-1][1].type!=="characterEscape"?h(w):(u.enter("strikethroughSequenceTemporary"),x(w))}function x(w){const k=Pa(f);if(w===126)return m>1?h(w):(u.consume(w),m++,x);if(m<2&&!n)return h(w);const y=u.exit("strikethroughSequenceTemporary"),S=Pa(w);return y._open=!S||S===2&&!!k,y._close=!k||k===2&&!!S,c(w)}}}class z5{constructor(){this.map=[]}add(t,n,s){H5(this,t,n,s)}consume(t){if(this.map.sort(function(l,u){return l[0]-u[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];s.push(t.slice()),t.length=0;let a=s.pop();for(;a;){for(const l of a)t.push(l);a=s.pop()}this.map.length=0}}function H5(e,t,n,s){let a=0;if(!(n===0&&s.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...s);return}a+=1}e.map.push([t,n,s])}}function $5(e,t){let n=!1;const s=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&s.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const l=s.length-1;s[l]=s[l]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return s}function U5(){return{flow:{null:{name:"table",tokenize:F5,resolveAll:V5}}}}function F5(e,t,n){const s=this;let a=0,l=0,u;return c;function c(B){let q=s.events.length-1;for(;q>-1;){const V=s.events[q][1].type;if(V==="lineEnding"||V==="linePrefix")q--;else break}const W=q>-1?s.events[q][1].type:null,O=W==="tableHead"||W==="tableRow"?N:h;return O===N&&s.parser.lazy[s.now().line]?n(B):O(B)}function h(B){return e.enter("tableHead"),e.enter("tableRow"),f(B)}function f(B){return B===124||(u=!0,l+=1),p(B)}function p(B){return B===null?n(B):Ue(B)?l>1?(l=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),x):n(B):it(B)?ut(e,p,"whitespace")(B):(l+=1,u&&(u=!1,a+=1),B===124?(e.enter("tableCellDivider"),e.consume(B),e.exit("tableCellDivider"),u=!0,p):(e.enter("data"),m(B)))}function m(B){return B===null||B===124||jt(B)?(e.exit("data"),p(B)):(e.consume(B),B===92?_:m)}function _(B){return B===92||B===124?(e.consume(B),m):m(B)}function x(B){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(B):(e.enter("tableDelimiterRow"),u=!1,it(B)?ut(e,w,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):w(B))}function w(B){return B===45||B===58?y(B):B===124?(u=!0,e.enter("tableCellDivider"),e.consume(B),e.exit("tableCellDivider"),k):T(B)}function k(B){return it(B)?ut(e,y,"whitespace")(B):y(B)}function y(B){return B===58?(l+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(B),e.exit("tableDelimiterMarker"),S):B===45?(l+=1,S(B)):B===null||Ue(B)?E(B):T(B)}function S(B){return B===45?(e.enter("tableDelimiterFiller"),v(B)):T(B)}function v(B){return B===45?(e.consume(B),v):B===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(B),e.exit("tableDelimiterMarker"),b):(e.exit("tableDelimiterFiller"),b(B))}function b(B){return it(B)?ut(e,E,"whitespace")(B):E(B)}function E(B){return B===124?w(B):B===null||Ue(B)?!u||a!==l?T(B):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(B)):T(B)}function T(B){return n(B)}function N(B){return e.enter("tableRow"),L(B)}function L(B){return B===124?(e.enter("tableCellDivider"),e.consume(B),e.exit("tableCellDivider"),L):B===null||Ue(B)?(e.exit("tableRow"),t(B)):it(B)?ut(e,L,"whitespace")(B):(e.enter("data"),A(B))}function A(B){return B===null||B===124||jt(B)?(e.exit("data"),L(B)):(e.consume(B),B===92?D:A)}function D(B){return B===92||B===124?(e.consume(B),A):A(B)}}function V5(e,t){let n=-1,s=!0,a=0,l=[0,0,0,0],u=[0,0,0,0],c=!1,h=0,f,p,m;const _=new z5;for(;++n<e.length;){const x=e[n],w=x[1];x[0]==="enter"?w.type==="tableHead"?(c=!1,h!==0&&(Hb(_,t,h,f,p),p=void 0,h=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},_.add(n,0,[["enter",f,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(s=!0,m=void 0,l=[0,0,0,0],u=[0,n+1,0,0],c&&(c=!1,p={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},_.add(n,0,[["enter",p,t]])),a=w.type==="tableDelimiterRow"?2:p?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(s=!1,u[2]===0&&(l[1]!==0&&(u[0]=u[1],m=Yc(_,t,l,a,void 0,m),l=[0,0,0,0]),u[2]=n)):w.type==="tableCellDivider"&&(s?s=!1:(l[1]!==0&&(u[0]=u[1],m=Yc(_,t,l,a,void 0,m)),l=u,u=[l[1],n,0,0])):w.type==="tableHead"?(c=!0,h=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(h=n,l[1]!==0?(u[0]=u[1],m=Yc(_,t,l,a,n,m)):u[1]!==0&&(m=Yc(_,t,u,a,n,m)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(u[3]=n)}for(h!==0&&Hb(_,t,h,f,p),_.consume(t.events),n=-1;++n<t.events.length;){const x=t.events[n];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=$5(t.events,n))}return e}function Yc(e,t,n,s,a,l){const u=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(l.end=Object.assign({},La(t.events,n[0])),e.add(n[0],0,[["exit",l,t]]));const h=La(t.events,n[1]);if(l={type:u,start:Object.assign({},h),end:Object.assign({},h)},e.add(n[1],0,[["enter",l,t]]),n[2]!==0){const f=La(t.events,n[2]),p=La(t.events,n[3]),m={type:c,start:Object.assign({},f),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",m,t]]),s!==2){const _=t.events[n[2]],x=t.events[n[3]];if(_[1].end=Object.assign({},x[1].end),_[1].type="chunkText",_[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,k=n[3]-n[2]-1;e.add(w,k,[])}}e.add(n[3]+1,0,[["exit",m,t]])}return a!==void 0&&(l.end=Object.assign({},La(t.events,a)),e.add(a,0,[["exit",l,t]]),l=void 0),l}function Hb(e,t,n,s,a){const l=[],u=La(t.events,n);a&&(a.end=Object.assign({},u),l.push(["exit",a,t])),s.end=Object.assign({},u),l.push(["exit",s,t]),e.add(n+1,0,l)}function La(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const G5={name:"tasklistCheck",tokenize:q5};function W5(){return{text:{91:G5}}}function q5(e,t,n){const s=this;return a;function a(h){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(h):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),l)}function l(h){return jt(h)?(e.enter("taskListCheckValueUnchecked"),e.consume(h),e.exit("taskListCheckValueUnchecked"),u):h===88||h===120?(e.enter("taskListCheckValueChecked"),e.consume(h),e.exit("taskListCheckValueChecked"),u):n(h)}function u(h){return h===93?(e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(h)}function c(h){return Ue(h)?t(h):it(h)?e.check({tokenize:K5},t,n)(h):n(h)}}function K5(e,t,n){return ut(e,s,"whitespace");function s(a){return a===null?n(a):t(a)}}function Y5(e){return l1([v5(),A5(),B5(e),U5(),W5()])}const X5={};function Q5(e){const t=this,n=e||X5,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),l=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),u=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(Y5(n)),l.push(g5()),u.push(x5(n))}var Im=Object.defineProperty,J5=Object.getOwnPropertyDescriptor,Z5=Object.getOwnPropertyNames,eO=Object.prototype.hasOwnProperty,Ip=(e,t)=>{let n={};for(var s in e)Im(n,s,{get:e[s],enumerable:!0});return Im(n,Symbol.toStringTag,{value:"Module"}),n},tO=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=Z5(t),l=0,u=a.length,c;l<u;l++)c=a[l],!eO.call(e,c)&&c!==n&&Im(e,c,{get:(h=>t[h]).bind(null,c),enumerable:!(s=J5(t,c))||s.enumerable});return e},J1=(e,t,n)=>(tO(e,t,"default"),n);const Yu=[{id:"abap",name:"ABAP",import:(()=>Z(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>Z(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>Z(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>Z(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>Z(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>Z(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>Z(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>Z(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>Z(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>Z(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>Z(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>Z(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>Z(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>Z(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>Z(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>Z(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>Z(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>Z(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>Z(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>Z(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>Z(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>Z(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>Z(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>Z(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>Z(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>Z(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>Z(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>Z(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>Z(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>Z(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>Z(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>Z(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>Z(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>Z(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>Z(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>Z(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>Z(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>Z(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>Z(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>Z(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>Z(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>Z(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>Z(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>Z(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>Z(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>Z(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>Z(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>Z(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>Z(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>Z(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>Z(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>Z(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>Z(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>Z(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>Z(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>Z(()=>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:(()=>Z(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>Z(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>Z(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>Z(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>Z(()=>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:(()=>Z(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>Z(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>Z(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>Z(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>Z(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>Z(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>Z(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>Z(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>Z(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>Z(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>Z(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>Z(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>Z(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>Z(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>Z(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>Z(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>Z(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>Z(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>Z(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>Z(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>Z(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>Z(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>Z(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>Z(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>Z(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>Z(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>Z(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>Z(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>Z(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>Z(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>Z(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>Z(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>Z(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>Z(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>Z(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>Z(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>Z(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>Z(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>Z(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>Z(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>Z(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>Z(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>Z(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>Z(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>Z(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>Z(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>Z(()=>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:(()=>Z(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>Z(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>Z(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>Z(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>Z(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>Z(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>Z(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>Z(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>Z(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>Z(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>Z(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>Z(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>Z(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>Z(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>Z(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>Z(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>Z(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>Z(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>Z(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>Z(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>Z(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>Z(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>Z(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>Z(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>Z(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>Z(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>Z(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>Z(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>Z(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>Z(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>Z(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>Z(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>Z(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>Z(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>Z(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>Z(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>Z(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>Z(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>Z(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>Z(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>Z(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>Z(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>Z(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>Z(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>Z(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>Z(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>Z(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>Z(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>Z(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>Z(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>Z(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>Z(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>Z(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>Z(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>Z(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>Z(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>Z(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>Z(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>Z(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>Z(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>Z(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>Z(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>Z(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>Z(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>Z(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>Z(()=>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:(()=>Z(()=>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:(()=>Z(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>Z(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>Z(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>Z(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>Z(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>Z(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>Z(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>Z(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>Z(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>Z(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>Z(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>Z(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>Z(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>Z(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>Z(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>Z(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>Z(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>Z(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>Z(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>Z(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>Z(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>Z(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>Z(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>Z(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>Z(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>Z(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>Z(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>Z(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>Z(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>Z(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>Z(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>Z(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>Z(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>Z(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>Z(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>Z(()=>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:(()=>Z(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>Z(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>Z(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>Z(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>Z(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>Z(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>Z(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>Z(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>Z(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>Z(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>Z(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>Z(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>Z(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>Z(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>Z(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>Z(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>Z(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>Z(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>Z(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>Z(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>Z(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>Z(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>Z(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>Z(()=>import("./zig-VOosw3JB.js"),[]))}],Pp=Object.fromEntries(Yu.map(e=>[e.id,e.import])),Bp=Object.fromEntries(Yu.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),zp={...Pp,...Bp},Hp=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>Z(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>Z(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>Z(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>Z(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>Z(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>Z(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>Z(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>Z(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>Z(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>Z(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>Z(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>Z(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>Z(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>Z(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>Z(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>Z(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>Z(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>Z(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>Z(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>Z(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>Z(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>Z(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>Z(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>Z(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>Z(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>Z(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>Z(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>Z(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>Z(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>Z(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>Z(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>Z(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>Z(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>Z(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>Z(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>Z(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>Z(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>Z(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>Z(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>Z(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>Z(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>Z(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>Z(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>Z(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>Z(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>Z(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>Z(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>Z(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>Z(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>Z(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>Z(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>Z(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>Z(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>Z(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>Z(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>Z(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>Z(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>Z(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>Z(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>Z(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>Z(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>Z(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>Z(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>Z(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>Z(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],$p=Object.fromEntries(Hp.map(e=>[e.id,e.import]));var Up=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function nO(){return 2147483648}function rO(){return typeof performance<"u"?performance.now():Date.now()}const sO=(e,t)=>e+(t-e%t)%t;async function iO(e){let t,n;const s={};function a(x){n=x,s.HEAPU8=new Uint8Array(x),s.HEAPU32=new Uint32Array(x)}function l(x,w,k){s.HEAPU8.copyWithin(x,w,w+k)}function u(x){try{return t.grow(x-n.byteLength+65535>>>16),a(t.buffer),1}catch{}}function c(x){const w=s.HEAPU8.length;x=x>>>0;const k=nO();if(x>k)return!1;for(let y=1;y<=4;y*=2){let S=w*(1+.2/y);S=Math.min(S,x+100663296);const v=Math.min(k,sO(Math.max(x,S),65536));if(u(v))return!0}return!1}const h=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function f(x,w,k=1024){const y=w+k;let S=w;for(;x[S]&&!(S>=y);)++S;if(S-w>16&&x.buffer&&h)return h.decode(x.subarray(w,S));let v="";for(;w<S;){let b=x[w++];if(!(b&128)){v+=String.fromCharCode(b);continue}const E=x[w++]&63;if((b&224)===192){v+=String.fromCharCode((b&31)<<6|E);continue}const T=x[w++]&63;if((b&240)===224?b=(b&15)<<12|E<<6|T:b=(b&7)<<18|E<<12|T<<6|x[w++]&63,b<65536)v+=String.fromCharCode(b);else{const N=b-65536;v+=String.fromCharCode(55296|N>>10,56320|N&1023)}}return v}function p(x,w){return x?f(s.HEAPU8,x,w):""}const m={emscripten_get_now:rO,emscripten_memcpy_big:l,emscripten_resize_heap:c,fd_write:()=>0};async function _(){const w=await e({env:m,wasi_snapshot_preview1:m});t=w.memory,a(t.buffer),Object.assign(s,w),s.UTF8ToString=p}return await _(),s}var aO=Object.defineProperty,oO=(e,t,n)=>t in e?aO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rn=(e,t,n)=>oO(e,typeof t!="symbol"?t+"":t,n);let un=null;function lO(e){throw new Up(e.UTF8ToString(e.getLastOnigError()))}class Xu{constructor(t){rn(this,"utf16Length"),rn(this,"utf8Length"),rn(this,"utf16Value"),rn(this,"utf8Value"),rn(this,"utf16OffsetToUtf8"),rn(this,"utf8OffsetToUtf16");const n=t.length,s=Xu._utf8ByteLength(t),a=s!==n,l=a?new Uint32Array(n+1):null;a&&(l[n]=s);const u=a?new Uint32Array(s+1):null;a&&(u[s]=n);const c=new Uint8Array(s);let h=0;for(let f=0;f<n;f++){const p=t.charCodeAt(f);let m=p,_=!1;if(p>=55296&&p<=56319&&f+1<n){const x=t.charCodeAt(f+1);x>=56320&&x<=57343&&(m=(p-55296<<10)+65536|x-56320,_=!0)}a&&(l[f]=h,_&&(l[f+1]=h),m<=127?u[h+0]=f:m<=2047?(u[h+0]=f,u[h+1]=f):m<=65535?(u[h+0]=f,u[h+1]=f,u[h+2]=f):(u[h+0]=f,u[h+1]=f,u[h+2]=f,u[h+3]=f)),m<=127?c[h++]=m:m<=2047?(c[h++]=192|(m&1984)>>>6,c[h++]=128|(m&63)>>>0):m<=65535?(c[h++]=224|(m&61440)>>>12,c[h++]=128|(m&4032)>>>6,c[h++]=128|(m&63)>>>0):(c[h++]=240|(m&1835008)>>>18,c[h++]=128|(m&258048)>>>12,c[h++]=128|(m&4032)>>>6,c[h++]=128|(m&63)>>>0),_&&f++}this.utf16Length=n,this.utf8Length=s,this.utf16Value=t,this.utf8Value=c,this.utf16OffsetToUtf8=l,this.utf8OffsetToUtf16=u}static _utf8ByteLength(t){let n=0;for(let s=0,a=t.length;s<a;s++){const l=t.charCodeAt(s);let u=l,c=!1;if(l>=55296&&l<=56319&&s+1<a){const h=t.charCodeAt(s+1);h>=56320&&h<=57343&&(u=(l-55296<<10)+65536|h-56320,c=!0)}u<=127?n+=1:u<=2047?n+=2:u<=65535?n+=3:n+=4,c&&s++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const Qu=class Ar{constructor(t){if(rn(this,"id",++Ar.LAST_ID),rn(this,"_onigBinding"),rn(this,"content"),rn(this,"utf16Length"),rn(this,"utf8Length"),rn(this,"utf16OffsetToUtf8"),rn(this,"utf8OffsetToUtf16"),rn(this,"ptr"),!un)throw new Up("Must invoke loadWasm first.");this._onigBinding=un,this.content=t;const n=new Xu(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!Ar._sharedPtrInUse?(Ar._sharedPtr||(Ar._sharedPtr=un.omalloc(1e4)),Ar._sharedPtrInUse=!0,un.HEAPU8.set(n.utf8Value,Ar._sharedPtr),this.ptr=Ar._sharedPtr):this.ptr=n.createString(un)}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===Ar._sharedPtr?Ar._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};rn(Qu,"LAST_ID",0);rn(Qu,"_sharedPtr",0);rn(Qu,"_sharedPtrInUse",!1);let Z1=Qu;class cO{constructor(t){if(rn(this,"_onigBinding"),rn(this,"_ptr"),!un)throw new Up("Must invoke loadWasm first.");const n=[],s=[];for(let c=0,h=t.length;c<h;c++){const f=new Xu(t[c]);n[c]=f.createString(un),s[c]=f.utf8Length}const a=un.omalloc(4*t.length);un.HEAPU32.set(n,a/4);const l=un.omalloc(4*t.length);un.HEAPU32.set(s,l/4);const u=un.createOnigScanner(a,l,t.length);for(let c=0,h=t.length;c<h;c++)un.ofree(n[c]);un.ofree(l),un.ofree(a),u===0&&lO(un),this._onigBinding=un,this._ptr=u}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,s){let a=0;if(typeof s=="number"&&(a=s),typeof t=="string"){t=new Z1(t);const l=this._findNextMatchSync(t,n,!1,a);return t.dispose(),l}return this._findNextMatchSync(t,n,!1,a)}_findNextMatchSync(t,n,s,a){const l=this._onigBinding,u=l.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),a);if(u===0)return null;const c=l.HEAPU32;let h=u/4;const f=c[h++],p=c[h++],m=[];for(let _=0;_<p;_++){const x=t.convertUtf8OffsetToUtf16(c[h++]),w=t.convertUtf8OffsetToUtf16(c[h++]);m[_]={start:x,end:w,length:w-x}}return{index:f,captureIndices:m}}}function uO(e){return typeof e.instantiator=="function"}function dO(e){return typeof e.default=="function"}function hO(e){return typeof e.data<"u"}function fO(e){return typeof Response<"u"&&e instanceof Response}function mO(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 Xc;function Fp(e){if(Xc)return Xc;async function t(){un=await iO(async n=>{let s=e;return s=await s,typeof s=="function"&&(s=await s(n)),typeof s=="function"&&(s=await s(n)),uO(s)?s=await s.instantiator(n):dO(s)?s=await s.default(n):(hO(s)&&(s=s.data),fO(s)?typeof WebAssembly.instantiateStreaming=="function"?s=await pO(s)(n):s=await gO(s)(n):mO(s)?s=await Zf(s)(n):s instanceof WebAssembly.Module?s=await Zf(s)(n):"default"in s&&s.default instanceof WebAssembly.Module&&(s=await Zf(s.default)(n))),"instance"in s&&(s=s.instance),"exports"in s&&(s=s.exports),s})}return Xc=t(),Xc}function Zf(e){return t=>WebAssembly.instantiate(e,t)}function pO(e){return t=>WebAssembly.instantiateStreaming(e,t)}function gO(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let ew;function xO(e){ew=e}function _O(){return ew}async function tw(e){return e&&await Fp(e),{createScanner(t){return new cO(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new Z1(t)}}}const yO=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:tw,getDefaultWasmLoader:_O,loadWasm:Fp,setDefaultWasmLoader:xO},Symbol.toStringTag,{value:"Module"}));var nw=Ip({});J1(nw,yO);var At=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function vO(e){return Vp(e)}function Vp(e){return Array.isArray(e)?bO(e):e instanceof RegExp?e:typeof e=="object"?SO(e):e}function bO(e){let t=[];for(let n=0,s=e.length;n<s;n++)t[n]=Vp(e[n]);return t}function SO(e){let t={};for(let n in e)t[n]=Vp(e[n]);return t}function rw(e,...t){return t.forEach(n=>{for(let s in n)e[s]=n[s]}),e}function sw(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?sw(e.substring(0,e.length-1)):e.substr(~t+1)}var em=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Qc=class{static hasCaptures(e){return e===null?!1:(em.lastIndex=0,em.test(e))}static replaceCaptures(e,t,n){return e.replace(em,(s,a,l,u)=>{let c=n[parseInt(a||l,10)];if(c){let h=t.substring(c.start,c.end);for(;h[0]===".";)h=h.substring(1);switch(u){case"downcase":return h.toLowerCase();case"upcase":return h.toUpperCase();default:return h}}else return s})}};function iw(e,t){return e<t?-1:e>t?1:0}function aw(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,s=t.length;if(n===s){for(let a=0;a<n;a++){let l=iw(e[a],t[a]);if(l!==0)return l}return 0}return n-s}function $b(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 ow(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var lw=class{constructor(e){pe(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}},yu=class{constructor(e,t,n){pe(this,"_cachedMatchRoot",new lw(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(kO(e),t)}static createFromParsedTheme(e,t){return jO(e,t)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,s=this._cachedMatchRoot.get(t).find(a=>wO(e.parent,a.parentScopes));return s?new cw(s.fontStyle,s.foreground,s.background):null}},tm=class ou{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const s of n)t=new ou(t,s);return t}static from(...t){let n=null;for(let s=0;s<t.length;s++)n=new ou(n,t[s]);return n}push(t){return new ou(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 s=this;for(;s&&s!==t;)n.push(s.scopeName),s=s.parent;return s===t?n.reverse():void 0}};function wO(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let s=t[n],a=!1;if(s===">"){if(n===t.length-1)return!1;s=t[++n],a=!0}for(;e&&!CO(e.scopeName,s);){if(a)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function CO(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var cw=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function kO(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],s=0;for(let a=0,l=t.length;a<l;a++){let u=t[a];if(!u.settings)continue;let c;if(typeof u.scope=="string"){let m=u.scope;m=m.replace(/^[,]+/,""),m=m.replace(/[,]+$/,""),c=m.split(",")}else Array.isArray(u.scope)?c=u.scope:c=[""];let h=-1;if(typeof u.settings.fontStyle=="string"){h=0;let m=u.settings.fontStyle.split(" ");for(let _=0,x=m.length;_<x;_++)switch(m[_]){case"italic":h=h|1;break;case"bold":h=h|2;break;case"underline":h=h|4;break;case"strikethrough":h=h|8;break}}let f=null;typeof u.settings.foreground=="string"&&$b(u.settings.foreground)&&(f=u.settings.foreground);let p=null;typeof u.settings.background=="string"&&$b(u.settings.background)&&(p=u.settings.background);for(let m=0,_=c.length;m<_;m++){let w=c[m].trim().split(" "),k=w[w.length-1],y=null;w.length>1&&(y=w.slice(0,w.length-1),y.reverse()),n[s++]=new EO(k,y,a,h,f,p)}}return n}var EO=class{constructor(e,t,n,s,a,l){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=s,this.foreground=a,this.background=l}},yn=(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))(yn||{});function jO(e,t){e.sort((h,f)=>{let p=iw(h.scope,f.scope);return p!==0||(p=aw(h.parentScopes,f.parentScopes),p!==0)?p:h.index-f.index});let n=0,s="#000000",a="#ffffff";for(;e.length>=1&&e[0].scope==="";){let h=e.shift();h.fontStyle!==-1&&(n=h.fontStyle),h.foreground!==null&&(s=h.foreground),h.background!==null&&(a=h.background)}let l=new NO(t),u=new cw(n,l.getId(s),l.getId(a)),c=new AO(new Pm(0,null,-1,0,0),[]);for(let h=0,f=e.length;h<f;h++){let p=e[h];c.insert(0,p.scope,p.parentScopes,p.fontStyle,l.getId(p.foreground),l.getId(p.background))}return new yu(l,u,c)}var NO=class{constructor(e){pe(this,"_isFrozen");pe(this,"_lastColorId");pe(this,"_id2color");pe(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)}},TO=Object.freeze([]),Pm=class uw{constructor(t,n,s,a,l){pe(this,"scopeDepth");pe(this,"parentScopes");pe(this,"fontStyle");pe(this,"foreground");pe(this,"background");this.scopeDepth=t,this.parentScopes=n||TO,this.fontStyle=s,this.foreground=a,this.background=l}clone(){return new uw(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let s=0,a=t.length;s<a;s++)n[s]=t[s].clone();return n}acceptOverwrite(t,n,s,a){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),s!==0&&(this.foreground=s),a!==0&&(this.background=a)}},AO=class Bm{constructor(t,n=[],s={}){pe(this,"_rulesWithParentScopes");this._mainRule=t,this._children=s,this._rulesWithParentScopes=n}static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let s=0,a=0;for(;t.parentScopes[s]===">"&&s++,n.parentScopes[a]===">"&&a++,!(s>=t.parentScopes.length||a>=n.parentScopes.length);){const l=n.parentScopes[a].length-t.parentScopes[s].length;if(l!==0)return l;s++,a++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let s=t.indexOf("."),a,l;if(s===-1?(a=t,l=""):(a=t.substring(0,s),l=t.substring(s+1)),this._children.hasOwnProperty(a))return this._children[a].match(l)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Bm._cmpBySpecificity),n}insert(t,n,s,a,l,u){if(n===""){this._doInsertHere(t,s,a,l,u);return}let c=n.indexOf("."),h,f;c===-1?(h=n,f=""):(h=n.substring(0,c),f=n.substring(c+1));let p;this._children.hasOwnProperty(h)?p=this._children[h]:(p=new Bm(this._mainRule.clone(),Pm.cloneArr(this._rulesWithParentScopes)),this._children[h]=p),p.insert(t+1,f,s,a,l,u)}_doInsertHere(t,n,s,a,l){if(n===null){this._mainRule.acceptOverwrite(t,s,a,l);return}for(let u=0,c=this._rulesWithParentScopes.length;u<c;u++){let h=this._rulesWithParentScopes[u];if(aw(h.parentScopes,n)===0){h.acceptOverwrite(t,s,a,l);return}}s===-1&&(s=this._mainRule.fontStyle),a===0&&(a=this._mainRule.foreground),l===0&&(l=this._mainRule.background),this._rulesWithParentScopes.push(new Pm(t,n,s,a,l))}},Ba=class sr{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=sr.getLanguageId(t),s=sr.getTokenType(t),a=sr.getFontStyle(t),l=sr.getForeground(t),u=sr.getBackground(t);console.log({languageId:n,tokenType:s,fontStyle:a,foreground:l,background:u})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,s,a,l,u,c){let h=sr.getLanguageId(t),f=sr.getTokenType(t),p=sr.containsBalancedBrackets(t)?1:0,m=sr.getFontStyle(t),_=sr.getForeground(t),x=sr.getBackground(t);return n!==0&&(h=n),s!==8&&(f=s),a!==null&&(p=a?1:0),l!==-1&&(m=l),u!==0&&(_=u),c!==0&&(x=c),(h<<0|f<<8|p<<10|m<<11|_<<15|x<<24)>>>0}};function vu(e,t){const n=[],s=LO(e);let a=s.next();for(;a!==null;){let h=0;if(a.length===2&&a.charAt(1)===":"){switch(a.charAt(0)){case"R":h=1;break;case"L":h=-1;break;default:console.log(`Unknown priority ${a} in scope selector`)}a=s.next()}let f=u();if(n.push({matcher:f,priority:h}),a!==",")break;a=s.next()}return n;function l(){if(a==="-"){a=s.next();const h=l();return f=>!!h&&!h(f)}if(a==="("){a=s.next();const h=c();return a===")"&&(a=s.next()),h}if(Ub(a)){const h=[];do h.push(a),a=s.next();while(Ub(a));return f=>t(h,f)}return null}function u(){const h=[];let f=l();for(;f;)h.push(f),f=l();return p=>h.every(m=>m(p))}function c(){const h=[];let f=u();for(;f&&(h.push(f),a==="|"||a===",");){do a=s.next();while(a==="|"||a===",");f=u()}return p=>h.some(m=>m(p))}}function Ub(e){return!!e&&!!e.match(/[\w\.:]+/)}function LO(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const s=n[0];return n=t.exec(e),s}}}function dw(e){typeof e.dispose=="function"&&e.dispose()}var ll=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},DO=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},RO=class{constructor(){pe(this,"_references",[]);pe(this,"_seenReferenceKeys",new Set);pe(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))}},OO=class{constructor(e,t){pe(this,"seenFullScopeRequests",new Set);pe(this,"seenPartialScopeRequests",new Set);pe(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new ll(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new RO;for(const n of e)MO(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof ll){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 MO(e,t,n,s){const a=n.lookup(e.scopeName);if(!a){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const l=n.lookup(t);e instanceof ll?lu({baseGrammar:l,selfGrammar:a},s):zm(e.ruleName,{baseGrammar:l,selfGrammar:a,repository:a.repository},s);const u=n.injections(e.scopeName);if(u)for(const c of u)s.add(new ll(c))}function zm(e,t,n){if(t.repository&&t.repository[e]){const s=t.repository[e];bu([s],t,n)}}function lu(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&bu(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&bu(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function bu(e,t,n){for(const s of e){if(n.visitedRule.has(s))continue;n.visitedRule.add(s);const a=s.repository?rw({},t.repository,s.repository):t.repository;Array.isArray(s.patterns)&&bu(s.patterns,{...t,repository:a},n);const l=s.include;if(!l)continue;const u=hw(l);switch(u.kind){case 0:lu({...t,selfGrammar:t.baseGrammar},n);break;case 1:lu(t,n);break;case 2:zm(u.ruleName,{...t,repository:a},n);break;case 3:case 4:const c=u.scopeName===t.selfGrammar.scopeName?t.selfGrammar:u.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(c){const h={baseGrammar:t.baseGrammar,selfGrammar:c,repository:a};u.kind===4?zm(u.ruleName,h,n):lu(h,n)}else u.kind===4?n.add(new DO(u.scopeName,u.ruleName)):n.add(new ll(u.scopeName));break}}}var IO=class{constructor(){pe(this,"kind",0)}},PO=class{constructor(){pe(this,"kind",1)}},BO=class{constructor(e){pe(this,"kind",2);this.ruleName=e}},zO=class{constructor(e){pe(this,"kind",3);this.scopeName=e}},HO=class{constructor(e,t){pe(this,"kind",4);this.scopeName=e,this.ruleName=t}};function hw(e){if(e==="$base")return new IO;if(e==="$self")return new PO;const t=e.indexOf("#");if(t===-1)return new zO(e);if(t===0)return new BO(e.substring(1));{const n=e.substring(0,t),s=e.substring(t+1);return new HO(n,s)}}var $O=/\\(\d+)/,Fb=/\\(\d+)/g,UO=-1,fw=-2;var wl=class{constructor(e,t,n,s){pe(this,"$location");pe(this,"id");pe(this,"_nameIsCapturing");pe(this,"_name");pe(this,"_contentNameIsCapturing");pe(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Qc.hasCaptures(this._name),this._contentName=s||null,this._contentNameIsCapturing=Qc.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${sw(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:Qc.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Qc.replaceCaptures(this._contentName,e,t)}},FO=class extends wl{constructor(t,n,s,a,l){super(t,n,s,a);pe(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=l}dispose(){}collectPatterns(t,n){throw new Error("Not supported!")}compile(t,n){throw new Error("Not supported!")}compileAG(t,n,s,a){throw new Error("Not supported!")}},VO=class extends wl{constructor(t,n,s,a,l){super(t,n,s,null);pe(this,"_match");pe(this,"captures");pe(this,"_cachedCompiledPatterns");this._match=new cl(a,this.id),this.captures=l,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,n){n.push(this._match)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,s,a){return this._getCachedCompiledPatterns(t).compileAG(t,s,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new ul,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Vb=class extends wl{constructor(t,n,s,a,l){super(t,n,s,a);pe(this,"hasMissingPatterns");pe(this,"patterns");pe(this,"_cachedCompiledPatterns");this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,n){for(const s of this.patterns)t.getRule(s).collectPatterns(t,n)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,s,a){return this._getCachedCompiledPatterns(t).compileAG(t,s,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new ul,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Hm=class extends wl{constructor(t,n,s,a,l,u,c,h,f,p){super(t,n,s,a);pe(this,"_begin");pe(this,"beginCaptures");pe(this,"_end");pe(this,"endHasBackReferences");pe(this,"endCaptures");pe(this,"applyEndPatternLast");pe(this,"hasMissingPatterns");pe(this,"patterns");pe(this,"_cachedCompiledPatterns");this._begin=new cl(l,this.id),this.beginCaptures=u,this._end=new cl(c||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=h,this.applyEndPatternLast=f||!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,s,a){return this._getCachedCompiledPatterns(t,n).compileAG(t,s,a)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new ul;for(const s of this.patterns)t.getRule(s).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}},Su=class extends wl{constructor(t,n,s,a,l,u,c,h,f){super(t,n,s,a);pe(this,"_begin");pe(this,"beginCaptures");pe(this,"whileCaptures");pe(this,"_while");pe(this,"whileHasBackReferences");pe(this,"hasMissingPatterns");pe(this,"patterns");pe(this,"_cachedCompiledPatterns");pe(this,"_cachedCompiledWhilePatterns");this._begin=new cl(l,this.id),this.beginCaptures=u,this.whileCaptures=h,this._while=new cl(c,fw),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=f.patterns,this.hasMissingPatterns=f.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,s,a){return this._getCachedCompiledPatterns(t).compileAG(t,s,a)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new ul;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,s,a){return this._getCachedCompiledWhilePatterns(t,n).compileAG(t,s,a)}_getCachedCompiledWhilePatterns(t,n){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new ul,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||""),this._cachedCompiledWhilePatterns}},mw=class _n{static createCaptureRule(t,n,s,a,l){return t.registerRule(u=>new FO(n,u,s,a,l))}static getCompiledRuleId(t,n,s){return t.id||n.registerRule(a=>{if(t.id=a,t.match)return new VO(t.$vscodeTextmateLocation,t.id,t.name,t.match,_n._compileCaptures(t.captures,n,s));if(typeof t.begin>"u"){t.repository&&(s=rw({},s,t.repository));let l=t.patterns;return typeof l>"u"&&t.include&&(l=[{include:t.include}]),new Vb(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,_n._compilePatterns(l,n,s))}return t.while?new Su(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,_n._compileCaptures(t.beginCaptures||t.captures,n,s),t.while,_n._compileCaptures(t.whileCaptures||t.captures,n,s),_n._compilePatterns(t.patterns,n,s)):new Hm(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,_n._compileCaptures(t.beginCaptures||t.captures,n,s),t.end,_n._compileCaptures(t.endCaptures||t.captures,n,s),t.applyEndPatternLast,_n._compilePatterns(t.patterns,n,s))}),t.id}static _compileCaptures(t,n,s){let a=[];if(t){let l=0;for(const u in t){if(u==="$vscodeTextmateLocation")continue;const c=parseInt(u,10);c>l&&(l=c)}for(let u=0;u<=l;u++)a[u]=null;for(const u in t){if(u==="$vscodeTextmateLocation")continue;const c=parseInt(u,10);let h=0;t[u].patterns&&(h=_n.getCompiledRuleId(t[u],n,s)),a[c]=_n.createCaptureRule(n,t[u].$vscodeTextmateLocation,t[u].name,t[u].contentName,h)}}return a}static _compilePatterns(t,n,s){let a=[];if(t)for(let l=0,u=t.length;l<u;l++){const c=t[l];let h=-1;if(c.include){const f=hw(c.include);switch(f.kind){case 0:case 1:h=_n.getCompiledRuleId(s[c.include],n,s);break;case 2:let p=s[f.ruleName];p&&(h=_n.getCompiledRuleId(p,n,s));break;case 3:case 4:const m=f.scopeName,_=f.kind===4?f.ruleName:null,x=n.getExternalGrammar(m,s);if(x)if(_){let w=x.repository[_];w&&(h=_n.getCompiledRuleId(w,n,x.repository))}else h=_n.getCompiledRuleId(x.repository.$self,n,x.repository);break}}else h=_n.getCompiledRuleId(c,n,s);if(h!==-1){const f=n.getRule(h);let p=!1;if((f instanceof Vb||f instanceof Hm||f instanceof Su)&&f.hasMissingPatterns&&f.patterns.length===0&&(p=!0),p)continue;a.push(h)}}return{patterns:a,hasMissingPatterns:(t?t.length:0)!==a.length}}},cl=class pw{constructor(t,n){pe(this,"source");pe(this,"ruleId");pe(this,"hasAnchor");pe(this,"hasBackReferences");pe(this,"_anchorCache");if(t&&typeof t=="string"){const s=t.length;let a=0,l=[],u=!1;for(let c=0;c<s;c++)if(t.charAt(c)==="\\"&&c+1<s){const f=t.charAt(c+1);f==="z"?(l.push(t.substring(a,c)),l.push("$(?!\\n)(?<!\\n)"),a=c+2):(f==="A"||f==="G")&&(u=!0),c++}this.hasAnchor=u,a===0?this.source=t:(l.push(t.substring(a,s)),this.source=l.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=$O.test(this.source):this.hasBackReferences=!1}clone(){return new pw(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 s=n.map(a=>t.substring(a.start,a.end));return Fb.lastIndex=0,this.source.replace(Fb,(a,l)=>ow(s[parseInt(l,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],s=[],a=[],l,u,c,h;for(l=0,u=this.source.length;l<u;l++)c=this.source.charAt(l),t[l]=c,n[l]=c,s[l]=c,a[l]=c,c==="\\"&&l+1<u&&(h=this.source.charAt(l+1),h==="A"?(t[l+1]="",n[l+1]="",s[l+1]="A",a[l+1]="A"):h==="G"?(t[l+1]="",n[l+1]="G",s[l+1]="",a[l+1]="G"):(t[l+1]=h,n[l+1]=h,s[l+1]=h,a[l+1]=h),l++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:s.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}},ul=class{constructor(){pe(this,"_items");pe(this,"_hasAnchors");pe(this,"_cached");pe(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 Gb(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 s=this._items.map(a=>a.resolveAnchors(t,n));return new Gb(e,s,this._items.map(a=>a.ruleId))}},Gb=class{constructor(e,t,n){pe(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(`
|
|
123
|
+
`)}findNextMatchSync(e,t,n){const s=this.scanner.findNextMatchSync(e,t,n);return s?{ruleId:this.rules[s.index],captureIndices:s.captureIndices}:null}},nm=class{constructor(e,t){this.languageId=e,this.tokenType=t}},ls,GO=(ls=class{constructor(t,n){pe(this,"_defaultAttributes");pe(this,"_embeddedLanguagesMatcher");pe(this,"_getBasicScopeAttributes",new lw(t=>{const n=this._scopeToLanguage(t),s=this._toStandardTokenType(t);return new nm(n,s)}));this._defaultAttributes=new nm(t,8),this._embeddedLanguagesMatcher=new WO(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?ls._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(ls.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!")}},pe(ls,"_NULL_SCOPE_METADATA",new nm(0,0)),pe(ls,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),ls),WO=class{constructor(e){pe(this,"values");pe(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,s])=>ow(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])}},Wb=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function gw(e,t,n,s,a,l,u,c){const h=t.content.length;let f=!1,p=-1;if(u){const x=qO(e,t,n,s,a,l);a=x.stack,s=x.linePos,n=x.isFirstLine,p=x.anchorPosition}const m=Date.now();for(;!f;){if(c!==0&&Date.now()-m>c)return new Wb(a,!0);_()}return new Wb(a,!1);function _(){const x=KO(e,t,n,s,a,p);if(!x){l.produce(a,h),f=!0;return}const w=x.captureIndices,k=x.matchedRuleId,y=w&&w.length>0?w[0].end>s:!1;if(k===UO){const S=a.getRule(e);l.produce(a,w[0].start),a=a.withContentNameScopesList(a.nameScopesList),Jo(e,t,n,a,l,S.endCaptures,w),l.produce(a,w[0].end);const v=a;if(a=a.parent,p=v.getAnchorPos(),!y&&v.getEnterPos()===s){a=v,l.produce(a,h),f=!0;return}}else{const S=e.getRule(k);l.produce(a,w[0].start);const v=a,b=S.getName(t.content,w),E=a.contentNameScopesList.pushAttributed(b,e);if(a=a.push(k,s,p,w[0].end===h,null,E,E),S instanceof Hm){const T=S;Jo(e,t,n,a,l,T.beginCaptures,w),l.produce(a,w[0].end),p=w[0].end;const N=T.getContentName(t.content,w),L=E.pushAttributed(N,e);if(a=a.withContentNameScopesList(L),T.endHasBackReferences&&(a=a.withEndRule(T.getEndWithResolvedBackReferences(t.content,w))),!y&&v.hasSameRuleAs(a)){a=a.pop(),l.produce(a,h),f=!0;return}}else if(S instanceof Su){const T=S;Jo(e,t,n,a,l,T.beginCaptures,w),l.produce(a,w[0].end),p=w[0].end;const N=T.getContentName(t.content,w),L=E.pushAttributed(N,e);if(a=a.withContentNameScopesList(L),T.whileHasBackReferences&&(a=a.withEndRule(T.getWhileWithResolvedBackReferences(t.content,w))),!y&&v.hasSameRuleAs(a)){a=a.pop(),l.produce(a,h),f=!0;return}}else if(Jo(e,t,n,a,l,S.captures,w),l.produce(a,w[0].end),a=a.pop(),!y){a=a.safePop(),l.produce(a,h),f=!0;return}}w[0].end>s&&(s=w[0].end,n=!1)}}function qO(e,t,n,s,a,l){let u=a.beginRuleCapturedEOL?0:-1;const c=[];for(let h=a;h;h=h.pop()){const f=h.getRule(e);f instanceof Su&&c.push({rule:f,stack:h})}for(let h=c.pop();h;h=c.pop()){const{ruleScanner:f,findOptions:p}=QO(h.rule,e,h.stack.endRule,n,s===u),m=f.findNextMatchSync(t,s,p);if(m){if(m.ruleId!==fw){a=h.stack.pop();break}m.captureIndices&&m.captureIndices.length&&(l.produce(h.stack,m.captureIndices[0].start),Jo(e,t,n,h.stack,l,h.rule.whileCaptures,m.captureIndices),l.produce(h.stack,m.captureIndices[0].end),u=m.captureIndices[0].end,m.captureIndices[0].end>s&&(s=m.captureIndices[0].end,n=!1))}else{a=h.stack.pop();break}}return{stack:a,linePos:s,anchorPosition:u,isFirstLine:n}}function KO(e,t,n,s,a,l){const u=YO(e,t,n,s,a,l),c=e.getInjections();if(c.length===0)return u;const h=XO(c,e,t,n,s,a,l);if(!h)return u;if(!u)return h;const f=u.captureIndices[0].start,p=h.captureIndices[0].start;return p<f||h.priorityMatch&&p===f?h:u}function YO(e,t,n,s,a,l){const u=a.getRule(e),{ruleScanner:c,findOptions:h}=xw(u,e,a.endRule,n,s===l),f=c.findNextMatchSync(t,s,h);return f?{captureIndices:f.captureIndices,matchedRuleId:f.ruleId}:null}function XO(e,t,n,s,a,l,u){let c=Number.MAX_VALUE,h=null,f,p=0;const m=l.contentNameScopesList.getScopeNames();for(let _=0,x=e.length;_<x;_++){const w=e[_];if(!w.matcher(m))continue;const k=t.getRule(w.ruleId),{ruleScanner:y,findOptions:S}=xw(k,t,null,s,a===u),v=y.findNextMatchSync(n,a,S);if(!v)continue;const b=v.captureIndices[0].start;if(!(b>=c)&&(c=b,h=v.captureIndices,f=v.ruleId,p=w.priority,c===a))break}return h?{priorityMatch:p===-1,captureIndices:h,matchedRuleId:f}:null}function xw(e,t,n,s,a){return{ruleScanner:e.compileAG(t,n,s,a),findOptions:0}}function QO(e,t,n,s,a){return{ruleScanner:e.compileWhileAG(t,n,s,a),findOptions:0}}function Jo(e,t,n,s,a,l,u){if(l.length===0)return;const c=t.content,h=Math.min(l.length,u.length),f=[],p=u[0].end;for(let m=0;m<h;m++){const _=l[m];if(_===null)continue;const x=u[m];if(x.length===0)continue;if(x.start>p)break;for(;f.length>0&&f[f.length-1].endPos<=x.start;)a.produceFromScopes(f[f.length-1].scopes,f[f.length-1].endPos),f.pop();if(f.length>0?a.produceFromScopes(f[f.length-1].scopes,x.start):a.produce(s,x.start),_.retokenizeCapturedWithRuleId){const k=_.getName(c,u),y=s.contentNameScopesList.pushAttributed(k,e),S=_.getContentName(c,u),v=y.pushAttributed(S,e),b=s.push(_.retokenizeCapturedWithRuleId,x.start,-1,!1,null,y,v),E=e.createOnigString(c.substring(0,x.end));gw(e,E,n&&x.start===0,x.start,b,a,!1,0),dw(E);continue}const w=_.getName(c,u);if(w!==null){const y=(f.length>0?f[f.length-1].scopes:s.contentNameScopesList).pushAttributed(w,e);f.push(new JO(y,x.end))}}for(;f.length>0;)a.produceFromScopes(f[f.length-1].scopes,f[f.length-1].endPos),f.pop()}var JO=class{constructor(e,t){pe(this,"scopes");pe(this,"endPos");this.scopes=e,this.endPos=t}};function ZO(e,t,n,s,a,l,u,c){return new t4(e,t,n,s,a,l,u,c)}function qb(e,t,n,s,a){const l=vu(t,wu),u=mw.getCompiledRuleId(n,s,a.repository);for(const c of l)e.push({debugSelector:t,matcher:c.matcher,ruleId:u,grammar:a,priority:c.priority})}function wu(e,t){if(t.length<e.length)return!1;let n=0;return e.every(s=>{for(let a=n;a<t.length;a++)if(e4(t[a],s))return n=a+1,!0;return!1})}function e4(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 t4=class{constructor(e,t,n,s,a,l,u,c){pe(this,"_rootId");pe(this,"_lastRuleId");pe(this,"_ruleId2desc");pe(this,"_includedGrammars");pe(this,"_grammarRepository");pe(this,"_grammar");pe(this,"_injections");pe(this,"_basicScopeAttributesProvider");pe(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=l,this._onigLib=c,this._basicScopeAttributesProvider=new GO(n,s),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=u,this._grammar=Kb(t,null),this._injections=null,this._tokenTypeMatchers=[],a)for(const h of Object.keys(a)){const f=vu(h,wu);for(const p of f)this._tokenTypeMatchers.push({matcher:p.matcher,type:a[h]})}}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,s=e.lookup(n);if(s){const a=s.injections;if(a)for(let u in a)qb(t,u,a[u],this,s);const l=this._grammarRepository.injections(n);l&&l.forEach(u=>{const c=this.getExternalGrammar(u);if(c){const h=c.injectionSelector;h&&qb(t,h,c,this,c)}})}return t.sort((a,l)=>a.priority-l.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=Kb(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){const s=this._tokenize(e,t,!1,n);return{tokens:s.lineTokens.getResult(s.ruleStack,s.lineLength),ruleStack:s.ruleStack,stoppedEarly:s.stoppedEarly}}tokenizeLine2(e,t,n=0){const s=this._tokenize(e,t,!0,n);return{tokens:s.lineTokens.getBinaryResult(s.ruleStack,s.lineLength),ruleStack:s.ruleStack,stoppedEarly:s.stoppedEarly}}_tokenize(e,t,n,s){this._rootId===-1&&(this._rootId=mw.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let a;if(!t||t===$m.NULL){a=!0;const f=this._basicScopeAttributesProvider.getDefaultAttributes(),p=this.themeProvider.getDefaults(),m=Ba.set(0,f.languageId,f.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),_=this.getRule(this._rootId).getName(null,null);let x;_?x=rl.createRootAndLookUpScopeName(_,m,this):x=rl.createRoot("unknown",m),t=new $m(null,this._rootId,-1,-1,!1,null,x,x)}else a=!1,t.reset();e=e+`
|
|
124
|
+
`;const l=this.createOnigString(e),u=l.content.length,c=new r4(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),h=gw(this,l,a,0,t,c,!0,s);return dw(l),{lineLength:u,lineTokens:c,ruleStack:h.stack,stoppedEarly:h.stoppedEarly}}};function Kb(e,t){return e=vO(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 rl=class Lr{constructor(t,n,s){this.parent=t,this.scopePath=n,this.tokenAttributes=s}static fromExtension(t,n){let s=t,a=(t==null?void 0:t.scopePath)??null;for(const l of n)a=tm.push(a,l.scopeNames),s=new Lr(s,a,l.encodedTokenAttributes);return s}static createRoot(t,n){return new Lr(null,new tm(null,t),n)}static createRootAndLookUpScopeName(t,n,s){const a=s.getMetadataForScope(t),l=new tm(null,t),u=s.themeProvider.themeMatch(l),c=Lr.mergeAttributes(n,a,u);return new Lr(null,l,c)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Lr.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,s){let a=-1,l=0,u=0;return s!==null&&(a=s.fontStyle,l=s.foregroundId,u=s.backgroundId),Ba.set(t,n.languageId,n.tokenType,null,a,l,u)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Lr._pushAttributed(this,t,n);const s=t.split(/ /g);let a=this;for(const l of s)a=Lr._pushAttributed(a,l,n);return a}static _pushAttributed(t,n,s){const a=s.getMetadataForScope(n),l=t.scopePath.push(n),u=s.themeProvider.themeMatch(l),c=Lr.mergeAttributes(t.tokenAttributes,a,u);return new Lr(t,l,c)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){var a;const n=[];let s=this;for(;s&&s!==t;)n.push({encodedTokenAttributes:s.tokenAttributes,scopeNames:s.scopePath.getExtensionIfDefined(((a=s.parent)==null?void 0:a.scopePath)??null)}),s=s.parent;return s===t?n.reverse():void 0}},ar,$m=(ar=class{constructor(t,n,s,a,l,u,c,h){pe(this,"_stackElementBrand");pe(this,"_enterPos");pe(this,"_anchorPos");pe(this,"depth");this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=l,this.endRule=u,this.nameScopesList=c,this.contentNameScopesList=h,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=s,this._anchorPos=a}equals(t){return t===null?!1:ar._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?rl.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(){ar._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,s,a,l,u,c){return new ar(this,t,n,s,a,l,u,c)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){var s,a;return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${(s=this.nameScopesList)==null?void 0:s.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 ar(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,s;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:((s=this.contentNameScopesList)==null?void 0:s.getExtensionIfDefined(this.nameScopesList))??[]}}static pushFrame(t,n){const s=rl.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new ar(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,s,rl.fromExtension(s,n.contentNameScopesList))}},pe(ar,"NULL",new ar(null,0,0,0,!1,null,null,null)),ar),n4=class{constructor(e,t){pe(this,"balancedBracketScopes");pe(this,"unbalancedBracketScopes");pe(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):vu(n,wu).map(s=>s.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>vu(n,wu).map(s=>s.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}},r4=class{constructor(e,t,n,s){pe(this,"_emitBinaryTokens");pe(this,"_lineText");pe(this,"_tokens");pe(this,"_binaryTokens");pe(this,"_lastTokenEndIndex");pe(this,"_tokenTypeOverrides");this.balancedBracketSelectors=s,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 s;if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let a=(e==null?void 0:e.tokenAttributes)??0,l=!1;if((s=this.balancedBracketSelectors)!=null&&s.matchesAlways&&(l=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const u=(e==null?void 0:e.getScopeNames())??[];for(const c of this._tokenTypeOverrides)c.matcher(u)&&(a=Ba.set(a,0,c.type,null,-1,0,0));this.balancedBracketSelectors&&(l=this.balancedBracketSelectors.match(u))}if(l&&(a=Ba.set(a,0,8,l,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===a){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(a),this._lastTokenEndIndex=t;return}const n=(e==null?void 0:e.getScopeNames())??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let s=0,a=this._binaryTokens.length;s<a;s++)n[s]=this._binaryTokens[s];return n}},s4=class{constructor(e,t){pe(this,"_grammars",new Map);pe(this,"_rawGrammars",new Map);pe(this,"_injectionGrammars",new Map);pe(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,s,a){if(!this._grammars.has(e)){let l=this._rawGrammars.get(e);if(!l)return null;this._grammars.set(e,ZO(e,l,t,n,s,a,this,this._onigLib))}return this._grammars.get(e)}},i4=class{constructor(t){pe(this,"_options");pe(this,"_syncRegistry");pe(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new s4(yu.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(yu.createFromRawTheme(t,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(t,n,s){return this.loadGrammarWithConfiguration(t,n,{embeddedLanguages:s})}loadGrammarWithConfiguration(t,n,s){return this._loadGrammar(t,n,s.embeddedLanguages,s.tokenTypes,new n4(s.balancedBracketSelectors||[],s.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,s,a,l){const u=new OO(this._syncRegistry,t);for(;u.Q.length>0;)u.Q.map(c=>this._loadSingleGrammar(c.scopeName)),u.processQueue();return this._grammarForScopeName(t,n,s,a,l)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const s=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,s)}}addGrammar(t,n=[],s=0,a=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,s,a)}_grammarForScopeName(t,n=0,s=null,a=null,l=null){return this._syncRegistry.grammarForScopeName(t,n,s,a,l)}},Um=$m.NULL;function Cu(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},s=typeof e=="string"?e:e.name;for(const[a,l]of Object.entries((t==null?void 0:t.colorReplacements)||{}))typeof l=="string"?n[a]=l:a===s&&Object.assign(n,l);return n}function Vs(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function a4(e){return Array.isArray(e)?e:[e]}async function _w(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Ju(e){return!e||["plaintext","txt","text","plain"].includes(e)}function yw(e){return e==="ansi"||Ju(e)}function Zu(e){return e==="none"}function vw(e){return Zu(e)}const o4=/(\r?\n)/g;function ed(e,t=!1){var l;if(e.length===0)return[["",0]];const n=e.split(o4);let s=0;const a=[];for(let u=0;u<n.length;u+=2){const c=t?n[u]+(n[u+1]||""):n[u];a.push([c,s]),s+=n[u].length,s+=((l=n[u+1])==null?void 0:l.length)||0}return a}const Yb={light:"#333333",dark:"#bbbbbb"},Xb={light:"#fffffe",dark:"#1e1e1e"},Qb="__shiki_resolved";function Gp(e){var c,h,f,p,m;if(e!=null&&e[Qb])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:s}=t;if(!n||!s){const _=t.settings?t.settings.find(x=>!x.name&&!x.scope):void 0;(c=_==null?void 0:_.settings)!=null&&c.foreground&&(s=_.settings.foreground),(h=_==null?void 0:_.settings)!=null&&h.background&&(n=_.settings.background),!s&&((f=t==null?void 0:t.colors)!=null&&f["editor.foreground"])&&(s=t.colors["editor.foreground"]),!n&&((p=t==null?void 0:t.colors)!=null&&p["editor.background"])&&(n=t.colors["editor.background"]),s||(s=t.type==="light"?Yb.light:Yb.dark),n||(n=t.type==="light"?Xb.light:Xb.dark),t.fg=s,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let a=0;const l=new Map;function u(_){var w;if(l.has(_))return l.get(_);a+=1;const x=`#${a.toString(16).padStart(8,"0").toLowerCase()}`;return(w=t.colorReplacements)!=null&&w[`#${x}`]?u(_):(l.set(_,x),x)}t.settings=t.settings.map(_=>{var y,S;const x=((y=_.settings)==null?void 0:y.foreground)&&!_.settings.foreground.startsWith("#"),w=((S=_.settings)==null?void 0:S.background)&&!_.settings.background.startsWith("#");if(!x&&!w)return _;const k={..._,settings:{..._.settings}};if(x){const v=u(_.settings.foreground);t.colorReplacements[v]=_.settings.foreground,k.settings.foreground=v}if(w){const v=u(_.settings.background);t.colorReplacements[v]=_.settings.background,k.settings.background=v}return k});for(const _ of Object.keys(t.colors||{}))if((_==="editor.foreground"||_==="editor.background"||_.startsWith("terminal.ansi"))&&!((m=t.colors[_])!=null&&m.startsWith("#"))){const x=u(t.colors[_]);t.colorReplacements[x]=t.colors[_],t.colors[_]=x}return Object.defineProperty(t,Qb,{enumerable:!1,writable:!1,value:!0}),t}async function bw(e){return[...new Set((await Promise.all(e.filter(t=>!yw(t)).map(async t=>await _w(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function Sw(e){return(await Promise.all(e.map(async t=>vw(t)?null:Gp(await _w(t))))).filter(t=>!!t)}function ww(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 At(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var l4=class extends i4{constructor(t,n,s,a={}){super(t);pe(this,"_resolver");pe(this,"_themes");pe(this,"_langs");pe(this,"_alias");pe(this,"_resolvedThemes",new Map);pe(this,"_resolvedGrammars",new Map);pe(this,"_langMap",new Map);pe(this,"_langGraph",new Map);pe(this,"_textmateThemeCache",new WeakMap);pe(this,"_loadedThemesCache",null);pe(this,"_loadedLanguagesCache",null);this._resolver=t,this._themes=n,this._langs=s,this._alias=a,this._themes.map(l=>this.loadTheme(l)),this.loadLanguages(this._langs)}getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const n=Gp(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=yu.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=ww(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){var l,u,c,h;if(this.getGrammar(t.name))return;const n=new Set([...this._langMap.values()].filter(f=>{var p;return(p=f.embeddedLangsLazy)==null?void 0:p.includes(t.name)}));this._resolver.addLanguage(t);const s={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const a=this.loadGrammarWithConfiguration(t.scopeName,1,s);if(a.name=t.name,this._resolvedGrammars.set(t.name,a),t.aliases&&t.aliases.forEach(f=>{this._alias[f]=t.name}),this._loadedLanguagesCache=null,n.size)for(const f of n)this._resolvedGrammars.delete(f.name),this._loadedLanguagesCache=null,(u=(l=this._syncRegistry)==null?void 0:l._injectionGrammars)==null||u.delete(f.scopeName),(h=(c=this._syncRegistry)==null?void 0:c._grammars)==null||h.delete(f.scopeName),this.loadLanguage(this._langMap.get(f.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()],s=n.filter(([a,l])=>!l);if(s.length){const a=n.filter(([l,u])=>{var c;return u?(c=u.embeddedLanguages||u.embeddedLangs)==null?void 0:c.some(h=>s.map(([f])=>f).includes(h)):!1}).filter(l=>!s.includes(l));throw new At(`Missing languages ${s.map(([l])=>`\`${l}\``).join(", ")}, required by ${a.map(([l])=>`\`${l}\``).join(", ")}`)}for(const[a,l]of n)this._resolver.addLanguage(l);for(const[a,l]of n)this.loadLanguage(l)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);const n=t.embeddedLanguages??t.embeddedLangs;if(n)for(const s of n)this._langGraph.set(s,this._langMap.get(s))}},c4=class{constructor(e,t){pe(this,"_langs",new Map);pe(this,"_scopeToLang",new Map);pe(this,"_injections",new Map);pe(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 s=1;s<=t.length;s++){const a=t.slice(0,s).join(".");n=[...n,...this._injections.get(a)||[]]}return n}};let qo=0;function u4(e){qo+=1,e.warnings!==!1&&qo>=10&&qo%10===0&&console.warn(`[Shiki] ${qo} 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 At("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),s=(e.themes||[]).flat(1).map(Gp),a=new l4(new c4(e.engine,n),s,n,e.langAlias);let l;function u(v){return ww(v,e.langAlias)}function c(v){y();const b=a.getGrammar(typeof v=="string"?v:v.name);if(!b)throw new At(`Language \`${v}\` not found, you may need to load it first`);return b}function h(v){if(v==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};y();const b=a.getTheme(v);if(!b)throw new At(`Theme \`${v}\` not found, you may need to load it first`);return b}function f(v){y();const b=h(v);return l!==v&&(a.setTheme(b),l=v),{theme:b,colorMap:a.getColorMap()}}function p(){return y(),a.getLoadedThemes()}function m(){return y(),a.getLoadedLanguages()}function _(...v){y(),a.loadLanguages(v.flat(1))}async function x(...v){return _(await bw(v))}function w(...v){y();for(const b of v.flat(1))a.loadTheme(b)}async function k(...v){return y(),w(await Sw(v))}function y(){if(t)throw new At("Shiki instance has been disposed")}function S(){t||(t=!0,a.dispose(),qo-=1)}return{setTheme:f,getTheme:h,getLanguage:c,getLoadedThemes:p,getLoadedLanguages:m,resolveLangAlias:u,loadLanguage:x,loadLanguageSync:_,loadTheme:k,loadThemeSync:w,dispose:S,[Symbol.dispose]:S}}async function d4(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,s]=await Promise.all([Sw(e.themes||[]),bw(e.langs||[]),e.engine]);return u4({...e,themes:t,langs:n,engine:s})}const Cw=new WeakMap;function td(e,t){Cw.set(e,t)}function dl(e){return Cw.get(e)}var nd=class kw{constructor(...t){pe(this,"_stacks",{});pe(this,"lang");if(t.length===2){const[n,s]=t;this.lang=s,this._stacks=n}else{const[n,s,a]=t;this.lang=s,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 kw(Object.fromEntries(a4(n).map(s=>[s,Um])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return h4(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function h4(e){const t=[],n=new Set;function s(a){var u;if(n.has(a))return;n.add(a);const l=(u=a==null?void 0:a.nameScopesList)==null?void 0:u.scopeName;l&&t.push(l),a.parent&&s(a.parent)}return s(e),t}function f4(e,t){if(!(e instanceof nd))throw new At("Invalid grammar state");return e.getInternalStack(t)}const m4=/,/,p4=/ /;function Ew(e,t,n={}){const{theme:s=e.getLoadedThemes()[0]}=n;if(Ju(e.resolveLangAlias(n.lang||"text"))||Zu(s))return ed(t).map(c=>[{content:c[0],offset:c[1]}]);const{theme:a,colorMap:l}=e.setTheme(s),u=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==u.name)throw new At(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${u.name}"`);if(!n.grammarState.themes.includes(a.name))throw new At(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return x4(t,u,a,l,n)}function g4(...e){if(e.length===2)return dl(e[1]);const[t,n,s={}]=e,{lang:a="text",theme:l=t.getLoadedThemes()[0]}=s;if(Ju(a)||Zu(l))throw new At("Plain language does not have grammar state");if(a==="ansi")throw new At("ANSI language does not have grammar state");const{theme:u,colorMap:c}=t.setTheme(l),h=t.getLanguage(a);return new nd(Wp(n,h,u,c,s).stateStack,h.name,u.name)}function x4(e,t,n,s,a){const l=Wp(e,t,n,s,a),u=new nd(l.stateStack,t.name,n.name);return td(l.tokens,u),l.tokens}function Wp(e,t,n,s,a){const l=Cu(n,a),{tokenizeMaxLineLength:u=0,tokenizeTimeLimit:c=500}=a,h=ed(e);let f=a.grammarState?f4(a.grammarState,n.name)??Um:a.grammarContextCode!=null?Wp(a.grammarContextCode,t,n,s,{...a,grammarState:void 0,grammarContextCode:void 0}).stateStack:Um,p=[];const m=[];for(let _=0,x=h.length;_<x;_++){const[w,k]=h[_];if(w===""){p=[],m.push([]);continue}if(u>0&&w.length>=u){p=[],m.push([{content:w,offset:k,color:"",fontStyle:0}]);continue}let y,S,v;a.includeExplanation&&(y=t.tokenizeLine(w,f,c),S=y.tokens,v=0);const b=t.tokenizeLine2(w,f,c),E=b.tokens.length/2;for(let T=0;T<E;T++){const N=b.tokens[2*T],L=T+1<E?b.tokens[2*T+2]:w.length;if(N===L)continue;const A=b.tokens[2*T+1],D=Vs(s[Ba.getForeground(A)],l),B=Ba.getFontStyle(A),q={content:w.substring(N,L),offset:k+N,color:D,fontStyle:B};if(a.includeExplanation){const W=[];if(a.includeExplanation!=="scopeName")for(const V of n.settings){let G;switch(typeof V.scope){case"string":G=V.scope.split(m4).map(z=>z.trim());break;case"object":G=V.scope;break;default:continue}W.push({settings:V,selectors:G.map(z=>z.split(p4))})}q.explanation=[];let O=0;for(;N+O<L;){const V=S[v],G=w.substring(V.startIndex,V.endIndex);O+=G.length,q.explanation.push({content:G,scopes:a.includeExplanation==="scopeName"?_4(V.scopes):y4(W,V.scopes)}),v+=1}}p.push(q)}m.push(p),p=[],f=b.ruleStack}return{tokens:m,stateStack:f}}function _4(e){return e.map(t=>({scopeName:t}))}function y4(e,t){const n=[];for(let s=0,a=t.length;s<a;s++){const l=t[s];n[s]={scopeName:l,themeMatches:b4(e,l,t.slice(0,s))}}return n}function Jb(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function v4(e,t,n){if(!Jb(e.at(-1),t))return!1;let s=e.length-2,a=n.length-1;for(;s>=0&&a>=0;)Jb(e[s],n[a])&&(s-=1),a-=1;return s===-1}function b4(e,t,n){const s=[];for(const{selectors:a,settings:l}of e)for(const u of a)if(v4(u,t,n)){s.push(l);break}return s}function jw(e,t,n,s=Ew){const a=Object.entries(n.themes).filter(f=>f[1]).map(f=>({color:f[0],theme:f[1]})),l=a.map(f=>{const p=s(e,t,{...n,theme:f.theme});return{tokens:p,state:dl(p),theme:typeof f.theme=="string"?f.theme:f.theme.name}}),u=S4(...l.map(f=>f.tokens)),c=u[0].map((f,p)=>f.map((m,_)=>{const x={content:m.content,variants:{},offset:m.offset};return"includeExplanation"in n&&n.includeExplanation&&(x.explanation=m.explanation),u.forEach((w,k)=>{const{content:y,explanation:S,offset:v,...b}=w[p][_];x.variants[a[k].color]=b}),x})),h=l[0].state?new nd(Object.fromEntries(l.map(f=>{var p;return[f.theme,(p=f.state)==null?void 0:p.getInternalStack(f.theme)]})),l[0].state.lang):void 0;return h&&td(c,h),c}function S4(...e){const t=e.map(()=>[]),n=e.length;for(let s=0;s<e[0].length;s++){const a=e.map(h=>h[s]),l=t.map(()=>[]);t.forEach((h,f)=>h.push(l[f]));const u=a.map(()=>0),c=a.map(h=>h[0]);for(;c.every(h=>h);){const h=Math.min(...c.map(f=>f.content.length));for(let f=0;f<n;f++){const p=c[f];p.content.length===h?(l[f].push(p),u[f]+=1,c[f]=a[f][u[f]]):(l[f].push({...p,content:p.content.slice(0,h)}),c[f]={...p,content:p.content.slice(h),offset:p.offset+h})}}}return t}const w4=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Cl{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Cl.prototype.normal={};Cl.prototype.property={};Cl.prototype.space=void 0;function Nw(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new Cl(n,s,t)}function Fm(e){return e.toLowerCase()}class On{constructor(t,n){this.attribute=n,this.property=t}}On.prototype.attribute="";On.prototype.booleanish=!1;On.prototype.boolean=!1;On.prototype.commaOrSpaceSeparated=!1;On.prototype.commaSeparated=!1;On.prototype.defined=!1;On.prototype.mustUseProperty=!1;On.prototype.number=!1;On.prototype.overloadedBoolean=!1;On.prototype.property="";On.prototype.spaceSeparated=!1;On.prototype.space=void 0;let C4=0;const Ze=Di(),Jt=Di(),Vm=Di(),Ee=Di(),Tt=Di(),Ma=Di(),Vn=Di();function Di(){return 2**++C4}const Gm=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ze,booleanish:Jt,commaOrSpaceSeparated:Vn,commaSeparated:Ma,number:Ee,overloadedBoolean:Vm,spaceSeparated:Tt},Symbol.toStringTag,{value:"Module"})),rm=Object.keys(Gm);class qp extends On{constructor(t,n,s,a){let l=-1;if(super(t,n),Zb(this,"space",a),typeof s=="number")for(;++l<rm.length;){const u=rm[l];Zb(this,rm[l],(s&Gm[u])===Gm[u])}}}qp.prototype.defined=!0;function Zb(e,t,n){n&&(e[t]=n)}function Va(e){const t={},n={};for(const[s,a]of Object.entries(e.properties)){const l=new qp(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(l.mustUseProperty=!0),t[s]=l,n[Fm(s)]=s,n[Fm(l.attribute)]=s}return new Cl(t,n,e.space)}const Tw=Va({properties:{ariaActiveDescendant:null,ariaAtomic:Jt,ariaAutoComplete:null,ariaBusy:Jt,ariaChecked:Jt,ariaColCount:Ee,ariaColIndex:Ee,ariaColSpan:Ee,ariaControls:Tt,ariaCurrent:null,ariaDescribedBy:Tt,ariaDetails:null,ariaDisabled:Jt,ariaDropEffect:Tt,ariaErrorMessage:null,ariaExpanded:Jt,ariaFlowTo:Tt,ariaGrabbed:Jt,ariaHasPopup:null,ariaHidden:Jt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Tt,ariaLevel:Ee,ariaLive:null,ariaModal:Jt,ariaMultiLine:Jt,ariaMultiSelectable:Jt,ariaOrientation:null,ariaOwns:Tt,ariaPlaceholder:null,ariaPosInSet:Ee,ariaPressed:Jt,ariaReadOnly:Jt,ariaRelevant:null,ariaRequired:Jt,ariaRoleDescription:Tt,ariaRowCount:Ee,ariaRowIndex:Ee,ariaRowSpan:Ee,ariaSelected:Jt,ariaSetSize:Ee,ariaSort:null,ariaValueMax:Ee,ariaValueMin:Ee,ariaValueNow:Ee,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Aw(e,t){return t in e?e[t]:t}function Lw(e,t){return Aw(e,t.toLowerCase())}const k4=Va({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ma,acceptCharset:Tt,accessKey:Tt,action:null,allow:null,allowFullScreen:Ze,allowPaymentRequest:Ze,allowUserMedia:Ze,alt:null,as:null,async:Ze,autoCapitalize:null,autoComplete:Tt,autoFocus:Ze,autoPlay:Ze,blocking:Tt,capture:null,charSet:null,checked:Ze,cite:null,className:Tt,cols:Ee,colSpan:null,content:null,contentEditable:Jt,controls:Ze,controlsList:Tt,coords:Ee|Ma,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ze,defer:Ze,dir:null,dirName:null,disabled:Ze,download:Vm,draggable:Jt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ze,formTarget:null,headers:Tt,height:Ee,hidden:Vm,high:Ee,href:null,hrefLang:null,htmlFor:Tt,httpEquiv:Tt,id:null,imageSizes:null,imageSrcSet:null,inert:Ze,inputMode:null,integrity:null,is:null,isMap:Ze,itemId:null,itemProp:Tt,itemRef:Tt,itemScope:Ze,itemType:Tt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ze,low:Ee,manifest:null,max:null,maxLength:Ee,media:null,method:null,min:null,minLength:Ee,multiple:Ze,muted:Ze,name:null,nonce:null,noModule:Ze,noValidate:Ze,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:Ze,optimum:Ee,pattern:null,ping:Tt,placeholder:null,playsInline:Ze,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ze,referrerPolicy:null,rel:Tt,required:Ze,reversed:Ze,rows:Ee,rowSpan:Ee,sandbox:Tt,scope:null,scoped:Ze,seamless:Ze,selected:Ze,shadowRootClonable:Ze,shadowRootDelegatesFocus:Ze,shadowRootMode:null,shape:null,size:Ee,sizes:null,slot:null,span:Ee,spellCheck:Jt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ee,step:null,style:null,tabIndex:Ee,target:null,title:null,translate:null,type:null,typeMustMatch:Ze,useMap:null,value:Jt,width:Ee,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Tt,axis:null,background:null,bgColor:null,border:Ee,borderColor:null,bottomMargin:Ee,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ze,declare:Ze,event:null,face:null,frame:null,frameBorder:null,hSpace:Ee,leftMargin:Ee,link:null,longDesc:null,lowSrc:null,marginHeight:Ee,marginWidth:Ee,noResize:Ze,noHref:Ze,noShade:Ze,noWrap:Ze,object:null,profile:null,prompt:null,rev:null,rightMargin:Ee,rules:null,scheme:null,scrolling:Jt,standby:null,summary:null,text:null,topMargin:Ee,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ee,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ze,disableRemotePlayback:Ze,prefix:null,property:null,results:Ee,security:null,unselectable:null},space:"html",transform:Lw}),E4=Va({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",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:Vn,accentHeight:Ee,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ee,amplitude:Ee,arabicForm:null,ascent:Ee,attributeName:null,attributeType:null,azimuth:Ee,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ee,by:null,calcMode:null,capHeight:Ee,className:Tt,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:Ee,diffuseConstant:Ee,direction:null,display:null,dur:null,divisor:Ee,dominantBaseline:null,download:Ze,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ee,enableBackground:null,end:null,event:null,exponent:Ee,externalResourcesRequired:null,fill:null,fillOpacity:Ee,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:Ma,g2:Ma,glyphName:Ma,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ee,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ee,horizOriginX:Ee,horizOriginY:Ee,id:null,ideographic:Ee,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ee,k:Ee,k1:Ee,k2:Ee,k3:Ee,k4:Ee,kernelMatrix:Vn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ee,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ee,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:Ee,overlineThickness:Ee,paintOrder:null,panose1:null,path:null,pathLength:Ee,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Tt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ee,pointsAtY:Ee,pointsAtZ:Ee,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Vn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Vn,rev:Vn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Vn,requiredFeatures:Vn,requiredFonts:Vn,requiredFormats:Vn,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:Ee,specularExponent:Ee,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ee,strikethroughThickness:Ee,string:null,stroke:null,strokeDashArray:Vn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ee,strokeOpacity:Ee,strokeWidth:null,style:null,surfaceScale:Ee,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Vn,tabIndex:Ee,tableValues:null,target:null,targetX:Ee,targetY:Ee,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Vn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ee,underlineThickness:Ee,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ee,values:null,vAlphabetic:Ee,vMathematical:Ee,vectorEffect:null,vHanging:Ee,vIdeographic:Ee,version:null,vertAdvY:Ee,vertOriginX:Ee,vertOriginY:Ee,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ee,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Aw}),Dw=Va({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()}}),Rw=Va({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Lw}),Ow=Va({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),j4=/[A-Z]/g,e0=/-[a-z]/g,N4=/^data[-\w.:]+$/i;function T4(e,t){const n=Fm(t);let s=t,a=On;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&N4.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(e0,L4);s="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!e0.test(l)){let u=l.replace(j4,A4);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=qp}return new a(s,t)}function A4(e){return"-"+e.toLowerCase()}function L4(e){return e.charAt(1).toUpperCase()}const D4=Nw([Tw,k4,Dw,Rw,Ow],"html"),Mw=Nw([Tw,E4,Dw,Rw,Ow],"svg"),t0={}.hasOwnProperty;function R4(e,t){const n=t||{};function s(a,...l){let u=s.invalid;const c=s.handlers;if(a&&t0.call(a,e)){const h=String(a[e]);u=t0.call(c,h)?c[h]:s.unknown}if(u)return u.call(this,a,...l)}return s.handlers=n.handlers||{},s.invalid=n.invalid,s.unknown=n.unknown,s}const O4=/["&'<>`]/g,M4=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,I4=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,P4=/[|\\{}()[\]^$+*?.]/g,n0=new WeakMap;function B4(e,t){if(e=e.replace(t.subset?z4(t.subset):O4,s),t.subset||t.escapeOnly)return e;return e.replace(M4,n).replace(I4,s);function n(a,l,u){return t.format((a.charCodeAt(0)-55296)*1024+a.charCodeAt(1)-56320+65536,u.charCodeAt(l+2),t)}function s(a,l,u){return t.format(a.charCodeAt(0),u.charCodeAt(l+1),t)}}function z4(e){let t=n0.get(e);return t||(t=H4(e),n0.set(e,t)),t}function H4(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(P4,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const $4=/[\dA-Fa-f]/;function U4(e,t,n){const s="&#x"+e.toString(16).toUpperCase();return n&&t&&!$4.test(String.fromCharCode(t))?s:s+";"}const F4=/\d/;function V4(e,t,n){const s="&#"+String(e);return n&&t&&!F4.test(String.fromCharCode(t))?s:s+";"}const G4=["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"],sm={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:"€"},W4=["cent","copy","divide","gt","lt","not","para","times"],Iw={}.hasOwnProperty,Wm={};let Jc;for(Jc in sm)Iw.call(sm,Jc)&&(Wm[sm[Jc]]=Jc);const q4=/[^\dA-Za-z]/;function K4(e,t,n,s){const a=String.fromCharCode(e);if(Iw.call(Wm,a)){const l=Wm[a],u="&"+l;return n&&G4.includes(l)&&!W4.includes(l)&&(!s||t&&t!==61&&q4.test(String.fromCharCode(t)))?u:u+";"}return""}function Y4(e,t,n){let s=U4(e,t,n.omitOptionalSemicolons),a;if((n.useNamedReferences||n.useShortestReferences)&&(a=K4(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!a)&&n.useShortestReferences){const l=V4(e,t,n.omitOptionalSemicolons);l.length<s.length&&(s=l)}return a&&(!n.useShortestReferences||a.length<s.length)?a:s}function Ia(e,t){return B4(e,Object.assign({format:Y4},t))}const X4=/^>|^->|<!--|-->|--!>|<!-$/g,Q4=[">"],J4=["<",">"];function Z4(e,t,n,s){return s.settings.bogusComments?"<?"+Ia(e.value,Object.assign({},s.settings.characterReferences,{subset:Q4}))+">":"<!--"+e.value.replace(X4,a)+"-->";function a(l){return Ia(l,Object.assign({},s.settings.characterReferences,{subset:J4}))}}function eM(e,t,n,s){return"<!"+(s.settings.upperDoctype?"DOCTYPE":"doctype")+(s.settings.tightDoctype?"":" ")+"html>"}function r0(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let s=0,a=n.indexOf(t);for(;a!==-1;)s++,a=n.indexOf(t,a+t.length);return s}function tM(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function nM(e){return e.join(" ").trim()}const rM=/[ \t\n\f\r]/g;function Kp(e){return typeof e=="object"?e.type==="text"?s0(e.value):!1:s0(e)}function s0(e){return e.replace(rM,"")===""}const on=Bw(1),Pw=Bw(-1),sM=[];function Bw(e){return t;function t(n,s,a){const l=n?n.children:sM;let u=(s||0)+e,c=l[u];if(!a)for(;c&&Kp(c);)u+=e,c=l[u];return c}}const iM={}.hasOwnProperty;function zw(e){return t;function t(n,s,a){return iM.call(e,n.tagName)&&e[n.tagName](n,s,a)}}const Yp=zw({body:oM,caption:im,colgroup:im,dd:dM,dt:uM,head:im,html:aM,li:cM,optgroup:hM,option:fM,p:lM,rp:i0,rt:i0,tbody:pM,td:a0,tfoot:gM,th:a0,thead:mM,tr:xM});function im(e,t,n){const s=on(n,t,!0);return!s||s.type!=="comment"&&!(s.type==="text"&&Kp(s.value.charAt(0)))}function aM(e,t,n){const s=on(n,t);return!s||s.type!=="comment"}function oM(e,t,n){const s=on(n,t);return!s||s.type!=="comment"}function lM(e,t,n){const s=on(n,t);return s?s.type==="element"&&(s.tagName==="address"||s.tagName==="article"||s.tagName==="aside"||s.tagName==="blockquote"||s.tagName==="details"||s.tagName==="div"||s.tagName==="dl"||s.tagName==="fieldset"||s.tagName==="figcaption"||s.tagName==="figure"||s.tagName==="footer"||s.tagName==="form"||s.tagName==="h1"||s.tagName==="h2"||s.tagName==="h3"||s.tagName==="h4"||s.tagName==="h5"||s.tagName==="h6"||s.tagName==="header"||s.tagName==="hgroup"||s.tagName==="hr"||s.tagName==="main"||s.tagName==="menu"||s.tagName==="nav"||s.tagName==="ol"||s.tagName==="p"||s.tagName==="pre"||s.tagName==="section"||s.tagName==="table"||s.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 cM(e,t,n){const s=on(n,t);return!s||s.type==="element"&&s.tagName==="li"}function uM(e,t,n){const s=on(n,t);return!!(s&&s.type==="element"&&(s.tagName==="dt"||s.tagName==="dd"))}function dM(e,t,n){const s=on(n,t);return!s||s.type==="element"&&(s.tagName==="dt"||s.tagName==="dd")}function i0(e,t,n){const s=on(n,t);return!s||s.type==="element"&&(s.tagName==="rp"||s.tagName==="rt")}function hM(e,t,n){const s=on(n,t);return!s||s.type==="element"&&s.tagName==="optgroup"}function fM(e,t,n){const s=on(n,t);return!s||s.type==="element"&&(s.tagName==="option"||s.tagName==="optgroup")}function mM(e,t,n){const s=on(n,t);return!!(s&&s.type==="element"&&(s.tagName==="tbody"||s.tagName==="tfoot"))}function pM(e,t,n){const s=on(n,t);return!s||s.type==="element"&&(s.tagName==="tbody"||s.tagName==="tfoot")}function gM(e,t,n){return!on(n,t)}function xM(e,t,n){const s=on(n,t);return!s||s.type==="element"&&s.tagName==="tr"}function a0(e,t,n){const s=on(n,t);return!s||s.type==="element"&&(s.tagName==="td"||s.tagName==="th")}const _M=zw({body:bM,colgroup:SM,head:vM,html:yM,tbody:wM});function yM(e){const t=on(e,-1);return!t||t.type!=="comment"}function vM(e){const t=new Set;for(const s of e.children)if(s.type==="element"&&(s.tagName==="base"||s.tagName==="title")){if(t.has(s.tagName))return!1;t.add(s.tagName)}const n=e.children[0];return!n||n.type==="element"}function bM(e){const t=on(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Kp(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function SM(e,t,n){const s=Pw(n,t),a=on(e,-1,!0);return n&&s&&s.type==="element"&&s.tagName==="colgroup"&&Yp(s,n.children.indexOf(s),n)?!1:!!(a&&a.type==="element"&&a.tagName==="col")}function wM(e,t,n){const s=Pw(n,t),a=on(e,-1);return n&&s&&s.type==="element"&&(s.tagName==="thead"||s.tagName==="tbody")&&Yp(s,n.children.indexOf(s),n)?!1:!!(a&&a.type==="element"&&a.tagName==="tr")}const Zc={name:[[`
|
|
125
|
+
\f\r &/=>`.split(""),`
|
|
126
|
+
\f\r "&'/=>\``.split("")],[`\0
|
|
127
|
+
\f\r "&'/<=>`.split(""),`\0
|
|
128
|
+
\f\r "&'/<=>\``.split("")]],unquoted:[[`
|
|
129
|
+
\f\r &>`.split(""),`\0
|
|
130
|
+
\f\r "&'<=>\``.split("")],[`\0
|
|
131
|
+
\f\r "&'<=>\``.split(""),`\0
|
|
132
|
+
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function CM(e,t,n,s){const a=s.schema,l=a.space==="svg"?!1:s.settings.omitOptionalTags;let u=a.space==="svg"?s.settings.closeEmptyElements:s.settings.voids.includes(e.tagName.toLowerCase());const c=[];let h;a.space==="html"&&e.tagName==="svg"&&(s.schema=Mw);const f=kM(s,e.properties),p=s.all(a.space==="html"&&e.tagName==="template"?e.content:e);return s.schema=a,p&&(u=!1),(f||!l||!_M(e,t,n))&&(c.push("<",e.tagName,f?" "+f:""),u&&(a.space==="svg"||s.settings.closeSelfClosing)&&(h=f.charAt(f.length-1),(!s.settings.tightSelfClosing||h==="/"||h&&h!=='"'&&h!=="'")&&c.push(" "),c.push("/")),c.push(">")),c.push(p),!u&&(!l||!Yp(e,t,n))&&c.push("</"+e.tagName+">"),c.join("")}function kM(e,t){const n=[];let s=-1,a;if(t){for(a in t)if(t[a]!==null&&t[a]!==void 0){const l=EM(e,a,t[a]);l&&n.push(l)}}for(;++s<n.length;){const l=e.settings.tightAttributes?n[s].charAt(n[s].length-1):void 0;s!==n.length-1&&l!=='"'&&l!=="'"&&(n[s]+=" ")}return n.join("")}function EM(e,t,n){const s=T4(e.schema,t),a=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,l=e.settings.allowDangerousCharacters?0:1;let u=e.quote,c;if(s.overloadedBoolean&&(n===s.attribute||n==="")?n=!0:(s.boolean||s.overloadedBoolean)&&(typeof n!="string"||n===s.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const h=Ia(s.attribute,Object.assign({},e.settings.characterReferences,{subset:Zc.name[a][l]}));return n===!0||(n=Array.isArray(n)?(s.commaSeparated?tM:nM)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?h:(e.settings.preferUnquoted&&(c=Ia(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Zc.unquoted[a][l]}))),c!==n&&(e.settings.quoteSmart&&r0(n,u)>r0(n,e.alternative)&&(u=e.alternative),c=u+Ia(n,Object.assign({},e.settings.characterReferences,{subset:(u==="'"?Zc.single:Zc.double)[a][l],attribute:!0}))+u),h+(c&&"="+c))}const jM=["<","&"];function Hw(e,t,n,s){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Ia(e.value,Object.assign({},s.settings.characterReferences,{subset:jM}))}function NM(e,t,n,s){return s.settings.allowDangerousHtml?e.value:Hw(e,t,n,s)}function TM(e,t,n,s){return s.all(e)}const AM=R4("type",{invalid:LM,unknown:DM,handlers:{comment:Z4,doctype:eM,element:CM,raw:NM,root:TM,text:Hw}});function LM(e){throw new Error("Expected node, not `"+e+"`")}function DM(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const RM={},OM={},MM=[];function IM(e,t){const n=t||RM,s=n.quote||'"',a=s==='"'?"'":'"';if(s!=='"'&&s!=="'")throw new Error("Invalid quote `"+s+"`, expected `'` or `\"`");return{one:PM,all:BM,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||w4,characterReferences:n.characterReferences||OM,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Mw:D4,quote:s,alternative:a}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function PM(e,t,n){return AM(e,t,n,this)}function BM(e){const t=[],n=e&&e.children||MM;let s=-1;for(;++s<n.length;)t[s]=this.one(n[s],s,e);return t.join("")}const o0=/\s+/g;function $w(e,t){var s;if(!t)return e;e.properties||(e.properties={}),(s=e.properties).class||(s.class=[]),typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(o0)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(o0);for(const a of n)a&&!e.properties.class.includes(a)&&e.properties.class.push(a);return e}const zM=/:?lang=["']([^"']+)["']/g,HM=/(?:```|~~~)([\w-]+)/g,$M=/\\begin\{([\w-]+)\}/g,UM=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function FM(e){const t=ed(e,!0).map(([a])=>a);function n(a){if(a===e.length)return{line:t.length-1,character:t.at(-1).length};let l=a,u=0;for(const c of t){if(l<c.length)break;l-=c.length,u++}return{line:u,character:l}}function s(a,l){let u=0;for(let c=0;c<a;c++)u+=t[c].length;return u+=l,u}return{lines:t,indexToPos:n,posToIndex:s}}function VM(e,t,n){const s=new Set;for(const l of e.matchAll(zM)){const u=l[1].toLowerCase().trim();u&&s.add(u)}for(const l of e.matchAll(HM)){const u=l[1].toLowerCase().trim();u&&s.add(u)}for(const l of e.matchAll($M)){const u=l[1].toLowerCase().trim();u&&s.add(u)}for(const l of e.matchAll(UM)){const u=l[1].toLowerCase().trim(),c=u.includes("/")?u.split("/").pop():u;c&&s.add(c)}if(!n)return[...s];const a=n.getBundledLanguages();return[...s].filter(l=>l&&a[l])}const GM=["color","background-color"];function WM(e,t){let n=0;const s=[];for(const a of t)a>n&&s.push({...e,content:e.content.slice(n,a),offset:e.offset+n}),n=a;return n<e.content.length&&s.push({...e,content:e.content.slice(n),offset:e.offset+n}),s}function qM(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((s,a)=>s-a);return n.length?e.map(s=>s.flatMap(a=>{const l=n.filter(u=>a.offset<u&&u<a.offset+a.content.length).map(u=>u-a.offset).sort((u,c)=>u-c);return l.length?WM(a,l):a})):e}function KM(e,t,n,s,a="css-vars"){const l={content:e.content,explanation:e.explanation,offset:e.offset},u=t.map(p=>ku(e.variants[p])),c=new Set(u.flatMap(p=>Object.keys(p))),h={},f=(p,m)=>{const _=m==="color"?"":m==="background-color"?"-bg":`-${m}`;return n+t[p]+(m==="color"?"":_)};return u.forEach((p,m)=>{for(const _ of c){const x=p[_]||"inherit";if(m===0&&s&&GM.includes(_))if(s==="light-dark()"&&u.length>1){const w=t.findIndex(y=>y==="light"),k=t.findIndex(y=>y==="dark");if(w===-1||k===-1)throw new At('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');h[_]=`light-dark(${u[w][_]||"inherit"}, ${u[k][_]||"inherit"})`,a==="css-vars"&&(h[f(m,_)]=x)}else h[_]=x;else a==="css-vars"&&(h[f(m,_)]=x)}}),l.htmlStyle=h,l}function ku(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&yn.Italic&&(t["font-style"]="italic"),e.fontStyle&yn.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&yn.Underline&&n.push("underline"),e.fontStyle&yn.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function qm(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function YM(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let l=function(c){if(typeof c=="number"){if(c<0||c>n.source.length)throw new At(`Invalid decoration offset: ${c}. Code length: ${n.source.length}`);return{...a.indexToPos(c),offset:c}}else{const h=a.lines[c.line];if(h===void 0)throw new At(`Invalid decoration position ${JSON.stringify(c)}. Lines length: ${a.lines.length}`);let f=c.character;if(f<0&&(f=h.length+f),f<0||f>h.length)throw new At(`Invalid decoration position ${JSON.stringify(c)}. Line ${c.line} length: ${h.length}`);return{...c,character:f,offset:a.posToIndex(c.line,f)}}};var s=l;const a=FM(n.source),u=(n.options.decorations||[]).map(c=>({...c,start:l(c.start),end:l(c.end)}));XM(u),e.set(n.meta,{decorations:u,converter:a,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){var s;if((s=this.options.decorations)!=null&&s.length)return qM(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 s=t(this),a=[...n.children].filter(m=>m.type==="element"&&m.tagName==="span");if(a.length!==s.converter.lines.length)throw new At(`Number of lines in code element (${a.length}) does not match the number of lines in the source (${s.converter.lines.length}). Failed to apply decorations.`);function l(m,_,x,w){const k=a[m];let y="",S=-1,v=-1;if(_===0&&(S=0),x===0&&(v=0),x===Number.POSITIVE_INFINITY&&(v=k.children.length),S===-1||v===-1)for(let E=0;E<k.children.length;E++)y+=Uw(k.children[E]),S===-1&&y.length===_&&(S=E+1),v===-1&&y.length===x&&(v=E+1);if(S===-1)throw new At(`Failed to find start index for decoration ${JSON.stringify(w.start)}`);if(v===-1)throw new At(`Failed to find end index for decoration ${JSON.stringify(w.end)}`);const b=k.children.slice(S,v);if(!w.alwaysWrap&&b.length===k.children.length)c(k,w,"line");else if(!w.alwaysWrap&&b.length===1&&b[0].type==="element")c(b[0],w,"token");else{const E={type:"element",tagName:"span",properties:{},children:b};c(E,w,"wrapper"),k.children.splice(S,b.length,E)}}function u(m,_){a[m]=c(a[m],_,"line")}function c(m,_,x){var y;const w=_.properties||{},k=_.transform||(S=>S);return m.tagName=_.tagName||"span",m.properties={...m.properties,...w,class:m.properties.class},(y=_.properties)!=null&&y.class&&$w(m,_.properties.class),m=k(m,x)||m,m}const h=[],f=s.decorations.sort((m,_)=>_.start.offset-m.start.offset||m.end.offset-_.end.offset);for(const m of f){const{start:_,end:x}=m;if(_.line===x.line)l(_.line,_.character,x.character,m);else if(_.line<x.line){l(_.line,_.character,Number.POSITIVE_INFINITY,m);for(let w=_.line+1;w<x.line;w++)h.unshift(()=>u(w,m));l(x.line,0,x.character,m)}}h.forEach(m=>m())}}}function XM(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new At(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let s=t+1;s<e.length;s++){const a=e[s],l=n.start.offset<=a.start.offset&&a.start.offset<n.end.offset,u=n.start.offset<a.end.offset&&a.end.offset<=n.end.offset,c=a.start.offset<=n.start.offset&&n.start.offset<a.end.offset,h=a.start.offset<n.end.offset&&n.end.offset<=a.end.offset;if(l||u||c||h){if(l&&u||c&&h||c&&n.start.offset===n.end.offset||u&&a.start.offset===a.end.offset)continue;throw new At(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(a.start)} intersect.`)}}}}function Uw(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(Uw).join(""):""}const QM=[YM()];function Eu(e){const t=JM(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...QM]}function JM(e){const t=[],n=[],s=[];for(const a of e)switch(a.enforce){case"pre":t.push(a);break;case"post":n.push(a);break;default:s.push(a)}return{pre:t,post:n,normal:s}}var wi=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],am={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function ZM(e,t){const n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){const s=e.indexOf("m",n);if(s!==-1)return{sequence:e.substring(n+2,s).split(";"),startPosition:n,position:s+1}}return{position:e.length}}function l0(e){const t=e.shift();if(t==="2"){const n=e.splice(0,3).map(s=>Number.parseInt(s));return n.length!==3||n.some(s=>Number.isNaN(s))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){const n=e.shift();if(n)return{type:"table",index:Number(n)}}}function eI(e){const t=[];for(;e.length>0;){const n=e.shift();if(!n)continue;const s=Number.parseInt(n);if(!Number.isNaN(s))if(s===0)t.push({type:"resetAll"});else if(s<=9)am[s]&&t.push({type:"setDecoration",value:am[s]});else if(s<=29){const a=am[s-20];a&&(t.push({type:"resetDecoration",value:a}),a==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(s<=37)t.push({type:"setForegroundColor",value:{type:"named",name:wi[s-30]}});else if(s===38){const a=l0(e);a&&t.push({type:"setForegroundColor",value:a})}else if(s===39)t.push({type:"resetForegroundColor"});else if(s<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:wi[s-40]}});else if(s===48){const a=l0(e);a&&t.push({type:"setBackgroundColor",value:a})}else s===49?t.push({type:"resetBackgroundColor"}):s===53?t.push({type:"setDecoration",value:"overline"}):s===55?t.push({type:"resetDecoration",value:"overline"}):s>=90&&s<=97?t.push({type:"setForegroundColor",value:{type:"named",name:wi[s-90+8]}}):s>=100&&s<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:wi[s-100+8]}})}return t}function tI(){let e=null,t=null,n=new Set;return{parse(s){const a=[];let l=0;do{const u=ZM(s,l),c=u.sequence?s.substring(l,u.startPosition):s.substring(l);if(c.length>0&&a.push({value:c,foreground:e,background:t,decorations:new Set(n)}),u.sequence){const h=eI(u.sequence);for(const f of h)f.type==="resetAll"?(e=null,t=null,n.clear()):f.type==="resetForegroundColor"?e=null:f.type==="resetBackgroundColor"?t=null:f.type==="resetDecoration"&&n.delete(f.value);for(const f of h)f.type==="setForegroundColor"?e=f.value:f.type==="setBackgroundColor"?t=f.value:f.type==="setDecoration"&&n.add(f.value)}l=u.position}while(l<s.length);return a}}}var nI={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 rI(e=nI){function t(c){return e[c]}function n(c){return`#${c.map(h=>Math.max(0,Math.min(h,255)).toString(16).padStart(2,"0")).join("")}`}let s;function a(){if(s)return s;s=[];for(let f=0;f<wi.length;f++)s.push(t(wi[f]));let c=[0,95,135,175,215,255];for(let f=0;f<6;f++)for(let p=0;p<6;p++)for(let m=0;m<6;m++)s.push(n([c[f],c[p],c[m]]));let h=8;for(let f=0;f<24;f++,h+=10)s.push(n([h,h,h]));return s}function l(c){return a()[c]}function u(c){switch(c.type){case"named":return t(c.name);case"rgb":return n(c.rgb);case"table":return l(c.index)}}return{value:u}}const sI=/#([0-9a-f]{3,8})/i,iI=/var\((--[\w-]+-ansi-[\w-]+)\)/,aI={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 oI(e,t,n){const s=Cu(e,n),a=ed(t),l=rI(Object.fromEntries(wi.map(c=>{var f;const h=`terminal.ansi${c[0].toUpperCase()}${c.substring(1)}`;return[c,((f=e.colors)==null?void 0:f[h])||aI[c]]}))),u=tI();return a.map(c=>u.parse(c[0]).map(h=>{let f,p;h.decorations.has("reverse")?(f=h.background?l.value(h.background):e.bg,p=h.foreground?l.value(h.foreground):e.fg):(f=h.foreground?l.value(h.foreground):e.fg,p=h.background?l.value(h.background):void 0),f=Vs(f,s),p=Vs(p,s),h.decorations.has("dim")&&(f=lI(f));let m=yn.None;return h.decorations.has("bold")&&(m|=yn.Bold),h.decorations.has("italic")&&(m|=yn.Italic),h.decorations.has("underline")&&(m|=yn.Underline),h.decorations.has("strikethrough")&&(m|=yn.Strikethrough),{content:h.value,offset:c[1],color:f,bgColor:p,fontStyle:m}}))}function lI(e){const t=e.match(sI);if(t){const s=t[1];if(s.length===8){const a=Math.round(Number.parseInt(s.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${s.slice(0,6)}${a}`}else{if(s.length===6)return`#${s}80`;if(s.length===4){const a=s[0],l=s[1],u=s[2],c=s[3];return`#${a}${a}${l}${l}${u}${u}${Math.round(Number.parseInt(`${c}${c}`,16)/2).toString(16).padStart(2,"0")}`}else if(s.length===3){const a=s[0],l=s[1],u=s[2];return`#${a}${a}${l}${l}${u}${u}80`}}}const n=e.match(iI);return n?`var(${n[1]}-dim)`:e}function Km(e,t,n={}){const s=e.resolveLangAlias(n.lang||"text"),{theme:a=e.getLoadedThemes()[0]}=n;if(!Ju(s)&&!Zu(a)&&s==="ansi"){const{theme:l}=e.setTheme(a);return oI(l,t,n)}return Ew(e,t,n)}function ju(e,t,n){let s,a,l,u,c,h;if("themes"in n){const{defaultColor:f="light",cssVariablePrefix:p="--shiki-",colorsRendering:m="css-vars"}=n,_=Object.entries(n.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,v)=>S.color===f?-1:v.color===f?1:0);if(_.length===0)throw new At("`themes` option must not be empty");const x=jw(e,t,n,Km);if(h=dl(x),f&&f!=="light-dark()"&&!_.some(S=>S.color===f))throw new At(`\`themes\` option must contain the defaultColor key \`${f}\``);const w=_.map(S=>e.getTheme(S.theme)),k=_.map(S=>S.color);l=x.map(S=>S.map(v=>KM(v,k,p,f,m))),h&&td(l,h);const y=_.map(S=>Cu(S.theme,n));a=c0(_,w,y,p,f,"fg",m),s=c0(_,w,y,p,f,"bg",m),u=`shiki-themes ${w.map(S=>S.name).join(" ")}`,c=f?void 0:[a,s].join(";")}else if("theme"in n){const f=Cu(n.theme,n);l=Km(e,t,n);const p=e.getTheme(n.theme);s=Vs(p.bg,f),a=Vs(p.fg,f),u=p.name,h=dl(l)}else throw new At("Invalid options, either `theme` or `themes` must be provided");return{tokens:l,fg:a,bg:s,themeName:u,rootStyle:c,grammarState:h}}function c0(e,t,n,s,a,l,u){return e.map((c,h)=>{const f=Vs(t[h][l],n[h])||"inherit",p=`${s+c.color}${l==="bg"?"-bg":""}:${f}`;if(h===0&&a){if(a==="light-dark()"&&e.length>1){const m=e.findIndex(x=>x.color==="light"),_=e.findIndex(x=>x.color==="dark");if(m===-1||_===-1)throw new At('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Vs(t[m][l],n[m])||"inherit"}, ${Vs(t[_][l],n[_])||"inherit"});${p}`}return f}return u==="css-vars"?p:null}).filter(c=>!!c).join(";")}const Fw=/^\s+$/,cI=/^(\s*)(.*?)(\s*)$/;function Nu(e,t,n,s={meta:{},options:n,codeToHast:(a,l)=>Nu(e,a,l),codeToTokens:(a,l)=>ju(e,a,l)}){var w,k;let a=t;for(const y of Eu(n))a=((w=y.preprocess)==null?void 0:w.call(s,a,n))||a;let{tokens:l,fg:u,bg:c,themeName:h,rootStyle:f,grammarState:p}=ju(e,a,n);const{mergeWhitespaces:m=!0,mergeSameStyleTokens:_=!1}=n;m===!0?l=dI(l):m==="never"&&(l=hI(l)),_&&(l=fI(l));const x={...s,get source(){return a}};for(const y of Eu(n))l=((k=y.tokens)==null?void 0:k.call(x,l))||l;return uI(l,{...n,fg:u,bg:c,themeName:h,rootStyle:n.rootStyle===!1?!1:n.rootStyle??f},x,p)}function uI(e,t,n,s=dl(e)){var k,y,S,v;const a=Eu(t),l=[],u={type:"root",children:[]},{structure:c="classic",tabindex:h="0"}=t,f={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?f.style=t.rootStyle:f.style=`background-color:${t.bg};color:${t.fg}`),h!==!1&&h!=null&&(f.tabindex=h.toString());for(const[b,E]of Object.entries(t.meta||{}))b.startsWith("_")||(f[b]=E);let p={type:"element",tagName:"pre",properties:f,children:[],data:t.data},m={type:"element",tagName:"code",properties:{},children:l};const _=[],x={...n,structure:c,addClassToHast:$w,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return u},get pre(){return p},get code(){return m},get lines(){return _}};if(e.forEach((b,E)=>{var L,A;E&&(c==="inline"?u.children.push({type:"element",tagName:"br",properties:{},children:[]}):c==="classic"&&l.push({type:"text",value:`
|
|
133
|
+
`}));let T={type:"element",tagName:"span",properties:{class:"line"},children:[]},N=0;for(const D of b){let B={type:"element",tagName:"span",properties:{...D.htmlAttrs},children:[{type:"text",value:D.content}]};const q=qm(D.htmlStyle||ku(D));q&&(B.properties.style=q);for(const W of a)B=((L=W==null?void 0:W.span)==null?void 0:L.call(x,B,E+1,N,T,D))||B;c==="inline"?u.children.push(B):c==="classic"&&T.children.push(B),N+=D.content.length}if(c==="classic"){for(const D of a)T=((A=D==null?void 0:D.line)==null?void 0:A.call(x,T,E+1))||T;_.push(T),l.push(T)}else c==="inline"&&_.push(T)}),c==="classic"){for(const b of a)m=((k=b==null?void 0:b.code)==null?void 0:k.call(x,m))||m;p.children.push(m);for(const b of a)p=((y=b==null?void 0:b.pre)==null?void 0:y.call(x,p))||p;u.children.push(p)}else if(c==="inline"){const b=[];let E={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const N of u.children)N.type==="element"&&N.tagName==="br"?(b.push(E),E={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(N.type==="element"||N.type==="text")&&E.children.push(N);b.push(E);let T={type:"element",tagName:"code",properties:{},children:b};for(const N of a)T=((S=N==null?void 0:N.code)==null?void 0:S.call(x,T))||T;u.children=[];for(let N=0;N<T.children.length;N++){N>0&&u.children.push({type:"element",tagName:"br",properties:{},children:[]});const L=T.children[N];L.type==="element"&&u.children.push(...L.children)}}let w=u;for(const b of a)w=((v=b==null?void 0:b.root)==null?void 0:v.call(x,w))||w;return s&&td(w,s),w}function dI(e){return e.map(t=>{const n=[];let s="",a;return t.forEach((l,u)=>{const c=!(l.fontStyle&&(l.fontStyle&yn.Underline||l.fontStyle&yn.Strikethrough));c&&Fw.test(l.content)&&t[u+1]?(a===void 0&&(a=l.offset),s+=l.content):s?(c?n.push({...l,offset:a,content:s+l.content}):n.push({content:s,offset:a},l),a=void 0,s=""):n.push(l)}),n})}function hI(e){return e.map(t=>t.flatMap(n=>{if(Fw.test(n.content))return n;const s=n.content.match(cI);if(!s)return n;const[,a,l,u]=s;if(!a&&!u)return n;const c=[{...n,offset:n.offset+a.length,content:l}];return a&&c.unshift({content:a,offset:n.offset}),u&&c.push({content:u,offset:n.offset+a.length+l.length}),c}))}function fI(e){return e.map(t=>{const n=[];for(const s of t){if(n.length===0){n.push({...s});continue}const a=n.at(-1),l=qm(a.htmlStyle||ku(a)),u=qm(s.htmlStyle||ku(s)),c=a.fontStyle&&(a.fontStyle&yn.Underline||a.fontStyle&yn.Strikethrough),h=s.fontStyle&&(s.fontStyle&yn.Underline||s.fontStyle&yn.Strikethrough);!c&&!h&&l===u?a.content+=s.content:n.push({...s})}return n})}const mI=IM;function pI(e,t,n){var l;const s={meta:{},options:n,codeToHast:(u,c)=>Nu(e,u,c),codeToTokens:(u,c)=>ju(e,u,c)};let a=mI(Nu(e,t,n,s));for(const u of Eu(n))a=((l=u.postprocess)==null?void 0:l.call(s,a,n))||a;return a}async function gI(e){const t=await d4(e);return{getLastGrammarState:(...n)=>g4(t,...n),codeToTokensBase:(n,s)=>Km(t,n,s),codeToTokensWithThemes:(n,s)=>jw(t,n,s),codeToTokens:(n,s)=>ju(t,n,s),codeToHast:(n,s)=>Nu(t,n,s),codeToHtml:(n,s)=>pI(t,n,s),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function xI(e){const t=e.langs,n=e.themes,s=e.engine;async function a(l){function u(m){var _;if(typeof m=="string"){if(m=((_=l.langAlias)==null?void 0:_[m])||m,yw(m))return[];const x=t[m];if(!x)throw new At(`Language \`${m}\` is not included in this bundle. You may want to load it from external source.`);return x}return m}function c(m){if(vw(m))return"none";if(typeof m=="string"){const _=n[m];if(!_)throw new At(`Theme \`${m}\` is not included in this bundle. You may want to load it from external source.`);return _}return m}const h=(l.themes??[]).map(m=>c(m)),f=(l.langs??[]).map(m=>u(m)),p=await gI({engine:l.engine??s(),...l,themes:h,langs:f});return{...p,loadLanguage(...m){return p.loadLanguage(...m.map(u))},loadTheme(...m){return p.loadTheme(...m.map(c))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return a}function _I(e){let t;async function n(s={}){if(t){const a=await t;return await Promise.all([a.loadTheme(...s.themes||[]),a.loadLanguage(...s.langs||[])]),a}else{t=e({...s,themes:[],langs:[]});const a=await t;return await Promise.all([a.loadTheme(...s.themes||[]),a.loadLanguage(...s.langs||[])]),a}}return n}function yI(e,t){const n=_I(e);async function s(a,l){var h;const u=await n({langs:[l.lang],themes:"theme"in l?[l.theme]:Object.values(l.themes)}),c=await((h=t==null?void 0:t.guessEmbeddedLanguages)==null?void 0:h.call(t,a,l.lang,u));return c&&await u.loadLanguage(...c),u}return{getSingletonHighlighter(a){return n(a)},async codeToHtml(a,l){return(await s(a,l)).codeToHtml(a,l)},async codeToHast(a,l){return(await s(a,l)).codeToHast(a,l)},async codeToTokens(a,l){return(await s(a,l)).codeToTokens(a,l)},async codeToTokensBase(a,l){return(await s(a,l)).codeToTokensBase(a,l)},async codeToTokensWithThemes(a,l){return(await s(a,l)).codeToTokensWithThemes(a,l)},async getLastGrammarState(a,l){return(await n({langs:[l.lang],themes:[l.theme]})).getLastGrammarState(a,l)}}}var vI=Ip({bundledLanguages:()=>zp,bundledLanguagesAlias:()=>Bp,bundledLanguagesBase:()=>Pp,bundledLanguagesInfo:()=>Yu,bundledThemes:()=>$p,bundledThemesInfo:()=>Hp,codeToHast:()=>Gw,codeToHtml:()=>Vw,codeToTokens:()=>Ww,codeToTokensBase:()=>qw,codeToTokensWithThemes:()=>Kw,createHighlighter:()=>rd,getLastGrammarState:()=>Xw,getSingletonHighlighter:()=>Yw});const rd=xI({langs:zp,themes:$p,engine:()=>(0,nw.createOnigurumaEngine)(Z(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:Vw,codeToHast:Gw,codeToTokens:Ww,codeToTokensBase:qw,codeToTokensWithThemes:Kw,getSingletonHighlighter:Yw,getLastGrammarState:Xw}=yI(rd,{guessEmbeddedLanguages:VM}),u0=4294967295;var bI=class{constructor(e,t={}){pe(this,"patterns");pe(this,"options");pe(this,"regexps");this.patterns=e,this.options=t;const{forgiving:n=!1,cache:s,regexConstructor:a}=t;if(!a)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(l=>{if(typeof l!="string")return l;const u=s==null?void 0:s.get(l);if(u){if(u instanceof RegExp)return u;if(n)return null;throw u}try{const c=a(l);return s==null||s.set(l,c),c}catch(c){if(s==null||s.set(l,c),n)return null;throw c}})}findNextMatchSync(e,t,n){const s=typeof e=="string"?e:e.content,a=[];function l(u,c,h=0){return{index:u,captureIndices:c.indices.map(f=>f==null?{start:u0,end:u0,length:0}:{start:f[0]+h,end:f[1]+h,length:f[1]-f[0]})}}for(let u=0;u<this.regexps.length;u++){const c=this.regexps[u];if(c)try{c.lastIndex=t;const h=c.exec(s);if(!h)continue;if(h.index===t)return l(u,h,0);a.push([u,h,0])}catch(h){if(this.options.forgiving)continue;throw h}}if(a.length){const u=Math.min(...a.map(c=>c[1].index));for(const[c,h,f]of a)if(h.index===u)return l(c,h,f)}return null}};function Ga(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function SI(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const Xp=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),dn=String.raw;function Wa(e,t){if(e==null)throw new Error(t??"Value expected");return e}const Qw=dn`\[\^?`,Jw=`c.? | C(?:-.?)?|${dn`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${dn`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${dn`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${dn`o\{[^\}]*\}?`}|${dn`\d{1,3}`}`,Qp=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,eu=new RegExp(dn`
|
|
134
|
+
\\ (?:
|
|
135
|
+
${Jw}
|
|
136
|
+
| [gk]<[^>]*>?
|
|
137
|
+
| [gk]'[^']*'?
|
|
138
|
+
| .
|
|
139
|
+
)
|
|
140
|
+
| \( (?:
|
|
141
|
+
\? (?:
|
|
142
|
+
[:=!>({]
|
|
143
|
+
| <[=!]
|
|
144
|
+
| <[^>]*>
|
|
145
|
+
| '[^']*'
|
|
146
|
+
| ~\|?
|
|
147
|
+
| #(?:[^)\\]|\\.?)*
|
|
148
|
+
| [^:)]*[:)]
|
|
149
|
+
)?
|
|
150
|
+
| \*[^\)]*\)?
|
|
151
|
+
)?
|
|
152
|
+
| (?:${Qp.source})+
|
|
153
|
+
| ${Qw}
|
|
154
|
+
| .
|
|
155
|
+
`.replace(/\s+/g,""),"gsu"),om=new RegExp(dn`
|
|
156
|
+
\\ (?:
|
|
157
|
+
${Jw}
|
|
158
|
+
| .
|
|
159
|
+
)
|
|
160
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
161
|
+
| ${Qw}
|
|
162
|
+
| &&
|
|
163
|
+
| .
|
|
164
|
+
`.replace(/\s+/g,""),"gsu");function wI(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 s=UI(n.flags),a=[s.extended],l={captureGroup:n.rules.captureGroup,getCurrentModX(){return a.at(-1)},numOpenGroups:0,popModX(){a.pop()},pushModX(m){a.push(m)},replaceCurrentModX(m){a[a.length-1]=m},singleline:n.rules.singleline};let u=[],c;for(eu.lastIndex=0;c=eu.exec(e);){const m=CI(l,e,c[0],eu.lastIndex);m.tokens?u.push(...m.tokens):m.token&&u.push(m.token),m.lastIndex!==void 0&&(eu.lastIndex=m.lastIndex)}const h=[];let f=0;u.filter(m=>m.type==="GroupOpen").forEach(m=>{m.kind==="capturing"?m.number=++f:m.raw==="("&&h.push(m)}),f||h.forEach((m,_)=>{m.kind="capturing",m.number=_+1});const p=f||h.length;return{tokens:u.map(m=>m.type==="EscapedNumber"?VI(m,p):m).flat(),flags:s}}function CI(e,t,n,s){const[a,l]=n;if(n==="["||n==="[^"){const u=kI(t,n,s);return{tokens:u.tokens,lastIndex:u.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(l))return{token:d0(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:MI(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:eC(n)}}if(l==="K")return{token:tC("keep",n)};if(l==="N"||l==="R")return{token:Ci("newline",n,{negate:l==="N"})};if(l==="O")return{token:Ci("any",n)};if(l==="X")return{token:Ci("text_segment",n)};const u=Zw(n,{inCharClass:!1});return Array.isArray(u)?{tokens:u}:{token:u}}if(a==="("){if(l==="*")return{token:zI(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(t[s]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:s+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:BI(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Da("group",n)};if(n==="(?>")return{token:Da("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Da(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Da("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Da("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:DI(n)}}if(e.getCurrentModX()){if(n==="#"){const u=t.indexOf(`
|
|
165
|
+
`,s);return{lastIndex:u===-1?t.length:u}}if(/^\s$/.test(n)){const u=/\s+/y;return u.lastIndex=s,{lastIndex:u.exec(t)?u.lastIndex:s}}}if(n===".")return{token:Ci("dot",n)};if(n==="^"||n==="$"){const u=e.singleline?{"^":dn`\A`,$:dn`\Z`}[n]:n;return{token:d0(u,n)}}return n==="|"?{token:jI(n)}:Qp.test(n)?{tokens:GI(n)}:{token:cs(Ga(n),n)}}function kI(e,t,n){const s=[h0(t[1]==="^",t)];let a=1,l;for(om.lastIndex=n;l=om.exec(e);){const u=l[0];if(u[0]==="["&&u[1]!==":")a++,s.push(h0(u[1]==="^",u));else if(u==="]"){if(s.at(-1).type==="CharacterClassOpen")s.push(cs(93,u));else if(a--,s.push(NI(u)),!a)break}else{const c=EI(u);Array.isArray(c)?s.push(...c):s.push(c)}}return{tokens:s,lastIndex:om.lastIndex||e.length}}function EI(e){if(e[0]==="\\")return Zw(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Xp.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Ci("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?TI(e):e==="&&"?AI(e):cs(Ga(e),e)}function Zw(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return PI(e);if("dDhHsSwW".includes(n))return HI(e);if(e.startsWith(dn`\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 $I(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const s=e.split(/\\x/).slice(1).map(u=>parseInt(u,16)),a=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(s)),l=new TextEncoder;return[...a].map(u=>{const c=[...l.encode(u)].map(h=>`\\x${h.toString(16)}`).join("");return cs(Ga(u),c)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return cs(FI(e),e);if(f0.has(n))return cs(f0.get(n),e);if(/\d/.test(n))return LI(t,e);if(e==="\\")throw new Error(dn`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return cs(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function jI(e){return{type:"Alternator",raw:e}}function d0(e,t){return{type:"Assertion",kind:e,raw:t}}function eC(e){return{type:"Backreference",raw:e}}function cs(e,t){return{type:"Character",value:e,raw:t}}function NI(e){return{type:"CharacterClassClose",raw:e}}function TI(e){return{type:"CharacterClassHyphen",raw:e}}function AI(e){return{type:"CharacterClassIntersector",raw:e}}function h0(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Ci(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function tC(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Wa(n.flags),raw:t}}function LI(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function DI(e){return{type:"GroupClose",raw:e}}function Da(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function RI(e,t,n,s){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:s}}function OI(e,t,n,s){return{type:"Quantifier",kind:e,min:t,max:n,raw:s}}function MI(e){return{type:"Subroutine",raw:e}}const II=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),f0=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function PI(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 cs(Ga(t.toUpperCase())-64,e)}function BI(e,t){let{on:n,off:s}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;s??(s="");const a=(t.getCurrentModX()||n.includes("x"))&&!s.includes("x"),l=p0(n),u=p0(s),c={};if(l&&(c.enable=l),u&&(c.disable=u),e.endsWith(")"))return t.replaceCurrentModX(a),tC("flags",e,{flags:c});if(e.endsWith(":"))return t.pushModX(a),t.numOpenGroups++,Da("group",e,{...(l||u)&&{flags:c}});throw new Error(`Unexpected flag modifier "${e}"`)}function zI(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:s,args:a}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(s==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const l=a?a.split(",").filter(p=>p!=="").map(p=>/^[+-]?\d+$/.test(p)?+p:p):[],[u,c,h]=l,f=II.has(n)?n.toLowerCase():"custom";switch(f){case"fail":case"mismatch":case"skip":if(l.length>0)throw new Error(`Named callout arguments not allowed "${l}"`);break;case"error":if(l.length>1)throw new Error(`Named callout allows only one argument "${l}"`);if(typeof u=="string")throw new Error(`Named callout argument must be a number "${u}"`);break;case"max":if(!l.length||l.length>2)throw new Error(`Named callout must have one or two arguments "${l}"`);if(typeof u=="string"&&!/^[A-Za-z_]\w*$/.test(u))throw new Error(`Named callout argument one must be a tag or number "${u}"`);if(l.length===2&&(typeof c=="number"||!/^[<>X]$/.test(c)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${c}"`);break;case"count":case"total_count":if(l.length>1)throw new Error(`Named callout allows only one argument "${l}"`);if(l.length===1&&(typeof u=="number"||!/^[<>X]$/.test(u)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${u}"`);break;case"cmp":if(l.length!==3)throw new Error(`Named callout must have three arguments "${l}"`);if(typeof u=="string"&&!/^[A-Za-z_]\w*$/.test(u))throw new Error(`Named callout argument one must be a tag or number "${u}"`);if(typeof c=="number"||!/^(?:[<>!=]=|[<>])$/.test(c))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${c}"`);if(typeof h=="string"&&!/^[A-Za-z_]\w*$/.test(h))throw new Error(`Named callout argument three must be a tag or number "${h}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${f}"`)}return RI(f,s??null,(a==null?void 0:a.split(","))??null,e)}function m0(e){let t=null,n,s;if(e[0]==="{"){const{minStr:a,maxStr:l}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,u=1e5;if(+a>u||l&&+l>u)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+a,s=l===void 0?+a:l===""?1/0:+l,n>s&&(t="possessive",[n,s]=[s,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,s=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return OI(t,n,s,e)}function HI(e){const t=e[1].toLowerCase();return Ci({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function $I(e){const{p:t,neg:n,value:s}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Ci("property",e,{value:s,negate:t==="P"&&!n||t==="p"&&!!n})}function p0(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 UI(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 s=e[n];if(!"imxDPSWy".includes(s))throw new Error(`Invalid flag "${s}"`);if(s==="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"}[s]]=!0}return t}function FI(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 VI(e,t){const{raw:n,inCharClass:s}=e,a=n.slice(1);if(!s&&(a!=="0"&&a.length===1||a[0]!=="0"&&+a<=t))return[eC(n)];const l=[],u=a.match(/^[0-7]+|\d/g);for(let c=0;c<u.length;c++){const h=u[c];let f;if(c===0&&h!=="8"&&h!=="9"){if(f=parseInt(h,8),f>127)throw new Error(dn`Octal encoded byte above 177 unsupported "${n}"`)}else f=Ga(h);l.push(cs(f,(c===0?"\\":"")+h))}return l}function GI(e){const t=[],n=new RegExp(Qp,"gy");let s;for(;s=n.exec(e);){const a=s[0];if(a[0]==="{"){const l=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(a);if(l){const{min:u,max:c}=l.groups;if(+u>+c&&a.endsWith("?")){n.lastIndex--,t.push(m0(a.slice(0,-1)));continue}}}t.push(m0(a))}return t}function nC(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(s=>t[s]===n[s])}function WI(e){return qI.has(e.type)}const qI=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function rC(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},s=wI(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),a=(_,x)=>{const w=s.tokens[l.nextIndex];switch(l.parent=_,l.nextIndex++,w.type){case"Alternator":return Ai();case"Assertion":return KI(w);case"Backreference":return YI(w,l);case"Character":return sd(w.value,{useLastValid:!!x.isCheckingRangeEnd});case"CharacterClassHyphen":return XI(w,l,x);case"CharacterClassOpen":return QI(w,l,x);case"CharacterSet":return JI(w,l);case"Directive":return sP(w.kind,{flags:w.flags});case"GroupOpen":return ZI(w,l,x);case"NamedCallout":return aP(w.kind,w.tag,w.arguments);case"Quantifier":return eP(w,l);case"Subroutine":return tP(w,l);default:throw new Error(`Unexpected token type "${w.type}"`)}},l={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:s.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:a},u=lP(iP(s.flags));let c=u.body[0];for(;l.nextIndex<s.tokens.length;){const _=a(c,{});_.type==="Alternative"?(u.body.push(_),c=_):c.body.push(_)}const{capturingGroups:h,hasNumberedRef:f,namedGroupsByName:p,subroutines:m}=l;if(f&&p.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:_}of m)if(typeof _=="number"){if(_>h.length)throw new Error("Subroutine uses a group number that's not defined");_&&(h[_-1].isSubroutined=!0)}else if(p.has(_)){if(p.get(_).length>1)throw new Error(dn`Subroutine uses a duplicate group name "\g<${_}>"`);p.get(_)[0].isSubroutined=!0}else throw new Error(dn`Subroutine uses a group name that's not defined "\g<${_}>"`);return u}function KI({kind:e}){return Ym(Wa({"^":"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===dn`\B`||e===dn`\Y`})}function YI({raw:e},t){const n=/^\\k[<']/.test(e),s=n?e.slice(3,-1):e.slice(1),a=(l,u=!1)=>{const c=t.capturingGroups.length;let h=!1;if(l>c)if(t.skipBackrefValidation)h=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Xm(u?c+1-l:l,{orphan:h})};if(n){const l=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(s);if(l)return a(+l.groups.num,!!l.groups.sign);if(/[-+]/.test(s))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(s))throw new Error(`Group name not defined to the left "${e}"`);return Xm(s)}return a(+s)}function XI(e,t,n){const{tokens:s,walk:a}=t,l=t.parent,u=l.body.at(-1),c=s[t.nextIndex];if(!n.isCheckingRangeEnd&&u&&u.type!=="CharacterClass"&&u.type!=="CharacterClassRange"&&c&&c.type!=="CharacterClassOpen"&&c.type!=="CharacterClassClose"&&c.type!=="CharacterClassIntersector"){const h=a(l,{...n,isCheckingRangeEnd:!0});if(u.type==="Character"&&h.type==="Character")return l.body.pop(),rP(u,h);throw new Error("Invalid character class range")}return sd(Ga("-"))}function QI({negate:e},t,n){const{tokens:s,walk:a}=t,l=[cu()],u=s[t.nextIndex];let c=_0(u);for(;c.type!=="CharacterClassClose";){if(c.type==="CharacterClassIntersector")l.push(cu()),t.nextIndex++;else{const f=l.at(-1);f.body.push(a(f,n))}c=_0(s[t.nextIndex],u)}const h=cu({negate:e});return l.length===1?h.body=l[0].body:(h.kind="intersection",h.body=l.map(f=>f.body.length===1?f.body[0]:f)),t.nextIndex++,h}function JI({kind:e,negate:t,value:n},s){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u}=s;if(e==="property"){const c=id(n);if(Xp.has(c)&&!(u!=null&&u.has(c)))e="posix",n=c;else return Ra(n,{negate:t,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u})}return e==="posix"?oP(n,{negate:t}):Qm(e,{negate:t})}function ZI(e,t,n){const{tokens:s,capturingGroups:a,namedGroupsByName:l,skipLookbehindValidation:u,walk:c}=t,h=cP(e),f=h.type==="AbsenceFunction",p=x0(h),m=p&&h.negate;if(h.type==="CapturingGroup"&&(a.push(h),h.name&&SI(l,h.name,[]).push(h)),f&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let _=y0(s[t.nextIndex]);for(;_.type!=="GroupClose";){if(_.type==="Alternator")h.body.push(Ai()),t.nextIndex++;else{const x=h.body.at(-1),w=c(x,{...n,isInAbsenceFunction:n.isInAbsenceFunction||f,isInLookbehind:n.isInLookbehind||p,isInNegLookbehind:n.isInNegLookbehind||m});if(x.body.push(w),(p||n.isInLookbehind)&&!u){const k="Lookbehind includes a pattern not allowed by Oniguruma";if(m||n.isInNegLookbehind){if(g0(w)||w.type==="CapturingGroup")throw new Error(k)}else if(g0(w)||x0(w)&&w.negate)throw new Error(k)}}_=y0(s[t.nextIndex])}return t.nextIndex++,h}function eP({kind:e,min:t,max:n},s){const a=s.parent,l=a.body.at(-1);if(!l||!WI(l))throw new Error("Quantifier requires a repeatable token");const u=iC(e,t,n,l);return a.body.pop(),u}function tP({raw:e},t){const{capturingGroups:n,subroutines:s}=t;let a=e.slice(3,-1);const l=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(a);if(l){const c=+l.groups.num,h=n.length;if(t.hasNumberedRef=!0,a={"":c,"+":h+c,"-":h+1-c}[l.groups.sign],a<1)throw new Error("Invalid subroutine number")}else a==="0"&&(a=0);const u=aC(a);return s.push(u),u}function nP(e,t){return{type:"AbsenceFunction",kind:e,body:kl(t==null?void 0:t.body)}}function Ai(e){return{type:"Alternative",body:oC(e==null?void 0:e.body)}}function Ym(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function Xm(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function sC(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!uP(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:kl(t==null?void 0:t.body)}}function sd(e,t){const n={useLastValid:!1,...t};if(e>1114111){const s=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${s}}"`):new Error(`Invalid code point out of range in JS "\\x{${s}}"`)}return{type:"Character",value:e}}function cu(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:oC(e==null?void 0:e.body)}}function rP(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Qm(e,t){const n=!!(t!=null&&t.negate),s={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(s.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(s.variableLength=!0),s}function sP(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Wa(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function iP(e){return{type:"Flags",...e}}function yr(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:kl(e==null?void 0:e.body)}}function Si(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:kl(e==null?void 0:e.body)}}function aP(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function oP(e,t){const n=!!(t!=null&&t.negate);if(!Xp.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function iC(e,t,n,s){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:s}}function lP(e,t){return{type:"Regex",body:kl(t==null?void 0:t.body),flags:e}}function aC(e){return{type:"Subroutine",ref:e}}function Ra(e,t){var a;const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let s=(a=n.unicodePropertyMap)==null?void 0:a.get(id(e));if(!s){if(n.normalizeUnknownPropertyNames)s=dP(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(dn`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:s??e,negate:n.negate}}function cP({flags:e,kind:t,name:n,negate:s,number:a}){switch(t){case"absence_repeater":return nP("repeater");case"atomic":return yr({atomic:!0});case"capturing":return sC(a,{name:n});case"group":return yr({flags:e});case"lookahead":case"lookbehind":return Si({behind:t==="lookbehind",negate:s});default:throw new Error(`Unexpected group kind "${t}"`)}}function kl(e){if(e===void 0)e=[Ai()];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 oC(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 g0(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function x0(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function uP(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function dP(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 id(e){return e.replace(/[- _]+/g,"").toLowerCase()}function _0(e,t){const n=t;return Wa(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function y0(e){return Wa(e,"Unclosed group")}function sl(e,t,n=null){function s(l,u){for(let c=0;c<l.length;c++){const h=a(l[c],u,c,l);c=Math.max(-1,c+h)}}function a(l,u=null,c=null,h=null){var S,v;let f=0,p=!1;const m={node:l,parent:u,key:c,container:h,root:e,remove(){tu(h).splice(Math.max(0,ka(c)+f),1),f--,p=!0},removeAllNextSiblings(){return tu(h).splice(ka(c)+1)},removeAllPrevSiblings(){const b=ka(c)+f;return f-=b,tu(h).splice(0,Math.max(0,b))},replaceWith(b,E={}){const T=!!E.traverse;h?h[Math.max(0,ka(c)+f)]=b:Wa(u,"Can't replace root node")[c]=b,T&&a(b,u,c,h),p=!0},replaceWithMultiple(b,E={}){const T=!!E.traverse;if(tu(h).splice(Math.max(0,ka(c)+f),1,...b),f+=b.length-1,T){let N=0;for(let L=0;L<b.length;L++)N+=a(b[L],u,ka(c)+L+N,h)}p=!0},skip(){p=!0}},{type:_}=l,x=t["*"],w=t[_],k=typeof x=="function"?x:x==null?void 0:x.enter,y=typeof w=="function"?w:w==null?void 0:w.enter;if(k==null||k(m,n),y==null||y(m,n),!p)switch(_){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":s(l.body,l);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":a(l.min,l,"min"),a(l.max,l,"max");break;case"Quantifier":a(l.body,l,"body");break;case"Regex":s(l.body,l),a(l.flags,l,"flags");break;default:throw new Error(`Unexpected node type "${_}"`)}return(S=w==null?void 0:w.exit)==null||S.call(w,m,n),(v=x==null?void 0:x.exit)==null||v.call(x,m,n),f}return a(e),e}function tu(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function ka(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const hP=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function fP(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function mP(e,t,n,s){return e.slice(0,t)+s+e.slice(t+n.length)}const lr=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Jp(e,t,n,s){const a=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),l=[!1];let u=0,c="";for(const h of e.matchAll(a)){const{0:f,groups:{$skip:p}}=h;if(!p&&(!s||s===lr.DEFAULT==!u)){n instanceof Function?c+=n(h,{context:u?lr.CHAR_CLASS:lr.DEFAULT,negated:l[l.length-1]}):c+=n;continue}f[0]==="["?(u++,l.push(f[1]==="^")):f==="]"&&u&&(u--,l.pop()),c+=f}return c}function lC(e,t,n,s){Jp(e,t,n,s)}function pP(e,t,n=0,s){if(!new RegExp(t,"su").test(e))return null;const a=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");a.lastIndex=n;let l=0,u;for(;u=a.exec(e);){const{0:c,groups:{$skip:h}}=u;if(!h&&(!s||s===lr.DEFAULT==!l))return u;c==="["?l++:c==="]"&&l&&l--,a.lastIndex==u.index&&a.lastIndex++}return null}function nu(e,t,n){return!!pP(e,t,0,n)}function gP(e,t){const n=/\\?./gsu;n.lastIndex=t;let s=e.length,a=0,l=1,u;for(;u=n.exec(e);){const[c]=u;if(c==="[")a++;else if(a)c==="]"&&a--;else if(c==="(")l++;else if(c===")"&&(l--,!l)){s=u.index;break}}return e.slice(t,s)}const v0=new RegExp(String.raw`(?<noncapturingStart>${hP})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function xP(e,t){const n=(t==null?void 0:t.hiddenCaptures)??[];let s=(t==null?void 0:t.captureTransfers)??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:s,hiddenCaptures:n};const a="(?>",l="(?:(?=(",u=[0],c=[];let h=0,f=0,p=NaN,m;do{m=!1;let _=0,x=0,w=!1,k;for(v0.lastIndex=Number.isNaN(p)?0:p+l.length;k=v0.exec(e);){const{0:y,index:S,groups:{capturingStart:v,noncapturingStart:b}}=k;if(y==="[")_++;else if(_)y==="]"&&_--;else if(y===a&&!w)p=S,w=!0;else if(w&&b)x++;else if(v)w?x++:(h++,u.push(h+f));else if(y===")"&&w){if(!x){f++;const E=h+f;if(e=`${e.slice(0,p)}${l}${e.slice(p+a.length,S)}))<$$${E}>)${e.slice(S+1)}`,m=!0,c.push(E),fP(n,E),s.size){const T=new Map;s.forEach((N,L)=>{T.set(L>=E?L+1:L,N.map(A=>A>=E?A+1:A))}),s=T}break}x--}}}while(m);return n.push(...c),e=Jp(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:_,groups:{backrefNum:x,wrappedBackrefNum:w}})=>{if(x){const k=+x;if(k>u.length-1)throw new Error(`Backref "${_}" greater than number of captures`);return`\\${u[k]}`}return`\\${w}`},lr.DEFAULT),{pattern:e,captureTransfers:s,hiddenCaptures:n}}const cC=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,lm=new RegExp(String.raw`
|
|
166
|
+
\\(?: \d+
|
|
167
|
+
| c[A-Za-z]
|
|
168
|
+
| [gk]<[^>]+>
|
|
169
|
+
| [pPu]\{[^\}]+\}
|
|
170
|
+
| u[A-Fa-f\d]{4}
|
|
171
|
+
| x[A-Fa-f\d]{2}
|
|
172
|
+
)
|
|
173
|
+
| \((?: \? (?: [:=!>]
|
|
174
|
+
| <(?:[=!]|[^>]+>)
|
|
175
|
+
| [A-Za-z\-]+:
|
|
176
|
+
| \(DEFINE\)
|
|
177
|
+
))?
|
|
178
|
+
| (?<qBase>${cC})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
179
|
+
| \\?.
|
|
180
|
+
`.replace(/\s+/g,""),"gsu");function _P(e){if(!new RegExp(`${cC}\\+`).test(e))return{pattern:e};const t=[];let n=null,s=null,a="",l=0,u;for(lm.lastIndex=0;u=lm.exec(e);){const{0:c,index:h,groups:{qBase:f,qMod:p,invalidQ:m}}=u;if(c==="[")l||(s=h),l++;else if(c==="]")l?l--:s=null;else if(!l)if(p==="+"&&a&&!a.startsWith("(")){if(m)throw new Error(`Invalid quantifier "${c}"`);let _=-1;if(/^\{\d+\}$/.test(f))e=mP(e,h+f.length,p,"");else{if(a===")"||a==="]"){const x=a===")"?n:s;if(x===null)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,x)}(?>${e.slice(x,h)}${f})${e.slice(h+c.length)}`}else e=`${e.slice(0,h-a.length)}(?>${a}${f})${e.slice(h+c.length)}`;_+=4}lm.lastIndex+=_}else c[0]==="("?t.push(h):c===")"&&(n=t.length?t.pop():null);a=c}return{pattern:e}}const or=String.raw,yP=or`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Jm=or`\(\?R=(?<rDepth>[^\)]+)\)|${yP}`,ad=or`\(\?<(?![=!])(?<captureName>[^>]+)>`,uC=or`${ad}|(?<unnamed>\()(?!\?)`,pi=new RegExp(or`${ad}|${Jm}|\(\?|\\?.`,"gsu"),cm="Cannot use multiple overlapping recursions";function vP(e,t){const{hiddenCaptures:n,mode:s}={hiddenCaptures:[],mode:"plugin",...t};let a=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(Jm,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if(s==="plugin"&&nu(e,or`\(\?\(DEFINE\)`,lr.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const l=[],u=nu(e,or`\\[1-9]`,lr.DEFAULT),c=new Map,h=[];let f=!1,p=0,m=0,_;for(pi.lastIndex=0;_=pi.exec(e);){const{0:x,groups:{captureName:w,rDepth:k,gRNameOrNum:y,gRDepth:S}}=_;if(x==="[")p++;else if(p)x==="]"&&p--;else if(k){if(b0(k),f)throw new Error(cm);if(u)throw new Error(`${s==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const v=e.slice(0,_.index),b=e.slice(pi.lastIndex);if(nu(b,Jm,lr.DEFAULT))throw new Error(cm);const E=+k-1;e=S0(v,b,E,!1,n,l,m),a=C0(a,v,E,l.length,0,m);break}else if(y){b0(S);let v=!1;for(const W of h)if(W.name===y||W.num===+y){if(v=!0,W.hasRecursedWithin)throw new Error(cm);break}if(!v)throw new Error(or`Recursive \g cannot be used outside the referenced group "${s==="external"?y:or`\g<${y}&R=${S}>`}"`);const b=c.get(y),E=gP(e,b);if(u&&nu(E,or`${ad}|\((?!\?)`,lr.DEFAULT))throw new Error(`${s==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const T=e.slice(b,_.index),N=E.slice(T.length+x.length),L=l.length,A=+S-1,D=S0(T,N,A,!0,n,l,m);a=C0(a,T,A,l.length-L,L,m);const B=e.slice(0,b),q=e.slice(b+E.length);e=`${B}${D}${q}`,pi.lastIndex+=D.length-x.length-T.length-N.length,h.forEach(W=>W.hasRecursedWithin=!0),f=!0}else if(w)m++,c.set(String(m),pi.lastIndex),c.set(w,pi.lastIndex),h.push({num:m,name:w});else if(x[0]==="("){const v=x==="(";v&&(m++,c.set(String(m),pi.lastIndex)),h.push(v?{num:m}:{})}else x===")"&&h.pop()}return n.push(...l),{pattern:e,captureTransfers:a,hiddenCaptures:n}}function b0(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 S0(e,t,n,s,a,l,u){const c=new Set;s&&lC(e+t,ad,({groups:{captureName:f}})=>{c.add(f)},lr.DEFAULT);const h=[n,s?c:null,a,l,u];return`${e}${w0(`(?:${e}`,"forward",...h)}(?:)${w0(`${t})`,"backward",...h)}${t}`}function w0(e,t,n,s,a,l,u){const h=p=>t==="forward"?p+2:n-p+2-1;let f="";for(let p=0;p<n;p++){const m=h(p);f+=Jp(e,or`${uC}|\\k<(?<backref>[^>]+)>`,({0:_,groups:{captureName:x,unnamed:w,backref:k}})=>{if(k&&s&&!s.has(k))return _;const y=`_$${m}`;if(w||x){const S=u+l.length+1;return l.push(S),bP(a,S),w?_:`(?<${x}${y}>`}return or`\k<${k}${y}>`},lr.DEFAULT)}return f}function bP(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function C0(e,t,n,s,a,l){if(e.size&&s){let u=0;lC(t,uC,()=>u++,lr.DEFAULT);const c=l-u+a,h=new Map;return e.forEach((f,p)=>{const m=(s-u*n)/n,_=u*n,x=p>c+u?p+s:p,w=[];for(const k of f)if(k<=c)w.push(k);else if(k>c+u+m)w.push(k+s);else if(k<=c+u)for(let y=0;y<=n;y++)w.push(k+u*y);else for(let y=0;y<=n;y++)w.push(k+_+m*y);h.set(x,w)}),h}return e}var sn=String.fromCodePoint,Ke=String.raw,br={},od=globalThis.RegExp;br.flagGroups=(()=>{try{new od("(?i:)")}catch{return!1}return!0})();br.unicodeSets=(()=>{try{new od("[[]]","v")}catch{return!1}return!0})();br.bugFlagVLiteralHyphenIsRange=br.unicodeSets?(()=>{try{new od(Ke`[\d\-a]`,"v")}catch{return!0}return!1})():!1;br.bugNestedClassIgnoresNegation=br.unicodeSets&&new od("[[^a]]","v").test("a");function Tu(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 hl(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function Zm(e,t){return k0[e]>=k0[t]}function SP(e,t){if(e==null)throw new Error(t??"Value expected");return e}var k0={ES2025:2025,ES2024:2024,ES2018:2018},wP={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function dC(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!wP[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=br.flagGroups?"ES2025":br.unicodeSets?"ES2024":"ES2018"),t}var CP="[ -\r ]",kP=new Set([sn(304),sn(305)]),ns=Ke`[\p{L}\p{M}\p{N}\p{Pc}]`;function hC(e){if(kP.has(e))return[e];const t=new Set,n=e.toLowerCase(),s=n.toUpperCase(),a=NP.get(n),l=EP.get(n),u=jP.get(n);return[...s].length===1&&t.add(s),u&&t.add(u),a&&t.add(a),t.add(n),l&&t.add(l),[...t]}var Zp=new Map(`C Other
|
|
181
|
+
Cc Control cntrl
|
|
182
|
+
Cf Format
|
|
183
|
+
Cn Unassigned
|
|
184
|
+
Co Private_Use
|
|
185
|
+
Cs Surrogate
|
|
186
|
+
L Letter
|
|
187
|
+
LC Cased_Letter
|
|
188
|
+
Ll Lowercase_Letter
|
|
189
|
+
Lm Modifier_Letter
|
|
190
|
+
Lo Other_Letter
|
|
191
|
+
Lt Titlecase_Letter
|
|
192
|
+
Lu Uppercase_Letter
|
|
193
|
+
M Mark Combining_Mark
|
|
194
|
+
Mc Spacing_Mark
|
|
195
|
+
Me Enclosing_Mark
|
|
196
|
+
Mn Nonspacing_Mark
|
|
197
|
+
N Number
|
|
198
|
+
Nd Decimal_Number digit
|
|
199
|
+
Nl Letter_Number
|
|
200
|
+
No Other_Number
|
|
201
|
+
P Punctuation punct
|
|
202
|
+
Pc Connector_Punctuation
|
|
203
|
+
Pd Dash_Punctuation
|
|
204
|
+
Pe Close_Punctuation
|
|
205
|
+
Pf Final_Punctuation
|
|
206
|
+
Pi Initial_Punctuation
|
|
207
|
+
Po Other_Punctuation
|
|
208
|
+
Ps Open_Punctuation
|
|
209
|
+
S Symbol
|
|
210
|
+
Sc Currency_Symbol
|
|
211
|
+
Sk Modifier_Symbol
|
|
212
|
+
Sm Math_Symbol
|
|
213
|
+
So Other_Symbol
|
|
214
|
+
Z Separator
|
|
215
|
+
Zl Line_Separator
|
|
216
|
+
Zp Paragraph_Separator
|
|
217
|
+
Zs Space_Separator
|
|
218
|
+
ASCII
|
|
219
|
+
ASCII_Hex_Digit AHex
|
|
220
|
+
Alphabetic Alpha
|
|
221
|
+
Any
|
|
222
|
+
Assigned
|
|
223
|
+
Bidi_Control Bidi_C
|
|
224
|
+
Bidi_Mirrored Bidi_M
|
|
225
|
+
Case_Ignorable CI
|
|
226
|
+
Cased
|
|
227
|
+
Changes_When_Casefolded CWCF
|
|
228
|
+
Changes_When_Casemapped CWCM
|
|
229
|
+
Changes_When_Lowercased CWL
|
|
230
|
+
Changes_When_NFKC_Casefolded CWKCF
|
|
231
|
+
Changes_When_Titlecased CWT
|
|
232
|
+
Changes_When_Uppercased CWU
|
|
233
|
+
Dash
|
|
234
|
+
Default_Ignorable_Code_Point DI
|
|
235
|
+
Deprecated Dep
|
|
236
|
+
Diacritic Dia
|
|
237
|
+
Emoji
|
|
238
|
+
Emoji_Component EComp
|
|
239
|
+
Emoji_Modifier EMod
|
|
240
|
+
Emoji_Modifier_Base EBase
|
|
241
|
+
Emoji_Presentation EPres
|
|
242
|
+
Extended_Pictographic ExtPict
|
|
243
|
+
Extender Ext
|
|
244
|
+
Grapheme_Base Gr_Base
|
|
245
|
+
Grapheme_Extend Gr_Ext
|
|
246
|
+
Hex_Digit Hex
|
|
247
|
+
IDS_Binary_Operator IDSB
|
|
248
|
+
IDS_Trinary_Operator IDST
|
|
249
|
+
ID_Continue IDC
|
|
250
|
+
ID_Start IDS
|
|
251
|
+
Ideographic Ideo
|
|
252
|
+
Join_Control Join_C
|
|
253
|
+
Logical_Order_Exception LOE
|
|
254
|
+
Lowercase Lower
|
|
255
|
+
Math
|
|
256
|
+
Noncharacter_Code_Point NChar
|
|
257
|
+
Pattern_Syntax Pat_Syn
|
|
258
|
+
Pattern_White_Space Pat_WS
|
|
259
|
+
Quotation_Mark QMark
|
|
260
|
+
Radical
|
|
261
|
+
Regional_Indicator RI
|
|
262
|
+
Sentence_Terminal STerm
|
|
263
|
+
Soft_Dotted SD
|
|
264
|
+
Terminal_Punctuation Term
|
|
265
|
+
Unified_Ideograph UIdeo
|
|
266
|
+
Uppercase Upper
|
|
267
|
+
Variation_Selector VS
|
|
268
|
+
White_Space space
|
|
269
|
+
XID_Continue XIDC
|
|
270
|
+
XID_Start XIDS`.split(/\s/).map(e=>[id(e),e])),EP=new Map([["s",sn(383)],[sn(383),"s"]]),jP=new Map([[sn(223),sn(7838)],[sn(107),sn(8490)],[sn(229),sn(8491)],[sn(969),sn(8486)]]),NP=new Map([Ps(453),Ps(456),Ps(459),Ps(498),...um(8072,8079),...um(8088,8095),...um(8104,8111),Ps(8124),Ps(8140),Ps(8188)]),TP=new Map([["alnum",Ke`[\p{Alpha}\p{Nd}]`],["alpha",Ke`\p{Alpha}`],["ascii",Ke`\p{ASCII}`],["blank",Ke`[\p{Zs}\t]`],["cntrl",Ke`\p{Cc}`],["digit",Ke`\p{Nd}`],["graph",Ke`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",Ke`\p{Lower}`],["print",Ke`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",Ke`[\p{P}\p{S}]`],["space",Ke`\p{space}`],["upper",Ke`\p{Upper}`],["word",Ke`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",Ke`\p{AHex}`]]);function AP(e,t){const n=[];for(let s=e;s<=t;s++)n.push(s);return n}function Ps(e){const t=sn(e);return[t.toLowerCase(),t]}function um(e,t){return AP(e,t).map(n=>Ps(n))}var fC=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function LP(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};mC(e);const s={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Zm(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};sl(e,DP,s);const a={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},l={currentFlags:a,prevFlags:null,globalFlags:a,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:s.subroutineRefMap};sl(e,RP,l);const u={groupsByName:l.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:l.reffedNodesByReferencer};return sl(e,OP,u),e._originMap=l.groupOriginByCopy,e._strategy=s.strategy,e}var DP={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:s,kind:a}=e;if(a==="repeater"){const l=yr();l.body[0].body.push(Si({negate:!0,body:s}),Ra("Any"));const u=yr();u.body[0].body.push(iC("greedy",0,1/0,l)),n(Wt(u,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:s}){const a=e.body.filter(l=>l.kind==="flags");for(let l=n+1;l<t.body.length;l++){const u=t.body[l];hl(s,u,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const s=gC(t.get(e));if(s){const a=yr({flags:s});a.body[0].body=e.body,e.body=[Wt(a,e)]}}}},Assertion({node:e,parent:t,key:n,container:s,root:a,remove:l,replaceWith:u},c){const{kind:h,negate:f}=e,{asciiWordBoundaries:p,avoidSubclass:m,supportedGNodes:_,wordIsAscii:x}=c;if(h==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${f?"Y":"y"}"`);if(h==="line_end")u(Wt(Si({body:[Ai({body:[Ym("string_end")]}),Ai({body:[sd(10)]})]}),t));else if(h==="line_start")u(Wt(rs(Ke`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(h==="search_start")if(_.has(e))a.flags.sticky=!0,l();else{const w=s[n-1];if(w&&HP(w))u(Wt(Si({negate:!0}),t));else{if(m)throw new Error(Ke`Uses "\G" in a way that requires a subclass`);u(Bs(Ym("string_start"),t)),c.strategy="clip_search"}}else if(!(h==="string_end"||h==="string_start"))if(h==="string_end_newline")u(Wt(rs(Ke`(?=\n?\z)`),t));else if(h==="word_boundary"){if(!x&&!p){const w=`(?:(?<=${ns})(?!${ns})|(?<!${ns})(?=${ns}))`,k=`(?:(?<=${ns})(?=${ns})|(?<!${ns})(?!${ns}))`;u(Wt(rs(f?k:w),t))}}else throw new Error(`Unexpected assertion kind "${h}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!hm(n)&&(n=dm(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:s}=e;s&&!hm(s)&&(s=dm(s,t),e.name=s),n.set(e.number,e),s&&n.set(s,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if(t.kind==="intersection"){const s=cu({body:[e]});n(Wt(s,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:s,minTargetEs2024:a,digitIsAscii:l,spaceIsAscii:u,wordIsAscii:c}){const{kind:h,negate:f,value:p}=e;if(l&&(h==="digit"||p==="digit")){n(Bs(Qm("digit",{negate:f}),t));return}if(u&&(h==="space"||p==="space")){n(Wt(fm(rs(CP),f),t));return}if(c&&(h==="word"||p==="word")){n(Bs(Qm("word",{negate:f}),t));return}if(h==="any")n(Bs(Ra("Any"),t));else if(h==="digit")n(Bs(Ra("Nd",{negate:f}),t));else if(h!=="dot")if(h==="text_segment"){if(s==="strict")throw new Error(Ke`Use of "\X" requires non-strict accuracy`);const m="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",_=Ke`\p{RI}{2}|${m}(?:\u200D${m})*`;n(Wt(rs(Ke`(?>\r\n|${a?Ke`\p{RGI_Emoji}`:_}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(h==="hex")n(Bs(Ra("AHex",{negate:f}),t));else if(h==="newline")n(Wt(rs(f?`[^
|
|
271
|
+
]`:`(?>\r
|
|
272
|
+
?|[
|
|
273
|
+
\v\f
\u2028\u2029])`),t));else if(h==="posix")if(!a&&(p==="graph"||p==="print")){if(s==="strict")throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);let m={graph:"!-~",print:" -~"}[p];f&&(m=`\0-${sn(m.codePointAt(0)-1)}${sn(m.codePointAt(2)+1)}-`),n(Wt(rs(`[${m}]`),t))}else n(Wt(fm(rs(TP.get(p)),f),t));else if(h==="property")Zp.has(id(p))||(e.key="sc");else if(h==="space")n(Bs(Ra("space",{negate:f}),t));else if(h==="word")n(Wt(fm(rs(ns),f),t));else throw new Error(`Unexpected character set kind "${h}"`)},Directive({node:e,parent:t,root:n,remove:s,replaceWith:a,removeAllPrevSiblings:l,removeAllNextSiblings:u}){const{kind:c,flags:h}=e;if(c==="flags")if(!h.enable&&!h.disable)s();else{const f=yr({flags:h});f.body[0].body=u(),a(Wt(f,t),{traverse:!0})}else if(c==="keep"){const f=n.body[0],m=n.body.length===1&&nC(f,{type:"Group"})&&f.body[0].body.length===1?f.body[0]:n;if(t.parent!==m||m.body.length>1)throw new Error(Ke`Uses "\K" in a way that's unsupported`);const _=Si({behind:!0});_.body[0].body=l(),a(Wt(_,t))}else throw new Error(`Unexpected directive kind "${c}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t!=null&&t.extended&&delete t.extended,n!=null&&n.extended&&delete n.extended,t!=null&&t.dotAll&&(n!=null&&n.dotAll)&&delete t.dotAll,t!=null&&t.ignoreCase&&(n!=null&&n.ignoreCase)&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:s}=e;if(s==="fail")n(Wt(Si({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${s.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=yr();t.body[0].body.push(e.body),e.body=Wt(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let s=!1,a=!1;for(const l of e.body)if(l.body.length===1&&l.body[0].kind==="search_start")l.body.pop();else{const u=_C(l.body);u?(s=!0,Array.isArray(u)?n.push(...u):n.push(u)):a=!0}s&&!a&&n.forEach(l=>t.add(l))},exit(e,{accuracy:t,passedLookbehind:n,strategy:s}){if(t==="strict"&&n&&s)throw new Error(Ke`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!hm(n)&&(n=dm(n,t),e.ref=n)}},RP={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:s,ref:a}=e;s||n.set(e,[...t.get(a).map(({node:l})=>l)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:s},{groupOriginByCopy:a,groupsByName:l,multiplexCapturesToLeftByRef:u,openRefs:c,reffedNodesByReferencer:h}){const f=a.get(e);if(f&&c.has(e.number)){const m=Bs(E0(e.number),t);h.set(m,c.get(e.number)),n(m);return}c.set(e.number,e),u.set(e.number,[]),e.name&&hl(u,e.name,[]);const p=u.get(e.name??e.number);for(let m=0;m<p.length;m++){const _=p[m];if(f===_.node||f&&f===_.origin||e===_.origin){p.splice(m,1);break}}if(u.get(e.number).push({node:e,origin:f}),e.name&&u.get(e.name).push({node:e,origin:f}),e.name){const m=hl(l,e.name,new Map);let _=!1;if(f)_=!0;else for(const x of m.values())if(!x.hasDuplicateNameToRemove){_=!0;break}l.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:_})}},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=Tu(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},s){const{isRecursive:a,ref:l}=e;if(a){let p=t;for(;(p=p.parent)&&!(p.type==="CapturingGroup"&&(p.name===l||p.number===l)););s.reffedNodesByReferencer.set(e,p);return}const u=s.subroutineRefMap.get(l),c=l===0,h=c?E0(0):pC(u,s.groupOriginByCopy,null);let f=h;if(!c){const p=gC(PP(u,_=>_.type==="Group"&&!!_.flags)),m=p?Tu(s.globalFlags,p):s.globalFlags;MP(m,s.currentFlags)||(f=yr({flags:BP(m)}),f.body[0].body.push(h))}n(Wt(f,t),{traverse:!c})}},OP={Backreference({node:e,parent:t,replaceWith:n},s){if(e.orphan){s.highestOrphanBackref=Math.max(s.highestOrphanBackref,e.ref);return}const l=s.reffedNodesByReferencer.get(e).filter(u=>IP(u,e));if(!l.length)n(Wt(Si({negate:!0}),t));else if(l.length>1){const u=yr({atomic:!0,body:l.reverse().map(c=>Ai({body:[Xm(c.number)]}))});n(Wt(u,t))}else e.ref=l[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let s=0;s<n;s++){const a=sC();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function mC(e){sl(e,{"*"({node:t,parent:n}){t.parent=n}})}function MP(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function IP(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const s=xC(n.parent);for(const a of s){if(a===n)break;if(a===e||yC(a,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function pC(e,t,n,s){const a=Array.isArray(e)?[]:{};for(const[l,u]of Object.entries(e))l==="parent"?a.parent=Array.isArray(n)?s:n:u&&typeof u=="object"?a[l]=pC(u,t,a,n):(l==="type"&&u==="CapturingGroup"&&t.set(a,t.get(e)??e),a[l]=u);return a}function E0(e){const t=aC(e);return t.isRecursive=!0,t}function PP(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function dm(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 gC(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:s})=>{t.forEach(a=>{var l,u;(l=s.enable)!=null&&l[a]&&(delete n.disable[a],n.enable[a]=!0),(u=s.disable)!=null&&u[a]&&(n.disable[a]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function BP({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 xC(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function _C(e){const t=e.find(n=>n.kind==="search_start"||$P(n,{negate:!1})||!zP(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 s of t.body){const a=_C(s.body);if(!a)return null;Array.isArray(a)?n.push(...a):n.push(a)}return n}return null}function yC(e,t){const n=xC(e)??[];for(const s of n)if(s===t||yC(s,t))return!0;return!1}function zP({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function HP(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function $P(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&nC(e.body[0],{type:"Assertion",kind:"search_start"})}function hm(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function rs(e,t){const s=rC(e,{...t,unicodePropertyMap:Zp}).body;return s.length>1||s[0].body.length>1?yr({body:s}):s[0].body[0]}function fm(e,t){return e.negate=t,e}function Bs(e,t){return e.parent=t,e}function Wt(e,t){return mC(e),e.parent=t,e}function UP(e,t){const n=dC(t),s=Zm(n.target,"ES2024"),a=Zm(n.target,"ES2025"),l=n.rules.recursionLimit;if(!Number.isInteger(l)||l<2||l>20)throw new Error("Invalid recursionLimit; use 2-20");let u=null,c=null;if(!a){const x=[e.flags.ignoreCase];sl(e,FP,{getCurrentModI:()=>x.at(-1),popModI(){x.pop()},pushModI(w){x.push(w)},setHasCasedChar(){x.at(-1)?u=!0:c=!0}})}const h={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||u)&&!c)};let f=e;const p={accuracy:n.accuracy,appliedGlobalFlags:h,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:f,originMap:e._originMap,recursionLimit:l,useAppliedIgnoreCase:!!(!a&&u&&c),useFlagMods:a,useFlagV:s,verbose:n.verbose};function m(x){return p.lastNode=f,f=x,SP(VP[x.type],`Unexpected node type "${x.type}"`)(x,p,m)}const _={pattern:e.body.map(m).join("|"),flags:m(e.flags),options:{...e.options}};return s||(delete _.options.force.v,_.options.disable.v=!0,_.options.unicodeSetsPlugin=null),_._captureTransfers=new Map,_._hiddenCaptures=[],p.captureMap.forEach((x,w)=>{x.hidden&&_._hiddenCaptures.push(w),x.transferTo&&hl(_._captureTransfers,x.transferTo,[]).push(w)}),_}var FP={"*":{enter({node:e},t){if(N0(e)){const n=t.getCurrentModI();t.pushModI(e.flags?Tu({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){N0(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){eg(sn(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),vC(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&fC.has(e.value)&&t.setHasCasedChar()}},VP={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?Ke`\B`:Ke`\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:s,name:a,number:l}=e,u={ignoreCase:t.currentFlags.ignoreCase},c=t.originMap.get(e);return c&&(u.hidden=!0,l>c.number&&(u.transferTo=c.number)),t.captureMap.set(l,u),`(${a?`?<${a}>`:""}${s.map(n).join("|")})`},Character({value:e},t){const n=sn(e),s=Ea(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(s!==n)return s;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&eg(n)){const a=hC(n);return t.inCharClass?a.join(""):a.length>1?`[${a.join("")}]`:a[0]}return n},CharacterClass(e,t,n){const{kind:s,negate:a,parent:l}=e;let{body:u}=e;if(s==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");br.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&u.some(T0)&&(u=[sd(45),...u.filter(f=>!T0(f))]);const c=()=>`[${a?"^":""}${u.map(n).join(s==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||br.bugNestedClassIgnoresNegation)&&!a){const p=u.filter(m=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(p.length){const m=yr(),_=m.body[0];return m.parent=l,_.parent=m,u=u.filter(x=>!p.includes(x)),e.body=u,u.length?(e.parent=_,_.body.push(e)):m.body.pop(),p.forEach(x=>{const w=Ai({body:[x]});x.parent=w,w.parent=m,m.body.push(w)}),n(m)}}t.inCharClass=!0;const f=c();return t.inCharClass=!1,f}const h=u[0];if(s==="union"&&!a&&h&&((!t.useFlagV||!t.verbose)&&l.kind==="union"&&!(br.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&l.kind==="intersection"&&u.length===1&&h.type!=="CharacterClassRange"))return u.map(n).join("");if(!t.useFlagV&&l.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return c()},CharacterClassRange(e,t){const n=e.min.value,s=e.max.value,a={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},l=Ea(n,a),u=Ea(s,a),c=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const h=vC(e);YP(h).forEach(p=>{c.add(Array.isArray(p)?`${Ea(p[0],a)}-${Ea(p[1],a)}`:Ea(p,a))})}return`${l}-${u}${[...c].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:s},a){if(e==="dot")return a.currentFlags.dotAll?a.appliedGlobalFlags.dotAll||a.useFlagMods?".":"[^]":Ke`[^\n]`;if(e==="digit")return t?Ke`\D`:Ke`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&fC.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?Ke`\P`:Ke`\p`}{${s?`${s}=`:""}${n}}`}if(e==="word")return t?Ke`\W`:Ke`\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:s},a,l){const u=a.currentFlags;n&&(a.currentFlags=Tu(u,n));const c=t.map(l).join("|"),h=!a.verbose&&t.length===1&&s.type!=="Quantifier"&&!e&&(!a.useFlagMods||!n)?c:`(?${XP(e,n,a.useFlagMods)}${c})`;return a.currentFlags=u,h},LookaroundAssertion({body:e,kind:t,negate:n},s,a){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(a).join("|")})`},Quantifier(e,t,n){return n(e.body)+QP(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const s=n.recursionLimit;return t===0?`(?R=${s})`:Ke`\g<${t}&R=${s}>`}},GP=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),WP=new Set(["-","\\","]","^","["]),qP=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),j0=new Map([[9,Ke`\t`],[10,Ke`\n`],[11,Ke`\v`],[12,Ke`\f`],[13,Ke`\r`],[8232,Ke`\u2028`],[8233,Ke`\u2029`],[65279,Ke`\uFEFF`]]),KP=new RegExp("^\\p{Cased}$","u");function eg(e){return KP.test(e)}function vC(e,t){const n=!!(t!=null&&t.firstOnly),s=e.min.value,a=e.max.value,l=[];if(s<65&&(a===65535||a>=131071)||s===65536&&a>=131071)return l;for(let u=s;u<=a;u++){const c=sn(u);if(!eg(c))continue;const h=hC(c).filter(f=>{const p=f.codePointAt(0);return p<s||p>a});if(h.length&&(l.push(...h),n))break}return l}function Ea(e,{escDigit:t,inCharClass:n,useFlagV:s}){if(j0.has(e))return j0.get(e);if(e<32||e>126&&e<160||e>262143||t&&JP(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=n?s?qP:WP:GP,l=sn(e);return(a.has(l)?"\\":"")+l}function YP(e){const t=e.map(a=>a.codePointAt(0)).sort((a,l)=>a-l),n=[];let s=null;for(let a=0;a<t.length;a++)t[a+1]===t[a]+1?s??(s=t[a]):s===null?n.push(t[a]):(n.push([s,t[a]]),s=null);return n}function XP(e,t,n){if(e)return">";let s="";if(t&&n){const{enable:a,disable:l}=t;s=(a!=null&&a.ignoreCase?"i":"")+(a!=null&&a.dotAll?"s":"")+(l?"-":"")+(l!=null&&l.ignoreCase?"i":"")+(l!=null&&l.dotAll?"s":"")}return`${s}:`}function QP({kind:e,max:t,min:n}){let s;return!n&&t===1?s="?":!n&&t===1/0?s="*":n===1&&t===1/0?s="+":n===t?s=`{${n}}`:s=`{${n},${t===1/0?"":t}}`,s+{greedy:"",lazy:"?",possessive:"+"}[e]}function N0({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function JP(e){return e>47&&e<58}function T0({type:e,value:t}){return e==="Character"&&t===45}var zs,os,ki,Hs,Ei,fl,ep,Gs,ZP=(Gs=class extends RegExp{constructor(n,s,a){var t=(...oz)=>(super(...oz),fi(this,fl),fi(this,zs,new Map),fi(this,os,null),fi(this,ki),fi(this,Hs,null),fi(this,Ei,null),pe(this,"rawOptions",{}),this);const l=!!(a!=null&&a.lazyCompile);if(n instanceof RegExp){if(a)throw new Error("Cannot provide options when copying a regexp");const u=n;t(u,s),pr(this,ki,u.source),u instanceof Gs&&(pr(this,zs,wn(u,zs)),pr(this,Hs,wn(u,Hs)),pr(this,Ei,wn(u,Ei)),this.rawOptions=u.rawOptions)}else{const u={hiddenCaptures:[],strategy:null,transfers:[],...a};t(l?"":n,s),pr(this,ki,n),pr(this,zs,t6(u.hiddenCaptures,u.transfers)),pr(this,Ei,u.strategy),this.rawOptions=a??{}}l||pr(this,os,this)}get source(){return wn(this,ki)||"(?:)"}exec(n){if(!wn(this,os)){const{lazyCompile:l,...u}=this.rawOptions;pr(this,os,new Gs(wn(this,ki),this.flags,u))}const s=this.global||this.sticky,a=this.lastIndex;if(wn(this,Ei)==="clip_search"&&s&&a){this.lastIndex=0;const l=vf(this,fl,ep).call(this,n.slice(a));return l&&(e6(l,a,n,this.hasIndices),this.lastIndex+=a),l}return vf(this,fl,ep).call(this,n)}},zs=new WeakMap,os=new WeakMap,ki=new WeakMap,Hs=new WeakMap,Ei=new WeakMap,fl=new WeakSet,ep=function(n){wn(this,os).lastIndex=this.lastIndex;const s=Xy(Gs.prototype,this,"exec").call(wn(this,os),n);if(this.lastIndex=wn(this,os).lastIndex,!s||!wn(this,zs).size)return s;const a=[...s];s.length=1;let l;this.hasIndices&&(l=[...s.indices],s.indices.length=1);const u=[0];for(let c=1;c<a.length;c++){const{hidden:h,transferTo:f}=wn(this,zs).get(c)??{};if(h?u.push(null):(u.push(s.length),s.push(a[c]),this.hasIndices&&s.indices.push(l[c])),f&&a[c]!==void 0){const p=u[f];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(s[p]=a[c],this.hasIndices&&(s.indices[p]=l[c]),s.groups){wn(this,Hs)||pr(this,Hs,n6(this.source));const m=wn(this,Hs).get(f);m&&(s.groups[m]=a[c],this.hasIndices&&(s.indices.groups[m]=l[c]))}}}return s},Gs);function e6(e,t,n,s){if(e.index+=t,e.input=n,s){const a=e.indices;for(let u=0;u<a.length;u++){const c=a[u];c&&(a[u]=[c[0]+t,c[1]+t])}const l=a.groups;l&&Object.keys(l).forEach(u=>{const c=l[u];c&&(l[u]=[c[0]+t,c[1]+t])})}}function t6(e,t){const n=new Map;for(const s of e)n.set(s,{hidden:!0});for(const[s,a]of t)for(const l of a)hl(n,l,{}).transferTo=s;return n}function n6(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let s=0,a=0,l;for(;l=t.exec(e);){const{0:u,groups:{capture:c,name:h}}=l;u==="["?s++:s?u==="]"&&s--:c&&(a++,h&&n.set(a,h))}return n}function r6(e,t){const n=s6(e,t);return n.options?new ZP(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function s6(e,t){const n=dC(t),s=rC(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Zp}),a=LP(s,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),l=UP(a,n),u=vP(l.pattern,{captureTransfers:l._captureTransfers,hiddenCaptures:l._hiddenCaptures,mode:"external"}),c=_P(u.pattern),h=xP(c.pattern,{captureTransfers:u.captureTransfers,hiddenCaptures:u.hiddenCaptures}),f={pattern:h.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${l.flags}${l.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const p=h.hiddenCaptures.sort((w,k)=>w-k),m=Array.from(h.captureTransfers),_=a._strategy,x=f.pattern.length>=n.lazyCompileLength;(p.length||m.length||_||x)&&(f.options={...p.length&&{hiddenCaptures:p},...m.length&&{transfers:m},..._&&{strategy:_},...x&&{lazyCompile:x}})}return f}function bC(e,t){return r6(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function i6(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>bC(n,{target:t.target})),{createScanner(n){return new bI(n,t)},createString(n){return{content:n}}}}J1(Ip({bundledLanguages:()=>zp,bundledLanguagesAlias:()=>Bp,bundledLanguagesBase:()=>Pp,bundledLanguagesInfo:()=>Yu,bundledThemes:()=>$p,bundledThemesInfo:()=>Hp,codeToHast:()=>Gw,codeToHtml:()=>Vw,codeToTokens:()=>Ww,codeToTokensBase:()=>qw,codeToTokensWithThemes:()=>Kw,createHighlighter:()=>rd,createJavaScriptRegexEngine:()=>i6,createOnigurumaEngine:()=>tw,defaultJavaScriptRegexConstructor:()=>bC,getLastGrammarState:()=>Xw,getSingletonHighlighter:()=>Yw,loadWasm:()=>Fp}),vI);let mm=null;const a6=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],o6=["github-dark-default","vitesse-light","monokai","dracula","nord"],l6={dark:"github-dark-default",light:"vitesse-light",monokai:"monokai",dracula:"dracula",nord:"nord"};function c6(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function u6(){return mm||(mm=rd({themes:o6,langs:a6})),mm}const Ko=new Map,d6=50;function h6(e,t,n){return`${e}|${t}|${n}`}async function SC(e,t,n="github-dark-default"){const s=h6(e,t,n),a=Ko.get(s);if(a)return a;const u=(await u6()).codeToHtml(e,{lang:t,theme:n,transformers:[c6()]});if(Ko.size>=d6){const c=Ko.keys().next().value;c&&Ko.delete(c)}return Ko.set(s,u),u}const f6={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 ld(e){var a;if(!e)return"text";const t=e.split("/").pop()??"",n=t.toLowerCase();if(n==="dockerfile")return"docker";if(n==="makefile")return"makefile";if(n==="cmakelists.txt")return"cmake";const s=(a=t.split(".").pop())==null?void 0:a.toLowerCase();return s?f6[s]??"text":"text"}function wC(){const e=Ut(n=>n.currentPreset);return Ut(n=>n.isCustom)?"github-dark-default":l6[e]??"github-dark-default"}function CC(e=2e3){const[t,n]=R.useState(!1),s=R.useCallback(async a=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(a);else{const l=document.createElement("textarea");l.value=a,l.style.position="fixed",l.style.left="-9999px",document.body.appendChild(l),l.select(),document.execCommand("copy"),document.body.removeChild(l)}n(!0),setTimeout(()=>n(!1),e)}catch(l){console.error("Failed to copy:",l)}},[e]);return{copied:t,copy:s}}const m6=R.memo(function({language:t,codeString:n,showSyntaxHighlighting:s}){const{copied:a,copy:l}=CC(),[u,c]=R.useState(null),h=wC(),f=R.useRef(n);return R.useEffect(()=>{s&&(f.current=n,SC(n,t,h).then(p=>{f.current===n&&c(p)}))},[n,t,h,s]),o.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[o.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:[o.jsx("span",{children:t}),o.jsx("button",{type:"button",onClick:p=>{p.preventDefault(),p.stopPropagation(),l(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:a?o.jsx(Mr,{}):o.jsx(ap,{})})]}),s&&u?o.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:u}}):o.jsx("div",{className:"overflow-x-auto",children:o.jsx("pre",{className:"my-0 px-4 py-3 overflow-x-auto font-mono text-sm whitespace-pre-wrap break-word",children:o.jsx("code",{className:`language-${t}`,children:n})})})]})});function p6(e,t){const n=e?"text-text-muted":"text-sky-400",s=e?"text-text-secondary":"text-amber-400";return{code({className:a,children:l,...u}){const c=/language-(\w+)/.exec(a||"");if(!c&&!String(l).includes(`
|
|
274
|
+
`)){const m=e?"text-text-muted":"text-accent-secondary";return o.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${m} font-mono text-xs`,...u,children:l})}const f=(c==null?void 0:c[1])||"text",p=String(l).replace(/\n$/,"");return o.jsx(m6,{language:f,codeString:p,showSyntaxHighlighting:t})},p({children:a}){const l=e?"text-text-muted":"text-text-primary";return o.jsx("p",{className:`${l} mb-1.5 last:mb-0 leading-tight`,children:a})},ul({children:a}){return o.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:a})},ol({children:a}){return o.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:a})},li({children:a}){const l=e?"text-text-muted":"text-text-primary";return o.jsx("li",{className:`${l} text-sm list-item`,children:a})},h1({children:a}){return o.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:a})},h2({children:a}){return o.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:a})},h3({children:a}){return o.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:a})},h4({children:a}){return o.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:a})},strong({children:a}){return o.jsx("strong",{className:`font-bold ${s}`,children:a})},em({children:a}){return o.jsx("em",{className:e?"italic text-text-secondary":"italic",children:a})},a({href:a,children:l}){return o.jsx("a",{href:a,className:"text-accent-primary hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:l})},blockquote({children:a}){const l=e?"text-text-muted":"text-text-secondary";return o.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${l} italic text-sm`,children:a})},table({children:a}){return o.jsx("div",{className:"overflow-x-auto my-1.5",children:o.jsx("table",{className:"min-w-full border border-border",children:a})})},th({children:a}){return o.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:a})},td({children:a}){return o.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:a})},hr(){return o.jsx("hr",{className:"border-border my-2"})},input({checked:a,...l}){return o.jsx("input",{type:"checkbox",checked:a,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...l})}}}const us=R.memo(function({content:t,className:n="",muted:s=!1}){const{showSyntaxHighlighting:a}=Ou(),l=R.useMemo(()=>{let c=g6(t);return c=x6(c),c},[t]),u=R.useMemo(()=>p6(s,a),[s,a]);return o.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:o.jsx(BR,{remarkPlugins:[Q5],components:u,children:l})})});function g6(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+:\s/gm,""),t}function x6(e){const t=/```/g,n=e.match(t);if(((n==null?void 0:n.length)??0)%2===1){const a=e.lastIndexOf("```");return e.slice(a+3).includes(`
|
|
275
|
+
`),e+"\n```"}return e}const _6=R.memo(function({content:t,variant:n="default"}){return n==="labeled"?o.jsxs("div",{className:"text-text-muted text-sm italic feed-item",children:[o.jsx("span",{className:"text-purple-400",children:"thinking:"}),o.jsx("div",{className:"ml-1.5 mt-0.5",children:o.jsx(us,{content:t})})]}):o.jsx("div",{className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item",children:o.jsx(us,{content:t,muted:!0})})});function kC({tool:e,className:t="w-4 h-4 text-text-muted flex-shrink-0"}){return e==="glob"||e==="grep"?o.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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"?o.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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"})}):o.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.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 za=R.memo(function({code:t,language:n,variant:s,showLineNumbers:a=!1,startLine:l=1}){const[u,c]=R.useState(null),h=wC(),f=R.useRef(t);if(R.useEffect(()=>{f.current=t,SC(t,n,h).then(m=>{f.current===t&&c(m)})},[t,n,h]),!u){const m=s==="inline"?"span":s==="block-nowrap"?"div":"pre";return o.jsx(m,{className:"language-",children:o.jsx("code",{className:"language-",children:t})})}if(s==="inline")return o.jsx("span",{dangerouslySetInnerHTML:{__html:u}});const p=a?"":"shiki-plain";return o.jsx("div",{className:p,style:{"--shiki-start":l},dangerouslySetInnerHTML:{__html:u}})});function EC({src:e,alt:t,isOpen:n,onClose:s}){return n?o.jsx(Dt,{isOpen:n,onClose:s,title:"",size:"full",children:o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})})}):null}const Au=R.memo(function({type:t,children:n}){const s=t==="removed"?"diff-removed-bg diff-removed-border":"diff-added-bg diff-added-border",a=t==="removed"?"line-through decoration-red-400/30":"";return o.jsx("div",{className:`border-l-[3px] ${s}`,children:o.jsx("div",{className:`min-w-0 py-3 ${a}`,children:o.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:n})})})}),y6=R.memo(function({oldString:t,newString:n,filePath:s}){const a=R.useMemo(()=>ld(s),[s]),l=t.length>0,u=n.length>0;return!l&&!u?o.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):o.jsxs("div",{className:"rounded overflow-hidden border border-border",children:[l&&o.jsx(Au,{type:"removed",children:o.jsx(za,{code:t,language:a,variant:"block",showLineNumbers:!0})}),u&&o.jsx(Au,{type:"added",children:o.jsx(za,{code:n,language:a,variant:"block",showLineNumbers:!0})})]})}),v6=R.memo(function({content:t,filePath:n}){const s=R.useMemo(()=>ld(n),[n]);return o.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto",children:o.jsx(Au,{type:"added",children:o.jsx(za,{code:t,language:s,variant:"block",showLineNumbers:!0})})})}),b6=R.memo(function({regions:t,filePath:n}){const s=R.useMemo(()=>ld(n),[n]);return t.length===0?o.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):o.jsx("div",{className:"space-y-2",children:t.map((a,l)=>o.jsx(w6,{region:a,language:s},l))})});function S6(e){const t=[];function n(s,a,l){const u=t[t.length-1];u&&u.type===s&&u.startLine+u.lines.length===a?u.lines.push(l):t.push({type:s,startLine:a,lines:[l]})}for(const s of e.beforeContext)n("context",s.lineNumber,s.content);for(const s of e.edits){const a=s.oldContent.split(`
|
|
276
|
+
`);for(let u=0;u<a.length;u++)n("removed",s.startLine+u,a[u]);const l=s.newContent.split(`
|
|
277
|
+
`);for(let u=0;u<l.length;u++)n("added",s.startLine+u,l[u])}for(const s of e.afterContext)n("context",s.lineNumber,s.content);return t}const w6=R.memo(function({region:t,language:n}){const s=S6(t);return o.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:s.map((a,l)=>o.jsx(C6,{section:a,language:n},l))})}),C6=R.memo(function({section:t,language:n}){const s=t.lines.join(`
|
|
278
|
+
`);return t.type==="context"?o.jsx("div",{children:o.jsx("div",{className:"min-w-0 py-3",children:o.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:o.jsx(za,{code:s,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):o.jsx(Au,{type:t.type,children:o.jsx(za,{code:s,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function A0(e){return e.split(`
|
|
279
|
+
`).filter(t=>!t.startsWith(`
|
|
280
|
+
[`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+: /,"")).join(`
|
|
281
|
+
`)}const k6=R.memo(function({result:t,metadata:n,filePath:s,heightExpanded:a=!1}){const[l,u]=R.useState(!1),c=R.useMemo(()=>ld(s),[s]),h=n==null?void 0:n.mimeType,f=n==null?void 0:n.base64Data;if(h!=null&&h.startsWith("image/")&&f){const k=`data:${h};base64,${f}`;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`rounded overflow-hidden border border-border ${a?"":"max-h-[45vh]"} flex items-center justify-center cursor-pointer hover:border-accent-primary transition-colors`,onClick:()=>u(!0),children:o.jsx("img",{src:k,alt:s,className:"max-w-full max-h-[45vh] object-contain"})}),o.jsx(EC,{src:k,alt:s,isOpen:l,onClose:()=>u(!1)})]})}if(!t)return o.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});const p=t;if(c==="markdown"){const k=A0(p);return o.jsx("div",{className:`rounded overflow-hidden border border-border ${a?"":"max-h-[45vh]"} overflow-y-auto p-2`,children:o.jsx(us,{content:k})})}const m=A0(p),_=p.split(`
|
|
282
|
+
`)[0],x=_==null?void 0:_.match(/^(\d+): /),w=x?parseInt(x[1],10):1;return o.jsx("div",{className:`rounded overflow-hidden border border-border ${a?"":"max-h-[45vh]"} overflow-y-auto`,children:o.jsx(za,{code:m,language:c,variant:"block",showLineNumbers:!0,startLine:w})})}),E6={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"}},L0=R.memo(function({diagnostics:t}){if(t.length===0)return null;const n=t.filter(l=>l.severity==="error"),s=t.filter(l=>l.severity==="warning"),a=t.filter(l=>l.severity==="info"||l.severity==="hint");return o.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[o.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[o.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&o.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),s.length>0&&o.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[s.length," warning",s.length!==1?"s":""]}),a.length>0&&o.jsxs("span",{className:"text-xs text-text-muted",children:[a.length," info"]})]}),o.jsx("div",{className:"max-h-48 overflow-y-auto",children:t.map((l,u)=>{const c=E6[l.severity];return o.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${c.bg} border-b border-border last:border-b-0`,children:[o.jsx("span",{className:`${c.color} text-xs flex-shrink-0 w-4 text-center`,children:c.icon}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",l.range.start.line+1,":",l.range.start.character+1]}),l.code&&o.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",l.code,"]"]})]}),o.jsx("div",{className:"text-xs text-text-primary break-words",children:l.message})]})]},u)})})]})}),j6=R.memo(function({command:t,timeout:n,startedAt:s,streamingOutput:a,status:l,result:u,error:c,durationMs:h}){const f=R.useRef(null),[p,m]=R.useState(0);R.useEffect(()=>{f.current&&l==="pending"&&(f.current.scrollTop=f.current.scrollHeight)},[a,l]),R.useEffect(()=>{if(l!=="pending"||!s)return;const k=setInterval(()=>{m(Date.now()-s)},100);return()=>clearInterval(k)},[l,s]);const _=n/1e3,x=l==="pending"?p/1e3:(h??0)/1e3,w=l==="pending"?(a==null?void 0:a.map(k=>k.content).join(""))??"":u??"";return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[o.jsx("span",{className:"text-text-muted flex-shrink-0",children:"$"}),o.jsx("code",{className:"text-text-primary break-all",children:t})]}),o.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted flex-shrink-0",children:[l==="pending"&&o.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),l==="interrupted"&&o.jsx("span",{className:"text-red-400",children:"interrupted"}),o.jsxs("span",{className:l==="pending"?"text-text-secondary":"text-text-muted",children:[x.toFixed(1),"s / ",_,"s"]})]})]}),l==="pending"&&o.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:o.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,p/n*100)}%`}})}),(w||l==="pending")&&o.jsx("pre",{ref:f,className:`text-xs bg-bg-primary p-2 rounded max-h-64 overflow-y-auto ${l==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:l==="pending"&&a?a.map((k,y)=>o.jsx("span",{className:k.stream==="stderr"?"text-accent-warning":"",children:mu(k.content)},y)):mu(w)}),l==="error"&&c&&o.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:c}),l!=="pending"&&h!==void 0&&o.jsxs("div",{className:"text-[10px] text-text-muted",children:["Completed in ",(h/1e3).toFixed(2),"s"]})]})});function N6(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 T6({confirmation:e}){const t=we(m=>m.confirmPath),n=we(m=>m.currentSession),s=we(m=>m.switchDangerLevel),{title:a,description:l}=N6(e.reason),u=e.reason==="sensitive_file"||e.reason==="both",c=u?"border-red-500/50":"border-amber-500/50",h=u?"bg-red-500/10":"bg-amber-500/10",f=e.reason==="git_no_verify",p=()=>{n!=null&&n.id&&s("dangerous"),t(e.callId,!0,!1)};return o.jsxs("div",{className:`border ${c} ${h} rounded p-3 my-2`,children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx(bm,{}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:`text-sm font-medium ${u?"text-red-400":"text-amber-400"}`,children:a}),o.jsx("div",{className:"text-xs text-text-muted",children:l})]})]}),o.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[o.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),o.jsx("div",{className:"bg-bg-primary rounded p-2 mb-3 max-h-24 overflow-y-auto",children:o.jsx("ul",{className:"space-y-0.5",children:e.paths.map((m,_)=>o.jsx("li",{className:`text-xs font-mono ${u?"text-red-300":"text-amber-300"} break-all`,children:m},_))})}),o.jsxs("div",{className:"flex gap-2",children:[o.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"}),o.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"}),o.jsx("button",{onClick:p,className:`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors ${f?"hidden":"bg-red-600 hover:bg-red-700 text-white"}`,title:"Enable dangerous mode and allow this request",children:"Allow Everything"})]})]})}function A6(e,t){if(e==="read_file"){const s=String(t.path??""),a=t.offset,l=t.limit,u=[];return a!==void 0&&a!==1&&u.push(`offset=${a}`),l!==void 0&&u.push(`limit=${l}`),u.length>0?`${s} [${u.join(", ")}]`:s}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 s=String(t.content??"");return s.length>60?s.slice(0,60)+"...":s}const n=JSON.stringify(t);return n.length>50?n.slice(0,50)+"...":n}function D0(e,t,n){return A6(e,t)}function L6(e){return JSON.stringify(e,null,2)}const D6={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-red-400",animate:!1}},R6=R.memo(function({tool:t,args:n,status:s,variant:a="compact",forceCompact:l,result:u,error:c,durationMs:h,diagnostics:f,editContext:p,startedAt:m,streamingOutput:_,metadata:x,callId:w}){var q;const k=t==="edit_file"||t==="write_file",y=t==="run_command"&&s==="pending",S=t==="read_file",b=l?!1:k||y||t==="return_value",[E,T]=R.useState(b),N=D6[s],L=an(W=>W.settings[ze.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",A=t==="edit_file"?(q=p==null?void 0:p.regions[0])==null?void 0:q.startLine:t==="read_file"?(()=>{const W=u==null?void 0:u.split(`
|
|
283
|
+
`)[0],O=W==null?void 0:W.match(/^(\d+): /);return O?parseInt(O[1],10):void 0})():void 0,D=we(W=>W.pendingPathConfirmations),B=s==="pending"&&w?D.find(W=>W.callId===w)??null:null;return a==="compact"?o.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-secondary rounded px-2 py-1.5",children:[o.jsx(kC,{tool:t}),o.jsx("span",{className:"text-accent-primary font-medium",children:t}),o.jsx("span",{className:"text-text-muted truncate flex-1",children:D0(t,n)}),o.jsx("span",{className:`${N.color} ${N.animate?"animate-pulse":""}`,children:s==="pending"?"...":"done"})]}):o.jsxs("div",{className:"border border-border rounded overflow-hidden my-1 min-w-0",children:[o.jsxs("button",{className:"w-full flex items-center gap-1.5 p-2 bg-secondary hover:bg-secondary/80 text-left",onClick:()=>T(!E),children:[o.jsx("span",{className:`${N.color} ${N.animate?"animate-pulse":""}`,children:N.icon}),o.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),o.jsx("span",{className:"text-text-muted text-xs flex-1 truncate",children:D0(t,n)}),o.jsx("span",{className:"text-text-muted text-xs",children:E?"▼":"▶"})]}),B&&o.jsx(T6,{confirmation:B}),(E||S)&&o.jsxs("div",{className:"p-2 bg-primary border-t border-border space-y-2 min-w-0",children:[t==="run_command"&&o.jsx(j6,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:m,streamingOutput:_,status:s,result:u,error:c,durationMs:h}),t==="edit_file"&&s==="success"&&o.jsxs(o.Fragment,{children:[p&&p.regions.length>0?o.jsx(b6,{regions:p.regions,filePath:String(n.path??"")}):o.jsx(y6,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),f&&f.length>0&&o.jsx(L0,{diagnostics:f})]}),t==="write_file"&&s==="success"&&o.jsxs(o.Fragment,{children:[o.jsx(v6,{content:String(n.content??""),filePath:String(n.path??"")}),f&&f.length>0&&o.jsx(L0,{diagnostics:f})]}),t==="read_file"&&s==="success"&&o.jsx(k6,{result:u,metadata:x,filePath:String(n.path??""),heightExpanded:E}),t==="return_value"&&(()=>{const W=(_==null?void 0:_.map(V=>V.content).join(""))??"",O=s==="pending"&&W?W:String(n.content??"");return o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),o.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:o.jsx(us,{content:O})})]})})(),t!=="edit_file"&&t!=="write_file"&&t!=="run_command"&&t!=="read_file"&&t!=="return_value"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),o.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto",children:L6(n)})]}),s==="success"&&u!==void 0&&o.jsxs("div",{children:[o.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",h!==void 0&&` (${h}ms)`,":"]}),o.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-32",children:u||"No output"})]})]}),s==="success"&&(t==="edit_file"||t==="write_file"||t==="read_file")&&h!==void 0&&o.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-2",children:[o.jsxs("span",{children:["Completed in ",h,"ms"]}),L&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String(n.path??"")&&o.jsx("a",{href:`vscode://file/${String(n.path)}${A?`:${A}`:""}`,className:"text-accent-primary hover:underline ml-auto",children:"Open in VSCode"})]}),s==="error"&&c&&t!=="run_command"&&o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),o.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error",children:c})]})]})]})}),O6={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"},M6={criteria:"criteria",review_findings:"review findings",todos:"tasks"};function I6(e,t){const n=O6[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const a=JSON.parse(t).key;if(a){const l=M6[a]??a;return`${n} ${l}`}}catch{}return n}function P6(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 B6=R.memo(function({name:t,arguments:n}){let a=I6(t,n)+"...";if(t==="run_command"&&n){const l=P6(n);l&&(a=l)}return o.jsx("div",{className:"border border-border rounded overflow-hidden my-1 min-w-0 animate-pulse",children:o.jsxs("div",{className:"flex items-center gap-1.5 p-2 bg-bg-tertiary",children:[o.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),o.jsx(kC,{tool:t}),o.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),t==="run_command"&&n?o.jsx("code",{className:"text-text-muted text-xs flex-1 truncate",children:a}):o.jsx("span",{className:"text-text-muted text-xs flex-1",children:a})]})})}),z6={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},H6=R.memo(function({todos:t}){return Array.isArray(t)?t.length===0?o.jsx("div",{className:"text-xs text-text-muted italic my-1",children:"No tasks"}):o.jsxs("div",{className:"my-1 rounded border border-border bg-bg-tertiary overflow-hidden",children:[o.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-bg-secondary",children:o.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Tasks"})}),o.jsx("div",{children:t.map((n,s)=>{const a=z6[n.status];return o.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${s>0?"border-t border-border":""}`,children:[o.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)??"○"}),o.jsx("span",{className:`text-sm leading-tight ${n.status==="completed"?"text-text-muted":"text-text-primary"}`,children:n.content})]},s)})})]}):o.jsx("div",{className:"text-xs text-accent-warning italic my-1",children:"⚠️ Invalid todos data"})}),R0={add:{icon:"○",color:"text-text-muted"},update:{icon:"○",color:"text-text-muted"},remove:{icon:"○",color:"text-text-muted"},complete:{icon:"◉",color:"text-purple-400"},pass:{icon:"✓",color:"text-accent-success"},fail:{icon:"✗",color:"text-accent-error"},get:{icon:"○",color:"text-text-muted"},list:{icon:"○",color:"text-text-muted"},schema:{icon:"○",color:"text-text-muted"}},jC=R.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const s=new Map((n==null?void 0:n.map(h=>[h.id,h]))??[]),a=t.find(h=>{var f,p;return h.arguments.action==="get"&&((f=h.result)==null?void 0:f.success)&&((p=h.result)==null?void 0:p.output)}),l=t.some(h=>h.name==="session_metadata"),u={criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"},c=(()=>{if(!l)return"Acceptance Criteria";const h=new Set(t.map(f=>f.arguments.key).filter(Boolean));if(h.size===1){const f=h.values().next().value;return f?u[f]??f:"Session Data"}return"Session Data"})();return o.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[o.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-secondary",children:o.jsx("span",{className:"text-xs font-medium text-text-muted",children:c})}),o.jsx("div",{className:"bg-primary",children:a?(()=>{const h=a.result.output;if(h==="No criteria defined yet.")return o.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5",children:[o.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),o.jsx("div",{className:"flex-1 min-w-0 text-text-muted text-sm",children:"No criteria defined yet."})]});try{return JSON.parse(h).map((p,m)=>o.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${m>0?"border-t border-border":""}`,children:[o.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx(us,{content:`[${p.id}] ${p.description}`})})]},p.id??m))}catch{return t.map((f,p)=>o.jsx(O0,{tc:f,index:p,criteriaMap:s},f.id??p))}})():t.map((h,f)=>o.jsx(O0,{tc:h,index:f,criteriaMap:s},h.id??f))})]})});function O0({tc:e,index:t,criteriaMap:n}){const s=e.arguments.action,a=e.arguments,l=e.name==="session_metadata",u=s==="remove",c=a.id,h=a.description,f=c?n.get(c):void 0,p=h??(f==null?void 0:f.description)??(u&&c?`[${c}]`:"Criterion updated"),m=a.reason,_=s==="fail";return o.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${t>0?"border-t border-border":""}`,children:[l?o.jsx(Fu,{status:a.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const x=s&&R0[s]?R0[s]:{icon:"○",color:"text-text-muted"};return o.jsx("span",{className:`${x.color} text-sm leading-tight flex-shrink-0`,children:x.icon})})(),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:u?"line-through text-text-muted":"",children:o.jsx(us,{content:p})}),m&&o.jsxs("div",{className:`mt-1 text-sm ${_?"text-accent-error":"text-text-muted"}`,children:[o.jsx("span",{className:"text-text-muted",children:"└ "}),'"',m,'"']})]})]})}function $6(e){return e==="criterion"||e==="session_metadata"}function U6(e){const t=[];let n=[];const s=()=>{n.length>0&&(t.push({type:"criteria_group",toolCalls:n}),n=[])};for(const a of e)a.type==="tool_call"&&$6(a.toolCall.name)?n.push(a.toolCall):(s(),t.push(a));return s(),t}function F6(e,t){if(e.segments&&e.segments.length>0)return V6(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 s of e.toolCalls)n.push({type:"tool_call",toolCall:s});if(e.preparingToolCalls)for(const s of e.preparingToolCalls)n.push({type:"preparing_tool_call",preparing:s});return t&&e.stats&&n.push({type:"stats",stats:e.stats}),n}function V6(e,t,n,s,a){const l=[],u=new Map(t.map(c=>[c.id,c]));for(const c of e)switch(c.type){case"text":l.push({type:"text",content:c.content});break;case"thinking":c.content&&c.content.trim().length>0&&l.push({type:"thinking",content:c.content});break;case"tool_call":{const h=u.get(c.toolCallId);h&&l.push({type:"tool_call",toolCall:h});break}}for(const c of n)l.push({type:"preparing_tool_call",preparing:c});return a&&s&&l.push({type:"stats",stats:s}),l}const tg=R.memo(function({message:t,showStats:n=!0,showThinking:s=!0,showVerboseToolOutput:a=!0}){const l=we(_=>{var x,w;return(w=(x=_.currentSession)==null?void 0:x.metadataEntries)==null?void 0:w.criteria}),u=mt(_=>_.defaults),c=mt(_=>_.userItems),h=[...u,...c],f=F6(t,n),p=s?f:f.filter(_=>_.type!=="thinking"),m=U6(p);return m.length===0?null:o.jsx("div",{className:"feed-item",children:o.jsxs("div",{className:"min-w-0",children:[m.map((_,x)=>{var w,k;switch(_.type){case"thinking":return o.jsx(_6,{content:_.content},x);case"text":return o.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:o.jsx(us,{content:_.content})},x);case"preparing_tool_call":return o.jsx(B6,{name:_.preparing.name,arguments:_.preparing.arguments},`preparing-${_.preparing.index}`);case"tool_call":{const y=_.toolCall,S=y.result;if(y.name==="todo_write"){const E=y.arguments.todos,T=Array.isArray(E)?E:[];return o.jsx(H6,{todos:T},x)}const v=(w=S==null?void 0:S.output)==null?void 0:w.includes("[interrupted by user]"),b=S?v?"interrupted":S.success?"success":"error":"pending";return o.jsx(R6,{tool:y.name,args:y.arguments,status:b,variant:"expandable",forceCompact:!a,result:S==null?void 0:S.output,error:S==null?void 0:S.error,durationMs:S==null?void 0:S.durationMs,diagnostics:S==null?void 0:S.diagnostics,editContext:S==null?void 0:S.editContext,startedAt:y.startedAt,streamingOutput:y.streamingOutput,metadata:S==null?void 0:S.metadata,callId:y.id},x)}case"criteria_group":return o.jsx(jC,{toolCalls:_.toolCalls,criteria:l},x);case"stats":{const y=_.stats;if(!y||"error"in y)return null;const S=((k=y.model.split("/").pop())==null?void 0:k.split("-").slice(0,2).join("-"))??y.model,v=il(h,y.mode),b=T=>T>=1e3?`${(T/1e3).toFixed(1)}k`:T.toString(),E=T=>T>=1e3?`${(T/1e3).toFixed(1)}k`:T.toFixed(1);return o.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted mt-3",children:[o.jsx("span",{className:"flex-1 h-px bg-border"}),o.jsx("span",{className:"text-text-secondary",children:S}),o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsx("span",{style:{color:v},children:y.mode}),o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsxs("span",{children:[y.totalTime.toFixed(1),"s"]}),y.toolTime>0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsxs("span",{children:[y.toolTime.toFixed(1),"s tools"]})]}),o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsxs("span",{children:[b(y.prefillTokens)," @ ",E(y.prefillSpeed)," pp"]}),o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsxs("span",{children:[b(y.generationTokens)," @ ",E(y.generationSpeed)," tg"]}),o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsx("button",{type:"button",className:"text-text-muted hover:text-text-secondary transition-colors",title:"View detailed stats",onClick:()=>{const T=new CustomEvent("open-turn-stats",{detail:{stats:y}});window.dispatchEvent(T)},children:o.jsx(pS,{className:"w-3 h-3"})}),o.jsx("span",{className:"flex-1 h-px bg-border"})]},x)}}}),t.partial&&o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[o.jsx(bm,{}),o.jsx("span",{children:"Aborted"})]}),t.completeReason==="truncated"&&o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-amber-400/80 mt-1",children:[o.jsx(bm,{}),o.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]})})});function Lu(e,t){const n=parseInt(e.slice(1,3),16),s=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16);return`rgba(${n},${s},${a},${t})`}function G6(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),n=Math.round(e%60);return n>0?`${t}m ${n}s`:`${t}m`}function W6(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const q6=R.memo(function({data:t}){var u;const n=Et(c=>c.defaults),s=Et(c=>c.userItems),l=((u=[...n,...s].find(c=>c.id===t.workflowId))==null?void 0:u.color)??t.workflowColor??"#8b949e";return o.jsxs("div",{className:"feed-item rounded p-3 border",style:{borderColor:Lu(l,.3),backgroundColor:Lu(l,.08)},children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx(Rj,{color:l}),o.jsx("span",{className:"text-sm font-medium",style:{color:l},children:t.workflowName??"Task Completed"})]}),o.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-2",children:[o.jsx(Yo,{label:"Iterations",value:String(t.iterations)}),o.jsx(Yo,{label:"Total time",value:G6(t.totalTimeSeconds)}),o.jsx(Yo,{label:"Tool calls",value:String(t.totalToolCalls)}),o.jsx(Yo,{label:"Tokens",value:W6(t.totalTokensGenerated)}),o.jsx(Yo,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function Yo({label:e,value:t}){return o.jsxs("div",{className:"bg-bg-primary/50 rounded px-2 py-1",children:[o.jsx("div",{className:"text-sm text-text-muted",children:e}),o.jsx("div",{className:"text-sm text-text-primary font-medium",children:t})]})}const K6=R.memo(function({data:t}){var u;const n=Et(c=>c.defaults),s=Et(c=>c.userItems),l=((u=[...n,...s].find(c=>c.id===t.workflowId))==null?void 0:u.color)??t.workflowColor??"#6b7280";return o.jsxs("div",{className:"feed-item flex items-center gap-2 px-3 py-2 rounded border",style:{borderColor:Lu(l,.3),backgroundColor:Lu(l,.08)},children:[o.jsx(jj,{className:"w-3 h-3 shrink-0",color:l}),o.jsx("span",{className:"text-sm font-medium",style:{color:l},children:t.workflowName}),o.jsx("span",{className:"text-text-muted text-sm",children:"started"})]})});function Y6({attachments:e,messageId:t}){const[n,s]=R.useState(null),a=we(p=>p.visionFallbackByMessage),l=we(p=>p.messages),u=R.useMemo(()=>{const p=l.findIndex(m=>m.id===t);if(p===-1)return null;for(let m=p+1;m<l.length;m++){const _=l[m];if(_&&_.role==="assistant")return _.id}return null},[l,t]),c=p=>{s(p)},h=()=>{s(null)},f=p=>{const m=`${t}-${p}`;if(a[m])return a[m];if(u){const _=`${u}-${p}`;return a[_]}return null};return e.length===0?null:o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(p=>{const m=f(p.id);return o.jsxs("div",{className:"relative inline-block",children:[o.jsxs("button",{onClick:()=>c(p.data),className:"group relative inline-block",title:p.filename,disabled:(m==null?void 0:m.type)==="start",children:[o.jsx("img",{src:p.data,alt: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"&&o.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:o.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(m==null?void 0:m.type)==="done"&&m.description&&o.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)})}),n&&o.jsx(EC,{src:n,alt:"Attached image",isOpen:!0,onClose:h})]})}function X6({content:e,align:t="right",messageIndex:n,sessionId:s}){const[a,l]=R.useState(!1),[u,c]=R.useState(!1),[h,f]=R.useState("left"),p=R.useRef(null),m=R.useRef(null),_=we(S=>S.loadSession),x=t==="right",w=()=>{if(!m.current)return"left";const S=m.current.getBoundingClientRect(),v=window.innerWidth-S.right,b=S.left,E=160,T=v>=E,N=b>=E;return N&&T||N?"left":T?"right":b>=v?"left":"right"};R.useEffect(()=>{const S=v=>{p.current&&!p.current.contains(v.target)&&l(!1)};return a&&document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[a]);const k=async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(e);else{const S=document.createElement("textarea");S.value=e,S.style.position="fixed",S.style.left="-999999px",document.body.appendChild(S),S.select(),document.execCommand("copy"),document.body.removeChild(S)}c(!0),l(!1),window.setTimeout(()=>c(!1),1500)}catch(S){console.error("Failed to copy:",S)}},y=async()=>{!s||n===void 0||(l(!1),await g2(s,n),_(s))};return o.jsx(o.Fragment,{children:o.jsxs("div",{className:`flex items-start gap-1.5 ${x?"":"order-first"}`,children:[u&&o.jsx(Mr,{className:"w-4 h-4 text-accent-success"}),o.jsxs("div",{ref:p,className:"relative",children:[o.jsx("button",{ref:m,onClick:()=>{a||f(w()),l(!a)},className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary",title:"Message options",children:o.jsx(op,{})}),a&&o.jsxs("div",{className:`absolute top-full mt-1 bg-bg-secondary border border-border rounded shadow-xl z-50 py-1 min-w-36 ${h==="right"?"left-0":"right-0"}`,children:[o.jsxs("button",{onClick:k,className:"w-full px-3 py-1.5 text-left text-sm text-text-primary hover:bg-bg-tertiary flex items-center gap-2",children:[o.jsx(ap,{className:"w-4 h-4"}),"Copy"]}),s&&n!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-t border-border my-1"}),o.jsxs("button",{onClick:y,className:"w-full px-3 py-1.5 text-left text-sm text-text-primary hover:bg-bg-tertiary flex items-center gap-2",children:[o.jsx(lp,{className:"w-4 h-4"}),"Replay"]})]})]})]})]})})}function Q6({message:e}){const[t,n]=R.useState(!1);if(e.messageKind!=="auto-prompt")return null;const s=e.metadata,a=(s==null?void 0:s.color)??"#6b7280",l=(s==null?void 0:s.name)??"Agent",u=(s==null?void 0:s.type)??"agent",h={agent:(s==null?void 0:s.kind)==="reminder"?"reminder":"definition injected",workflow:"instructions",compaction:"prompt injected",subagent:"instructions"}[u]??"injected",f=u==="workflow"||u==="subagent";return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[o.jsx("span",{className:"flex-1 h-px bg-border"}),o.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${f?"":"cursor-pointer"}`,style:{backgroundColor:a},onClick:()=>!f&&n(!0)}),o.jsx("span",{className:f?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:a},onClick:()=>!f&&n(!0),children:l}),o.jsx("span",{children:"·"}),o.jsx("span",{className:f?"":"cursor-pointer hover:text-text-secondary transition-colors",onClick:()=>!f&&n(!0),children:h}),o.jsx("span",{className:"flex-1 h-px bg-border"})]}),f&&o.jsx("div",{className:"flex justify-center feed-item mb-4",children:o.jsx("div",{className:"max-w-[75%] rounded p-3 bg-bg-tertiary/50 text-text-secondary text-sm",style:{borderLeft:`3px solid ${a}`},children:o.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:e.content})})}),o.jsx(Dt,{isOpen:t,onClose:()=>n(!1),title:`${l} Prompt`,size:"lg",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:a}}),o.jsx("span",{className:"text-sm text-text-primary font-medium",children:l}),o.jsxs("span",{className:"text-xs text-text-muted",children:["(",u,")"]})]}),o.jsx("div",{className:"h-full min-h-96",children:o.jsx("pre",{className:"text-sm text-text-secondary whitespace-pre-wrap bg-bg-tertiary rounded p-4 h-full min-h-96 overflow-auto font-mono",children:e.content})})]})})]})}function J6({message:e,messageIndex:t,sessionId:n}){const s=e.messageKind==="auto-prompt",a=e.messageKind==="command",l=e.isSystemGenerated;return o.jsxs("div",{className:"flex justify-end items-start gap-1.5 feed-item",children:[!l&&o.jsx(X6,{content:e.content,align:"right",messageIndex:t,sessionId:n}),o.jsxs("div",{className:`max-w-[75%] rounded p-2 ${l?a?"bg-teal-500/10 border border-teal-500/30":s?"bg-slate-500/10 border border-slate-500/30":"bg-amber-500/10 border border-amber-500/30":"bg-accent-primary/15 text-text-primary"}`,children:[l&&o.jsx("span",{className:`text-[10px] block mb-0.5 ${a?"text-teal-400":s?"text-slate-400":"text-amber-400"}`,children:a?"Command":s?"Auto":"System"}),o.jsx("div",{className:`whitespace-pre-wrap text-sm ${l?`${a?"text-teal-200":s?"text-slate-200":"text-amber-200 italic"}`:""}`,children:e.content}),e.attachments&&e.attachments.length>0&&o.jsx(Y6,{attachments:e.attachments,messageId:e.id})]})]})}const NC=R.memo(function({message:t,isLastAssistantMessage:n=!1,messageIndex:s,sessionId:a}){const l=t.role==="user",u=t.role==="assistant",c=t.role==="system",h=t.role==="tool";if(u)return o.jsx(tg,{message:t,showStats:n});if(c&&t.isCompacted)return o.jsxs("div",{className:"feed-item bg-bg-tertiary/50 border border-border rounded p-2",children:[o.jsx("div",{className:"text-text-muted text-xs mb-0.5",children:"[Compacted]"}),o.jsx("div",{className:"text-text-secondary text-xs whitespace-pre-wrap",children:t.content.replace(`[COMPACTED HISTORY]
|
|
284
|
+
`,"")})]});if(h)return o.jsxs("div",{className:"feed-item bg-bg-tertiary/30 border-l-2 border-accent-primary rounded-r p-2",children:[o.jsxs("div",{className:"text-accent-primary text-xs mb-0.5",children:["Tool: ",t.toolName]}),o.jsxs("pre",{className:"text-text-secondary text-xs whitespace-pre-wrap overflow-x-auto max-h-32",children:[t.content.slice(0,500),t.content.length>500&&"..."]})]});if(t.messageKind==="workflow-started")try{const f=JSON.parse(t.content);return o.jsx(K6,{data:f})}catch{}if(t.messageKind==="task-completed")try{const f=JSON.parse(t.content);return o.jsx(q6,{data:f})}catch{}return t.messageKind==="context-reset"?o.jsxs("div",{className:"flex items-center gap-4 mb-6 text-text-muted text-xs uppercase tracking-wide",children:[o.jsx("div",{className:"flex-1 border-t border-border"}),o.jsx("span",{children:t.content}),o.jsx("div",{className:"flex-1 border-t border-border"})]}):t.messageKind==="auto-prompt"&&t.isSystemGenerated?o.jsx(Q6,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?o.jsx("div",{className:"flex justify-end feed-item",children:o.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-amber-500/10 border border-amber-500/30",children:[o.jsx("span",{className:"text-[10px] block mb-0.5 text-amber-400",children:"System"}),o.jsx("div",{className:"whitespace-pre-wrap text-sm text-amber-200 italic",children:t.content})]})}):l?o.jsx(J6,{message:t,messageIndex:s,sessionId:a}):o.jsx("div",{className:"flex justify-start feed-item",children:o.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:o.jsx(us,{content:t.content})})})}),TC=(e,t)=>{const n=R.useRef(!0),s=R.useRef(null),[a,l]=R.useState(!0),u=()=>{const c=e.current;c&&(c.scrollTop=c.scrollHeight)};return R.useEffect(()=>{const c=e.current;if(!c)return;const h=x=>{if(x.deltaY>0){requestAnimationFrame(()=>requestAnimationFrame(()=>{c.scrollHeight-c.scrollTop-c.offsetHeight<100&&(n.current=!0,l(!0))}));return}n.current=!1,l(!1)},f=x=>{x.touches[0]&&(s.current=x.touches[0].clientY)},p=x=>{if(s.current===null)return;const w=x.touches[0];if(!w)return;if(w.clientY-s.current>0){n.current=!1,l(!1);return}requestAnimationFrame(()=>requestAnimationFrame(()=>{c.scrollHeight-c.scrollTop-c.offsetHeight<100&&(n.current=!0,l(!0))}))},m=new MutationObserver(()=>{n.current&&requestAnimationFrame(u)}),_=setInterval(()=>{n.current&&u()},1e3);return c.addEventListener("wheel",h,{passive:!0}),c.addEventListener("touchstart",f,{passive:!0}),c.addEventListener("touchmove",p,{passive:!0}),m.observe(c,{childList:!0,subtree:!0,characterData:!0}),()=>{c.removeEventListener("wheel",h),c.removeEventListener("touchstart",f),c.removeEventListener("touchmove",p),m.disconnect(),clearInterval(_)}},[t==null?void 0:t.id]),{force_scroll_to_bottom:()=>{n.current=!0,l(!0),u()},isAutoScrollActive:a,setAutoScroll:c=>{n.current=c,l(c),c&&u()}}},Z6={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function eB(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function M0(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function tB({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:s,dangerZone:a}=e,l=Math.round(t/n*100);return o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[o.jsxs("span",{className:M0(l,a),children:[hu(t),"/",hu(n)]}),o.jsxs("span",{className:M0(l,a),children:["(",l,"%)"]}),o.jsx(qS,{percent:l,dangerZone:a,size:"sm"}),a&&o.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),s>0&&o.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[s,"x"]})]})}const nB=R.memo(function({messages:t,subAgentType:n,subAgentId:s,isStreaming:a}){const l=R.useRef(null),u=R.useRef(null),[c,h]=R.useState(!1),f=mt(L=>L.defaults),p=mt(L=>L.userItems),m=[...f,...p],_=we(L=>L.subAgentContextStates[s]),{showThinking:x,showVerboseToolOutput:w}=Ou(),{isAutoScrollActive:k,setAutoScroll:y}=TC(u,null);R.useEffect(()=>{a||y(!0)},[a]);const S=R.useCallback(()=>{const L=!c;h(L),L&&setTimeout(()=>{var A;(A=l.current)==null||A.scrollIntoView({block:"start",behavior:"smooth"})},220)},[c]),v=m.find(L=>L.id===n),b=(v==null?void 0:v.name)??Z6[n]??n,E=il(m,n),T=eB(E),N=t.filter(L=>L.role!=="tool");return o.jsxs("div",{ref:l,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[o.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:T,children:[o.jsx("span",{className:"text-xs font-medium",children:b}),o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:_&&o.jsx(tB,{contextState:_})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5",onClick:()=>y(!k),children:[o.jsx("span",{className:`w-1 h-1 rounded-full ${k?"bg-accent-success":"border border-text-muted"}`}),"live"]}),o.jsxs("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary",onClick:S,children:[c?"▼":"▶"," Expand"]})]})]}),o.jsx("div",{ref:u,className:`${c?"max-h-[calc(100vh-10rem)]":"max-h-80"} overflow-y-auto p-2 transition-[max-height] duration-200`,children:N.map(L=>L.role==="assistant"?o.jsx(tg,{message:L,showStats:!0,showThinking:x,showVerboseToolOutput:w},L.id):o.jsx(NC,{message:L,isLastAssistantMessage:!1},L.id))})]})});function AC(e,t,n=!0){R.useEffect(()=>{if(!n)return;const s=a=>{var l;(l=e.current)!=null&&l.contains(a.target)||t()};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[e,t,n])}const rB=[],sB=R.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:s}){const a=we(D=>{var B,q;return((q=(B=D.currentSession)==null?void 0:B.metadataEntries)==null?void 0:q.criteria)??rB}),l=we(D=>{var B;return(B=D.currentSession)==null?void 0:B.id}),u=we(D=>{var B;return(B=D.currentSession)==null?void 0:B.mode}),c=we(D=>{var B;return(B=D.currentSession)==null?void 0:B.phase}),h=we(D=>D.error),f=we(D=>D.clearError),p=we(D=>D.acceptAndBuild),m=Pu(),{showThinking:_,showVerboseToolOutput:x,showStats:w,showAgentDefinitions:k,showWorkflowBars:y}=Ou(),S=Et(D=>D.defaults),v=Et(D=>D.userItems),b=[...S,...v],E=u==="planner",T=a.length>0,N=c==="done",L=t.some(D=>D.type==="message"&&D.message.role==="assistant"),A=E&&T&&!m&&L&&!N;return o.jsxs("div",{ref:n,"data-testid":"chat-scroll-container",className:"flex-1 min-w-0 overflow-y-auto relative bg-primary",children:[o.jsx("div",{className:"pt-4",children:t.map((D,B)=>{if(D.type==="context-divider")return o.jsxs("div",{"data-item-index":B,className:"flex items-center gap-2 feed-item px-2 md:px-4",children:[o.jsx("div",{className:"flex-1 border-t border-border"}),o.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),o.jsx("div",{className:"flex-1 border-t border-border"})]},B);if(D.type==="subagent"){const V=D.messages.some(G=>G.isStreaming);return o.jsx("div",{"data-item-index":B,className:"px-2 md:px-4",children:o.jsx(nB,{messages:D.messages,subAgentType:D.subAgentType,subAgentId:D.subAgentId,isStreaming:V})},B)}if(D.type==="criteria-batch")return o.jsx("div",{"data-item-index":B,className:"feed-item px-2 md:px-4",children:o.jsx(jC,{toolCalls:D.toolCalls,criteria:a})},B);const q=D.message;if(q.role==="assistant")return o.jsx("div",{"data-item-index":B,className:"px-2 md:px-4",children:o.jsx(tg,{message:q,showStats:w,showThinking:_,showVerboseToolOutput:x})},B);const W=!k&&q.messageKind==="auto-prompt",O=!y&&(q.messageKind==="workflow-started"||q.messageKind==="task-completed");return W||O?null:o.jsx("div",{"data-item-index":B,className:"px-2 md:px-4",children:o.jsx("div",{"data-message-id":q.id,className:s===q.id?"rounded animate-highlight-fade":void 0,children:o.jsx(NC,{message:q,messageIndex:B,sessionId:l,isLastAssistantMessage:!1})})},B)})}),o.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[h&&o.jsx("div",{className:"feed-item bg-red-500/10 border border-red-500/50 rounded p-2",children:o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-red-400 text-sm font-medium",children:h.code}),o.jsx("div",{className:"text-red-300 text-xs mt-0.5",children:h.message})]}),o.jsx(yl,{onClick:f,className:"text-red-400 hover:text-red-300 p-0.5",size:"sm"})]})}),A&&o.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:b.map(D=>{const B=D.color??"#3b82f6",q=parseInt(B.slice(1,3),16),W=parseInt(B.slice(3,5),16),O=parseInt(B.slice(5,7),16),V=`rgba(${q},${W},${O},0.12)`,G=`rgba(${q},${W},${O},0.22)`,z=`rgba(${q},${W},${O},0.25)`;return o.jsx(iB,{workflowName:D.name,color:B,bg:V,bgHover:G,border:z,subGroups:D.subGroups,onLaunch:X=>p(D.id,void 0,void 0,X)},D.id)})})]})]})});function iB({workflowName:e,color:t,bg:n,bgHover:s,border:a,subGroups:l,onLaunch:u}){const[c,h]=R.useState(!1),f=R.useRef(null);return AC(f,()=>h(!1),c),o.jsxs("div",{className:"relative flex",children:[o.jsxs("button",{onClick:()=>u(),"data-testid":"workflow-run-button",className:"px-4 py-1.5 rounded-l text-sm font-medium transition-colors",style:{backgroundColor:n,color:t,border:`1px solid ${a}`,borderRight:"none"},onMouseEnter:p=>{p.currentTarget.style.backgroundColor=s},onMouseLeave:p=>{p.currentTarget.style.backgroundColor=n},children:["▶ ",e]}),l&&l.length>0&&o.jsxs("div",{ref:f,className:"relative",children:[o.jsx("button",{onClick:()=>h(!c),className:"px-1.5 py-1.5 rounded-r text-sm font-medium transition-colors",style:{backgroundColor:n,color:t,border:`1px solid ${a}`},onMouseEnter:p=>{p.currentTarget.style.backgroundColor=s},onMouseLeave:p=>{p.currentTarget.style.backgroundColor=n},children:"⋮"}),c&&o.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:[o.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"}),o.jsx("div",{className:"border-t border-border/50"}),l.map(p=>o.jsx("button",{onClick:()=>{u(p),h(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:p},p))]})]})]})}function aB({question:e}){const t=we(u=>u.answerQuestion),[n,s]=R.useState(""),a=()=>{t(e.callId,n)},l=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),a())};return o.jsx(Dt,{isOpen:!0,onClose:()=>{},size:"sm",closeOnBackdropClick:!1,closeOnEscape:!1,showCloseButton:!1,children:o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-text-primary",children:e.question}),o.jsx("textarea",{value:n,onChange:u=>s(u.target.value),onKeyDown:l,placeholder:"Type your answer here...",className:"w-full min-h-[120px] px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",autoFocus:!0}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(tt,{variant:"secondary",size:"sm",onClick:()=>t(e.callId,""),children:"Skip"}),o.jsx(tt,{variant:"primary",size:"sm",onClick:a,children:"Send Answer"})]})]})})}function oB(){const e=we(s=>s.connectionStatus),t=we(s=>s.reconnect);if(e==="connected")return null;const n=e==="reconnecting";return o.jsxs("div",{className:`
|
|
285
|
+
flex items-center justify-between px-4 py-2
|
|
286
|
+
text-sm font-medium
|
|
287
|
+
${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"}
|
|
288
|
+
`,children:[o.jsx("div",{className:"flex items-center gap-2",children:n?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"flex gap-1",children:[o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"150ms"}}),o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"300ms"}})]}),o.jsx("span",{children:"Reconnecting to server..."})]}):o.jsxs(o.Fragment,{children:[o.jsx(Mj,{}),o.jsx("span",{children:"Connection lost"})]})}),o.jsx("button",{onClick:()=>t(),disabled:n,className:`
|
|
289
|
+
px-3 py-1 rounded text-xs font-medium
|
|
290
|
+
transition-colors
|
|
291
|
+
${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"}
|
|
292
|
+
`,children:n?"Reconnecting...":"Reconnect"})]})}const nn=qn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async()=>{await hp("/api/commands",e,!0)},fetchCommand:async n=>{try{const s=await Ne(`/api/commands/${n}`);return s.ok?await s.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const s=await Ne(`/api/commands/defaults/${n}`);return s.ok?await s.json():null}catch{return null}},createCommand:async(n,s)=>{const a=await Ws("POST","/api/commands",{...n,destination:s});return a.success&&await t().fetchCommands(),a},updateCommand:async(n,s)=>{const a=await Ws("PUT",`/api/commands/${n}`,s);return a.success&&await t().fetchCommands(),a},deleteCommand:async n=>{try{const s=await Ne(`/api/commands/${n}`,{method:"DELETE"}),a=await s.json();return s.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateCommand:async(n,s)=>Iu(`/api/commands/${n}/duplicate`,()=>t().fetchCommands(),s)}));function lB(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function cB({onClick:e}){return o.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:o.jsx(uu,{})})}function LC({isOpen:e,onClose:t,initialEditId:n}){const s=nn(me=>me.defaults),a=nn(me=>me.userItems),l=nn(me=>me.projectItems),u=nn(me=>me.loading),c=nn(me=>me.fetchCommands),h=nn(me=>me.fetchCommand),f=nn(me=>me.fetchDefaultContent),p=nn(me=>me.createCommand),m=nn(me=>me.updateCommand),_=nn(me=>me.deleteCommand),[x,w]=R.useState(null),[k,y]=R.useState(null),{view:S,editingId:v,formError:b,saving:E,formData:T,setView:N,setEditingId:L,setFormError:A,setFormData:D,setSaving:B}=TS(),{requestDelete:q,clearConfirm:W,isConfirming:O}=fp(),V=R.useRef(!1),G=mt(me=>me.defaults),z=mt(me=>me.userItems),X=mt(me=>me.fetchAgents),F=[...G,...z].filter(me=>!me.subagent),M=R.useRef(c),$=R.useRef(X),P=R.useRef(h),U=R.useRef(f),J=R.useRef(n),Q=R.useRef(N),se=R.useRef(L),Y=R.useRef(A),H=R.useRef(W);R.useEffect(()=>{M.current=c,$.current=X,P.current=h,U.current=f,J.current=n,Q.current=N,se.current=L,Y.current=A,H.current=W}),R.useEffect(()=>{if(e)if(M.current(),$.current(),V.current||(H.current(),V.current=!0),J.current){const me=s.some(je=>je.id===J.current);Q.current("edit"),se.current(J.current),Y.current(""),me?U.current(J.current).then(je=>{je&&D({name:je.metadata.name+" (copy)",id:`${J.current}-copy-${Date.now()}`,prompt:je.prompt,agentMode:je.metadata.agentMode??"",isDefault:!0,destination:"user"})}):P.current(J.current).then(je=>{je&&D({name:je.metadata.name,id:je.metadata.id,prompt:je.prompt,agentMode:je.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else Q.current("list"),se.current(null);else V.current=!1},[e]);const ee=async me=>{w(me);const je=await f(me);y((je==null?void 0:je.prompt)??null)},te=async me=>{if(s.some(nt=>nt.id===me)){const nt=await f(me);nt&&(L(null),D({name:`${nt.metadata.name} (copy)`,id:`${me}-copy-${Date.now()}`,prompt:nt.prompt,agentMode:nt.metadata.agentMode??"",isDefault:!0,destination:"user"}),A(""),N("edit"))}else{const nt=await h(me);nt&&(L(null),D({name:`${nt.metadata.name} (copy)`,id:`${me}-copy-${Date.now()}`,prompt:nt.prompt,agentMode:nt.metadata.agentMode??"",isDefault:!1,destination:"user"}),A(""),N("edit"))}},ce=()=>{D({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),L(null),N("edit")},he=async me=>{const je=await h(me);je&&(L(me),D({name:je.metadata.name,id:je.metadata.id,prompt:je.prompt,agentMode:je.metadata.agentMode??"",isDefault:!1,destination:"user"}),A(""),N("edit"))},Te=async me=>{await _(me),W()},Ae=async()=>{const me=v??T.id;if(!me||!T.name||!T.prompt){A("Name and message are required.");return}B(!0),A("");const je={metadata:{id:me,name:T.name,...T.agentMode?{agentMode:T.agentMode}:{}},prompt:T.prompt},nt=v?await m(v,je):await p(je,T.destination);if(B(!1),!nt.success){A(nt.error??"Failed to save command.");return}n?t():N("list")},Le=()=>{n?t():(N("list"),w(null),y(null))},Pe=me=>{D(je=>({...je,name:me})),(!v||T.isDefault)&&D(je=>({...je,id:lB(me)}))},de=()=>{w(null),y(null),N("list")},Ie=()=>{x&&(w(null),N("edit"),L(x),f(x).then(me=>{me&&D({name:`${me.metadata.name} (copy)`,id:`${x}-copy-${Date.now()}`,prompt:me.prompt,agentMode:me.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(x){const me=s.find(je=>je.id===x);return o.jsx(Dt,{isOpen:e,onClose:de,title:`Default: ${(me==null?void 0:me.name)??x}`,size:"xl",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"space-y-3 mb-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[o.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),o.jsx("span",{className:"font-mono",children:x})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),o.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:me==null?void 0:me.name})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Agent Mode"}),o.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-muted",children:(me==null?void 0:me.agentMode)||"None"})]})]}),o.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),o.jsx("textarea",{value:k??"",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"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[o.jsx(tt,{variant:"secondary",onClick:de,children:"Close"}),o.jsx(tt,{variant:"primary",onClick:Ie,children:"Duplicate & Customize"})]})]})})}if(S==="edit")return o.jsx(Dt,{isOpen:e,onClose:Le,title:v?"Edit Command":"New Command",size:"xl",children:o.jsxs("div",{className:"flex flex-col h-full",children:[b&&o.jsx(gp,{message:b}),o.jsxs("div",{className:"space-y-3 mb-3",children:[o.jsx(NS,{name:T.name,id:T.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!v&&!T.isDefault,onNameChange:Pe,onIdChange:me=>D(je=>({...je,id:me}))}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",o.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),o.jsxs("select",{value:T.agentMode,onChange:me=>D(je=>({...je,agentMode:me.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:[o.jsx("option",{value:"",children:"None (keep current mode)"}),F.map(me=>o.jsx("option",{value:me.id,children:me.name},me.id))]})]}),!v&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),o.jsxs("select",{value:T.destination,onChange:me=>D(je=>({...je,destination:me.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:[o.jsx("option",{value:"user",children:"Global config"}),o.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]})]}),o.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),o.jsx("textarea",{value:T.prompt,onChange:me=>D(je=>({...je,prompt:me.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"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[o.jsx(tt,{variant:"secondary",onClick:Le,children:"Cancel"}),o.jsx(tt,{variant:"primary",onClick:Ae,disabled:E||!T.name||!T.prompt,children:E?"Saving...":"Save"})]})]})});const Se=me=>me.map(je=>o.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[o.jsx("div",{className:"min-w-0 flex-1 mr-3",children:o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("span",{className:"text-text-primary text-sm font-medium",children:je.name})})}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[o.jsx(Fs,{onClick:()=>he(je.id)}),o.jsx(du,{onClick:()=>te(je.id)}),O(je.id,"delete")?o.jsx(mp,{onConfirm:()=>Te(je.id),onCancel:W}):o.jsx(pp,{onClick:()=>q(je.id)})]})]},je.id));return o.jsxs(Dt,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[o.jsx(kS,{description:"Commands are pre-defined messages you can send with a single click.",onNew:ce}),o.jsxs(jS,{loading:u,hasItems:s.length>0||a.length>0||l.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[s.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),o.jsx("div",{className:"space-y-2",children:s.map(me=>o.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[o.jsx("div",{className:"min-w-0 flex-1 mr-3",children:o.jsx("span",{className:"text-text-primary text-sm font-medium",children:me.name})}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[o.jsx(cB,{onClick:()=>ee(me.id)}),o.jsx(du,{onClick:()=>te(me.id)})]})]},me.id))})]}),a.length>0&&o.jsx(CS,{children:Se(a)}),l.length>0&&o.jsxs("div",{className:"mt-4",children:[o.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),o.jsx("div",{className:"space-y-2",children:Se(l)})]})]})]})}const gi=150,ss=54,ru=80,gr=30,ja=70,I0=100,xi=50,su=50,P0=4,DC={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},RC=[{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)"}],uB=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"}];function ng(e,t){if(e.type==="agent"){const n=t.find(s=>s.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(s=>s.id===e.subAgentType);return{name:(n==null?void 0:n.name)??(e.subAgentType||"Sub-Agent"),color:(n==null?void 0:n.color)||"#a855f7"}}return{name:"Shell",color:"#22c55e"}}function dB(e,t,n,s){const a=su+xi+gi+I0+gi+xi+su,l=a/2,u=su+xi+gi/2,c=su+xi+gi+I0+gi/2,h=[],f=[],p=new Map,m=e.filter(G=>G.type==="agent"||G.type==="shell"),_=e.filter(G=>G.type==="sub_agent"),x=_.length>0,w=x?u:l,k=m.length>0?c:l,y=xi+gr/2;h.push({id:"$start",type:"terminal",label:"Start",cx:w,cy:y,w:ru,h:gr}),p.set("$start",{cx:w,cy:y,w:ru,h:gr});const S=G=>{h.push({id:"$done",type:"terminal",label:"Done",cx:w,cy:G,w:ru,h:gr}),p.set("$done",{cx:w,cy:G,w:ru,h:gr})};if(e.length===0){const G=y+gr/2+ja*2+gr/2;return S(G),{nodes:h,edges:f,width:a,height:G+gr/2+xi,posMap:p}}const v=y+gr/2+ja,b=(G,z)=>{G.forEach((X,ne)=>{const F=v+ne*(ss+ja)+ss/2,{name:M,color:$}=ng(X,s);h.push({id:X.id,type:"step",label:M,color:$,cx:z,cy:F,w:gi,h:ss}),p.set(X.id,{cx:z,cy:F,w:gi,h:ss})})};b(m,w),b(_,k);const E=m.length>0?v+(m.length-1)*(ss+ja)+ss/2:y,T=x?v+(_.length-1)*(ss+ja)+ss/2:y,N=Math.max(E,T)+ss/2+ja+gr/2;S(N);const L=[];t&&p.has(t)&&L.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let A=0;for(const G of e)G.transitions.forEach((z,X)=>{var U;if(!z.goto||!p.has(z.goto))return;const ne=p.get(G.id),F=p.get(z.goto),M=z.when.type==="step_result"?`${z.when.result}`:z.when.type==="metadata_all_match"?`${z.when.key??"?"}=${z.when.value??"?"}`:z.when.type==="metadata_all_in"?`${z.when.key??"?"} in [${((U=z.when.values)==null?void 0:U.join(","))??"?"}]`:DC[z.when.type]??z.when.type,$=G.id===z.goto;let P;$?P="back":F.cy>ne.cy+1?P="down":F.cy<ne.cy-1?P="back":P="same",L.push({from:G.id,to:z.goto,label:M,edgeKey:`${G.id}:${X}`,direction:P,backEdgeIndex:P==="back"?A++:0})});const D=new Map,B=new Map,q=new Map,W=new Map;for(const G of L)G.direction==="down"&&(D.set(G.from,(D.get(G.from)??0)+1),B.set(G.to,(B.get(G.to)??0)+1));const O=new Map,V=new Map;for(const G of L){if(G.direction!=="same")continue;const z=[G.from,G.to].sort().join("|");O.set(z,(O.get(z)??0)+1)}for(const G of L){if(G.direction==="back"||G.direction==="same"){let P=0;if(G.direction==="same"){const U=[G.from,G.to].sort().join("|");P=V.get(U)??0,V.set(U,P+1)}f.push({...G,fromPort:0,toPort:0,sameEdgeIndex:P});continue}const z=D.get(G.from)??1,X=B.get(G.to)??1,ne=q.get(G.from)??0,F=W.get(G.to)??0;q.set(G.from,ne+1),W.set(G.to,F+1);const M=z===1?0:-.6+1.2*ne/(z-1),$=X===1?0:-.6+1.2*F/(X-1);f.push({...G,fromPort:M,toPort:$,sameEdgeIndex:0})}return{nodes:h,edges:f,width:a,height:N+gr/2+xi,posMap:p}}function hB({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:s,startConditionLabel:a,agentTypes:l,isReadOnly:u,onSelectNode:c,onSelectEdge:h,onRemoveStep:f,onCreateTransition:p,onReconnectTo:m,onReconnectFrom:_,onDeleteTransition:x}){const w=R.useRef(null),k=R.useRef(!1),[y,S]=R.useState(null),[v,b]=R.useState(null),[E,T]=R.useState(null),{nodes:N,edges:L,width:A,height:D,posMap:B}=R.useMemo(()=>dB(e,t,a,l),[e,t,a,l]),q=R.useCallback(Q=>{var te;const se=w.current;if(!se)return{x:0,y:0};const Y=se.createSVGPoint();Y.x=Q.clientX,Y.y=Q.clientY;const H=(te=se.getScreenCTM())==null?void 0:te.inverse();if(!H)return{x:0,y:0};const ee=Y.matrixTransform(H);return{x:ee.x,y:ee.y}},[]),W=R.useCallback(Q=>!Q||!v||Q==="$start"?!1:v.type==="reconnect-from"?Q!=="$done":!0,[v]),O=R.useCallback((Q,se)=>{if(u)return;Q.stopPropagation(),Q.preventDefault();const Y=q(Q);b({type:"new",fromNodeId:se,mouseX:Y.x,mouseY:Y.y})},[q,u]),V=R.useCallback((Q,se)=>{if(u)return;Q.stopPropagation(),Q.preventDefault();const Y=q(Q);b({type:"reconnect-to",fromNodeId:se.from,edgeKey:se.edgeKey,mouseX:Y.x,mouseY:Y.y})},[q,u]),G=R.useCallback((Q,se)=>{if(u)return;Q.stopPropagation(),Q.preventDefault();const Y=q(Q);b({type:"reconnect-from",fromNodeId:se.from,fixedTargetId:se.to,edgeKey:se.edgeKey,mouseX:Y.x,mouseY:Y.y})},[q,u]),z=R.useCallback(Q=>{if(!v)return;const se=q(Q);b(Y=>Y?{...Y,mouseX:se.x,mouseY:se.y}:null)},[v,q]),X=R.useCallback(()=>{v&&(k.current=!0,E&&W(E)&&(v.type==="new"?p(v.fromNodeId,E):v.type==="reconnect-to"?m(v.edgeKey,E):v.type==="reconnect-from"&&_(v.edgeKey,E)),b(null),T(null))},[v,E,W,p,m,_]),ne=R.useCallback(()=>{if(k.current){k.current=!1;return}c(null),h(null)},[c,h]);R.useEffect(()=>{if(u)return;const Q=se=>{se.target instanceof HTMLInputElement||se.target instanceof HTMLTextAreaElement||se.target instanceof HTMLSelectElement||(se.key==="Delete"||se.key==="Backspace")&&s&&s!=="start"&&(se.preventDefault(),x(s),h(null))};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[u,s,x,h]);const F=Q=>{const se=B.get(Q.from),Y=B.get(Q.to);if(!se||!Y)return null;let H,ee,te,ce="middle",he,Te;if(Q.direction==="down"){const Ae=se.cx+Q.fromPort*(se.w/2-10),Le=se.cy+se.h/2,Pe=Y.cx+Q.toPort*(Y.w/2-10),de=Y.cy-Y.h/2,Ie=de-Le,Se=Pe-Ae;H=`M ${Ae} ${Le} C ${Ae} ${Le+Ie*.4}, ${Pe-Se*.2} ${de-Ie*.1}, ${Pe} ${de}`,ee=Ae+(Pe-Ae)*.5,te=Le+Ie*.6,he={x:Ae,y:Le},Te={x:Pe,y:de}}else if(Q.direction==="back"){const Ae=Q.from===Q.to,Le=se.cx>=A/2,Pe=Q.backEdgeIndex*16,de=Le?A-20-Pe:20+Pe;if(Ae){const Ie=se.cx>=A/2,Se=30+Q.backEdgeIndex*14,me=se.cy-se.h/2,je=Ie?se.cx+se.w/2:se.cx-se.w/2,nt=Ie?je+Se:je-Se,Mt=se.cx+(Ie?se.w/4:-se.w/4),gt=me-20-Q.backEdgeIndex*10;H=`M ${je} ${se.cy} C ${nt} ${se.cy}, ${nt} ${gt}, ${Mt} ${me}`,ee=nt+10,te=gt+4,ce="middle",he={x:je,y:se.cy},Te={x:Mt,y:me}}else{const Ie=Le?se.cx+se.w/2:se.cx-se.w/2,Se=Y.cx+(Le?Y.w/4:-Y.w/4),me=Math.min(se.cy,Y.cy)-Y.h/2-18-Q.backEdgeIndex*14;H=`M ${Ie} ${se.cy} L ${de} ${se.cy} L ${de} ${me} L ${Se} ${me} L ${Se} ${Y.cy-Y.h/2}`,ee=de,te=(se.cy+me)/2,ce=Le?"start":"end",he={x:Ie,y:se.cy},Te={x:Se,y:Y.cy-Y.h/2}}}else{const Ae=Y.cx>se.cx,Le=Q.sameEdgeIndex===0?-12:12,Pe=Ae?se.cx+se.w/2:se.cx-se.w/2,de=Ae?Y.cx-Y.w/2:Y.cx+Y.w/2,Ie=se.cy+Le,Se=Y.cy+Le,me=(Pe+de)/2;H=`M ${Pe} ${Ie} C ${me} ${Ie}, ${me} ${Se}, ${de} ${Se}`,ee=me,te=(Ie+Se)/2-6,he={x:Pe,y:Ie},Te={x:de,y:Se}}return{path:H,labelX:ee,labelY:te,labelAnchor:ce,fromPt:he,toPt:Te}},M=(Q,se)=>{const Y=F(Q);if(!Y)return null;const{path:H,labelX:ee,labelY:te,labelAnchor:ce}=Y,he=s===Q.edgeKey,Te=Q.label&&Q.label!=="otherwise";return o.jsxs("g",{children:[o.jsx("path",{d:H,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:Ae=>{Ae.stopPropagation(),u||h(he?null:Q.edgeKey)}}),o.jsx("path",{d:H,fill:"none",stroke:he?"#58a6ff":"#484f58",strokeWidth:he?2.2:1.2,markerEnd:he?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),Te&&o.jsx("text",{x:ee+(ce==="start"?5:ce==="end"?-5:0),y:te+3,textAnchor:ce,className:"text-[8px]",fill:he?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:Q.label})]},se)},$=()=>{if(!s||v)return null;const Q=L.find(te=>te.edgeKey===s);if(!Q)return null;const se=F(Q);if(!se)return null;const{fromPt:Y,toPt:H}=se,ee=6;return o.jsxs(o.Fragment,{children:[Q.edgeKey!=="start"&&o.jsx("circle",{cx:Y.x,cy:Y.y,r:ee,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:te=>G(te,Q)}),o.jsx("circle",{cx:H.x,cy:H.y,r:ee,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:te=>V(te,Q)})]})},P=()=>{if(!v)return null;let Q,se,Y,H;if(v.type==="reconnect-from"){const ce=B.get(v.fixedTargetId);if(!ce)return null;Q=v.mouseX,se=v.mouseY,Y=ce.cx,H=ce.cy-ce.h/2}else{const ce=B.get(v.fromNodeId);if(!ce)return null;Q=ce.cx,se=ce.cy+ce.h/2,Y=v.mouseX,H=v.mouseY}const ee=H-se,te=Math.abs(ee)>10?`M ${Q} ${se} C ${Q} ${se+ee*.4}, ${Y} ${H-ee*.4}, ${Y} ${H}`:`M ${Q} ${se} L ${Y} ${H}`;return o.jsx("path",{d:te,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},U=Q=>{const se=Q.cy+Q.h/2,Y=(v==null?void 0:v.fromNodeId)===Q.id;return o.jsx("circle",{cx:Q.cx,cy:se,r:P0,fill:Y?"#58a6ff":"#1c2128",stroke:Y?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:Y?1:.5,className:"cursor-crosshair",onMouseDown:H=>O(H,Q.id)})},J=Q=>{const se=Q.cy-Q.h/2,Y=v&&E===Q.id&&W(Q.id);return o.jsx("circle",{cx:Q.cx,cy:se,r:P0,fill:Y?"#3fb950":"#1c2128",stroke:Y?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:Y?1:.5})};return o.jsxs("svg",{ref:w,viewBox:`0 0 ${A} ${D}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:z,onMouseUp:X,onClick:ne,children:[o.jsxs("defs",{children:[o.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:o.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),o.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:o.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),L.map((Q,se)=>M(Q,se)),N.map(Q=>{const se=n===Q.id,Y=Q.cx-Q.w/2,H=Q.cy-Q.h/2,ee=y===Q.id,te=v&&E===Q.id&&W(Q.id);if(Q.type==="terminal"){const he=Q.id==="$start",Te=he?"#58a6ff":"#3fb950",Ae=he,Le=!he;return o.jsxs("g",{onClick:Pe=>{Pe.stopPropagation(),he&&!u&&h("start")},className:he&&!u?"cursor-pointer":void 0,children:[te&&o.jsx("rect",{x:Y-3,y:H-3,width:Q.w+6,height:Q.h+6,rx:Q.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),he&&s==="start"&&o.jsx("rect",{x:Y-3,y:H-3,width:Q.w+6,height:Q.h+6,rx:Q.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),o.jsx("rect",{x:Y,y:H,width:Q.w,height:Q.h,rx:Q.h/2,fill:Te,fillOpacity:.08,stroke:Te,strokeOpacity:.4,strokeWidth:1.5}),o.jsx("text",{x:Q.cx,y:Q.cy+4,textAnchor:"middle",fill:Te,className:"text-[10px] font-medium",pointerEvents:"none",children:Q.label}),Ae&&U(Q),Le&&J(Q)]},Q.id)}const ce=Q.color??"#6b7280";return o.jsxs("g",{onClick:he=>{he.stopPropagation(),u||c(se?null:Q.id)},onMouseEnter:()=>S(Q.id),onMouseLeave:()=>S(null),className:u?void 0:"cursor-pointer",children:[te&&o.jsx("rect",{x:Y-3,y:H-3,width:Q.w+6,height:Q.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),se&&o.jsx("rect",{x:Y-3,y:H-3,width:Q.w+6,height:Q.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),o.jsx("rect",{x:Y,y:H,width:Q.w,height:Q.h,rx:10,fill:ce,fillOpacity:.08,stroke:ce,strokeOpacity:.6,strokeWidth:se?2:1.5}),o.jsx("text",{x:Q.cx,y:Q.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:Q.label}),!u&&U(Q),!u&&J(Q),ee&&!v&&!u&&o.jsxs("g",{onClick:he=>{he.stopPropagation(),f(Q.id)},className:"cursor-pointer",children:[o.jsx("circle",{cx:Y+Q.w-2,cy:H+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),o.jsx("line",{x1:Y+Q.w-5,y1:H-1,x2:Y+Q.w+1,y2:H+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),o.jsx("line",{x1:Y+Q.w+1,y1:H-1,x2:Y+Q.w-5,y2:H+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},Q.id)}),v&&N.map(Q=>W(Q.id)?o.jsx("rect",{x:Q.cx-Q.w/2-8,y:Q.cy-Q.h/2-8,width:Q.w+16,height:Q.h+16,fill:"transparent",rx:12,onMouseEnter:()=>T(Q.id),onMouseLeave:()=>T(null),onMouseUp:se=>{se.stopPropagation(),X()}},`drop-${Q.id}`):null),P(),$()]})}function fB({name:e,id:t,color:n,description:s,isBuiltIn:a,actions:l}){return o.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:n}}),o.jsx("span",{className:"text-text-primary text-sm font-medium",children:e}),o.jsx("span",{className:"text-text-muted text-xs font-mono",children:t}),a&&o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),s&&o.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:s})]}),o.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 ml-3",children:l})]})}function B0({title:e,items:t,renderActions:n}){return t.length===0?null:o.jsxs("div",{children:[o.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),o.jsx("div",{className:"space-y-2",children:t.map(s=>o.jsx(fB,{name:s.name,id:s.id,color:s.color??"#3b82f6",description:s.description,actions:n(s)},s.id))})]})}const Na="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",pm="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",is="block text-[11px] text-text-secondary mb-0.5";function gm({variables:e,onInsert:t}){return e.length===0?null:o.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(n=>o.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 mB({step:e,isEntry:t,agentTypes:n,transitionCount:s,templateVariables:a,onUpdate:l,onRemove:u,onSetEntry:c}){const{color:h,name:f}=ng(e,n);return o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:h+"20",color:h},children:f}),t&&o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[!t&&o.jsx("button",{onClick:c,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),o.jsx("button",{onClick:u,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:is,children:"Type"}),o.jsx("select",{value:e.type,onChange:p=>{const m=p.target.value,_=m==="sub_agent"?"verification":"build";if(m==="agent"){const x=n.find(w=>!w.subagent);l({...e,type:m,phase:_,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);l({...e,type:m,phase:_,subAgentType:(x==null?void 0:x.id)??"",name:(x==null?void 0:x.name)??"Sub-Agent"})}else l({...e,type:m,phase:_,name:"Shell"})},className:pm,children:uB.map(p=>o.jsx("option",{value:p.value,children:p.label},p.value))})]}),e.type==="agent"&&o.jsxs("div",{children:[o.jsx("label",{className:is,children:"Agent Type"}),o.jsx("select",{value:e.agentId??"builder",onChange:p=>{const m=n.find(_=>_.id===p.target.value);l({...e,agentId:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:pm,children:n.filter(p=>!p.subagent).map(p=>o.jsx("option",{value:p.id,children:p.name},p.id))})]}),e.type==="sub_agent"&&o.jsxs("div",{children:[o.jsx("label",{className:is,children:"Sub-Agent Type"}),o.jsxs("select",{value:e.subAgentType??"",onChange:p=>{const m=n.find(_=>_.id===p.target.value);l({...e,subAgentType:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:pm,children:[o.jsx("option",{value:"",children:"— select —"}),n.filter(p=>p.subagent).map(p=>o.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:is,children:"Prompt"}),o.jsx("textarea",{value:e.prompt??"",onChange:p=>l({...e,prompt:p.target.value||void 0}),rows:6,className:`${Na} resize-y text-xs`,placeholder:"Injected on first entry..."}),o.jsx(gm,{variables:a,onInsert:p=>l({...e,prompt:(e.prompt??"")+`{{${p}}}`})})]}),o.jsxs("div",{children:[o.jsx("label",{className:is,children:"Nudge Prompt"}),o.jsx("textarea",{value:e.nudgePrompt??"",onChange:p=>l({...e,nudgePrompt:p.target.value||void 0}),rows:6,className:`${Na} resize-y text-xs`,placeholder:"Injected on re-entry..."}),o.jsx(gm,{variables:a,onInsert:p=>l({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${p}}}`})})]})]}),e.type==="shell"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:is,children:"Command"}),o.jsx("textarea",{value:e.command??"",onChange:p=>l({...e,command:p.target.value}),rows:3,className:`${Na} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),o.jsx(gm,{variables:a,onInsert:p=>l({...e,command:(e.command??"")+`{{${p}}}`})})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx("label",{className:is,children:"Timeout (ms)"}),o.jsx("input",{type:"number",value:e.timeout??6e4,onChange:p=>l({...e,timeout:Number(p.target.value)}),className:`${Na} font-mono text-xs`})]}),o.jsxs("div",{children:[o.jsx("label",{className:is,children:"Success Codes"}),o.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:p=>l({...e,successExitCodes:p.target.value.split(",").map(m=>Number(m.trim())).filter(m=>!isNaN(m))}),className:`${Na} font-mono text-xs`})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:is,children:"Sub-group"}),o.jsx("input",{value:e.subGroup??"",onChange:p=>l({...e,subGroup:p.target.value||void 0}),placeholder:"e.g. build, verify, review",className:Na})]}),o.jsx("div",{className:"pt-1 border-t border-border/50",children:o.jsxs("p",{className:"text-text-muted text-[10px]",children:[s," outgoing transition",s!==1?"s":""," — drag from the bottom port to connect."]})})]})}const Ta="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",z0="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",_i="block text-[11px] text-text-secondary mb-0.5";function pB({fromLabel:e,toLabel:t,condition:n,subGroup:s,fromStep:a,agentTypes:l,transitionIndex:u,totalTransitions:c,onUpdateCondition:h,onUpdateSubGroup:f,onDelete:p,onMoveUp:m,onMoveDown:_}){var k;const x=a&&(a.type==="sub_agent"||a.type==="agent")?l.find(y=>y.id===(a.type==="sub_agent"?a.subAgentType:a.agentId)):void 0,w=(x==null?void 0:x.results)&&x.results.length>0;return o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:["#",u+1]}),c>1&&o.jsxs("div",{className:"flex items-center gap-0.5",children:[o.jsx("button",{onClick:m,disabled:u===0,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move up (higher priority)",children:o.jsx(Sr,{className:"w-3 h-3",rotate:180})}),o.jsx("button",{onClick:_,disabled:u===c-1,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move down (lower priority)",children:o.jsx(Sr,{className:"w-3 h-3"})})]})]}),o.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[o.jsx("span",{className:"font-medium text-text-primary",children:e}),o.jsx(mS,{}),o.jsx("span",{className:"font-medium text-text-primary",children:t})]}),o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Condition"}),o.jsx("select",{value:n.type,onChange:y=>{h(y.target.value==="step_result"?{type:"step_result",result:"success"}:{type:y.target.value})},className:z0,children:RC.map(y=>o.jsx("option",{value:y.value,children:y.label},y.value))})]}),n.type==="step_result"&&o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Result"}),w?o.jsx("select",{value:n.result??x.results[0],onChange:y=>{h({type:"step_result",result:y.target.value})},className:z0,children:x.results.map(y=>o.jsx("option",{value:y,children:y},y))}):o.jsx("input",{type:"text",value:n.result??"success",onChange:y=>h({type:"step_result",result:y.target.value}),placeholder:"e.g. success, passed, failed",className:Ta})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Metadata Key"}),o.jsx("input",{type:"text",value:n.key??"",onChange:y=>h({...n,key:y.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Ta})]}),o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Field"}),o.jsx("input",{type:"text",value:n.field??"",onChange:y=>h({...n,field:y.target.value}),placeholder:"e.g. status",className:Ta})]}),n.type==="metadata_all_match"?o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Value"}),o.jsx("input",{type:"text",value:n.value??"",onChange:y=>h({...n,value:y.target.value}),placeholder:"e.g. passed, resolved",className:Ta})]}):o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Values (comma-separated)"}),o.jsx("input",{type:"text",value:((k=n.values)==null?void 0:k.join(", "))??"",onChange:y=>h({...n,values:y.target.value.split(",").map(S=>S.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Ta})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Sub-group"}),o.jsx("input",{type:"text",value:s??"",onChange:y=>f(y.target.value||void 0),placeholder:"e.g. build, verify",className:Ta})]}),o.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function gB(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function xB(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const as="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",H0="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",xr="block text-[11px] text-text-secondary mb-0.5",$0=[];function OC({isOpen:e,onClose:t,initialEditId:n}){var Pi,hs;const s=Et(ye=>ye.defaults),a=Et(ye=>ye.userItems),l=Et(ye=>ye.loading),u=Et(ye=>ye.templateVariables),c=Et(ye=>ye.fetchWorkflows),h=Et(ye=>ye.fetchWorkflow),f=Et(ye=>ye.fetchDefaultContent),p=Et(ye=>ye.fetchTemplateVariables),m=Et(ye=>ye.createWorkflow),_=Et(ye=>ye.updateWorkflow),x=Et(ye=>ye.deleteWorkflow),{requestDelete:w,clearConfirm:k,isConfirming:y}=fp(),[S,v]=R.useState("list"),[b,E]=R.useState(null),[T,N]=R.useState(!1),[L,A]=R.useState(null),[D,B]=R.useState(null),[q,W]=R.useState(""),[O,V]=R.useState(""),[G,z]=R.useState(""),[X,ne]=R.useState("1.0.0"),[F,M]=R.useState("#3b82f6"),[$,P]=R.useState(""),[U,J]=R.useState(50),[Q,se]=R.useState($0),[Y,H]=R.useState({type:"always"}),[ee,te]=R.useState(""),[ce,he]=R.useState(!1),Te=mt(ye=>ye.defaults),Ae=mt(ye=>ye.userItems),Le=mt(ye=>ye.projectItems),Pe=R.useMemo(()=>[...Te,...Ae,...Le],[Te,Ae,Le]),de=mt(ye=>ye.fetchAgents),[Ie]=R.useState(null);R.useEffect(()=>{e&&(c(),p(),de(),A(null),B(null),n?s.some(_e=>_e.id===n)?f(n).then(_e=>{_e&&Se({..._e,metadata:{..._e.metadata,name:_e.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):h(n).then(_e=>{_e&&Se(_e,{editingId:n,isReadOnly:!1})}):(v("list"),E(null),N(!1)))},[e,c,h,f,p,n]);const Se=(ye,_e)=>{W(ye.metadata.name),V(ye.metadata.id),z(ye.metadata.description),ne(ye.metadata.version),M(ye.metadata.color??"#3b82f6"),P(ye.entryStep),J(ye.settings.maxIterations),se(ye.steps),H(ye.startCondition??{type:"always"}),te(""),(_e==null?void 0:_e.editingId)!==void 0&&E(_e.editingId),(_e==null?void 0:_e.isReadOnly)!==void 0&&N(_e.isReadOnly),(_e==null?void 0:_e.selectedNodeKey)!==void 0&&A(null),(_e==null?void 0:_e.selectedEdgeKey)!==void 0&&B(null),v("edit")},me=async ye=>{const _e=await h(ye);_e&&Se(_e,{editingId:ye,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},je=async()=>{var et;const ye=b??O;if(!ye||!q)return te("Name is required."),!1;if(Q.length===0)return te("Add at least one step."),!1;let _e=$;if(!_e||!Q.some(qe=>qe.id===_e)){if(_e=((et=Q.find(qe=>qe.id))==null?void 0:et.id)??"",!_e)return te("All steps need an ID."),!1;P(_e)}he(!0),te("");const De={metadata:{id:ye,name:q,description:G,version:X||"1.0.0",color:F},entryStep:_e,settings:{maxIterations:U},steps:Q,startCondition:Y},$e=b?await _(b,De):await m(De);return he(!1),$e.success?(b||E(ye),!0):(te($e.error??"Failed to save."),!1)},nt=async()=>{await je()},Mt=async()=>{await je()&&(n?t():v("list"))},gt=()=>{n?t():v("list")},Zt=ye=>{W(ye),b||V(gB(ye))},ge=async ye=>s.some(De=>De.id===ye)?await f(ye):await h(ye),Ce=async ye=>{const _e=await ge(ye);_e&&Se(_e,{editingId:ye,isReadOnly:!0})},Oe=async ye=>{const _e=await ge(ye);_e&&Se({..._e,metadata:{..._e.metadata,name:_e.metadata.name+" (copy)",id:`${ye}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},Ve=()=>{E(null),W(""),V(""),z(""),ne("1.0.0"),M("#3b82f6"),P(""),J(50),se(structuredClone($0)),H({type:"always"}),te(""),A(null),B(null),N(!1),v("edit")},Ge=async ye=>{await x(ye),k()},vt=R.useCallback(ye=>{A(ye),B(null)},[]),Xe=R.useCallback(ye=>{B(ye),A(null)},[]),bt=L!==null?Number(L):-1,ct=bt>=0?Q[bt]??null:null,en=R.useCallback(ye=>{se(_e=>_e.map((De,$e)=>$e===bt?ye:De))},[bt]),He=Y.type==="step_result"?`${Y.result}`:Y.type==="metadata_all_match"?`${Y.key??"?"}=${Y.value??"?"}`:Y.type==="metadata_all_in"?`${Y.key??"?"} in [${((Pi=Y.values)==null?void 0:Pi.join(","))??"?"}]`:DC[Y.type]??Y.type,ur=()=>{const ye=Q.length,_e=xB(Q),De=Pe.find($e=>!$e.subagent);se([...Q,{id:_e,name:(De==null?void 0:De.name)??"Agent",type:"agent",phase:"build",agentId:(De==null?void 0:De.id)??"builder",transitions:[]}]),$||P(_e),vt(String(ye))},Mn=R.useCallback((ye,_e)=>{ye==="$start"?(P(_e),Xe("start")):se(De=>{const $e=De.find(qe=>qe.id===ye),et=$e?$e.transitions.length:0;return Xe(`${ye}:${et}`),De.map(qe=>qe.id===ye?{...qe,transitions:[...qe.transitions,{when:{type:"always"},goto:_e}]}:qe)})},[Xe]),Ri=ye=>{if(ye==="start")return null;const _e=ye.lastIndexOf(":"),De=ye.slice(0,_e),$e=parseInt(ye.slice(_e+1));return{stepId:De,transIdx:$e}},dr=R.useCallback((ye,_e)=>{const De=Ri(ye);De&&se($e=>$e.map(et=>et.id===De.stepId?{...et,transitions:et.transitions.map((qe,dt)=>dt===De.transIdx?_e(qe):qe)}:et))},[]),Oi=R.useCallback((ye,_e)=>{if(ye==="start"){P(_e);return}dr(ye,De=>({...De,goto:_e}))},[dr]),Mi=R.useCallback((ye,_e)=>{const De=Ri(ye);De&&(se($e=>{const et=$e.find(dt=>dt.id===De.stepId);if(!et)return $e;const qe=et.transitions[De.transIdx];return qe?$e.map(dt=>dt.id===De.stepId?{...dt,transitions:dt.transitions.filter((hn,It)=>It!==De.transIdx)}:dt.id===_e?{...dt,transitions:[...dt.transitions,qe]}:dt):$e}),B(null))},[]),wr=R.useCallback(ye=>{if(ye==="start"){P(""),B(null);return}const _e=Ri(ye);_e&&(se(De=>De.map($e=>$e.id===_e.stepId?{...$e,transitions:$e.transitions.filter((et,qe)=>qe!==_e.transIdx)}:$e)),B(null))},[]),Ii=R.useCallback((ye,_e)=>{if(ye==="start"){H(_e);return}dr(ye,De=>({...De,when:_e}))},[dr]),Ys=R.useCallback((ye,_e)=>{ye!=="start"&&dr(ye,De=>({...De,subGroup:_e||void 0}))},[dr]),qa=ye=>ng(ye,Pe).name,El=()=>{if(!D)return null;if(D==="start"){const hn=Q.find(It=>It.id===$);return{type:"start",fromLabel:"Start",toLabel:hn?qa(hn):"(none)",condition:Y}}const ye=D.lastIndexOf(":"),_e=D.slice(0,ye),De=parseInt(D.slice(ye+1)),$e=Q.find(hn=>hn.id===_e);if(!$e)return null;const et=$e.transitions[De];if(!et)return null;const qe=Q.find(hn=>hn.id===et.goto),dt=et.goto==="$done"?"Done":qe?qa(qe):et.goto;return{type:"step",fromLabel:qa($e),toLabel:dt,condition:et.when,subGroup:et.subGroup}};if(S==="edit"){const ye=El();return o.jsxs(Dt,{isOpen:e,onClose:gt,title:T?q:b?"Edit Workflow":"New Workflow",size:"full",children:[ee&&o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:ee}),o.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[o.jsxs("div",{className:"min-w-[140px]",children:[o.jsx("label",{className:xr,children:"Name"}),o.jsx("input",{value:q,onChange:_e=>Zt(_e.target.value),placeholder:"Workflow name",className:`${as} ${T?"opacity-50":""}`,readOnly:T})]}),o.jsxs("div",{className:"min-w-[100px]",children:[o.jsx("label",{className:xr,children:"ID"}),o.jsx("input",{value:O,readOnly:!0,className:`${as} font-mono opacity-50`})]}),o.jsxs("div",{className:"flex-1 min-w-[140px]",children:[o.jsx("label",{className:xr,children:"Description"}),o.jsx("input",{value:G,onChange:_e=>!T&&z(_e.target.value),readOnly:T,placeholder:"What does this workflow do?",className:`${as} ${T?"opacity-50":""}`})]}),o.jsxs("div",{className:"w-20",children:[o.jsx("label",{className:xr,children:"Max Iter."}),o.jsx("input",{type:"number",value:U,onChange:_e=>!T&&J(Number(_e.target.value)),readOnly:T,className:`${as} font-mono ${T?"opacity-50":""}`})]}),o.jsxs("div",{children:[o.jsx("label",{className:xr,children:"Color"}),o.jsx("input",{type:"color",value:F,onChange:_e=>!T&&M(_e.target.value),disabled:T,className:`w-8 h-8 rounded border border-border bg-transparent ${T?"opacity-50":"cursor-pointer"}`})]})]}),o.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[o.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[o.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),!T&&o.jsx("button",{onClick:ur,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),o.jsxs("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:[o.jsx(hB,{steps:Q,entryStep:$,selectedNodeId:(ct==null?void 0:ct.id)??null,selectedEdgeKey:D,startConditionLabel:He,agentTypes:Pe,isReadOnly:T,onSelectNode:_e=>{if(_e===null){vt(null);return}const De=Q.findIndex($e=>$e.id===_e);vt(De>=0?String(De):null)},onSelectEdge:Xe,onRemoveStep:_e=>{var $e;const De=Q.findIndex(et=>et.id===_e);if(se(et=>et.filter(qe=>qe.id!==_e)),bt===De&&vt(null),$===_e){const et=Q.filter(qe=>qe.id!==_e);P((($e=et[0])==null?void 0:$e.id)??"")}},onCreateTransition:Mn,onReconnectTo:Oi,onReconnectFrom:Mi,onDeleteTransition:wr}),Q.length===0&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[o.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),o.jsx("button",{onClick:ur,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"})]})]})]}),o.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[o.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:o.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),o.jsx("div",{className:"p-3 overflow-y-auto flex-1 min-h-0",children:T&&(ye||ct)?o.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):ye?ye.type==="start"?o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),$&&o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[o.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),o.jsx(mS,{}),o.jsx("span",{className:"text-text-primary font-medium",children:ye.toLabel})]}),o.jsxs("div",{children:[o.jsx("label",{className:xr,children:"Activation Condition"}),o.jsx("select",{value:Y.type,onChange:_e=>H(_e.target.value==="step_result"?{type:"step_result",result:"success"}:_e.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:_e.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:_e.target.value}),className:H0,children:RC.map(_e=>o.jsx("option",{value:_e.value,children:_e.label},_e.value))})]}),Y.type==="step_result"&&o.jsxs("div",{children:[o.jsx("label",{className:xr,children:"Result"}),$&&(()=>{const _e=Q.find(qe=>qe.id===$),De=_e&&(_e.type==="sub_agent"||_e.type==="agent")?Pe.find(qe=>qe.id===(_e.type==="sub_agent"?_e.subAgentType:_e.agentId)):void 0,$e=(De==null?void 0:De.results)&&De.results.length>0,et=(De==null?void 0:De.results)??[];return $e?o.jsx("select",{value:Y.result??et[0],onChange:qe=>H({type:"step_result",result:qe.target.value}),className:H0,children:et.map(qe=>o.jsx("option",{value:qe,children:qe},qe))}):o.jsx("input",{type:"text",value:Y.result??"success",onChange:qe=>H({type:"step_result",result:qe.target.value}),placeholder:"e.g. success, passed, failed",className:as})})()]}),(Y.type==="metadata_all_match"||Y.type==="metadata_all_in")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:xr,children:"Metadata Key"}),o.jsx("input",{type:"text",value:Y.key??"",onChange:_e=>H({...Y,key:_e.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:as})]}),o.jsxs("div",{children:[o.jsx("label",{className:xr,children:"Field"}),o.jsx("input",{type:"text",value:Y.field??"",onChange:_e=>H({...Y,field:_e.target.value}),placeholder:"e.g. status",className:as})]}),Y.type==="metadata_all_match"?o.jsxs("div",{children:[o.jsx("label",{className:xr,children:"Value"}),o.jsx("input",{type:"text",value:Y.value??"",onChange:_e=>H({...Y,value:_e.target.value}),placeholder:"e.g. passed, resolved",className:as})]}):o.jsxs("div",{children:[o.jsx("label",{className:xr,children:"Values (comma-separated)"}),o.jsx("input",{type:"text",value:((hs=Y.values)==null?void 0:hs.join(", "))??"",onChange:_e=>H({...Y,values:_e.target.value.split(",").map(De=>De.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:as})]})]}),o.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 _e=Ri(D),De=_e==null?void 0:_e.stepId,$e=(_e==null?void 0:_e.transIdx)??0,et=De?Q.find(dt=>dt.id===De):void 0,qe=(et==null?void 0:et.transitions.length)??0;return o.jsx(pB,{fromLabel:ye.fromLabel,toLabel:ye.toLabel,condition:ye.condition,subGroup:"subGroup"in ye?ye.subGroup:void 0,fromStep:ye.type==="step"?Q.find(dt=>dt.id===ye.fromLabel):void 0,agentTypes:Pe,transitionIndex:$e,totalTransitions:qe,onUpdateCondition:dt=>Ii(D,dt),onUpdateSubGroup:dt=>Ys(D,dt),onDelete:()=>wr(D),onMoveUp:()=>{se(dt=>{const hn=dt.find(xt=>xt.id===De);if(!hn||$e===0)return dt;const It=[...hn.transitions];return[It[$e-1],It[$e]]=[It[$e],It[$e-1]],dt.map(xt=>xt.id===De?{...xt,transitions:It}:xt)}),B(`${De}:${$e-1}`)},onMoveDown:()=>{se(dt=>{const hn=dt.find(xt=>xt.id===De);if(!hn||$e===hn.transitions.length-1)return dt;const It=[...hn.transitions];return[It[$e],It[$e+1]]=[It[$e+1],It[$e]],dt.map(xt=>xt.id===De?{...xt,transitions:It}:xt)}),B(`${De}:${$e+1}`)}})})():ct?o.jsx(mB,{step:ct,isEntry:ct.id===$,agentTypes:Pe,transitionCount:ct.transitions.length,templateVariables:u,onUpdate:en,onRemove:()=>{var _e;if(ct&&(se(Q.filter((De,$e)=>$e!==bt)),vt(null),$===ct.id)){const De=Q.filter(($e,et)=>et!==bt);P(((_e=De[0])==null?void 0:_e.id)??"")}},onSetEntry:()=>P(ct.id)}):o.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",o.jsx("br",{}),"Drag from a port to connect."]})})]})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[o.jsx(tt,{variant:"secondary",onClick:gt,children:"Close"}),T?o.jsx(tt,{variant:"primary",onClick:()=>{W(q+" (copy)"),V(`${b}-copy-${Date.now()}`),E(null),N(!1)},children:"Duplicate & Customize"}):o.jsxs(o.Fragment,{children:[o.jsx(tt,{variant:"primary",onClick:nt,children:"Save"}),o.jsx(tt,{variant:"primary",onClick:Mt,children:"Save & Close"})]})]})]})}return o.jsx(Dt,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:o.jsx(wS,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:Ve,loading:l,hasItems:s.length>0||a.length>0,children:o.jsxs("div",{className:"space-y-4",children:[o.jsx(B0,{title:"Built-in",items:s,renderActions:ye=>o.jsx(o.Fragment,{children:o.jsx(Fs,{onClick:()=>Oe(ye.id),children:o.jsx(uu,{})})})}),o.jsx(B0,{title:"Custom",items:a,renderActions:ye=>o.jsxs(o.Fragment,{children:[o.jsx(Fs,{onClick:()=>Ce(ye.id),children:o.jsx(uu,{})}),o.jsx(Fs,{onClick:()=>me(ye.id),children:o.jsx("span",{className:"text-[10px]",children:"Edit"})}),o.jsx(du,{onClick:()=>Oe(ye.id)}),y(ye.id,"delete")?o.jsx(mp,{onConfirm:()=>Ge(ye.id),onCancel:k}):o.jsx(pp,{onClick:()=>w(ye.id)})]})})]})})})}function MC(e,t){if(!t)return!0;const n=t.toLowerCase().split(/\s+/),s=e.toLowerCase().split(/\s+/);return n.every(a=>{for(const l of s){let u=0;for(let c=0;c<l.length&&u<a.length;c++)l[c]===a[u]&&u++;if(u===a.length)return!0}return!1})}function IC(e,t,n,s,a){switch(e.key){case"ArrowDown":e.preventDefault(),n(l=>Math.min(l+1,t));break;case"ArrowUp":e.preventDefault(),n(l=>Math.max(l-1,0));break;case"Enter":e.preventDefault(),s();break;case"Escape":e.preventDefault(),a();break}}function _B(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function yB({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:s,onSelectWorkflow:a,onCloseCompleteAction:l,textareaContent:u,onSearchMessages:c,onToggleAutoScroll:h,isAutoScrollActive:f}){const[,p]=cr(),m=nn(J=>J.fetchCommands),_=Et(J=>J.fetchWorkflows),x=mt(J=>J.fetchAgents),w=nn(J=>J.defaults),k=nn(J=>J.userItems),y=nn(J=>J.projectItems),S=Et(J=>J.defaults),v=Et(J=>J.userItems),b=Et(J=>J.projectItems),E=mt(J=>J.defaults),T=mt(J=>J.userItems),N=mt(J=>J.projectItems),L=we(J=>{var Q;return(Q=J.currentSession)==null?void 0:Q.mode}),A=we(J=>{var Q;return((Q=J.currentSession)==null?void 0:Q.dangerLevel)??"normal"}),D=we(J=>J.switchMode),B=we(J=>J.switchDangerLevel),q=we(J=>{var Q;return(Q=J.currentSession)==null?void 0:Q.projectId}),W=R.useRef(void 0),[O,V]=R.useState(""),[G,z]=R.useState(0),X=R.useRef(null),ne=R.useRef(!1);R.useEffect(()=>{e&&(ne.current=!0)},[e]),R.useEffect(()=>{if(e){m(),_(),x(),V(""),z(0);const J=setTimeout(()=>{var Q;return(Q=X.current)==null?void 0:Q.focus()},50);return()=>clearTimeout(J)}},[e,m,_,x]),R.useEffect(()=>{var J;!e&&ne.current&&(n==null||n(),(J=W.current)==null||J.call(W),W.current=void 0)},[e,n]);const F=(J,Q)=>{const se=new Set(Q.map(Y=>Y.id));return[...J.filter(Y=>!se.has(Y.id)),...Q]},$=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const J=q??_B(window.location.pathname);J&&p(`/p/${J}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{W.current=l,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),c==null||c()}},{id:"toggle-autoscroll",name:f?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),h==null||h(!f)}},...F(F(E,T),N).filter(J=>!J.subagent&&J.id!==L).map(J=>({id:J.id,name:J.name,prefix:"Agent > Switch to",action:()=>D(J.id)})),...F(F(w,k),y).map(J=>({id:J.id,name:J.name,prefix:"Command > Launch",action:()=>s(J.id,u)})),...F(F(S,v),b).map(J=>({id:J.id,name:J.name,prefix:"Workflow > Run",action:()=>a(J.id)})),...["normal","dangerous"].filter(J=>J!==A).map(J=>({id:J,name:J.charAt(0).toUpperCase()+J.slice(1),prefix:"Mode > Switch to",action:()=>B(J)}))].filter(J=>MC(`${J.prefix} ${J.name}`,O)),P=$.length-1,U=J=>{IC(J,P,z,()=>{var Q;(Q=$[G])==null||Q.action(),t()},t)};return e?$a.createPortal(o.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[o.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),o.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[o.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[o.jsx("input",{ref:X,type:"text",value:O,onChange:J=>{V(J.target.value),z(0)},onKeyDown:U,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),o.jsx(dp,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),o.jsx("div",{className:"overflow-y-auto max-h-[60vh] p-2",children:$.length===0?o.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:w.length+k.length+S.length+v.length>0?"No matches":"No agents, commands, or workflows yet"}):$.map((J,Q)=>o.jsxs("button",{type:"button",onClick:()=>{J.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${Q===G?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:[o.jsxs("span",{className:"text-text-muted font-normal",children:[J.prefix," "]}),o.jsx("span",{children:J.name})]},J.id))})]})]}),document.body):null}function vB(e){const t=new Date(e),n=new Date;if(t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear())return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});const a=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0"),c=String(t.getHours()).padStart(2,"0"),h=String(t.getMinutes()).padStart(2,"0");return`${a}/${l}/${u} ${c}:${h}`}function bB(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 SB(e){var t,n;if(e.type==="message"){const s=e.message;if(s.role==="assistant"){const a=(t=s.content)==null?void 0:t.trim();return((n=s.thinkingContent)==null?void 0:n.trim())&&!a?"italic text-text-muted":""}if(s.role==="user")return"font-bold"}return""}function wB(e){var n,s;if(e.type!=="message")return o.jsx(Rv,{className:"w-3.5 h-3.5"});const t=e.message;return t.role==="assistant"?(n=t.thinkingContent)!=null&&n.trim()&&!((s=t.content)!=null&&s.trim())?o.jsx(Pj,{className:"w-3.5 h-3.5"}):o.jsx(Rv,{className:"w-3.5 h-3.5"}):o.jsx(Ij,{className:"w-3.5 h-3.5"})}function U0(e){var t;if(e.type==="message"){const n=e.message,s=n.content||"",a=s.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(n.messageKind==="workflow-started")try{return`Workflow: ${JSON.parse(s).workflowName}`}catch{return"Workflow started"}if(n.messageKind==="task-completed")return"Task completed";if(n.messageKind==="auto-prompt")return"Auto-prompt";if(n.messageKind==="correction")return"Correction";if(n.messageKind==="context-reset")return"Context reset";if(n.messageKind==="command")return"Command executed";if(n.role==="assistant")return a?a.slice(0,200):(t=n.thinkingContent)!=null&&t.trim()?n.thinkingContent.slice(0,200):"";const l=a.slice(0,200);return l.length<a.length?`${l}...`:l}return e.type==="subagent"?`Sub-agent: ${e.subAgentType}`:e.type==="criteria-batch"?"Acceptance Criteria":""}function CB({isOpen:e,onClose:t,displayItems:n,onNavigate:s}){const[a,l]=R.useState(""),[u,c]=R.useState(0),h=R.useRef(null),f=R.useRef(null),p=R.useMemo(()=>n.filter(y=>{var S,v;return!(y.type==="context-divider"||y.type==="message"&&y.message.role==="assistant"&&!((S=y.message.content)!=null&&S.trim())&&!((v=y.message.thinkingContent)!=null&&v.trim()))}),[n]),m=R.useMemo(()=>a?p.filter(y=>{const S=U0(y);return MC(S,a)}):p,[p,a]),_=m.length-1;R.useEffect(()=>{if(e){l(""),c(0);const y=setTimeout(()=>{var S;return(S=h.current)==null?void 0:S.focus()},50);return()=>clearTimeout(y)}},[e]),R.useEffect(()=>{e&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[e]);const x=y=>{IC(y,_,c,()=>{const S=m[u];if(S){const v=n.indexOf(S);v>=0&&s(v),t()}},t)},w=y=>{const S=n.indexOf(y);S>=0&&s(S),t()},k=y=>n.indexOf(y);return e?$a.createPortal(o.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[o.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),o.jsxs("div",{className:"relative w-full max-w-lg bg-bg-secondary border border-border rounded shadow-xl",children:[o.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[o.jsx(cp,{}),o.jsx("input",{ref:h,type:"text",value:a,onChange:y=>{l(y.target.value),c(0)},onKeyDown:x,placeholder:"Search timeline...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),o.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:o.jsx(gl,{className:"w-4 h-4"})})]}),o.jsx("div",{ref:f,className:"overflow-y-auto max-h-[60vh] p-2",children:m.length===0?o.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:p.length>0?"No matches":"No messages yet"}):m.map((y,S)=>{const v=k(y),b=wB(y),E=U0(y),T=SB(y),N=bB(y),L=y.type==="message"&&y.message.role==="user";return o.jsx("button",{type:"button",onClick:()=>w(y),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${S===u?"bg-accent-primary/20 text-text-primary":L?"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:o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[o.jsx("span",{className:"flex-shrink-0",children:b}),o.jsx("span",{className:`truncate flex-1 ${T}`,children:E})]}),N&&o.jsx("span",{className:"text-text-muted text-xs shrink-0",children:vB(N)})]})},`${v}-${y.type}`)})})]})]}),document.body):null}function kB({attachment:e,onRemove:t}){const n=s=>s<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:`${(s/1048576).toFixed(1)} MB`;return o.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[o.jsx(yl,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),o.jsx("img",{src:e.data,alt:e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}),o.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),o.jsx("div",{className:"text-[10px] text-text-muted",children:n(e.size)})]})}function EB({history:e,selectedIndex:t,onSelect:n,onEscape:s,onNavigate:a}){const l=R.useRef(null),u=R.useRef(null);R.useEffect(()=>{u.current&&l.current&&u.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[t]);const c=f=>{switch(f.key){case"Enter":f.preventDefault(),e[t]&&n(e[t].content);break;case"Escape":f.preventDefault(),s();break;case"ArrowUp":f.preventDefault(),a("up");break;case"ArrowDown":f.preventDefault(),a("down");break}},h=f=>{n(f)};return o.jsx("div",{ref:l,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg overflow-y-auto max-h-64",onKeyDown:c,children:e.map((f,p)=>o.jsxs("div",{ref:p===t?u:null,role:"listitem",onClick:()=>h(f.content),className:`
|
|
293
|
+
p-2 rounded cursor-pointer transition-colors
|
|
294
|
+
${p===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
|
|
295
|
+
`,children:[o.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[f.formattedTimestamp,f.sessionName&&o.jsxs(o.Fragment,{children:[" | ",o.jsx("span",{className:"text-accent-primary font-medium",children:f.sessionName})]})]}),o.jsx("div",{className:"text-sm text-text-primary mt-1",children:f.trimmedContent})]},f.id))})}function jB(){const e=uj(),t=e?"bg-amber-400":"bg-accent-primary";return o.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs("span",{className:"flex gap-0.5",children:[o.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"0ms"}}),o.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"150ms"}}),o.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"300ms"}})]}),o.jsx("span",{className:"text-text-secondary",children:e?"Running... (abort in progress)":"Running"})]}),!e&&o.jsx("span",{className:"text-text-muted",children:"esc to interrupt"})]})}const NB={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function TB(e,t={}){const n={...NB,...t};if(!e.type.startsWith("image/"))throw new Error("File is not an image");if(!["image/png","image/jpeg","image/gif"].includes(e.type))throw new Error(`Unsupported image format: ${e.type}. Only PNG, JPG, and GIF are supported.`);if(e.size<=n.maxSizeBytes){const a=await e.arrayBuffer(),l=IB(a),u=`data:${e.type};base64,${l}`,c=await PC(u);return{dataUrl:u,mimeType:e.type,size:e.size,width:c.width,height:c.height}}return await AB(e,n)}async function AB(e,t){const n=await DB(e),s=await PC(n),{width:a,height:l}=LB(s.width,s.height,t.maxWidth,t.maxHeight),u=RB();u.width=a,u.height=l;const c=u.getContext("2d");if(!c)throw new Error("Failed to get canvas context");c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="high",c.drawImage(s,0,0,a,l);let h=t.quality,f="";for(let m=0;m<10&&(f=u.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,h),!(F0(f)<=t.maxSizeBytes||h<=.3));m++)h-=.1;const p=F0(f);return{dataUrl:f,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:p,width:a,height:l}}function LB(e,t,n,s){const a=e/t;return e>t&&e>n?{width:n,height:Math.round(n/a)}:t>e&&t>s?{width:Math.round(s*a),height:s}:{width:e,height:t}}function DB(e){return new Promise((t,n)=>{const s=MB(),a=new s;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function PC(e){return new Promise((t,n)=>{const s=OB(),a=new s;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function RB(){var t;const e=rg();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function OB(){const e=rg();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function MB(){const e=rg();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function rg(){return globalThis}function IB(e){const t=new Uint8Array(e);let n="";for(let s=0;s<t.byteLength;s++){const a=t[s];a!==void 0&&(n+=String.fromCharCode(a))}return btoa(n)}function F0(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}function PB(e){return["image/png","image/jpeg","image/gif"].includes(e.type)}function BB(e,t=50*1024*1024){return e.size>t?{valid:!1,error:`Image file is too large (${V0(e.size)}). Maximum size is ${V0(t)}.`}:{valid:!0}}function V0(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}async function xm(e,t,n,s={}){const{maxSizeBytes:a=50*1024*1024,filename:l}=s;if(!PB(e)){n(`Unsupported file type: ${e.type}. Only PNG, JPG, and GIF are supported.`);return}const u=BB(e,a);if(!u.valid){n(u.error??"Image file is too large");return}try{const c=await TB(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),h={id:oS(),filename:l??e.name,mimeType:c.mimeType,size:c.size,data:c.dataUrl};t(h)}catch(c){const h=c instanceof Error?c.message??"Failed to process image":"Failed to process image";n(h)}}function zB({children:e}){return $a.createPortal(e,document.body)}function HB(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 $B({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:s,onOpenWorkflowsManager:a,onAttach:l,textareaContent:u,attachments:c}){const[h,f]=R.useState(!1),[p,m]=R.useState("commands"),[_,x]=R.useState(""),[w,k]=R.useState(0),[y,S]=R.useState(null),[v,b]=R.useState(null),E=R.useRef(null),T=R.useRef(null),N=nn(P=>P.defaults),L=nn(P=>P.userItems),A=nn(P=>P.fetchCommands),D=Et(P=>P.defaults),B=Et(P=>P.userItems),q=Et(P=>P.fetchWorkflows),W=[...N,...L],O=[...D,...B];R.useEffect(()=>{h&&(p==="commands"?A():p==="workflows"&&q())},[h,p,A,q]),R.useEffect(()=>{h&&(x(""),k(0),requestAnimationFrame(()=>{var P;return(P=E.current)==null?void 0:P.focus()}))},[h,p]),R.useEffect(()=>{if(!h)return;const P=U=>{var J;(J=T.current)!=null&&J.contains(U.target)||f(!1)};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[h]);const V=P=>{switch(P.key){case"ArrowDown":P.preventDefault(),k(U=>{const Q=(p==="commands"?W:O).filter(se=>{const Y=_.toLowerCase();return!Y||se.name.toLowerCase().includes(Y)});return Math.min(U+1,Q.length-1)});break;case"ArrowUp":P.preventDefault(),k(U=>Math.max(U-1,0));break;case"Enter":P.preventDefault();break;case"Escape":P.preventDefault(),f(!1);break}},G=P=>{x(P),k(0)},z=W.filter(P=>!_||P.name.toLowerCase().includes(_.toLowerCase())),X=O.filter(P=>!_||P.name.toLowerCase().includes(_.toLowerCase())),ne=async P=>{const U=await nn.getState().fetchCommand(P);U&&e(U.prompt,U.metadata.agentMode,u,c),f(!1)},F=P=>{t(P),f(!1)},M=(P,U)=>{U.stopPropagation(),f(!1),S(P)},$=(P,U)=>{U.stopPropagation(),f(!1),b(P)};return o.jsxs("div",{ref:T,className:"relative",children:[o.jsx("button",{type:"button",onClick:()=>f(!h),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:o.jsx(gS,{className:"w-4 h-4"})}),h&&o.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:[o.jsxs("div",{className:"flex border-b border-border",children:[o.jsx("button",{type:"button",onClick:()=>{m("commands"),x(""),k(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"}),o.jsx("button",{type:"button",onClick:()=>{m("workflows"),x(""),k(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"}),o.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"&&o.jsx("div",{className:"p-2 border-b border-border",children:o.jsx("input",{ref:E,value:_,onChange:P=>G(P.target.value),onKeyDown:V,placeholder:p==="commands"?"Search commands...":"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),o.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:p==="commands"?z.length===0?o.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:W.length===0?"No commands yet":"No matches"}):z.map((P,U)=>o.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${U===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[o.jsx("button",{type:"button",onClick:()=>ne(P.id),className:"flex-1 text-left",children:o.jsx("div",{className:"text-sm text-text-primary font-medium",children:P.name})}),o.jsx(Fs,{className:"opacity-0 group-hover:opacity-100",onClick:J=>M(P.id,J)})]},P.id)):p==="workflows"?X.length===0?o.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:O.length===0?"No workflows yet":"No matches"}):X.map((P,U)=>{const J=HB(P),Q=P.color??"#3b82f6";return o.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${U===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[o.jsxs("button",{type:"button",onClick:()=>F(P.id),className:"flex-1 text-left flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:Q}}),o.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:P.name}),J!==null&&o.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:J?"#22c55e":"#6b7280"},title:J?"Entry condition met":"Entry condition not met"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[P.subGroups&&P.subGroups.length>0&&o.jsx(UB,{subGroups:P.subGroups,onSelect:se=>{f(!1),n(P.id,se)}}),o.jsx(Fs,{className:"opacity-0 group-hover:opacity-100",onClick:se=>$(P.id,se)})]})]},P.id)}):o.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[o.jsxs("button",{type:"button",onClick:()=>{l(),f(!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:[o.jsx(xj,{className:"w-4 h-4"}),o.jsx("span",{className:"text-sm font-medium",children:"Attach image"})]}),o.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),p!=="attach"&&o.jsx("div",{className:"border-t border-border p-1",children:o.jsx("button",{type:"button",onClick:()=>{f(!1),p==="commands"?s():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..."})})]}),o.jsx(LC,{isOpen:!!y,onClose:()=>S(null),initialEditId:y}),o.jsx(OC,{isOpen:!!v,onClose:()=>b(null),initialEditId:v})]})}function UB({subGroups:e,onSelect:t}){const[n,s]=R.useState(!1),[a,l]=R.useState({top:0,right:0}),u=R.useRef(null),c=R.useRef(null);AC(c,()=>s(!1),n);const h=f=>{if(f.stopPropagation(),!n&&u.current){const p=u.current.getBoundingClientRect();l({top:p.bottom+4,right:window.innerWidth-p.right})}s(!n)};return o.jsxs(o.Fragment,{children:[o.jsx("button",{ref:u,type:"button",onClick:h,className:"p-1 rounded text-text-muted hover:text-text-primary transition-colors",title:"Sub-groups",children:"⋮"}),n&&o.jsx(zB,{children:o.jsx("div",{ref:c,onMouseDown:f=>f.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(f=>o.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),t(f)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:f},f))})})]})}function FB({messages:e,onCancel:t}){return e.length===0?null:o.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:e.map(n=>o.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:[o.jsxs("span",{className:"font-medium",children:[n.mode==="asap"?"ASAP":"Queue",":"]}),o.jsx("span",{className:"truncate max-w-[200px]",children:n.content}),o.jsx(yl,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function VB({agent:e,isBuiltIn:t,isConfirmingDelete:n,onView:s,onEdit:a,onDuplicate:l,onDelete:u}){return o.jsxs(ES,{isBuiltIn:t,isConfirmingDelete:n,onView:s,onEdit:a,onDuplicate:l,onDelete:u,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:e.color??"#6b7280"}}),o.jsx("span",{className:"text-text-primary text-sm font-medium",children:e.name}),o.jsx("span",{className:"text-text-muted text-xs font-mono",children:e.id}),t&&o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),e.description&&o.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),o.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[e.allowedTools.slice(0,5).map(c=>o.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:c},c)),e.allowedTools.length>5&&o.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",e.allowedTools.length-5," more"]})]})]})}function G0({title:e,agents:t,subagents:n,isBuiltIn:s,onView:a,onDuplicate:l,onEdit:u,onDelete:c}){if(t.length===0&&n.length===0)return null;const h=f=>o.jsx(VB,{agent:f,isBuiltIn:s,isConfirmingDelete:!1,onView:()=>a(f.id),onEdit:s?void 0:()=>u==null?void 0:u(f.id),onDuplicate:()=>l(f.id),onDelete:s?void 0:()=>c==null?void 0:c(f.id)},f.id);return o.jsxs("div",{children:[o.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),o.jsxs("div",{className:"space-y-2",children:[t.map(h),n.length>0&&o.jsxs("div",{className:"mt-3",children:[o.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:"Sub-agents"}),o.jsx("div",{className:"space-y-2",children:n.map(h)})]})]})]})}function GB(e){const t=new Map;for(const n of e){const s=n.indexOf(":");if(s===-1)t.set(n,new Set);else{const a=n.slice(0,s),u=n.slice(s+1).split(",").filter(Boolean);t.set(a,new Set(u))}}return t}function _m(e){const t=[];for(const[n,s]of e)s.size===0?t.push(n):t.push(`${n}:${[...s].join(",")}`);return t}function WB({formName:e,formId:t,formDescription:n,formSubagent:s,formTools:a,formColor:l,formPrompt:u,formError:c,saving:h,isReadOnly:f,availableTools:p,onNameChange:m,onIdChange:_,onDescriptionChange:x,onSubagentChange:w,onColorChange:k,onPromptChange:y,onSave:S,onCancel:v,onDuplicate:b}){const E=GB(a),T=(A,D)=>{const B=new Map(E),q=B.get(A)||new Set,W=new Set(q);W.has(D)?W.delete(D):W.add(D),W.size===0?B.set(A,new Set):B.set(A,W),L(_m(B))},N=A=>{const D=new Map(E);D.has(A)?D.delete(A):D.set(A,new Set),L(_m(D))},L=A=>{};return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"space-y-3",children:[c&&o.jsx(gp,{message:c}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(ji,{label:"Name",value:e,onChange:m,placeholder:"My Agent",readOnly:f}),o.jsx(ji,{label:"ID",value:t,onChange:_,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(ji,{label:"Description",value:n,onChange:x,placeholder:"What this agent does",readOnly:f}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),o.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[o.jsx("button",{onClick:()=>!f&&w(!0),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${s?"bg-accent-primary/25 text-accent-primary":"bg-bg-tertiary text-text-muted hover:text-text-secondary"} ${f?"pointer-events-none opacity-60":""}`,children:"Sub-agent"}),o.jsx("button",{onClick:()=>!f&&w(!1),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${s?"bg-bg-tertiary text-text-muted hover:text-text-secondary":"bg-accent-primary/25 text-accent-primary"} ${f?"pointer-events-none opacity-60":""}`,children:"Top-level"}),o.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[o.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),o.jsx("input",{type:"color",value:l,onChange:A=>!f&&k(A.target.value),disabled:f,className:"w-6 h-6 rounded cursor-pointer border border-border bg-transparent"})]})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Tools"}),o.jsx("div",{className:"flex flex-wrap gap-1.5 p-2 bg-bg-tertiary border border-border rounded max-h-32 overflow-y-auto",children:p.map(A=>{const D=E.has(A.name),B=A.actions.length>0,q=E.get(A.name)||new Set;return B?f?o.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:[o.jsx("span",{children:A.name}),o.jsx("span",{className:"text-[10px]",children:"*"})]},A.name):o.jsx(xl,{trigger:o.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${D?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted"}`,children:[o.jsx("span",{children:A.name}),B&&o.jsx("span",{className:`text-[10px] ${D&&q.size>0?"text-accent-primary":"text-text-muted"}`,children:"*"})]}),minWidth:"160px",items:[...A.actions.map(W=>({label:o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${A.name}-${W}`,children:[o.jsx("input",{type:"checkbox",id:`${A.name}-${W}`,checked:q.has(W),onChange:()=>T(A.name,W),disabled:f,className:"w-3 h-3 rounded accent-accent-primary"}),o.jsx("span",{children:W})]}),closeOnClick:!1})),{label:D?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(D)N(A.name);else{const W=new Map(E);W.set(A.name,new Set(A.actions)),L(_m(W))}}}]},A.name):o.jsx("button",{onClick:()=>!f&&N(A.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${D?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${f?"pointer-events-none":"cursor-pointer"}`,children:o.jsx("span",{children:A.name})},A.name)})})]})]}),o.jsxs("div",{className:"flex-1 min-h-[150px] border-t border-border pt-3 flex flex-col",children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),o.jsx("textarea",{value:u,onChange:A=>!f&&y(A.target.value),readOnly:f,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 ${f?"opacity-60":""}`})]}),o.jsx(Kj,{onCancel:v,onSave:S,saving:h,saveDisabled:!e||!u||f}),f&&o.jsx("div",{className:"flex justify-end mt-2",children:o.jsx("button",{onClick:b,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"})})]})}function qB(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"")}function KB({isOpen:e,onClose:t,initialEditId:n}){const s=mt(de=>de.defaults),a=mt(de=>de.userItems),l=mt(de=>de.loading),u=mt(de=>de.fetchAgents),c=mt(de=>de.fetchAgent),h=mt(de=>de.fetchDefaultContent),f=mt(de=>de.createAgent),p=mt(de=>de.updateAgent),m=mt(de=>de.deleteAgent),[_,x]=R.useState("list"),[w,k]=R.useState(null),[y,S]=R.useState(!1),[v,b]=R.useState(""),[E,T]=R.useState(""),[N,L]=R.useState(""),[A,D]=R.useState(!0),[B,q]=R.useState([]),[W,O]=R.useState("#6b7280"),[V,G]=R.useState(""),[z,X]=R.useState(""),[ne,F]=R.useState(!1),[M,$]=R.useState([]),P=de=>{b(de.metadata.name),T(de.metadata.id),L(de.metadata.description),D(de.metadata.subagent),q(de.metadata.allowedTools),O(de.metadata.color??"#6b7280"),G(de.prompt),X("")},U=(de,Ie,Se)=>{b(de.metadata.name+" (copy)"),T(`${Ie}-copy-${Date.now()}`),L(de.metadata.description),D(de.metadata.subagent),q(de.metadata.allowedTools),O(de.metadata.color??"#6b7280"),G(de.prompt),X(""),k(null),S(!1),x("edit")},J=(de,Ie)=>{P(de),k(Ie),S(!0),x("edit")};R.useEffect(()=>{e&&(u(),Ne("/api/tools").then(de=>de.json()).then(de=>$(de.tools||[])).catch(()=>$([])),n?s.some(Ie=>Ie.id===n)?h(n).then(Ie=>{Ie&&U(Ie,n)}):c(n).then(Ie=>{Ie&&(P(Ie),k(n),S(!1),x("edit"))}):(x("list"),k(null),S(!1)))},[e,u,c,h,n]);const Q=async de=>{if(s.some(Se=>Se.id===de)){const Se=await h(de);if(!Se)return;J(Se,de)}else{const Se=await c(de);if(!Se)return;J(Se,de)}},se=async de=>{const Ie=await h(de);Ie&&U(Ie,de)},Y=()=>{k(null),b(""),T(""),L(""),D(!0),q(["read_file"]),O("#6b7280"),G(""),X(""),S(!1),x("edit")},H=async de=>{const Ie=await c(de);Ie&&(P(Ie),k(de),S(!1),x("edit"))},ee=async de=>{await m(de)},te=async()=>{const de=w??E;if(!de||!v||!V){X("Name and prompt are required.");return}F(!0),X("");const Ie={metadata:{id:de,name:v,description:N,subagent:A,allowedTools:B,color:W},prompt:V},Se=w?await p(w,Ie):await f(Ie);if(F(!1),!Se.success){X(Se.error??"Failed to save agent.");return}n?t():x("list")},ce=()=>{n?t():(x("list"),S(!1))},he=de=>{b(de),w||T(qB(de))},Te=s.filter(de=>de.subagent),Ae=s.filter(de=>!de.subagent),Le=a.filter(de=>de.subagent),Pe=a.filter(de=>!de.subagent);return _==="edit"?o.jsx(Dt,{isOpen:e,onClose:ce,title:y?`${v}`:w?"Edit Agent":"New Agent",size:"xl",children:o.jsx(WB,{formName:v,formId:E,formDescription:N,formSubagent:A,formTools:B,formColor:W,formPrompt:V,formError:z,saving:ne,isReadOnly:y,availableTools:M,onNameChange:he,onIdChange:T,onDescriptionChange:L,onSubagentChange:D,onColorChange:O,onPromptChange:G,onSave:te,onCancel:ce,onDuplicate:()=>{b(v+" (copy)"),T(`${w}-copy-${Date.now()}`),k(null),S(!1)}})}):o.jsx(Dt,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:o.jsx(wS,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:Y,loading:l,hasItems:s.length>0||a.length>0,children:o.jsxs("div",{className:"space-y-4",children:[s.length>0&&o.jsx(G0,{title:"Built-in",agents:Ae,subagents:Te,isBuiltIn:!0,onView:Q,onDuplicate:se}),a.length>0&&o.jsx(G0,{title:"Custom",agents:Pe,subagents:Le,isBuiltIn:!1,onView:Q,onDuplicate:se,onEdit:H,onDelete:ee})]})})})}function YB(){const e=we(v=>{var b;return(b=v.currentSession)==null?void 0:b.mode}),t=we(v=>v.switchMode),n=mt(v=>v.defaults),s=mt(v=>v.userItems),a=mt(v=>v.fetchAgents),l=[...n,...s],[u,c]=R.useState(!1),[h,f]=R.useState(!1),[p,m]=R.useState(null),_=R.useRef(null);R.useEffect(()=>{a()},[a]),R.useEffect(()=>{function v(b){_.current&&!_.current.contains(b.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);const x=up();if(!e)return null;const w=l.filter(v=>!v.subagent),k=w.find(v=>v.id===e),y=(k==null?void 0:k.name)??e,S=il(l,e);return o.jsxs("div",{className:"relative",ref:_,children:[o.jsxs("button",{type:"button",onClick:()=>c(!u),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[o.jsx("span",{className:"text-sm font-medium",style:{color:S},children:y}),o.jsx(Sr,{className:`w-3 h-3 text-text-muted transition-transform ${u?"rotate-180":""}`})]}),u&&w.length>0&&o.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:[w.map((v,b)=>{const E=v.id===e,T=il(l,v.id),N=x.agentSwitching[b],L=N?yS(N):null;return o.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors group ${E?"bg-bg-tertiary":"hover:bg-bg-tertiary cursor-pointer"}`,children:[o.jsxs("button",{type:"button",onClick:()=>{E||t(v.id),c(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"font-medium truncate",style:{color:T},children:v.name}),E&&o.jsx(Mr,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),L&&o.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:L})]},v.id)}),o.jsx("div",{className:"border-t border-border p-1",children:o.jsx("button",{type:"button",onClick:()=>{c(!1),f(!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..."})})]}),o.jsx(KB,{isOpen:h,onClose:()=>{f(!1),m(null)},initialEditId:p})]})}function XB(){const e=we(s=>s.currentSession),t=we(s=>s.switchDangerLevel);if(!e)return null;const n=e.dangerLevel??"normal";return o.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[o.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"}),o.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 W0({message:e,field:t,label:n}){const s=e==null?void 0:e[t];return o.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[o.jsx("span",{className:s!=null?"text-accent-success":"text-red-500",children:s!=null?"✓":"✗"}),o.jsxs("span",{className:"text-text-secondary",children:[n,":"]}),o.jsx("span",{className:"text-text-primary font-mono truncate max-w-[200px]",children:JSON.stringify(s??"undefined")})]})}function q0({kwargs:e,onChange:t,mode:n,modelId:s,testResults:a,thinkingField:l,onSeeRaw:u,onTest:c}){var f,p,m,_,x;const h=s+"-"+n;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Extra kwargs"}),o.jsx("input",{type:"text",value:e,onChange:w=>t(w.target.value),className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono"})]}),o.jsxs("div",{className:"flex gap-2 items-start",children:[o.jsx("button",{onClick:c,disabled:(f=a[h])==null?void 0:f.loading,className:"px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-muted hover:text-text-secondary disabled:opacity-50",children:(p=a[h])!=null&&p.loading?"Testing...":"Test"}),((m=a[h])==null?void 0:m.result)&&o.jsx(QB,{testKey:h,testResults:a,thinkingField:l,onSeeRaw:u}),((_=a[h])==null?void 0:_.error)&&o.jsx("span",{className:"text-xs text-red-500",children:(x=a[h])==null?void 0:x.error})]})]})}function QB({testKey:e,testResults:t,thinkingField:n,onSeeRaw:s}){const a=t[e];if(!(a!=null&&a.result))return null;const l=a.message,u=n||(l!=null&&l.reasoning?"reasoning":l!=null&&l.reasoning_content?"reasoning_content":l!=null&&l.thinking?"thinking":void 0);return o.jsxs("div",{className:"flex-1 space-y-1",children:[a.message&&o.jsxs(o.Fragment,{children:[o.jsx(W0,{message:a.message,field:"content",label:"content"}),u&&o.jsx(W0,{message:a.message,field:u,label:u})]}),o.jsx("button",{onClick:()=>s(a.result??""),className:"text-xs text-accent-primary hover:underline",children:"See raw output"})]})}const JB=[8e3,11434,8080],ZB=[{value:"auto",label:"Auto-detect"},{value:"vllm",label:"vLLM"},{value:"sglang",label:"SGLang"},{value:"ollama",label:"Ollama"},{value:"llamacpp",label:"llama.cpp"},{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"opencode-go",label:"OpenCode Go"}];function BC({isOpen:e,onClose:t,onSave:n,initialStep:s=1,editProvider:a,editModelId:l}){const[u,c]=R.useState(s),[h,f]=R.useState(""),[p,m]=R.useState(""),[_,x]=R.useState("auto"),[w,k]=R.useState(""),[y,S]=R.useState(!1),[v,b]=R.useState(!1),[E,T]=R.useState(null),[N,L]=R.useState([]),[A,D]=R.useState(null),[B,q]=R.useState(!1),[W,O]=R.useState(""),[V,G]=R.useState({}),[z,X]=R.useState('{"enable_thinking": true}'),[ne,F]=R.useState('{"enable_thinking": false}'),[M,$]=R.useState({}),[P,U]=R.useState(null);function J(H,ee){G(te=>({...te,[H]:{...te[H],...ee}}))}R.useEffect(()=>{var H,ee;if(e)if(c(s),f((a==null?void 0:a.name)??""),m((a==null?void 0:a.url)??""),x((a==null?void 0:a.backend)??"auto"),k((a==null?void 0:a.apiKey)??""),S((a==null?void 0:a.isLocal)??!1),T(null),O((a==null?void 0:a.thinkingField)??""),$({}),U(null),(H=a==null?void 0:a.models)!=null&&H.length){const te={};for(const ce of a.models)te[ce.id]={contextWindow:ce.contextWindow,supportsVision:ce.supportsVision,thinkingEnabled:ce.thinkingEnabled,thinkingLevel:ce.thinkingLevel??(ce.thinkingEnabled?"max":void 0),nonThinkingEnabled:ce.nonThinkingEnabled,thinkingExtraKwargs:ce.thinkingExtraKwargs,nonThinkingExtraKwargs:ce.nonThinkingExtraKwargs,defaultTemperature:ce.defaultTemperature,defaultTopP:ce.defaultTopP,defaultTopK:ce.defaultTopK,defaultMaxTokens:ce.defaultMaxTokens};G(te),L(a.models.map(ce=>({id:ce.id,contextWindow:ce.contextWindow}))),D(l??((ee=a.models[0])==null?void 0:ee.id)??null)}else L([]),G({}),D(null)},[e,s,a,l]),R.useEffect(()=>{u===2&&p&&N.length===0&&!v&&!E&&Q(p)},[u]);async function Q(H){var ee,te;b(!0),T(null),L([]);try{const ce=await Ne(`/api/providers/models?url=${encodeURIComponent(H)}`);if(ce.ok){const he=await ce.json();if((ee=he.models)!=null&&ee.length){L(he.models),D(((te=he.models[0])==null?void 0:te.id)??null);const Te={};for(const Ae of he.models)Te[Ae.id]={contextWindow:Ae.contextWindow,thinkingEnabled:!0,thinkingLevel:"max",defaultTemperature:Ae.defaultTemperature,defaultTopP:Ae.defaultTopP,defaultTopK:Ae.defaultTopK,defaultMaxTokens:Ae.defaultMaxTokens};G(Te)}}else{const he=await ce.json();T(he.error??`Failed to fetch models from ${H}`)}}catch(ce){T(`Failed to fetch models from ${H}: ${ce instanceof Error?ce.message:"Unknown error"}`)}b(!1)}async function se(H,ee){const te=H+"-"+ee;$(Te=>({...Te,[te]:{loading:!0}}));const ce=V[H],he={};if(ee==="thinking"){if(he.reasoning_effort=(ce==null?void 0:ce.thinkingLevel)??"low",z)try{he.chat_template_kwargs=JSON.parse(z)}catch{}}else if(he.reasoning_effort="none",ne)try{he.chat_template_kwargs=JSON.parse(ne)}catch{}try{const Te=await Ne("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,model:H,params:he,apiKey:w||void 0})}),Ae=await Te.json();Te.ok?$(Le=>({...Le,[te]:{loading:!1,result:JSON.stringify(Ae,null,2),message:Ae.message}})):$(Le=>({...Le,[te]:{loading:!1,error:Ae.error??"Test failed"}}))}catch(Te){$(Ae=>({...Ae,[te]:{loading:!1,error:Te instanceof Error?Te.message:"Request failed"}}))}}function Y(){const H=h||"Provider",ee=(a==null?void 0:a.id)??`temp-${Date.now()}`;n({id:ee,name:H,url:p,backend:_,apiKey:w||void 0,isLocal:y||void 0,thinkingField:W||void 0,models:N.map(te=>{var ce,he,Te,Ae,Le,Pe,de;return{id:te.id,contextWindow:((ce=V[te.id])==null?void 0:ce.contextWindow)??te.contextWindow,supportsVision:(he=V[te.id])==null?void 0:he.supportsVision,thinkingEnabled:(Te=V[te.id])==null?void 0:Te.thinkingEnabled,thinkingLevel:(Ae=V[te.id])==null?void 0:Ae.thinkingLevel,nonThinkingEnabled:(Le=V[te.id])==null?void 0:Le.nonThinkingEnabled,thinkingExtraKwargs:(Pe=V[te.id])==null?void 0:Pe.thinkingExtraKwargs,nonThinkingExtraKwargs:(de=V[te.id])==null?void 0:de.nonThinkingExtraKwargs}})}),t()}return e?o.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:H=>{H.target===H.currentTarget&&t()},children:[o.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[85vh] overflow-y-auto shadow-2xl",children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[o.jsx("h3",{className:"text-lg font-semibold text-text-primary",children:a?"Edit Provider":"Add Provider"}),o.jsx("button",{onClick:t,className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),o.jsx("div",{className:"flex gap-1.5 px-6 pt-4",children:[1,2,3].map(H=>o.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${H<u?"bg-accent-success":H===u?"bg-accent-primary":"bg-border"}`},H))}),u===1&&o.jsxs("div",{className:"px-6 py-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Common URLs"}),o.jsx("div",{className:"grid grid-cols-3 gap-2",children:JB.map(H=>o.jsxs("button",{type:"button",onClick:()=>{f(""),m(`http://localhost:${H}`),x("auto"),T(null)},className:`p-2 rounded border text-center text-sm transition-colors ${p===`http://localhost:${H}`?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:["localhost:",H]},H))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"API URL"}),o.jsx("input",{type:"text",value:p,"data-testid":"provider-modal-url",onChange:H=>{m(H.target.value),T(null),L([]),G({})},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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name"}),o.jsx("input",{type:"text",value:h,onChange:H=>f(H.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"})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm text-text-secondary mb-1",children:["API key ",o.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),o.jsx("input",{type:"password",value:w,onChange:H=>k(H.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"})]}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:y,onChange:H=>S(H.target.checked),className:"w-4 h-4 rounded border-border bg-bg-primary accent-accent-primary"}),o.jsx("span",{className:"text-sm text-text-secondary",children:"This is a local provider"})]})]}),u===2&&o.jsxs("div",{className:"px-6 py-4 space-y-4",children:[o.jsx("div",{children:o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Backend type"}),o.jsx("select",{value:_,onChange:H=>x(H.target.value),"data-testid":"provider-modal-backend",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:ZB.map(H=>o.jsx("option",{value:H.value,children:H.label},H.value))})]}),o.jsx("button",{onClick:()=>q(!0),className:"px-3 h-[38px] bg-bg-primary border border-border rounded-lg hover:border-text-muted transition-colors flex items-center justify-center",title:"Provider-level defaults",children:o.jsx("svg",{className:"w-4 h-4 text-text-muted",viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z",clipRule:"evenodd"})})})]})}),v&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[o.jsx("span",{className:"w-4 h-4 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),"Fetching models..."]}),E&&o.jsxs("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-500 border border-red-500/20",children:[o.jsx("p",{children:E}),o.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["URL: ",p]}),o.jsx("button",{onClick:()=>Q(p),className:"mt-2 text-xs text-accent-primary hover:underline",children:"Retry"})]}),N.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Available Models"}),o.jsx("p",{className:"text-xs text-text-muted mb-3",children:"Configure each model's thinking behavior and parameters. Models without explicit config use provider defaults."})]}),o.jsx("div",{className:"space-y-2",children:N.map(H=>{var ee,te,ce,he,Te,Ae,Le,Pe,de,Ie,Se,me,je,nt,Mt,gt,Zt,ge,Ce,Oe,Ve,Ge,vt,Xe,bt,ct,en;return o.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[o.jsxs("button",{onClick:()=>D(A===H.id?null:H.id),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-tertiary transition-colors text-left",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-sm font-medium text-text-primary",children:H.id.split("/").pop()}),o.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[H.contextWindow.toLocaleString()," ctx"]})]}),o.jsx(Sr,{className:`w-4 h-4 text-text-muted transition-transform ${A===H.id?"rotate-180":""}`})]}),A===H.id&&o.jsxs("div",{className:"px-4 pb-4 border-t border-border pt-3 space-y-3",children:[o.jsxs("div",{className:"flex gap-3 items-end",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Context window (tokens)"}),o.jsx("input",{type:"number",value:((ee=V[H.id])==null?void 0:ee.contextWindow)??H.contextWindow,onChange:He=>J(H.id,{contextWindow:parseInt(He.target.value)||H.contextWindow}),className:"w-32 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),o.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary pb-1",children:[o.jsx("input",{type:"checkbox",checked:((te=V[H.id])==null?void 0:te.supportsVision)??!1,onChange:He=>J(H.id,{supportsVision:He.target.checked}),className:"accent-accent-primary"})," ","Supports vision"]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:((ce=V[H.id])==null?void 0:ce.thinkingEnabled)??!1,onChange:He=>J(H.id,{thinkingEnabled:He.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),o.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Thinking"})]}),((he=V[H.id])==null?void 0:he.thinkingEnabled)&&o.jsxs("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-primary/30",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Reasoning effort"}),o.jsx("input",{type:"text",value:((Te=V[H.id])==null?void 0:Te.thinkingLevel)??"max",onChange:He=>J(H.id,{thinkingLevel:He.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),o.jsx(q0,{kwargs:z,onChange:X,mode:"thinking",modelId:H.id,testResults:M,thinkingField:W,onSeeRaw:U,onTest:()=>se(H.id,"thinking")})]}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:((Ae=V[H.id])==null?void 0:Ae.nonThinkingEnabled)??!1,onChange:He=>J(H.id,{nonThinkingEnabled:He.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),o.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Non-thinking"})]}),((Le=V[H.id])==null?void 0:Le.nonThinkingEnabled)&&o.jsx("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:o.jsx(q0,{kwargs:ne,onChange:F,mode:"non-thinking",modelId:H.id,testResults:M,thinkingField:W,onSeeRaw:U,onTest:()=>se(H.id,"non-thinking")})})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-xs text-accent-primary cursor-pointer hover:underline",onClick:()=>{var He;return(He=document.getElementById(`adv-${H.id}`))==null?void 0:He.classList.toggle("hidden")},children:"▸ Advanced parameters"}),o.jsxs("div",{id:`adv-${H.id}`,className:"hidden mt-2 space-y-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Temperature"}),o.jsx("input",{type:"number",step:"0.1",value:((Pe=V[H.id])==null?void 0:Pe.temperature)??"",onChange:He=>J(H.id,{temperature:He.target.value?parseFloat(He.target.value):void 0}),placeholder:((Ie=(de=V[H.id])==null?void 0:de.defaultTemperature)==null?void 0:Ie.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary text-text-secondary"}),((Se=V[H.id])==null?void 0:Se.defaultTemperature)!==void 0&&o.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(me=V[H.id])==null?void 0:me.defaultTemperature]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top P"}),o.jsx("input",{type:"number",step:"0.05",value:((je=V[H.id])==null?void 0:je.topP)??"",onChange:He=>J(H.id,{topP:He.target.value?parseFloat(He.target.value):void 0}),placeholder:((Mt=(nt=V[H.id])==null?void 0:nt.defaultTopP)==null?void 0:Mt.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((gt=V[H.id])==null?void 0:gt.defaultTopP)!==void 0&&o.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Zt=V[H.id])==null?void 0:Zt.defaultTopP]})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top K"}),o.jsx("input",{type:"number",value:((ge=V[H.id])==null?void 0:ge.topK)??"",onChange:He=>J(H.id,{topK:He.target.value?parseInt(He.target.value):void 0}),placeholder:((Oe=(Ce=V[H.id])==null?void 0:Ce.defaultTopK)==null?void 0:Oe.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((Ve=V[H.id])==null?void 0:Ve.defaultTopK)!==void 0&&o.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Ge=V[H.id])==null?void 0:Ge.defaultTopK]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Max tokens"}),o.jsx("input",{type:"number",value:((vt=V[H.id])==null?void 0:vt.maxTokens)??"",onChange:He=>J(H.id,{maxTokens:He.target.value?parseInt(He.target.value):void 0}),placeholder:((bt=(Xe=V[H.id])==null?void 0:Xe.defaultMaxTokens)==null?void 0:bt.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((ct=V[H.id])==null?void 0:ct.defaultMaxTokens)!==void 0&&o.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(en=V[H.id])==null?void 0:en.defaultMaxTokens]})]})]})]})]})]})]},H.id)})})]})]}),u===3&&o.jsx("div",{className:"px-6 py-4 space-y-4",children:o.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx("span",{className:"text-sm font-medium text-text-primary",children:h||"Provider"}),o.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-accent-primary/20 text-accent-primary",children:ip(_)})]}),o.jsx("p",{className:"text-xs text-text-muted mb-3",children:p}),N.length>0&&o.jsxs("div",{className:"border-t border-border pt-3",children:[o.jsxs("p",{className:"text-xs text-text-secondary mb-2",children:["Models configured: ",o.jsx("strong",{children:N.length})]}),o.jsx("div",{className:"space-y-1",children:N.map(H=>{var ee,te;return o.jsxs("div",{className:"text-xs text-text-muted flex items-center gap-2",children:[o.jsxs("span",{children:["• ",H.id.split("/").pop()]}),o.jsxs("span",{className:"text-text-secondary",children:[H.contextWindow.toLocaleString()," ctx"]}),((ee=V[H.id])==null?void 0:ee.thinkingEnabled)&&o.jsx("span",{className:"text-accent-success",children:"thinking"}),((te=V[H.id])==null?void 0:te.nonThinkingEnabled)&&o.jsx("span",{className:"text-accent-warning",children:"non-thinking"})]},H.id)})})]})]})}),o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-border",children:[o.jsx("div",{children:u>1&&o.jsx("button",{onClick:()=>c(u-1),className:"text-sm text-text-muted hover:text-text-secondary transition-colors",children:"← Back"})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{onClick:t,className:"px-4 py-2 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),u<3?o.jsx("button",{onClick:()=>c(u+1),disabled:u===1&&!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:u===1?"Next — Test & Configure":"Next — Review"}):o.jsx("button",{onClick:Y,"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 transition-colors",children:"Save Provider"})]})]})]}),B&&o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:H=>{H.target===H.currentTarget&&q(!1)},children:o.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[480px] shadow-2xl",children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[o.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Provider-Level Defaults"}),o.jsx("button",{onClick:()=>q(!1),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),o.jsxs("div",{className:"px-6 py-4 space-y-4",children:[o.jsx("p",{className:"text-xs text-text-muted",children:"These apply to all models unless overridden per-model."}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Non-thinking mode params"}),o.jsx("input",{type:"text",defaultValue:'reasoning_effort: "none"',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Thinking mode params"}),o.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"})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Thinking response field ",o.jsx("span",{className:"text-text-muted",children:"(override)"})]}),o.jsx("input",{type:"text",value:W,onChange:H=>O(H.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"}),o.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)."})]})]}),o.jsx("div",{className:"flex justify-end px-6 py-4 border-t border-border",children:o.jsx("button",{onClick:()=>q(!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"})})]})}),P&&o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[70]",onClick:H=>{H.target===H.currentTarget&&U(null)},children:o.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[600px] max-h-[70vh] shadow-2xl flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border flex-shrink-0",children:[o.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Raw Response"}),o.jsx("button",{onClick:()=>U(null),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),o.jsx("pre",{className:"px-6 py-4 overflow-y-auto text-xs text-text-secondary font-mono whitespace-pre-wrap flex-1",children:P})]})})]}):null}function e8(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function t8(){var $;const[,e]=cr(),t=we(P=>P.currentSession),n=we(P=>P.setSessionProvider),[s,a]=R.useState(!1),[l,u]=R.useState([]),[c,h]=R.useState(null),f=R.useRef(null),[p,m]=R.useState(null),[_,x]=R.useState(!1),w=R.useRef(new Set),k=Bt(P=>P.providers),y=Bt(P=>P.activeProviderId),S=Bt(P=>P.defaultModelSelection),v=Bt(P=>P.activating),b=Bt(P=>P.activateProvider),E=Bt(P=>P.refreshModel),T=Bt(P=>P.refreshProviderModels);R.useEffect(()=>{function P(U){f.current&&!f.current.contains(U.target)&&(a(!1),u([]),w.current=new Set)}return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]),R.useEffect(()=>{if(s){const P=k.map(U=>U.id);u(P),P.forEach(U=>{w.current.has(U)||(w.current.add(U),q(U))})}},[s,k]);const N=k.find(P=>P.id===y),L=(N==null?void 0:N.status)==="disconnected",A=S?S.split("/").pop()??null:null,D=A?(($=A.split("/").pop())==null?void 0:$.replace(/-/g," "))??A:"detecting...",B=(P,U)=>S?S===`${P}/${U}`:!1,q=async P=>{h(P);try{await T(P)}catch{}finally{h(null)}},W=P=>{l.includes(P.id)?u(l.filter(U=>U!==P.id)):(u([...l,P.id]),q(P.id))},O=async P=>{if(P.id===y){W(P);return}t?(n(P.id,void 0),Bt.getState().syncFromSession(P.id,""),a(!1),u([])):await b(P.id)&&(a(!1),u([]))},V=P=>{W(P)},G=async(P,U)=>{P.stopPropagation(),w.current.delete(U),await q(U)},z=(P,U)=>{m({providerId:P,model:U}),x(!0)},X=p?k.find(P=>P.id===p.providerId):void 0,ne=()=>{m(null),x(!1)},F=async P=>{try{if(!(await Ne(`/api/providers/${P.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:P.name,url:P.url,backend:P.backend,apiKey:P.apiKey,isLocal:P.isLocal,thinkingField:P.thinkingField,models:P.models})})).ok)throw new Error("Failed to update provider");for(const J of P.models){const Q={};if(J.contextWindow!==void 0&&(Q.contextWindow=J.contextWindow),J.supportsVision!==void 0&&(Q.supportsVision=J.supportsVision),J.thinkingEnabled!==void 0&&(Q.thinkingEnabled=J.thinkingEnabled),J.thinkingLevel!==void 0&&(Q.thinkingLevel=J.thinkingLevel),J.nonThinkingEnabled!==void 0&&(Q.nonThinkingEnabled=J.nonThinkingEnabled),J.thinkingExtraKwargs!==void 0&&(Q.thinkingExtraKwargs=J.thinkingExtraKwargs),J.nonThinkingExtraKwargs!==void 0&&(Q.nonThinkingExtraKwargs=J.nonThinkingExtraKwargs),Object.keys(Q).length>0&&!(await Ne(`/api/providers/${P.id}/models/${encodeURIComponent(J.id)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)})).ok)throw new Error(`Failed to update model: ${J.id}`)}await Bt.getState().fetchConfig()}catch{}m(null),x(!1)},M=async(P,U)=>{if(t){n(P,U),Bt.getState().syncFromSession(P,U),u([]),a(!1);return}h("activating");try{Bt.getState().syncFromSession(P,U),u([]),a(!1);const J=await Ne(`/api/providers/${P}/activate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:U})});if(J.ok){const Q=await J.json();Bt.getState().syncFromSession(Q.activeProviderId,Q.model)}}catch{}finally{h(null)}};return k.length===0?o.jsxs("button",{type:"button",onClick:()=>E(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:L?"LLM server is offline. Click to retry.":A??"Click to refresh model",children:[L?o.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-sm text-accent-primary",children:D}),o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${N!=null&&N.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:N!=null&&N.isLocal?"local":"api"})]}),o.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):o.jsxs("div",{className:"relative",ref:f,children:[o.jsxs("button",{type:"button",onClick:()=>a(!s),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:[L?o.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-sm text-accent-primary",children:D}),o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${N!=null&&N.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:N!=null&&N.isLocal?"local":"api"})]}),o.jsx(Sr,{className:"w-3 h-3 text-text-muted transition-transform",rotate:s?180:0})]}),s&&o.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-72 bg-bg-secondary border border-border rounded-lg shadow-lg z-50 overflow-hidden max-h-[80vh] overflow-y-auto",children:[o.jsx("div",{className:"py-1",children:k.map(P=>{var U;return o.jsxs("div",{children:[o.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${P.id===y?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${v?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[o.jsxs("div",{onClick:()=>!v&&O(P),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[o.jsx("span",{className:`text-sm font-medium truncate ${P.id===y?"text-accent-primary":"text-text-primary"}`,children:P.name}),o.jsx("span",{className:"text-xs text-text-muted truncate",children:P.backend!=="auto"&&ip(P.backend)})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[P.id===y?o.jsx("span",{className:"text-accent-success",title:"Active",children:o.jsx(Mr,{className:"w-4 h-4"})}):o.jsx("span",{className:"w-4"}),o.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),G(J,P.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:o.jsx(lp,{className:`w-4 h-4 ${c===P.id?"animate-spin":""} ${P.id===y?"text-accent-primary":"text-text-muted"}`})}),o.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),V(P)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:o.jsx(Sr,{className:`w-4 h-4 transition-transform ${l.includes(P.id)?"rotate-180":""} ${P.id===y?"text-accent-primary":"text-text-muted"}`})})]})]}),l.includes(P.id)&&o.jsx("div",{className:"bg-bg-primary border-t border-border max-h-40 overflow-y-auto",children:c===P.id?o.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):(U=P.models)!=null&&U.length?P.models.map(J=>{var Q;return o.jsxs("button",{type:"button",onClick:()=>M(P.id,J.id),disabled:c==="activating",className:`w-full px-4 py-1.5 text-left hover:bg-bg-tertiary transition-colors text-sm flex items-center justify-between group ${c==="activating"?"opacity-50 cursor-wait":""} ${B(P.id,J.id)?"text-accent-primary":"text-text-secondary"}`,children:[o.jsx("span",{className:"truncate flex-1",children:((Q=J.id.split("/").pop())==null?void 0:Q.replace(/-/g," "))??J.id}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx("span",{className:"text-xs text-text-muted",children:e8(J.contextWindow)}),o.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),z(P.id,J)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:o.jsx(bj,{className:"w-3 h-3 text-text-muted"})})]}),B(P.id,J.id)&&o.jsx("span",{className:"text-accent-success flex-shrink-0 ml-1",children:o.jsx(Mr,{className:"w-3.5 h-3.5"})})]},J.id)}):o.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},P.id)})}),o.jsx("div",{className:"border-t border-border px-3 py-2",children:o.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),p&&_&&o.jsx(BC,{isOpen:!0,onClose:ne,onSave:F,initialStep:2,editProvider:{id:p.providerId,name:(X==null?void 0:X.name)??"",url:(X==null?void 0:X.url)??"",backend:(X==null?void 0:X.backend)??"auto",apiKey:X==null?void 0:X.apiKey,isLocal:X==null?void 0:X.isLocal,thinkingField:X==null?void 0:X.thinkingField,models:X==null?void 0:X.models},editModelId:p.model.id})]})}function n8({input:e,setInput:t,attachments:n,setAttachments:s,dragOver:a,setDragOver:l,errorMessage:u,setErrorMessage:c,scrollContainerRef:h,sessionId:f,sessionMode:p,showHistory:m,history:_,selectedIndex:x,openHistory:w,closeHistory:k,navigateUp:y,navigateDown:S,selectCurrent:v,isAutoScrollActive:b,setAutoScroll:E,onOpenMessageSearch:T,onOpenCommandsModal:N,onOpenWorkflowsModal:L,onSelectWorkflow:A,onSelectWorkflowWithSubGroup:D,clearInput:B}){const q=R.useRef(null),W=R.useRef(null),O=R.useRef(0),V=Pu(),G=we(ee=>ee.sendMessage),z=we(ee=>ee.stopGeneration),X=we(ee=>ee.cancelQueued),ne=we(ee=>ee.queuedMessages),F=R.useCallback(()=>{const ee=q.current;if(!ee)return;const te=e.length>=O.current;O.current=e.length,te||(ee.style.height="auto"),ee.style.height=`${Math.min(200,ee.scrollHeight)}px`},[e]);R.useEffect(()=>{if(!f)return;const ee=`openfox:draft:${f}`,te=localStorage.getItem(ee);te!==null&&t(te)},[f,t]),R.useEffect(()=>{var ee;(ee=q.current)==null||ee.focus(),F()},[f,F]),R.useEffect(()=>{if(!f)return;const ee=`openfox:draft:${f}`,te=setTimeout(()=>{e?localStorage.setItem(ee,e):localStorage.removeItem(ee)},500);return()=>clearTimeout(te)},[f,e]),R.useEffect(()=>{F()},[e,F]),R.useEffect(()=>{const ee=q.current;if(!ee)return;const te=async ce=>{var Te;if(document.activeElement!==ee)return;const he=(Te=ce.clipboardData)==null?void 0:Te.items;if(he){for(const Ae of Array.from(he))if(Ae.type.startsWith("image/")){ce.preventDefault();const Le=Ae.getAsFile();if(!Le)continue;await xm(Le,Pe=>s([...n,Pe]),c,{filename:"pasted-image"})}}};return ee.addEventListener("paste",te),()=>ee.removeEventListener("paste",te)},[n,s,c]);const M=ee=>{ee.preventDefault(),!(!e.trim()&&n.length===0)&&(G(e,n.length>0?n:void 0),B())},$=ee=>{if(m)switch(ee.key){case"Enter":{ee.preventDefault();const te=v();te&&(t(te),k());return}case"Escape":ee.preventDefault(),k(),V&&z();return;case"ArrowUp":ee.preventDefault(),y();return;case"ArrowDown":ee.preventDefault(),S();return}if(ee.key==="ArrowUp"&&e.trim()===""&&!m){ee.preventDefault(),w();return}ee.key==="Enter"&&!ee.shiftKey&&(ee.preventDefault(),M(ee))},P=R.useCallback(async ee=>{const te=ee.target.files;if(!(!te||te.length===0)){c(null);for(const ce of Array.from(te))await xm(ce,he=>s([...n,he]),c);W.current&&(W.current.value="")}},[n,s,c]),U=R.useCallback(ee=>{ee.preventDefault(),ee.stopPropagation(),l(!0)},[l]),J=R.useCallback(ee=>{ee.preventDefault(),ee.stopPropagation(),l(!1)},[l]),Q=R.useCallback(async ee=>{ee.preventDefault(),ee.stopPropagation(),l(!1),c(null);const te=ee.dataTransfer.files;if(!(!te||te.length===0))for(const ce of Array.from(te))await xm(ce,he=>s([...n,he]),c)},[n,s,l,c]),se=R.useCallback(ee=>{s(n.filter(te=>te.id!==ee))},[n,s]),Y=R.useCallback(()=>{var ee;(ee=W.current)==null||ee.click()},[]),H=()=>{var ee;!e.trim()&&n.length===0||((ee=h.current)==null||ee.scrollTo({top:h.current.scrollHeight,behavior:"smooth"}),G(e,n),B())};return o.jsxs("form",{onSubmit:M,className:"relative p-2 md:p-4 bg-secondary",children:[V&&o.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:o.jsx(jB,{})}),o.jsxs("div",{className:"absolute -top-8 right-2 md:right-4 z-10 flex items-center gap-2",children:[o.jsxs("button",{type:"button",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",onClick:()=>E(!b),children:[b?o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):o.jsx(Sr,{className:"w-3 h-3 text-text-muted"}),b?"live":"scroll to bottom"]}),o.jsxs("button",{type:"button",onClick:T,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:[o.jsx(cp,{}),"Browse history"]})]}),o.jsx("input",{ref:W,type:"file",accept:".png,.jpg,.jpeg,.gif",onChange:P,className:"hidden",multiple:!0}),u&&o.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:u}),n.length>0&&o.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(ee=>o.jsx(kB,{attachment:ee,onRemove:se},ee.id))}),m&&o.jsx(EB,{history:_,selectedIndex:x,onSelect:ee=>{t(ee),k()},onEscape:k,onNavigate:ee=>{ee==="up"?y():S()}}),o.jsx(FB,{messages:ne,onCancel:X}),o.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${a?"bg-accent-primary/10":"bg-primary"}`,onDragOver:U,onDragLeave:J,onDrop:Q,children:[o.jsx("textarea",{id:LS,ref:q,value:e,onChange:ee=>{t(ee.target.value),m&&k()},onKeyDown:$,placeholder:"What would you like to build?","data-testid":"chat-input-textarea",className:"flex-1 bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:"24px",maxHeight:"200px"},spellCheck:!1}),o.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[V&&o.jsxs("button",{type:"button",onClick:()=>z(),"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:[o.jsx(xS,{}),"Abort"]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("button",{type:"button",onClick:H,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"}),o.jsx($B,{onSendCommand:(ee,te,ce,he)=>{var Ae;te&&p!==te&&we.getState().switchMode(te);const Te=ce&&ce.trim()?`${ce.trim()}
|
|
296
|
+
|
|
297
|
+
${ee}`:ee;(Ae=h.current)==null||Ae.scrollTo({top:h.current.scrollHeight,behavior:"smooth"}),G(Te,he!=null&&he.length?he:void 0,{messageKind:"command",isSystemGenerated:!0}),B()},onSelectWorkflow:A,onSelectWorkflowWithSubGroup:D,onOpenCommandsManager:N,onOpenWorkflowsManager:L,onAttach:Y,textareaContent:e,attachments:n.length>0?n:void 0})]})]})]}),o.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(YB,{}),o.jsx(XB,{})]}),o.jsx(t8,{})]})]})}function r8(e){return e==="criterion"||e==="session_metadata"}function s8(e){var t,n;return e.role!=="assistant"||e.subAgentId||(t=e.content)!=null&&t.trim()||(n=e.thinkingContent)!=null&&n.trim()||!e.toolCalls||e.toolCalls.length===0?!1:e.toolCalls.every(s=>r8(s.name))}function i8(e,t=[]){const n=[];let s=null,a=[],l,u=1;const c=new Map,h=new Map,f=[];for(const x of t)x.type==="message"?c.set(x.message.id,x):x.type==="subagent"?h.set(x.subAgentId,x):x.type==="criteria-batch"&&f.push(x);let p=0;const m=()=>{if(a.length>0){const x=f[p];x&&x.type==="criteria-batch"&&x.toolCalls.length===a.length&&x.toolCalls.every((k,y)=>{var S;return k.id===((S=a[y])==null?void 0:S.id)})?n.push(x):n.push({type:"criteria-batch",toolCalls:[...a]}),p++,a=[]}},_=()=>{if(!s)return;const x=s,w=h.get(x.subAgentId);w&&w.type==="subagent"&&w.messages.length===x.messages.length&&w.messages.every((y,S)=>y===x.messages[S])?n.push(w):n.push({type:"subagent",subAgentId:x.subAgentId,subAgentType:x.subAgentType,messages:x.messages}),s=null};for(const x of e)if(x.role!=="tool"){if(x.contextWindowId&&l&&x.contextWindowId!==l&&(m(),_(),u++,n.push({type:"context-divider",windowSequence:u})),l=x.contextWindowId,s8(x)){_();for(const w of x.toolCalls)a.push(w);continue}if(m(),x.subAgentId&&x.subAgentType)s&&s.subAgentId===x.subAgentId?s.messages.push(x):(_(),s={subAgentId:x.subAgentId,subAgentType:x.subAgentType,messages:[x]});else{_();const w=c.get(x.id);w&&w.type==="message"&&w.message===x?n.push(w):n.push({type:"message",message:x})}}return m(),_(),n}function a8(e){const{year:t,month:n,day:s}=PS(e);return`${t}/${n}/${s} ${Uu(e)}`}function o8(e,t){return e.length<=t?e:e.substring(0,t)+"..."}const l8=10,c8=150;function u8(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 d8(e){return[...e].sort((s,a)=>new Date(a.timestamp).getTime()-new Date(s.timestamp).getTime()).slice(0,l8).reverse().map(s=>({id:s.id,content:s.content,timestamp:s.timestamp,formattedTimestamp:a8(s.timestamp),trimmedContent:o8(s.content,c8),sessionId:s.sessionId,sessionName:s.sessionName}))}function h8(e,t,n){const s=[],a=e.filter(l=>l.role==="user"&&!l.isSystemGenerated&&l.messageKind!=="auto-prompt");for(const l of a)s.push({id:l.id,content:l.content,timestamp:l.timestamp,sessionId:n??"",sessionName:"This session"});for(const l of t)n&&l.id===n||s.push(...u8(l));return d8(s)}function f8(e,t=[],n=null){const[s,a]=R.useState(0),[l,u]=R.useState(!1),c=R.useMemo(()=>h8(e,t,n),[e,t,n]),h=R.useCallback(()=>{c.length>0&&(a(c.length-1),u(!0))},[c.length]),f=R.useCallback(()=>{u(!1),a(0)},[]),p=R.useCallback(()=>{a(x=>c.length===0?x:x===0?c.length-1:x-1)},[c.length]),m=R.useCallback(()=>{a(x=>c.length===0?x:x===c.length-1?0:x+1)},[c.length]),_=R.useCallback(()=>{if(c.length===0||!l)return null;const x=c[s];return(x==null?void 0:x.content)??null},[c,s,l]);return{history:c,selectedIndex:s,showHistory:l,openHistory:h,closeHistory:f,navigateUp:p,navigateDown:m,selectCurrent:_}}R.memo(function({item:t}){const[n,s]=R.useState(!1);return t.type==="start"?o.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:[o.jsx("span",{className:"animate-pulse",children:"●"}),o.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&o.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[o.jsx("span",{className:"text-accent-success",children:"✓"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),o.jsx("button",{type:"button",onClick:()=>s(!n),className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:n?"Hide":"Show"})]}),n&&t.description&&o.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:o.jsx(us,{content:t.description})})]})]})});function m8({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t}={}){const n=e??!0,[s,a]=R.useState(""),[l,u]=R.useState([]),[c,h]=R.useState(!1),[f,p]=R.useState(null),[m,_]=R.useState(!1),[x,w]=R.useState(!1),[k,y]=R.useState(!1),[S,v]=R.useState(!1),[b,E]=R.useState(null),T=R.useRef(null),N=we(Se=>Se.currentSession),L=we(Se=>Se.messages),A=we(Se=>Se.streamingMessage),D=we(Se=>Se.sessions),B=we(Se=>Se.pendingQuestion),q=Pu(),W=we(Se=>Se.sendMessage),O=we(Se=>Se.acceptAndBuild),V=we(Se=>Se.stopGeneration),G=we(Se=>Se.launchRunner),z=mt(Se=>Se.defaults),X=mt(Se=>Se.userItems),ne=[...z,...X].filter(Se=>!Se.subagent),{history:F,selectedIndex:M,showHistory:$,openHistory:P,closeHistory:U,navigateUp:J,navigateDown:Q,selectCurrent:se}=f8(L,D,N==null?void 0:N.id);R.useEffect(()=>{const Se=me=>{E(me.detail.stats)};return window.addEventListener("open-turn-stats",Se),()=>window.removeEventListener("open-turn-stats",Se)},[]),R.useEffect(()=>{Et.getState().fetchWorkflows()},[]);const Y=R.useMemo(()=>A?L.map(Se=>Se.id===A.id?A:Se):L,[L,A]),H=R.useRef([]),ee=R.useMemo(()=>{const Se=i8(Y,H.current);return H.current=Se,Se},[Y]),{isAutoScrollActive:te,setAutoScroll:ce}=TC(T,N),he=R.useCallback(Se=>{var je;ce(!1);const me=document.querySelector(`[data-item-index="${Se}"]`);me&&(me.scrollIntoView({behavior:"smooth",block:"start"}),(je=me.closest('[data-testid="chat-scroll-container"]'))==null||je.scrollBy(0,-80))},[ce]);R.useEffect(()=>{const Se=me=>{const je=k||m||x||S||b;me.key==="Escape"&&q&&!je&&V(),me.key==="ScrollLock"&&ce(!te)};return window.addEventListener("keydown",Se),()=>window.removeEventListener("keydown",Se)},[q,V,te,k,m,x,S,b]);const Te=up();SS(Te.quickAction,()=>{y(!0)}),Uj(Te.agentSwitching,ne,Se=>{we.getState().switchMode(Se)});const Ae=(N==null?void 0:N.mode)==="planner",Le=(N==null?void 0:N.mode)==="builder",Pe=Se=>{const me=s.trim()?s:void 0,je=l.length>0?l:void 0;Ae?O(Se,me,je):Le&&G(me,je,Se),Ie()},de=(Se,me)=>{const je=s.trim()?s:void 0,nt=l.length>0?l:void 0;Ae?O(Se,je,nt,me):Le&&G(je,nt,Se,me),Ie()},Ie=()=>{a(""),u([]),N!=null&&N.id&&localStorage.removeItem(`openfox:draft:${N.id}`)};return o.jsxs(o.Fragment,{children:[o.jsxs(wT,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:t,messages:Y,children:[B&&o.jsx(aB,{question:B}),o.jsx(ET,{}),b&&o.jsx(jT,{stats:b,onClose:()=>E(null)}),o.jsx(oB,{}),o.jsx(sB,{displayItems:ee,scrollContainerRef:T,highlightedMessageId:null}),o.jsx(n8,{input:s,setInput:a,attachments:l,setAttachments:u,dragOver:c,setDragOver:h,errorMessage:f,setErrorMessage:p,scrollContainerRef:T,sessionId:N==null?void 0:N.id,sessionMode:N==null?void 0:N.mode,showHistory:$,history:F,selectedIndex:M,openHistory:P,closeHistory:U,navigateUp:J,navigateDown:Q,selectCurrent:se,isAutoScrollActive:te,setAutoScroll:ce,onOpenMessageSearch:()=>v(!0),onOpenCommandsModal:()=>_(!0),onOpenWorkflowsModal:()=>w(!0),onSelectWorkflow:Pe,onSelectWorkflowWithSubGroup:de,clearInput:Ie}),o.jsx(LC,{isOpen:m,onClose:()=>_(!1)}),o.jsx(OC,{isOpen:x,onClose:()=>w(!1)}),o.jsx(yB,{isOpen:k,onClose:()=>y(!1),onSearchMessages:()=>v(!0),isAutoScrollActive:te,onToggleAutoScroll:ce,textareaContent:s,onCloseComplete:DS,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(Se,me)=>{const je=await nn.getState().fetchCommand(Se);if(je){const nt=me!=null&&me.trim()?`${me.trim()}
|
|
298
|
+
|
|
299
|
+
${je.prompt}`:je.prompt;je.metadata.agentMode&&we.getState().switchMode(je.metadata.agentMode),W(nt,l!=null&&l.length?l:void 0,{messageKind:"command",isSystemGenerated:!0}),Ie()}},onSelectWorkflow:Se=>{const me=s.trim()||void 0,je=l.length>0?l:void 0;(N==null?void 0:N.mode)==="planner"?we.getState().acceptAndBuild(Se,me,je):we.getState().launchRunner(me,je,Se),Ie()}})]}),S&&o.jsx(CB,{isOpen:S,onClose:()=>v(!1),displayItems:ee,onNavigate:he})]})}function K0({isOpen:e,isRetry:t,onSubmit:n,onCancel:s}){const[a,l]=R.useState(""),u=R.useRef(null);R.useEffect(()=>{e&&(l(""),setTimeout(()=>{var h;return(h=u.current)==null?void 0:h.focus()},100))},[e]);const c=h=>{h.preventDefault(),a.trim()&&n(a)};return o.jsx(Dt,{isOpen:e,onClose:s,title:t?"Invalid Password":"Password Required",size:"sm",children:o.jsxs("form",{onSubmit:c,className:"space-y-4",children:[o.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."}),o.jsx($u,{ref:u,type:"password",value:a,onChange:h=>l(h.target.value),placeholder:"Enter password",autoFocus:!0}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(tt,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),o.jsx(tt,{type:"submit",disabled:!a.trim(),children:t?"Try Again":"Connect"})]})]})})}function p8({currentStep:e,totalSteps:t,labels:n,onStepClick:s}){return o.jsx("div",{className:"flex justify-center py-6",children:o.jsx("div",{className:"flex items-center",children:Array.from({length:t},(a,l)=>{const u=l+1,c=u<e,h=u===e;return o.jsxs("div",{className:"flex items-center",children:[o.jsx("button",{onClick:()=>s==null?void 0:s(u),className:`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors shrink-0 ${c?"bg-accent-primary text-text-primary hover:opacity-80":h?"bg-accent-primary text-text-primary":"bg-bg-tertiary text-text-muted"}`,children:c?"✓":u}),o.jsx("button",{onClick:()=>s==null?void 0:s(u),className:`ml-2 mr-4 text-sm whitespace-nowrap hidden sm:block ${h?"text-text-primary font-medium":"text-text-muted hover:text-text-secondary"}`,children:n[l]}),l<t-1&&o.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${c?"bg-accent-primary":"bg-border"}`})]},l)})})})}function g8({onNext:e}){const[t,n]=R.useState([]),[s,a]=R.useState([]),[l,u]=R.useState(!1),[c,h]=R.useState(null),[f,p]=R.useState(null);R.useEffect(()=>{m()},[]);async function m(){try{const b=await Ne("/api/providers");if(b.ok){const T=(await b.json()).providers.map(N=>({id:N.id,name:N.name,url:N.url,backend:N.backend,model:null,apiKey:N.apiKey,isLocal:N.isLocal,thinkingField:N.thinkingField,models:N.models}));n(T),a(T)}}catch{}}async function _(b){const E=b.id.startsWith("temp-"),T={name:b.name,url:b.url,backend:b.backend,apiKey:b.apiKey,isLocal:b.isLocal,thinkingField:b.thinkingField,models:b.models};try{if(E){const N=await Ne("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T)});if(N.ok){const L=await N.json(),A={...b,id:L.provider.id,model:null};a(D=>[...D,A]),n(D=>[...D,A])}}else await Ne(`/api/providers/${b.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(T)}),a(N=>N.map(L=>L.id===b.id?{...L,...b,model:null}:L)),n(N=>N.map(L=>L.id===b.id?{...L,...b,model:null}:L))}catch{if(E){const N={...b,model:null};a(L=>[...L,N])}}}function x(){h(null),u(!0)}function w(b){h(b),u(!0)}function k(){u(!1),h(null)}function y(b){p(b),t.some(T=>T.id===b)?Ne(`/api/providers/${b}`,{method:"DELETE"}).then(()=>{a(s.filter(T=>T.id!==b)),n(t.filter(T=>T.id!==b)),p(null)}).catch(()=>p(null)):(a(s.filter(T=>T.id!==b)),p(null))}function S(){const b=s.filter(E=>!E.id.startsWith("temp-"));e({providers:b})}const v=s.length>0;return o.jsxs("div",{className:"max-w-xl mx-auto",children:[o.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),o.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),o.jsxs("div",{className:"space-y-4",children:[s.length>0?o.jsx("div",{className:"space-y-2",children:s.map(b=>o.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:ip(b.backend)}),o.jsx("span",{className:"text-text-primary font-medium",children:b.name}),o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${b.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:b.isLocal?"local":"api"})]}),o.jsx("p",{className:"text-text-muted text-sm mt-1",children:b.url}),b.model&&o.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",b.model]})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>w(b),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary border border-border rounded transition-colors",children:"Edit"}),o.jsx("button",{onClick:()=>y(b.id),disabled:f===b.id,className:"p-2 text-text-muted hover:text-red-500 transition-colors disabled:opacity-50",title:"Remove provider",children:o.jsx(pl,{})})]})]},b.id))}):o.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:o.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),o.jsxs("button",{onClick:x,"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:[o.jsx(qs,{className:"w-4 h-4"}),"Add Provider"]}),o.jsx("button",{onClick:S,disabled:!v,"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"})]}),o.jsx(BC,{isOpen:l,onClose:k,onSave:_,initialStep:1,editProvider:c??void 0})]})}function x8({onNext:e}){const[t,n]=R.useState(""),[s,a]=R.useState(!1);return R.useEffect(()=>{Ne("/api/config").then(l=>l.json()).then(l=>{l.workdir?n(l.workdir):fetch("/api/directories?path="+encodeURIComponent("/home")).then(u=>u.json()).then(u=>{u.current&&n(u.current)}).catch(()=>{})}).catch(()=>{fetch("/api/directories?path="+encodeURIComponent("/home")).then(l=>l.json()).then(l=>{l.current&&n(l.current)}).catch(()=>{})})},[]),o.jsxs("div",{className:"max-w-xl mx-auto",children:[o.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),o.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"text",value:t,onChange:l=>n(l.target.value),placeholder:"/home/user/projects","data-testid":"onboarding-workdir-input",className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),o.jsx("button",{onClick:()=>a(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),s&&o.jsx(xp,{initialPath:t||void 0,onSelect:l=>{n(l),a(!1)},onClose:()=>a(!1)}),o.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 _8({onNext:e}){const[t,n]=R.useState(!1),[s,a]=R.useState("http://localhost:11434"),[l,u]=R.useState("qwen3.5:0.8b"),{copied:c,copy:h}=CC();R.useEffect(()=>{Ne("/api/config").then(p=>p.json()).then(p=>{p.visionFallback&&(n(p.visionFallback.enabled),a(p.visionFallback.url),u(p.visionFallback.model))}).catch(()=>{})},[]);function f(p){if(p){e({});return}e({visionFallback:{enabled:t,url:s,model:l,timeout:120}})}return o.jsxs("div",{className:"max-w-xl mx-auto",children:[o.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),o.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[o.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"To enable vision support, you need an Ollama server with a vision model:"}),o.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),o.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[o.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3.5:0.8b"}),o.jsx("button",{onClick:()=>h("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:c?o.jsx(Mr,{className:"w-4 h-4 text-accent-primary"}):o.jsx(vj,{className:"w-4 h-4"})})]})]}),o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:t,onChange:p=>n(p.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),o.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),t&&o.jsxs("div",{className:"space-y-4 pl-8",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),o.jsx("input",{type:"text",value:s,onChange:p=>a(p.target.value),placeholder:"http://localhost:11434",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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),o.jsx("input",{type:"text",value:l,onChange:p=>u(p.target.value),placeholder:"qwen3.5:0.8b",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"})]})]}),o.jsxs("div",{className:"flex items-center justify-between pt-4",children:[o.jsx("button",{onClick:()=>f(!0),"data-testid":"onboarding-skip-button",className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),o.jsx("button",{onClick:()=>f(!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 y8({onComplete:e}){const[t,n]=R.useState(1),[s,a]=R.useState(!1),[l,u]=R.useState({});async function c(m){u(_=>({..._,providers:m.providers})),n(2)}async function h(m){u(_=>({..._,...m})),n(3)}async function f(m){a(!0);try{if(!(await Ne("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:l.workdir,visionFallback:m.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(_){console.error("Failed to save onboarding data:",_),a(!1)}}const p=m=>{n(m)};return o.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[o.jsx(yl,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),o.jsx(p8,{currentStep:t,totalSteps:3,labels:["LLM Server","Projects Folder","Vision"],onStepClick:p}),o.jsx("div",{className:"max-w-xl mx-auto",children:s?o.jsxs("div",{className:"text-center",children:[o.jsx(qs,{className:"w-6 h-6"}),o.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):o.jsxs(o.Fragment,{children:[t===1&&o.jsx(g8,{onNext:c}),t===2&&o.jsx(x8,{onNext:h}),t===3&&o.jsx(_8,{onNext:f})]})})]})}const Y0="openfox_updated_to",X0="update_pending";function v8(){const[e,t]=R.useState(!1),n=localStorage.getItem(Y0),s=localStorage.getItem(X0);R.useEffect(()=>{if(!n||!s)return;const l=setTimeout(()=>t(!0),3e4);return()=>clearTimeout(l)},[n,s]);const a=()=>{localStorage.removeItem(Y0),localStorage.removeItem(X0),t(!0)};return e||s!=="true"||!n?null:o.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:[o.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:o.jsx(Mr,{className:"w-3 h-3 text-accent-primary"})}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),o.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),o.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:o.jsx(_S,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Ut.getState().loadUserPresets(),Ut.getState().applySavedTheme());function sg(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function zC(){return o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(_l,{})})}function b8({sidebarOpen:e,onSidebarToggle:t}){const[,n]=sp("/p/:projectId"),s=n==null?void 0:n.projectId,a=we(h=>h.connectionStatus),l=Lt(h=>h.currentProject),u=sg();return mj({canLoad:a==="connected"||u,projectId:s,currentProjectId:l==null?void 0:l.id}),!l||l.id!==s?o.jsx(zC,{}):o.jsxs(o.Fragment,{children:[o.jsx(zS,{projectId:s,isOpen:e,onClose:t}),o.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:o.jsx(PN,{})})]})}function S8({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:s}){const[,a]=sp("/p/:projectId/s/:sessionId"),l=a==null?void 0:a.projectId,u=a==null?void 0:a.sessionId,[,c]=cr(),h=we(k=>k.connectionStatus),f=we(k=>k.currentSession),p=we(k=>k.error),m=we(k=>k.clearError),_=Lt(k=>k.currentProject),x=sg();return pj({canLoad:h==="connected"||x,projectId:l,sessionId:u,currentProjectId:_==null?void 0:_.id,currentSessionId:f==null?void 0:f.id}),R.useEffect(()=>{(p==null?void 0:p.code)==="NOT_FOUND"&&l&&(m(),c(`/p/${l}`))},[p,l,m,c]),!_||_.id!==l?o.jsx(zC,{}):o.jsxs(o.Fragment,{children:[o.jsx(zS,{projectId:l,isOpen:e,onClose:t}),o.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:o.jsx(m8,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:s})})]})}function w8(){const e=Bt(n=>n.fetchConfig);function t(){e(),window.history.back()}return o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsx(y8,{onComplete:t})})}function C8(){const{connectionStatus:e}=dj(),t=Bt(G=>G.fetchConfig),n=Bt(G=>G.refreshProviderModels),s=Bt(G=>G.providers),a=Bt(G=>G.activeProviderId),[,l]=cr(),u=sg(),[c,h]=R.useState(!1);R.useEffect(()=>{(e==="connected"||u)&&t().then(()=>{h(!0),an.getState().getSettings([...J0,ze.DISPLAY_THEME,ze.DISPLAY_USER_PRESETS,ze.KEYBINDINGS])})},[e,u,t]),R.useEffect(()=>{c&&a&&n(a).then(()=>{const G=Bt.getState().defaultModelSelection;(G?G.split("/")[0]:null)!==a&&t()})},[c,a,n,t]);const f=an(G=>G.settings);R.useEffect(()=>{c&&s.length===0&&l("/onboarding")},[c,s.length]),R.useEffect(()=>{const{applyPreset:G,applyTokens:z,setFollowSystemTheme:X,initSystemThemeListener:ne}=Ut.getState(),F=f[ze.DISPLAY_THEME],M=f[ze.DISPLAY_USER_PRESETS],$=f[ze.DISPLAY_FOLLOW_SYSTEM_THEME];if(M&&localStorage.setItem("openfox:userPresets",M),F){localStorage.setItem("openfox:theme",F);try{const U=JSON.parse(F);U.preset&&U.tokens?(G(U.preset),Ut.setState({basePreset:U.preset}),z(U.tokens)):U.preset?G(U.preset):U.tokens&&z(U.tokens)}catch{G("dark")}}else G("system");$!==void 0&&Ut.getState().followSystemTheme!==($==="true")&&X($==="true");const P=ne();return()=>P()},[f[ze.DISPLAY_THEME],f[ze.DISPLAY_USER_PRESETS]]);const p=()=>{const G=localStorage.getItem("openfox:leftSidebar");return G!==null?G==="true":!0},m=()=>{const G=localStorage.getItem("openfox:rightSidebar");return G!==null?G==="true":!0},[_,x]=R.useState(p),[w,k]=R.useState(m),[y,S]=R.useState(!1),[v,b]=R.useState(!1),[E,T]=R.useState(!1),N=x2();R.useEffect(()=>{const G=()=>{T(window.innerWidth<768)};return G(),window.addEventListener("resize",G),()=>window.removeEventListener("resize",G)},[]);const L=E?y:_,A=E?v:w,D=()=>{E?S(!y):x(!_)},B=()=>{E?b(!v):k(!w)};R.useEffect(()=>{E||localStorage.setItem("openfox:leftSidebar",String(_))},[_,E]),R.useEffect(()=>{E||localStorage.setItem("openfox:rightSidebar",String(w))},[w,E]),R.useEffect(()=>{(e==="connected"||u)&&t()},[e,t,u]);const q=we(G=>G.showPasswordModal),W=we(G=>G.passwordModalRetry),O=we(G=>G.submitPassword),V=we(G=>G.cancelPassword);return e!=="connected"&&!q&&!u?o.jsxs(o.Fragment,{children:[o.jsx(K0,{isOpen:!0,isRetry:W,onSubmit:O,onCancel:V}),o.jsx("div",{className:"h-screen flex items-center justify-center",children:o.jsx(vN,{text:"Connecting to server..."})})]}):o.jsxs(o.Fragment,{children:[o.jsx(K0,{isOpen:q,isRetry:W,onSubmit:O,onCancel:V}),o.jsxs("div",{className:"flex flex-col",style:{height:E?`calc(${N.offsetTop}px + ${N.height}px)`:"100vh"},children:[o.jsx(RN,{}),o.jsx(jN,{onMenuClick:D,onCriteriaToggle:B}),o.jsx("div",{className:"flex-1 flex overflow-hidden",children:o.jsxs(z2,{children:[o.jsx(Ho,{path:"/onboarding",children:o.jsx(w8,{})}),o.jsx(Ho,{path:"/p/:projectId/s/:sessionId",children:o.jsx(S8,{sidebarOpen:L,onSidebarToggle:D,rightSidebarOpen:A,onRightSidebarToggle:B})}),o.jsx(Ho,{path:"/p/:projectId/new",children:o.jsx(IN,{})}),o.jsx(Ho,{path:"/p/:projectId",children:o.jsx(b8,{sidebarOpen:L,onSidebarToggle:D})}),o.jsx(Ho,{path:"/",children:o.jsx(MN,{})})]})})]}),o.jsx(v8,{})]})}h2.createRoot(document.getElementById("root")).render(o.jsx($s.StrictMode,{children:o.jsx(C8,{})}));
|